@wordpress/block-editor 8.6.0 → 9.2.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 (466) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +5 -2
  3. package/build/components/block-alignment-control/constants.js +48 -0
  4. package/build/components/block-alignment-control/constants.js.map +1 -0
  5. package/build/components/block-alignment-control/ui.js +9 -40
  6. package/build/components/block-alignment-control/ui.js.map +1 -1
  7. package/build/components/block-alignment-control/ui.native.js +92 -0
  8. package/build/components/block-alignment-control/ui.native.js.map +1 -0
  9. package/build/components/block-alignment-matrix-control/index.js +1 -6
  10. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  11. package/build/components/block-content-overlay/index.js +4 -82
  12. package/build/components/block-content-overlay/index.js.map +1 -1
  13. package/build/components/block-draggable/draggable-chip.native.js +65 -0
  14. package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
  15. package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
  16. package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  17. package/build/components/block-draggable/index.native.js +488 -0
  18. package/build/components/block-draggable/index.native.js.map +1 -0
  19. package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
  20. package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  21. package/build/components/block-list/block-list-context.native.js +195 -0
  22. package/build/components/block-list/block-list-context.native.js.map +1 -0
  23. package/build/components/block-list/block-list-item-cell.native.js +67 -0
  24. package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
  25. package/build/components/block-list/block-list-item.native.js +12 -9
  26. package/build/components/block-list/block-list-item.native.js.map +1 -1
  27. package/build/components/block-list/block.native.js +27 -5
  28. package/build/components/block-list/block.native.js.map +1 -1
  29. package/build/components/block-list/index.js +34 -32
  30. package/build/components/block-list/index.js.map +1 -1
  31. package/build/components/block-list/index.native.js +75 -23
  32. package/build/components/block-list/index.native.js.map +1 -1
  33. package/build/components/block-list/use-block-props/index.js +8 -4
  34. package/build/components/block-list/use-block-props/index.js.map +1 -1
  35. package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
  36. package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  37. package/build/components/block-list/use-in-between-inserter.js +1 -1
  38. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  39. package/build/components/block-mobile-toolbar/index.native.js +10 -3
  40. package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
  41. package/build/components/block-mover/index.native.js +17 -4
  42. package/build/components/block-mover/index.native.js.map +1 -1
  43. package/build/components/block-navigation/dropdown.js +11 -5
  44. package/build/components/block-navigation/dropdown.js.map +1 -1
  45. package/build/components/block-popover/inbetween.js +19 -8
  46. package/build/components/block-popover/inbetween.js.map +1 -1
  47. package/build/components/block-popover/index.js +20 -16
  48. package/build/components/block-popover/index.js.map +1 -1
  49. package/build/components/block-preview/index.js +1 -1
  50. package/build/components/block-preview/index.js.map +1 -1
  51. package/build/components/block-tools/block-selection-button.js +1 -0
  52. package/build/components/block-tools/block-selection-button.js.map +1 -1
  53. package/build/components/block-tools/selected-block-popover.js +1 -29
  54. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  55. package/build/components/block-variation-transforms/index.js +16 -2
  56. package/build/components/block-variation-transforms/index.js.map +1 -1
  57. package/build/components/border-radius-control/input-controls.js +10 -3
  58. package/build/components/border-radius-control/input-controls.js.map +1 -1
  59. package/build/components/color-style-selector/index.js +9 -0
  60. package/build/components/color-style-selector/index.js.map +1 -1
  61. package/build/components/colors-gradients/dropdown.js +122 -41
  62. package/build/components/colors-gradients/dropdown.js.map +1 -1
  63. package/build/components/colors-gradients/panel-color-gradient-settings.js +35 -60
  64. package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  65. package/build/components/convert-to-group-buttons/toolbar.js +22 -5
  66. package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
  67. package/build/components/iframe/index.js +51 -50
  68. package/build/components/iframe/index.js.map +1 -1
  69. package/build/components/image-editor/use-save-image.js +3 -1
  70. package/build/components/image-editor/use-save-image.js.map +1 -1
  71. package/build/components/index.js +14 -23
  72. package/build/components/index.js.map +1 -1
  73. package/build/components/inserter/index.js +21 -7
  74. package/build/components/inserter/index.js.map +1 -1
  75. package/build/components/inserter/index.native.js +2 -2
  76. package/build/components/inserter/index.native.js.map +1 -1
  77. package/build/components/inserter/quick-inserter.js +4 -5
  78. package/build/components/inserter/quick-inserter.js.map +1 -1
  79. package/build/components/link-control/constants.js +11 -1
  80. package/build/components/link-control/constants.js.map +1 -1
  81. package/build/components/link-control/search-results.js +4 -3
  82. package/build/components/link-control/search-results.js.map +1 -1
  83. package/build/components/link-control/use-search-handler.js +4 -4
  84. package/build/components/link-control/use-search-handler.js.map +1 -1
  85. package/build/components/list-view/block.js +15 -15
  86. package/build/components/list-view/block.js.map +1 -1
  87. package/build/components/list-view/branch.js +9 -13
  88. package/build/components/list-view/branch.js.map +1 -1
  89. package/build/components/list-view/context.js +1 -4
  90. package/build/components/list-view/context.js.map +1 -1
  91. package/build/components/list-view/drop-indicator.js +0 -1
  92. package/build/components/list-view/drop-indicator.js.map +1 -1
  93. package/build/components/list-view/index.js +15 -32
  94. package/build/components/list-view/index.js.map +1 -1
  95. package/build/components/media-placeholder/index.js +0 -2
  96. package/build/components/media-placeholder/index.js.map +1 -1
  97. package/build/components/media-replace-flow/index.js +0 -2
  98. package/build/components/media-replace-flow/index.js.map +1 -1
  99. package/build/components/media-upload/index.native.js +10 -4
  100. package/build/components/media-upload/index.native.js.map +1 -1
  101. package/build/components/navigable-toolbar/index.js +12 -2
  102. package/build/components/navigable-toolbar/index.js.map +1 -1
  103. package/build/components/plain-text/index.native.js +62 -7
  104. package/build/components/plain-text/index.native.js.map +1 -1
  105. package/build/components/publish-date-time-picker/index.js +55 -0
  106. package/build/components/publish-date-time-picker/index.js.map +1 -0
  107. package/build/components/rich-text/format-toolbar-container.js +0 -1
  108. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  109. package/build/components/rich-text/index.js +2 -2
  110. package/build/components/rich-text/index.js.map +1 -1
  111. package/build/components/rich-text/index.native.js +5 -1
  112. package/build/components/rich-text/index.native.js.map +1 -1
  113. package/build/components/url-input/index.js +11 -4
  114. package/build/components/url-input/index.js.map +1 -1
  115. package/build/components/use-block-drop-zone/index.native.js +167 -0
  116. package/build/components/use-block-drop-zone/index.native.js.map +1 -0
  117. package/build/components/use-on-block-drop/index.native.js +95 -0
  118. package/build/components/use-on-block-drop/index.native.js.map +1 -0
  119. package/build/components/use-setting/index.js +42 -18
  120. package/build/components/use-setting/index.js.map +1 -1
  121. package/build/components/warning/index.js +6 -1
  122. package/build/components/warning/index.js.map +1 -1
  123. package/build/components/writing-flow/use-click-selection.js +1 -3
  124. package/build/components/writing-flow/use-click-selection.js.map +1 -1
  125. package/build/components/writing-flow/use-input.js +15 -0
  126. package/build/components/writing-flow/use-input.js.map +1 -1
  127. package/build/components/writing-flow/use-selection-observer.js +49 -8
  128. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  129. package/build/elements/index.js +9 -0
  130. package/build/elements/index.js.map +1 -0
  131. package/build/hooks/anchor.js.map +1 -1
  132. package/build/hooks/border.js +2 -7
  133. package/build/hooks/border.js.map +1 -1
  134. package/build/hooks/color-panel.js +14 -7
  135. package/build/hooks/color-panel.js.map +1 -1
  136. package/build/hooks/color.js +8 -88
  137. package/build/hooks/color.js.map +1 -1
  138. package/build/hooks/dimensions.js +16 -6
  139. package/build/hooks/dimensions.js.map +1 -1
  140. package/build/hooks/index.js +2 -0
  141. package/build/hooks/index.js.map +1 -1
  142. package/build/hooks/margin.js +64 -12
  143. package/build/hooks/margin.js.map +1 -1
  144. package/build/hooks/padding.js +60 -12
  145. package/build/hooks/padding.js.map +1 -1
  146. package/build/hooks/settings.js +32 -0
  147. package/build/hooks/settings.js.map +1 -0
  148. package/build/hooks/style.js +14 -13
  149. package/build/hooks/style.js.map +1 -1
  150. package/build/hooks/typography.js +6 -2
  151. package/build/hooks/typography.js.map +1 -1
  152. package/build/index.js +14 -0
  153. package/build/index.js.map +1 -1
  154. package/build/layouts/flex.js +5 -2
  155. package/build/layouts/flex.js.map +1 -1
  156. package/build/store/actions.js +14 -0
  157. package/build/store/actions.js.map +1 -1
  158. package/build/store/defaults.js +0 -1
  159. package/build/store/defaults.js.map +1 -1
  160. package/build/store/reducer.js +17 -2
  161. package/build/store/reducer.js.map +1 -1
  162. package/build/store/selectors.js +43 -13
  163. package/build/store/selectors.js.map +1 -1
  164. package/build-module/components/block-alignment-control/constants.js +36 -0
  165. package/build-module/components/block-alignment-control/constants.js.map +1 -0
  166. package/build-module/components/block-alignment-control/ui.js +4 -35
  167. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  168. package/build-module/components/block-alignment-control/ui.native.js +78 -0
  169. package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
  170. package/build-module/components/block-alignment-matrix-control/index.js +1 -6
  171. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  172. package/build-module/components/block-content-overlay/index.js +3 -78
  173. package/build-module/components/block-content-overlay/index.js.map +1 -1
  174. package/build-module/components/block-draggable/draggable-chip.native.js +51 -0
  175. package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
  176. package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
  177. package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
  178. package/build-module/components/block-draggable/index.native.js +453 -0
  179. package/build-module/components/block-draggable/index.native.js.map +1 -0
  180. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
  181. package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
  182. package/build-module/components/block-list/block-list-context.native.js +179 -0
  183. package/build-module/components/block-list/block-list-context.native.js.map +1 -0
  184. package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
  185. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
  186. package/build-module/components/block-list/block-list-item.native.js +12 -9
  187. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  188. package/build-module/components/block-list/block.native.js +26 -5
  189. package/build-module/components/block-list/block.native.js.map +1 -1
  190. package/build-module/components/block-list/index.js +35 -33
  191. package/build-module/components/block-list/index.js.map +1 -1
  192. package/build-module/components/block-list/index.native.js +72 -23
  193. package/build-module/components/block-list/index.native.js.map +1 -1
  194. package/build-module/components/block-list/use-block-props/index.js +9 -5
  195. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  196. package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
  197. package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
  198. package/build-module/components/block-list/use-in-between-inserter.js +1 -1
  199. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  200. package/build-module/components/block-mobile-toolbar/index.native.js +9 -3
  201. package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
  202. package/build-module/components/block-mover/index.native.js +18 -5
  203. package/build-module/components/block-mover/index.native.js.map +1 -1
  204. package/build-module/components/block-navigation/dropdown.js +10 -5
  205. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  206. package/build-module/components/block-popover/inbetween.js +19 -8
  207. package/build-module/components/block-popover/inbetween.js.map +1 -1
  208. package/build-module/components/block-popover/index.js +21 -15
  209. package/build-module/components/block-popover/index.js.map +1 -1
  210. package/build-module/components/block-preview/index.js +1 -1
  211. package/build-module/components/block-preview/index.js.map +1 -1
  212. package/build-module/components/block-tools/block-selection-button.js +1 -0
  213. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  214. package/build-module/components/block-tools/selected-block-popover.js +2 -29
  215. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  216. package/build-module/components/block-variation-transforms/index.js +13 -2
  217. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  218. package/build-module/components/border-radius-control/input-controls.js +11 -4
  219. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  220. package/build-module/components/color-style-selector/index.js +6 -0
  221. package/build-module/components/color-style-selector/index.js.map +1 -1
  222. package/build-module/components/colors-gradients/dropdown.js +124 -43
  223. package/build-module/components/colors-gradients/dropdown.js.map +1 -1
  224. package/build-module/components/colors-gradients/panel-color-gradient-settings.js +36 -64
  225. package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
  226. package/build-module/components/convert-to-group-buttons/toolbar.js +23 -6
  227. package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
  228. package/build-module/components/iframe/index.js +52 -51
  229. package/build-module/components/iframe/index.js.map +1 -1
  230. package/build-module/components/image-editor/use-save-image.js +2 -1
  231. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  232. package/build-module/components/index.js +2 -3
  233. package/build-module/components/index.js.map +1 -1
  234. package/build-module/components/inserter/index.js +21 -7
  235. package/build-module/components/inserter/index.js.map +1 -1
  236. package/build-module/components/inserter/index.native.js +2 -2
  237. package/build-module/components/inserter/index.native.js.map +1 -1
  238. package/build-module/components/inserter/quick-inserter.js +4 -5
  239. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  240. package/build-module/components/link-control/constants.js +5 -0
  241. package/build-module/components/link-control/constants.js.map +1 -1
  242. package/build-module/components/link-control/search-results.js +3 -4
  243. package/build-module/components/link-control/search-results.js.map +1 -1
  244. package/build-module/components/link-control/use-search-handler.js +5 -5
  245. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  246. package/build-module/components/list-view/block.js +15 -16
  247. package/build-module/components/list-view/block.js.map +1 -1
  248. package/build-module/components/list-view/branch.js +9 -13
  249. package/build-module/components/list-view/branch.js.map +1 -1
  250. package/build-module/components/list-view/context.js +1 -4
  251. package/build-module/components/list-view/context.js.map +1 -1
  252. package/build-module/components/list-view/drop-indicator.js +0 -1
  253. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  254. package/build-module/components/list-view/index.js +15 -31
  255. package/build-module/components/list-view/index.js.map +1 -1
  256. package/build-module/components/media-placeholder/index.js +0 -2
  257. package/build-module/components/media-placeholder/index.js.map +1 -1
  258. package/build-module/components/media-replace-flow/index.js +0 -2
  259. package/build-module/components/media-replace-flow/index.js.map +1 -1
  260. package/build-module/components/media-upload/index.native.js +8 -3
  261. package/build-module/components/media-upload/index.native.js.map +1 -1
  262. package/build-module/components/navigable-toolbar/index.js +12 -2
  263. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  264. package/build-module/components/plain-text/index.native.js +63 -8
  265. package/build-module/components/plain-text/index.native.js.map +1 -1
  266. package/build-module/components/publish-date-time-picker/index.js +42 -0
  267. package/build-module/components/publish-date-time-picker/index.js.map +1 -0
  268. package/build-module/components/rich-text/format-toolbar-container.js +0 -1
  269. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  270. package/build-module/components/rich-text/index.js +2 -2
  271. package/build-module/components/rich-text/index.js.map +1 -1
  272. package/build-module/components/rich-text/index.native.js +5 -1
  273. package/build-module/components/rich-text/index.native.js.map +1 -1
  274. package/build-module/components/url-input/index.js +11 -4
  275. package/build-module/components/url-input/index.js.map +1 -1
  276. package/build-module/components/use-block-drop-zone/index.native.js +148 -0
  277. package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
  278. package/build-module/components/use-on-block-drop/index.native.js +83 -0
  279. package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
  280. package/build-module/components/use-setting/index.js +43 -19
  281. package/build-module/components/use-setting/index.js.map +1 -1
  282. package/build-module/components/warning/index.js +6 -1
  283. package/build-module/components/warning/index.js.map +1 -1
  284. package/build-module/components/writing-flow/use-click-selection.js +1 -3
  285. package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
  286. package/build-module/components/writing-flow/use-input.js +15 -0
  287. package/build-module/components/writing-flow/use-input.js.map +1 -1
  288. package/build-module/components/writing-flow/use-selection-observer.js +49 -8
  289. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  290. package/build-module/elements/index.js +2 -0
  291. package/build-module/elements/index.js.map +1 -0
  292. package/build-module/hooks/anchor.js.map +1 -1
  293. package/build-module/hooks/border.js +2 -7
  294. package/build-module/hooks/border.js.map +1 -1
  295. package/build-module/hooks/color-panel.js +11 -6
  296. package/build-module/hooks/color-panel.js.map +1 -1
  297. package/build-module/hooks/color.js +8 -88
  298. package/build-module/hooks/color.js.map +1 -1
  299. package/build-module/hooks/dimensions.js +19 -9
  300. package/build-module/hooks/dimensions.js.map +1 -1
  301. package/build-module/hooks/index.js +1 -0
  302. package/build-module/hooks/index.js.map +1 -1
  303. package/build-module/hooks/margin.js +61 -13
  304. package/build-module/hooks/margin.js.map +1 -1
  305. package/build-module/hooks/padding.js +57 -13
  306. package/build-module/hooks/padding.js.map +1 -1
  307. package/build-module/hooks/settings.js +29 -0
  308. package/build-module/hooks/settings.js.map +1 -0
  309. package/build-module/hooks/style.js +15 -14
  310. package/build-module/hooks/style.js.map +1 -1
  311. package/build-module/hooks/typography.js +6 -2
  312. package/build-module/hooks/typography.js.map +1 -1
  313. package/build-module/index.js +1 -0
  314. package/build-module/index.js.map +1 -1
  315. package/build-module/layouts/flex.js +4 -2
  316. package/build-module/layouts/flex.js.map +1 -1
  317. package/build-module/store/actions.js +12 -0
  318. package/build-module/store/actions.js.map +1 -1
  319. package/build-module/store/defaults.js +0 -1
  320. package/build-module/store/defaults.js.map +1 -1
  321. package/build-module/store/reducer.js +17 -2
  322. package/build-module/store/reducer.js.map +1 -1
  323. package/build-module/store/selectors.js +37 -12
  324. package/build-module/store/selectors.js.map +1 -1
  325. package/build-style/style-rtl.css +100 -225
  326. package/build-style/style.css +100 -225
  327. package/package.json +30 -30
  328. package/src/components/block-alignment-control/constants.js +45 -0
  329. package/src/components/block-alignment-control/ui.js +69 -109
  330. package/src/components/block-alignment-control/ui.native.js +86 -0
  331. package/src/components/block-alignment-matrix-control/index.js +1 -5
  332. package/src/components/block-content-overlay/index.js +8 -95
  333. package/src/components/block-content-overlay/style.scss +2 -12
  334. package/src/components/block-draggable/draggable-chip.native.js +49 -0
  335. package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
  336. package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
  337. package/src/components/block-draggable/index.native.js +462 -0
  338. package/src/components/block-draggable/style.native.scss +19 -0
  339. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +73 -0
  340. package/src/components/block-draggable/test/helpers.native.js +183 -0
  341. package/src/components/block-draggable/test/index.native.js +496 -0
  342. package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
  343. package/src/components/block-list/block-list-context.native.js +175 -0
  344. package/src/components/block-list/block-list-item-cell.native.js +49 -0
  345. package/src/components/block-list/block-list-item.native.js +7 -11
  346. package/src/components/block-list/block.native.js +37 -8
  347. package/src/components/block-list/index.js +44 -44
  348. package/src/components/block-list/index.native.js +54 -13
  349. package/src/components/block-list/style.scss +7 -18
  350. package/src/components/block-list/test/block-list-context.native.js +253 -0
  351. package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
  352. package/src/components/block-list/use-block-props/index.js +10 -5
  353. package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
  354. package/src/components/block-list/use-in-between-inserter.js +1 -1
  355. package/src/components/block-mobile-toolbar/index.native.js +9 -1
  356. package/src/components/block-mover/index.native.js +22 -6
  357. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -0
  358. package/src/components/block-navigation/dropdown.js +12 -8
  359. package/src/components/block-popover/inbetween.js +21 -8
  360. package/src/components/block-popover/index.js +18 -15
  361. package/src/components/block-popover/style.scss +4 -0
  362. package/src/components/block-preview/index.js +1 -4
  363. package/src/components/block-switcher/style.scss +2 -39
  364. package/src/components/block-tools/block-selection-button.js +1 -0
  365. package/src/components/block-tools/selected-block-popover.js +1 -36
  366. package/src/components/block-tools/style.scss +1 -12
  367. package/src/components/block-variation-transforms/index.js +6 -2
  368. package/src/components/border-radius-control/input-controls.js +16 -8
  369. package/src/components/border-radius-control/style.scss +3 -2
  370. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  371. package/src/components/color-style-selector/index.js +18 -9
  372. package/src/components/colors-gradients/dropdown.js +130 -62
  373. package/src/components/colors-gradients/panel-color-gradient-settings.js +30 -76
  374. package/src/components/colors-gradients/style.scss +52 -50
  375. package/src/components/convert-to-group-buttons/toolbar.js +30 -13
  376. package/src/components/duotone-control/style.scss +1 -7
  377. package/src/components/iframe/index.js +62 -54
  378. package/src/components/image-editor/use-save-image.js +2 -1
  379. package/src/components/image-size-control/README.md +1 -1
  380. package/src/components/index.js +2 -3
  381. package/src/components/inserter/index.js +20 -0
  382. package/src/components/inserter/index.native.js +2 -2
  383. package/src/components/inserter/quick-inserter.js +3 -11
  384. package/src/components/inserter/style.native.scss +1 -0
  385. package/src/components/inserter/style.scss +2 -1
  386. package/src/components/link-control/constants.js +11 -0
  387. package/src/components/link-control/search-results.js +4 -5
  388. package/src/components/link-control/use-search-handler.js +11 -5
  389. package/src/components/list-view/block.js +24 -34
  390. package/src/components/list-view/branch.js +10 -20
  391. package/src/components/list-view/context.js +1 -4
  392. package/src/components/list-view/drop-indicator.js +0 -1
  393. package/src/components/list-view/index.js +11 -41
  394. package/src/components/list-view/style.scss +2 -1
  395. package/src/components/media-placeholder/index.js +0 -2
  396. package/src/components/media-replace-flow/index.js +0 -2
  397. package/src/components/media-upload/index.native.js +6 -2
  398. package/src/components/media-upload/test/index.native.js +31 -6
  399. package/src/components/navigable-toolbar/index.js +12 -2
  400. package/src/components/plain-text/index.native.js +64 -8
  401. package/src/components/preview-options/style.scss +0 -4
  402. package/src/components/publish-date-time-picker/README.md +52 -0
  403. package/src/components/publish-date-time-picker/index.js +50 -0
  404. package/src/components/publish-date-time-picker/style.scss +20 -0
  405. package/src/components/rich-text/format-toolbar-container.js +0 -1
  406. package/src/components/rich-text/index.js +3 -1
  407. package/src/components/rich-text/index.native.js +4 -0
  408. package/src/components/rich-text/style.scss +2 -8
  409. package/src/components/url-input/index.js +9 -4
  410. package/src/components/use-block-drop-zone/index.native.js +173 -0
  411. package/src/components/use-on-block-drop/index.native.js +119 -0
  412. package/src/components/use-setting/index.js +57 -21
  413. package/src/components/warning/index.js +47 -42
  414. package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
  415. package/src/components/warning/test/index.js +1 -1
  416. package/src/components/writing-flow/use-click-selection.js +1 -4
  417. package/src/components/writing-flow/use-input.js +12 -0
  418. package/src/components/writing-flow/use-selection-observer.js +55 -10
  419. package/src/elements/index.js +1 -0
  420. package/src/hooks/anchor.js +1 -1
  421. package/src/hooks/border.js +2 -11
  422. package/src/hooks/border.scss +0 -48
  423. package/src/hooks/color-panel.js +13 -9
  424. package/src/hooks/color.js +5 -74
  425. package/src/hooks/color.scss +5 -58
  426. package/src/hooks/dimensions.js +55 -41
  427. package/src/hooks/index.js +1 -0
  428. package/src/hooks/margin.js +64 -15
  429. package/src/hooks/padding.js +60 -15
  430. package/src/hooks/padding.scss +12 -0
  431. package/src/hooks/settings.js +32 -0
  432. package/src/hooks/style.js +25 -39
  433. package/src/hooks/test/settings.js +48 -0
  434. package/src/hooks/typography.js +2 -0
  435. package/src/index.js +1 -0
  436. package/src/layouts/flex.js +11 -3
  437. package/src/store/actions.js +12 -0
  438. package/src/store/defaults.js +0 -1
  439. package/src/store/reducer.js +14 -1
  440. package/src/store/selectors.js +42 -12
  441. package/src/store/test/reducer.js +5 -0
  442. package/src/store/test/selectors.js +17 -0
  443. package/src/style.scss +2 -2
  444. package/tsconfig.tsbuildinfo +1 -1
  445. package/build/components/border-style-control/index.js +0 -60
  446. package/build/components/border-style-control/index.js.map +0 -1
  447. package/build/components/colors/color-panel.js +0 -82
  448. package/build/components/colors/color-panel.js.map +0 -1
  449. package/build/components/colors/color-panel.native.js +0 -11
  450. package/build/components/colors/color-panel.native.js.map +0 -1
  451. package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
  452. package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  453. package/build-module/components/border-style-control/index.js +0 -50
  454. package/build-module/components/border-style-control/index.js.map +0 -1
  455. package/build-module/components/colors/color-panel.js +0 -70
  456. package/build-module/components/colors/color-panel.js.map +0 -1
  457. package/build-module/components/colors/color-panel.native.js +0 -4
  458. package/build-module/components/colors/color-panel.native.js.map +0 -1
  459. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
  460. package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
  461. package/src/components/block-alignment-matrix-control/style.scss +0 -10
  462. package/src/components/border-style-control/index.js +0 -47
  463. package/src/components/border-style-control/style.scss +0 -18
  464. package/src/components/colors/color-panel.js +0 -91
  465. package/src/components/colors/color-panel.native.js +0 -3
  466. package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
@@ -0,0 +1,183 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import {
5
+ act,
6
+ fireEvent,
7
+ initializeEditor,
8
+ waitForStoreResolvers,
9
+ within,
10
+ advanceAnimationByFrame,
11
+ } from 'test/helpers';
12
+ import { fireGestureHandler } from 'react-native-gesture-handler/jest-utils';
13
+ import { State } from 'react-native-gesture-handler';
14
+
15
+ // Touch event type constants have been extracted from original source code, as they are not exported in the package.
16
+ // Reference: https://github.com/software-mansion/react-native-gesture-handler/blob/90895e5f38616a6be256fceec6c6a391cd9ad7c7/src/TouchEventType.ts
17
+ export const TouchEventType = {
18
+ UNDETERMINED: 0,
19
+ TOUCHES_DOWN: 1,
20
+ TOUCHES_MOVE: 2,
21
+ TOUCHES_UP: 3,
22
+ TOUCHES_CANCELLED: 4,
23
+ };
24
+
25
+ const DEFAULT_TOUCH_EVENTS = [
26
+ {
27
+ id: 1,
28
+ eventType: TouchEventType.TOUCHES_DOWN,
29
+ x: 0,
30
+ y: 0,
31
+ },
32
+ ];
33
+
34
+ /**
35
+ * @typedef {Object} WPBlockWithLayout
36
+ * @property {string} name Name of the block (e.g. Paragraph).
37
+ * @property {string} html HTML content.
38
+ * @property {Object} layout Layout data.
39
+ * @property {Object} layout.x X position.
40
+ * @property {Object} layout.y Y position.
41
+ * @property {Object} layout.width Width.
42
+ * @property {Object} layout.height Height.
43
+ */
44
+
45
+ /**
46
+ * Initialize the editor with an array of blocks that include their HTML and layout.
47
+ *
48
+ * @param {WPBlockWithLayout[]} blocks Initial blocks.
49
+ *
50
+ * @return {import('@testing-library/react-native').RenderAPI} The Testing Library screen.
51
+ */
52
+ export const initializeWithBlocksLayouts = async ( blocks ) => {
53
+ const initialHtml = blocks.map( ( block ) => block.html ).join( '\n' );
54
+
55
+ const screen = await initializeEditor( { initialHtml } );
56
+ const { getByA11yLabel } = screen;
57
+
58
+ const waitPromises = [];
59
+ blocks.forEach( ( block, index ) => {
60
+ const a11yLabel = new RegExp(
61
+ `${ block.name } Block\\. Row ${ index + 1 }`
62
+ );
63
+ const element = getByA11yLabel( a11yLabel );
64
+ // "onLayout" event will populate the blocks layouts data.
65
+ fireEvent( element, 'layout', {
66
+ nativeEvent: { layout: block.layout },
67
+ } );
68
+ if ( block.nestedBlocks ) {
69
+ // Nested blocks are rendered via the FlatList of the inner block list.
70
+ // In order to render the items of a FlatList, it's required to trigger the
71
+ // "onLayout" event. Additionally, the call is wrapped over "waitForStoreResolvers"
72
+ // because the nested blocks might make API requests (e.g. the Gallery block).
73
+ waitPromises.push(
74
+ waitForStoreResolvers( () =>
75
+ fireEvent(
76
+ within( element ).getByTestId( 'block-list-wrapper' ),
77
+ 'layout',
78
+ {
79
+ nativeEvent: {
80
+ layout: {
81
+ width: block.layout.width,
82
+ height: block.layout.height,
83
+ },
84
+ },
85
+ }
86
+ )
87
+ )
88
+ );
89
+
90
+ block.nestedBlocks.forEach( ( nestedBlock, nestedIndex ) => {
91
+ const nestedA11yLabel = new RegExp(
92
+ `${ nestedBlock.name } Block\\. Row ${ nestedIndex + 1 }`
93
+ );
94
+ fireEvent(
95
+ within( element ).getByA11yLabel( nestedA11yLabel ),
96
+ 'layout',
97
+ {
98
+ nativeEvent: { layout: nestedBlock.layout },
99
+ }
100
+ );
101
+ } );
102
+ }
103
+ } );
104
+ await Promise.all( waitPromises );
105
+
106
+ return screen;
107
+ };
108
+
109
+ /**
110
+ * Fires long-press gesture event on a block.
111
+ *
112
+ * @param {import('react-test-renderer').ReactTestInstance} block Block test instance.
113
+ * @param {string} testID Id for querying the draggable trigger element.
114
+ * @param {Object} [options] Configuration options for the gesture event.
115
+ * @param {boolean} [options.failed] Determines if the gesture should fail.
116
+ * @param {number} [options.triggerIndex] In case there are multiple draggable triggers, this specifies the index to use.
117
+ */
118
+ export const fireLongPress = (
119
+ block,
120
+ testID,
121
+ { failed = false, triggerIndex } = {}
122
+ ) => {
123
+ const draggableTrigger =
124
+ typeof triggerIndex !== 'undefined'
125
+ ? within( block ).getAllByTestId( testID )[ triggerIndex ]
126
+ : within( block ).getByTestId( testID );
127
+ if ( failed ) {
128
+ fireGestureHandler( draggableTrigger, [ { state: State.FAILED } ] );
129
+ } else {
130
+ fireGestureHandler( draggableTrigger, [
131
+ { oldState: State.BEGAN, state: State.ACTIVE },
132
+ { state: State.ACTIVE },
133
+ { state: State.END },
134
+ ] );
135
+ }
136
+ // Advance timers one frame to ensure that shared values
137
+ // are updated and trigger animation reactions.
138
+ act( () => advanceAnimationByFrame( 1 ) );
139
+ };
140
+
141
+ /**
142
+ * Fires pan gesture event on a BlockDraggable component.
143
+ *
144
+ * @param {import('react-test-renderer').ReactTestInstance} blockDraggable BlockDraggable test instance.
145
+ * @param {Object} [touchEvents] Array of touch events to dispatch on the pan gesture.
146
+ */
147
+ export const firePanGesture = (
148
+ blockDraggable,
149
+ touchEvents = DEFAULT_TOUCH_EVENTS
150
+ ) => {
151
+ const gestureTouchEvents = touchEvents.map(
152
+ ( { eventType, ...touchEvent } ) => ( {
153
+ allTouches: [ touchEvent ],
154
+ eventType,
155
+ } )
156
+ );
157
+ fireGestureHandler( blockDraggable, [
158
+ // TOUCHES_DOWN event is only received on ACTIVE state, so we have to fire it manually.
159
+ { oldState: State.BEGAN, state: State.ACTIVE },
160
+ ...gestureTouchEvents,
161
+ { state: State.END },
162
+ ] );
163
+ // Advance timers one frame to ensure that shared values
164
+ // are updated and trigger animation reactions.
165
+ act( () => advanceAnimationByFrame( 1 ) );
166
+ };
167
+
168
+ /**
169
+ * Gets the draggable chip element.
170
+ *
171
+ * @param {import('@testing-library/react-native').RenderAPI} screen The Testing Library screen.
172
+ *
173
+ * @return {import('react-test-renderer').ReactTestInstance} Draggable chip test instance.
174
+ */
175
+ export const getDraggableChip = ( { getByTestId } ) => {
176
+ let draggableChip;
177
+ try {
178
+ draggableChip = getByTestId( 'draggable-chip' );
179
+ } catch ( e ) {
180
+ // NOOP.
181
+ }
182
+ return draggableChip;
183
+ };
@@ -0,0 +1,496 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import {
5
+ fireEvent,
6
+ getEditorHtml,
7
+ within,
8
+ waitForStoreResolvers,
9
+ withReanimatedTimer,
10
+ } from 'test/helpers';
11
+ import { getByGestureTestId } from 'react-native-gesture-handler/jest-utils';
12
+ import TextInputState from 'react-native/Libraries/Components/TextInput/TextInputState';
13
+
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+ import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
18
+ import { registerCoreBlocks } from '@wordpress/block-library';
19
+ import '@wordpress/jest-console';
20
+
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+ import {
25
+ initializeWithBlocksLayouts,
26
+ fireLongPress,
27
+ firePanGesture,
28
+ TouchEventType,
29
+ getDraggableChip,
30
+ } from './helpers';
31
+
32
+ // Mock throttle to allow updating the dragging position on every "onDragOver" event.
33
+ jest.mock( 'lodash', () => ( {
34
+ ...jest.requireActual( 'lodash' ),
35
+ throttle: ( fn ) => {
36
+ fn.cancel = jest.fn();
37
+ return fn;
38
+ },
39
+ } ) );
40
+
41
+ beforeAll( () => {
42
+ // Register all core blocks
43
+ registerCoreBlocks();
44
+ } );
45
+
46
+ afterAll( () => {
47
+ // Clean up registered blocks
48
+ getBlockTypes().forEach( ( block ) => {
49
+ unregisterBlockType( block.name );
50
+ } );
51
+ } );
52
+
53
+ const TOUCH_EVENT_ID = 1;
54
+ const BLOCKS = [
55
+ {
56
+ name: 'Paragraph',
57
+ html: `
58
+ <!-- wp:paragraph -->
59
+ <p>This is a paragraph.</p>
60
+ <!-- /wp:paragraph -->`,
61
+ layout: { x: 0, y: 0, width: 100, height: 100 },
62
+ },
63
+ {
64
+ name: 'Image',
65
+ html: `
66
+ <!-- wp:image {"sizeSlug":"large"} -->
67
+ <figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt=""/></figure>
68
+ <!-- /wp:image -->`,
69
+ layout: { x: 0, y: 100, width: 100, height: 100 },
70
+ },
71
+ {
72
+ name: 'Spacer',
73
+ html: `
74
+ <!-- wp:spacer -->
75
+ <div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
76
+ <!-- /wp:spacer -->`,
77
+ layout: { x: 0, y: 200, width: 100, height: 100 },
78
+ },
79
+ {
80
+ name: 'Gallery',
81
+ html: `
82
+ <!-- wp:gallery {"linkTo":"none"} -->
83
+ <figure class="wp-block-gallery has-nested-images columns-default is-cropped"><!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
84
+ <figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt=""/></figure>
85
+ <!-- /wp:image -->
86
+
87
+ <!-- wp:image {"sizeSlug":"large","linkDestination":"none"} -->
88
+ <figure class="wp-block-image size-large"><img src="https://cldup.com/cXyG__fTLN.jpg" alt=""/></figure>
89
+ <!-- /wp:image --></figure>
90
+ <!-- /wp:gallery -->`,
91
+ layout: { x: 0, y: 300, width: 100, height: 100 },
92
+ nestedBlocks: [
93
+ { name: 'Image', layout: { x: 0, y: 300, width: 50, height: 50 } },
94
+ { name: 'Image', layout: { x: 50, y: 300, width: 50, height: 50 } },
95
+ ],
96
+ },
97
+ ];
98
+
99
+ describe( 'BlockDraggable', () => {
100
+ describe( 'drag mode', () => {
101
+ describe( 'Text block', () => {
102
+ it( 'enables drag mode when unselected', async () =>
103
+ withReanimatedTimer( async () => {
104
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
105
+ const { getByA11yLabel } = screen;
106
+
107
+ // Start dragging from block's content
108
+ fireLongPress(
109
+ getByA11yLabel( /Paragraph Block\. Row 1/ ),
110
+ 'draggable-trigger-content'
111
+ );
112
+ expect( getDraggableChip( screen ) ).toBeVisible();
113
+
114
+ // "firePanGesture" finishes the dragging gesture
115
+ firePanGesture(
116
+ getByGestureTestId( 'block-draggable-wrapper' )
117
+ );
118
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
119
+ } ) );
120
+
121
+ it( 'enables drag mode when selected', async () =>
122
+ withReanimatedTimer( async () => {
123
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
124
+ const { getByA11yLabel } = screen;
125
+ const blockDraggableWrapper = getByGestureTestId(
126
+ 'block-draggable-wrapper'
127
+ );
128
+
129
+ const paragraphBlock = getByA11yLabel(
130
+ /Paragraph Block\. Row 1/
131
+ );
132
+ fireEvent.press( paragraphBlock );
133
+
134
+ // Start dragging from block's content
135
+ fireLongPress(
136
+ paragraphBlock,
137
+ 'draggable-trigger-content'
138
+ );
139
+ expect( getDraggableChip( screen ) ).toBeVisible();
140
+ // "firePanGesture" finishes the dragging gesture
141
+ firePanGesture( blockDraggableWrapper );
142
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
143
+
144
+ // Start dragging from block's mobile toolbar
145
+ fireLongPress(
146
+ paragraphBlock,
147
+ 'draggable-trigger-mobile-toolbar'
148
+ );
149
+ expect( getDraggableChip( screen ) ).toBeVisible();
150
+ // "firePanGesture" finishes the dragging gesture
151
+ firePanGesture( blockDraggableWrapper );
152
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
153
+ } ) );
154
+
155
+ it( 'does not enable drag mode when selected and editing text', async () =>
156
+ withReanimatedTimer( async () => {
157
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
158
+ const { getByA11yLabel } = screen;
159
+
160
+ const paragraphBlock = getByA11yLabel(
161
+ /Paragraph Block\. Row 1/
162
+ );
163
+
164
+ // Select Paragraph block and start editing text
165
+ fireEvent.press( paragraphBlock );
166
+ fireEvent(
167
+ within( paragraphBlock ).getByPlaceholderText(
168
+ 'Start writing…'
169
+ ),
170
+ 'focus'
171
+ );
172
+
173
+ // Start dragging from block's content
174
+ fireLongPress(
175
+ paragraphBlock,
176
+ 'draggable-trigger-content',
177
+ { failed: true }
178
+ );
179
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
180
+ // Check that no text input has been unfocused to confirm
181
+ // that editing text is still enabled.
182
+ expect(
183
+ TextInputState.blurTextInput
184
+ ).not.toHaveBeenCalled();
185
+ } ) );
186
+
187
+ it( 'finishes editing text and enables drag mode when long-pressing over a different block', async () =>
188
+ withReanimatedTimer( async () => {
189
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
190
+ const { getByA11yLabel } = screen;
191
+
192
+ const paragraphBlock = getByA11yLabel(
193
+ /Paragraph Block\. Row 1/
194
+ );
195
+ const spacerBlock = getByA11yLabel(
196
+ /Spacer Block\. Row 3/
197
+ );
198
+
199
+ // Select Paragraph block and start editing text
200
+ fireEvent.press( paragraphBlock );
201
+ fireEvent(
202
+ within( paragraphBlock ).getByPlaceholderText(
203
+ 'Start writing…'
204
+ ),
205
+ 'focus'
206
+ );
207
+
208
+ // Start dragging from a different block's content
209
+ fireLongPress( spacerBlock, 'draggable-trigger-content' );
210
+ expect( getDraggableChip( screen ) ).toBeVisible();
211
+ // Check that any text input has been unfocused to confirm
212
+ // that editing text finished.
213
+ expect( TextInputState.blurTextInput ).toHaveBeenCalled();
214
+ } ) );
215
+ } );
216
+
217
+ describe( 'Media block', () => {
218
+ it( 'enables drag mode when unselected', async () =>
219
+ withReanimatedTimer( async () => {
220
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
221
+ const { getAllByA11yLabel } = screen;
222
+
223
+ // We select the first Image block as the Gallery block
224
+ // also contains Image blocks.
225
+ const imageBlock = getAllByA11yLabel(
226
+ /Image Block\. Row 2/
227
+ )[ 0 ];
228
+ // Start dragging from block's content
229
+ fireLongPress( imageBlock, 'draggable-trigger-content' );
230
+ expect( getDraggableChip( screen ) ).toBeVisible();
231
+
232
+ // "firePanGesture" finishes the dragging gesture
233
+ firePanGesture(
234
+ getByGestureTestId( 'block-draggable-wrapper' )
235
+ );
236
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
237
+ } ) );
238
+
239
+ it( 'enables drag mode when selected', async () =>
240
+ withReanimatedTimer( async () => {
241
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
242
+ const { getAllByA11yLabel } = screen;
243
+ const blockDraggableWrapper = getByGestureTestId(
244
+ 'block-draggable-wrapper'
245
+ );
246
+
247
+ // We select the first Image block as the Gallery block
248
+ // also contains Image blocks.
249
+ const imageBlock = getAllByA11yLabel(
250
+ /Image Block\. Row 2/
251
+ )[ 0 ];
252
+ fireEvent.press( imageBlock );
253
+
254
+ // Start dragging from block's content
255
+ fireLongPress( imageBlock, 'draggable-trigger-content' );
256
+ expect( getDraggableChip( screen ) ).toBeVisible();
257
+ // "firePanGesture" finishes the dragging gesture
258
+ firePanGesture( blockDraggableWrapper );
259
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
260
+
261
+ // Start dragging from block's mobile toolbar
262
+ fireLongPress(
263
+ imageBlock,
264
+ 'draggable-trigger-mobile-toolbar'
265
+ );
266
+ expect( getDraggableChip( screen ) ).toBeVisible();
267
+ // "firePanGesture" finishes the dragging gesture
268
+ firePanGesture( blockDraggableWrapper );
269
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
270
+ } ) );
271
+ } );
272
+
273
+ describe( 'Nested block', () => {
274
+ it( 'enables drag mode when unselected', async () =>
275
+ withReanimatedTimer( async () => {
276
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
277
+ const { getByA11yLabel } = screen;
278
+
279
+ // Start dragging from block's content, specifically the first
280
+ // trigger index, which corresponds to the Gallery block content.
281
+ fireLongPress(
282
+ getByA11yLabel( /Gallery Block\. Row 4/ ),
283
+ 'draggable-trigger-content',
284
+ { triggerIndex: 0 }
285
+ );
286
+ expect( getDraggableChip( screen ) ).toBeVisible();
287
+
288
+ // "firePanGesture" finishes the dragging gesture
289
+ firePanGesture(
290
+ getByGestureTestId( 'block-draggable-wrapper' )
291
+ );
292
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
293
+ } ) );
294
+
295
+ it( 'enables drag mode when selected', async () =>
296
+ withReanimatedTimer( async () => {
297
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
298
+ const { getByA11yLabel } = screen;
299
+ const blockDraggableWrapper = getByGestureTestId(
300
+ 'block-draggable-wrapper'
301
+ );
302
+
303
+ const galleryBlock = getByA11yLabel(
304
+ /Gallery Block\. Row 4/
305
+ );
306
+ await waitForStoreResolvers( () =>
307
+ fireEvent.press( galleryBlock )
308
+ );
309
+
310
+ // Start dragging from block's content, specifically the first
311
+ // trigger index, which corresponds to the Gallery block content.
312
+ fireLongPress( galleryBlock, 'draggable-trigger-content', {
313
+ triggerIndex: 0,
314
+ } );
315
+ expect( getDraggableChip( screen ) ).toBeVisible();
316
+ // "firePanGesture" finishes the dragging gesture
317
+ firePanGesture( blockDraggableWrapper );
318
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
319
+
320
+ // Start dragging from block's mobile toolbar
321
+ fireLongPress(
322
+ galleryBlock,
323
+ 'draggable-trigger-mobile-toolbar'
324
+ );
325
+ expect( getDraggableChip( screen ) ).toBeVisible();
326
+ // "firePanGesture" finishes the dragging gesture
327
+ firePanGesture( blockDraggableWrapper );
328
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
329
+ } ) );
330
+
331
+ it( 'enables drag mode when nested block is selected', async () =>
332
+ withReanimatedTimer( async () => {
333
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
334
+ const { getByA11yLabel } = screen;
335
+ const blockDraggableWrapper = getByGestureTestId(
336
+ 'block-draggable-wrapper'
337
+ );
338
+
339
+ const galleryBlock = getByA11yLabel(
340
+ /Gallery Block\. Row 4/
341
+ );
342
+ const galleryItem = within( galleryBlock ).getByA11yLabel(
343
+ /Image Block\. Row 2/
344
+ );
345
+ fireEvent.press( galleryBlock );
346
+ fireEvent.press( galleryItem );
347
+
348
+ // Start dragging from nested block's content
349
+ fireLongPress( galleryItem, 'draggable-trigger-content' );
350
+ expect( getDraggableChip( screen ) ).toBeVisible();
351
+ // "firePanGesture" finishes the dragging gesture
352
+ firePanGesture( blockDraggableWrapper );
353
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
354
+
355
+ // After dropping the block, the gallery item gets automatically selected.
356
+ // Hence, we have to select the gallery item again.
357
+ fireEvent.press( galleryItem );
358
+
359
+ // Start dragging from nested block's mobile toolbar
360
+ fireLongPress(
361
+ galleryItem,
362
+ 'draggable-trigger-mobile-toolbar'
363
+ );
364
+ expect( getDraggableChip( screen ) ).toBeVisible();
365
+ // "firePanGesture" finishes the dragging gesture
366
+ firePanGesture( blockDraggableWrapper );
367
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
368
+ } ) );
369
+ } );
370
+
371
+ describe( 'Other block', () => {
372
+ it( 'enables drag mode when unselected', async () =>
373
+ withReanimatedTimer( async () => {
374
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
375
+ const { getByA11yLabel } = screen;
376
+
377
+ // Start dragging from block's content
378
+ fireLongPress(
379
+ getByA11yLabel( /Spacer Block\. Row 3/ ),
380
+ 'draggable-trigger-content'
381
+ );
382
+ expect( getDraggableChip( screen ) ).toBeVisible();
383
+
384
+ // "firePanGesture" finishes the dragging gesture
385
+ firePanGesture(
386
+ getByGestureTestId( 'block-draggable-wrapper' )
387
+ );
388
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
389
+ } ) );
390
+
391
+ it( 'enables drag mode when selected', async () =>
392
+ withReanimatedTimer( async () => {
393
+ const screen = await initializeWithBlocksLayouts( BLOCKS );
394
+ const { getByA11yLabel } = screen;
395
+ const blockDraggableWrapper = getByGestureTestId(
396
+ 'block-draggable-wrapper'
397
+ );
398
+
399
+ const spacerBlock = getByA11yLabel(
400
+ /Spacer Block\. Row 3/
401
+ );
402
+ await waitForStoreResolvers( () =>
403
+ fireEvent.press( spacerBlock )
404
+ );
405
+
406
+ // Start dragging from block's content
407
+ fireLongPress( spacerBlock, 'draggable-trigger-content' );
408
+ expect( getDraggableChip( screen ) ).toBeVisible();
409
+ // "firePanGesture" finishes the dragging gesture
410
+ firePanGesture( blockDraggableWrapper );
411
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
412
+
413
+ // Start dragging from block's mobile toolbar
414
+ fireLongPress(
415
+ spacerBlock,
416
+ 'draggable-trigger-mobile-toolbar'
417
+ );
418
+ expect( getDraggableChip( screen ) ).toBeVisible();
419
+ // "firePanGesture" finishes the dragging gesture
420
+ firePanGesture( blockDraggableWrapper );
421
+ expect( getDraggableChip( screen ) ).not.toBeDefined();
422
+ } ) );
423
+ } );
424
+ } );
425
+
426
+ it( 'moves blocks', async () =>
427
+ withReanimatedTimer( async () => {
428
+ const { getByA11yLabel } = await initializeWithBlocksLayouts(
429
+ BLOCKS
430
+ );
431
+ const blockDraggableWrapper = getByGestureTestId(
432
+ 'block-draggable-wrapper'
433
+ );
434
+
435
+ expect( getEditorHtml() ).toMatchSnapshot( 'Initial order' );
436
+
437
+ // Move Paragraph block from first to second position
438
+ fireLongPress(
439
+ getByA11yLabel( /Paragraph Block\. Row 1/ ),
440
+ 'draggable-trigger-content'
441
+ );
442
+ firePanGesture( blockDraggableWrapper, [
443
+ {
444
+ id: TOUCH_EVENT_ID,
445
+ eventType: TouchEventType.TOUCHES_DOWN,
446
+ x: 0,
447
+ y: 0,
448
+ },
449
+ {
450
+ id: TOUCH_EVENT_ID,
451
+ eventType: TouchEventType.TOUCHES_MOVE,
452
+ x: 0,
453
+ // Dropping position is in the second half of the second block's height.
454
+ y: 180,
455
+ },
456
+ ] );
457
+ // Draggable Pan gesture uses the Gesture state manager to manually
458
+ // activate the gesture. Since this not available in tests, the library
459
+ // displays a warning message.
460
+ expect( console ).toHaveWarnedWith(
461
+ '[react-native-gesture-handler] You have to use react-native-reanimated in order to control the state of the gesture.'
462
+ );
463
+ expect( getEditorHtml() ).toMatchSnapshot(
464
+ 'Paragraph block moved from first to second position'
465
+ );
466
+
467
+ // Move Spacer block from third to first position
468
+ fireLongPress(
469
+ getByA11yLabel( /Spacer Block\. Row 3/ ),
470
+ 'draggable-trigger-content'
471
+ );
472
+ firePanGesture( blockDraggableWrapper, [
473
+ {
474
+ id: TOUCH_EVENT_ID,
475
+ eventType: TouchEventType.TOUCHES_DOWN,
476
+ x: 0,
477
+ y: 250,
478
+ },
479
+ {
480
+ id: TOUCH_EVENT_ID,
481
+ eventType: TouchEventType.TOUCHES_MOVE,
482
+ x: 0,
483
+ y: 0,
484
+ },
485
+ ] );
486
+ // Draggable Pan gesture uses the Gesture state manager to manually
487
+ // activate the gesture. Since this not available in tests, the library
488
+ // displays a warning message.
489
+ expect( console ).toHaveWarnedWith(
490
+ '[react-native-gesture-handler] You have to use react-native-reanimated in order to control the state of the gesture.'
491
+ );
492
+ expect( getEditorHtml() ).toMatchSnapshot(
493
+ 'Spacer block moved from third to first position'
494
+ );
495
+ } ) );
496
+ } );