@wordpress/block-editor 13.1.0 → 13.3.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 (437) hide show
  1. package/CHANGELOG.md +21 -17
  2. package/README.md +1 -2
  3. package/build/components/block-breadcrumb/index.js +12 -1
  4. package/build/components/block-breadcrumb/index.js.map +1 -1
  5. package/build/components/block-lock/modal.js +67 -67
  6. package/build/components/block-lock/modal.js.map +1 -1
  7. package/build/components/block-lock/toolbar.js +0 -1
  8. package/build/components/block-lock/toolbar.js.map +1 -1
  9. package/build/components/block-mover/button.js +1 -1
  10. package/build/components/block-mover/button.js.map +1 -1
  11. package/build/components/block-mover/index.js +12 -6
  12. package/build/components/block-mover/index.js.map +1 -1
  13. package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
  14. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  15. package/build/components/block-patterns-paging/index.js +5 -7
  16. package/build/components/block-patterns-paging/index.js.map +1 -1
  17. package/build/components/block-quick-navigation/index.js +20 -17
  18. package/build/components/block-quick-navigation/index.js.map +1 -1
  19. package/build/components/block-rename/modal.js +4 -12
  20. package/build/components/block-rename/modal.js.map +1 -1
  21. package/build/components/block-toolbar/shuffle.js +4 -1
  22. package/build/components/block-toolbar/shuffle.js.map +1 -1
  23. package/build/components/block-tools/block-selection-button.js +7 -58
  24. package/build/components/block-tools/block-selection-button.js.map +1 -1
  25. package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  26. package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  27. package/build/components/block-tools/index.js +14 -1
  28. package/build/components/block-tools/index.js.map +1 -1
  29. package/build/components/block-tools/use-show-block-tools.js +4 -2
  30. package/build/components/block-tools/use-show-block-tools.js.map +1 -1
  31. package/build/components/block-tools/zoom-out-mode-inserters.js +5 -4
  32. package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  33. package/build/components/block-tools/zoom-out-popover.js +57 -0
  34. package/build/components/block-tools/zoom-out-popover.js.map +1 -0
  35. package/build/components/block-tools/zoom-out-toolbar.js +138 -0
  36. package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
  37. package/build/components/button-block-appender/index.js +3 -1
  38. package/build/components/button-block-appender/index.js.map +1 -1
  39. package/build/components/child-layout-control/index.js +193 -127
  40. package/build/components/child-layout-control/index.js.map +1 -1
  41. package/build/components/date-format-picker/index.js +10 -1
  42. package/build/components/date-format-picker/index.js.map +1 -1
  43. package/build/components/dimensions-tool/index.js +6 -4
  44. package/build/components/dimensions-tool/index.js.map +1 -1
  45. package/build/components/font-appearance-control/index.js +26 -61
  46. package/build/components/font-appearance-control/index.js.map +1 -1
  47. package/build/components/global-styles/background-panel.js +178 -116
  48. package/build/components/global-styles/background-panel.js.map +1 -1
  49. package/build/components/global-styles/border-panel.js +2 -1
  50. package/build/components/global-styles/border-panel.js.map +1 -1
  51. package/build/components/global-styles/color-panel.js +2 -1
  52. package/build/components/global-styles/color-panel.js.map +1 -1
  53. package/build/components/global-styles/dimensions-panel.js +2 -1
  54. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  55. package/build/components/global-styles/filters-panel.js +2 -1
  56. package/build/components/global-styles/filters-panel.js.map +1 -1
  57. package/build/components/global-styles/hooks.js +8 -0
  58. package/build/components/global-styles/hooks.js.map +1 -1
  59. package/build/components/global-styles/image-settings-panel.js +2 -1
  60. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  61. package/build/components/global-styles/typography-panel.js +50 -12
  62. package/build/components/global-styles/typography-panel.js.map +1 -1
  63. package/build/components/global-styles/typography-utils.js +50 -0
  64. package/build/components/global-styles/typography-utils.js.map +1 -1
  65. package/build/components/global-styles/use-global-styles-output.js +25 -9
  66. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  67. package/build/components/global-styles/utils.js +17 -7
  68. package/build/components/global-styles/utils.js.map +1 -1
  69. package/build/components/grid/grid-item-movers.js +94 -0
  70. package/build/components/grid/grid-item-movers.js.map +1 -0
  71. package/build/components/{grid-visualizer → grid}/grid-item-resizer.js +18 -56
  72. package/build/components/grid/grid-item-resizer.js.map +1 -0
  73. package/build/components/grid/grid-visualizer.js +305 -0
  74. package/build/components/grid/grid-visualizer.js.map +1 -0
  75. package/build/components/{grid-visualizer → grid}/index.js +14 -0
  76. package/build/components/grid/index.js.map +1 -0
  77. package/build/components/grid/use-get-number-of-blocks-before-cell.js +40 -0
  78. package/build/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
  79. package/build/components/grid/use-grid-layout-sync.js +169 -0
  80. package/build/components/grid/use-grid-layout-sync.js.map +1 -0
  81. package/build/components/grid/utils.js +145 -0
  82. package/build/components/grid/utils.js.map +1 -0
  83. package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
  84. package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  85. package/build/components/inner-blocks/index.js +1 -1
  86. package/build/components/inner-blocks/index.js.map +1 -1
  87. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  88. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  89. package/build/components/inserter/menu.js +26 -4
  90. package/build/components/inserter/menu.js.map +1 -1
  91. package/build/components/inserter/quick-inserter.js +2 -1
  92. package/build/components/inserter/quick-inserter.js.map +1 -1
  93. package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
  94. package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  95. package/build/components/link-control/link-preview.js +1 -1
  96. package/build/components/link-control/link-preview.js.map +1 -1
  97. package/build/components/media-placeholder/index.js +19 -23
  98. package/build/components/media-placeholder/index.js.map +1 -1
  99. package/build/components/navigable-toolbar/index.js +3 -1
  100. package/build/components/navigable-toolbar/index.js.map +1 -1
  101. package/build/components/rich-text/event-listeners/input-rules.js +1 -0
  102. package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
  103. package/build/components/rich-text/index.native.js +10 -4
  104. package/build/components/rich-text/index.native.js.map +1 -1
  105. package/build/components/rich-text/native/index.native.js +14 -0
  106. package/build/components/rich-text/native/index.native.js.map +1 -1
  107. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
  108. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  109. package/build/components/tabbed-sidebar/index.js +66 -0
  110. package/build/components/tabbed-sidebar/index.js.map +1 -0
  111. package/build/components/url-popover/index.js +3 -0
  112. package/build/components/url-popover/index.js.map +1 -1
  113. package/build/hooks/background.js +26 -4
  114. package/build/hooks/background.js.map +1 -1
  115. package/build/hooks/block-hooks.js +11 -17
  116. package/build/hooks/block-hooks.js.map +1 -1
  117. package/build/hooks/block-style-variation.js +195 -11
  118. package/build/hooks/block-style-variation.js.map +1 -1
  119. package/build/hooks/duotone.js +16 -11
  120. package/build/hooks/duotone.js.map +1 -1
  121. package/build/hooks/grid-visualizer.js +65 -0
  122. package/build/hooks/grid-visualizer.js.map +1 -0
  123. package/build/hooks/index.js +15 -2
  124. package/build/hooks/index.js.map +1 -1
  125. package/build/hooks/layout-child.js +65 -40
  126. package/build/hooks/layout-child.js.map +1 -1
  127. package/build/hooks/position.js +2 -9
  128. package/build/hooks/position.js.map +1 -1
  129. package/build/hooks/use-bindings-attributes.js +16 -6
  130. package/build/hooks/use-bindings-attributes.js.map +1 -1
  131. package/build/hooks/utils.js +5 -2
  132. package/build/hooks/utils.js.map +1 -1
  133. package/build/layouts/constrained.js +44 -2
  134. package/build/layouts/constrained.js.map +1 -1
  135. package/build/layouts/grid.js +92 -76
  136. package/build/layouts/grid.js.map +1 -1
  137. package/build/lock-unlock.js +1 -1
  138. package/build/lock-unlock.js.map +1 -1
  139. package/build/private-apis.js +6 -1
  140. package/build/private-apis.js.map +1 -1
  141. package/build/store/actions.js +17 -1
  142. package/build/store/actions.js.map +1 -1
  143. package/build/store/defaults.js +0 -2
  144. package/build/store/defaults.js.map +1 -1
  145. package/build/store/defaults.native.js +0 -3
  146. package/build/store/defaults.native.js.map +1 -1
  147. package/build/store/private-keys.js +2 -1
  148. package/build/store/private-keys.js.map +1 -1
  149. package/build/utils/format-font-style.js +45 -0
  150. package/build/utils/format-font-style.js.map +1 -0
  151. package/build/utils/format-font-weight.js +68 -0
  152. package/build/utils/format-font-weight.js.map +1 -0
  153. package/build/utils/get-editor-region.js +34 -0
  154. package/build/utils/get-editor-region.js.map +1 -0
  155. package/build/utils/get-font-styles-and-weights.js +167 -0
  156. package/build/utils/get-font-styles-and-weights.js.map +1 -0
  157. package/build/utils/pasting.js +5 -13
  158. package/build/utils/pasting.js.map +1 -1
  159. package/build-module/components/block-breadcrumb/index.js +12 -1
  160. package/build-module/components/block-breadcrumb/index.js.map +1 -1
  161. package/build-module/components/block-lock/modal.js +67 -67
  162. package/build-module/components/block-lock/modal.js.map +1 -1
  163. package/build-module/components/block-lock/toolbar.js +0 -1
  164. package/build-module/components/block-lock/toolbar.js.map +1 -1
  165. package/build-module/components/block-mover/button.js +1 -1
  166. package/build-module/components/block-mover/button.js.map +1 -1
  167. package/build-module/components/block-mover/index.js +12 -6
  168. package/build-module/components/block-mover/index.js.map +1 -1
  169. package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
  170. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  171. package/build-module/components/block-patterns-paging/index.js +5 -7
  172. package/build-module/components/block-patterns-paging/index.js.map +1 -1
  173. package/build-module/components/block-quick-navigation/index.js +20 -17
  174. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  175. package/build-module/components/block-rename/modal.js +5 -13
  176. package/build-module/components/block-rename/modal.js.map +1 -1
  177. package/build-module/components/block-toolbar/shuffle.js +4 -1
  178. package/build-module/components/block-toolbar/shuffle.js.map +1 -1
  179. package/build-module/components/block-tools/block-selection-button.js +10 -61
  180. package/build-module/components/block-tools/block-selection-button.js.map +1 -1
  181. package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
  182. package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
  183. package/build-module/components/block-tools/index.js +14 -1
  184. package/build-module/components/block-tools/index.js.map +1 -1
  185. package/build-module/components/block-tools/use-show-block-tools.js +4 -2
  186. package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
  187. package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -4
  188. package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
  189. package/build-module/components/block-tools/zoom-out-popover.js +48 -0
  190. package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
  191. package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
  192. package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
  193. package/build-module/components/button-block-appender/index.js +3 -1
  194. package/build-module/components/button-block-appender/index.js.map +1 -1
  195. package/build-module/components/child-layout-control/index.js +194 -128
  196. package/build-module/components/child-layout-control/index.js.map +1 -1
  197. package/build-module/components/date-format-picker/index.js +11 -3
  198. package/build-module/components/date-format-picker/index.js.map +1 -1
  199. package/build-module/components/dimensions-tool/index.js +6 -4
  200. package/build-module/components/dimensions-tool/index.js.map +1 -1
  201. package/build-module/components/font-appearance-control/index.js +28 -63
  202. package/build-module/components/font-appearance-control/index.js.map +1 -1
  203. package/build-module/components/global-styles/background-panel.js +181 -119
  204. package/build-module/components/global-styles/background-panel.js.map +1 -1
  205. package/build-module/components/global-styles/border-panel.js +3 -2
  206. package/build-module/components/global-styles/border-panel.js.map +1 -1
  207. package/build-module/components/global-styles/color-panel.js +3 -2
  208. package/build-module/components/global-styles/color-panel.js.map +1 -1
  209. package/build-module/components/global-styles/dimensions-panel.js +3 -2
  210. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  211. package/build-module/components/global-styles/filters-panel.js +3 -2
  212. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  213. package/build-module/components/global-styles/hooks.js +8 -0
  214. package/build-module/components/global-styles/hooks.js.map +1 -1
  215. package/build-module/components/global-styles/image-settings-panel.js +3 -2
  216. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  217. package/build-module/components/global-styles/typography-panel.js +52 -14
  218. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  219. package/build-module/components/global-styles/typography-utils.js +48 -0
  220. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  221. package/build-module/components/global-styles/use-global-styles-output.js +25 -9
  222. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  223. package/build-module/components/global-styles/utils.js +15 -6
  224. package/build-module/components/global-styles/utils.js.map +1 -1
  225. package/build-module/components/grid/grid-item-movers.js +87 -0
  226. package/build-module/components/grid/grid-item-movers.js.map +1 -0
  227. package/build-module/components/{grid-visualizer → grid}/grid-item-resizer.js +13 -51
  228. package/build-module/components/grid/grid-item-resizer.js.map +1 -0
  229. package/build-module/components/grid/grid-visualizer.js +297 -0
  230. package/build-module/components/grid/grid-visualizer.js.map +1 -0
  231. package/build-module/components/grid/index.js +5 -0
  232. package/build-module/components/grid/index.js.map +1 -0
  233. package/build-module/components/grid/use-get-number-of-blocks-before-cell.js +33 -0
  234. package/build-module/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
  235. package/build-module/components/grid/use-grid-layout-sync.js +162 -0
  236. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -0
  237. package/build-module/components/grid/utils.js +131 -0
  238. package/build-module/components/grid/utils.js.map +1 -0
  239. package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
  240. package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
  241. package/build-module/components/inner-blocks/index.js +1 -1
  242. package/build-module/components/inner-blocks/index.js.map +1 -1
  243. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
  244. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
  245. package/build-module/components/inserter/menu.js +26 -4
  246. package/build-module/components/inserter/menu.js.map +1 -1
  247. package/build-module/components/inserter/quick-inserter.js +2 -1
  248. package/build-module/components/inserter/quick-inserter.js.map +1 -1
  249. package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
  250. package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
  251. package/build-module/components/link-control/link-preview.js +1 -1
  252. package/build-module/components/link-control/link-preview.js.map +1 -1
  253. package/build-module/components/media-placeholder/index.js +19 -23
  254. package/build-module/components/media-placeholder/index.js.map +1 -1
  255. package/build-module/components/navigable-toolbar/index.js +3 -1
  256. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  257. package/build-module/components/rich-text/event-listeners/input-rules.js +1 -1
  258. package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
  259. package/build-module/components/rich-text/index.native.js +11 -5
  260. package/build-module/components/rich-text/index.native.js.map +1 -1
  261. package/build-module/components/rich-text/native/index.native.js +14 -0
  262. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  263. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
  264. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  265. package/build-module/components/tabbed-sidebar/index.js +60 -0
  266. package/build-module/components/tabbed-sidebar/index.js.map +1 -0
  267. package/build-module/components/url-popover/index.js +3 -0
  268. package/build-module/components/url-popover/index.js.map +1 -1
  269. package/build-module/hooks/background.js +26 -4
  270. package/build-module/hooks/background.js.map +1 -1
  271. package/build-module/hooks/block-hooks.js +11 -17
  272. package/build-module/hooks/block-hooks.js.map +1 -1
  273. package/build-module/hooks/block-style-variation.js +193 -11
  274. package/build-module/hooks/block-style-variation.js.map +1 -1
  275. package/build-module/hooks/duotone.js +16 -11
  276. package/build-module/hooks/duotone.js.map +1 -1
  277. package/build-module/hooks/grid-visualizer.js +64 -0
  278. package/build-module/hooks/grid-visualizer.js.map +1 -0
  279. package/build-module/hooks/index.js +3 -0
  280. package/build-module/hooks/index.js.map +1 -1
  281. package/build-module/hooks/layout-child.js +63 -38
  282. package/build-module/hooks/layout-child.js.map +1 -1
  283. package/build-module/hooks/position.js +2 -9
  284. package/build-module/hooks/position.js.map +1 -1
  285. package/build-module/hooks/use-bindings-attributes.js +16 -6
  286. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  287. package/build-module/hooks/utils.js +5 -2
  288. package/build-module/hooks/utils.js.map +1 -1
  289. package/build-module/layouts/constrained.js +44 -2
  290. package/build-module/layouts/constrained.js.map +1 -1
  291. package/build-module/layouts/grid.js +92 -76
  292. package/build-module/layouts/grid.js.map +1 -1
  293. package/build-module/lock-unlock.js +1 -1
  294. package/build-module/lock-unlock.js.map +1 -1
  295. package/build-module/private-apis.js +8 -3
  296. package/build-module/private-apis.js.map +1 -1
  297. package/build-module/store/actions.js +17 -1
  298. package/build-module/store/actions.js.map +1 -1
  299. package/build-module/store/defaults.js +0 -2
  300. package/build-module/store/defaults.js.map +1 -1
  301. package/build-module/store/defaults.native.js +0 -3
  302. package/build-module/store/defaults.native.js.map +1 -1
  303. package/build-module/store/private-keys.js +1 -0
  304. package/build-module/store/private-keys.js.map +1 -1
  305. package/build-module/utils/format-font-style.js +39 -0
  306. package/build-module/utils/format-font-style.js.map +1 -0
  307. package/build-module/utils/format-font-weight.js +62 -0
  308. package/build-module/utils/format-font-weight.js.map +1 -0
  309. package/build-module/utils/get-editor-region.js +28 -0
  310. package/build-module/utils/get-editor-region.js.map +1 -0
  311. package/build-module/utils/get-font-styles-and-weights.js +160 -0
  312. package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
  313. package/build-module/utils/pasting.js +5 -13
  314. package/build-module/utils/pasting.js.map +1 -1
  315. package/build-style/content-rtl.css +1 -0
  316. package/build-style/content.css +1 -0
  317. package/build-style/style-rtl.css +238 -106
  318. package/build-style/style.css +238 -106
  319. package/package.json +32 -32
  320. package/src/components/block-breadcrumb/index.js +16 -1
  321. package/src/components/block-lock/modal.js +95 -82
  322. package/src/components/block-lock/style.scss +11 -1
  323. package/src/components/block-lock/toolbar.js +0 -1
  324. package/src/components/block-mover/button.js +1 -1
  325. package/src/components/block-mover/index.js +37 -24
  326. package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
  327. package/src/components/block-patterns-paging/index.js +8 -11
  328. package/src/components/block-patterns-paging/style.scss +18 -0
  329. package/src/components/block-quick-navigation/index.js +21 -28
  330. package/src/components/block-rename/modal.js +2 -8
  331. package/src/components/block-switcher/test/index.js +6 -6
  332. package/src/components/block-toolbar/shuffle.js +4 -1
  333. package/src/components/block-toolbar/style.scss +1 -11
  334. package/src/components/block-tools/block-selection-button.js +11 -83
  335. package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
  336. package/src/components/block-tools/index.js +21 -1
  337. package/src/components/block-tools/style.scss +15 -0
  338. package/src/components/block-tools/use-show-block-tools.js +14 -6
  339. package/src/components/block-tools/zoom-out-mode-inserters.js +5 -4
  340. package/src/components/block-tools/zoom-out-popover.js +49 -0
  341. package/src/components/block-tools/zoom-out-toolbar.js +140 -0
  342. package/src/components/button-block-appender/index.js +2 -1
  343. package/src/components/child-layout-control/index.js +243 -160
  344. package/src/components/date-format-picker/index.js +10 -1
  345. package/src/components/date-format-picker/style.scss +0 -9
  346. package/src/components/dimensions-tool/index.js +97 -89
  347. package/src/components/font-appearance-control/index.js +29 -83
  348. package/src/components/font-appearance-control/style.scss +3 -5
  349. package/src/components/global-styles/background-panel.js +249 -170
  350. package/src/components/global-styles/border-panel.js +3 -2
  351. package/src/components/global-styles/color-panel.js +3 -2
  352. package/src/components/global-styles/dimensions-panel.js +3 -2
  353. package/src/components/global-styles/filters-panel.js +3 -2
  354. package/src/components/global-styles/hooks.js +9 -0
  355. package/src/components/global-styles/image-settings-panel.js +3 -2
  356. package/src/components/global-styles/style.scss +105 -20
  357. package/src/components/global-styles/test/typography-utils.js +269 -0
  358. package/src/components/global-styles/test/use-global-styles-output.js +38 -3
  359. package/src/components/global-styles/typography-panel.js +49 -12
  360. package/src/components/global-styles/typography-utils.js +63 -0
  361. package/src/components/global-styles/use-global-styles-output.js +25 -9
  362. package/src/components/global-styles/utils.js +17 -6
  363. package/src/components/grid/grid-item-movers.js +112 -0
  364. package/src/components/{grid-visualizer → grid}/grid-item-resizer.js +15 -52
  365. package/src/components/grid/grid-visualizer.js +384 -0
  366. package/src/components/grid/index.js +4 -0
  367. package/src/components/grid/style.scss +98 -0
  368. package/src/components/grid/use-get-number-of-blocks-before-cell.js +30 -0
  369. package/src/components/grid/use-grid-layout-sync.js +170 -0
  370. package/src/components/grid/utils.js +178 -0
  371. package/src/components/iframe/content.scss +1 -0
  372. package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
  373. package/src/components/inner-blocks/index.js +4 -1
  374. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
  375. package/src/components/inserter/menu.js +47 -13
  376. package/src/components/inserter/quick-inserter.js +6 -1
  377. package/src/components/inserter/style.scss +1 -49
  378. package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
  379. package/src/components/link-control/link-preview.js +1 -1
  380. package/src/components/media-placeholder/index.js +22 -32
  381. package/src/components/navigable-toolbar/index.js +3 -1
  382. package/src/components/rich-text/event-listeners/input-rules.js +1 -1
  383. package/src/components/rich-text/index.native.js +10 -8
  384. package/src/components/rich-text/native/index.native.js +17 -0
  385. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -1
  386. package/src/components/tabbed-sidebar/README.md +76 -0
  387. package/src/components/tabbed-sidebar/index.js +70 -0
  388. package/src/components/tabbed-sidebar/style.scss +53 -0
  389. package/src/components/url-popover/index.js +3 -0
  390. package/src/hooks/background.js +25 -10
  391. package/src/hooks/block-hooks.js +9 -16
  392. package/src/hooks/block-style-variation.js +226 -9
  393. package/src/hooks/duotone.js +16 -12
  394. package/src/hooks/grid-visualizer.js +64 -0
  395. package/src/hooks/index.js +3 -0
  396. package/src/hooks/layout-child.js +75 -39
  397. package/src/hooks/position.js +3 -10
  398. package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
  399. package/src/hooks/use-bindings-attributes.js +18 -4
  400. package/src/hooks/utils.js +5 -1
  401. package/src/layouts/constrained.js +43 -2
  402. package/src/layouts/grid.js +175 -88
  403. package/src/lock-unlock.js +1 -1
  404. package/src/private-apis.js +12 -1
  405. package/src/store/actions.js +21 -1
  406. package/src/store/defaults.js +0 -2
  407. package/src/store/defaults.native.js +0 -3
  408. package/src/store/private-keys.js +1 -0
  409. package/src/style.scss +2 -2
  410. package/src/utils/format-font-style.js +40 -0
  411. package/src/utils/format-font-weight.js +63 -0
  412. package/src/utils/get-editor-region.js +31 -0
  413. package/src/utils/get-font-styles-and-weights.js +191 -0
  414. package/src/utils/pasting.js +5 -12
  415. package/src/utils/test/format-font-style.js +34 -0
  416. package/src/utils/test/format-font-weight.js +66 -0
  417. package/src/utils/test/get-font-styles-and-weights.js +513 -0
  418. package/tsconfig.tsbuildinfo +1 -1
  419. package/build/components/grid-visualizer/grid-item-resizer.js.map +0 -1
  420. package/build/components/grid-visualizer/grid-visualizer.js +0 -92
  421. package/build/components/grid-visualizer/grid-visualizer.js.map +0 -1
  422. package/build/components/grid-visualizer/index.js.map +0 -1
  423. package/build/components/grid-visualizer/utils.js +0 -10
  424. package/build/components/grid-visualizer/utils.js.map +0 -1
  425. package/build-module/components/grid-visualizer/grid-item-resizer.js.map +0 -1
  426. package/build-module/components/grid-visualizer/grid-visualizer.js +0 -84
  427. package/build-module/components/grid-visualizer/grid-visualizer.js.map +0 -1
  428. package/build-module/components/grid-visualizer/index.js +0 -3
  429. package/build-module/components/grid-visualizer/index.js.map +0 -1
  430. package/build-module/components/grid-visualizer/utils.js +0 -4
  431. package/build-module/components/grid-visualizer/utils.js.map +0 -1
  432. package/src/components/grid-visualizer/grid-visualizer.js +0 -101
  433. package/src/components/grid-visualizer/index.js +0 -2
  434. package/src/components/grid-visualizer/style.scss +0 -34
  435. package/src/components/grid-visualizer/utils.js +0 -5
  436. package/src/hooks/position.scss +0 -18
  437. /package/src/components/font-sizes/{README.MD → README.md} +0 -0
@@ -12,8 +12,15 @@ import {
12
12
  Flex,
13
13
  FlexItem,
14
14
  } from '@wordpress/components';
15
- import { __ } from '@wordpress/i18n';
15
+ import { __, _x } from '@wordpress/i18n';
16
16
  import { useEffect } from '@wordpress/element';
17
+ import { useSelect, useDispatch } from '@wordpress/data';
18
+
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+ import { useGetNumberOfBlocksBeforeCell } from '../grid/use-get-number-of-blocks-before-cell';
23
+ import { store as blockEditorStore } from '../../store';
17
24
 
18
25
  function helpText( selfStretch, parentLayout ) {
19
26
  const { orientation = 'horizontal' } = parentLayout;
@@ -48,21 +55,46 @@ export default function ChildLayoutControl( {
48
55
  isShownByDefault,
49
56
  panelId,
50
57
  } ) {
51
- const {
52
- selfStretch,
53
- flexSize,
54
- columnStart,
55
- rowStart,
56
- columnSpan,
57
- rowSpan,
58
- } = childLayout;
59
58
  const {
60
59
  type: parentType,
61
60
  default: { type: defaultParentType = 'default' } = {},
62
- orientation = 'horizontal',
63
61
  } = parentLayout ?? {};
64
62
  const parentLayoutType = parentType || defaultParentType;
65
63
 
64
+ if ( parentLayoutType === 'flex' ) {
65
+ return (
66
+ <FlexControls
67
+ childLayout={ childLayout }
68
+ onChange={ onChange }
69
+ parentLayout={ parentLayout }
70
+ isShownByDefault={ isShownByDefault }
71
+ panelId={ panelId }
72
+ />
73
+ );
74
+ } else if ( parentLayoutType === 'grid' ) {
75
+ return (
76
+ <GridControls
77
+ childLayout={ childLayout }
78
+ onChange={ onChange }
79
+ parentLayout={ parentLayout }
80
+ isShownByDefault={ isShownByDefault }
81
+ panelId={ panelId }
82
+ />
83
+ );
84
+ }
85
+
86
+ return null;
87
+ }
88
+
89
+ function FlexControls( {
90
+ childLayout,
91
+ onChange,
92
+ parentLayout,
93
+ isShownByDefault,
94
+ panelId,
95
+ } ) {
96
+ const { selfStretch, flexSize } = childLayout;
97
+ const { orientation = 'horizontal' } = parentLayout ?? {};
66
98
  const hasFlexValue = () => !! selfStretch;
67
99
  const flexResetLabel =
68
100
  orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
@@ -73,6 +105,104 @@ export default function ChildLayoutControl( {
73
105
  } );
74
106
  };
75
107
 
108
+ useEffect( () => {
109
+ if ( selfStretch === 'fixed' && ! flexSize ) {
110
+ onChange( {
111
+ ...childLayout,
112
+ selfStretch: 'fit',
113
+ } );
114
+ }
115
+ }, [] );
116
+
117
+ return (
118
+ <VStack
119
+ as={ ToolsPanelItem }
120
+ spacing={ 2 }
121
+ hasValue={ hasFlexValue }
122
+ label={ flexResetLabel }
123
+ onDeselect={ resetFlex }
124
+ isShownByDefault={ isShownByDefault }
125
+ panelId={ panelId }
126
+ >
127
+ <ToggleGroupControl
128
+ __nextHasNoMarginBottom
129
+ size="__unstable-large"
130
+ label={ childLayoutOrientation( parentLayout ) }
131
+ value={ selfStretch || 'fit' }
132
+ help={ helpText( selfStretch, parentLayout ) }
133
+ onChange={ ( value ) => {
134
+ const newFlexSize = value !== 'fixed' ? null : flexSize;
135
+ onChange( {
136
+ selfStretch: value,
137
+ flexSize: newFlexSize,
138
+ } );
139
+ } }
140
+ isBlock
141
+ >
142
+ <ToggleGroupControlOption
143
+ key="fit"
144
+ value="fit"
145
+ label={ _x(
146
+ 'Fit',
147
+ 'Intrinsic block width in flex layout'
148
+ ) }
149
+ />
150
+ <ToggleGroupControlOption
151
+ key="fill"
152
+ value="fill"
153
+ label={ _x(
154
+ 'Grow',
155
+ 'Block with expanding width in flex layout'
156
+ ) }
157
+ />
158
+ <ToggleGroupControlOption
159
+ key="fixed"
160
+ value="fixed"
161
+ label={ _x(
162
+ 'Fixed',
163
+ 'Block with fixed width in flex layout'
164
+ ) }
165
+ />
166
+ </ToggleGroupControl>
167
+ { selfStretch === 'fixed' && (
168
+ <UnitControl
169
+ size="__unstable-large"
170
+ onChange={ ( value ) => {
171
+ onChange( {
172
+ selfStretch,
173
+ flexSize: value,
174
+ } );
175
+ } }
176
+ value={ flexSize }
177
+ />
178
+ ) }
179
+ </VStack>
180
+ );
181
+ }
182
+
183
+ export function childLayoutOrientation( parentLayout ) {
184
+ const { orientation = 'horizontal' } = parentLayout;
185
+ return orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
186
+ }
187
+
188
+ function GridControls( {
189
+ childLayout,
190
+ onChange,
191
+ parentLayout,
192
+ isShownByDefault,
193
+ panelId,
194
+ } ) {
195
+ const { columnStart, rowStart, columnSpan, rowSpan } = childLayout;
196
+ const { columnCount = 3, rowCount } = parentLayout ?? {};
197
+ const rootClientId = useSelect( ( select ) =>
198
+ select( blockEditorStore ).getBlockRootClientId( panelId )
199
+ );
200
+ const { moveBlocksToPosition, __unstableMarkNextChangeAsNotPersistent } =
201
+ useDispatch( blockEditorStore );
202
+ const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(
203
+ rootClientId,
204
+ columnCount
205
+ );
76
206
  const hasStartValue = () => !! columnStart || !! rowStart;
77
207
  const hasSpanValue = () => !! columnSpan || !! rowSpan;
78
208
  const resetGridStarts = () => {
@@ -88,184 +218,137 @@ export default function ChildLayoutControl( {
88
218
  } );
89
219
  };
90
220
 
91
- useEffect( () => {
92
- if ( selfStretch === 'fixed' && ! flexSize ) {
93
- onChange( {
94
- ...childLayout,
95
- selfStretch: 'fit',
96
- } );
97
- }
98
- }, [] );
99
-
100
221
  return (
101
222
  <>
102
- { parentLayoutType === 'flex' && (
103
- <VStack
223
+ <HStack
224
+ as={ ToolsPanelItem }
225
+ hasValue={ hasSpanValue }
226
+ label={ __( 'Grid span' ) }
227
+ onDeselect={ resetGridSpans }
228
+ isShownByDefault={ isShownByDefault }
229
+ panelId={ panelId }
230
+ >
231
+ <InputControl
232
+ size="__unstable-large"
233
+ label={ __( 'Column span' ) }
234
+ type="number"
235
+ onChange={ ( value ) => {
236
+ // Don't allow unsetting.
237
+ const newColumnSpan =
238
+ value === '' ? 1 : parseInt( value, 10 );
239
+ onChange( {
240
+ columnStart,
241
+ rowStart,
242
+ rowSpan,
243
+ columnSpan: newColumnSpan,
244
+ } );
245
+ } }
246
+ value={ columnSpan ?? 1 }
247
+ min={ 1 }
248
+ />
249
+ <InputControl
250
+ size="__unstable-large"
251
+ label={ __( 'Row span' ) }
252
+ type="number"
253
+ onChange={ ( value ) => {
254
+ // Don't allow unsetting.
255
+ const newRowSpan =
256
+ value === '' ? 1 : parseInt( value, 10 );
257
+ onChange( {
258
+ columnStart,
259
+ rowStart,
260
+ columnSpan,
261
+ rowSpan: newRowSpan,
262
+ } );
263
+ } }
264
+ value={ rowSpan ?? 1 }
265
+ min={ 1 }
266
+ />
267
+ </HStack>
268
+ { window.__experimentalEnableGridInteractivity && columnCount && (
269
+ // Use Flex with an explicit width on the FlexItem instead of HStack to
270
+ // work around an issue in webkit where inputs with a max attribute are
271
+ // sized incorrectly.
272
+ <Flex
104
273
  as={ ToolsPanelItem }
105
- spacing={ 2 }
106
- hasValue={ hasFlexValue }
107
- label={ flexResetLabel }
108
- onDeselect={ resetFlex }
109
- isShownByDefault={ isShownByDefault }
274
+ hasValue={ hasStartValue }
275
+ label={ __( 'Grid placement' ) }
276
+ onDeselect={ resetGridStarts }
277
+ isShownByDefault={ false }
110
278
  panelId={ panelId }
111
279
  >
112
- <ToggleGroupControl
113
- __nextHasNoMarginBottom
114
- size="__unstable-large"
115
- label={ childLayoutOrientation( parentLayout ) }
116
- value={ selfStretch || 'fit' }
117
- help={ helpText( selfStretch, parentLayout ) }
118
- onChange={ ( value ) => {
119
- const newFlexSize =
120
- value !== 'fixed' ? null : flexSize;
121
- onChange( {
122
- selfStretch: value,
123
- flexSize: newFlexSize,
124
- } );
125
- } }
126
- isBlock
127
- >
128
- <ToggleGroupControlOption
129
- key="fit"
130
- value="fit"
131
- label={ __( 'Fit' ) }
132
- />
133
- <ToggleGroupControlOption
134
- key="fill"
135
- value="fill"
136
- label={ __( 'Fill' ) }
137
- />
138
- <ToggleGroupControlOption
139
- key="fixed"
140
- value="fixed"
141
- label={ __( 'Fixed' ) }
142
- />
143
- </ToggleGroupControl>
144
- { selfStretch === 'fixed' && (
145
- <UnitControl
146
- size="__unstable-large"
147
- onChange={ ( value ) => {
148
- onChange( {
149
- selfStretch,
150
- flexSize: value,
151
- } );
152
- } }
153
- value={ flexSize }
154
- />
155
- ) }
156
- </VStack>
157
- ) }
158
- { parentLayoutType === 'grid' && (
159
- <>
160
- <HStack
161
- as={ ToolsPanelItem }
162
- hasValue={ hasSpanValue }
163
- label={ __( 'Grid span' ) }
164
- onDeselect={ resetGridSpans }
165
- isShownByDefault={ isShownByDefault }
166
- panelId={ panelId }
167
- >
280
+ <FlexItem style={ { width: '50%' } }>
168
281
  <InputControl
169
282
  size="__unstable-large"
170
- label={ __( 'Column span' ) }
283
+ label={ __( 'Column' ) }
171
284
  type="number"
172
285
  onChange={ ( value ) => {
286
+ // Don't allow unsetting.
287
+ const newColumnStart =
288
+ value === '' ? 1 : parseInt( value, 10 );
173
289
  onChange( {
174
- columnStart,
290
+ columnStart: newColumnStart,
175
291
  rowStart,
292
+ columnSpan,
176
293
  rowSpan,
177
- columnSpan: value,
178
294
  } );
295
+ __unstableMarkNextChangeAsNotPersistent();
296
+ moveBlocksToPosition(
297
+ [ panelId ],
298
+ rootClientId,
299
+ rootClientId,
300
+ getNumberOfBlocksBeforeCell(
301
+ newColumnStart,
302
+ rowStart
303
+ )
304
+ );
179
305
  } }
180
- value={ columnSpan }
306
+ value={ columnStart ?? 1 }
181
307
  min={ 1 }
308
+ max={
309
+ columnCount
310
+ ? columnCount - ( columnSpan ?? 1 ) + 1
311
+ : undefined
312
+ }
182
313
  />
314
+ </FlexItem>
315
+ <FlexItem style={ { width: '50%' } }>
183
316
  <InputControl
184
317
  size="__unstable-large"
185
- label={ __( 'Row span' ) }
318
+ label={ __( 'Row' ) }
186
319
  type="number"
187
320
  onChange={ ( value ) => {
321
+ // Don't allow unsetting.
322
+ const newRowStart =
323
+ value === '' ? 1 : parseInt( value, 10 );
188
324
  onChange( {
189
325
  columnStart,
190
- rowStart,
326
+ rowStart: newRowStart,
191
327
  columnSpan,
192
- rowSpan: value,
328
+ rowSpan,
193
329
  } );
330
+ __unstableMarkNextChangeAsNotPersistent();
331
+ moveBlocksToPosition(
332
+ [ panelId ],
333
+ rootClientId,
334
+ rootClientId,
335
+ getNumberOfBlocksBeforeCell(
336
+ columnStart,
337
+ newRowStart
338
+ )
339
+ );
194
340
  } }
195
- value={ rowSpan }
341
+ value={ rowStart ?? 1 }
196
342
  min={ 1 }
343
+ max={
344
+ rowCount
345
+ ? rowCount - ( rowSpan ?? 1 ) + 1
346
+ : undefined
347
+ }
197
348
  />
198
- </HStack>
199
- { window.__experimentalEnableGridInteractivity && (
200
- // Use Flex with an explicit width on the FlexItem instead of HStack to
201
- // work around an issue in webkit where inputs with a max attribute are
202
- // sized incorrectly.
203
- <Flex
204
- as={ ToolsPanelItem }
205
- hasValue={ hasStartValue }
206
- label={ __( 'Grid placement' ) }
207
- onDeselect={ resetGridStarts }
208
- isShownByDefault={ false }
209
- panelId={ panelId }
210
- >
211
- <FlexItem style={ { width: '50%' } }>
212
- <InputControl
213
- size="__unstable-large"
214
- label={ __( 'Column' ) }
215
- type="number"
216
- onChange={ ( value ) => {
217
- onChange( {
218
- columnStart: value,
219
- rowStart,
220
- columnSpan,
221
- rowSpan,
222
- } );
223
- } }
224
- value={ columnStart }
225
- min={ 1 }
226
- max={
227
- parentLayout?.columnCount
228
- ? parentLayout.columnCount -
229
- ( columnSpan ?? 1 ) +
230
- 1
231
- : undefined
232
- }
233
- />
234
- </FlexItem>
235
- <FlexItem style={ { width: '50%' } }>
236
- <InputControl
237
- size="__unstable-large"
238
- label={ __( 'Row' ) }
239
- type="number"
240
- onChange={ ( value ) => {
241
- onChange( {
242
- columnStart,
243
- rowStart: value,
244
- columnSpan,
245
- rowSpan,
246
- } );
247
- } }
248
- value={ rowStart }
249
- min={ 1 }
250
- max={
251
- parentLayout?.rowCount
252
- ? parentLayout.rowCount -
253
- ( rowSpan ?? 1 ) +
254
- 1
255
- : undefined
256
- }
257
- />
258
- </FlexItem>
259
- </Flex>
260
- ) }
261
- </>
349
+ </FlexItem>
350
+ </Flex>
262
351
  ) }
263
352
  </>
264
353
  );
265
354
  }
266
-
267
- export function childLayoutOrientation( parentLayout ) {
268
- const { orientation = 'horizontal' } = parentLayout;
269
-
270
- return orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
271
- }
@@ -8,11 +8,20 @@ import {
8
8
  TextControl,
9
9
  ExternalLink,
10
10
  VisuallyHidden,
11
- CustomSelectControl,
12
11
  ToggleControl,
13
12
  __experimentalVStack as VStack,
13
+ privateApis as componentsPrivateApis,
14
14
  } from '@wordpress/components';
15
15
 
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ import { unlock } from '../../lock-unlock';
20
+
21
+ const { CustomSelectControlV2Legacy: CustomSelectControl } = unlock(
22
+ componentsPrivateApis
23
+ );
24
+
16
25
  // So that we illustrate the different formats in the dropdown properly, show a date that is
17
26
  // somwhat recent, has a day greater than 12, and a month with more than three letters.
18
27
  const exampleDate = new Date();
@@ -4,13 +4,4 @@
4
4
 
5
5
  .block-editor-date-format-picker__custom-format-select-control__custom-option {
6
6
  border-top: 1px solid $gray-300;
7
-
8
- &.has-hint {
9
- grid-template-columns: auto 30px;
10
- }
11
-
12
- .components-custom-select-control__item-hint {
13
- grid-row: 2;
14
- text-align: left;
15
- }
16
7
  }
@@ -58,6 +58,7 @@ function DimensionsTool( {
58
58
  scaleOptions, // Default options handled by ScaleTool.
59
59
  defaultScale = 'fill', // Match CSS default value for object-fit.
60
60
  unitsOptions, // Default options handled by UnitControl.
61
+ tools = [ 'aspectRatio', 'widthHeight', 'scale' ],
61
62
  } ) {
62
63
  // Coerce undefined and CSS default values to be null.
63
64
  const width =
@@ -92,95 +93,102 @@ function DimensionsTool( {
92
93
 
93
94
  return (
94
95
  <>
95
- <AspectRatioTool
96
- panelId={ panelId }
97
- options={ aspectRatioOptions }
98
- defaultValue={ defaultAspectRatio }
99
- value={ aspectRatioValue }
100
- onChange={ ( nextAspectRatio ) => {
101
- const nextValue = { ...value };
102
-
103
- // 'auto' is CSS default, so it gets treated as null.
104
- nextAspectRatio =
105
- nextAspectRatio === 'auto' ? null : nextAspectRatio;
106
-
107
- setLastAspectRatio( nextAspectRatio );
108
-
109
- // Update aspectRatio.
110
- if ( ! nextAspectRatio ) {
111
- delete nextValue.aspectRatio;
112
- } else {
113
- nextValue.aspectRatio = nextAspectRatio;
114
- }
115
-
116
- // Auto-update scale.
117
- if ( ! nextAspectRatio ) {
118
- delete nextValue.scale;
119
- } else if ( lastScale ) {
120
- nextValue.scale = lastScale;
121
- } else {
122
- nextValue.scale = defaultScale;
123
- setLastScale( defaultScale );
124
- }
125
-
126
- // Auto-update width and height.
127
- if ( 'custom' !== nextAspectRatio && width && height ) {
128
- delete nextValue.height;
129
- }
130
-
131
- onChange( nextValue );
132
- } }
133
- />
134
- <WidthHeightTool
135
- panelId={ panelId }
136
- units={ unitsOptions }
137
- value={ { width, height } }
138
- onChange={ ( { width: nextWidth, height: nextHeight } ) => {
139
- const nextValue = { ...value };
140
-
141
- // 'auto' is CSS default, so it gets treated as null.
142
- nextWidth = nextWidth === 'auto' ? null : nextWidth;
143
- nextHeight = nextHeight === 'auto' ? null : nextHeight;
144
-
145
- // Update width.
146
- if ( ! nextWidth ) {
147
- delete nextValue.width;
148
- } else {
149
- nextValue.width = nextWidth;
150
- }
151
-
152
- // Update height.
153
- if ( ! nextHeight ) {
154
- delete nextValue.height;
155
- } else {
156
- nextValue.height = nextHeight;
157
- }
158
-
159
- // Auto-update aspectRatio.
160
- if ( nextWidth && nextHeight ) {
161
- delete nextValue.aspectRatio;
162
- } else if ( lastAspectRatio ) {
163
- nextValue.aspectRatio = lastAspectRatio;
164
- } else {
165
- // No setting defaultAspectRatio here, because
166
- // aspectRatio is optional in this scenario,
167
- // unlike scale.
168
- }
169
-
170
- // Auto-update scale.
171
- if ( ! lastAspectRatio && !! nextWidth !== !! nextHeight ) {
172
- delete nextValue.scale;
173
- } else if ( lastScale ) {
174
- nextValue.scale = lastScale;
175
- } else {
176
- nextValue.scale = defaultScale;
177
- setLastScale( defaultScale );
178
- }
179
-
180
- onChange( nextValue );
181
- } }
182
- />
183
- { showScaleControl && (
96
+ { tools.includes( 'aspectRatio' ) && (
97
+ <AspectRatioTool
98
+ panelId={ panelId }
99
+ options={ aspectRatioOptions }
100
+ defaultValue={ defaultAspectRatio }
101
+ value={ aspectRatioValue }
102
+ onChange={ ( nextAspectRatio ) => {
103
+ const nextValue = { ...value };
104
+
105
+ // 'auto' is CSS default, so it gets treated as null.
106
+ nextAspectRatio =
107
+ nextAspectRatio === 'auto' ? null : nextAspectRatio;
108
+
109
+ setLastAspectRatio( nextAspectRatio );
110
+
111
+ // Update aspectRatio.
112
+ if ( ! nextAspectRatio ) {
113
+ delete nextValue.aspectRatio;
114
+ } else {
115
+ nextValue.aspectRatio = nextAspectRatio;
116
+ }
117
+
118
+ // Auto-update scale.
119
+ if ( ! nextAspectRatio ) {
120
+ delete nextValue.scale;
121
+ } else if ( lastScale ) {
122
+ nextValue.scale = lastScale;
123
+ } else {
124
+ nextValue.scale = defaultScale;
125
+ setLastScale( defaultScale );
126
+ }
127
+
128
+ // Auto-update width and height.
129
+ if ( 'custom' !== nextAspectRatio && width && height ) {
130
+ delete nextValue.height;
131
+ }
132
+
133
+ onChange( nextValue );
134
+ } }
135
+ />
136
+ ) }
137
+ { tools.includes( 'widthHeight' ) && (
138
+ <WidthHeightTool
139
+ panelId={ panelId }
140
+ units={ unitsOptions }
141
+ value={ { width, height } }
142
+ onChange={ ( { width: nextWidth, height: nextHeight } ) => {
143
+ const nextValue = { ...value };
144
+
145
+ // 'auto' is CSS default, so it gets treated as null.
146
+ nextWidth = nextWidth === 'auto' ? null : nextWidth;
147
+ nextHeight = nextHeight === 'auto' ? null : nextHeight;
148
+
149
+ // Update width.
150
+ if ( ! nextWidth ) {
151
+ delete nextValue.width;
152
+ } else {
153
+ nextValue.width = nextWidth;
154
+ }
155
+
156
+ // Update height.
157
+ if ( ! nextHeight ) {
158
+ delete nextValue.height;
159
+ } else {
160
+ nextValue.height = nextHeight;
161
+ }
162
+
163
+ // Auto-update aspectRatio.
164
+ if ( nextWidth && nextHeight ) {
165
+ delete nextValue.aspectRatio;
166
+ } else if ( lastAspectRatio ) {
167
+ nextValue.aspectRatio = lastAspectRatio;
168
+ } else {
169
+ // No setting defaultAspectRatio here, because
170
+ // aspectRatio is optional in this scenario,
171
+ // unlike scale.
172
+ }
173
+
174
+ // Auto-update scale.
175
+ if (
176
+ ! lastAspectRatio &&
177
+ !! nextWidth !== !! nextHeight
178
+ ) {
179
+ delete nextValue.scale;
180
+ } else if ( lastScale ) {
181
+ nextValue.scale = lastScale;
182
+ } else {
183
+ nextValue.scale = defaultScale;
184
+ setLastScale( defaultScale );
185
+ }
186
+
187
+ onChange( nextValue );
188
+ } }
189
+ />
190
+ ) }
191
+ { tools.includes( 'scale' ) && showScaleControl && (
184
192
  <ScaleTool
185
193
  panelId={ panelId }
186
194
  options={ scaleOptions }