@wordpress/block-editor 7.0.4 → 8.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 (347) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +31 -0
  3. package/build/components/alignment-control/ui.js +1 -2
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/block-icon/index.js +5 -1
  6. package/build/components/block-icon/index.js.map +1 -1
  7. package/build/components/block-inspector/index.js +4 -0
  8. package/build/components/block-inspector/index.js.map +1 -1
  9. package/build/components/block-list/index.native.js +1 -1
  10. package/build/components/block-list/index.native.js.map +1 -1
  11. package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
  12. package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  13. package/build/components/block-navigation/dropdown.js +0 -1
  14. package/build/components/block-navigation/dropdown.js.map +1 -1
  15. package/build/components/block-patterns-list/index.js +1 -8
  16. package/build/components/block-patterns-list/index.js.map +1 -1
  17. package/build/components/block-settings/container.native.js +5 -2
  18. package/build/components/block-settings/container.native.js.map +1 -1
  19. package/build/components/block-settings-menu/block-settings-dropdown.js +22 -2
  20. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  21. package/build/components/block-styles/preview.native.js +2 -2
  22. package/build/components/block-styles/preview.native.js.map +1 -1
  23. package/build/components/colors-gradients/control.js +8 -47
  24. package/build/components/colors-gradients/control.js.map +1 -1
  25. package/build/components/colors-gradients/panel-color-gradient-settings.js +81 -6
  26. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  27. package/build/components/duotone-control/index.js +5 -2
  28. package/build/components/duotone-control/index.js.map +1 -1
  29. package/build/components/font-appearance-control/index.js +27 -15
  30. package/build/components/font-appearance-control/index.js.map +1 -1
  31. package/build/components/iframe/index.js +1 -1
  32. package/build/components/iframe/index.js.map +1 -1
  33. package/build/components/index.js +20 -2
  34. package/build/components/index.js.map +1 -1
  35. package/build/components/index.native.js +2 -2
  36. package/build/components/index.native.js.map +1 -1
  37. package/build/components/inner-blocks/index.js +5 -4
  38. package/build/components/inner-blocks/index.js.map +1 -1
  39. package/build/components/inner-blocks/index.native.js +4 -3
  40. package/build/components/inner-blocks/index.native.js.map +1 -1
  41. package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
  42. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  43. package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
  44. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  45. package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
  46. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  47. package/build/components/inserter/block-patterns-tab.js +74 -45
  48. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  49. package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  50. package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  51. package/build/components/inserter/pattern-panel.js +19 -10
  52. package/build/components/inserter/pattern-panel.js.map +1 -1
  53. package/build/components/inspector-controls/groups.js +3 -1
  54. package/build/components/inspector-controls/groups.js.map +1 -1
  55. package/build/components/letter-spacing-control/index.js +9 -6
  56. package/build/components/letter-spacing-control/index.js.map +1 -1
  57. package/build/components/link-control/index.js +88 -35
  58. package/build/components/link-control/index.js.map +1 -1
  59. package/build/components/link-control/link-preview.js +19 -6
  60. package/build/components/link-control/link-preview.js.map +1 -1
  61. package/build/components/link-control/search-input.js +12 -3
  62. package/build/components/link-control/search-input.js.map +1 -1
  63. package/build/components/list-view/block.js +49 -23
  64. package/build/components/list-view/block.js.map +1 -1
  65. package/build/components/list-view/branch.js +92 -73
  66. package/build/components/list-view/branch.js.map +1 -1
  67. package/build/components/list-view/index.js +39 -16
  68. package/build/components/list-view/index.js.map +1 -1
  69. package/build/components/list-view/leaf.js +1 -1
  70. package/build/components/list-view/leaf.js.map +1 -1
  71. package/build/components/list-view/use-list-view-client-ids.js +8 -58
  72. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  73. package/build/components/rich-text/embed-handler-picker.native.js +1 -0
  74. package/build/components/rich-text/embed-handler-picker.native.js.map +1 -1
  75. package/build/components/rich-text/format-edit.js +28 -2
  76. package/build/components/rich-text/format-edit.js.map +1 -1
  77. package/build/components/rich-text/format-toolbar/index.js +2 -1
  78. package/build/components/rich-text/format-toolbar/index.js.map +1 -1
  79. package/build/components/url-input/index.js +11 -4
  80. package/build/components/url-input/index.js.map +1 -1
  81. package/build/components/use-setting/index.js +48 -9
  82. package/build/components/use-setting/index.js.map +1 -1
  83. package/build/hooks/border.js +5 -5
  84. package/build/hooks/border.js.map +1 -1
  85. package/build/hooks/color-panel.js +2 -1
  86. package/build/hooks/color-panel.js.map +1 -1
  87. package/build/hooks/duotone.js +16 -5
  88. package/build/hooks/duotone.js.map +1 -1
  89. package/build/hooks/font-appearance.js +49 -6
  90. package/build/hooks/font-appearance.js.map +1 -1
  91. package/build/hooks/font-family.js +37 -16
  92. package/build/hooks/font-family.js.map +1 -1
  93. package/build/hooks/font-size.js +51 -9
  94. package/build/hooks/font-size.js.map +1 -1
  95. package/build/hooks/index.js +8 -0
  96. package/build/hooks/index.js.map +1 -1
  97. package/build/hooks/index.native.js +8 -0
  98. package/build/hooks/index.native.js.map +1 -1
  99. package/build/hooks/letter-spacing.js +44 -7
  100. package/build/hooks/letter-spacing.js.map +1 -1
  101. package/build/hooks/line-height.js +45 -8
  102. package/build/hooks/line-height.js.map +1 -1
  103. package/build/hooks/margin.js +1 -1
  104. package/build/hooks/margin.js.map +1 -1
  105. package/build/hooks/padding.js +1 -1
  106. package/build/hooks/padding.js.map +1 -1
  107. package/build/hooks/text-decoration.js +42 -6
  108. package/build/hooks/text-decoration.js.map +1 -1
  109. package/build/hooks/text-transform.js +42 -6
  110. package/build/hooks/text-transform.js.map +1 -1
  111. package/build/hooks/typography.js +108 -8
  112. package/build/hooks/typography.js.map +1 -1
  113. package/build/hooks/use-cached-truthy.js +29 -0
  114. package/build/hooks/use-cached-truthy.js.map +1 -0
  115. package/build/index.js +7 -0
  116. package/build/index.js.map +1 -1
  117. package/build/layouts/flex.js +120 -28
  118. package/build/layouts/flex.js.map +1 -1
  119. package/build/store/actions.js +303 -265
  120. package/build/store/actions.js.map +1 -1
  121. package/build/store/index.js +1 -3
  122. package/build/store/index.js.map +1 -1
  123. package/build/store/reducer.js +23 -22
  124. package/build/store/reducer.js.map +1 -1
  125. package/build/store/selectors.js +44 -35
  126. package/build/store/selectors.js.map +1 -1
  127. package/build-module/components/alignment-control/ui.js +1 -2
  128. package/build-module/components/alignment-control/ui.js.map +1 -1
  129. package/build-module/components/block-icon/index.js +5 -1
  130. package/build-module/components/block-icon/index.js.map +1 -1
  131. package/build-module/components/block-inspector/index.js +4 -0
  132. package/build-module/components/block-inspector/index.js.map +1 -1
  133. package/build-module/components/block-list/index.native.js +1 -1
  134. package/build-module/components/block-list/index.native.js.map +1 -1
  135. package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
  136. package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
  137. package/build-module/components/block-navigation/dropdown.js +0 -1
  138. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  139. package/build-module/components/block-patterns-list/index.js +1 -6
  140. package/build-module/components/block-patterns-list/index.js.map +1 -1
  141. package/build-module/components/block-settings/container.native.js +6 -3
  142. package/build-module/components/block-settings/container.native.js.map +1 -1
  143. package/build-module/components/block-settings-menu/block-settings-dropdown.js +24 -4
  144. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  145. package/build-module/components/block-styles/preview.native.js +2 -2
  146. package/build-module/components/block-styles/preview.native.js.map +1 -1
  147. package/build-module/components/colors-gradients/control.js +12 -53
  148. package/build-module/components/colors-gradients/control.js.map +1 -1
  149. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +82 -6
  150. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  151. package/build-module/components/duotone-control/index.js +5 -2
  152. package/build-module/components/duotone-control/index.js.map +1 -1
  153. package/build-module/components/font-appearance-control/index.js +23 -15
  154. package/build-module/components/font-appearance-control/index.js.map +1 -1
  155. package/build-module/components/iframe/index.js +1 -1
  156. package/build-module/components/iframe/index.js.map +1 -1
  157. package/build-module/components/index.js +3 -1
  158. package/build-module/components/index.js.map +1 -1
  159. package/build-module/components/index.native.js +1 -1
  160. package/build-module/components/index.native.js.map +1 -1
  161. package/build-module/components/inner-blocks/index.js +6 -5
  162. package/build-module/components/inner-blocks/index.js.map +1 -1
  163. package/build-module/components/inner-blocks/index.native.js +5 -4
  164. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  165. package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
  166. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
  167. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
  168. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
  169. package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
  170. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
  171. package/build-module/components/inserter/block-patterns-tab.js +75 -46
  172. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  173. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
  174. package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
  175. package/build-module/components/inserter/pattern-panel.js +21 -13
  176. package/build-module/components/inserter/pattern-panel.js.map +1 -1
  177. package/build-module/components/inspector-controls/groups.js +3 -1
  178. package/build-module/components/inspector-controls/groups.js.map +1 -1
  179. package/build-module/components/letter-spacing-control/index.js +9 -6
  180. package/build-module/components/letter-spacing-control/index.js.map +1 -1
  181. package/build-module/components/link-control/index.js +88 -36
  182. package/build-module/components/link-control/index.js.map +1 -1
  183. package/build-module/components/link-control/link-preview.js +19 -7
  184. package/build-module/components/link-control/link-preview.js.map +1 -1
  185. package/build-module/components/link-control/search-input.js +11 -3
  186. package/build-module/components/link-control/search-input.js.map +1 -1
  187. package/build-module/components/list-view/block.js +49 -24
  188. package/build-module/components/list-view/block.js.map +1 -1
  189. package/build-module/components/list-view/branch.js +92 -73
  190. package/build-module/components/list-view/branch.js.map +1 -1
  191. package/build-module/components/list-view/index.js +41 -18
  192. package/build-module/components/list-view/index.js.map +1 -1
  193. package/build-module/components/list-view/leaf.js +1 -1
  194. package/build-module/components/list-view/leaf.js.map +1 -1
  195. package/build-module/components/list-view/use-list-view-client-ids.js +8 -58
  196. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  197. package/build-module/components/rich-text/embed-handler-picker.native.js +1 -0
  198. package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -1
  199. package/build-module/components/rich-text/format-edit.js +28 -3
  200. package/build-module/components/rich-text/format-edit.js.map +1 -1
  201. package/build-module/components/rich-text/format-toolbar/index.js +2 -1
  202. package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
  203. package/build-module/components/url-input/index.js +11 -4
  204. package/build-module/components/url-input/index.js.map +1 -1
  205. package/build-module/components/use-setting/index.js +48 -9
  206. package/build-module/components/use-setting/index.js.map +1 -1
  207. package/build-module/hooks/border.js +5 -5
  208. package/build-module/hooks/border.js.map +1 -1
  209. package/build-module/hooks/color-panel.js +2 -1
  210. package/build-module/hooks/color-panel.js.map +1 -1
  211. package/build-module/hooks/duotone.js +16 -5
  212. package/build-module/hooks/duotone.js.map +1 -1
  213. package/build-module/hooks/font-appearance.js +45 -6
  214. package/build-module/hooks/font-appearance.js.map +1 -1
  215. package/build-module/hooks/font-family.js +33 -16
  216. package/build-module/hooks/font-family.js.map +1 -1
  217. package/build-module/hooks/font-size.js +47 -9
  218. package/build-module/hooks/font-size.js.map +1 -1
  219. package/build-module/hooks/index.js +1 -0
  220. package/build-module/hooks/index.js.map +1 -1
  221. package/build-module/hooks/index.native.js +1 -0
  222. package/build-module/hooks/index.native.js.map +1 -1
  223. package/build-module/hooks/letter-spacing.js +40 -7
  224. package/build-module/hooks/letter-spacing.js.map +1 -1
  225. package/build-module/hooks/line-height.js +41 -8
  226. package/build-module/hooks/line-height.js.map +1 -1
  227. package/build-module/hooks/margin.js +1 -1
  228. package/build-module/hooks/margin.js.map +1 -1
  229. package/build-module/hooks/padding.js +1 -1
  230. package/build-module/hooks/padding.js.map +1 -1
  231. package/build-module/hooks/text-decoration.js +38 -6
  232. package/build-module/hooks/text-decoration.js.map +1 -1
  233. package/build-module/hooks/text-transform.js +38 -6
  234. package/build-module/hooks/text-transform.js.map +1 -1
  235. package/build-module/hooks/typography.js +117 -17
  236. package/build-module/hooks/typography.js.map +1 -1
  237. package/build-module/hooks/use-cached-truthy.js +21 -0
  238. package/build-module/hooks/use-cached-truthy.js.map +1 -0
  239. package/build-module/index.js +1 -1
  240. package/build-module/index.js.map +1 -1
  241. package/build-module/layouts/flex.js +124 -32
  242. package/build-module/layouts/flex.js.map +1 -1
  243. package/build-module/store/actions.js +266 -241
  244. package/build-module/store/actions.js.map +1 -1
  245. package/build-module/store/index.js +1 -2
  246. package/build-module/store/index.js.map +1 -1
  247. package/build-module/store/reducer.js +23 -22
  248. package/build-module/store/reducer.js.map +1 -1
  249. package/build-module/store/selectors.js +42 -30
  250. package/build-module/store/selectors.js.map +1 -1
  251. package/build-style/style-rtl.css +160 -57
  252. package/build-style/style.css +160 -57
  253. package/package.json +13 -14
  254. package/src/components/alignment-control/test/__snapshots__/index.js.snap +0 -2
  255. package/src/components/alignment-control/ui.js +1 -4
  256. package/src/components/block-draggable/style.scss +19 -4
  257. package/src/components/block-icon/index.js +4 -1
  258. package/src/components/block-inspector/index.js +5 -0
  259. package/src/components/block-list/index.native.js +1 -1
  260. package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
  261. package/src/components/block-navigation/dropdown.js +0 -1
  262. package/src/components/block-patterns-list/index.js +1 -8
  263. package/src/components/block-patterns-list/style.scss +22 -12
  264. package/src/components/block-settings/container.native.js +7 -0
  265. package/src/components/block-settings-menu/block-settings-dropdown.js +19 -7
  266. package/src/components/block-styles/preview.native.js +2 -2
  267. package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
  268. package/src/components/color-palette/test/__snapshots__/control.js.snap +88 -63
  269. package/src/components/colors-gradients/control.js +19 -62
  270. package/src/components/colors-gradients/panel-color-gradient-settings.js +76 -6
  271. package/src/components/colors-gradients/style.scss +3 -14
  272. package/src/components/colors-gradients/test/control.js +0 -16
  273. package/src/components/duotone-control/index.js +6 -0
  274. package/src/components/duotone-control/style.scss +27 -12
  275. package/src/components/font-appearance-control/index.js +22 -14
  276. package/src/components/iframe/index.js +1 -1
  277. package/src/components/index.js +3 -4
  278. package/src/components/index.native.js +1 -4
  279. package/src/components/inner-blocks/index.js +4 -4
  280. package/src/components/inner-blocks/index.native.js +7 -4
  281. package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
  282. package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
  283. package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
  284. package/src/components/inserter/block-patterns-tab.js +107 -80
  285. package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
  286. package/src/components/inserter/pattern-panel.js +33 -16
  287. package/src/components/inserter/style.scss +64 -1
  288. package/src/components/inserter/test/block-types-tab.native.js +1 -1
  289. package/src/components/inserter/test/fixtures/index.native.js +12 -0
  290. package/src/components/inspector-controls/groups.js +4 -0
  291. package/src/components/letter-spacing-control/index.js +12 -6
  292. package/src/components/link-control/README.md +7 -0
  293. package/src/components/link-control/index.js +99 -34
  294. package/src/components/link-control/link-preview.js +21 -9
  295. package/src/components/link-control/search-input.js +9 -3
  296. package/src/components/link-control/style.scss +32 -16
  297. package/src/components/link-control/test/index.js +179 -4
  298. package/src/components/list-view/block.js +67 -23
  299. package/src/components/list-view/branch.js +113 -91
  300. package/src/components/list-view/index.js +58 -19
  301. package/src/components/list-view/leaf.js +1 -1
  302. package/src/components/list-view/style.scss +14 -3
  303. package/src/components/list-view/use-list-view-client-ids.js +7 -66
  304. package/src/components/rich-text/embed-handler-picker.native.js +1 -0
  305. package/src/components/rich-text/format-edit.js +36 -2
  306. package/src/components/rich-text/format-toolbar/index.js +3 -0
  307. package/src/components/url-input/index.js +14 -4
  308. package/src/components/use-setting/index.js +49 -11
  309. package/src/hooks/border.js +8 -11
  310. package/src/hooks/color-panel.js +1 -0
  311. package/src/hooks/duotone.js +21 -7
  312. package/src/hooks/font-appearance.js +38 -7
  313. package/src/hooks/font-family.js +29 -13
  314. package/src/hooks/font-size.js +42 -6
  315. package/src/hooks/index.js +1 -0
  316. package/src/hooks/index.native.js +1 -0
  317. package/src/hooks/layout.scss +3 -1
  318. package/src/hooks/letter-spacing.js +35 -7
  319. package/src/hooks/line-height.js +37 -9
  320. package/src/hooks/margin.js +1 -1
  321. package/src/hooks/padding.js +1 -1
  322. package/src/hooks/text-decoration.js +34 -6
  323. package/src/hooks/text-transform.js +34 -6
  324. package/src/hooks/typography.js +165 -15
  325. package/src/hooks/typography.scss +16 -0
  326. package/src/hooks/use-cached-truthy.js +20 -0
  327. package/src/index.js +1 -0
  328. package/src/layouts/flex.js +137 -41
  329. package/src/store/actions.js +223 -391
  330. package/src/store/index.js +1 -2
  331. package/src/store/reducer.js +36 -18
  332. package/src/store/selectors.js +52 -47
  333. package/src/store/test/actions.js +395 -694
  334. package/src/store/test/selectors.js +79 -21
  335. package/src/style.scss +1 -1
  336. package/src/utils/test/parse-css-unit-to-px.js +127 -167
  337. package/build/components/text-decoration-and-transform/index.js +0 -39
  338. package/build/components/text-decoration-and-transform/index.js.map +0 -1
  339. package/build/store/controls.js +0 -44
  340. package/build/store/controls.js.map +0 -1
  341. package/build-module/components/text-decoration-and-transform/index.js +0 -30
  342. package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
  343. package/build-module/store/controls.js +0 -32
  344. package/build-module/store/controls.js.map +0 -1
  345. package/src/components/text-decoration-and-transform/index.js +0 -36
  346. package/src/components/text-decoration-and-transform/style.scss +0 -3
  347. package/src/store/controls.js +0 -39
@@ -5,32 +5,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.resetBlocks = resetBlocks;
9
- exports.validateBlocksToTemplate = validateBlocksToTemplate;
10
8
  exports.resetSelection = resetSelection;
11
9
  exports.receiveBlocks = receiveBlocks;
12
10
  exports.updateBlockAttributes = updateBlockAttributes;
13
11
  exports.updateBlock = updateBlock;
14
12
  exports.selectBlock = selectBlock;
15
- exports.selectPreviousBlock = selectPreviousBlock;
16
- exports.selectNextBlock = selectNextBlock;
17
13
  exports.startMultiSelect = startMultiSelect;
18
14
  exports.stopMultiSelect = stopMultiSelect;
19
- exports.multiSelect = multiSelect;
20
15
  exports.clearSelectedBlock = clearSelectedBlock;
21
16
  exports.toggleSelection = toggleSelection;
22
- exports.replaceBlocks = replaceBlocks;
23
17
  exports.replaceBlock = replaceBlock;
24
- exports.moveBlocksToPosition = moveBlocksToPosition;
25
18
  exports.moveBlockToPosition = moveBlockToPosition;
26
19
  exports.insertBlock = insertBlock;
27
- exports.insertBlocks = insertBlocks;
28
20
  exports.showInsertionPoint = showInsertionPoint;
29
21
  exports.hideInsertionPoint = hideInsertionPoint;
30
22
  exports.setTemplateValidity = setTemplateValidity;
31
- exports.synchronizeTemplate = synchronizeTemplate;
32
- exports.mergeBlocks = mergeBlocks;
33
- exports.removeBlocks = removeBlocks;
34
23
  exports.removeBlock = removeBlock;
35
24
  exports.replaceInnerBlocks = replaceInnerBlocks;
36
25
  exports.toggleBlockMode = toggleBlockMode;
@@ -47,17 +36,9 @@ exports.updateSettings = updateSettings;
47
36
  exports.__unstableSaveReusableBlock = __unstableSaveReusableBlock;
48
37
  exports.__unstableMarkLastChangeAsPersistent = __unstableMarkLastChangeAsPersistent;
49
38
  exports.__unstableMarkNextChangeAsNotPersistent = __unstableMarkNextChangeAsNotPersistent;
50
- exports.__unstableMarkAutomaticChange = __unstableMarkAutomaticChange;
51
- exports.__unstableMarkAutomaticChangeFinal = __unstableMarkAutomaticChangeFinal;
52
- exports.setNavigationMode = setNavigationMode;
53
- exports.setBlockMovingClientId = setBlockMovingClientId;
54
- exports.duplicateBlocks = duplicateBlocks;
55
- exports.insertBeforeBlock = insertBeforeBlock;
56
- exports.insertAfterBlock = insertAfterBlock;
57
39
  exports.toggleBlockHighlight = toggleBlockHighlight;
58
- exports.flashBlock = flashBlock;
59
40
  exports.setHasControlledInnerBlocks = setHasControlledInnerBlocks;
60
- exports.moveBlocksUp = exports.moveBlocksDown = void 0;
41
+ exports.flashBlock = exports.insertAfterBlock = exports.insertBeforeBlock = exports.duplicateBlocks = exports.setBlockMovingClientId = exports.setNavigationMode = exports.__unstableMarkAutomaticChange = exports.removeBlocks = exports.mergeBlocks = exports.synchronizeTemplate = exports.insertBlocks = exports.moveBlocksToPosition = exports.moveBlocksUp = exports.moveBlocksDown = exports.replaceBlocks = exports.multiSelect = exports.selectNextBlock = exports.selectPreviousBlock = exports.validateBlocksToTemplate = exports.resetBlocks = void 0;
61
42
 
62
43
  var _lodash = require("lodash");
63
44
 
@@ -67,16 +48,10 @@ var _a11y = require("@wordpress/a11y");
67
48
 
68
49
  var _i18n = require("@wordpress/i18n");
69
50
 
70
- var _data = require("@wordpress/data");
71
-
72
51
  var _richText = require("@wordpress/rich-text");
73
52
 
74
53
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
75
54
 
76
- var _controls = require("../store/controls");
77
-
78
- var _constants = require("./constants");
79
-
80
55
  /**
81
56
  * External dependencies
82
57
  */
@@ -86,49 +61,53 @@ var _constants = require("./constants");
86
61
  */
87
62
 
88
63
  /**
89
- * Internal dependencies
90
- */
91
-
92
- /**
93
- * Generator which will yield a default block insert action if there
94
- * are no other blocks at the root of the editor. This generator should be used
64
+ * Action which will insert a default block insert action if there
65
+ * are no other blocks at the root of the editor. This action should be used
95
66
  * in actions which may result in no blocks remaining in the editor (removal,
96
67
  * replacement, etc).
97
68
  */
98
- function* ensureDefaultBlock() {
99
- const count = yield _data.controls.select(_constants.STORE_NAME, 'getBlockCount'); // To avoid a focus loss when removing the last block, assure there is
69
+ const ensureDefaultBlock = () => ({
70
+ select,
71
+ dispatch
72
+ }) => {
73
+ // To avoid a focus loss when removing the last block, assure there is
100
74
  // always a default block if the last of the blocks have been removed.
75
+ const count = select.getBlockCount();
101
76
 
102
- if (count === 0) {
103
- const {
104
- __unstableHasCustomAppender
105
- } = yield _data.controls.select(_constants.STORE_NAME, 'getSettings'); // If there's an custom appender, don't insert default block.
106
- // We have to remember to manually move the focus elsewhere to
107
- // prevent it from being lost though.
77
+ if (count > 0) {
78
+ return;
79
+ } // If there's an custom appender, don't insert default block.
80
+ // We have to remember to manually move the focus elsewhere to
81
+ // prevent it from being lost though.
108
82
 
109
- if (__unstableHasCustomAppender) {
110
- return;
111
- }
112
83
 
113
- return yield insertDefaultBlock();
84
+ const {
85
+ __unstableHasCustomAppender
86
+ } = select.getSettings();
87
+
88
+ if (__unstableHasCustomAppender) {
89
+ return;
114
90
  }
115
- }
91
+
92
+ dispatch.insertDefaultBlock();
93
+ };
116
94
  /**
117
- * Returns an action object used in signalling that blocks state should be
118
- * reset to the specified array of blocks, taking precedence over any other
119
- * content reflected as an edit in state.
95
+ * Action that resets blocks state to the specified array of blocks, taking precedence
96
+ * over any other content reflected as an edit in state.
120
97
  *
121
98
  * @param {Array} blocks Array of blocks.
122
99
  */
123
100
 
124
101
 
125
- function* resetBlocks(blocks) {
126
- yield {
102
+ const resetBlocks = blocks => ({
103
+ dispatch
104
+ }) => {
105
+ dispatch({
127
106
  type: 'RESET_BLOCKS',
128
107
  blocks
129
- };
130
- return yield* validateBlocksToTemplate(blocks);
131
- }
108
+ });
109
+ dispatch(validateBlocksToTemplate(blocks));
110
+ };
132
111
  /**
133
112
  * Block validity is a function of blocks state (at the point of a
134
113
  * reset) and the template setting. As a compromise to its placement
@@ -139,20 +118,25 @@ function* resetBlocks(blocks) {
139
118
  */
140
119
 
141
120
 
142
- function* validateBlocksToTemplate(blocks) {
143
- const template = yield _data.controls.select(_constants.STORE_NAME, 'getTemplate');
144
- const templateLock = yield _data.controls.select(_constants.STORE_NAME, 'getTemplateLock'); // Unlocked templates are considered always valid because they act
121
+ exports.resetBlocks = resetBlocks;
122
+
123
+ const validateBlocksToTemplate = blocks => ({
124
+ select,
125
+ dispatch
126
+ }) => {
127
+ const template = select.getTemplate();
128
+ const templateLock = select.getTemplateLock(); // Unlocked templates are considered always valid because they act
145
129
  // as default values only.
146
130
 
147
131
  const isBlocksValidToTemplate = !template || templateLock !== 'all' || (0, _blocks.doBlocksMatchTemplate)(blocks, template); // Update if validity has changed.
148
132
 
149
- const isValidTemplate = yield _data.controls.select(_constants.STORE_NAME, 'isValidTemplate');
133
+ const isValidTemplate = select.isValidTemplate();
150
134
 
151
135
  if (isBlocksValidToTemplate !== isValidTemplate) {
152
- yield setTemplateValidity(isBlocksValidToTemplate);
136
+ dispatch.setTemplateValidity(isBlocksValidToTemplate);
153
137
  return isBlocksValidToTemplate;
154
138
  }
155
- }
139
+ };
156
140
  /**
157
141
  * A block selection object.
158
142
  *
@@ -178,6 +162,8 @@ function* validateBlocksToTemplate(blocks) {
178
162
  */
179
163
 
180
164
 
165
+ exports.validateBlocksToTemplate = validateBlocksToTemplate;
166
+
181
167
  function resetSelection(selectionStart, selectionEnd, initialPosition) {
182
168
  /* eslint-enable jsdoc/valid-types */
183
169
  return {
@@ -211,8 +197,7 @@ function receiveBlocks(blocks) {
211
197
  };
212
198
  }
213
199
  /**
214
- * Returns an action object used in signalling that the multiple blocks'
215
- * attributes with the specified client IDs have been updated.
200
+ * Action that updates attributes of multiple blocks with the specified client IDs.
216
201
  *
217
202
  * @param {string|string[]} clientIds Block client IDs.
218
203
  * @param {Object} attributes Block attributes to be merged. Should be keyed by clientIds if
@@ -231,8 +216,7 @@ function updateBlockAttributes(clientIds, attributes, uniqueByBlock = false) {
231
216
  };
232
217
  }
233
218
  /**
234
- * Returns an action object used in signalling that the block with the
235
- * specified client ID has been updated.
219
+ * Action that updates the block with the specified client ID.
236
220
  *
237
221
  * @param {string} clientId Block client ID.
238
222
  * @param {Object} updates Block attributes to be merged.
@@ -280,14 +264,16 @@ function selectBlock(clientId, initialPosition = 0) {
280
264
  */
281
265
 
282
266
 
283
- function* selectPreviousBlock(clientId) {
284
- const previousBlockClientId = yield _data.controls.select(_constants.STORE_NAME, 'getPreviousBlockClientId', clientId);
267
+ const selectPreviousBlock = clientId => ({
268
+ select,
269
+ dispatch
270
+ }) => {
271
+ const previousBlockClientId = select.getPreviousBlockClientId(clientId);
285
272
 
286
273
  if (previousBlockClientId) {
287
- yield selectBlock(previousBlockClientId, -1);
288
- return [previousBlockClientId];
274
+ dispatch.selectBlock(previousBlockClientId, -1);
289
275
  }
290
- }
276
+ };
291
277
  /**
292
278
  * Yields action objects used in signalling that the block following the given
293
279
  * clientId should be selected.
@@ -296,28 +282,34 @@ function* selectPreviousBlock(clientId) {
296
282
  */
297
283
 
298
284
 
299
- function* selectNextBlock(clientId) {
300
- const nextBlockClientId = yield _data.controls.select(_constants.STORE_NAME, 'getNextBlockClientId', clientId);
285
+ exports.selectPreviousBlock = selectPreviousBlock;
286
+
287
+ const selectNextBlock = clientId => ({
288
+ select,
289
+ dispatch
290
+ }) => {
291
+ const nextBlockClientId = select.getNextBlockClientId(clientId);
301
292
 
302
293
  if (nextBlockClientId) {
303
- yield selectBlock(nextBlockClientId);
304
- return [nextBlockClientId];
294
+ dispatch.selectBlock(nextBlockClientId);
305
295
  }
306
- }
296
+ };
307
297
  /**
308
- * Returns an action object used in signalling that a block multi-selection has started.
298
+ * Action that starts block multi-selection.
309
299
  *
310
300
  * @return {Object} Action object.
311
301
  */
312
302
 
313
303
 
304
+ exports.selectNextBlock = selectNextBlock;
305
+
314
306
  function startMultiSelect() {
315
307
  return {
316
308
  type: 'START_MULTI_SELECT'
317
309
  };
318
310
  }
319
311
  /**
320
- * Returns an action object used in signalling that block multi-selection stopped.
312
+ * Action that stops block multi-selection.
321
313
  *
322
314
  * @return {Object} Action object.
323
315
  */
@@ -329,45 +321,50 @@ function stopMultiSelect() {
329
321
  };
330
322
  }
331
323
  /**
332
- * Returns an action object used in signalling that block multi-selection changed.
324
+ * Action that changes block multi-selection.
333
325
  *
334
326
  * @param {string} start First block of the multi selection.
335
327
  * @param {string} end Last block of the multiselection.
336
328
  */
337
329
 
338
330
 
339
- function* multiSelect(start, end) {
340
- const startBlockRootClientId = yield _data.controls.select(_constants.STORE_NAME, 'getBlockRootClientId', start);
341
- const endBlockRootClientId = yield _data.controls.select(_constants.STORE_NAME, 'getBlockRootClientId', end); // Only allow block multi-selections at the same level.
331
+ const multiSelect = (start, end) => ({
332
+ select,
333
+ dispatch
334
+ }) => {
335
+ const startBlockRootClientId = select.getBlockRootClientId(start);
336
+ const endBlockRootClientId = select.getBlockRootClientId(end); // Only allow block multi-selections at the same level.
342
337
 
343
338
  if (startBlockRootClientId !== endBlockRootClientId) {
344
339
  return;
345
340
  }
346
341
 
347
- yield {
342
+ dispatch({
348
343
  type: 'MULTI_SELECT',
349
344
  start,
350
345
  end
351
- };
352
- const blockCount = yield _data.controls.select(_constants.STORE_NAME, 'getSelectedBlockCount');
346
+ });
347
+ const blockCount = select.getSelectedBlockCount();
353
348
  (0, _a11y.speak)((0, _i18n.sprintf)(
354
349
  /* translators: %s: number of selected blocks */
355
350
  (0, _i18n._n)('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive');
356
- }
351
+ };
357
352
  /**
358
- * Returns an action object used in signalling that the block selection is cleared.
353
+ * Action that clears the block selection.
359
354
  *
360
355
  * @return {Object} Action object.
361
356
  */
362
357
 
363
358
 
359
+ exports.multiSelect = multiSelect;
360
+
364
361
  function clearSelectedBlock() {
365
362
  return {
366
363
  type: 'CLEAR_SELECTED_BLOCK'
367
364
  };
368
365
  }
369
366
  /**
370
- * Returns an action object that enables or disables block selection.
367
+ * Action that enables or disables block selection.
371
368
  *
372
369
  * @param {boolean} [isSelectionEnabled=true] Whether block selection should
373
370
  * be enabled.
@@ -420,8 +417,7 @@ function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
420
417
  /* eslint-disable jsdoc/valid-types */
421
418
 
422
419
  /**
423
- * Returns an action object signalling that a blocks should be replaced with
424
- * one or more replacement blocks.
420
+ * Action that replaces given blocks with one or more replacement blocks.
425
421
  *
426
422
  * @param {(string|string[])} clientIds Block client ID(s) to replace.
427
423
  * @param {(Object|Object[])} blocks Replacement block(s).
@@ -429,26 +425,29 @@ function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
429
425
  * @param {0|-1|null} initialPosition Index of caret after in the selected block after the operation.
430
426
  * @param {?Object} meta Optional Meta values to be passed to the action object.
431
427
  *
432
- * @yield {Object} Action object.
428
+ * @return {Object} Action object.
433
429
  */
434
430
 
435
431
 
436
- function* replaceBlocks(clientIds, blocks, indexToSelect, initialPosition = 0, meta) {
432
+ const replaceBlocks = (clientIds, blocks, indexToSelect, initialPosition = 0, meta) => ({
433
+ select,
434
+ dispatch
435
+ }) => {
437
436
  /* eslint-enable jsdoc/valid-types */
438
437
  clientIds = (0, _lodash.castArray)(clientIds);
439
- blocks = getBlocksWithDefaultStylesApplied((0, _lodash.castArray)(blocks), yield _data.controls.select(_constants.STORE_NAME, 'getSettings'));
440
- const rootClientId = yield _data.controls.select(_constants.STORE_NAME, 'getBlockRootClientId', (0, _lodash.first)(clientIds)); // Replace is valid if the new blocks can be inserted in the root block.
438
+ blocks = getBlocksWithDefaultStylesApplied((0, _lodash.castArray)(blocks), select.getSettings());
439
+ const rootClientId = select.getBlockRootClientId((0, _lodash.first)(clientIds)); // Replace is valid if the new blocks can be inserted in the root block.
441
440
 
442
441
  for (let index = 0; index < blocks.length; index++) {
443
442
  const block = blocks[index];
444
- const canInsertBlock = yield _data.controls.select(_constants.STORE_NAME, 'canInsertBlockType', block.name, rootClientId);
443
+ const canInsertBlock = select.canInsertBlockType(block.name, rootClientId);
445
444
 
446
445
  if (!canInsertBlock) {
447
446
  return;
448
447
  }
449
448
  }
450
449
 
451
- yield {
450
+ dispatch({
452
451
  type: 'REPLACE_BLOCKS',
453
452
  clientIds,
454
453
  blocks,
@@ -456,12 +455,11 @@ function* replaceBlocks(clientIds, blocks, indexToSelect, initialPosition = 0, m
456
455
  indexToSelect,
457
456
  initialPosition,
458
457
  meta
459
- };
460
- yield* ensureDefaultBlock();
461
- }
458
+ });
459
+ dispatch(ensureDefaultBlock());
460
+ };
462
461
  /**
463
- * Returns an action object signalling that a single block should be replaced
464
- * with one or more replacement blocks.
462
+ * Action that replaces a single block with one or more replacement blocks.
465
463
  *
466
464
  * @param {(string|string[])} clientId Block client ID to replace.
467
465
  * @param {(Object|Object[])} block Replacement block(s).
@@ -470,6 +468,8 @@ function* replaceBlocks(clientIds, blocks, indexToSelect, initialPosition = 0, m
470
468
  */
471
469
 
472
470
 
471
+ exports.replaceBlocks = replaceBlocks;
472
+
473
473
  function replaceBlock(clientId, block) {
474
474
  return replaceBlocks(clientId, block);
475
475
  }
@@ -483,91 +483,89 @@ function replaceBlock(clientId, block) {
483
483
  */
484
484
 
485
485
 
486
- function createOnMove(type) {
487
- return function* (clientIds, rootClientId) {
488
- const canMoveBlocks = yield _data.controls.select(_constants.STORE_NAME, 'canMoveBlocks', clientIds, rootClientId); // If one of the blocks is locked or the parent is locked, we cannot move any block.
486
+ const createOnMove = type => (clientIds, rootClientId) => ({
487
+ select,
488
+ dispatch
489
+ }) => {
490
+ // If one of the blocks is locked or the parent is locked, we cannot move any block.
491
+ const canMoveBlocks = select.canMoveBlocks(clientIds, rootClientId);
489
492
 
490
- if (!canMoveBlocks) {
491
- return;
492
- }
493
+ if (!canMoveBlocks) {
494
+ return;
495
+ }
493
496
 
494
- yield {
495
- clientIds: (0, _lodash.castArray)(clientIds),
496
- type,
497
- rootClientId
498
- };
499
- };
500
- }
497
+ dispatch({
498
+ type,
499
+ clientIds: (0, _lodash.castArray)(clientIds),
500
+ rootClientId
501
+ });
502
+ };
501
503
 
502
504
  const moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN');
503
505
  exports.moveBlocksDown = moveBlocksDown;
504
506
  const moveBlocksUp = createOnMove('MOVE_BLOCKS_UP');
505
507
  /**
506
- * Returns an action object signalling that the given blocks should be moved to
507
- * a new position.
508
+ * Action that moves given blocks to a new position.
508
509
  *
509
510
  * @param {?string} clientIds The client IDs of the blocks.
510
511
  * @param {?string} fromRootClientId Root client ID source.
511
512
  * @param {?string} toRootClientId Root client ID destination.
512
513
  * @param {number} index The index to move the blocks to.
513
- *
514
- * @yield {Object} Action object.
515
514
  */
516
515
 
517
516
  exports.moveBlocksUp = moveBlocksUp;
518
517
 
519
- function* moveBlocksToPosition(clientIds, fromRootClientId = '', toRootClientId = '', index) {
520
- const canMoveBlocks = yield _data.controls.select(_constants.STORE_NAME, 'canMoveBlocks', clientIds, fromRootClientId);
521
- const canRemoveBlocks = yield _data.controls.select(_constants.STORE_NAME, 'canRemoveBlocks', clientIds, fromRootClientId); // If one of the blocks is locked or the parent is locked, we cannot move any block.
518
+ const moveBlocksToPosition = (clientIds, fromRootClientId = '', toRootClientId = '', index) => ({
519
+ select,
520
+ dispatch
521
+ }) => {
522
+ const canMoveBlocks = select.canMoveBlocks(clientIds, fromRootClientId); // If one of the blocks is locked or the parent is locked, we cannot move any block.
522
523
 
523
524
  if (!canMoveBlocks) {
524
525
  return;
526
+ } // If moving inside the same root block the move is always possible.
527
+
528
+
529
+ if (fromRootClientId !== toRootClientId) {
530
+ const canRemoveBlocks = select.canRemoveBlocks(clientIds, fromRootClientId); // If we're moving to another block, it means we're deleting blocks from
531
+ // the original block, so we need to check if removing is possible.
532
+
533
+ if (!canRemoveBlocks) {
534
+ return;
535
+ }
536
+
537
+ const canInsertBlocks = select.canInsertBlocks(clientIds, toRootClientId); // If moving to other parent block, the move is possible if we can insert a block of the same type inside the new parent block.
538
+
539
+ if (!canInsertBlocks) {
540
+ return;
541
+ }
525
542
  }
526
543
 
527
- const action = {
544
+ dispatch({
528
545
  type: 'MOVE_BLOCKS_TO_POSITION',
529
546
  fromRootClientId,
530
547
  toRootClientId,
531
548
  clientIds,
532
549
  index
533
- }; // If moving inside the same root block the move is always possible.
534
-
535
- if (fromRootClientId === toRootClientId) {
536
- yield action;
537
- return;
538
- } // If we're moving to another block, it means we're deleting blocks from
539
- // the original block, so we need to check if removing is possible.
540
-
541
-
542
- if (!canRemoveBlocks) {
543
- return;
544
- }
545
-
546
- const canInsertBlocks = yield _data.controls.select(_constants.STORE_NAME, 'canInsertBlocks', clientIds, toRootClientId); // If moving to other parent block, the move is possible if we can insert a block of the same type inside the new parent block.
547
-
548
- if (canInsertBlocks) {
549
- yield action;
550
- }
551
- }
550
+ });
551
+ };
552
552
  /**
553
- * Returns an action object signalling that the given block should be moved to a
554
- * new position.
553
+ * Action that moves given block to a new position.
555
554
  *
556
555
  * @param {?string} clientId The client ID of the block.
557
556
  * @param {?string} fromRootClientId Root client ID source.
558
557
  * @param {?string} toRootClientId Root client ID destination.
559
558
  * @param {number} index The index to move the block to.
560
- *
561
- * @yield {Object} Action object.
562
559
  */
563
560
 
564
561
 
565
- function* moveBlockToPosition(clientId, fromRootClientId = '', toRootClientId = '', index) {
566
- yield moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index);
562
+ exports.moveBlocksToPosition = moveBlocksToPosition;
563
+
564
+ function moveBlockToPosition(clientId, fromRootClientId = '', toRootClientId = '', index) {
565
+ return moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index);
567
566
  }
568
567
  /**
569
- * Returns an action object used in signalling that a single block should be
570
- * inserted, optionally at a specific index respective a root block list.
568
+ * Action that inserts a single block, optionally at a specific index respective a root block list.
571
569
  *
572
570
  * @param {Object} block Block object to insert.
573
571
  * @param {?number} index Index at which block should be inserted.
@@ -579,14 +577,13 @@ function* moveBlockToPosition(clientId, fromRootClientId = '', toRootClientId =
579
577
  */
580
578
 
581
579
 
582
- function insertBlock(block, index, rootClientId, updateSelection = true, meta) {
580
+ function insertBlock(block, index, rootClientId, updateSelection, meta) {
583
581
  return insertBlocks([block], index, rootClientId, updateSelection, 0, meta);
584
582
  }
585
583
  /* eslint-disable jsdoc/valid-types */
586
584
 
587
585
  /**
588
- * Returns an action object used in signalling that an array of blocks should
589
- * be inserted, optionally at a specific index respective a root block list.
586
+ * Action that inserts an array of blocks, optionally at a specific index respective a root block list.
590
587
  *
591
588
  * @param {Object[]} blocks Block objects to insert.
592
589
  * @param {?number} index Index at which block should be inserted.
@@ -598,7 +595,10 @@ function insertBlock(block, index, rootClientId, updateSelection = true, meta) {
598
595
  */
599
596
 
600
597
 
601
- function* insertBlocks(blocks, index, rootClientId, updateSelection = true, initialPosition = 0, meta) {
598
+ const insertBlocks = (blocks, index, rootClientId, updateSelection = true, initialPosition = 0, meta) => ({
599
+ select,
600
+ dispatch
601
+ }) => {
602
602
  /* eslint-enable jsdoc/valid-types */
603
603
  if ((0, _lodash.isObject)(initialPosition)) {
604
604
  meta = initialPosition;
@@ -610,11 +610,11 @@ function* insertBlocks(blocks, index, rootClientId, updateSelection = true, init
610
610
  });
611
611
  }
612
612
 
613
- blocks = getBlocksWithDefaultStylesApplied((0, _lodash.castArray)(blocks), yield _data.controls.select(_constants.STORE_NAME, 'getSettings'));
613
+ blocks = getBlocksWithDefaultStylesApplied((0, _lodash.castArray)(blocks), select.getSettings());
614
614
  const allowedBlocks = [];
615
615
 
616
616
  for (const block of blocks) {
617
- const isValid = yield _data.controls.select(_constants.STORE_NAME, 'canInsertBlockType', block.name, rootClientId);
617
+ const isValid = select.canInsertBlockType(block.name, rootClientId);
618
618
 
619
619
  if (isValid) {
620
620
  allowedBlocks.push(block);
@@ -622,7 +622,7 @@ function* insertBlocks(blocks, index, rootClientId, updateSelection = true, init
622
622
  }
623
623
 
624
624
  if (allowedBlocks.length) {
625
- return {
625
+ dispatch({
626
626
  type: 'INSERT_BLOCKS',
627
627
  blocks: allowedBlocks,
628
628
  index,
@@ -631,12 +631,11 @@ function* insertBlocks(blocks, index, rootClientId, updateSelection = true, init
631
631
  updateSelection,
632
632
  initialPosition: updateSelection ? initialPosition : null,
633
633
  meta
634
- };
634
+ });
635
635
  }
636
- }
636
+ };
637
637
  /**
638
- * Returns an action object used in signalling that the insertion point should
639
- * be shown.
638
+ * Action that shows the insertion point.
640
639
  *
641
640
  * @param {?string} rootClientId Optional root client ID of block list on
642
641
  * which to insert.
@@ -647,6 +646,8 @@ function* insertBlocks(blocks, index, rootClientId, updateSelection = true, init
647
646
  */
648
647
 
649
648
 
649
+ exports.insertBlocks = insertBlocks;
650
+
650
651
  function showInsertionPoint(rootClientId, index, __unstableOptions = {}) {
651
652
  const {
652
653
  __unstableWithInserter
@@ -659,7 +660,7 @@ function showInsertionPoint(rootClientId, index, __unstableOptions = {}) {
659
660
  };
660
661
  }
661
662
  /**
662
- * Returns an action object hiding the insertion point.
663
+ * Action that hides the insertion point.
663
664
  *
664
665
  * @return {Object} Action object.
665
666
  */
@@ -671,7 +672,7 @@ function hideInsertionPoint() {
671
672
  };
672
673
  }
673
674
  /**
674
- * Returns an action object resetting the template validity.
675
+ * Action that resets the template validity.
675
676
  *
676
677
  * @param {boolean} isValid template validity flag.
677
678
  *
@@ -686,51 +687,59 @@ function setTemplateValidity(isValid) {
686
687
  };
687
688
  }
688
689
  /**
689
- * Returns an action object synchronize the template with the list of blocks
690
+ * Action that synchronizes the template with the list of blocks.
690
691
  *
691
692
  * @return {Object} Action object.
692
693
  */
693
694
 
694
695
 
695
- function* synchronizeTemplate() {
696
- yield {
696
+ const synchronizeTemplate = () => ({
697
+ select,
698
+ dispatch
699
+ }) => {
700
+ dispatch({
697
701
  type: 'SYNCHRONIZE_TEMPLATE'
698
- };
699
- const blocks = yield _data.controls.select(_constants.STORE_NAME, 'getBlocks');
700
- const template = yield _data.controls.select(_constants.STORE_NAME, 'getTemplate');
702
+ });
703
+ const blocks = select.getBlocks();
704
+ const template = select.getTemplate();
701
705
  const updatedBlockList = (0, _blocks.synchronizeBlocksWithTemplate)(blocks, template);
702
- return yield resetBlocks(updatedBlockList);
703
- }
706
+ dispatch.resetBlocks(updatedBlockList);
707
+ };
704
708
  /**
705
- * Returns an action object used in signalling that two blocks should be merged
709
+ * Action that merges two blocks.
706
710
  *
707
711
  * @param {string} firstBlockClientId Client ID of the first block to merge.
708
712
  * @param {string} secondBlockClientId Client ID of the second block to merge.
709
713
  */
710
714
 
711
715
 
712
- function* mergeBlocks(firstBlockClientId, secondBlockClientId) {
716
+ exports.synchronizeTemplate = synchronizeTemplate;
717
+
718
+ const mergeBlocks = (firstBlockClientId, secondBlockClientId) => ({
719
+ select,
720
+ dispatch
721
+ }) => {
713
722
  const blocks = [firstBlockClientId, secondBlockClientId];
714
- yield {
723
+ dispatch({
715
724
  type: 'MERGE_BLOCKS',
716
725
  blocks
717
- };
726
+ });
718
727
  const [clientIdA, clientIdB] = blocks;
719
- const blockA = yield _data.controls.select(_constants.STORE_NAME, 'getBlock', clientIdA);
728
+ const blockA = select.getBlock(clientIdA);
720
729
  const blockAType = (0, _blocks.getBlockType)(blockA.name); // Only focus the previous block if it's not mergeable
721
730
 
722
731
  if (blockAType && !blockAType.merge) {
723
- yield selectBlock(blockA.clientId);
732
+ dispatch.selectBlock(blockA.clientId);
724
733
  return;
725
734
  }
726
735
 
727
- const blockB = yield _data.controls.select(_constants.STORE_NAME, 'getBlock', clientIdB);
736
+ const blockB = select.getBlock(clientIdB);
728
737
  const blockBType = (0, _blocks.getBlockType)(blockB.name);
729
738
  const {
730
739
  clientId,
731
740
  attributeKey,
732
741
  offset
733
- } = yield _data.controls.select(_constants.STORE_NAME, 'getSelectionStart');
742
+ } = select.getSelectionStart();
734
743
  const selectedBlockType = clientId === clientIdA ? blockAType : blockBType;
735
744
  const attributeDefinition = selectedBlockType.attributes[attributeKey];
736
745
  const canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== undefined && offset !== undefined && // We cannot restore text selection if the RichText identifier
@@ -808,16 +817,16 @@ function* mergeBlocks(firstBlockClientId, secondBlockClientId) {
808
817
  preserveWhiteSpace
809
818
  });
810
819
  updatedAttributes[newAttributeKey] = newHtml;
811
- yield selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset);
820
+ dispatch.selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset);
812
821
  }
813
822
 
814
- yield* replaceBlocks([blockA.clientId, blockB.clientId], [{ ...blockA,
823
+ dispatch.replaceBlocks([blockA.clientId, blockB.clientId], [{ ...blockA,
815
824
  attributes: { ...blockA.attributes,
816
825
  ...updatedAttributes
817
826
  }
818
827
  }, ...blocksWithTheSameType.slice(1)], 0 // If we don't pass the `indexToSelect` it will default to the last block.
819
828
  );
820
- }
829
+ };
821
830
  /**
822
831
  * Yields action objects used in signalling that the blocks corresponding to
823
832
  * the set of specified client IDs are to be removed.
@@ -828,36 +837,36 @@ function* mergeBlocks(firstBlockClientId, secondBlockClientId) {
828
837
  */
829
838
 
830
839
 
831
- function* removeBlocks(clientIds, selectPrevious = true) {
840
+ exports.mergeBlocks = mergeBlocks;
841
+
842
+ const removeBlocks = (clientIds, selectPrevious = true) => ({
843
+ select,
844
+ dispatch
845
+ }) => {
832
846
  if (!clientIds || !clientIds.length) {
833
847
  return;
834
848
  }
835
849
 
836
850
  clientIds = (0, _lodash.castArray)(clientIds);
837
- const rootClientId = yield _data.controls.select(_constants.STORE_NAME, 'getBlockRootClientId', clientIds[0]);
838
- const canRemoveBlocks = yield _data.controls.select(_constants.STORE_NAME, 'canRemoveBlocks', clientIds, rootClientId);
851
+ const rootClientId = select.getBlockRootClientId(clientIds[0]);
852
+ const canRemoveBlocks = select.canRemoveBlocks(clientIds, rootClientId);
839
853
 
840
854
  if (!canRemoveBlocks) {
841
855
  return;
842
856
  }
843
857
 
844
- let previousBlockId;
845
-
846
858
  if (selectPrevious) {
847
- previousBlockId = yield selectPreviousBlock(clientIds[0]);
848
- } else {
849
- previousBlockId = yield _data.controls.select(_constants.STORE_NAME, 'getPreviousBlockClientId', clientIds[0]);
859
+ dispatch.selectPreviousBlock(clientIds[0]);
850
860
  }
851
861
 
852
- yield {
862
+ dispatch({
853
863
  type: 'REMOVE_BLOCKS',
854
864
  clientIds
855
- }; // To avoid a focus loss when removing the last block, assure there is
865
+ }); // To avoid a focus loss when removing the last block, assure there is
856
866
  // always a default block if the last of the blocks have been removed.
857
867
 
858
- const defaultBlockId = yield* ensureDefaultBlock();
859
- return [previousBlockId || defaultBlockId];
860
- }
868
+ dispatch(ensureDefaultBlock());
869
+ };
861
870
  /**
862
871
  * Returns an action object used in signalling that the block with the
863
872
  * specified client ID is to be removed.
@@ -870,6 +879,8 @@ function* removeBlocks(clientIds, selectPrevious = true) {
870
879
  */
871
880
 
872
881
 
882
+ exports.removeBlocks = removeBlocks;
883
+
873
884
  function removeBlock(clientId, selectPrevious) {
874
885
  return removeBlocks([clientId], selectPrevious);
875
886
  }
@@ -990,8 +1001,7 @@ function exitFormattedText() {
990
1001
  };
991
1002
  }
992
1003
  /**
993
- * Returns an action object used in signalling that the user caret has changed
994
- * position.
1004
+ * Action that changes the position of the user caret.
995
1005
  *
996
1006
  * @param {string} clientId The selected block client ID.
997
1007
  * @param {string} attributeKey The selected block attribute key.
@@ -1012,8 +1022,7 @@ function selectionChange(clientId, attributeKey, startOffset, endOffset) {
1012
1022
  };
1013
1023
  }
1014
1024
  /**
1015
- * Returns an action object used in signalling that a new block of the default
1016
- * type should be added to the block list.
1025
+ * Action that adds a new block of the default type to the block list.
1017
1026
  *
1018
1027
  * @param {?Object} attributes Optional attributes of the block to assign.
1019
1028
  * @param {?string} rootClientId Optional root client ID of block list on which
@@ -1036,7 +1045,7 @@ function insertDefaultBlock(attributes, rootClientId, index) {
1036
1045
  return insertBlock(block, index, rootClientId);
1037
1046
  }
1038
1047
  /**
1039
- * Returns an action object that changes the nested settings of a given block.
1048
+ * Action that changes the nested settings of a given block.
1040
1049
  *
1041
1050
  * @param {string} clientId Client ID of the block whose nested setting are
1042
1051
  * being received.
@@ -1054,7 +1063,7 @@ function updateBlockListSettings(clientId, settings) {
1054
1063
  };
1055
1064
  }
1056
1065
  /**
1057
- * Returns an action object used in signalling that the block editor settings have been updated.
1066
+ * Action that updates the block editor settings.
1058
1067
  *
1059
1068
  * @param {Object} settings Updated settings
1060
1069
  *
@@ -1069,7 +1078,7 @@ function updateSettings(settings) {
1069
1078
  };
1070
1079
  }
1071
1080
  /**
1072
- * Returns an action object used in signalling that a temporary reusable blocks have been saved
1081
+ * Action that signals that a temporary reusable block has been saved
1073
1082
  * in order to switch its temporary id with the real id.
1074
1083
  *
1075
1084
  * @param {string} id Reusable block's id.
@@ -1087,7 +1096,7 @@ function __unstableSaveReusableBlock(id, updatedId) {
1087
1096
  };
1088
1097
  }
1089
1098
  /**
1090
- * Returns an action object used in signalling that the last block change should be marked explicitly as persistent.
1099
+ * Action that marks the last block change explicitly as persistent.
1091
1100
  *
1092
1101
  * @return {Object} Action object.
1093
1102
  */
@@ -1099,7 +1108,7 @@ function __unstableMarkLastChangeAsPersistent() {
1099
1108
  };
1100
1109
  }
1101
1110
  /**
1102
- * Returns an action object used in signalling that the next block change should be marked explicitly as not persistent.
1111
+ * Action that signals that the next block change should be marked explicitly as not persistent.
1103
1112
  *
1104
1113
  * @return {Object} Action object.
1105
1114
  */
@@ -1111,151 +1120,180 @@ function __unstableMarkNextChangeAsNotPersistent() {
1111
1120
  };
1112
1121
  }
1113
1122
  /**
1114
- * Returns an action object used in signalling that the last block change is
1115
- * an automatic change, meaning it was not performed by the user, and can be
1116
- * undone using the `Escape` and `Backspace` keys. This action must be called
1117
- * after the change was made, and any actions that are a consequence of it, so
1118
- * it is recommended to be called at the next idle period to ensure all
1123
+ * Action that marks the last block change as an automatic change, meaning it was not
1124
+ * performed by the user, and can be undone using the `Escape` and `Backspace` keys.
1125
+ * This action must be called after the change was made, and any actions that are a
1126
+ * consequence of it, so it is recommended to be called at the next idle period to ensure all
1119
1127
  * selection changes have been recorded.
1120
1128
  */
1121
1129
 
1122
1130
 
1123
- function* __unstableMarkAutomaticChange() {
1124
- yield {
1131
+ const __unstableMarkAutomaticChange = () => ({
1132
+ dispatch
1133
+ }) => {
1134
+ dispatch({
1125
1135
  type: 'MARK_AUTOMATIC_CHANGE'
1126
- };
1127
- yield (0, _controls.__unstableMarkAutomaticChangeFinalControl)();
1128
- }
1129
-
1130
- function __unstableMarkAutomaticChangeFinal() {
1131
- return {
1132
- type: 'MARK_AUTOMATIC_CHANGE_FINAL'
1133
- };
1134
- }
1136
+ });
1137
+ const {
1138
+ requestIdleCallback = cb => setTimeout(cb, 100)
1139
+ } = window;
1140
+ requestIdleCallback(() => {
1141
+ dispatch({
1142
+ type: 'MARK_AUTOMATIC_CHANGE_FINAL'
1143
+ });
1144
+ });
1145
+ };
1135
1146
  /**
1136
- * Generators that triggers an action used to enable or disable the navigation mode.
1147
+ * Action that enables or disables the navigation mode.
1137
1148
  *
1138
1149
  * @param {string} isNavigationMode Enable/Disable navigation mode.
1139
1150
  */
1140
1151
 
1141
1152
 
1142
- function* setNavigationMode(isNavigationMode = true) {
1143
- yield {
1153
+ exports.__unstableMarkAutomaticChange = __unstableMarkAutomaticChange;
1154
+
1155
+ const setNavigationMode = (isNavigationMode = true) => ({
1156
+ dispatch
1157
+ }) => {
1158
+ dispatch({
1144
1159
  type: 'SET_NAVIGATION_MODE',
1145
1160
  isNavigationMode
1146
- };
1161
+ });
1147
1162
 
1148
1163
  if (isNavigationMode) {
1149
1164
  (0, _a11y.speak)((0, _i18n.__)('You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.'));
1150
1165
  } else {
1151
1166
  (0, _a11y.speak)((0, _i18n.__)('You are currently in edit mode. To return to the navigation mode, press Escape.'));
1152
1167
  }
1153
- }
1168
+ };
1154
1169
  /**
1155
- * Generator that triggers an action used to enable or disable the block moving mode.
1170
+ * Action that enables or disables the block moving mode.
1156
1171
  *
1157
1172
  * @param {string|null} hasBlockMovingClientId Enable/Disable block moving mode.
1158
1173
  */
1159
1174
 
1160
1175
 
1161
- function* setBlockMovingClientId(hasBlockMovingClientId = null) {
1162
- yield {
1176
+ exports.setNavigationMode = setNavigationMode;
1177
+
1178
+ const setBlockMovingClientId = (hasBlockMovingClientId = null) => ({
1179
+ dispatch
1180
+ }) => {
1181
+ dispatch({
1163
1182
  type: 'SET_BLOCK_MOVING_MODE',
1164
1183
  hasBlockMovingClientId
1165
- };
1184
+ });
1166
1185
 
1167
1186
  if (hasBlockMovingClientId) {
1168
1187
  (0, _a11y.speak)((0, _i18n.__)('Use the Tab key and Arrow keys to choose new block location. Use Left and Right Arrow keys to move between nesting levels. Once location is selected press Enter or Space to move the block.'));
1169
1188
  }
1170
- }
1189
+ };
1171
1190
  /**
1172
- * Generator that triggers an action used to duplicate a list of blocks.
1191
+ * Action that duplicates a list of blocks.
1173
1192
  *
1174
1193
  * @param {string[]} clientIds
1175
1194
  * @param {boolean} updateSelection
1176
1195
  */
1177
1196
 
1178
1197
 
1179
- function* duplicateBlocks(clientIds, updateSelection = true) {
1180
- if (!clientIds && !clientIds.length) {
1198
+ exports.setBlockMovingClientId = setBlockMovingClientId;
1199
+
1200
+ const duplicateBlocks = (clientIds, updateSelection = true) => ({
1201
+ select,
1202
+ dispatch
1203
+ }) => {
1204
+ if (!clientIds || !clientIds.length) {
1181
1205
  return;
1182
- }
1206
+ } // Return early if blocks don't exist.
1183
1207
 
1184
- const blocks = yield _data.controls.select(_constants.STORE_NAME, 'getBlocksByClientId', clientIds);
1185
- const rootClientId = yield _data.controls.select(_constants.STORE_NAME, 'getBlockRootClientId', clientIds[0]); // Return early if blocks don't exist.
1208
+
1209
+ const blocks = select.getBlocksByClientId(clientIds);
1186
1210
 
1187
1211
  if ((0, _lodash.some)(blocks, block => !block)) {
1188
1212
  return;
1189
- }
1213
+ } // Return early if blocks don't support multiple usage.
1190
1214
 
1191
- const blockNames = blocks.map(block => block.name); // Return early if blocks don't support multiple usage.
1192
1215
 
1193
- if ((0, _lodash.some)(blockNames, blockName => !(0, _blocks.hasBlockSupport)(blockName, 'multiple', true))) {
1216
+ const blockNames = blocks.map(block => block.name);
1217
+
1218
+ if (blockNames.some(blockName => !(0, _blocks.hasBlockSupport)(blockName, 'multiple', true))) {
1194
1219
  return;
1195
1220
  }
1196
1221
 
1197
- const lastSelectedIndex = yield _data.controls.select(_constants.STORE_NAME, 'getBlockIndex', (0, _lodash.last)((0, _lodash.castArray)(clientIds)), rootClientId);
1222
+ const rootClientId = select.getBlockRootClientId(clientIds[0]);
1223
+ const lastSelectedIndex = select.getBlockIndex((0, _lodash.last)((0, _lodash.castArray)(clientIds)), rootClientId);
1198
1224
  const clonedBlocks = blocks.map(block => (0, _blocks.__experimentalCloneSanitizedBlock)(block));
1199
- yield insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId, updateSelection);
1225
+ dispatch.insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId, updateSelection);
1200
1226
 
1201
1227
  if (clonedBlocks.length > 1 && updateSelection) {
1202
- yield multiSelect((0, _lodash.first)(clonedBlocks).clientId, (0, _lodash.last)(clonedBlocks).clientId);
1228
+ dispatch.multiSelect((0, _lodash.first)(clonedBlocks).clientId, (0, _lodash.last)(clonedBlocks).clientId);
1203
1229
  }
1204
1230
 
1205
1231
  return clonedBlocks.map(block => block.clientId);
1206
- }
1232
+ };
1207
1233
  /**
1208
- * Generator used to insert an empty block after a given block.
1234
+ * Action that inserts an empty block before a given block.
1209
1235
  *
1210
1236
  * @param {string} clientId
1211
1237
  */
1212
1238
 
1213
1239
 
1214
- function* insertBeforeBlock(clientId) {
1240
+ exports.duplicateBlocks = duplicateBlocks;
1241
+
1242
+ const insertBeforeBlock = clientId => ({
1243
+ select,
1244
+ dispatch
1245
+ }) => {
1215
1246
  if (!clientId) {
1216
1247
  return;
1217
1248
  }
1218
1249
 
1219
- const rootClientId = yield _data.controls.select(_constants.STORE_NAME, 'getBlockRootClientId', clientId);
1220
- const isLocked = yield _data.controls.select(_constants.STORE_NAME, 'getTemplateLock', rootClientId);
1250
+ const rootClientId = select.getBlockRootClientId(clientId);
1251
+ const isLocked = select.getTemplateLock(rootClientId);
1221
1252
 
1222
1253
  if (isLocked) {
1223
1254
  return;
1224
1255
  }
1225
1256
 
1226
- const firstSelectedIndex = yield _data.controls.select(_constants.STORE_NAME, 'getBlockIndex', clientId, rootClientId);
1227
- return yield insertDefaultBlock({}, rootClientId, firstSelectedIndex);
1228
- }
1257
+ const firstSelectedIndex = select.getBlockIndex(clientId, rootClientId);
1258
+ return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex);
1259
+ };
1229
1260
  /**
1230
- * Generator used to insert an empty block before a given block.
1261
+ * Action that inserts an empty block after a given block.
1231
1262
  *
1232
1263
  * @param {string} clientId
1233
1264
  */
1234
1265
 
1235
1266
 
1236
- function* insertAfterBlock(clientId) {
1267
+ exports.insertBeforeBlock = insertBeforeBlock;
1268
+
1269
+ const insertAfterBlock = clientId => ({
1270
+ select,
1271
+ dispatch
1272
+ }) => {
1237
1273
  if (!clientId) {
1238
1274
  return;
1239
1275
  }
1240
1276
 
1241
- const rootClientId = yield _data.controls.select(_constants.STORE_NAME, 'getBlockRootClientId', clientId);
1242
- const isLocked = yield _data.controls.select(_constants.STORE_NAME, 'getTemplateLock', rootClientId);
1277
+ const rootClientId = select.getBlockRootClientId(clientId);
1278
+ const isLocked = select.getTemplateLock(rootClientId);
1243
1279
 
1244
1280
  if (isLocked) {
1245
1281
  return;
1246
1282
  }
1247
1283
 
1248
- const firstSelectedIndex = yield _data.controls.select(_constants.STORE_NAME, 'getBlockIndex', clientId, rootClientId);
1249
- return yield insertDefaultBlock({}, rootClientId, firstSelectedIndex + 1);
1250
- }
1284
+ const firstSelectedIndex = select.getBlockIndex(clientId, rootClientId);
1285
+ return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex + 1);
1286
+ };
1251
1287
  /**
1252
- * Returns an action object that toggles the highlighted block state.
1288
+ * Action that toggles the highlighted block state.
1253
1289
  *
1254
1290
  * @param {string} clientId The block's clientId.
1255
1291
  * @param {boolean} isHighlighted The highlight state.
1256
1292
  */
1257
1293
 
1258
1294
 
1295
+ exports.insertAfterBlock = insertAfterBlock;
1296
+
1259
1297
  function toggleBlockHighlight(clientId, isHighlighted) {
1260
1298
  return {
1261
1299
  type: 'TOGGLE_BLOCK_HIGHLIGHT',
@@ -1264,29 +1302,29 @@ function toggleBlockHighlight(clientId, isHighlighted) {
1264
1302
  };
1265
1303
  }
1266
1304
  /**
1267
- * Yields action objects used in signalling that the block corresponding to the
1268
- * given clientId should appear to "flash" by rhythmically highlighting it.
1305
+ * Action that "flashes" the block with a given `clientId` by rhythmically highlighting it.
1269
1306
  *
1270
1307
  * @param {string} clientId Target block client ID.
1271
1308
  */
1272
1309
 
1273
1310
 
1274
- function* flashBlock(clientId) {
1275
- yield toggleBlockHighlight(clientId, true);
1276
- yield {
1277
- type: 'SLEEP',
1278
- duration: 150
1279
- };
1280
- yield toggleBlockHighlight(clientId, false);
1281
- }
1311
+ const flashBlock = clientId => async ({
1312
+ dispatch
1313
+ }) => {
1314
+ dispatch(toggleBlockHighlight(clientId, true));
1315
+ await new Promise(resolve => setTimeout(resolve, 150));
1316
+ dispatch(toggleBlockHighlight(clientId, false));
1317
+ };
1282
1318
  /**
1283
- * Returns an action object that sets whether the block has controlled innerblocks.
1319
+ * Action that sets whether a block has controlled inner blocks.
1284
1320
  *
1285
1321
  * @param {string} clientId The block's clientId.
1286
1322
  * @param {boolean} hasControlledInnerBlocks True if the block's inner blocks are controlled.
1287
1323
  */
1288
1324
 
1289
1325
 
1326
+ exports.flashBlock = flashBlock;
1327
+
1290
1328
  function setHasControlledInnerBlocks(clientId, hasControlledInnerBlocks) {
1291
1329
  return {
1292
1330
  type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',