@wordpress/block-editor 10.4.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (638) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +0 -1
  3. package/build/autocompleters/block.js +2 -6
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/autocompleters/link.js +2 -0
  6. package/build/autocompleters/link.js.map +1 -1
  7. package/build/components/block-card/index.js +51 -3
  8. package/build/components/block-card/index.js.map +1 -1
  9. package/build/components/block-draggable/index.native.js +46 -39
  10. package/build/components/block-draggable/index.native.js.map +1 -1
  11. package/build/components/block-edit/edit.js +4 -3
  12. package/build/components/block-edit/edit.js.map +1 -1
  13. package/build/components/block-edit/edit.native.js +4 -7
  14. package/build/components/block-edit/edit.native.js.map +1 -1
  15. package/build/components/block-inspector/index.js +35 -33
  16. package/build/components/block-inspector/index.js.map +1 -1
  17. package/build/components/block-list/block-list-context.native.js +5 -8
  18. package/build/components/block-list/block-list-context.native.js.map +1 -1
  19. package/build/components/block-list/block.js +55 -24
  20. package/build/components/block-list/block.js.map +1 -1
  21. package/build/components/block-list/block.native.js +61 -28
  22. package/build/components/block-list/block.native.js.map +1 -1
  23. package/build/components/block-lock/menu-item.js +1 -1
  24. package/build/components/block-lock/menu-item.js.map +1 -1
  25. package/build/components/block-lock/modal.js +16 -9
  26. package/build/components/block-lock/modal.js.map +1 -1
  27. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
  28. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  29. package/build/components/block-pattern-setup/index.js +3 -2
  30. package/build/components/block-pattern-setup/index.js.map +1 -1
  31. package/build/components/block-patterns-list/index.js +33 -11
  32. package/build/components/block-patterns-list/index.js.map +1 -1
  33. package/build/components/block-preview/auto.js +9 -3
  34. package/build/components/block-preview/auto.js.map +1 -1
  35. package/build/components/block-preview/index.js +5 -9
  36. package/build/components/block-preview/index.js.map +1 -1
  37. package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
  38. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  39. package/build/components/block-styles/utils.js +3 -3
  40. package/build/components/block-styles/utils.js.map +1 -1
  41. package/build/components/block-switcher/index.js +19 -4
  42. package/build/components/block-switcher/index.js.map +1 -1
  43. package/build/components/block-toolbar/index.js +5 -1
  44. package/build/components/block-toolbar/index.js.map +1 -1
  45. package/build/components/block-tools/insertion-point.js +8 -49
  46. package/build/components/block-tools/insertion-point.js.map +1 -1
  47. package/build/components/block-tools/selected-block-popover.js +27 -4
  48. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  49. package/build/components/block-variation-picker/index.js +1 -2
  50. package/build/components/block-variation-picker/index.js.map +1 -1
  51. package/build/components/colors/with-colors.js +4 -3
  52. package/build/components/colors/with-colors.js.map +1 -1
  53. package/build/components/font-sizes/fluid-utils.js +24 -40
  54. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  55. package/build/components/font-sizes/with-font-sizes.js +7 -5
  56. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  57. package/build/components/height-control/index.js +115 -0
  58. package/build/components/height-control/index.js.map +1 -0
  59. package/build/components/iframe/index.js +11 -8
  60. package/build/components/iframe/index.js.map +1 -1
  61. package/build/components/image-editor/use-save-image.js +2 -0
  62. package/build/components/image-editor/use-save-image.js.map +1 -1
  63. package/build/components/image-editor/zoom-dropdown.js +1 -0
  64. package/build/components/image-editor/zoom-dropdown.js.map +1 -1
  65. package/build/components/index.js +18 -0
  66. package/build/components/index.js.map +1 -1
  67. package/build/components/inner-blocks/index.js +25 -9
  68. package/build/components/inner-blocks/index.js.map +1 -1
  69. package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
  70. package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  71. package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  72. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  73. package/build/components/inserter/block-patterns-tab.js +25 -46
  74. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  75. package/build/components/inserter/block-types-tab.js +3 -1
  76. package/build/components/inserter/block-types-tab.js.map +1 -1
  77. package/build/components/inserter/hooks/use-debounced-input.js +27 -0
  78. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
  79. package/build/components/inserter/index.js +8 -3
  80. package/build/components/inserter/index.js.map +1 -1
  81. package/build/components/inserter/index.native.js +3 -4
  82. package/build/components/inserter/index.native.js.map +1 -1
  83. package/build/components/inserter/media-tab/hooks.js +103 -0
  84. package/build/components/inserter/media-tab/hooks.js.map +1 -0
  85. package/build/components/inserter/media-tab/index.js +32 -0
  86. package/build/components/inserter/media-tab/index.js.map +1 -0
  87. package/build/components/inserter/media-tab/media-list.js +100 -0
  88. package/build/components/inserter/media-tab/media-list.js.map +1 -0
  89. package/build/components/inserter/media-tab/media-panel.js +96 -0
  90. package/build/components/inserter/media-tab/media-panel.js.map +1 -0
  91. package/build/components/inserter/media-tab/media-tab.js +120 -0
  92. package/build/components/inserter/media-tab/media-tab.js.map +1 -0
  93. package/build/components/inserter/media-tab/utils.js +54 -0
  94. package/build/components/inserter/media-tab/utils.js.map +1 -0
  95. package/build/components/inserter/menu.js +35 -12
  96. package/build/components/inserter/menu.js.map +1 -1
  97. package/build/components/inserter/mobile-tab-navigation.js +70 -0
  98. package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
  99. package/build/components/inserter/quick-inserter.js +1 -0
  100. package/build/components/inserter/quick-inserter.js.map +1 -1
  101. package/build/components/inserter/reusable-blocks-tab.js +4 -1
  102. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  103. package/build/components/inserter/search-results.js +3 -1
  104. package/build/components/inserter/search-results.js.map +1 -1
  105. package/build/components/inserter/tabs.js +16 -2
  106. package/build/components/inserter/tabs.js.map +1 -1
  107. package/build/components/inserter-list-item/index.js +4 -1
  108. package/build/components/inserter-list-item/index.js.map +1 -1
  109. package/build/components/inspector-controls/groups.js +2 -0
  110. package/build/components/inspector-controls/groups.js.map +1 -1
  111. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
  112. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  113. package/build/components/inspector-controls-tabs/index.js +71 -0
  114. package/build/components/inspector-controls-tabs/index.js.map +1 -0
  115. package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
  116. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  117. package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
  118. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  119. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
  120. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  121. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
  122. package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  123. package/build/components/inspector-controls-tabs/utils.js +37 -0
  124. package/build/components/inspector-controls-tabs/utils.js.map +1 -0
  125. package/build/components/link-control/index.js +19 -34
  126. package/build/components/link-control/index.js.map +1 -1
  127. package/build/components/link-control/search-input.js +1 -2
  128. package/build/components/link-control/search-input.js.map +1 -1
  129. package/build/components/link-control/use-internal-input-value.js +26 -0
  130. package/build/components/link-control/use-internal-input-value.js.map +1 -0
  131. package/build/components/list-view/block.js +10 -5
  132. package/build/components/list-view/block.js.map +1 -1
  133. package/build/components/list-view/branch.js +22 -15
  134. package/build/components/list-view/branch.js.map +1 -1
  135. package/build/components/media-upload/index.native.js +2 -3
  136. package/build/components/media-upload/index.native.js.map +1 -1
  137. package/build/components/off-canvas-editor/appender.js +104 -0
  138. package/build/components/off-canvas-editor/appender.js.map +1 -0
  139. package/build/components/off-canvas-editor/block-contents.js +100 -0
  140. package/build/components/off-canvas-editor/block-contents.js.map +1 -0
  141. package/build/components/off-canvas-editor/block-edit-button.js +50 -0
  142. package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
  143. package/build/components/off-canvas-editor/block-select-button.js +119 -0
  144. package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
  145. package/build/components/off-canvas-editor/block.js +324 -0
  146. package/build/components/off-canvas-editor/block.js.map +1 -0
  147. package/build/components/off-canvas-editor/branch.js +179 -0
  148. package/build/components/off-canvas-editor/branch.js.map +1 -0
  149. package/build/components/off-canvas-editor/context.js +19 -0
  150. package/build/components/off-canvas-editor/context.js.map +1 -0
  151. package/build/components/off-canvas-editor/drop-indicator.js +118 -0
  152. package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
  153. package/build/components/off-canvas-editor/expander.js +41 -0
  154. package/build/components/off-canvas-editor/expander.js.map +1 -0
  155. package/build/components/off-canvas-editor/index.js +213 -0
  156. package/build/components/off-canvas-editor/index.js.map +1 -0
  157. package/build/components/off-canvas-editor/leaf.js +60 -0
  158. package/build/components/off-canvas-editor/leaf.js.map +1 -0
  159. package/build/components/off-canvas-editor/link-ui.js +185 -0
  160. package/build/components/off-canvas-editor/link-ui.js.map +1 -0
  161. package/build/components/off-canvas-editor/update-attributes.js +108 -0
  162. package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
  163. package/build/components/off-canvas-editor/use-block-selection.js +139 -0
  164. package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
  165. package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
  166. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  167. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
  168. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  169. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
  170. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  171. package/build/components/off-canvas-editor/utils.js +60 -0
  172. package/build/components/off-canvas-editor/utils.js.map +1 -0
  173. package/build/components/rich-text/format-toolbar/index.js +8 -4
  174. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  175. package/build/components/rich-text/index.js +3 -3
  176. package/build/components/rich-text/index.js.map +1 -1
  177. package/build/components/rich-text/index.native.js +0 -2
  178. package/build/components/rich-text/index.native.js.map +1 -1
  179. package/build/components/rich-text/use-insert-replacement-text.js +43 -0
  180. package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
  181. package/build/components/rich-text/use-undo-automatic-change.js +9 -1
  182. package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
  183. package/build/components/rich-text/utils.js +1 -19
  184. package/build/components/rich-text/utils.js.map +1 -1
  185. package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
  186. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  187. package/build/components/ungroup-button/index.native.js +4 -2
  188. package/build/components/ungroup-button/index.native.js.map +1 -1
  189. package/build/components/url-input/index.js +46 -43
  190. package/build/components/url-input/index.js.map +1 -1
  191. package/build/components/url-popover/index.js +31 -2
  192. package/build/components/url-popover/index.js.map +1 -1
  193. package/build/components/use-block-display-information/index.js +8 -4
  194. package/build/components/use-block-display-information/index.js.map +1 -1
  195. package/build/components/use-setting/index.js +10 -2
  196. package/build/components/use-setting/index.js.map +1 -1
  197. package/build/hooks/child-layout.js +209 -0
  198. package/build/hooks/child-layout.js.map +1 -0
  199. package/build/hooks/color-panel.js +17 -1
  200. package/build/hooks/color-panel.js.map +1 -1
  201. package/build/hooks/color.js +1 -1
  202. package/build/hooks/color.js.map +1 -1
  203. package/build/hooks/content-lock-ui.js +14 -7
  204. package/build/hooks/content-lock-ui.js.map +1 -1
  205. package/build/hooks/dimensions.js +65 -16
  206. package/build/hooks/dimensions.js.map +1 -1
  207. package/build/hooks/layout.js +59 -3
  208. package/build/hooks/layout.js.map +1 -1
  209. package/build/hooks/margin.js +4 -2
  210. package/build/hooks/margin.js.map +1 -1
  211. package/build/hooks/min-height.js +139 -0
  212. package/build/hooks/min-height.js.map +1 -0
  213. package/build/hooks/padding.js +4 -2
  214. package/build/hooks/padding.js.map +1 -1
  215. package/build/hooks/style.js +3 -2
  216. package/build/hooks/style.js.map +1 -1
  217. package/build/layouts/flex.js +22 -21
  218. package/build/layouts/flex.js.map +1 -1
  219. package/build/store/actions.js +26 -0
  220. package/build/store/actions.js.map +1 -1
  221. package/build/store/reducer.js +420 -265
  222. package/build/store/reducer.js.map +1 -1
  223. package/build/store/selectors.js +73 -49
  224. package/build/store/selectors.js.map +1 -1
  225. package/build/utils/sorting.js +63 -0
  226. package/build/utils/sorting.js.map +1 -0
  227. package/build-module/autocompleters/block.js +2 -6
  228. package/build-module/autocompleters/block.js.map +1 -1
  229. package/build-module/autocompleters/link.js +2 -0
  230. package/build-module/autocompleters/link.js.map +1 -1
  231. package/build-module/components/block-card/index.js +45 -3
  232. package/build-module/components/block-card/index.js.map +1 -1
  233. package/build-module/components/block-draggable/index.native.js +40 -31
  234. package/build-module/components/block-draggable/index.native.js.map +1 -1
  235. package/build-module/components/block-edit/edit.js +4 -2
  236. package/build-module/components/block-edit/edit.js.map +1 -1
  237. package/build-module/components/block-edit/edit.native.js +4 -6
  238. package/build-module/components/block-edit/edit.native.js.map +1 -1
  239. package/build-module/components/block-inspector/index.js +32 -30
  240. package/build-module/components/block-inspector/index.js.map +1 -1
  241. package/build-module/components/block-list/block-list-context.native.js +5 -8
  242. package/build-module/components/block-list/block-list-context.native.js.map +1 -1
  243. package/build-module/components/block-list/block.js +55 -25
  244. package/build-module/components/block-list/block.js.map +1 -1
  245. package/build-module/components/block-list/block.native.js +61 -28
  246. package/build-module/components/block-list/block.native.js.map +1 -1
  247. package/build-module/components/block-lock/menu-item.js +2 -2
  248. package/build-module/components/block-lock/menu-item.js.map +1 -1
  249. package/build-module/components/block-lock/modal.js +17 -10
  250. package/build-module/components/block-lock/modal.js.map +1 -1
  251. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
  252. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  253. package/build-module/components/block-pattern-setup/index.js +3 -2
  254. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  255. package/build-module/components/block-patterns-list/index.js +35 -13
  256. package/build-module/components/block-patterns-list/index.js.map +1 -1
  257. package/build-module/components/block-preview/auto.js +9 -3
  258. package/build-module/components/block-preview/auto.js.map +1 -1
  259. package/build-module/components/block-preview/index.js +5 -8
  260. package/build-module/components/block-preview/index.js.map +1 -1
  261. package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
  262. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  263. package/build-module/components/block-styles/utils.js +3 -3
  264. package/build-module/components/block-styles/utils.js.map +1 -1
  265. package/build-module/components/block-switcher/index.js +19 -4
  266. package/build-module/components/block-switcher/index.js.map +1 -1
  267. package/build-module/components/block-toolbar/index.js +6 -2
  268. package/build-module/components/block-toolbar/index.js.map +1 -1
  269. package/build-module/components/block-tools/insertion-point.js +8 -49
  270. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  271. package/build-module/components/block-tools/selected-block-popover.js +27 -5
  272. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  273. package/build-module/components/block-variation-picker/index.js +1 -2
  274. package/build-module/components/block-variation-picker/index.js.map +1 -1
  275. package/build-module/components/colors/with-colors.js +5 -4
  276. package/build-module/components/colors/with-colors.js.map +1 -1
  277. package/build-module/components/font-sizes/fluid-utils.js +24 -40
  278. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  279. package/build-module/components/font-sizes/with-font-sizes.js +8 -6
  280. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  281. package/build-module/components/height-control/index.js +103 -0
  282. package/build-module/components/height-control/index.js.map +1 -0
  283. package/build-module/components/iframe/index.js +11 -8
  284. package/build-module/components/iframe/index.js.map +1 -1
  285. package/build-module/components/image-editor/use-save-image.js +2 -0
  286. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  287. package/build-module/components/image-editor/zoom-dropdown.js +1 -0
  288. package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
  289. package/build-module/components/index.js +2 -0
  290. package/build-module/components/index.js.map +1 -1
  291. package/build-module/components/inner-blocks/index.js +27 -11
  292. package/build-module/components/inner-blocks/index.js.map +1 -1
  293. package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
  294. package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
  295. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  296. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
  297. package/build-module/components/inserter/block-patterns-tab.js +27 -49
  298. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  299. package/build-module/components/inserter/block-types-tab.js +3 -2
  300. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  301. package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
  302. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
  303. package/build-module/components/inserter/index.js +8 -3
  304. package/build-module/components/inserter/index.js.map +1 -1
  305. package/build-module/components/inserter/index.native.js +3 -5
  306. package/build-module/components/inserter/index.native.js.map +1 -1
  307. package/build-module/components/inserter/media-tab/hooks.js +89 -0
  308. package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
  309. package/build-module/components/inserter/media-tab/index.js +4 -0
  310. package/build-module/components/inserter/media-tab/index.js.map +1 -0
  311. package/build-module/components/inserter/media-tab/media-list.js +86 -0
  312. package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
  313. package/build-module/components/inserter/media-tab/media-panel.js +77 -0
  314. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
  315. package/build-module/components/inserter/media-tab/media-tab.js +100 -0
  316. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
  317. package/build-module/components/inserter/media-tab/utils.js +45 -0
  318. package/build-module/components/inserter/media-tab/utils.js.map +1 -0
  319. package/build-module/components/inserter/menu.js +33 -12
  320. package/build-module/components/inserter/menu.js.map +1 -1
  321. package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
  322. package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
  323. package/build-module/components/inserter/quick-inserter.js +1 -0
  324. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  325. package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
  326. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  327. package/build-module/components/inserter/search-results.js +3 -2
  328. package/build-module/components/inserter/search-results.js.map +1 -1
  329. package/build-module/components/inserter/tabs.js +15 -2
  330. package/build-module/components/inserter/tabs.js.map +1 -1
  331. package/build-module/components/inserter-list-item/index.js +5 -2
  332. package/build-module/components/inserter-list-item/index.js.map +1 -1
  333. package/build-module/components/inspector-controls/groups.js +2 -0
  334. package/build-module/components/inspector-controls/groups.js.map +1 -1
  335. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
  336. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
  337. package/build-module/components/inspector-controls-tabs/index.js +56 -0
  338. package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
  339. package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
  340. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
  341. package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
  342. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
  343. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
  344. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
  345. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
  346. package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
  347. package/build-module/components/inspector-controls-tabs/utils.js +26 -0
  348. package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
  349. package/build-module/components/link-control/index.js +18 -34
  350. package/build-module/components/link-control/index.js.map +1 -1
  351. package/build-module/components/link-control/search-input.js +1 -2
  352. package/build-module/components/link-control/search-input.js.map +1 -1
  353. package/build-module/components/link-control/use-internal-input-value.js +18 -0
  354. package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
  355. package/build-module/components/list-view/block.js +10 -5
  356. package/build-module/components/list-view/block.js.map +1 -1
  357. package/build-module/components/list-view/branch.js +21 -14
  358. package/build-module/components/list-view/branch.js.map +1 -1
  359. package/build-module/components/media-upload/index.native.js +2 -4
  360. package/build-module/components/media-upload/index.native.js.map +1 -1
  361. package/build-module/components/off-canvas-editor/appender.js +89 -0
  362. package/build-module/components/off-canvas-editor/appender.js.map +1 -0
  363. package/build-module/components/off-canvas-editor/block-contents.js +85 -0
  364. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
  365. package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
  366. package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
  367. package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
  368. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
  369. package/build-module/components/off-canvas-editor/block.js +298 -0
  370. package/build-module/components/off-canvas-editor/block.js.map +1 -0
  371. package/build-module/components/off-canvas-editor/branch.js +164 -0
  372. package/build-module/components/off-canvas-editor/branch.js.map +1 -0
  373. package/build-module/components/off-canvas-editor/context.js +7 -0
  374. package/build-module/components/off-canvas-editor/context.js.map +1 -0
  375. package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
  376. package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
  377. package/build-module/components/off-canvas-editor/expander.js +32 -0
  378. package/build-module/components/off-canvas-editor/expander.js.map +1 -0
  379. package/build-module/components/off-canvas-editor/index.js +189 -0
  380. package/build-module/components/off-canvas-editor/index.js.map +1 -0
  381. package/build-module/components/off-canvas-editor/leaf.js +45 -0
  382. package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
  383. package/build-module/components/off-canvas-editor/link-ui.js +165 -0
  384. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
  385. package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
  386. package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
  387. package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
  388. package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
  389. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
  390. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
  391. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
  392. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
  393. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
  394. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
  395. package/build-module/components/off-canvas-editor/utils.js +44 -0
  396. package/build-module/components/off-canvas-editor/utils.js.map +1 -0
  397. package/build-module/components/rich-text/format-toolbar/index.js +6 -2
  398. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  399. package/build-module/components/rich-text/index.js +2 -3
  400. package/build-module/components/rich-text/index.js.map +1 -1
  401. package/build-module/components/rich-text/index.native.js +0 -2
  402. package/build-module/components/rich-text/index.native.js.map +1 -1
  403. package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
  404. package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
  405. package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
  406. package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
  407. package/build-module/components/rich-text/utils.js +1 -16
  408. package/build-module/components/rich-text/utils.js.map +1 -1
  409. package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
  410. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  411. package/build-module/components/ungroup-button/index.native.js +3 -2
  412. package/build-module/components/ungroup-button/index.native.js.map +1 -1
  413. package/build-module/components/url-input/index.js +46 -43
  414. package/build-module/components/url-input/index.js.map +1 -1
  415. package/build-module/components/url-popover/index.js +30 -3
  416. package/build-module/components/url-popover/index.js.map +1 -1
  417. package/build-module/components/use-block-display-information/index.js +9 -5
  418. package/build-module/components/use-block-display-information/index.js.map +1 -1
  419. package/build-module/components/use-setting/index.js +9 -2
  420. package/build-module/components/use-setting/index.js.map +1 -1
  421. package/build-module/hooks/child-layout.js +189 -0
  422. package/build-module/hooks/child-layout.js.map +1 -0
  423. package/build-module/hooks/color-panel.js +17 -1
  424. package/build-module/hooks/color-panel.js.map +1 -1
  425. package/build-module/hooks/color.js +1 -1
  426. package/build-module/hooks/color.js.map +1 -1
  427. package/build-module/hooks/content-lock-ui.js +16 -9
  428. package/build-module/hooks/content-lock-ui.js.map +1 -1
  429. package/build-module/hooks/dimensions.js +60 -16
  430. package/build-module/hooks/dimensions.js.map +1 -1
  431. package/build-module/hooks/layout.js +57 -2
  432. package/build-module/hooks/layout.js.map +1 -1
  433. package/build-module/hooks/margin.js +4 -2
  434. package/build-module/hooks/margin.js.map +1 -1
  435. package/build-module/hooks/min-height.js +116 -0
  436. package/build-module/hooks/min-height.js.map +1 -0
  437. package/build-module/hooks/padding.js +4 -2
  438. package/build-module/hooks/padding.js.map +1 -1
  439. package/build-module/hooks/style.js +4 -3
  440. package/build-module/hooks/style.js.map +1 -1
  441. package/build-module/layouts/flex.js +23 -22
  442. package/build-module/layouts/flex.js.map +1 -1
  443. package/build-module/store/actions.js +22 -0
  444. package/build-module/store/actions.js.map +1 -1
  445. package/build-module/store/reducer.js +415 -265
  446. package/build-module/store/reducer.js.map +1 -1
  447. package/build-module/store/selectors.js +66 -48
  448. package/build-module/store/selectors.js.map +1 -1
  449. package/build-module/utils/sorting.js +56 -0
  450. package/build-module/utils/sorting.js.map +1 -0
  451. package/build-style/content-rtl.css +701 -0
  452. package/build-style/content.css +701 -0
  453. package/build-style/default-editor-styles-rtl.css +14 -0
  454. package/build-style/default-editor-styles.css +14 -0
  455. package/build-style/style-rtl.css +305 -668
  456. package/build-style/style.css +305 -668
  457. package/package.json +32 -30
  458. package/src/autocompleters/block.js +2 -6
  459. package/src/autocompleters/link.js +2 -0
  460. package/src/components/alignment-control/README.md +1 -1
  461. package/src/components/alignment-control/test/index.js +4 -1
  462. package/src/components/block-alignment-control/test/index.js +4 -1
  463. package/src/components/block-alignment-control/test/index.native.js +4 -4
  464. package/src/components/block-card/index.js +46 -2
  465. package/src/components/block-card/style.scss +4 -0
  466. package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
  467. package/src/components/block-draggable/content.scss +20 -0
  468. package/src/components/block-draggable/index.native.js +54 -40
  469. package/src/components/block-draggable/style.scss +0 -21
  470. package/src/components/block-draggable/test/helpers.native.js +7 -9
  471. package/src/components/block-draggable/test/index.native.js +35 -45
  472. package/src/components/block-edit/edit.js +5 -2
  473. package/src/components/block-edit/edit.native.js +5 -6
  474. package/src/components/block-inspector/index.js +96 -81
  475. package/src/components/block-inspector/style.scss +9 -1
  476. package/src/components/block-list/block-list-context.native.js +5 -8
  477. package/src/components/block-list/block.js +74 -23
  478. package/src/components/block-list/block.native.js +78 -23
  479. package/src/components/block-list/{style.scss → content.scss} +11 -20
  480. package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
  481. package/src/components/block-lock/menu-item.js +5 -2
  482. package/src/components/block-lock/modal.js +19 -36
  483. package/src/components/block-lock/style.scss +8 -17
  484. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
  485. package/src/components/block-mover/style.scss +0 -1
  486. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
  487. package/src/components/block-pattern-setup/index.js +2 -1
  488. package/src/components/block-patterns-list/index.js +47 -24
  489. package/src/components/block-popover/style.scss +1 -1
  490. package/src/components/block-preview/README.md +15 -10
  491. package/src/components/block-preview/auto.js +7 -1
  492. package/src/components/block-preview/content.scss +4 -0
  493. package/src/components/block-preview/index.js +7 -12
  494. package/src/components/block-preview/style.scss +0 -7
  495. package/src/components/block-preview/test/index.js +18 -35
  496. package/src/components/block-selection-clearer/test/index.js +12 -12
  497. package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
  498. package/src/components/block-styles/utils.js +3 -3
  499. package/src/components/block-switcher/index.js +19 -4
  500. package/src/components/block-switcher/test/index.js +4 -0
  501. package/src/components/block-toolbar/index.js +12 -5
  502. package/src/components/block-toolbar/style.scss +10 -0
  503. package/src/components/block-tools/insertion-point.js +3 -47
  504. package/src/components/block-tools/selected-block-popover.js +80 -34
  505. package/src/components/block-tools/style.scss +27 -5
  506. package/src/components/block-variation-picker/index.js +1 -4
  507. package/src/components/block-vertical-alignment-control/test/index.js +4 -1
  508. package/src/components/colors/with-colors.js +13 -23
  509. package/src/components/default-block-appender/{style.scss → content.scss} +1 -0
  510. package/src/components/font-sizes/fluid-utils.js +37 -64
  511. package/src/components/font-sizes/test/fluid-utils.js +5 -5
  512. package/src/components/font-sizes/with-font-sizes.js +14 -11
  513. package/src/components/height-control/index.js +123 -0
  514. package/src/components/height-control/stories/index.js +21 -0
  515. package/src/components/height-control/style.scss +5 -0
  516. package/src/components/iframe/index.js +25 -18
  517. package/src/components/image-editor/use-save-image.js +2 -0
  518. package/src/components/image-editor/zoom-dropdown.js +1 -0
  519. package/src/components/index.js +2 -0
  520. package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
  521. package/src/components/inner-blocks/index.js +30 -10
  522. package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
  523. package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
  524. package/src/components/inserter/block-patterns-tab.js +28 -71
  525. package/src/components/inserter/block-types-tab.js +3 -2
  526. package/src/components/inserter/hooks/use-debounced-input.js +17 -0
  527. package/src/components/inserter/index.js +10 -2
  528. package/src/components/inserter/index.native.js +1 -1
  529. package/src/components/inserter/media-tab/hooks.js +88 -0
  530. package/src/components/inserter/media-tab/index.js +3 -0
  531. package/src/components/inserter/media-tab/media-list.js +93 -0
  532. package/src/components/inserter/media-tab/media-panel.js +83 -0
  533. package/src/components/inserter/media-tab/media-tab.js +135 -0
  534. package/src/components/inserter/media-tab/utils.js +37 -0
  535. package/src/components/inserter/menu.js +55 -13
  536. package/src/components/inserter/mobile-tab-navigation.js +85 -0
  537. package/src/components/inserter/quick-inserter.js +1 -0
  538. package/src/components/inserter/reusable-blocks-tab.js +4 -2
  539. package/src/components/inserter/search-results.js +3 -2
  540. package/src/components/inserter/stories/index.js +1 -1
  541. package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
  542. package/src/components/inserter/style.scss +184 -18
  543. package/src/components/inserter/tabs.js +12 -1
  544. package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
  545. package/src/components/inserter-list-item/index.js +11 -1
  546. package/src/components/inserter-list-item/style.scss +26 -0
  547. package/src/components/inspector-controls/groups.js +2 -0
  548. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
  549. package/src/components/inspector-controls-tabs/index.js +62 -0
  550. package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
  551. package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
  552. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
  553. package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
  554. package/src/components/inspector-controls-tabs/utils.js +28 -0
  555. package/src/components/line-height-control/test/index.js +5 -5
  556. package/src/components/link-control/README.md +1 -1
  557. package/src/components/link-control/index.js +24 -39
  558. package/src/components/link-control/search-input.js +1 -2
  559. package/src/components/link-control/test/index.js +400 -582
  560. package/src/components/link-control/use-internal-input-value.js +22 -0
  561. package/src/components/list-view/block.js +7 -3
  562. package/src/components/list-view/branch.js +21 -14
  563. package/src/components/list-view/style.scss +20 -9
  564. package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
  565. package/src/components/media-replace-flow/test/index.js +37 -9
  566. package/src/components/media-upload/test/index.native.js +2 -0
  567. package/src/components/off-canvas-editor/README.md +5 -0
  568. package/src/components/off-canvas-editor/appender.js +93 -0
  569. package/src/components/off-canvas-editor/block-contents.js +89 -0
  570. package/src/components/off-canvas-editor/block-edit-button.js +27 -0
  571. package/src/components/off-canvas-editor/block-select-button.js +113 -0
  572. package/src/components/off-canvas-editor/block.js +401 -0
  573. package/src/components/off-canvas-editor/branch.js +208 -0
  574. package/src/components/off-canvas-editor/context.js +8 -0
  575. package/src/components/off-canvas-editor/drop-indicator.js +126 -0
  576. package/src/components/off-canvas-editor/expander.js +26 -0
  577. package/src/components/off-canvas-editor/index.js +242 -0
  578. package/src/components/off-canvas-editor/leaf.js +52 -0
  579. package/src/components/off-canvas-editor/link-ui.js +166 -0
  580. package/src/components/off-canvas-editor/style.scss +26 -0
  581. package/src/components/off-canvas-editor/test/utils.js +50 -0
  582. package/src/components/off-canvas-editor/update-attributes.js +99 -0
  583. package/src/components/off-canvas-editor/use-block-selection.js +169 -0
  584. package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
  585. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
  586. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
  587. package/src/components/off-canvas-editor/utils.js +58 -0
  588. package/src/components/plain-text/{style.scss → content.scss} +0 -0
  589. package/src/components/recursion-provider/test/index.js +27 -29
  590. package/src/components/responsive-block-control/test/index.js +69 -92
  591. package/src/components/rich-text/content.scss +42 -0
  592. package/src/components/rich-text/format-toolbar/index.js +6 -4
  593. package/src/components/rich-text/index.js +2 -2
  594. package/src/components/rich-text/index.native.js +0 -2
  595. package/src/components/rich-text/style.scss +0 -43
  596. package/src/components/rich-text/use-insert-replacement-text.js +31 -0
  597. package/src/components/rich-text/use-undo-automatic-change.js +7 -1
  598. package/src/components/rich-text/utils.js +2 -21
  599. package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
  600. package/src/components/ungroup-button/index.native.js +6 -2
  601. package/src/components/url-input/index.js +57 -73
  602. package/src/components/url-popover/README.md +12 -3
  603. package/src/components/url-popover/index.js +33 -3
  604. package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
  605. package/src/components/url-popover/test/index.js +21 -9
  606. package/src/components/use-block-display-information/index.js +14 -5
  607. package/src/components/use-setting/index.js +20 -2
  608. package/src/components/use-setting/test/index.js +99 -0
  609. package/src/content.scss +10 -0
  610. package/src/hooks/child-layout.js +190 -0
  611. package/src/hooks/color-panel.js +13 -1
  612. package/src/hooks/color.js +2 -0
  613. package/src/hooks/content-lock-ui.js +47 -35
  614. package/src/hooks/dimensions.js +119 -21
  615. package/src/hooks/layout.js +62 -3
  616. package/src/hooks/margin.js +4 -3
  617. package/src/hooks/min-height.js +104 -0
  618. package/src/hooks/padding.js +4 -3
  619. package/src/hooks/style.js +10 -2
  620. package/src/hooks/test/style.js +4 -0
  621. package/src/hooks/test/use-typography-props.js +1 -1
  622. package/src/layouts/flex.js +43 -38
  623. package/src/store/actions.js +22 -0
  624. package/src/store/reducer.js +480 -434
  625. package/src/store/selectors.js +70 -64
  626. package/src/store/test/actions.js +18 -0
  627. package/src/store/test/performance.js +71 -0
  628. package/src/store/test/reducer.js +662 -490
  629. package/src/store/test/selectors.js +1839 -1306
  630. package/src/style.scss +4 -7
  631. package/src/utils/sorting.js +54 -0
  632. package/src/utils/test/sorting.js +49 -0
  633. package/tsconfig.tsbuildinfo +1 -1
  634. package/build/components/block-preview/live.js +0 -30
  635. package/build/components/block-preview/live.js.map +0 -1
  636. package/build-module/components/block-preview/live.js +0 -20
  637. package/build-module/components/block-preview/live.js.map +0 -1
  638. package/src/components/block-preview/live.js +0 -19
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { reduce, omit, mapValues, isEqual, isEmpty } from 'lodash';
4
+ import fastDeepEqual from 'fast-deep-equal/es6';
5
+ import { omit, isEmpty } from 'lodash';
5
6
  /**
6
7
  * WordPress dependencies
7
8
  */
@@ -31,16 +32,18 @@ const identity = x => x;
31
32
 
32
33
  function mapBlockOrder(blocks) {
33
34
  let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
34
- const result = {
35
- [rootClientId]: []
36
- };
35
+ const result = new Map();
36
+ const current = [];
37
+ result.set(rootClientId, current);
37
38
  blocks.forEach(block => {
38
39
  const {
39
40
  clientId,
40
41
  innerBlocks
41
42
  } = block;
42
- result[rootClientId].push(clientId);
43
- Object.assign(result, mapBlockOrder(innerBlocks, clientId));
43
+ current.push(clientId);
44
+ mapBlockOrder(innerBlocks, clientId).forEach((order, subClientId) => {
45
+ result.set(subClientId, order);
46
+ });
44
47
  });
45
48
  return result;
46
49
  }
@@ -57,9 +60,25 @@ function mapBlockOrder(blocks) {
57
60
 
58
61
  function mapBlockParents(blocks) {
59
62
  let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
60
- return blocks.reduce((result, block) => Object.assign(result, {
61
- [block.clientId]: rootClientId
62
- }, mapBlockParents(block.innerBlocks, block.clientId)), {});
63
+ const result = [];
64
+ const stack = [[rootClientId, blocks]];
65
+
66
+ while (stack.length) {
67
+ const [parent, currentBlocks] = stack.shift();
68
+ currentBlocks.forEach(_ref => {
69
+ let {
70
+ innerBlocks,
71
+ ...block
72
+ } = _ref;
73
+ result.push([block.clientId, parent]);
74
+
75
+ if (innerBlocks !== null && innerBlocks !== void 0 && innerBlocks.length) {
76
+ stack.push([block.clientId, innerBlocks]);
77
+ }
78
+ });
79
+ }
80
+
81
+ return result;
63
82
  }
64
83
  /**
65
84
  * Helper method to iterate through all blocks, recursing into inner blocks,
@@ -69,12 +88,28 @@ function mapBlockParents(blocks) {
69
88
  * @param {Array} blocks Blocks to flatten.
70
89
  * @param {Function} transform Transforming function to be applied to each block.
71
90
  *
72
- * @return {Object} Flattened object.
91
+ * @return {Array} Flattened object.
73
92
  */
74
93
 
75
94
 
76
95
  function flattenBlocks(blocks) {
77
96
  let transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity;
97
+ const result = [];
98
+ const stack = [...blocks];
99
+
100
+ while (stack.length) {
101
+ const {
102
+ innerBlocks,
103
+ ...block
104
+ } = stack.shift();
105
+ stack.push(...innerBlocks);
106
+ result.push([block.clientId, transform(block)]);
107
+ }
108
+
109
+ return result;
110
+ }
111
+
112
+ function getFlattenedClientIds(blocks) {
78
113
  const result = {};
79
114
  const stack = [...blocks];
80
115
 
@@ -84,7 +119,7 @@ function flattenBlocks(blocks) {
84
119
  ...block
85
120
  } = stack.shift();
86
121
  stack.push(...innerBlocks);
87
- result[block.clientId] = transform(block);
122
+ result[block.clientId] = true;
88
123
  }
89
124
 
90
125
  return result;
@@ -96,7 +131,7 @@ function flattenBlocks(blocks) {
96
131
  *
97
132
  * @param {Array} blocks Blocks to flatten.
98
133
  *
99
- * @return {Object} Flattened block attributes object.
134
+ * @return {Array} Flattened block attributes object.
100
135
  */
101
136
 
102
137
 
@@ -110,32 +145,13 @@ function getFlattenedBlocksWithoutAttributes(blocks) {
110
145
  *
111
146
  * @param {Array} blocks Blocks to flatten.
112
147
  *
113
- * @return {Object} Flattened block attributes object.
148
+ * @return {Array} Flattened block attributes object.
114
149
  */
115
150
 
116
151
 
117
152
  function getFlattenedBlockAttributes(blocks) {
118
153
  return flattenBlocks(blocks, block => block.attributes);
119
154
  }
120
- /**
121
- * Returns an object against which it is safe to perform mutating operations,
122
- * given the original object and its current working copy.
123
- *
124
- * @param {Object} original Original object.
125
- * @param {Object} working Working object.
126
- *
127
- * @return {Object} Mutation-safe object.
128
- */
129
-
130
-
131
- function getMutateSafeObject(original, working) {
132
- if (original === working) {
133
- return { ...original
134
- };
135
- }
136
-
137
- return working;
138
- }
139
155
  /**
140
156
  * Returns true if the two object arguments have the same keys, or false
141
157
  * otherwise.
@@ -148,7 +164,7 @@ function getMutateSafeObject(original, working) {
148
164
 
149
165
 
150
166
  export function hasSameKeys(a, b) {
151
- return isEqual(Object.keys(a), Object.keys(b));
167
+ return fastDeepEqual(Object.keys(a), Object.keys(b));
152
168
  }
153
169
  /**
154
170
  * Returns true if, given the currently dispatching action and the previously
@@ -162,11 +178,11 @@ export function hasSameKeys(a, b) {
162
178
  */
163
179
 
164
180
  export function isUpdatingSameBlockAttribute(action, lastAction) {
165
- return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && isEqual(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes);
181
+ return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && fastDeepEqual(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes);
166
182
  }
167
183
 
168
- function buildBlockTree(state, blocks) {
169
- const result = {};
184
+ function updateBlockTreeForBlocks(state, blocks) {
185
+ const treeToUpdate = state.tree;
170
186
  const stack = [...blocks];
171
187
  const flattenedBlocks = [...blocks];
172
188
 
@@ -178,26 +194,25 @@ function buildBlockTree(state, blocks) {
178
194
 
179
195
 
180
196
  for (const block of flattenedBlocks) {
181
- result[block.clientId] = {};
197
+ treeToUpdate.set(block.clientId, {});
182
198
  }
183
199
 
184
200
  for (const block of flattenedBlocks) {
185
- result[block.clientId] = Object.assign(result[block.clientId], { ...state.byClientId[block.clientId],
186
- attributes: state.attributes[block.clientId],
187
- innerBlocks: block.innerBlocks.map(subBlock => result[subBlock.clientId])
188
- });
201
+ treeToUpdate.set(block.clientId, Object.assign(treeToUpdate.get(block.clientId), { ...state.byClientId.get(block.clientId),
202
+ attributes: state.attributes.get(block.clientId),
203
+ innerBlocks: block.innerBlocks.map(subBlock => treeToUpdate.get(subBlock.clientId))
204
+ }));
189
205
  }
190
-
191
- return result;
192
206
  }
193
207
 
194
- function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
195
- let updateChildrenOfUpdatedClientIds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
208
+ function updateParentInnerBlocksInTree(state, updatedClientIds) {
209
+ let updateChildrenOfUpdatedClientIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
210
+ const treeToUpdate = state.tree;
196
211
  const uncontrolledParents = new Set([]);
197
212
  const controlledParents = new Set();
198
213
 
199
214
  for (const clientId of updatedClientIds) {
200
- let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents[clientId];
215
+ let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents.get(clientId);
201
216
 
202
217
  do {
203
218
  if (state.controlledInnerBlocks[current]) {
@@ -208,7 +223,7 @@ function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
208
223
  } else {
209
224
  // Else continue traversing up through parents.
210
225
  uncontrolledParents.add(current);
211
- current = state.parents[current];
226
+ current = state.parents.get(current);
212
227
  }
213
228
  } while (current !== undefined);
214
229
  } // To make sure the order of assignments doesn't matter,
@@ -216,23 +231,21 @@ function updateParentInnerBlocksInTree(state, tree, updatedClientIds) {
216
231
 
217
232
 
218
233
  for (const clientId of uncontrolledParents) {
219
- tree[clientId] = { ...tree[clientId]
220
- };
234
+ treeToUpdate.set(clientId, { ...treeToUpdate.get(clientId)
235
+ });
221
236
  }
222
237
 
223
238
  for (const clientId of uncontrolledParents) {
224
- tree[clientId].innerBlocks = (state.order[clientId] || []).map(subClientId => tree[subClientId]);
239
+ treeToUpdate.get(clientId).innerBlocks = (state.order.get(clientId) || []).map(subClientId => treeToUpdate.get(subClientId));
225
240
  } // Controlled parent blocks, need a dedicated key for their inner blocks
226
241
  // to be used when doing getBlocks( controlledBlockClientId ).
227
242
 
228
243
 
229
244
  for (const clientId of controlledParents) {
230
- tree['controlled||' + clientId] = {
231
- innerBlocks: (state.order[clientId] || []).map(subClientId => tree[subClientId])
232
- };
245
+ treeToUpdate.set('controlled||' + clientId, {
246
+ innerBlocks: (state.order.get(clientId) || []).map(subClientId => treeToUpdate.get(subClientId))
247
+ });
233
248
  }
234
-
235
- return tree;
236
249
  }
237
250
  /**
238
251
  * Higher-order reducer intended to compute full block objects key for each block in the post.
@@ -254,61 +267,61 @@ const withBlockTree = reducer => function () {
254
267
  return state;
255
268
  }
256
269
 
257
- newState.tree = state.tree ? state.tree : {};
270
+ newState.tree = state.tree ? state.tree : new Map();
258
271
 
259
272
  switch (action.type) {
260
273
  case 'RECEIVE_BLOCKS':
261
274
  case 'INSERT_BLOCKS':
262
275
  {
263
- const subTree = buildBlockTree(newState, action.blocks);
264
- newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
265
- ...subTree
266
- }, action.rootClientId ? [action.rootClientId] : [''], true);
276
+ newState.tree = new Map(newState.tree);
277
+ updateBlockTreeForBlocks(newState, action.blocks);
278
+ updateParentInnerBlocksInTree(newState, action.rootClientId ? [action.rootClientId] : [''], true);
267
279
  break;
268
280
  }
269
281
 
270
282
  case 'UPDATE_BLOCK':
271
- newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
272
- [action.clientId]: { ...newState.tree[action.clientId],
273
- ...newState.byClientId[action.clientId],
274
- attributes: newState.attributes[action.clientId]
275
- }
276
- }, [action.clientId], false);
283
+ newState.tree = new Map(newState.tree);
284
+ newState.tree.set(action.clientId, { ...newState.tree.get(action.clientId),
285
+ ...newState.byClientId.get(action.clientId),
286
+ attributes: newState.attributes.get(action.clientId)
287
+ });
288
+ updateParentInnerBlocksInTree(newState, [action.clientId], false);
277
289
  break;
278
290
 
279
291
  case 'UPDATE_BLOCK_ATTRIBUTES':
280
292
  {
281
- const newSubTree = action.clientIds.reduce((result, clientId) => {
282
- result[clientId] = { ...newState.tree[clientId],
283
- attributes: newState.attributes[clientId]
284
- };
285
- return result;
286
- }, {});
287
- newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
288
- ...newSubTree
289
- }, action.clientIds, false);
293
+ newState.tree = new Map(newState.tree);
294
+ action.clientIds.forEach(clientId => {
295
+ newState.tree.set(clientId, { ...newState.tree.get(clientId),
296
+ attributes: newState.attributes.get(clientId)
297
+ });
298
+ });
299
+ updateParentInnerBlocksInTree(newState, action.clientIds, false);
290
300
  break;
291
301
  }
292
302
 
293
303
  case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
294
304
  {
295
- const subTree = buildBlockTree(newState, action.blocks);
296
- newState.tree = updateParentInnerBlocksInTree(newState, { ...omit(newState.tree, action.replacedClientIds.concat( // Controlled inner blocks are only removed
297
- // if the block doesn't move to another position
298
- // otherwise their content will be lost.
299
- action.replacedClientIds.filter(clientId => !subTree[clientId]).map(clientId => 'controlled||' + clientId))),
300
- ...subTree
301
- }, action.blocks.map(b => b.clientId), false); // If there are no replaced blocks, it means we're removing blocks so we need to update their parent.
305
+ const inserterClientIds = getFlattenedClientIds(action.blocks);
306
+ newState.tree = new Map(newState.tree);
307
+ action.replacedClientIds.concat( // Controlled inner blocks are only removed
308
+ // if the block doesn't move to another position
309
+ // otherwise their content will be lost.
310
+ action.replacedClientIds.filter(clientId => !inserterClientIds[clientId]).map(clientId => 'controlled||' + clientId)).forEach(key => {
311
+ newState.tree.delete(key);
312
+ });
313
+ updateBlockTreeForBlocks(newState, action.blocks);
314
+ updateParentInnerBlocksInTree(newState, action.blocks.map(b => b.clientId), false); // If there are no replaced blocks, it means we're removing blocks so we need to update their parent.
302
315
 
303
316
  const parentsOfRemovedBlocks = [];
304
317
 
305
318
  for (const clientId of action.clientIds) {
306
- if (state.parents[clientId] !== undefined && (state.parents[clientId] === '' || newState.byClientId[state.parents[clientId]])) {
307
- parentsOfRemovedBlocks.push(state.parents[clientId]);
319
+ if (state.parents.get(clientId) !== undefined && (state.parents.get(clientId) === '' || newState.byClientId.get(state.parents.get(clientId)))) {
320
+ parentsOfRemovedBlocks.push(state.parents.get(clientId));
308
321
  }
309
322
  }
310
323
 
311
- newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, parentsOfRemovedBlocks, true);
324
+ updateParentInnerBlocksInTree(newState, parentsOfRemovedBlocks, true);
312
325
  break;
313
326
  }
314
327
 
@@ -316,12 +329,16 @@ const withBlockTree = reducer => function () {
316
329
  const parentsOfRemovedBlocks = [];
317
330
 
318
331
  for (const clientId of action.clientIds) {
319
- if (state.parents[clientId] !== undefined && (state.parents[clientId] === '' || newState.byClientId[state.parents[clientId]])) {
320
- parentsOfRemovedBlocks.push(state.parents[clientId]);
332
+ if (state.parents.get(clientId) !== undefined && (state.parents.get(clientId) === '' || newState.byClientId.get(state.parents.get(clientId)))) {
333
+ parentsOfRemovedBlocks.push(state.parents.get(clientId));
321
334
  }
322
335
  }
323
336
 
324
- newState.tree = updateParentInnerBlocksInTree(newState, omit(newState.tree, action.removedClientIds.concat(action.removedClientIds.map(clientId => 'controlled||' + clientId))), parentsOfRemovedBlocks, true);
337
+ newState.tree = new Map(newState.tree);
338
+ action.removedClientIds.concat(action.removedClientIds.map(clientId => 'controlled||' + clientId)).forEach(key => {
339
+ newState.tree.delete(key);
340
+ });
341
+ updateParentInnerBlocksInTree(newState, parentsOfRemovedBlocks, true);
325
342
  break;
326
343
 
327
344
  case 'MOVE_BLOCKS_TO_POSITION':
@@ -338,7 +355,8 @@ const withBlockTree = reducer => function () {
338
355
  updatedBlockUids.push(action.toRootClientId);
339
356
  }
340
357
 
341
- newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, updatedBlockUids, true);
358
+ newState.tree = new Map(newState.tree);
359
+ updateParentInnerBlocksInTree(newState, updatedBlockUids, true);
342
360
  break;
343
361
  }
344
362
 
@@ -346,28 +364,27 @@ const withBlockTree = reducer => function () {
346
364
  case 'MOVE_BLOCKS_DOWN':
347
365
  {
348
366
  const updatedBlockUids = [action.rootClientId ? action.rootClientId : ''];
349
- newState.tree = updateParentInnerBlocksInTree(newState, newState.tree, updatedBlockUids, true);
367
+ newState.tree = new Map(newState.tree);
368
+ updateParentInnerBlocksInTree(newState, updatedBlockUids, true);
350
369
  break;
351
370
  }
352
371
 
353
372
  case 'SAVE_REUSABLE_BLOCK_SUCCESS':
354
373
  {
355
- const updatedBlockUids = Object.entries(newState.attributes).filter(_ref => {
356
- let [clientId, attributes] = _ref;
357
- return newState.byClientId[clientId].name === 'core/block' && attributes.ref === action.updatedId;
358
- }).map(_ref2 => {
359
- let [clientId] = _ref2;
360
- return clientId;
374
+ const updatedBlockUids = [];
375
+ newState.attributes.forEach((attributes, clientId) => {
376
+ if (newState.byClientId.get(clientId).name === 'core/block' && attributes.ref === action.updatedId) {
377
+ updatedBlockUids.push(clientId);
378
+ }
361
379
  });
362
- newState.tree = updateParentInnerBlocksInTree(newState, { ...newState.tree,
363
- ...updatedBlockUids.reduce((result, clientId) => {
364
- result[clientId] = { ...newState.byClientId[clientId],
365
- attributes: newState.attributes[clientId],
366
- innerBlocks: newState.tree[clientId].innerBlocks
367
- };
368
- return result;
369
- }, {})
370
- }, updatedBlockUids, false);
380
+ newState.tree = new Map(newState.tree);
381
+ updatedBlockUids.forEach(clientId => {
382
+ newState.tree.set(clientId, { ...newState.byClientId.get(clientId),
383
+ attributes: newState.attributes.get(clientId),
384
+ innerBlocks: newState.tree.get(clientId).innerBlocks
385
+ });
386
+ });
387
+ updateParentInnerBlocksInTree(newState, updatedBlockUids, false);
371
388
  }
372
389
  }
373
390
 
@@ -464,7 +481,7 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
464
481
  let result = clientIds;
465
482
 
466
483
  for (let i = 0; i < result.length; i++) {
467
- if (!state.order[result[i]] || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
484
+ if (!state.order.get(result[i]) || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
468
485
  continue;
469
486
  }
470
487
 
@@ -472,7 +489,7 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
472
489
  result = [...result];
473
490
  }
474
491
 
475
- result.push(...state.order[result[i]]);
492
+ result.push(...state.order.get(result[i]));
476
493
  }
477
494
 
478
495
  return result;
@@ -513,19 +530,17 @@ const withInnerBlocksRemoveCascade = reducer => (state, action) => {
513
530
  const withBlockReset = reducer => (state, action) => {
514
531
  if (action.type === 'RESET_BLOCKS') {
515
532
  const newState = { ...state,
516
- byClientId: getFlattenedBlocksWithoutAttributes(action.blocks),
517
- attributes: getFlattenedBlockAttributes(action.blocks),
533
+ byClientId: new Map(getFlattenedBlocksWithoutAttributes(action.blocks)),
534
+ attributes: new Map(getFlattenedBlockAttributes(action.blocks)),
518
535
  order: mapBlockOrder(action.blocks),
519
- parents: mapBlockParents(action.blocks),
536
+ parents: new Map(mapBlockParents(action.blocks)),
520
537
  controlledInnerBlocks: {}
521
538
  };
522
- const subTree = buildBlockTree(newState, action.blocks);
523
- newState.tree = { ...subTree,
524
- // Root.
525
- '': {
526
- innerBlocks: action.blocks.map(subBlock => subTree[subBlock.clientId])
527
- }
528
- };
539
+ newState.tree = new Map(state === null || state === void 0 ? void 0 : state.tree);
540
+ updateBlockTreeForBlocks(newState, action.blocks);
541
+ newState.tree.set('', {
542
+ innerBlocks: action.blocks.map(subBlock => newState.tree.get(subBlock.clientId))
543
+ });
529
544
  return newState;
530
545
  }
531
546
 
@@ -578,11 +593,11 @@ const withReplaceInnerBlocks = reducer => (state, action) => {
578
593
 
579
594
  let stateAfterBlocksRemoval = state;
580
595
 
581
- if (state.order[action.rootClientId]) {
596
+ if (state.order.get(action.rootClientId)) {
582
597
  stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
583
598
  type: 'REMOVE_BLOCKS',
584
599
  keepControlledInnerBlocks: nestedControllers,
585
- clientIds: state.order[action.rootClientId]
600
+ clientIds: state.order.get(action.rootClientId)
586
601
  });
587
602
  }
588
603
 
@@ -596,26 +611,21 @@ const withReplaceInnerBlocks = reducer => (state, action) => {
596
611
  // preserve their block order. Otherwise, an inner block controller's blocks
597
612
  // will be deleted entirely from its entity.
598
613
 
599
- stateAfterInsert.order = { ...stateAfterInsert.order,
600
- ...reduce(nestedControllers, (result, value, key) => {
601
- if (state.order[key]) {
602
- result[key] = state.order[key];
603
- }
604
-
605
- return result;
606
- }, {})
607
- };
608
- stateAfterInsert.tree = { ...stateAfterInsert.tree,
609
- ...reduce(nestedControllers, (result, value, _key) => {
610
- const key = `controlled||${_key}`;
611
-
612
- if (state.tree[key]) {
613
- result[key] = state.tree[key];
614
- }
614
+ const stateAfterInsertOrder = new Map(stateAfterInsert.order);
615
+ Object.keys(nestedControllers).forEach(key => {
616
+ if (state.order.get(key)) {
617
+ stateAfterInsertOrder.set(key, state.order.get(key));
618
+ }
619
+ });
620
+ stateAfterInsert.order = stateAfterInsertOrder;
621
+ stateAfterInsert.tree = new Map(stateAfterInsert.tree);
622
+ Object.keys(nestedControllers).forEach(_key => {
623
+ const key = `controlled||${_key}`;
615
624
 
616
- return result;
617
- }, {})
618
- };
625
+ if (state.tree.has(key)) {
626
+ stateAfterInsert.tree.set(key, state.tree.get(key));
627
+ }
628
+ });
619
629
  }
620
630
 
621
631
  return stateAfterInsert;
@@ -645,18 +655,17 @@ const withSaveReusableBlock = reducer => (state, action) => {
645
655
 
646
656
  state = { ...state
647
657
  };
648
- state.attributes = mapValues(state.attributes, (attributes, clientId) => {
658
+ state.attributes = new Map(state.attributes);
659
+ state.attributes.forEach((attributes, clientId) => {
649
660
  const {
650
661
  name
651
- } = state.byClientId[clientId];
662
+ } = state.byClientId.get(clientId);
652
663
 
653
664
  if (name === 'core/block' && attributes.ref === id) {
654
- return { ...attributes,
665
+ state.attributes.set(clientId, { ...attributes,
655
666
  ref: updatedId
656
- };
667
+ });
657
668
  }
658
-
659
- return attributes;
660
669
  });
661
670
  }
662
671
 
@@ -699,131 +708,202 @@ export const blocks = pipe(combineReducers, withSaveReusableBlock, // Needs to b
699
708
  withBlockTree, // Needs to be before withInnerBlocksRemoveCascade.
700
709
  withInnerBlocksRemoveCascade, withReplaceInnerBlocks, // Needs to be after withInnerBlocksRemoveCascade.
701
710
  withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetControlledBlocks)({
711
+ // The state is using a Map instead of a plain object for performance reasons.
712
+ // You can run the "./test/performance.js" unit test to check the impact
713
+ // code changes can have on this reducer.
702
714
  byClientId() {
703
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
715
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
704
716
  let action = arguments.length > 1 ? arguments[1] : undefined;
705
717
 
706
718
  switch (action.type) {
707
719
  case 'RECEIVE_BLOCKS':
708
720
  case 'INSERT_BLOCKS':
709
- return { ...state,
710
- ...getFlattenedBlocksWithoutAttributes(action.blocks)
711
- };
721
+ {
722
+ const newState = new Map(state);
723
+ getFlattenedBlocksWithoutAttributes(action.blocks).forEach(_ref2 => {
724
+ let [key, value] = _ref2;
725
+ newState.set(key, value);
726
+ });
727
+ return newState;
728
+ }
712
729
 
713
730
  case 'UPDATE_BLOCK':
714
- // Ignore updates if block isn't known.
715
- if (!state[action.clientId]) {
716
- return state;
717
- } // Do nothing if only attributes change.
731
+ {
732
+ // Ignore updates if block isn't known.
733
+ if (!state.has(action.clientId)) {
734
+ return state;
735
+ } // Do nothing if only attributes change.
718
736
 
719
737
 
720
- const changes = omit(action.updates, 'attributes');
738
+ const changes = omit(action.updates, 'attributes');
721
739
 
722
- if (isEmpty(changes)) {
723
- return state;
724
- }
740
+ if (isEmpty(changes)) {
741
+ return state;
742
+ }
725
743
 
726
- return { ...state,
727
- [action.clientId]: { ...state[action.clientId],
744
+ const newState = new Map(state);
745
+ newState.set(action.clientId, { ...state.get(action.clientId),
728
746
  ...changes
729
- }
730
- };
747
+ });
748
+ return newState;
749
+ }
731
750
 
732
751
  case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
733
- if (!action.blocks) {
734
- return state;
735
- }
752
+ {
753
+ if (!action.blocks) {
754
+ return state;
755
+ }
736
756
 
737
- return { ...omit(state, action.replacedClientIds),
738
- ...getFlattenedBlocksWithoutAttributes(action.blocks)
739
- };
757
+ const newState = new Map(state);
758
+ action.replacedClientIds.forEach(clientId => {
759
+ newState.delete(clientId);
760
+ });
761
+ getFlattenedBlocksWithoutAttributes(action.blocks).forEach(_ref3 => {
762
+ let [key, value] = _ref3;
763
+ newState.set(key, value);
764
+ });
765
+ return newState;
766
+ }
740
767
 
741
768
  case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
742
- return omit(state, action.removedClientIds);
769
+ {
770
+ const newState = new Map(state);
771
+ action.removedClientIds.forEach(clientId => {
772
+ newState.delete(clientId);
773
+ });
774
+ return newState;
775
+ }
743
776
  }
744
777
 
745
778
  return state;
746
779
  },
747
780
 
781
+ // The state is using a Map instead of a plain object for performance reasons.
782
+ // You can run the "./test/performance.js" unit test to check the impact
783
+ // code changes can have on this reducer.
748
784
  attributes() {
749
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
785
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
750
786
  let action = arguments.length > 1 ? arguments[1] : undefined;
751
787
 
752
788
  switch (action.type) {
753
789
  case 'RECEIVE_BLOCKS':
754
790
  case 'INSERT_BLOCKS':
755
- return { ...state,
756
- ...getFlattenedBlockAttributes(action.blocks)
757
- };
791
+ {
792
+ const newState = new Map(state);
793
+ getFlattenedBlockAttributes(action.blocks).forEach(_ref4 => {
794
+ let [key, value] = _ref4;
795
+ newState.set(key, value);
796
+ });
797
+ return newState;
798
+ }
758
799
 
759
800
  case 'UPDATE_BLOCK':
760
- // Ignore updates if block isn't known or there are no attribute changes.
761
- if (!state[action.clientId] || !action.updates.attributes) {
762
- return state;
763
- }
801
+ {
802
+ // Ignore updates if block isn't known or there are no attribute changes.
803
+ if (!state.get(action.clientId) || !action.updates.attributes) {
804
+ return state;
805
+ }
764
806
 
765
- return { ...state,
766
- [action.clientId]: { ...state[action.clientId],
807
+ const newState = new Map(state);
808
+ newState.set(action.clientId, { ...state.get(action.clientId),
767
809
  ...action.updates.attributes
768
- }
769
- };
810
+ });
811
+ return newState;
812
+ }
770
813
 
771
814
  case 'UPDATE_BLOCK_ATTRIBUTES':
772
815
  {
773
816
  // Avoid a state change if none of the block IDs are known.
774
- if (action.clientIds.every(id => !state[id])) {
817
+ if (action.clientIds.every(id => !state.get(id))) {
775
818
  return state;
776
819
  }
777
820
 
778
- const next = action.clientIds.reduce((accumulator, id) => ({ ...accumulator,
779
- [id]: reduce(action.uniqueByBlock ? action.attributes[id] : action.attributes, (result, value, key) => {
780
- // Consider as updates only changed values.
781
- if (value !== result[key]) {
782
- result = getMutateSafeObject(state[id], result);
783
- result[key] = value;
784
- }
821
+ let hasChange = false;
822
+ const newState = new Map(state);
785
823
 
786
- return result;
787
- }, state[id])
788
- }), {});
824
+ for (const clientId of action.clientIds) {
825
+ var _action$attributes;
789
826
 
790
- if (action.clientIds.every(id => next[id] === state[id])) {
791
- return state;
827
+ const updatedAttributeEntries = Object.entries(action.uniqueByBlock ? action.attributes[clientId] : (_action$attributes = action.attributes) !== null && _action$attributes !== void 0 ? _action$attributes : {});
828
+
829
+ if (updatedAttributeEntries.length === 0) {
830
+ continue;
831
+ }
832
+
833
+ let hasUpdatedAttributes = false;
834
+ const existingAttributes = state.get(clientId);
835
+ const newAttributes = {};
836
+ updatedAttributeEntries.forEach(_ref5 => {
837
+ let [key, value] = _ref5;
838
+
839
+ if (existingAttributes[key] !== value) {
840
+ hasUpdatedAttributes = true;
841
+ newAttributes[key] = value;
842
+ }
843
+ });
844
+ hasChange = hasChange || hasUpdatedAttributes;
845
+
846
+ if (hasUpdatedAttributes) {
847
+ newState.set(clientId, { ...existingAttributes,
848
+ ...newAttributes
849
+ });
850
+ }
792
851
  }
793
852
 
794
- return { ...state,
795
- ...next
796
- };
853
+ return hasChange ? newState : state;
797
854
  }
798
855
 
799
856
  case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
800
- if (!action.blocks) {
801
- return state;
802
- }
857
+ {
858
+ if (!action.blocks) {
859
+ return state;
860
+ }
803
861
 
804
- return { ...omit(state, action.replacedClientIds),
805
- ...getFlattenedBlockAttributes(action.blocks)
806
- };
862
+ const newState = new Map(state);
863
+ action.replacedClientIds.forEach(clientId => {
864
+ newState.delete(clientId);
865
+ });
866
+ getFlattenedBlockAttributes(action.blocks).forEach(_ref6 => {
867
+ let [key, value] = _ref6;
868
+ newState.set(key, value);
869
+ });
870
+ return newState;
871
+ }
807
872
 
808
873
  case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
809
- return omit(state, action.removedClientIds);
874
+ {
875
+ const newState = new Map(state);
876
+ action.removedClientIds.forEach(clientId => {
877
+ newState.delete(clientId);
878
+ });
879
+ return newState;
880
+ }
810
881
  }
811
882
 
812
883
  return state;
813
884
  },
814
885
 
886
+ // The state is using a Map instead of a plain object for performance reasons.
887
+ // You can run the "./test/performance.js" unit test to check the impact
888
+ // code changes can have on this reducer.
815
889
  order() {
816
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
890
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
817
891
  let action = arguments.length > 1 ? arguments[1] : undefined;
818
892
 
819
893
  switch (action.type) {
820
894
  case 'RECEIVE_BLOCKS':
821
895
  {
896
+ var _state$get;
897
+
822
898
  const blockOrder = mapBlockOrder(action.blocks);
823
- return { ...state,
824
- ...omit(blockOrder, ''),
825
- '': ((state === null || state === void 0 ? void 0 : state['']) || []).concat(blockOrder[''])
826
- };
899
+ const newState = new Map(state);
900
+ blockOrder.forEach((order, clientId) => {
901
+ if (clientId !== '') {
902
+ newState.set(clientId, order);
903
+ }
904
+ });
905
+ newState.set('', ((_state$get = state.get('')) !== null && _state$get !== void 0 ? _state$get : []).concat(blockOrder['']));
906
+ return newState;
827
907
  }
828
908
 
829
909
  case 'INSERT_BLOCKS':
@@ -831,20 +911,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
831
911
  const {
832
912
  rootClientId = ''
833
913
  } = action;
834
- const subState = state[rootClientId] || [];
914
+ const subState = state.get(rootClientId) || [];
835
915
  const mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
836
916
  const {
837
917
  index = subState.length
838
918
  } = action;
839
- return { ...state,
840
- ...mappedBlocks,
841
- [rootClientId]: insertAt(subState, mappedBlocks[rootClientId], index)
842
- };
919
+ const newState = new Map(state);
920
+ mappedBlocks.forEach((order, clientId) => {
921
+ newState.set(clientId, order);
922
+ });
923
+ newState.set(rootClientId, insertAt(subState, mappedBlocks.get(rootClientId), index));
924
+ return newState;
843
925
  }
844
926
 
845
927
  case 'MOVE_BLOCKS_TO_POSITION':
846
928
  {
847
- var _state$fromRootClient, _state$fromRootClient2;
929
+ var _state$get$filter, _state$get2;
848
930
 
849
931
  const {
850
932
  fromRootClientId = '',
@@ -852,22 +934,22 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
852
934
  clientIds
853
935
  } = action;
854
936
  const {
855
- index = state[toRootClientId].length
937
+ index = state.get(toRootClientId).length
856
938
  } = action; // Moving inside the same parent block.
857
939
 
858
940
  if (fromRootClientId === toRootClientId) {
859
- const subState = state[toRootClientId];
941
+ const subState = state.get(toRootClientId);
860
942
  const fromIndex = subState.indexOf(clientIds[0]);
861
- return { ...state,
862
- [toRootClientId]: moveTo(state[toRootClientId], fromIndex, index, clientIds.length)
863
- };
943
+ const newState = new Map(state);
944
+ newState.set(toRootClientId, moveTo(state.get(toRootClientId), fromIndex, index, clientIds.length));
945
+ return newState;
864
946
  } // Moving from a parent block to another.
865
947
 
866
948
 
867
- return { ...state,
868
- [fromRootClientId]: (_state$fromRootClient = (_state$fromRootClient2 = state[fromRootClientId]) === null || _state$fromRootClient2 === void 0 ? void 0 : _state$fromRootClient2.filter(id => !clientIds.includes(id))) !== null && _state$fromRootClient !== void 0 ? _state$fromRootClient : [],
869
- [toRootClientId]: insertAt(state[toRootClientId], clientIds, index)
870
- };
949
+ const newState = new Map(state);
950
+ newState.set(fromRootClientId, (_state$get$filter = (_state$get2 = state.get(fromRootClientId)) === null || _state$get2 === void 0 ? void 0 : _state$get2.filter(id => !clientIds.includes(id))) !== null && _state$get$filter !== void 0 ? _state$get$filter : []);
951
+ newState.set(toRootClientId, insertAt(state.get(toRootClientId), clientIds, index));
952
+ return newState;
871
953
  }
872
954
 
873
955
  case 'MOVE_BLOCKS_UP':
@@ -877,16 +959,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
877
959
  rootClientId = ''
878
960
  } = action;
879
961
  const firstClientId = clientIds[0];
880
- const subState = state[rootClientId];
962
+ const subState = state.get(rootClientId);
881
963
 
882
964
  if (!subState.length || firstClientId === subState[0]) {
883
965
  return state;
884
966
  }
885
967
 
886
968
  const firstIndex = subState.indexOf(firstClientId);
887
- return { ...state,
888
- [rootClientId]: moveTo(subState, firstIndex, firstIndex - 1, clientIds.length)
889
- };
969
+ const newState = new Map(state);
970
+ newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex - 1, clientIds.length));
971
+ return newState;
890
972
  }
891
973
 
892
974
  case 'MOVE_BLOCKS_DOWN':
@@ -897,16 +979,16 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
897
979
  } = action;
898
980
  const firstClientId = clientIds[0];
899
981
  const lastClientId = clientIds[clientIds.length - 1];
900
- const subState = state[rootClientId];
982
+ const subState = state.get(rootClientId);
901
983
 
902
984
  if (!subState.length || lastClientId === subState[subState.length - 1]) {
903
985
  return state;
904
986
  }
905
987
 
906
988
  const firstIndex = subState.indexOf(firstClientId);
907
- return { ...state,
908
- [rootClientId]: moveTo(subState, firstIndex, firstIndex + 1, clientIds.length)
909
- };
989
+ const newState = new Map(state);
990
+ newState.set(rootClientId, moveTo(subState, firstIndex, firstIndex + 1, clientIds.length));
991
+ return newState;
910
992
  }
911
993
 
912
994
  case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
@@ -920,29 +1002,50 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
920
1002
  }
921
1003
 
922
1004
  const mappedBlocks = mapBlockOrder(action.blocks);
923
- return pipe([nextState => omit(nextState, action.replacedClientIds), nextState => ({ ...nextState,
924
- ...omit(mappedBlocks, '')
925
- }), nextState => mapValues(nextState, subState => reduce(subState, (result, clientId) => {
926
- if (clientId === clientIds[0]) {
927
- return [...result, ...mappedBlocks['']];
1005
+ const newState = new Map(state);
1006
+ action.replacedClientIds.forEach(clientId => {
1007
+ newState.delete(clientId);
1008
+ });
1009
+ mappedBlocks.forEach((order, clientId) => {
1010
+ if (clientId !== '') {
1011
+ newState.set(clientId, order);
928
1012
  }
1013
+ });
1014
+ newState.forEach((order, clientId) => {
1015
+ const newSubOrder = Object.values(order).reduce((result, subClientId) => {
1016
+ if (subClientId === clientIds[0]) {
1017
+ return [...result, ...mappedBlocks.get('')];
1018
+ }
929
1019
 
930
- if (clientIds.indexOf(clientId) === -1) {
931
- result.push(clientId);
932
- }
1020
+ if (clientIds.indexOf(subClientId) === -1) {
1021
+ result.push(subClientId);
1022
+ }
933
1023
 
934
- return result;
935
- }, []))])(state);
1024
+ return result;
1025
+ }, []);
1026
+ newState.set(clientId, newSubOrder);
1027
+ });
1028
+ return newState;
936
1029
  }
937
1030
 
938
1031
  case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
939
- return pipe([// Remove inner block ordering for removed blocks.
940
- nextState => omit(nextState, action.removedClientIds), // Remove deleted blocks from other blocks' orderings.
941
- nextState => mapValues(nextState, subState => {
942
- var _subState$filter;
1032
+ {
1033
+ const newState = new Map(state); // Remove inner block ordering for removed blocks.
1034
+
1035
+ action.removedClientIds.forEach(clientId => {
1036
+ newState.delete(clientId);
1037
+ });
1038
+ newState.forEach((order, clientId) => {
1039
+ var _order$filter;
943
1040
 
944
- return (_subState$filter = subState === null || subState === void 0 ? void 0 : subState.filter(id => !action.removedClientIds.includes(id))) !== null && _subState$filter !== void 0 ? _subState$filter : [];
945
- })])(state);
1041
+ const newSubOrder = (_order$filter = order === null || order === void 0 ? void 0 : order.filter(id => !action.removedClientIds.includes(id))) !== null && _order$filter !== void 0 ? _order$filter : [];
1042
+
1043
+ if (newSubOrder.length !== order.length) {
1044
+ newState.set(clientId, newSubOrder);
1045
+ }
1046
+ });
1047
+ return newState;
1048
+ }
946
1049
  }
947
1050
 
948
1051
  return state;
@@ -951,37 +1054,60 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
951
1054
  // While technically redundant data as the inverse of `order`, it serves as
952
1055
  // an optimization for the selectors which derive the ancestry of a block.
953
1056
  parents() {
954
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1057
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map();
955
1058
  let action = arguments.length > 1 ? arguments[1] : undefined;
956
1059
 
957
1060
  switch (action.type) {
958
1061
  case 'RECEIVE_BLOCKS':
959
- return { ...state,
960
- ...mapBlockParents(action.blocks)
961
- };
1062
+ {
1063
+ const newState = new Map(state);
1064
+ mapBlockParents(action.blocks).forEach(_ref7 => {
1065
+ let [key, value] = _ref7;
1066
+ newState.set(key, value);
1067
+ });
1068
+ return newState;
1069
+ }
962
1070
 
963
1071
  case 'INSERT_BLOCKS':
964
- return { ...state,
965
- ...mapBlockParents(action.blocks, action.rootClientId || '')
966
- };
1072
+ {
1073
+ const newState = new Map(state);
1074
+ mapBlockParents(action.blocks, action.rootClientId || '').forEach(_ref8 => {
1075
+ let [key, value] = _ref8;
1076
+ newState.set(key, value);
1077
+ });
1078
+ return newState;
1079
+ }
967
1080
 
968
1081
  case 'MOVE_BLOCKS_TO_POSITION':
969
1082
  {
970
- return { ...state,
971
- ...action.clientIds.reduce((accumulator, id) => {
972
- accumulator[id] = action.toRootClientId || '';
973
- return accumulator;
974
- }, {})
975
- };
1083
+ const newState = new Map(state);
1084
+ action.clientIds.forEach(id => {
1085
+ newState.set(id, action.toRootClientId || '');
1086
+ });
1087
+ return newState;
976
1088
  }
977
1089
 
978
1090
  case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
979
- return { ...omit(state, action.replacedClientIds),
980
- ...mapBlockParents(action.blocks, state[action.clientIds[0]])
981
- };
1091
+ {
1092
+ const newState = new Map(state);
1093
+ action.replacedClientIds.forEach(clientId => {
1094
+ newState.delete(clientId);
1095
+ });
1096
+ mapBlockParents(action.blocks, state.get(action.clientIds[0])).forEach(_ref9 => {
1097
+ let [key, value] = _ref9;
1098
+ newState.set(key, value);
1099
+ });
1100
+ return newState;
1101
+ }
982
1102
 
983
1103
  case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
984
- return omit(state, action.removedClientIds);
1104
+ {
1105
+ const newState = new Map(state);
1106
+ action.removedClientIds.forEach(clientId => {
1107
+ newState.delete(clientId);
1108
+ });
1109
+ return newState;
1110
+ }
985
1111
  }
986
1112
 
987
1113
  return state;
@@ -1005,6 +1131,29 @@ withBlockReset, withPersistentBlockChange, withIgnoredBlockChange, withResetCont
1005
1131
  }
1006
1132
 
1007
1133
  });
1134
+ /**
1135
+ * Reducer returning visibility status of block interface.
1136
+ *
1137
+ * @param {boolean} state Current state.
1138
+ * @param {Object} action Dispatched action.
1139
+ *
1140
+ * @return {boolean} Updated state.
1141
+ */
1142
+
1143
+ export function isBlockInterfaceHidden() {
1144
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1145
+ let action = arguments.length > 1 ? arguments[1] : undefined;
1146
+
1147
+ switch (action.type) {
1148
+ case 'HIDE_BLOCK_INTERFACE':
1149
+ return true;
1150
+
1151
+ case 'SHOW_BLOCK_INTERFACE':
1152
+ return false;
1153
+ }
1154
+
1155
+ return state;
1156
+ }
1008
1157
  /**
1009
1158
  * Reducer returning typing state.
1010
1159
  *
@@ -1359,7 +1508,7 @@ export function insertionPoint() {
1359
1508
  operation
1360
1509
  }; // Bail out updates if the states are the same.
1361
1510
 
1362
- return isEqual(state, nextState) ? state : nextState;
1511
+ return fastDeepEqual(state, nextState) ? state : nextState;
1363
1512
  }
1364
1513
 
1365
1514
  case 'HIDE_INSERTION_POINT':
@@ -1499,7 +1648,7 @@ export const blockListSettings = function () {
1499
1648
  return state;
1500
1649
  }
1501
1650
 
1502
- if (isEqual(state[clientId], action.settings)) {
1651
+ if (fastDeepEqual(state[clientId], action.settings)) {
1503
1652
  return state;
1504
1653
  }
1505
1654
 
@@ -1724,6 +1873,7 @@ export function temporarilyEditingAsBlocks() {
1724
1873
  export default combineReducers({
1725
1874
  blocks,
1726
1875
  isTyping,
1876
+ isBlockInterfaceHidden,
1727
1877
  draggedBlocks,
1728
1878
  selection,
1729
1879
  isMultiSelecting,