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