@wordpress/block-editor 12.0.0 → 12.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 (627) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/build/autocompleters/block.js +13 -5
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-breadcrumb/index.js +6 -3
  6. package/build/components/block-breadcrumb/index.js.map +1 -1
  7. package/build/components/block-controls/slot.js +12 -4
  8. package/build/components/block-controls/slot.js.map +1 -1
  9. package/build/components/block-controls/slot.native.js +10 -1
  10. package/build/components/block-controls/slot.native.js.map +1 -1
  11. package/build/components/block-draggable/index.js +11 -7
  12. package/build/components/block-draggable/index.js.map +1 -1
  13. package/build/components/block-draggable/use-scroll-when-dragging.js +2 -2
  14. package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  15. package/build/components/block-editing-mode/index.js +84 -0
  16. package/build/components/block-editing-mode/index.js.map +1 -0
  17. package/build/components/block-list/block-invalid-warning.native.js +15 -7
  18. package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
  19. package/build/components/block-list/block-list-block-context.js +15 -0
  20. package/build/components/block-list/block-list-block-context.js.map +1 -0
  21. package/build/components/block-list/block-list-item-cell.native.js +15 -2
  22. package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
  23. package/build/components/block-list/block-list-item.native.js +158 -195
  24. package/build/components/block-list/block-list-item.native.js.map +1 -1
  25. package/build/components/block-list/block-outline.native.js +57 -0
  26. package/build/components/block-list/block-outline.native.js.map +1 -0
  27. package/build/components/block-list/block.js +29 -37
  28. package/build/components/block-list/block.js.map +1 -1
  29. package/build/components/block-list/block.native.js +347 -311
  30. package/build/components/block-list/block.native.js.map +1 -1
  31. package/build/components/block-list/index.native.js +260 -357
  32. package/build/components/block-list/index.native.js.map +1 -1
  33. package/build/components/block-list/insertion-point.native.js +4 -2
  34. package/build/components/block-list/insertion-point.native.js.map +1 -1
  35. package/build/components/block-list/use-block-props/index.js +2 -2
  36. package/build/components/block-list/use-block-props/index.js.map +1 -1
  37. package/build/components/block-list/use-in-between-inserter.js +7 -5
  38. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  39. package/build/components/block-list-appender/index.js +15 -1
  40. package/build/components/block-list-appender/index.js.map +1 -1
  41. package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
  42. package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  43. package/build/components/block-settings-menu/block-settings-dropdown.js +8 -10
  44. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  45. package/build/components/block-settings-menu-controls/index.js +15 -4
  46. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  47. package/build/components/block-styles/preview-panel.js +1 -2
  48. package/build/components/block-styles/preview-panel.js.map +1 -1
  49. package/build/components/block-switcher/block-transformations-menu.js +8 -0
  50. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  51. package/build/components/block-switcher/block-variation-transformations.js +125 -0
  52. package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
  53. package/build/components/block-switcher/index.js +34 -12
  54. package/build/components/block-switcher/index.js.map +1 -1
  55. package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
  56. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  57. package/build/components/block-toolbar/index.js +9 -7
  58. package/build/components/block-toolbar/index.js.map +1 -1
  59. package/build/components/block-tools/block-contextual-toolbar.js +22 -65
  60. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  61. package/build/components/block-tools/insertion-point.js +11 -5
  62. package/build/components/block-tools/insertion-point.js.map +1 -1
  63. package/build/components/block-tools/selected-block-popover.js +3 -8
  64. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  65. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  66. package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  67. package/build/components/convert-to-group-buttons/index.js +7 -2
  68. package/build/components/convert-to-group-buttons/index.js.map +1 -1
  69. package/build/components/convert-to-group-buttons/index.native.js +87 -3
  70. package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
  71. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
  72. package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  73. package/build/components/global-styles/advanced-panel.js +86 -0
  74. package/build/components/global-styles/advanced-panel.js.map +1 -0
  75. package/build/components/global-styles/color-panel.js +4 -1
  76. package/build/components/global-styles/color-panel.js.map +1 -1
  77. package/build/components/global-styles/dimensions-panel.js +9 -8
  78. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  79. package/build/components/global-styles/hooks.js +1 -2
  80. package/build/components/global-styles/hooks.js.map +1 -1
  81. package/build/components/global-styles/index.js +24 -0
  82. package/build/components/global-styles/index.js.map +1 -1
  83. package/build/components/global-styles/typography-panel.js +1 -1
  84. package/build/components/global-styles/typography-panel.js.map +1 -1
  85. package/build/components/global-styles/use-global-styles-output.js +27 -4
  86. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  87. package/build/components/global-styles/utils.js +30 -0
  88. package/build/components/global-styles/utils.js.map +1 -1
  89. package/build/components/iframe/index.js +14 -7
  90. package/build/components/iframe/index.js.map +1 -1
  91. package/build/components/image-editor/use-save-image.js +24 -8
  92. package/build/components/image-editor/use-save-image.js.map +1 -1
  93. package/build/components/inner-blocks/index.js +2 -1
  94. package/build/components/inner-blocks/index.js.map +1 -1
  95. package/build/components/inner-blocks/index.native.js +7 -7
  96. package/build/components/inner-blocks/index.native.js.map +1 -1
  97. package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
  98. package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  99. package/build/components/inserter/index.js +3 -7
  100. package/build/components/inserter/index.js.map +1 -1
  101. package/build/components/inserter/quick-inserter.js +2 -4
  102. package/build/components/inserter/quick-inserter.js.map +1 -1
  103. package/build/components/inserter/search-results.js +19 -6
  104. package/build/components/inserter/search-results.js.map +1 -1
  105. package/build/components/inserter-draggable-blocks/index.js +5 -0
  106. package/build/components/inserter-draggable-blocks/index.js.map +1 -1
  107. package/build/components/inspector-controls/fill.js +1 -1
  108. package/build/components/inspector-controls/fill.js.map +1 -1
  109. package/build/components/inspector-controls/fill.native.js +1 -1
  110. package/build/components/inspector-controls/fill.native.js.map +1 -1
  111. package/build/components/inspector-controls/slot.js +3 -6
  112. package/build/components/inspector-controls/slot.js.map +1 -1
  113. package/build/components/inspector-controls/slot.native.js +1 -1
  114. package/build/components/inspector-controls/slot.native.js.map +1 -1
  115. package/build/components/line-height-control/index.js +7 -2
  116. package/build/components/line-height-control/index.js.map +1 -1
  117. package/build/components/link-control/use-internal-input-value.js +9 -8
  118. package/build/components/link-control/use-internal-input-value.js.map +1 -1
  119. package/build/components/list-view/appender.js +6 -1
  120. package/build/components/list-view/appender.js.map +1 -1
  121. package/build/components/list-view/block-contents.js +9 -2
  122. package/build/components/list-view/block-contents.js.map +1 -1
  123. package/build/components/list-view/block-select-button.js +2 -1
  124. package/build/components/list-view/block-select-button.js.map +1 -1
  125. package/build/components/list-view/block.js +25 -29
  126. package/build/components/list-view/block.js.map +1 -1
  127. package/build/components/list-view/branch.js +1 -3
  128. package/build/components/list-view/branch.js.map +1 -1
  129. package/build/components/list-view/index.js +43 -22
  130. package/build/components/list-view/index.js.map +1 -1
  131. package/build/components/list-view/use-list-view-client-ids.js +27 -3
  132. package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
  133. package/build/components/list-view/use-list-view-drop-zone.js +163 -11
  134. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  135. package/build/components/media-placeholder/index.js +68 -7
  136. package/build/components/media-placeholder/index.js.map +1 -1
  137. package/build/components/multi-selection-inspector/index.js +2 -2
  138. package/build/components/multi-selection-inspector/index.js.map +1 -1
  139. package/build/components/preview-options/index.js +6 -1
  140. package/build/components/preview-options/index.js.map +1 -1
  141. package/build/components/publish-date-time-picker/index.js +0 -2
  142. package/build/components/publish-date-time-picker/index.js.map +1 -1
  143. package/build/components/spacing-sizes-control/spacing-input-control.js +1 -1
  144. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  145. package/build/components/url-input/index.js +4 -2
  146. package/build/components/url-input/index.js.map +1 -1
  147. package/build/components/use-block-drop-zone/index.js +25 -15
  148. package/build/components/use-block-drop-zone/index.js.map +1 -1
  149. package/build/components/use-resize-canvas/index.js +8 -1
  150. package/build/components/use-resize-canvas/index.js.map +1 -1
  151. package/build/components/writing-flow/use-arrow-nav.js +13 -7
  152. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  153. package/build/hooks/align.js +4 -8
  154. package/build/hooks/align.js.map +1 -1
  155. package/build/hooks/behaviors.js +115 -0
  156. package/build/hooks/behaviors.js.map +1 -0
  157. package/build/hooks/border.js +1 -1
  158. package/build/hooks/border.js.map +1 -1
  159. package/build/hooks/color.js +1 -1
  160. package/build/hooks/color.js.map +1 -1
  161. package/build/hooks/content-lock-ui.js +8 -12
  162. package/build/hooks/content-lock-ui.js.map +1 -1
  163. package/build/hooks/dimensions.js +0 -30
  164. package/build/hooks/dimensions.js.map +1 -1
  165. package/build/hooks/duotone.js +5 -9
  166. package/build/hooks/duotone.js.map +1 -1
  167. package/build/hooks/index.js +2 -0
  168. package/build/hooks/index.js.map +1 -1
  169. package/build/hooks/index.native.js +8 -0
  170. package/build/hooks/index.native.js.map +1 -1
  171. package/build/hooks/layout.js +10 -11
  172. package/build/hooks/layout.js.map +1 -1
  173. package/build/hooks/position.js +1 -1
  174. package/build/hooks/position.js.map +1 -1
  175. package/build/hooks/style.js +1 -1
  176. package/build/hooks/style.js.map +1 -1
  177. package/build/hooks/use-editor-wrapper-styles.native.js +255 -0
  178. package/build/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  179. package/build/hooks/use-typography-props.js +14 -10
  180. package/build/hooks/use-typography-props.js.map +1 -1
  181. package/build/index.native.js +31 -0
  182. package/build/index.native.js.map +1 -0
  183. package/build/private-apis.js +4 -7
  184. package/build/private-apis.js.map +1 -1
  185. package/build/store/private-actions.js +46 -0
  186. package/build/store/private-actions.js.map +1 -1
  187. package/build/store/private-selectors.js +88 -0
  188. package/build/store/private-selectors.js.map +1 -1
  189. package/build/store/reducer.js +36 -1
  190. package/build/store/reducer.js.map +1 -1
  191. package/build/store/selectors.js +28 -18
  192. package/build/store/selectors.js.map +1 -1
  193. package/build/utils/order-inserter-block-items.js +41 -0
  194. package/build/utils/order-inserter-block-items.js.map +1 -0
  195. package/build/utils/use-should-contextual-toolbar-show.js +16 -12
  196. package/build/utils/use-should-contextual-toolbar-show.js.map +1 -1
  197. package/build-module/autocompleters/block.js +12 -5
  198. package/build-module/autocompleters/block.js.map +1 -1
  199. package/build-module/components/block-breadcrumb/index.js +5 -3
  200. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  201. package/build-module/components/block-controls/slot.js +11 -4
  202. package/build-module/components/block-controls/slot.js.map +1 -1
  203. package/build-module/components/block-controls/slot.native.js +9 -1
  204. package/build-module/components/block-controls/slot.native.js.map +1 -1
  205. package/build-module/components/block-draggable/index.js +10 -6
  206. package/build-module/components/block-draggable/index.js.map +1 -1
  207. package/build-module/components/block-draggable/use-scroll-when-dragging.js +2 -2
  208. package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
  209. package/build-module/components/block-editing-mode/index.js +72 -0
  210. package/build-module/components/block-editing-mode/index.js.map +1 -0
  211. package/build-module/components/block-list/block-invalid-warning.native.js +16 -8
  212. package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
  213. package/build-module/components/block-list/block-list-block-context.js +6 -0
  214. package/build-module/components/block-list/block-list-block-context.js.map +1 -0
  215. package/build-module/components/block-list/block-list-item-cell.native.js +13 -2
  216. package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
  217. package/build-module/components/block-list/block-list-item.native.js +160 -190
  218. package/build-module/components/block-list/block-list-item.native.js.map +1 -1
  219. package/build-module/components/block-list/block-outline.native.js +44 -0
  220. package/build-module/components/block-list/block-outline.native.js.map +1 -0
  221. package/build-module/components/block-list/block.js +26 -34
  222. package/build-module/components/block-list/block.js.map +1 -1
  223. package/build-module/components/block-list/block.native.js +345 -310
  224. package/build-module/components/block-list/block.native.js.map +1 -1
  225. package/build-module/components/block-list/index.native.js +263 -355
  226. package/build-module/components/block-list/index.native.js.map +1 -1
  227. package/build-module/components/block-list/insertion-point.native.js +4 -2
  228. package/build-module/components/block-list/insertion-point.native.js.map +1 -1
  229. package/build-module/components/block-list/use-block-props/index.js +1 -1
  230. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  231. package/build-module/components/block-list/use-in-between-inserter.js +6 -5
  232. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  233. package/build-module/components/block-list-appender/index.js +15 -1
  234. package/build-module/components/block-list-appender/index.js.map +1 -1
  235. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
  236. package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
  237. package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -9
  238. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  239. package/build-module/components/block-settings-menu-controls/index.js +13 -5
  240. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  241. package/build-module/components/block-styles/preview-panel.js +1 -2
  242. package/build-module/components/block-styles/preview-panel.js.map +1 -1
  243. package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
  244. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  245. package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
  246. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
  247. package/build-module/components/block-switcher/index.js +33 -12
  248. package/build-module/components/block-switcher/index.js.map +1 -1
  249. package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
  250. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  251. package/build-module/components/block-toolbar/index.js +8 -7
  252. package/build-module/components/block-toolbar/index.js.map +1 -1
  253. package/build-module/components/block-tools/block-contextual-toolbar.js +22 -65
  254. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  255. package/build-module/components/block-tools/insertion-point.js +11 -5
  256. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  257. package/build-module/components/block-tools/selected-block-popover.js +3 -7
  258. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  259. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
  260. package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
  261. package/build-module/components/convert-to-group-buttons/index.js +7 -2
  262. package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
  263. package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
  264. package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
  265. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
  266. package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
  267. package/build-module/components/global-styles/advanced-panel.js +74 -0
  268. package/build-module/components/global-styles/advanced-panel.js.map +1 -0
  269. package/build-module/components/global-styles/color-panel.js +5 -2
  270. package/build-module/components/global-styles/color-panel.js.map +1 -1
  271. package/build-module/components/global-styles/dimensions-panel.js +9 -8
  272. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  273. package/build-module/components/global-styles/hooks.js +1 -2
  274. package/build-module/components/global-styles/hooks.js.map +1 -1
  275. package/build-module/components/global-styles/index.js +3 -1
  276. package/build-module/components/global-styles/index.js.map +1 -1
  277. package/build-module/components/global-styles/typography-panel.js +1 -1
  278. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  279. package/build-module/components/global-styles/use-global-styles-output.js +25 -4
  280. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  281. package/build-module/components/global-styles/utils.js +25 -0
  282. package/build-module/components/global-styles/utils.js.map +1 -1
  283. package/build-module/components/iframe/index.js +15 -8
  284. package/build-module/components/iframe/index.js.map +1 -1
  285. package/build-module/components/image-editor/use-save-image.js +24 -8
  286. package/build-module/components/image-editor/use-save-image.js.map +1 -1
  287. package/build-module/components/inner-blocks/index.js +2 -1
  288. package/build-module/components/inner-blocks/index.js.map +1 -1
  289. package/build-module/components/inner-blocks/index.native.js +7 -6
  290. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  291. package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
  292. package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
  293. package/build-module/components/inserter/index.js +3 -7
  294. package/build-module/components/inserter/index.js.map +1 -1
  295. package/build-module/components/inserter/quick-inserter.js +2 -4
  296. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  297. package/build-module/components/inserter/search-results.js +16 -6
  298. package/build-module/components/inserter/search-results.js.map +1 -1
  299. package/build-module/components/inserter-draggable-blocks/index.js +4 -0
  300. package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
  301. package/build-module/components/inspector-controls/fill.js +1 -1
  302. package/build-module/components/inspector-controls/fill.js.map +1 -1
  303. package/build-module/components/inspector-controls/fill.native.js +1 -1
  304. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  305. package/build-module/components/inspector-controls/slot.js +4 -7
  306. package/build-module/components/inspector-controls/slot.js.map +1 -1
  307. package/build-module/components/inspector-controls/slot.native.js +1 -1
  308. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  309. package/build-module/components/line-height-control/index.js +7 -2
  310. package/build-module/components/line-height-control/index.js.map +1 -1
  311. package/build-module/components/link-control/use-internal-input-value.js +9 -8
  312. package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
  313. package/build-module/components/list-view/appender.js +6 -2
  314. package/build-module/components/list-view/appender.js.map +1 -1
  315. package/build-module/components/list-view/block-contents.js +9 -3
  316. package/build-module/components/list-view/block-contents.js.map +1 -1
  317. package/build-module/components/list-view/block-select-button.js +2 -1
  318. package/build-module/components/list-view/block-select-button.js.map +1 -1
  319. package/build-module/components/list-view/block.js +24 -29
  320. package/build-module/components/list-view/block.js.map +1 -1
  321. package/build-module/components/list-view/branch.js +1 -3
  322. package/build-module/components/list-view/branch.js.map +1 -1
  323. package/build-module/components/list-view/index.js +44 -23
  324. package/build-module/components/list-view/index.js.map +1 -1
  325. package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
  326. package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
  327. package/build-module/components/list-view/use-list-view-drop-zone.js +160 -11
  328. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  329. package/build-module/components/media-placeholder/index.js +66 -7
  330. package/build-module/components/media-placeholder/index.js.map +1 -1
  331. package/build-module/components/multi-selection-inspector/index.js +2 -2
  332. package/build-module/components/multi-selection-inspector/index.js.map +1 -1
  333. package/build-module/components/preview-options/index.js +7 -2
  334. package/build-module/components/preview-options/index.js.map +1 -1
  335. package/build-module/components/publish-date-time-picker/index.js +0 -2
  336. package/build-module/components/publish-date-time-picker/index.js.map +1 -1
  337. package/build-module/components/spacing-sizes-control/spacing-input-control.js +1 -1
  338. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
  339. package/build-module/components/url-input/index.js +4 -2
  340. package/build-module/components/url-input/index.js.map +1 -1
  341. package/build-module/components/use-block-drop-zone/index.js +25 -16
  342. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  343. package/build-module/components/use-resize-canvas/index.js +8 -1
  344. package/build-module/components/use-resize-canvas/index.js.map +1 -1
  345. package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
  346. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  347. package/build-module/hooks/align.js +4 -7
  348. package/build-module/hooks/align.js.map +1 -1
  349. package/build-module/hooks/behaviors.js +97 -0
  350. package/build-module/hooks/behaviors.js.map +1 -0
  351. package/build-module/hooks/border.js +1 -1
  352. package/build-module/hooks/border.js.map +1 -1
  353. package/build-module/hooks/color.js +1 -1
  354. package/build-module/hooks/color.js.map +1 -1
  355. package/build-module/hooks/content-lock-ui.js +8 -11
  356. package/build-module/hooks/content-lock-ui.js.map +1 -1
  357. package/build-module/hooks/dimensions.js +0 -28
  358. package/build-module/hooks/dimensions.js.map +1 -1
  359. package/build-module/hooks/duotone.js +4 -7
  360. package/build-module/hooks/duotone.js.map +1 -1
  361. package/build-module/hooks/index.js +1 -0
  362. package/build-module/hooks/index.js.map +1 -1
  363. package/build-module/hooks/index.native.js +1 -0
  364. package/build-module/hooks/index.native.js.map +1 -1
  365. package/build-module/hooks/layout.js +9 -11
  366. package/build-module/hooks/layout.js.map +1 -1
  367. package/build-module/hooks/position.js +1 -1
  368. package/build-module/hooks/position.js.map +1 -1
  369. package/build-module/hooks/style.js +1 -1
  370. package/build-module/hooks/style.js.map +1 -1
  371. package/build-module/hooks/use-editor-wrapper-styles.native.js +242 -0
  372. package/build-module/hooks/use-editor-wrapper-styles.native.js.map +1 -0
  373. package/build-module/hooks/use-typography-props.js +14 -10
  374. package/build-module/hooks/use-typography-props.js.map +1 -1
  375. package/build-module/index.native.js +6 -0
  376. package/build-module/index.native.js.map +1 -0
  377. package/build-module/private-apis.js +3 -5
  378. package/build-module/private-apis.js.map +1 -1
  379. package/build-module/store/private-actions.js +42 -0
  380. package/build-module/store/private-actions.js.map +1 -1
  381. package/build-module/store/private-selectors.js +79 -0
  382. package/build-module/store/private-selectors.js.map +1 -1
  383. package/build-module/store/reducer.js +34 -1
  384. package/build-module/store/reducer.js.map +1 -1
  385. package/build-module/store/selectors.js +26 -17
  386. package/build-module/store/selectors.js.map +1 -1
  387. package/build-module/utils/order-inserter-block-items.js +32 -0
  388. package/build-module/utils/order-inserter-block-items.js.map +1 -0
  389. package/build-module/utils/use-should-contextual-toolbar-show.js +16 -12
  390. package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -1
  391. package/build-style/content-rtl.css +32 -14
  392. package/build-style/content.css +32 -14
  393. package/build-style/default-editor-styles-rtl.css +1 -1
  394. package/build-style/default-editor-styles.css +1 -1
  395. package/build-style/style-rtl.css +56 -77
  396. package/build-style/style.css +57 -77
  397. package/package.json +32 -31
  398. package/src/autocompleters/block.js +15 -7
  399. package/src/components/block-breadcrumb/index.js +11 -3
  400. package/src/components/block-breadcrumb/style.scss +2 -1
  401. package/src/components/block-controls/slot.js +8 -4
  402. package/src/components/block-controls/slot.native.js +6 -1
  403. package/src/components/block-draggable/index.js +10 -6
  404. package/src/components/block-draggable/use-scroll-when-dragging.js +8 -2
  405. package/src/components/block-editing-mode/index.js +71 -0
  406. package/src/components/block-list/block-invalid-warning.native.js +17 -9
  407. package/src/components/block-list/block-list-block-context.js +6 -0
  408. package/src/components/block-list/block-list-item-cell.native.js +10 -1
  409. package/src/components/block-list/block-list-item.native.js +180 -208
  410. package/src/components/block-list/block-outline.native.js +58 -0
  411. package/src/components/block-list/block.js +38 -56
  412. package/src/components/block-list/block.native.js +531 -501
  413. package/src/components/block-list/content.scss +5 -6
  414. package/src/components/block-list/index.native.js +324 -382
  415. package/src/components/block-list/insertion-point.native.js +2 -2
  416. package/src/components/block-list/test/block-invalid-warning.native.js +48 -0
  417. package/src/components/block-list/test/index.native.js +205 -0
  418. package/src/components/block-list/use-block-props/index.js +1 -1
  419. package/src/components/block-list/use-in-between-inserter.js +7 -3
  420. package/src/components/block-list-appender/index.js +22 -4
  421. package/src/components/block-mobile-toolbar/block-actions-menu.native.js +26 -1
  422. package/src/components/block-mover/style.scss +1 -0
  423. package/src/components/block-pattern-setup/style.scss +1 -4
  424. package/src/components/block-patterns-list/style.scss +1 -4
  425. package/src/components/block-settings-menu/block-settings-dropdown.js +10 -17
  426. package/src/components/block-settings-menu-controls/index.js +24 -4
  427. package/src/components/block-styles/preview-panel.js +1 -3
  428. package/src/components/block-styles/style.scss +4 -4
  429. package/src/components/block-switcher/block-transformations-menu.js +12 -0
  430. package/src/components/block-switcher/block-variation-transformations.js +115 -0
  431. package/src/components/block-switcher/index.js +38 -5
  432. package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
  433. package/src/components/block-switcher/style.scss +6 -5
  434. package/src/components/block-toolbar/index.js +10 -11
  435. package/src/components/block-tools/block-contextual-toolbar.js +32 -67
  436. package/src/components/block-tools/insertion-point.js +23 -9
  437. package/src/components/block-tools/selected-block-popover.js +3 -5
  438. package/src/components/block-tools/style.scss +8 -0
  439. package/src/components/button-block-appender/content.scss +22 -0
  440. package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
  441. package/src/components/convert-to-group-buttons/index.js +9 -2
  442. package/src/components/convert-to-group-buttons/index.native.js +79 -1
  443. package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
  444. package/src/components/global-styles/advanced-panel.js +82 -0
  445. package/src/components/global-styles/color-panel.js +6 -1
  446. package/src/components/global-styles/dimensions-panel.js +9 -8
  447. package/src/components/global-styles/hooks.js +1 -5
  448. package/src/components/global-styles/index.js +6 -1
  449. package/src/components/global-styles/style.scss +17 -0
  450. package/src/components/global-styles/test/utils.js +57 -1
  451. package/src/components/global-styles/typography-panel.js +1 -1
  452. package/src/components/global-styles/use-global-styles-output.js +21 -3
  453. package/src/components/global-styles/utils.js +27 -0
  454. package/src/components/iframe/index.js +22 -12
  455. package/src/components/image-editor/use-save-image.js +20 -9
  456. package/src/components/inner-blocks/README.md +5 -0
  457. package/src/components/inner-blocks/index.js +2 -0
  458. package/src/components/inner-blocks/index.native.js +16 -6
  459. package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
  460. package/src/components/inserter/index.js +1 -9
  461. package/src/components/inserter/quick-inserter.js +0 -2
  462. package/src/components/inserter/search-results.js +32 -6
  463. package/src/components/inserter-draggable-blocks/index.js +4 -0
  464. package/src/components/inspector-controls/fill.js +1 -1
  465. package/src/components/inspector-controls/fill.native.js +1 -1
  466. package/src/components/inspector-controls/slot.js +4 -9
  467. package/src/components/inspector-controls/slot.native.js +1 -1
  468. package/src/components/line-height-control/index.js +7 -2
  469. package/src/components/line-height-control/stories/index.js +1 -1
  470. package/src/components/link-control/test/index.js +42 -0
  471. package/src/components/link-control/use-internal-input-value.js +8 -7
  472. package/src/components/list-view/appender.js +3 -2
  473. package/src/components/list-view/block-contents.js +32 -20
  474. package/src/components/list-view/block-select-button.js +5 -1
  475. package/src/components/list-view/block.js +34 -37
  476. package/src/components/list-view/branch.js +1 -7
  477. package/src/components/list-view/index.js +42 -17
  478. package/src/components/list-view/style.scss +7 -7
  479. package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
  480. package/src/components/list-view/use-list-view-client-ids.js +21 -4
  481. package/src/components/list-view/use-list-view-drop-zone.js +194 -11
  482. package/src/components/media-placeholder/index.js +74 -1
  483. package/src/components/multi-selection-inspector/index.js +2 -2
  484. package/src/components/preview-options/index.js +9 -2
  485. package/src/components/publish-date-time-picker/index.js +0 -2
  486. package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
  487. package/src/components/url-input/README.md +6 -0
  488. package/src/components/url-input/index.js +2 -2
  489. package/src/components/use-block-drop-zone/index.js +31 -17
  490. package/src/components/use-resize-canvas/index.js +9 -1
  491. package/src/components/writing-flow/test/index.js +15 -0
  492. package/src/components/writing-flow/use-arrow-nav.js +17 -4
  493. package/src/hooks/align.js +5 -12
  494. package/src/hooks/behaviors.js +104 -0
  495. package/src/hooks/border.js +2 -1
  496. package/src/hooks/color.js +2 -1
  497. package/src/hooks/content-lock-ui.js +3 -15
  498. package/src/hooks/dimensions.js +0 -40
  499. package/src/hooks/duotone.js +4 -11
  500. package/src/hooks/index.js +1 -0
  501. package/src/hooks/index.native.js +1 -0
  502. package/src/hooks/layout.js +14 -20
  503. package/src/hooks/position.js +2 -1
  504. package/src/hooks/style.js +2 -1
  505. package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
  506. package/src/hooks/test/use-typography-props.js +47 -2
  507. package/src/hooks/use-editor-wrapper-styles.native.js +250 -0
  508. package/src/hooks/use-editor-wrapper-styles.native.scss +11 -0
  509. package/src/hooks/use-typography-props.js +10 -11
  510. package/src/index.native.js +6 -0
  511. package/src/private-apis.js +2 -4
  512. package/src/store/private-actions.js +39 -0
  513. package/src/store/private-selectors.js +95 -0
  514. package/src/store/reducer.js +27 -0
  515. package/src/store/selectors.js +25 -15
  516. package/src/store/test/private-actions.js +32 -1
  517. package/src/store/test/private-selectors.js +158 -0
  518. package/src/store/test/reducer.js +48 -0
  519. package/src/style.scss +0 -3
  520. package/src/utils/order-inserter-block-items.js +26 -0
  521. package/src/utils/use-should-contextual-toolbar-show.js +19 -9
  522. package/tsconfig.json +1 -0
  523. package/tsconfig.tsbuildinfo +1 -1
  524. package/build/components/block-list/block-list-compact.native.js +0 -75
  525. package/build/components/block-list/block-list-compact.native.js.map +0 -1
  526. package/build/components/off-canvas-editor/appender.js +0 -125
  527. package/build/components/off-canvas-editor/appender.js.map +0 -1
  528. package/build/components/off-canvas-editor/block-contents.js +0 -141
  529. package/build/components/off-canvas-editor/block-contents.js.map +0 -1
  530. package/build/components/off-canvas-editor/block-select-button.js +0 -126
  531. package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
  532. package/build/components/off-canvas-editor/block.js +0 -297
  533. package/build/components/off-canvas-editor/block.js.map +0 -1
  534. package/build/components/off-canvas-editor/branch.js +0 -197
  535. package/build/components/off-canvas-editor/branch.js.map +0 -1
  536. package/build/components/off-canvas-editor/context.js +0 -19
  537. package/build/components/off-canvas-editor/context.js.map +0 -1
  538. package/build/components/off-canvas-editor/drop-indicator.js +0 -118
  539. package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
  540. package/build/components/off-canvas-editor/expander.js +0 -41
  541. package/build/components/off-canvas-editor/expander.js.map +0 -1
  542. package/build/components/off-canvas-editor/index.js +0 -236
  543. package/build/components/off-canvas-editor/index.js.map +0 -1
  544. package/build/components/off-canvas-editor/leaf-more-menu.js +0 -146
  545. package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  546. package/build/components/off-canvas-editor/leaf.js +0 -60
  547. package/build/components/off-canvas-editor/leaf.js.map +0 -1
  548. package/build/components/off-canvas-editor/link-ui.js +0 -186
  549. package/build/components/off-canvas-editor/link-ui.js.map +0 -1
  550. package/build/components/off-canvas-editor/update-attributes.js +0 -108
  551. package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
  552. package/build/components/off-canvas-editor/use-block-selection.js +0 -139
  553. package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
  554. package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
  555. package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  556. package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
  557. package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  558. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
  559. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  560. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
  561. package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  562. package/build/components/off-canvas-editor/utils.js +0 -60
  563. package/build/components/off-canvas-editor/utils.js.map +0 -1
  564. package/build-module/components/block-list/block-list-compact.native.js +0 -60
  565. package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
  566. package/build-module/components/off-canvas-editor/appender.js +0 -108
  567. package/build-module/components/off-canvas-editor/appender.js.map +0 -1
  568. package/build-module/components/off-canvas-editor/block-contents.js +0 -121
  569. package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
  570. package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
  571. package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
  572. package/build-module/components/off-canvas-editor/block.js +0 -273
  573. package/build-module/components/off-canvas-editor/block.js.map +0 -1
  574. package/build-module/components/off-canvas-editor/branch.js +0 -179
  575. package/build-module/components/off-canvas-editor/branch.js.map +0 -1
  576. package/build-module/components/off-canvas-editor/context.js +0 -7
  577. package/build-module/components/off-canvas-editor/context.js.map +0 -1
  578. package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
  579. package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
  580. package/build-module/components/off-canvas-editor/expander.js +0 -32
  581. package/build-module/components/off-canvas-editor/expander.js.map +0 -1
  582. package/build-module/components/off-canvas-editor/index.js +0 -213
  583. package/build-module/components/off-canvas-editor/index.js.map +0 -1
  584. package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -128
  585. package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
  586. package/build-module/components/off-canvas-editor/leaf.js +0 -45
  587. package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
  588. package/build-module/components/off-canvas-editor/link-ui.js +0 -166
  589. package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
  590. package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
  591. package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
  592. package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
  593. package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
  594. package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
  595. package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
  596. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
  597. package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
  598. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
  599. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
  600. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
  601. package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
  602. package/build-module/components/off-canvas-editor/utils.js +0 -44
  603. package/build-module/components/off-canvas-editor/utils.js.map +0 -1
  604. package/src/components/block-list/block-list-compact.native.js +0 -63
  605. package/src/components/off-canvas-editor/README.md +0 -5
  606. package/src/components/off-canvas-editor/appender.js +0 -124
  607. package/src/components/off-canvas-editor/block-contents.js +0 -156
  608. package/src/components/off-canvas-editor/block-select-button.js +0 -128
  609. package/src/components/off-canvas-editor/block.js +0 -347
  610. package/src/components/off-canvas-editor/branch.js +0 -238
  611. package/src/components/off-canvas-editor/context.js +0 -8
  612. package/src/components/off-canvas-editor/drop-indicator.js +0 -126
  613. package/src/components/off-canvas-editor/expander.js +0 -26
  614. package/src/components/off-canvas-editor/index.js +0 -271
  615. package/src/components/off-canvas-editor/leaf-more-menu.js +0 -157
  616. package/src/components/off-canvas-editor/leaf.js +0 -52
  617. package/src/components/off-canvas-editor/link-ui.js +0 -167
  618. package/src/components/off-canvas-editor/style.scss +0 -34
  619. package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
  620. package/src/components/off-canvas-editor/test/utils.js +0 -50
  621. package/src/components/off-canvas-editor/update-attributes.js +0 -99
  622. package/src/components/off-canvas-editor/use-block-selection.js +0 -169
  623. package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
  624. package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
  625. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
  626. package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
  627. package/src/components/off-canvas-editor/utils.js +0 -58
@@ -0,0 +1,282 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { renderHook } from '@testing-library/react-native';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
10
+ import { registerCoreBlocks } from '@wordpress/block-library';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { useEditorWrapperStyles } from '../use-editor-wrapper-styles';
16
+
17
+ jest.mock( '../use-editor-wrapper-styles.scss', () => ( {
18
+ 'use-editor-wrapper-styles': {
19
+ width: '100%',
20
+ maxWidth: 580,
21
+ alignSelf: 'center',
22
+ },
23
+ 'use-editor-wrapper-styles--reversed': {
24
+ flexDirection: 'column-reverse',
25
+ width: '100%',
26
+ maxWidth: 580,
27
+ },
28
+ } ) );
29
+
30
+ const defaultCanvasStyles = {
31
+ width: '100%',
32
+ maxWidth: 580,
33
+ alignSelf: 'center',
34
+ };
35
+
36
+ describe( 'useEditorWrapperStyles', () => {
37
+ beforeAll( () => {
38
+ // Register all core blocks
39
+ registerCoreBlocks();
40
+ } );
41
+
42
+ afterAll( () => {
43
+ // Clean up registered blocks
44
+ getBlockTypes().forEach( ( block ) => {
45
+ unregisterBlockType( block.name );
46
+ } );
47
+ } );
48
+
49
+ it( 'should return the default wrapper styles when no props are set', () => {
50
+ // Arrange
51
+ jest.spyOn(
52
+ require( 'react-native' ),
53
+ 'useWindowDimensions'
54
+ ).mockReturnValue( { width: 900, height: 600 } );
55
+
56
+ // Act
57
+ const { result } = renderHook( () => useEditorWrapperStyles() );
58
+
59
+ // Assert
60
+ expect( result.current[ 0 ] ).toEqual( [
61
+ expect.objectContaining( defaultCanvasStyles ),
62
+ {},
63
+ ] );
64
+ } );
65
+
66
+ it( 'should return the correct wrapper styles and margin for wide (medium) alignment', () => {
67
+ // Arrange
68
+ jest.spyOn(
69
+ require( 'react-native' ),
70
+ 'useWindowDimensions'
71
+ ).mockReturnValue( { width: 900, height: 600 } );
72
+
73
+ // Act
74
+ const { result } = renderHook( () =>
75
+ useEditorWrapperStyles( {
76
+ align: 'wide',
77
+ blockName: 'core/group',
78
+ blockWidth: 800,
79
+ marginHorizontal: 16,
80
+ } )
81
+ );
82
+
83
+ // Assert
84
+ expect( result.current[ 0 ] ).toEqual( [
85
+ expect.objectContaining( defaultCanvasStyles ),
86
+ expect.objectContaining( {
87
+ maxWidth: 770,
88
+ } ),
89
+ ] );
90
+ expect( result.current[ 1 ] ).toEqual( 16 );
91
+ } );
92
+
93
+ it( 'should return the correct wrapper styles and margin for wide (landscape) alignment', () => {
94
+ // Arrange
95
+ jest.spyOn(
96
+ require( 'react-native' ),
97
+ 'useWindowDimensions'
98
+ ).mockReturnValue( { width: 800, height: 600 } );
99
+
100
+ // Act
101
+ const { result } = renderHook( () =>
102
+ useEditorWrapperStyles( {
103
+ align: 'wide',
104
+ blockName: 'core/group',
105
+ blockWidth: 700,
106
+ marginHorizontal: 16,
107
+ } )
108
+ );
109
+
110
+ // Assert
111
+ expect( result.current[ 0 ] ).toEqual( [
112
+ expect.objectContaining( defaultCanvasStyles ),
113
+ expect.objectContaining( {
114
+ maxWidth: 662,
115
+ } ),
116
+ ] );
117
+ expect( result.current[ 1 ] ).toEqual( 16 );
118
+ } );
119
+
120
+ it( 'should return the correct wrapper styles and margin for wide alignment', () => {
121
+ // Arrange
122
+ jest.spyOn(
123
+ require( 'react-native' ),
124
+ 'useWindowDimensions'
125
+ ).mockReturnValue( { width: 1194, height: 834 } );
126
+
127
+ // Act
128
+ const { result } = renderHook( () =>
129
+ useEditorWrapperStyles( {
130
+ align: 'wide',
131
+ blockName: 'core/group',
132
+ blockWidth: 800,
133
+ marginHorizontal: 16,
134
+ } )
135
+ );
136
+
137
+ // Assert
138
+ expect( result.current[ 0 ] ).toEqual( [
139
+ expect.objectContaining( defaultCanvasStyles ),
140
+ expect.objectContaining( {
141
+ maxWidth: 1054,
142
+ } ),
143
+ ] );
144
+ expect( result.current[ 1 ] ).toEqual( 16 );
145
+ } );
146
+
147
+ it( 'should return the correct wrapper styles and margin for full alignment', () => {
148
+ // Arrange
149
+ jest.spyOn(
150
+ require( 'react-native' ),
151
+ 'useWindowDimensions'
152
+ ).mockReturnValue( { width: 800, height: 600 } );
153
+
154
+ // Act
155
+ const { result } = renderHook( () =>
156
+ useEditorWrapperStyles( {
157
+ align: 'full',
158
+ blockName: 'core/cover',
159
+ blockWidth: 700,
160
+ marginHorizontal: 16,
161
+ } )
162
+ );
163
+
164
+ // Assert
165
+ expect( result.current[ 0 ] ).toEqual( [
166
+ expect.objectContaining( defaultCanvasStyles ),
167
+ expect.objectContaining( {
168
+ maxWidth: '100%',
169
+ } ),
170
+ ] );
171
+ expect( result.current[ 1 ] ).toEqual( 0 );
172
+ } );
173
+
174
+ it( 'should return the correct wrapper styles and margin for left alignment', () => {
175
+ // Arrange
176
+ jest.spyOn(
177
+ require( 'react-native' ),
178
+ 'useWindowDimensions'
179
+ ).mockReturnValue( { width: 800, height: 600 } );
180
+
181
+ // Act
182
+ const { result } = renderHook( () =>
183
+ useEditorWrapperStyles( { align: 'left', marginHorizontal: 16 } )
184
+ );
185
+
186
+ // Assert
187
+ expect( result.current[ 0 ] ).toEqual( [
188
+ expect.objectContaining( defaultCanvasStyles ),
189
+ {},
190
+ ] );
191
+ expect( result.current[ 1 ] ).toEqual( 16 );
192
+ } );
193
+
194
+ it( 'should return the correct wrapper styles and margin for center alignment', () => {
195
+ // Arrange
196
+ jest.spyOn(
197
+ require( 'react-native' ),
198
+ 'useWindowDimensions'
199
+ ).mockReturnValue( { width: 640, height: 960 } );
200
+
201
+ // Act
202
+ const { result } = renderHook( () =>
203
+ useEditorWrapperStyles( { align: 'center', marginHorizontal: 16 } )
204
+ );
205
+
206
+ // Assert
207
+ expect( result.current[ 0 ] ).toEqual( [
208
+ expect.objectContaining( defaultCanvasStyles ),
209
+ {},
210
+ ] );
211
+ expect( result.current[ 1 ] ).toEqual( 16 );
212
+ } );
213
+
214
+ it( 'should return the correct wrapper styles and margin for right alignment', () => {
215
+ // Arrange
216
+ jest.spyOn(
217
+ require( 'react-native' ),
218
+ 'useWindowDimensions'
219
+ ).mockReturnValue( { width: 960, height: 640 } );
220
+
221
+ // Act
222
+ const { result } = renderHook( () =>
223
+ useEditorWrapperStyles( { align: 'right', marginHorizontal: 16 } )
224
+ );
225
+
226
+ // Assert
227
+ expect( result.current[ 0 ] ).toEqual( [
228
+ expect.objectContaining( defaultCanvasStyles ),
229
+ {},
230
+ ] );
231
+ expect( result.current[ 1 ] ).toEqual( 16 );
232
+ } );
233
+
234
+ it( 'should return the correct wrapper styles and margin when reversed is true', () => {
235
+ // Arrange
236
+ jest.spyOn(
237
+ require( 'react-native' ),
238
+ 'useWindowDimensions'
239
+ ).mockReturnValue( { width: 800, height: 600 } );
240
+
241
+ // Act
242
+ const { result } = renderHook( () =>
243
+ useEditorWrapperStyles( { reversed: true, marginHorizontal: 16 } )
244
+ );
245
+
246
+ // Assert
247
+ expect( result.current[ 0 ] ).toEqual( [
248
+ expect.objectContaining( {
249
+ flexDirection: 'column-reverse',
250
+ width: '100%',
251
+ maxWidth: 580,
252
+ } ),
253
+ {},
254
+ ] );
255
+ expect( result.current[ 1 ] ).toEqual( 16 );
256
+ } );
257
+
258
+ it( 'should return the correct wrapper styles and margin when contentResizeMode is set', () => {
259
+ // Arrange
260
+ jest.spyOn(
261
+ require( 'react-native' ),
262
+ 'useWindowDimensions'
263
+ ).mockReturnValue( { width: 800, height: 600 } );
264
+
265
+ // Act
266
+ const { result } = renderHook( () =>
267
+ useEditorWrapperStyles( {
268
+ contentResizeMode: 'stretch',
269
+ marginHorizontal: 16,
270
+ } )
271
+ );
272
+
273
+ // Assert
274
+ expect( result.current[ 0 ] ).toEqual( [
275
+ expect.objectContaining( {
276
+ flex: 1,
277
+ } ),
278
+ {},
279
+ ] );
280
+ expect( result.current[ 1 ] ).toEqual( 16 );
281
+ } );
282
+ } );
@@ -39,7 +39,15 @@ describe( 'getTypographyClassesAndStyles', () => {
39
39
  },
40
40
  },
41
41
  };
42
- expect( getTypographyClassesAndStyles( attributes, true ) ).toEqual( {
42
+ expect(
43
+ getTypographyClassesAndStyles( attributes, {
44
+ typography: {
45
+ fluid: {
46
+ minFontSize: '1rem',
47
+ },
48
+ },
49
+ } )
50
+ ).toEqual( {
43
51
  className: 'has-tofu-font-family',
44
52
  style: {
45
53
  letterSpacing: '22px',
@@ -63,7 +71,11 @@ describe( 'getTypographyClassesAndStyles', () => {
63
71
  };
64
72
  expect(
65
73
  getTypographyClassesAndStyles( attributes, {
66
- minFontSize: '1rem',
74
+ typography: {
75
+ fluid: {
76
+ minFontSize: '1rem',
77
+ },
78
+ },
67
79
  } )
68
80
  ).toEqual( {
69
81
  className: 'has-tofu-font-family',
@@ -75,4 +87,37 @@ describe( 'getTypographyClassesAndStyles', () => {
75
87
  },
76
88
  } );
77
89
  } );
90
+
91
+ it( 'should use layout.wideSize for the maximum viewport value', () => {
92
+ const attributes = {
93
+ fontFamily: 'tofu',
94
+ style: {
95
+ typography: {
96
+ textDecoration: 'underline',
97
+ fontSize: '2rem',
98
+ textTransform: 'uppercase',
99
+ },
100
+ },
101
+ };
102
+ expect(
103
+ getTypographyClassesAndStyles( attributes, {
104
+ typography: {
105
+ fluid: {
106
+ minFontSize: '1rem',
107
+ },
108
+ },
109
+ layout: {
110
+ wideSize: '1000px',
111
+ },
112
+ } )
113
+ ).toEqual( {
114
+ className: 'has-tofu-font-family',
115
+ style: {
116
+ textDecoration: 'underline',
117
+ fontSize:
118
+ 'clamp(1.25rem, 1.25rem + ((1vw - 0.2rem) * 1.765), 2rem)',
119
+ textTransform: 'uppercase',
120
+ },
121
+ } );
122
+ } );
78
123
  } );
@@ -0,0 +1,250 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { useWindowDimensions } from 'react-native';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useMemo } from '@wordpress/element';
10
+ import {
11
+ ALIGNMENT_BREAKPOINTS,
12
+ WIDE_ALIGNMENTS,
13
+ alignmentHelpers,
14
+ } from '@wordpress/components';
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ import styles from './use-editor-wrapper-styles.scss';
20
+
21
+ const ALIGNMENT_MAX_WIDTH = {
22
+ full: '100%',
23
+ wide: 1054,
24
+ wideMedium: 770,
25
+ wideLandscape: 662,
26
+ };
27
+
28
+ const BLOCK_DEFAULT_MARGIN = 16;
29
+
30
+ /**
31
+ * Get the styles for the wide width alignment.
32
+ *
33
+ * @param {Object} [options] The options for the helper.
34
+ * @param {string} options.align The alignment value.
35
+ * @param {boolean} options.isLandscape Whether the screen is in landscape mode.
36
+ * @param {number} options.width The width of the screen.
37
+ * @return {Object} An object containing the styles for the wide width alignment.
38
+ */
39
+ function getWideWidthStyles( { align, isLandscape, width } = {} ) {
40
+ if ( align !== WIDE_ALIGNMENTS.alignments.wide ) {
41
+ return {};
42
+ }
43
+
44
+ if ( isLandscape && width < ALIGNMENT_BREAKPOINTS.large ) {
45
+ return { maxWidth: ALIGNMENT_MAX_WIDTH.wideLandscape };
46
+ }
47
+
48
+ if ( width <= ALIGNMENT_BREAKPOINTS.small ) {
49
+ return { maxWidth: width };
50
+ }
51
+
52
+ if (
53
+ width >= ALIGNMENT_BREAKPOINTS.medium &&
54
+ width < ALIGNMENT_BREAKPOINTS.wide
55
+ ) {
56
+ return { maxWidth: ALIGNMENT_MAX_WIDTH.wideMedium };
57
+ }
58
+
59
+ return { maxWidth: ALIGNMENT_MAX_WIDTH.wide };
60
+ }
61
+
62
+ /**
63
+ * Get the styles for the full width alignment.
64
+ *
65
+ * @param {Object} [options] The options for the helper.
66
+ * @param {string} options.align The alignment value.
67
+ * @param {string} options.blockName The name of the block.
68
+ * @param {boolean} options.hasParents Whether the block has parents.
69
+ * @param {string} options.parentBlockName The name of the parent block.
70
+ * @return {Object} An object containing the styles for the full width alignment.
71
+ */
72
+ function getFullWidthStyles( {
73
+ align,
74
+ blockName,
75
+ hasParents,
76
+ parentBlockName,
77
+ } = {} ) {
78
+ const { isContainerRelated, isFullWidth } = alignmentHelpers;
79
+ const fullWidthStyles = isFullWidth( align )
80
+ ? { maxWidth: ALIGNMENT_MAX_WIDTH.full }
81
+ : {};
82
+
83
+ if (
84
+ ! align &&
85
+ hasParents &&
86
+ ! isContainerRelated( parentBlockName ) &&
87
+ isContainerRelated( blockName )
88
+ ) {
89
+ fullWidthStyles.paddingHorizontal = BLOCK_DEFAULT_MARGIN;
90
+ }
91
+
92
+ return fullWidthStyles;
93
+ }
94
+
95
+ /**
96
+ * Get the block margin based on various conditions.
97
+ *
98
+ * @param {Object} [options] The options for the helper.
99
+ * @param {string} options.align The alignment value.
100
+ * @param {string} options.blockName The name of the block.
101
+ * @param {number} options.blockWidth The width of the block.
102
+ * @param {boolean} options.hasParents Whether the block has parents.
103
+ * @param {number} options.marginHorizontal Default horizontal margin.
104
+ * @param {string} options.parentBlockAlignment The alignment of the parent block.
105
+ * @param {string} options.parentBlockName The name of the parent block.
106
+ * @param {number} options.parentWidth The width of the parent block.
107
+ * @param {number} options.width The width of the screen.
108
+ * @return {number} The calculated block margin.
109
+ */
110
+ function getBlockMargin( {
111
+ align,
112
+ blockName,
113
+ blockWidth,
114
+ hasParents,
115
+ marginHorizontal,
116
+ parentBlockAlignment,
117
+ parentBlockName,
118
+ parentWidth,
119
+ width,
120
+ } = {} ) {
121
+ const { isContainerRelated, isWider, isWideWidth, isFullWidth } =
122
+ alignmentHelpers;
123
+
124
+ if ( isFullWidth( align ) ) {
125
+ if ( ! hasParents ) {
126
+ return 0;
127
+ }
128
+ return marginHorizontal;
129
+ }
130
+
131
+ if ( isWideWidth( align ) ) {
132
+ return marginHorizontal;
133
+ }
134
+
135
+ if (
136
+ isFullWidth( parentBlockAlignment ) &&
137
+ ! isWider( blockWidth, 'medium' )
138
+ ) {
139
+ if ( isContainerRelated( blockName ) || isWider( width, 'mobile' ) ) {
140
+ return marginHorizontal;
141
+ }
142
+ return marginHorizontal * 2;
143
+ }
144
+
145
+ if (
146
+ isContainerRelated( parentBlockName ) &&
147
+ ! isContainerRelated( blockName )
148
+ ) {
149
+ const isScreenWidthEqual = parentWidth === width;
150
+ if ( isScreenWidthEqual || isWider( width, 'mobile' ) ) {
151
+ return marginHorizontal;
152
+ }
153
+ }
154
+
155
+ return marginHorizontal;
156
+ }
157
+
158
+ /**
159
+ * Custom hook to get the styles and margin for the editor wrapper.
160
+ *
161
+ * @param {Object} [props] The props for the hook.
162
+ * @param {string} props.align The alignment value.
163
+ * @param {string} props.blockName The name of the block.
164
+ * @param {number} props.blockWidth The width of the block.
165
+ * @param {string} props.contentResizeMode The content resize mode.
166
+ * @param {boolean} props.hasParents Whether the block has parents.
167
+ * @param {number} props.marginHorizontal Default horizontal margin.
168
+ * @param {string} props.parentBlockAlignment The alignment of the parent block.
169
+ * @param {string} props.parentBlockName The name of the parent block.
170
+ * @param {number} props.parentWidth The width of the parent block.
171
+ * @param {boolean} [props.reversed=false] Whether the flex direction should be reversed.
172
+ * @return {[Array, number]} An array containing the wrapper styles and block margin.
173
+ */
174
+ export function useEditorWrapperStyles( {
175
+ align,
176
+ blockName,
177
+ blockWidth,
178
+ contentResizeMode,
179
+ hasParents,
180
+ marginHorizontal,
181
+ parentBlockAlignment,
182
+ parentBlockName,
183
+ parentWidth,
184
+ reversed = false,
185
+ } = {} ) {
186
+ const { width, height } = useWindowDimensions();
187
+ const isLandscape = width >= height;
188
+
189
+ const blockMargin = useMemo(
190
+ () =>
191
+ getBlockMargin( {
192
+ align,
193
+ blockName,
194
+ blockWidth,
195
+ hasParents,
196
+ marginHorizontal,
197
+ parentBlockAlignment,
198
+ parentBlockName,
199
+ parentWidth,
200
+ width,
201
+ } ),
202
+ [
203
+ align,
204
+ blockName,
205
+ blockWidth,
206
+ hasParents,
207
+ marginHorizontal,
208
+ parentBlockAlignment,
209
+ parentBlockName,
210
+ parentWidth,
211
+ width,
212
+ ]
213
+ );
214
+
215
+ const wrapperStyles = useMemo( () => {
216
+ let canvasStyles;
217
+
218
+ if ( contentResizeMode === 'stretch' ) {
219
+ // For these cases, no width constraints should be added.
220
+ canvasStyles = { flex: 1 };
221
+ } else if ( reversed ) {
222
+ canvasStyles = styles[ 'use-editor-wrapper-styles--reversed' ];
223
+ } else {
224
+ canvasStyles = styles[ 'use-editor-wrapper-styles' ];
225
+ }
226
+
227
+ const alignmentStyles = {
228
+ ...getWideWidthStyles( { align, isLandscape, width } ),
229
+ ...getFullWidthStyles( {
230
+ align,
231
+ blockName,
232
+ hasParents,
233
+ parentBlockName,
234
+ } ),
235
+ };
236
+
237
+ return [ canvasStyles, alignmentStyles ];
238
+ }, [
239
+ align,
240
+ blockName,
241
+ hasParents,
242
+ parentBlockName,
243
+ isLandscape,
244
+ width,
245
+ contentResizeMode,
246
+ reversed,
247
+ ] );
248
+
249
+ return [ wrapperStyles, blockMargin ];
250
+ }
@@ -0,0 +1,11 @@
1
+ .use-editor-wrapper-styles {
2
+ width: 100%;
3
+ max-width: 580;
4
+ align-self: center;
5
+ }
6
+
7
+ .use-editor-wrapper-styles--reversed {
8
+ flex-direction: column-reverse;
9
+ width: 100%;
10
+ max-width: 580;
11
+ }
@@ -11,25 +11,23 @@ import { getInlineStyles } from './style';
11
11
  import { getFontSizeClass } from '../components/font-sizes';
12
12
  import { getComputedFluidTypographyValue } from '../components/font-sizes/fluid-utils';
13
13
 
14
- // This utility is intended to assist where the serialization of the typography
15
- // block support is being skipped for a block but the typography related CSS
16
- // styles still need to be generated so they can be applied to inner elements.
17
-
14
+ /*
15
+ * This utility is intended to assist where the serialization of the typography
16
+ * block support is being skipped for a block but the typography related CSS
17
+ * styles still need to be generated so they can be applied to inner elements.
18
+ */
18
19
  /**
19
20
  * Provides the CSS class names and inline styles for a block's typography support
20
21
  * attributes.
21
22
  *
22
- * @param {Object} attributes Block attributes.
23
- * @param {Object|boolean} fluidTypographySettings If boolean, whether the function should try to convert font sizes to fluid values,
24
- * otherwise an object containing theme fluid typography settings.
23
+ * @param {Object} attributes Block attributes.
24
+ * @param {Object|boolean} settings Merged theme.json settings
25
25
  *
26
26
  * @return {Object} Typography block support derived CSS classes & styles.
27
27
  */
28
- export function getTypographyClassesAndStyles(
29
- attributes,
30
- fluidTypographySettings
31
- ) {
28
+ export function getTypographyClassesAndStyles( attributes, settings ) {
32
29
  let typographyStyles = attributes?.style?.typography || {};
30
+ const fluidTypographySettings = settings?.typography?.fluid;
33
31
 
34
32
  if (
35
33
  !! fluidTypographySettings &&
@@ -40,6 +38,7 @@ export function getTypographyClassesAndStyles(
40
38
  getComputedFluidTypographyValue( {
41
39
  fontSize: attributes?.style?.typography?.fontSize,
42
40
  minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
41
+ maximumViewPortWidth: settings?.layout?.wideSize,
43
42
  } ) || attributes?.style?.typography?.fontSize;
44
43
  typographyStyles = {
45
44
  ...typographyStyles,
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ export * from './index.js';
5
+
6
+ export { useEditorWrapperStyles } from './hooks';
@@ -4,14 +4,13 @@
4
4
  import * as globalStyles from './components/global-styles';
5
5
  import { ExperimentalBlockEditorProvider } from './components/provider';
6
6
  import { lock } from './lock-unlock';
7
- import OffCanvasEditor from './components/off-canvas-editor';
8
- import LeafMoreMenu from './components/off-canvas-editor/leaf-more-menu';
9
7
  import ResizableBoxPopover from './components/resizable-box-popover';
10
8
  import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
11
9
  import { PrivateListView } from './components/list-view';
12
10
  import BlockInfo from './components/block-info-slot-fill';
13
11
  import { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';
14
12
  import { cleanEmptyObject } from './hooks/utils';
13
+ import { useBlockEditingMode } from './components/block-editing-mode';
15
14
 
16
15
  /**
17
16
  * Private @wordpress/block-editor APIs.
@@ -20,12 +19,11 @@ export const privateApis = {};
20
19
  lock( privateApis, {
21
20
  ...globalStyles,
22
21
  ExperimentalBlockEditorProvider,
23
- LeafMoreMenu,
24
- OffCanvasEditor,
25
22
  PrivateInserter,
26
23
  PrivateListView,
27
24
  ResizableBoxPopover,
28
25
  BlockInfo,
29
26
  useShouldContextualToolbarShow,
30
27
  cleanEmptyObject,
28
+ useBlockEditingMode,
31
29
  } );