@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 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.native.js"],"names":["CHIP_OFFSET_TO_TOUCH_POSITION","BLOCK_OPACITY_ANIMATION_CONFIG","duration","BLOCK_OPACITY_ANIMATION_DELAY","DEFAULT_LONG_PRESS_MIN_DURATION","DEFAULT_IOS_LONG_PRESS_MIN_DURATION","BlockDraggableWrapper","children","isRTL","draggedBlockIcon","setDraggedBlockIcon","selectBlock","startDraggingBlocks","stopDraggingBlocks","blockEditorStore","scrollRef","animatedScrollRef","left","right","width","safeAreaOffset","contentWidth","scroll","offsetY","chip","x","y","height","currentYPosition","isDragging","startScrolling","scrollOnDragOver","stopScrolling","draggingScrollHandler","scrollHandler","event","contentOffset","value","onBlockDragOver","onBlockDragEnd","onBlockDrop","targetBlockIndex","setDraggedBlockIconByClientId","clientId","blockName","getBlockName","blockIcon","icon","onStartDragging","position","stopDragging","onStopDragging","srcRootClientId","srcClientIds","type","undefined","onChipLayout","nativeEvent","layout","startDragging","id","dragPosition","updateDragging","chipDynamicStyles","chipOffset","translateX","transform","translateY","chipStyles","styles","exitingAnimation","currentHeight","currentWidth","animations","scale","initialValues","onScroll","ZoomInEasyDown","BlockDraggable","draggingClientId","enabled","testID","wasBeingDragged","isEditingText","setIsEditingText","isScreenReaderEnabled","setIsScreenReaderEnabled","draggingAnimation","opacity","startDraggingBlock","stopDraggingBlock","isDraggable","isBeingDragged","isBlockSelected","_select","getBlockRootClientId","getTemplateLock","isBlockBeingDragged","getSelectedBlockClientId","rootClientId","templateLock","selectedBlockClientId","current","onFocusChangeAztec","isFocused","mounted","isAnyAztecInputFocused","RCTAztecView","InputState","addFocusChangeListener","screenReaderChangedListener","AccessibilityInfo","addEventListener","then","screenReaderEnabled","removeFocusChangeListener","remove","onLongPressDraggable","blurCurrentFocusedElement","animatedWrapperStyles","wrapperStyles","canDragBlock","Platform","select","ios","android"],"mappings":";;;;;;;;;AAwBA;;AArBA;;AACA;;AAIA;;AAcA;;AACA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AA5CA;AACA;AACA;;AAiBA;AACA;AACA;;AAcA;AACA;AACA;AASA,MAAMA,6BAA6B,GAAG,EAAtC;AACA,MAAMC,8BAA8B,GAAG;AAAEC,EAAAA,QAAQ,EAAE;AAAZ,CAAvC;AACA,MAAMC,6BAA6B,GAAG,GAAtC;AACA,MAAMC,+BAA+B,GAAG,GAAxC;AACA,MAAMC,mCAAmC,GACxCD,+BAA+B,GAAG,EADnC;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAME,qBAAqB,GAAG,QAA2B;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAyB;AACxD,QAAM,CAAEC,gBAAF,EAAoBC,mBAApB,IAA4C,wBAAlD;AAEA,QAAM;AACLC,IAAAA,WADK;AAELC,IAAAA,mBAFK;AAGLC,IAAAA;AAHK,MAIF,uBAAaC,YAAb,CAJJ;AAMA,QAAM;AAAEC,IAAAA;AAAF,MAAgB,4CAAtB;AACA,QAAMC,iBAAiB,GAAG,4CAA1B;AACA,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAkB,oDAAxB;AACA,QAAM;AAAEC,IAAAA;AAA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Frame,\n} from 'react-native-safe-area-context';\nimport Animated, {\n\trunOnJS,\n\trunOnUI,\n\tuseAnimatedRef,\n\tuseAnimatedStyle,\n\tuseSharedValue,\n\twithDelay,\n\twithTiming,\n\tZoomInEasyDown,\n} from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { Draggable, DraggableTrigger } from '@wordpress/components';\nimport { select, useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tPlatform,\n} from '@wordpress/element';\nimport { getBlockType } from '@wordpress/blocks';\nimport { generateHapticFeedback } from '@wordpress/react-native-bridge';\nimport RCTAztecView from '@wordpress/react-native-aztec';\n\n/**\n * Internal dependencies\n */\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport DraggableChip from './draggable-chip';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockListContext } from '../block-list/block-list-context';\nimport DroppingInsertionPoint from './dropping-insertion-point';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport styles from './style.scss';\n\nconst CHIP_OFFSET_TO_TOUCH_POSITION = 32;\nconst BLOCK_OPACITY_ANIMATION_CONFIG = { duration: 350 };\nconst BLOCK_OPACITY_ANIMATION_DELAY = 250;\nconst DEFAULT_LONG_PRESS_MIN_DURATION = 500;\nconst DEFAULT_IOS_LONG_PRESS_MIN_DURATION =\n\tDEFAULT_LONG_PRESS_MIN_DURATION - 50;\n\n/**\n * Block draggable wrapper component\n *\n * This component handles all the interactions for dragging blocks.\n * It relies on the block list and its context for dragging, hence it\n * should be rendered between the `BlockListProvider` component and the\n * block list rendering. It also requires listening to scroll events,\n * therefore for this purpose, it returns the `onScroll` event handler\n * that should be attached to the list that renders the blocks.\n *\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {boolean} props.isRTL Check if current locale is RTL.\n *\n * @return {Function} Render function that passes `onScroll` event handler.\n */\nconst BlockDraggableWrapper = ( { children, isRTL } ) => {\n\tconst [ draggedBlockIcon, setDraggedBlockIcon ] = useState();\n\n\tconst {\n\t\tselectBlock,\n\t\tstartDraggingBlocks,\n\t\tstopDraggingBlocks,\n\t} = useDispatch( blockEditorStore );\n\n\tconst { scrollRef } = useBlockListContext();\n\tconst animatedScrollRef = useAnimatedRef();\n\tconst { left, right } = useSafeAreaInsets();\n\tconst { width } = useSafeAreaFrame();\n\tconst safeAreaOffset = left + right;\n\tconst contentWidth = width - safeAreaOffset;\n\tanimatedScrollRef( scrollRef );\n\n\tconst scroll = {\n\t\toffsetY: useSharedValue( 0 ),\n\t};\n\tconst chip = {\n\t\tx: useSharedValue( 0 ),\n\t\ty: useSharedValue( 0 ),\n\t\twidth: useSharedValue( 0 ),\n\t\theight: useSharedValue( 0 ),\n\t};\n\tconst currentYPosition = useSharedValue( 0 );\n\tconst isDragging = useSharedValue( false );\n\n\tconst [\n\t\tstartScrolling,\n\t\tscrollOnDragOver,\n\t\tstopScrolling,\n\t\tdraggingScrollHandler,\n\t] = useScrollWhenDragging();\n\n\tconst scrollHandler = ( event ) => {\n\t\t'worklet';\n\t\tconst { contentOffset } = event;\n\t\tscroll.offsetY.value = contentOffset.y;\n\n\t\tdraggingScrollHandler( event );\n\t};\n\n\tconst {\n\t\tonBlockDragOver,\n\t\tonBlockDragEnd,\n\t\tonBlockDrop,\n\t\ttargetBlockIndex,\n\t} = useBlockDropZone();\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.value ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tconst setDraggedBlockIconByClientId = ( clientId ) => {\n\t\tconst blockName = select( blockEditorStore ).getBlockName( clientId );\n\t\tconst blockIcon = getBlockType( blockName )?.icon;\n\t\tif ( blockIcon ) {\n\t\t\tsetDraggedBlockIcon( blockIcon );\n\t\t}\n\t};\n\n\tconst onStartDragging = ( { clientId, position } ) => {\n\t\tif ( clientId ) {\n\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\tsetDraggedBlockIconByClientId( clientId );\n\t\t\trunOnUI( startScrolling )( position.y );\n\t\t\tgenerateHapticFeedback();\n\t\t} else {\n\t\t\t// We stop dragging if no block is found.\n\t\t\trunOnUI( stopDragging )();\n\t\t}\n\t};\n\n\tconst onStopDragging = ( { clientId } ) => {\n\t\tif ( clientId ) {\n\t\t\tonBlockDrop( {\n\t\t\t\t// Dropping is only allowed at root level\n\t\t\t\tsrcRootClientId: '',\n\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\ttype: 'block',\n\t\t\t} );\n\t\t\tselectBlock( clientId );\n\t\t\tsetDraggedBlockIcon( undefined );\n\t\t}\n\t\tonBlockDragEnd();\n\t\tstopDraggingBlocks();\n\t};\n\n\tconst onChipLayout = ( { nativeEvent: { layout } } ) => {\n\t\tif ( layout.width > 0 ) {\n\t\t\tchip.width.value = layout.width;\n\t\t}\n\t\tif ( layout.height > 0 ) {\n\t\t\tchip.height.value = layout.height;\n\t\t}\n\t};\n\n\tconst startDragging = ( { x, y, id } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\tisDragging.value = true;\n\n\t\trunOnJS( onStartDragging )( { clientId: id, position: dragPosition } );\n\t};\n\n\tconst updateDragging = ( { x, y } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\trunOnJS( onBlockDragOver )( { x, y: y + scroll.offsetY.value } );\n\n\t\t// Update scrolling velocity\n\t\tscrollOnDragOver( dragPosition.y );\n\t};\n\n\tconst stopDragging = ( { id } ) => {\n\t\t'worklet';\n\t\tisDragging.value = false;\n\n\t\tstopScrolling();\n\t\trunOnJS( onStopDragging )( { clientId: id } );\n\t};\n\n\tconst chipDynamicStyles = useAnimatedStyle( () => {\n\t\tconst chipOffset = chip.width.value / 2;\n\t\tconst translateX = ! isRTL\n\t\t\t? chip.x.value - chipOffset\n\t\t\t: -( contentWidth - ( chip.x.value + chipOffset ) );\n\n\t\treturn {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateX,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateY:\n\t\t\t\t\t\tchip.y.value -\n\t\t\t\t\t\tchip.height.value -\n\t\t\t\t\t\tCHIP_OFFSET_TO_TOUCH_POSITION,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t} );\n\tconst chipStyles = [\n\t\tchipDynamicStyles,\n\t\tstyles[ 'draggable-chip__wrapper' ],\n\t];\n\n\tconst exitingAnimation = ( { currentHeight, currentWidth } ) => {\n\t\t'worklet';\n\t\tconst translateX = ! isRTL ? 0 : currentWidth * -1;\n\t\tconst duration = 150;\n\t\tconst animations = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: withTiming( currentHeight, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateX: withTiming( translateX, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{ scale: withTiming( 0, { duration } ) },\n\t\t\t],\n\t\t};\n\t\tconst initialValues = {\n\t\t\ttransform: [ { translateY: 0 }, { translateX }, { scale: 1 } ],\n\t\t};\n\t\treturn {\n\t\t\tinitialValues,\n\t\t\tanimations,\n\t\t};\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<DroppingInsertionPoint\n\t\t\t\tscroll={ scroll }\n\t\t\t\tcurrentYPosition={ currentYPosition }\n\t\t\t\tisDragging={ isDragging }\n\t\t\t\ttargetBlockIndex={ targetBlockIndex }\n\t\t\t/>\n\t\t\t<Draggable\n\t\t\t\tonDragStart={ startDragging }\n\t\t\t\tonDragOver={ updateDragging }\n\t\t\t\tonDragEnd={ stopDragging }\n\t\t\t\ttestID=\"block-draggable-wrapper\"\n\t\t\t>\n\t\t\t\t{ children( { onScroll: scrollHandler } ) }\n\t\t\t</Draggable>\n\t\t\t<Animated.View\n\t\t\t\tonLayout={ onChipLayout }\n\t\t\t\tstyle={ chipStyles }\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t>\n\t\t\t\t{ draggedBlockIcon && (\n\t\t\t\t\t<Animated.View\n\t\t\t\t\t\tentering={ ZoomInEasyDown.duration( 200 ) }\n\t\t\t\t\t\texiting={ exitingAnimation }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DraggableChip icon={ draggedBlockIcon } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t) }\n\t\t\t</Animated.View>\n\t\t</>\n\t);\n};\n\n/**\n * Block draggable component\n *\n * This component serves for animating the block when it is being dragged.\n * Hence, it should be wrapped around the rendering of a block.\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {string} props.clientId Client id of the block.\n * @param {string} [props.draggingClientId] Client id to use for dragging. If not defined, the value from `clientId` will be used.\n * @param {boolean} [props.enabled] Enables the draggable trigger.\n * @param {string} [props.testID] Id used for querying the long-press gesture handler in tests.\n *\n * @return {Function} Render function which includes the parameter `isDraggable` to determine if the block can be dragged.\n */\nconst BlockDraggable = ( {\n\tclientId,\n\tchildren,\n\tdraggingClientId,\n\tenabled = true,\n\ttestID,\n} ) => {\n\tconst wasBeingDragged = useRef( false );\n\tconst [ isEditingText, setIsEditingText ] = useState( false );\n\tconst [ isScreenReaderEnabled, setIsScreenReaderEnabled ] = useState(\n\t\tfalse\n\t);\n\n\tconst draggingAnimation = {\n\t\topacity: useSharedValue( 1 ),\n\t};\n\n\tconst startDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withTiming(\n\t\t\t0.4,\n\t\t\tBLOCK_OPACITY_ANIMATION_CONFIG\n\t\t);\n\t};\n\n\tconst stopDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withDelay(\n\t\t\tBLOCK_OPACITY_ANIMATION_DELAY,\n\t\t\twithTiming( 1, BLOCK_OPACITY_ANIMATION_CONFIG )\n\t\t);\n\t};\n\n\tconst { isDraggable, isBeingDragged, isBlockSelected } = useSelect(\n\t\t( _select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tisBlockBeingDragged,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = _select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst templateLock = rootClientId\n\t\t\t\t? getTemplateLock( rootClientId )\n\t\t\t\t: null;\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\treturn {\n\t\t\t\tisBeingDragged: isBlockBeingDragged( clientId ),\n\t\t\t\tisDraggable: 'all' !== templateLock,\n\t\t\t\tisBlockSelected:\n\t\t\t\t\tselectedBlockClientId && selectedBlockClientId === clientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isBeingDragged !== wasBeingDragged.current ) {\n\t\t\tif ( isBeingDragged ) {\n\t\t\t\tstartDraggingBlock();\n\t\t\t} else {\n\t\t\t\tstopDraggingBlock();\n\t\t\t}\n\t\t}\n\t\twasBeingDragged.current = isBeingDragged;\n\t}, [ isBeingDragged ] );\n\n\tconst onFocusChangeAztec = useCallback( ( { isFocused } ) => {\n\t\tsetIsEditingText( isFocused );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tlet mounted = true;\n\n\t\tconst isAnyAztecInputFocused = RCTAztecView.InputState.isFocused();\n\t\tif ( isAnyAztecInputFocused ) {\n\t\t\tsetIsEditingText( isAnyAztecInputFocused );\n\t\t}\n\n\t\tRCTAztecView.InputState.addFocusChangeListener( onFocusChangeAztec );\n\n\t\tconst screenReaderChangedListener = AccessibilityInfo.addEventListener(\n\t\t\t'screenReaderChanged',\n\t\t\tsetIsScreenReaderEnabled\n\t\t);\n\t\tAccessibilityInfo.isScreenReaderEnabled().then(\n\t\t\t( screenReaderEnabled ) => {\n\t\t\t\tif ( mounted ) {\n\t\t\t\t\tsetIsScreenReaderEnabled( screenReaderEnabled );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\n\t\t\tRCTAztecView.InputState.removeFocusChangeListener(\n\t\t\t\tonFocusChangeAztec\n\t\t\t);\n\n\t\t\tscreenReaderChangedListener.remove();\n\t\t};\n\t}, [] );\n\n\tconst onLongPressDraggable = useCallback( () => {\n\t\t// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.\n\t\tRCTAztecView.InputState.blurCurrentFocusedElement();\n\t}, [] );\n\n\tconst animatedWrapperStyles = useAnimatedStyle( () => {\n\t\treturn {\n\t\t\topacity: draggingAnimation.opacity.value,\n\t\t};\n\t} );\n\tconst wrapperStyles = [\n\t\tanimatedWrapperStyles,\n\t\tstyles[ 'draggable-wrapper__container' ],\n\t];\n\n\tconst canDragBlock =\n\t\tenabled &&\n\t\t! isScreenReaderEnabled &&\n\t\t( ! isBlockSelected || ! isEditingText );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { isDraggable: false } );\n\t}\n\n\treturn (\n\t\t<DraggableTrigger\n\t\t\tid={ draggingClientId || clientId }\n\t\t\tenabled={ enabled && canDragBlock }\n\t\t\tminDuration={ Platform.select( {\n\t\t\t\t// On iOS, using a lower min duration than the default\n\t\t\t\t// value prevents the long-press gesture from being\n\t\t\t\t// triggered in underneath elements. This is required to\n\t\t\t\t// prevent enabling text editing when dragging is available.\n\t\t\t\tios: canDragBlock\n\t\t\t\t\t? DEFAULT_IOS_LONG_PRESS_MIN_DURATION\n\t\t\t\t\t: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t\tandroid: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t} ) }\n\t\t\tonLongPress={ onLongPressDraggable }\n\t\t\ttestID={ testID }\n\t\t>\n\t\t\t<Animated.View style={ wrapperStyles }>\n\t\t\t\t{ children( { isDraggable: true } ) }\n\t\t\t</Animated.View>\n\t\t</DraggableTrigger>\n\t);\n};\n\nexport { BlockDraggableWrapper };\nexport default BlockDraggable;\n"]}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useScrollWhenDragging;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ var _reactNativeReanimated = require("react-native-reanimated");
11
+
12
+ var _blockListContext = require("../block-list/block-list-context");
13
+
14
+ /**
15
+ * External dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ const SCROLL_INACTIVE_DISTANCE_PX = 50;
22
+ const SCROLL_INTERVAL_MS = 1000;
23
+ const VELOCITY_MULTIPLIER = 5000;
24
+ /**
25
+ * React hook that scrolls the scroll container when a block is being dragged.
26
+ *
27
+ * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
28
+ * functions to be called in `onDragStart`, `onDragOver`
29
+ * and `onDragEnd` events respectively. Additionally,
30
+ * `scrollHandler` function is returned which should be
31
+ * called in the `onScroll` event of the block list.
32
+ */
33
+
34
+ function useScrollWhenDragging() {
35
+ const {
36
+ scrollRef
37
+ } = (0, _blockListContext.useBlockListContext)();
38
+ const animatedScrollRef = (0, _reactNativeReanimated.useAnimatedRef)();
39
+ animatedScrollRef(scrollRef);
40
+ const {
41
+ height: windowHeight
42
+ } = (0, _reactNative.useWindowDimensions)();
43
+ const velocityY = (0, _reactNativeReanimated.useSharedValue)(0);
44
+ const offsetY = (0, _reactNativeReanimated.useSharedValue)(0);
45
+ const dragStartY = (0, _reactNativeReanimated.useSharedValue)(0);
46
+ const animationTimer = (0, _reactNativeReanimated.useSharedValue)(0);
47
+ const isAnimationTimerActive = (0, _reactNativeReanimated.useSharedValue)(false);
48
+ const isScrollActive = (0, _reactNativeReanimated.useSharedValue)(false);
49
+ const scroll = {
50
+ offsetY: (0, _reactNativeReanimated.useSharedValue)(0),
51
+ maxOffsetY: (0, _reactNativeReanimated.useSharedValue)(0)
52
+ };
53
+
54
+ const scrollHandler = event => {
55
+ 'worklet';
56
+
57
+ const {
58
+ contentSize,
59
+ contentOffset,
60
+ layoutMeasurement
61
+ } = event;
62
+ scroll.offsetY.value = contentOffset.y;
63
+ scroll.maxOffsetY.value = contentSize.height - layoutMeasurement.height;
64
+ };
65
+
66
+ const stopScrolling = () => {
67
+ 'worklet';
68
+
69
+ (0, _reactNativeReanimated.cancelAnimation)(animationTimer);
70
+ isAnimationTimerActive.value = false;
71
+ isScrollActive.value = false;
72
+ velocityY.value = 0;
73
+ };
74
+
75
+ const startScrolling = y => {
76
+ 'worklet';
77
+
78
+ stopScrolling();
79
+ offsetY.value = scroll.offsetY.value;
80
+ dragStartY.value = y;
81
+ animationTimer.value = 0;
82
+ animationTimer.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(1, {
83
+ duration: SCROLL_INTERVAL_MS,
84
+ easing: _reactNativeReanimated.Easing.linear
85
+ }), -1, true);
86
+ isAnimationTimerActive.value = true;
87
+ };
88
+
89
+ const scrollOnDragOver = y => {
90
+ 'worklet';
91
+
92
+ const dragDistance = Math.max(Math.abs(y - dragStartY.value) - SCROLL_INACTIVE_DISTANCE_PX, 0);
93
+ const distancePercentage = dragDistance / windowHeight;
94
+
95
+ if (!isScrollActive.value) {
96
+ isScrollActive.value = dragDistance > 0;
97
+ } else if (y > dragStartY.value) {
98
+ // User is dragging downwards.
99
+ velocityY.value = VELOCITY_MULTIPLIER * distancePercentage;
100
+ } else if (y < dragStartY.value) {
101
+ // User is dragging upwards.
102
+ velocityY.value = -VELOCITY_MULTIPLIER * distancePercentage;
103
+ } else {
104
+ velocityY.value = 0;
105
+ }
106
+ };
107
+
108
+ (0, _reactNativeReanimated.useAnimatedReaction)(() => animationTimer.value, (value, previous) => {
109
+ if (velocityY.value === 0) {
110
+ return;
111
+ }
112
+
113
+ const delta = Math.abs(value - previous);
114
+ let newOffset = offsetY.value + delta * velocityY.value;
115
+
116
+ if (scroll.maxOffsetY.value !== 0) {
117
+ newOffset = Math.max(0, Math.min(scroll.maxOffsetY.value, newOffset));
118
+ } else {
119
+ // Scroll values are empty until receiving the first scroll event.
120
+ // In that case, the max offset is unknown and we can't clamp the
121
+ // new offset value.
122
+ newOffset = Math.max(0, newOffset);
123
+ }
124
+
125
+ offsetY.value = newOffset;
126
+ (0, _reactNativeReanimated.scrollTo)(animatedScrollRef, 0, offsetY.value, false);
127
+ });
128
+ return [startScrolling, scrollOnDragOver, stopScrolling, scrollHandler];
129
+ }
130
+ //# sourceMappingURL=use-scroll-when-dragging.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/use-scroll-when-dragging.native.js"],"names":["SCROLL_INACTIVE_DISTANCE_PX","SCROLL_INTERVAL_MS","VELOCITY_MULTIPLIER","useScrollWhenDragging","scrollRef","animatedScrollRef","height","windowHeight","velocityY","offsetY","dragStartY","animationTimer","isAnimationTimerActive","isScrollActive","scroll","maxOffsetY","scrollHandler","event","contentSize","contentOffset","layoutMeasurement","value","y","stopScrolling","startScrolling","duration","easing","Easing","linear","scrollOnDragOver","dragDistance","Math","max","abs","distancePercentage","previous","delta","newOffset","min"],"mappings":";;;;;;;AAGA;;AACA;;AAcA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGA,MAAMA,2BAA2B,GAAG,EAApC;AACA,MAAMC,kBAAkB,GAAG,IAA3B;AACA,MAAMC,mBAAmB,GAAG,IAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,qBAAT,GAAiC;AAC/C,QAAM;AAAEC,IAAAA;AAAF,MAAgB,4CAAtB;AACA,QAAMC,iBAAiB,GAAG,4CAA1B;AACAA,EAAAA,iBAAiB,CAAED,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ACA,QAAIE,SAAS,GAAG5B,OAAO,CAACY,KAAR,GAAgBe,KAAK,GAAG5B,SAAS,CAACa,KAAlD;;AAEA,QAAKP,MAAM,CAACC,UAAP,CAAkBM,KAAlB,KAA4B,CAAjC,EAAqC;AACpCgB,MAAAA,SAAS,GAAGN,IAAI,CAACC,GAAL,CACX,CADW,EAEXD,IAAI,CAACO,GAAL,CAAUxB,MAAM,CAACC,UAAP,CAAkBM,KAA5B,EAAmCgB,SAAnC,CAFW,CAAZ;AAIA,KALD,MAKO;AACN;AACA;AACA;AACAA,MAAAA,SAAS,GAAGN,IAAI,CAACC,GAAL,CAAU,CAAV,EAAaK,SAAb,CAAZ;AACA;;AAED5B,IAAAA,OAAO,CAACY,KAAR,GAAgBgB,SAAhB;AACA,yCAAUhC,iBAAV,EAA6B,CAA7B,EAAgCI,OAAO,CAACY,KAAxC,EAA+C,KAA/C;AACA,GAxBF;AA2BA,SAAO,CAAEG,cAAF,EAAkBK,gBAAlB,EAAoCN,aAApC,EAAmDP,aAAnD,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { useWindowDimensions } from 'react-native';\nimport {\n\tuseSharedValue,\n\tuseAnimatedRef,\n\tscrollTo,\n\tuseAnimatedReaction,\n\twithTiming,\n\twithRepeat,\n\tcancelAnimation,\n\tEasing,\n} from 'react-native-reanimated';\n\n/**\n * Internal dependencies\n */\nimport { useBlockListContext } from '../block-list/block-list-context';\n\nconst SCROLL_INACTIVE_DISTANCE_PX = 50;\nconst SCROLL_INTERVAL_MS = 1000;\nconst VELOCITY_MULTIPLIER = 5000;\n\n/**\n * React hook that scrolls the scroll container when a block is being dragged.\n *\n * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`\n * functions to be called in `onDragStart`, `onDragOver`\n * and `onDragEnd` events respectively. Additionally,\n * \t\t\t\t\t\t`scrollHandler` function is returned which should be\n * \t\t\t\t\t\tcalled in the `onScroll` event of the block list.\n */\nexport default function useScrollWhenDragging() {\n\tconst { scrollRef } = useBlockListContext();\n\tconst animatedScrollRef = useAnimatedRef();\n\tanimatedScrollRef( scrollRef );\n\n\tconst { height: windowHeight } = useWindowDimensions();\n\n\tconst velocityY = useSharedValue( 0 );\n\tconst offsetY = useSharedValue( 0 );\n\tconst dragStartY = useSharedValue( 0 );\n\tconst animationTimer = useSharedValue( 0 );\n\tconst isAnimationTimerActive = useSharedValue( false );\n\tconst isScrollActive = useSharedValue( false );\n\n\tconst scroll = {\n\t\toffsetY: useSharedValue( 0 ),\n\t\tmaxOffsetY: useSharedValue( 0 ),\n\t};\n\tconst scrollHandler = ( event ) => {\n\t\t'worklet';\n\t\tconst { contentSize, contentOffset, layoutMeasurement } = event;\n\t\tscroll.offsetY.value = contentOffset.y;\n\t\tscroll.maxOffsetY.value = contentSize.height - layoutMeasurement.height;\n\t};\n\n\tconst stopScrolling = () => {\n\t\t'worklet';\n\t\tcancelAnimation( animationTimer );\n\n\t\tisAnimationTimerActive.value = false;\n\t\tisScrollActive.value = false;\n\t\tvelocityY.value = 0;\n\t};\n\n\tconst startScrolling = ( y ) => {\n\t\t'worklet';\n\t\tstopScrolling();\n\t\toffsetY.value = scroll.offsetY.value;\n\t\tdragStartY.value = y;\n\n\t\tanimationTimer.value = 0;\n\t\tanimationTimer.value = withRepeat(\n\t\t\twithTiming( 1, {\n\t\t\t\tduration: SCROLL_INTERVAL_MS,\n\t\t\t\teasing: Easing.linear,\n\t\t\t} ),\n\t\t\t-1,\n\t\t\ttrue\n\t\t);\n\t\tisAnimationTimerActive.value = true;\n\t};\n\n\tconst scrollOnDragOver = ( y ) => {\n\t\t'worklet';\n\t\tconst dragDistance = Math.max(\n\t\t\tMath.abs( y - dragStartY.value ) - SCROLL_INACTIVE_DISTANCE_PX,\n\t\t\t0\n\t\t);\n\t\tconst distancePercentage = dragDistance / windowHeight;\n\n\t\tif ( ! isScrollActive.value ) {\n\t\t\tisScrollActive.value = dragDistance > 0;\n\t\t} else if ( y > dragStartY.value ) {\n\t\t\t// User is dragging downwards.\n\t\t\tvelocityY.value = VELOCITY_MULTIPLIER * distancePercentage;\n\t\t} else if ( y < dragStartY.value ) {\n\t\t\t// User is dragging upwards.\n\t\t\tvelocityY.value = -VELOCITY_MULTIPLIER * distancePercentage;\n\t\t} else {\n\t\t\tvelocityY.value = 0;\n\t\t}\n\t};\n\n\tuseAnimatedReaction(\n\t\t() => animationTimer.value,\n\t\t( value, previous ) => {\n\t\t\tif ( velocityY.value === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst delta = Math.abs( value - previous );\n\t\t\tlet newOffset = offsetY.value + delta * velocityY.value;\n\n\t\t\tif ( scroll.maxOffsetY.value !== 0 ) {\n\t\t\t\tnewOffset = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\tMath.min( scroll.maxOffsetY.value, newOffset )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Scroll values are empty until receiving the first scroll event.\n\t\t\t\t// In that case, the max offset is unknown and we can't clamp the\n\t\t\t\t// new offset value.\n\t\t\t\tnewOffset = Math.max( 0, newOffset );\n\t\t\t}\n\n\t\t\toffsetY.value = newOffset;\n\t\t\tscrollTo( animatedScrollRef, 0, offsetY.value, false );\n\t\t}\n\t);\n\n\treturn [ startScrolling, scrollOnDragOver, stopScrolling, scrollHandler ];\n}\n"]}
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_BLOCK_LIST_CONTEXT = exports.BlockListProvider = exports.BlockListConsumer = void 0;
7
+ exports.deleteBlockLayoutByClientId = deleteBlockLayoutByClientId;
8
+ exports.useBlockListContext = void 0;
9
+
10
+ var _lodash = require("lodash");
11
+
12
+ var _element = require("@wordpress/element");
13
+
14
+ /**
15
+ * External dependencies
16
+ */
17
+
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+ const DEFAULT_BLOCK_LIST_CONTEXT = {
22
+ scrollRef: null,
23
+ blocksLayouts: {
24
+ current: {}
25
+ },
26
+ findBlockLayoutByClientId,
27
+ getBlockLayoutsOrderedByYCoord,
28
+ findBlockLayoutByPosition,
29
+ updateBlocksLayouts
30
+ };
31
+ exports.DEFAULT_BLOCK_LIST_CONTEXT = DEFAULT_BLOCK_LIST_CONTEXT;
32
+ const Context = (0, _element.createContext)(DEFAULT_BLOCK_LIST_CONTEXT);
33
+ const {
34
+ Provider,
35
+ Consumer
36
+ } = Context;
37
+ /**
38
+ * Finds a block's layout data by position.
39
+ *
40
+ * @param {Object} data Blocks layouts object.
41
+ * @param {Object} position Position to use for finding the block.
42
+ * @param {number} position.x X coordinate.
43
+ * @param {number} position.y Y coordinate.
44
+ *
45
+ * @return {Object|undefined} Found block layout data that matches the provided position. If none is found, `undefined` will be returned.
46
+ */
47
+
48
+ exports.BlockListConsumer = Consumer;
49
+ exports.BlockListProvider = Provider;
50
+
51
+ function findBlockLayoutByPosition(data, position) {
52
+ // Only enabled for root level blocks
53
+ return Object.values(data).find(block => {
54
+ return position.x >= block.x && position.x <= block.x + block.width && position.y >= block.y && position.y <= block.y + block.height;
55
+ });
56
+ }
57
+ /**
58
+ * Finds a block's layout data by its client Id.
59
+ *
60
+ * @param {Object} data Blocks layouts object.
61
+ * @param {string} clientId Block's clientId.
62
+ *
63
+ * @return {Object} Found block layout data.
64
+ */
65
+
66
+
67
+ function findBlockLayoutByClientId(data, clientId) {
68
+ return Object.entries(data).reduce((acc, entry) => {
69
+ const item = entry[1];
70
+
71
+ if (acc) {
72
+ return acc;
73
+ }
74
+
75
+ if ((item === null || item === void 0 ? void 0 : item.clientId) === clientId) {
76
+ return item;
77
+ }
78
+
79
+ if (item !== null && item !== void 0 && item.innerBlocks && Object.keys(item.innerBlocks).length > 0) {
80
+ return findBlockLayoutByClientId(item.innerBlocks, clientId);
81
+ }
82
+
83
+ return null;
84
+ }, null);
85
+ }
86
+ /**
87
+ * Deletes the layout data of a block by its client Id.
88
+ *
89
+ * @param {Object} data Blocks layouts object.
90
+ * @param {string} clientId Block's clientsId.
91
+ *
92
+ * @return {Object} Updated data object.
93
+ */
94
+
95
+
96
+ function deleteBlockLayoutByClientId(data, clientId) {
97
+ return Object.keys(data).reduce((acc, key) => {
98
+ var _data$key;
99
+
100
+ if (key !== clientId) {
101
+ acc[key] = data[key];
102
+ }
103
+
104
+ if ((_data$key = data[key]) !== null && _data$key !== void 0 && _data$key.innerBlocks && Object.keys(data[key].innerBlocks).length > 0) {
105
+ if (acc[key]) {
106
+ acc[key].innerBlocks = deleteBlockLayoutByClientId(data[key].innerBlocks, clientId);
107
+ }
108
+ }
109
+
110
+ return acc;
111
+ }, {});
112
+ }
113
+ /**
114
+ * Orders the block's layout data by its Y coordinate.
115
+ *
116
+ * @param {Object} data Blocks layouts object.
117
+ *
118
+ * @return {Object} Blocks layouts object ordered by its Y coordinate.
119
+ */
120
+
121
+
122
+ function getBlockLayoutsOrderedByYCoord(data) {
123
+ // Only enabled for root level blocks.
124
+ // Using lodash orderBy due to hermes not having
125
+ // stable support for native .sort(). It will be
126
+ // supported in the React Native version 0.68.0.
127
+ return (0, _lodash.orderBy)(data, ['y', 'asc']);
128
+ }
129
+ /**
130
+ * Updates or deletes a block's layout data in the blocksLayouts object,
131
+ * in case of deletion, the layout data is not required.
132
+ *
133
+ * @param {Object} blocksLayouts Blocks layouts object.
134
+ * @param {Object} blockData Block's layout data to add or remove to/from the blockLayouts object.
135
+ * @param {string} blockData.clientId Block's clientId.
136
+ * @param {?string} blockData.rootClientId Optional. Block's rootClientId.
137
+ * @param {?boolean} blockData.shouldRemove Optional. Flag to remove it from the blocksLayout list.
138
+ * @param {number} blockData.width Block's width.
139
+ * @param {number} blockData.height Block's height.
140
+ * @param {number} blockData.x Block's x coordinate (relative to the parent).
141
+ * @param {number} blockData.y Block's y coordinate (relative to the parent).
142
+ */
143
+
144
+
145
+ function updateBlocksLayouts(blocksLayouts, blockData) {
146
+ const {
147
+ clientId,
148
+ rootClientId,
149
+ shouldRemove,
150
+ ...layoutProps
151
+ } = blockData;
152
+
153
+ if (clientId && shouldRemove) {
154
+ blocksLayouts.current = deleteBlockLayoutByClientId(blocksLayouts.current, clientId);
155
+ return;
156
+ }
157
+
158
+ if (clientId && !rootClientId) {
159
+ var _blocksLayouts$curren;
160
+
161
+ blocksLayouts.current[clientId] = {
162
+ clientId,
163
+ rootClientId,
164
+ ...layoutProps,
165
+ innerBlocks: { ...((_blocksLayouts$curren = blocksLayouts.current[clientId]) === null || _blocksLayouts$curren === void 0 ? void 0 : _blocksLayouts$curren.innerBlocks)
166
+ }
167
+ };
168
+ } else if (clientId && rootClientId) {
169
+ const block = findBlockLayoutByClientId(blocksLayouts.current, rootClientId);
170
+
171
+ if (block) {
172
+ var _block$innerBlocks$cl;
173
+
174
+ block.innerBlocks[clientId] = {
175
+ clientId,
176
+ rootClientId,
177
+ ...layoutProps,
178
+ innerBlocks: { ...((_block$innerBlocks$cl = block.innerBlocks[clientId]) === null || _block$innerBlocks$cl === void 0 ? void 0 : _block$innerBlocks$cl.innerBlocks)
179
+ }
180
+ };
181
+ }
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Hook that returns the block list context.
187
+ *
188
+ * @return {Object} Block list context
189
+ */
190
+ const useBlockListContext = () => {
191
+ return (0, _element.useContext)(Context);
192
+ };
193
+
194
+ exports.useBlockListContext = useBlockListContext;
195
+ //# sourceMappingURL=block-list-context.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/block-list-context.native.js"],"names":["DEFAULT_BLOCK_LIST_CONTEXT","scrollRef","blocksLayouts","current","findBlockLayoutByClientId","getBlockLayoutsOrderedByYCoord","findBlockLayoutByPosition","updateBlocksLayouts","Context","Provider","Consumer","data","position","Object","values","find","block","x","width","y","height","clientId","entries","reduce","acc","entry","item","innerBlocks","keys","length","deleteBlockLayoutByClientId","key","blockData","rootClientId","shouldRemove","layoutProps","useBlockListContext"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;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xC,SAAO,yBAAY5B,OAAZ,CAAP;AACA,CAFM","sourcesContent":["/**\n * External dependencies\n */\nimport { orderBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nexport const DEFAULT_BLOCK_LIST_CONTEXT = {\n\tscrollRef: null,\n\tblocksLayouts: { current: {} },\n\tfindBlockLayoutByClientId,\n\tgetBlockLayoutsOrderedByYCoord,\n\tfindBlockLayoutByPosition,\n\tupdateBlocksLayouts,\n};\n\nconst Context = createContext( DEFAULT_BLOCK_LIST_CONTEXT );\nconst { Provider, Consumer } = Context;\n\n/**\n * Finds a block's layout data by position.\n *\n * @param {Object} data Blocks layouts object.\n * @param {Object} position Position to use for finding the block.\n * @param {number} position.x X coordinate.\n * @param {number} position.y Y coordinate.\n *\n * @return {Object|undefined} Found block layout data that matches the provided position. If none is found, `undefined` will be returned.\n */\nfunction findBlockLayoutByPosition( data, position ) {\n\t// Only enabled for root level blocks\n\treturn Object.values( data ).find( ( block ) => {\n\t\treturn (\n\t\t\tposition.x >= block.x &&\n\t\t\tposition.x <= block.x + block.width &&\n\t\t\tposition.y >= block.y &&\n\t\t\tposition.y <= block.y + block.height\n\t\t);\n\t} );\n}\n\n/**\n * Finds a block's layout data by its client Id.\n *\n * @param {Object} data Blocks layouts object.\n * @param {string} clientId Block's clientId.\n *\n * @return {Object} Found block layout data.\n */\nfunction findBlockLayoutByClientId( data, clientId ) {\n\treturn Object.entries( data ).reduce( ( acc, entry ) => {\n\t\tconst item = entry[ 1 ];\n\t\tif ( acc ) {\n\t\t\treturn acc;\n\t\t}\n\t\tif ( item?.clientId === clientId ) {\n\t\t\treturn item;\n\t\t}\n\t\tif ( item?.innerBlocks && Object.keys( item.innerBlocks ).length > 0 ) {\n\t\t\treturn findBlockLayoutByClientId( item.innerBlocks, clientId );\n\t\t}\n\t\treturn null;\n\t}, null );\n}\n\n/**\n * Deletes the layout data of a block by its client Id.\n *\n * @param {Object} data Blocks layouts object.\n * @param {string} clientId Block's clientsId.\n *\n * @return {Object} Updated data object.\n */\nexport function deleteBlockLayoutByClientId( data, clientId ) {\n\treturn Object.keys( data ).reduce( ( acc, key ) => {\n\t\tif ( key !== clientId ) {\n\t\t\tacc[ key ] = data[ key ];\n\t\t}\n\t\tif (\n\t\t\tdata[ key ]?.innerBlocks &&\n\t\t\tObject.keys( data[ key ].innerBlocks ).length > 0\n\t\t) {\n\t\t\tif ( acc[ key ] ) {\n\t\t\t\tacc[ key ].innerBlocks = deleteBlockLayoutByClientId(\n\t\t\t\t\tdata[ key ].innerBlocks,\n\t\t\t\t\tclientId\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn acc;\n\t}, {} );\n}\n\n/**\n * Orders the block's layout data by its Y coordinate.\n *\n * @param {Object} data Blocks layouts object.\n *\n * @return {Object} Blocks layouts object ordered by its Y coordinate.\n */\nfunction getBlockLayoutsOrderedByYCoord( data ) {\n\t// Only enabled for root level blocks.\n\t// Using lodash orderBy due to hermes not having\n\t// stable support for native .sort(). It will be\n\t// supported in the React Native version 0.68.0.\n\treturn orderBy( data, [ 'y', 'asc' ] );\n}\n\n/**\n * Updates or deletes a block's layout data in the blocksLayouts object,\n * in case of deletion, the layout data is not required.\n *\n * @param {Object} blocksLayouts Blocks layouts object.\n * @param {Object} blockData Block's layout data to add or remove to/from the blockLayouts object.\n * @param {string} blockData.clientId Block's clientId.\n * @param {?string} blockData.rootClientId Optional. Block's rootClientId.\n * @param {?boolean} blockData.shouldRemove Optional. Flag to remove it from the blocksLayout list.\n * @param {number} blockData.width Block's width.\n * @param {number} blockData.height Block's height.\n * @param {number} blockData.x Block's x coordinate (relative to the parent).\n * @param {number} blockData.y Block's y coordinate (relative to the parent).\n */\n\nfunction updateBlocksLayouts( blocksLayouts, blockData ) {\n\tconst { clientId, rootClientId, shouldRemove, ...layoutProps } = blockData;\n\n\tif ( clientId && shouldRemove ) {\n\t\tblocksLayouts.current = deleteBlockLayoutByClientId(\n\t\t\tblocksLayouts.current,\n\t\t\tclientId\n\t\t);\n\t\treturn;\n\t}\n\n\tif ( clientId && ! rootClientId ) {\n\t\tblocksLayouts.current[ clientId ] = {\n\t\t\tclientId,\n\t\t\trootClientId,\n\t\t\t...layoutProps,\n\t\t\tinnerBlocks: {\n\t\t\t\t...blocksLayouts.current[ clientId ]?.innerBlocks,\n\t\t\t},\n\t\t};\n\t} else if ( clientId && rootClientId ) {\n\t\tconst block = findBlockLayoutByClientId(\n\t\t\tblocksLayouts.current,\n\t\t\trootClientId\n\t\t);\n\n\t\tif ( block ) {\n\t\t\tblock.innerBlocks[ clientId ] = {\n\t\t\t\tclientId,\n\t\t\t\trootClientId,\n\t\t\t\t...layoutProps,\n\t\t\t\tinnerBlocks: {\n\t\t\t\t\t...block.innerBlocks[ clientId ]?.innerBlocks,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n}\n\nexport { Provider as BlockListProvider, Consumer as BlockListConsumer };\n\n/**\n * Hook that returns the block list context.\n *\n * @return {Object} Block list context\n */\nexport const useBlockListContext = () => {\n\treturn useContext( Context );\n};\n"]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _blockListContext = require("./block-list-context");
13
+
14
+ /**
15
+ * External dependencies
16
+ */
17
+
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+
22
+ /**
23
+ * Internal dependencies
24
+ */
25
+ function BlockListItemCell(_ref) {
26
+ let {
27
+ children,
28
+ clientId,
29
+ rootClientId,
30
+ onLayout
31
+ } = _ref;
32
+ const {
33
+ blocksLayouts,
34
+ updateBlocksLayouts
35
+ } = (0, _blockListContext.useBlockListContext)();
36
+ (0, _element.useEffect)(() => {
37
+ return () => {
38
+ updateBlocksLayouts(blocksLayouts, {
39
+ clientId,
40
+ shouldRemove: true
41
+ });
42
+ };
43
+ }, []);
44
+ const onCellLayout = (0, _element.useCallback)(event => {
45
+ const {
46
+ nativeEvent: {
47
+ layout
48
+ }
49
+ } = event;
50
+ updateBlocksLayouts(blocksLayouts, {
51
+ clientId,
52
+ rootClientId,
53
+ ...layout
54
+ });
55
+
56
+ if (onLayout) {
57
+ onLayout(event);
58
+ }
59
+ }, [clientId, rootClientId, updateBlocksLayouts, onLayout]);
60
+ return (0, _element.createElement)(_reactNative.View, {
61
+ onLayout: onCellLayout
62
+ }, children);
63
+ }
64
+
65
+ var _default = BlockListItemCell;
66
+ exports.default = _default;
67
+ //# sourceMappingURL=block-list-item-cell.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/block-list-item-cell.native.js"],"names":["BlockListItemCell","children","clientId","rootClientId","onLayout","blocksLayouts","updateBlocksLayouts","shouldRemove","onCellLayout","event","nativeEvent","layout"],"mappings":";;;;;;;AAQA;;AALA;;AAUA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGA,SAASA,iBAAT,OAA6E;AAAA,MAAjD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA,YAAtB;AAAoCC,IAAAA;AAApC,GAAiD;AAC5E,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAAyC,4CAA/C;AAEA,0BAAW,MAAM;AAChB,WAAO,MAAM;AACZA,MAAAA,mBAAmB,CAAED,aAAF,EAAiB;AACnCH,QAAAA,QADmC;AAEnCK,QAAAA,YAAY,EAAE;AAFqB,OAAjB,CAAnB;AAIA,KALD;AAMA,GAPD,EAOG,EAPH;AASA,QAAMC,YAAY,GAAG,0BAClBC,KAAF,IAAa;AACZ,UAAM;AACLC,MAAAA,WAAW,EAAE;AAAEC,QAAAA;AAAF;AADR,QAEFF,KAFJ;AAGAH,IAAAA,mBAAmB,CAAED,aAAF,EAAiB;AACnCH,MAAAA,QADmC;AAEnCC,MAAAA,YAFmC;AAGnC,SAAGQ;AAHgC,KAAjB,CAAnB;;AAMA,QAAKP,QAAL,EAAgB;AACfA,MAAAA,QAAQ,CAAEK,KAAF,CAAR;AACA;AACD,GAdmB,EAepB,CAAEP,QAAF,EAAYC,YAAZ,EAA0BG,mBAA1B,EAA+CF,QAA/C,CAfoB,CAArB;AAkBA,SAAO,4BAAC,iBAAD;AAAM,IAAA,QAAQ,EAAGI;AAAjB,KAAkCP,QAAlC,CAAP;AACA;;eAEcD,iB","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useBlockListContext } from './block-list-context';\n\nfunction BlockListItemCell( { children, clientId, rootClientId, onLayout } ) {\n\tconst { blocksLayouts, updateBlocksLayouts } = useBlockListContext();\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tupdateBlocksLayouts( blocksLayouts, {\n\t\t\t\tclientId,\n\t\t\t\tshouldRemove: true,\n\t\t\t} );\n\t\t};\n\t}, [] );\n\n\tconst onCellLayout = useCallback(\n\t\t( event ) => {\n\t\t\tconst {\n\t\t\t\tnativeEvent: { layout },\n\t\t\t} = event;\n\t\t\tupdateBlocksLayouts( blocksLayouts, {\n\t\t\t\tclientId,\n\t\t\t\trootClientId,\n\t\t\t\t...layout,\n\t\t\t} );\n\n\t\t\tif ( onLayout ) {\n\t\t\t\tonLayout( event );\n\t\t\t}\n\t\t},\n\t\t[ clientId, rootClientId, updateBlocksLayouts, onLayout ]\n\t);\n\n\treturn <View onLayout={ onCellLayout }>{ children }</View>;\n}\n\nexport default BlockListItemCell;\n"]}
@@ -154,23 +154,26 @@ class BlockListItem extends _element.Component {
154
154
 
155
155
  render() {
156
156
  const {
157
- gridProperties,
158
- clientId,
159
157
  parentWidth,
160
- items,
161
- blockWidth
158
+ blockWidth,
159
+ isGridItem
162
160
  } = this.props;
163
161
 
164
162
  if (!blockWidth) {
165
163
  return null;
166
164
  }
167
165
 
168
- if (gridProperties) {
166
+ if (isGridItem) {
167
+ const {
168
+ numOfColumns,
169
+ tileCount,
170
+ tileIndex
171
+ } = this.props;
169
172
  return (0, _element.createElement)(_gridItem.default, {
170
- numOfColumns: gridProperties.numColumns,
171
- tileCount: items.length,
172
- index: items.indexOf(clientId),
173
- maxWidth: parentWidth
173
+ maxWidth: parentWidth,
174
+ numOfColumns: numOfColumns,
175
+ tileCount: tileCount,
176
+ index: tileIndex
174
177
  }, this.renderContent());
175
178
  }
176
179
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/block-list-item.native.js"],"names":["stretchStyle","flex","BlockListItem","Component","getMarginHorizontal","blockAlignment","marginHorizontal","parentBlockAlignment","hasParents","blockName","parentBlockName","parentWidth","blockWidth","props","isFullWidth","isWideWidth","isWider","isContainerRelated","alignmentHelpers","screenWidth","Math","floor","Dimensions","get","width","isScreenWidthEqual","getContentStyles","readableContentViewStyle","styles","fullAlignment","paddingHorizontal","fullAlignmentPadding","paddingLeft","renderContent","clientId","isReadOnly","shouldShowInsertionPointBefore","shouldShowInsertionPointAfter","contentResizeMode","shouldShowInnerBlockAppender","restProps","maxWidth","render","gridProperties","items","numColumns","length","indexOf","select","rootClientId","isStackedHorizontally","getBlockOrder","getBlockInsertionPoint","isBlockInsertionPointVisible","getSettings","getBlockParents","getBlock","blockEditorStore","blockClientIds","insertionPoint","blockInsertionPointIsVisible","index","readOnly","attributes","name","align","parents","parentBlock"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAQA,MAAMA,YAAY,GAAG;AACpBC,EAAAA,IAAI,EAAE;AADc,CAArB;;AAIO,MAAMC,aAAN,SAA4BC,kBAA5B,CAAsC;AAC5CC,EAAAA,mBAAmB,GAAG;AACrB,UAAM;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AA,6BAFM;AAGNF,IAAAA,UAHM;AAIN3B,IAAAA,UAJM;AAKNH,IAAAA,cAAc,EAAE4D,KALV;AAMN1D,IAAAA,oBANM;AAONE,IAAAA,SAAS,EAAEuD,IAPL;AAQNtD,IAAAA;AARM,GAAP;AAUA,CArDF,CADuB,CAAT,EAwDVR,aAxDU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View, Dimensions } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { ReadableContentView, alignmentHelpers } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockInsertionPoint from './insertion-point';\nimport Grid from './grid-item';\n\nimport styles from './block-list-item.native.scss';\nimport { store as blockEditorStore } from '../../store';\n\nconst stretchStyle = {\n\tflex: 1,\n};\n\nexport class BlockListItem extends Component {\n\tgetMarginHorizontal() {\n\t\tconst {\n\t\t\tblockAlignment,\n\t\t\tmarginHorizontal,\n\t\t\tparentBlockAlignment,\n\t\t\thasParents,\n\t\t\tblockName,\n\t\t\tparentBlockName,\n\t\t\tparentWidth,\n\t\t\tblockWidth,\n\t\t} = this.props;\n\t\tconst {\n\t\t\tisFullWidth,\n\t\t\tisWideWidth,\n\t\t\tisWider,\n\t\t\tisContainerRelated,\n\t\t} = alignmentHelpers;\n\n\t\tif ( isFullWidth( blockAlignment ) ) {\n\t\t\tif ( ! hasParents ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn marginHorizontal;\n\t\t}\n\t\tif ( isWideWidth( blockAlignment ) ) {\n\t\t\treturn marginHorizontal;\n\t\t}\n\n\t\tconst screenWidth = Math.floor( Dimensions.get( 'window' ).width );\n\n\t\tif (\n\t\t\tisFullWidth( parentBlockAlignment ) &&\n\t\t\t! isWider( blockWidth, 'medium' )\n\t\t) {\n\t\t\tif (\n\t\t\t\tisContainerRelated( blockName ) ||\n\t\t\t\tisWider( screenWidth, 'mobile' )\n\t\t\t) {\n\t\t\t\treturn marginHorizontal;\n\t\t\t}\n\t\t\treturn marginHorizontal * 2;\n\t\t}\n\n\t\tif (\n\t\t\tisContainerRelated( parentBlockName ) &&\n\t\t\t! isContainerRelated( blockName )\n\t\t) {\n\t\t\tconst isScreenWidthEqual = parentWidth === screenWidth;\n\t\t\tif ( isScreenWidthEqual || isWider( screenWidth, 'mobile' ) ) {\n\t\t\t\treturn marginHorizontal;\n\t\t\t}\n\t\t}\n\n\t\treturn marginHorizontal;\n\t}\n\n\tgetContentStyles( readableContentViewStyle ) {\n\t\tconst {\n\t\t\tblockAlignment,\n\t\t\tblockName,\n\t\t\thasParents,\n\t\t\tparentBlockName,\n\t\t} = this.props;\n\t\tconst { isFullWidth, isContainerRelated } = alignmentHelpers;\n\n\t\treturn [\n\t\t\treadableContentViewStyle,\n\t\t\tisFullWidth( blockAlignment ) &&\n\t\t\t\t! hasParents && {\n\t\t\t\t\twidth: styles.fullAlignment.width,\n\t\t\t\t},\n\t\t\t! blockAlignment &&\n\t\t\t\thasParents &&\n\t\t\t\t! isContainerRelated( parentBlockName ) &&\n\t\t\t\tisContainerRelated( blockName ) && {\n\t\t\t\t\tpaddingHorizontal: styles.fullAlignmentPadding.paddingLeft,\n\t\t\t\t},\n\t\t];\n\t}\n\n\trenderContent() {\n\t\tconst {\n\t\t\tblockAlignment,\n\t\t\tclientId,\n\t\t\tisReadOnly,\n\t\t\tshouldShowInsertionPointBefore,\n\t\t\tshouldShowInsertionPointAfter,\n\t\t\tcontentResizeMode,\n\t\t\tshouldShowInnerBlockAppender,\n\t\t\tparentWidth,\n\t\t\tmarginHorizontal,\n\t\t\tblockName,\n\t\t\tblockWidth,\n\t\t\t...restProps\n\t\t} = this.props;\n\t\tconst readableContentViewStyle =\n\t\t\tcontentResizeMode === 'stretch' && stretchStyle;\n\t\tconst { isContainerRelated } = alignmentHelpers;\n\n\t\treturn (\n\t\t\t<ReadableContentView\n\t\t\t\talign={ blockAlignment }\n\t\t\t\tstyle={ [\n\t\t\t\t\treadableContentViewStyle,\n\t\t\t\t\tisContainerRelated( blockName ) &&\n\t\t\t\t\t\tparentWidth && {\n\t\t\t\t\t\t\tmaxWidth: parentWidth + 2 * marginHorizontal,\n\t\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t<View\n\t\t\t\t\tstyle={ this.getContentStyles( readableContentViewStyle ) }\n\t\t\t\t\tpointerEvents={ isReadOnly ? 'box-only' : 'auto' }\n\t\t\t\t>\n\t\t\t\t\t{ shouldShowInsertionPointBefore && (\n\t\t\t\t\t\t<BlockInsertionPoint />\n\t\t\t\t\t) }\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tshowTitle={ false }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tparentWidth={ parentWidth }\n\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\tmarginHorizontal={ this.getMarginHorizontal() }\n\t\t\t\t\t\tblockWidth={ blockWidth }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! shouldShowInnerBlockAppender() &&\n\t\t\t\t\t\tshouldShowInsertionPointAfter && (\n\t\t\t\t\t\t\t<BlockInsertionPoint />\n\t\t\t\t\t\t) }\n\t\t\t\t</View>\n\t\t\t</ReadableContentView>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tgridProperties,\n\t\t\tclientId,\n\t\t\tparentWidth,\n\t\t\titems,\n\t\t\tblockWidth,\n\t\t} = this.props;\n\n\t\tif ( ! blockWidth ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( gridProperties ) {\n\t\t\treturn (\n\t\t\t\t<Grid\n\t\t\t\t\tnumOfColumns={ gridProperties.numColumns }\n\t\t\t\t\ttileCount={ items.length }\n\t\t\t\t\tindex={ items.indexOf( clientId ) }\n\t\t\t\t\tmaxWidth={ parentWidth }\n\t\t\t\t>\n\t\t\t\t\t{ this.renderContent() }\n\t\t\t\t</Grid>\n\t\t\t);\n\t\t}\n\t\treturn this.renderContent();\n\t}\n}\n\nexport default compose( [\n\twithSelect(\n\t\t( select, { rootClientId, isStackedHorizontally, clientId } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetBlock,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst blockClientIds = getBlockOrder( rootClientId );\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst blockInsertionPointIsVisible = isBlockInsertionPointVisible();\n\t\t\tconst shouldShowInsertionPointBefore =\n\t\t\t\t! isStackedHorizontally &&\n\t\t\t\tblockInsertionPointIsVisible &&\n\t\t\t\tinsertionPoint.rootClientId === rootClientId &&\n\t\t\t\t// If list is empty, show the insertion point (via the default appender)\n\t\t\t\t( blockClientIds.length === 0 ||\n\t\t\t\t\t// Or if the insertion point is right before the denoted block.\n\t\t\t\t\tblockClientIds[ insertionPoint.index ] === clientId );\n\n\t\t\tconst shouldShowInsertionPointAfter =\n\t\t\t\t! isStackedHorizontally &&\n\t\t\t\tblockInsertionPointIsVisible &&\n\t\t\t\tinsertionPoint.rootClientId === rootClientId &&\n\t\t\t\t// If the insertion point is at the end of the list.\n\t\t\t\tblockClientIds.length === insertionPoint.index &&\n\t\t\t\t// And the denoted block is the last one on the list, show the indicator at the end of the block.\n\t\t\t\tblockClientIds[ insertionPoint.index - 1 ] === clientId;\n\n\t\t\tconst isReadOnly = getSettings().readOnly;\n\n\t\t\tconst { attributes, name } = getBlock( clientId ) || {};\n\t\t\tconst { align } = attributes || {};\n\t\t\tconst parents = getBlockParents( clientId, true );\n\t\t\tconst hasParents = !! parents.length;\n\t\t\tconst parentBlock = hasParents ? getBlock( parents[ 0 ] ) : {};\n\t\t\tconst { align: parentBlockAlignment } =\n\t\t\t\tparentBlock?.attributes || {};\n\t\t\tconst { name: parentBlockName } = parentBlock || {};\n\n\t\t\treturn {\n\t\t\t\tshouldShowInsertionPointBefore,\n\t\t\t\tshouldShowInsertionPointAfter,\n\t\t\t\tisReadOnly,\n\t\t\t\thasParents,\n\t\t\t\tblockAlignment: align,\n\t\t\t\tparentBlockAlignment,\n\t\t\t\tblockName: name,\n\t\t\t\tparentBlockName,\n\t\t\t};\n\t\t}\n\t),\n] )( BlockListItem );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/block-list-item.native.js"],"names":["stretchStyle","flex","BlockListItem","Component","getMarginHorizontal","blockAlignment","marginHorizontal","parentBlockAlignment","hasParents","blockName","parentBlockName","parentWidth","blockWidth","props","isFullWidth","isWideWidth","isWider","isContainerRelated","alignmentHelpers","screenWidth","Math","floor","Dimensions","get","width","isScreenWidthEqual","getContentStyles","readableContentViewStyle","styles","fullAlignment","paddingHorizontal","fullAlignmentPadding","paddingLeft","renderContent","clientId","isReadOnly","shouldShowInsertionPointBefore","shouldShowInsertionPointAfter","contentResizeMode","shouldShowInnerBlockAppender","restProps","maxWidth","render","isGridItem","numOfColumns","tileCount","tileIndex","select","rootClientId","isStackedHorizontally","getBlockOrder","getBlockInsertionPoint","isBlockInsertionPointVisible","getSettings","getBlockParents","getBlock","blockEditorStore","blockClientIds","insertionPoint","blockInsertionPointIsVisible","length","index","readOnly","attributes","name","align","parents","parentBlock"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAQA,MAAMA,YAAY,GAAG;AACpBC,EAAAA,IAAI,EAAE;AADc,CAArB;;AAIO,MAAMC,aAAN,SAA4BC,kBAA5B,CAAsC;AAC5CC,EAAAA,mBAAmB,GAAG;AACrB,UAAM;AACLC,MAAAA,cADK;AAELC,MAAAA,gBAFK;AAGLC,MAAAA,oBAHK;AAIL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,IAAAA,cAAc,EAAE4D,KALV;AAMN1D,IAAAA,oBANM;AAONE,IAAAA,SAAS,EAAEuD,IAPL;AAQNtD,IAAAA;AARM,GAAP;AAUA,CArDF,CADuB,CAAT,EAwDVR,aAxDU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { View, Dimensions } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { ReadableContentView, alignmentHelpers } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockInsertionPoint from './insertion-point';\nimport Grid from './grid-item';\n\nimport styles from './block-list-item.native.scss';\nimport { store as blockEditorStore } from '../../store';\n\nconst stretchStyle = {\n\tflex: 1,\n};\n\nexport class BlockListItem extends Component {\n\tgetMarginHorizontal() {\n\t\tconst {\n\t\t\tblockAlignment,\n\t\t\tmarginHorizontal,\n\t\t\tparentBlockAlignment,\n\t\t\thasParents,\n\t\t\tblockName,\n\t\t\tparentBlockName,\n\t\t\tparentWidth,\n\t\t\tblockWidth,\n\t\t} = this.props;\n\t\tconst {\n\t\t\tisFullWidth,\n\t\t\tisWideWidth,\n\t\t\tisWider,\n\t\t\tisContainerRelated,\n\t\t} = alignmentHelpers;\n\n\t\tif ( isFullWidth( blockAlignment ) ) {\n\t\t\tif ( ! hasParents ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn marginHorizontal;\n\t\t}\n\t\tif ( isWideWidth( blockAlignment ) ) {\n\t\t\treturn marginHorizontal;\n\t\t}\n\n\t\tconst screenWidth = Math.floor( Dimensions.get( 'window' ).width );\n\n\t\tif (\n\t\t\tisFullWidth( parentBlockAlignment ) &&\n\t\t\t! isWider( blockWidth, 'medium' )\n\t\t) {\n\t\t\tif (\n\t\t\t\tisContainerRelated( blockName ) ||\n\t\t\t\tisWider( screenWidth, 'mobile' )\n\t\t\t) {\n\t\t\t\treturn marginHorizontal;\n\t\t\t}\n\t\t\treturn marginHorizontal * 2;\n\t\t}\n\n\t\tif (\n\t\t\tisContainerRelated( parentBlockName ) &&\n\t\t\t! isContainerRelated( blockName )\n\t\t) {\n\t\t\tconst isScreenWidthEqual = parentWidth === screenWidth;\n\t\t\tif ( isScreenWidthEqual || isWider( screenWidth, 'mobile' ) ) {\n\t\t\t\treturn marginHorizontal;\n\t\t\t}\n\t\t}\n\n\t\treturn marginHorizontal;\n\t}\n\n\tgetContentStyles( readableContentViewStyle ) {\n\t\tconst {\n\t\t\tblockAlignment,\n\t\t\tblockName,\n\t\t\thasParents,\n\t\t\tparentBlockName,\n\t\t} = this.props;\n\t\tconst { isFullWidth, isContainerRelated } = alignmentHelpers;\n\n\t\treturn [\n\t\t\treadableContentViewStyle,\n\t\t\tisFullWidth( blockAlignment ) &&\n\t\t\t\t! hasParents && {\n\t\t\t\t\twidth: styles.fullAlignment.width,\n\t\t\t\t},\n\t\t\t! blockAlignment &&\n\t\t\t\thasParents &&\n\t\t\t\t! isContainerRelated( parentBlockName ) &&\n\t\t\t\tisContainerRelated( blockName ) && {\n\t\t\t\t\tpaddingHorizontal: styles.fullAlignmentPadding.paddingLeft,\n\t\t\t\t},\n\t\t];\n\t}\n\n\trenderContent() {\n\t\tconst {\n\t\t\tblockAlignment,\n\t\t\tclientId,\n\t\t\tisReadOnly,\n\t\t\tshouldShowInsertionPointBefore,\n\t\t\tshouldShowInsertionPointAfter,\n\t\t\tcontentResizeMode,\n\t\t\tshouldShowInnerBlockAppender,\n\t\t\tparentWidth,\n\t\t\tmarginHorizontal,\n\t\t\tblockName,\n\t\t\tblockWidth,\n\t\t\t...restProps\n\t\t} = this.props;\n\n\t\tconst readableContentViewStyle =\n\t\t\tcontentResizeMode === 'stretch' && stretchStyle;\n\t\tconst { isContainerRelated } = alignmentHelpers;\n\n\t\treturn (\n\t\t\t<ReadableContentView\n\t\t\t\talign={ blockAlignment }\n\t\t\t\tstyle={ [\n\t\t\t\t\treadableContentViewStyle,\n\t\t\t\t\tisContainerRelated( blockName ) &&\n\t\t\t\t\t\tparentWidth && {\n\t\t\t\t\t\t\tmaxWidth: parentWidth + 2 * marginHorizontal,\n\t\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t<View\n\t\t\t\t\tstyle={ this.getContentStyles( readableContentViewStyle ) }\n\t\t\t\t\tpointerEvents={ isReadOnly ? 'box-only' : 'auto' }\n\t\t\t\t>\n\t\t\t\t\t{ shouldShowInsertionPointBefore && (\n\t\t\t\t\t\t<BlockInsertionPoint />\n\t\t\t\t\t) }\n\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tshowTitle={ false }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tparentWidth={ parentWidth }\n\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\tmarginHorizontal={ this.getMarginHorizontal() }\n\t\t\t\t\t\tblockWidth={ blockWidth }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! shouldShowInnerBlockAppender() &&\n\t\t\t\t\t\tshouldShowInsertionPointAfter && (\n\t\t\t\t\t\t\t<BlockInsertionPoint />\n\t\t\t\t\t\t) }\n\t\t\t\t</View>\n\t\t\t</ReadableContentView>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst { parentWidth, blockWidth, isGridItem } = this.props;\n\n\t\tif ( ! blockWidth ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( isGridItem ) {\n\t\t\tconst { numOfColumns, tileCount, tileIndex } = this.props;\n\t\t\treturn (\n\t\t\t\t<Grid\n\t\t\t\t\tmaxWidth={ parentWidth }\n\t\t\t\t\tnumOfColumns={ numOfColumns }\n\t\t\t\t\ttileCount={ tileCount }\n\t\t\t\t\tindex={ tileIndex }\n\t\t\t\t>\n\t\t\t\t\t{ this.renderContent() }\n\t\t\t\t</Grid>\n\t\t\t);\n\t\t}\n\t\treturn this.renderContent();\n\t}\n}\n\nexport default compose( [\n\twithSelect(\n\t\t( select, { rootClientId, isStackedHorizontally, clientId } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetBlock,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst blockClientIds = getBlockOrder( rootClientId );\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst blockInsertionPointIsVisible = isBlockInsertionPointVisible();\n\t\t\tconst shouldShowInsertionPointBefore =\n\t\t\t\t! isStackedHorizontally &&\n\t\t\t\tblockInsertionPointIsVisible &&\n\t\t\t\tinsertionPoint.rootClientId === rootClientId &&\n\t\t\t\t// If list is empty, show the insertion point (via the default appender)\n\t\t\t\t( blockClientIds.length === 0 ||\n\t\t\t\t\t// Or if the insertion point is right before the denoted block.\n\t\t\t\t\tblockClientIds[ insertionPoint.index ] === clientId );\n\n\t\t\tconst shouldShowInsertionPointAfter =\n\t\t\t\t! isStackedHorizontally &&\n\t\t\t\tblockInsertionPointIsVisible &&\n\t\t\t\tinsertionPoint.rootClientId === rootClientId &&\n\t\t\t\t// If the insertion point is at the end of the list.\n\t\t\t\tblockClientIds.length === insertionPoint.index &&\n\t\t\t\t// And the denoted block is the last one on the list, show the indicator at the end of the block.\n\t\t\t\tblockClientIds[ insertionPoint.index - 1 ] === clientId;\n\n\t\t\tconst isReadOnly = getSettings().readOnly;\n\n\t\t\tconst { attributes, name } = getBlock( clientId ) || {};\n\t\t\tconst { align } = attributes || {};\n\t\t\tconst parents = getBlockParents( clientId, true );\n\t\t\tconst hasParents = !! parents.length;\n\t\t\tconst parentBlock = hasParents ? getBlock( parents[ 0 ] ) : {};\n\t\t\tconst { align: parentBlockAlignment } =\n\t\t\t\tparentBlock?.attributes || {};\n\t\t\tconst { name: parentBlockName } = parentBlock || {};\n\n\t\t\treturn {\n\t\t\t\tshouldShowInsertionPointBefore,\n\t\t\t\tshouldShowInsertionPointAfter,\n\t\t\t\tisReadOnly,\n\t\t\t\thasParents,\n\t\t\t\tblockAlignment: align,\n\t\t\t\tparentBlockAlignment,\n\t\t\t\tblockName: name,\n\t\t\t\tparentBlockName,\n\t\t\t};\n\t\t}\n\t),\n] )( BlockListItem );\n"]}