@wordpress/block-library 8.7.0 → 8.9.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 (416) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/column/index.js +2 -1
  3. package/build/column/index.js.map +1 -1
  4. package/build/columns/edit.js +24 -6
  5. package/build/columns/edit.js.map +1 -1
  6. package/build/columns/index.js +2 -1
  7. package/build/columns/index.js.map +1 -1
  8. package/build/columns/utils.js +4 -9
  9. package/build/columns/utils.js.map +1 -1
  10. package/build/cover/edit/index.js +46 -50
  11. package/build/cover/edit/index.js.map +1 -1
  12. package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
  13. package/build/cover/edit/resizable-cover-popover.js.map +1 -0
  14. package/build/cover/index.js +12 -0
  15. package/build/cover/index.js.map +1 -1
  16. package/build/cover/transforms.js +10 -7
  17. package/build/cover/transforms.js.map +1 -1
  18. package/build/details/edit.js +67 -0
  19. package/build/details/edit.js.map +1 -0
  20. package/build/details/index.js +110 -0
  21. package/build/details/index.js.map +1 -0
  22. package/build/details/save.js +33 -0
  23. package/build/details/save.js.map +1 -0
  24. package/build/details-content/edit.js +34 -0
  25. package/build/details-content/edit.js.map +1 -0
  26. package/build/details-content/index.js +94 -0
  27. package/build/details-content/index.js.map +1 -0
  28. package/build/details-content/save.js +20 -0
  29. package/build/details-content/save.js.map +1 -0
  30. package/build/details-summary/edit.js +42 -0
  31. package/build/details-summary/edit.js.map +1 -0
  32. package/build/details-summary/index.js +97 -0
  33. package/build/details-summary/index.js.map +1 -0
  34. package/build/details-summary/save.js +24 -0
  35. package/build/details-summary/save.js.map +1 -0
  36. package/build/embed/deprecated.js +4 -1
  37. package/build/embed/deprecated.js.map +1 -1
  38. package/build/embed/embed-link-settings.native.js +1 -1
  39. package/build/embed/embed-link-settings.native.js.map +1 -1
  40. package/build/embed/embed-placeholder.js +1 -1
  41. package/build/embed/embed-placeholder.js.map +1 -1
  42. package/build/embed/index.js +4 -1
  43. package/build/embed/index.js.map +1 -1
  44. package/build/embed/transforms.js +4 -1
  45. package/build/embed/transforms.js.map +1 -1
  46. package/build/embed/util.js +4 -1
  47. package/build/embed/util.js.map +1 -1
  48. package/build/file/edit.native.js +0 -2
  49. package/build/file/edit.native.js.map +1 -1
  50. package/build/gallery/use-get-media.native.js +2 -1
  51. package/build/gallery/use-get-media.native.js.map +1 -1
  52. package/build/group/edit.js +3 -1
  53. package/build/group/edit.js.map +1 -1
  54. package/build/group/index.js +3 -0
  55. package/build/group/index.js.map +1 -1
  56. package/build/image/edit.js +16 -13
  57. package/build/image/edit.js.map +1 -1
  58. package/build/image/index.js +5 -3
  59. package/build/image/index.js.map +1 -1
  60. package/build/index.js +24 -6
  61. package/build/index.js.map +1 -1
  62. package/build/index.native.js +9 -5
  63. package/build/index.native.js.map +1 -1
  64. package/build/media-text/edit.js +4 -2
  65. package/build/media-text/edit.js.map +1 -1
  66. package/build/media-text/index.js +3 -0
  67. package/build/media-text/index.js.map +1 -1
  68. package/build/media-text/media-container.js +2 -6
  69. package/build/media-text/media-container.js.map +1 -1
  70. package/build/media-text/media-container.native.js +3 -3
  71. package/build/media-text/media-container.native.js.map +1 -1
  72. package/build/navigation/deprecated.js +8 -11
  73. package/build/navigation/deprecated.js.map +1 -1
  74. package/build/navigation/edit/index.js +32 -64
  75. package/build/navigation/edit/index.js.map +1 -1
  76. package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
  77. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  78. package/build/post-author/index.js +0 -1
  79. package/build/post-author/index.js.map +1 -1
  80. package/build/post-date/edit.js +4 -2
  81. package/build/post-date/edit.js.map +1 -1
  82. package/build/post-excerpt/edit.js +2 -2
  83. package/build/post-excerpt/edit.js.map +1 -1
  84. package/build/post-featured-image/dimension-controls.js +2 -1
  85. package/build/post-featured-image/dimension-controls.js.map +1 -1
  86. package/build/post-featured-image/edit.js +16 -27
  87. package/build/post-featured-image/edit.js.map +1 -1
  88. package/build/post-time-to-read/edit.js +1 -1
  89. package/build/post-time-to-read/edit.js.map +1 -1
  90. package/build/post-time-to-read/index.js +7 -0
  91. package/build/post-time-to-read/index.js.map +1 -1
  92. package/build/query/deprecated.js +8 -6
  93. package/build/query/deprecated.js.map +1 -1
  94. package/build/query/edit/inspector-controls/create-new-post-link.js +41 -0
  95. package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  96. package/build/query/edit/inspector-controls/index.js +14 -6
  97. package/build/query/edit/inspector-controls/index.js.map +1 -1
  98. package/build/query/edit/pattern-selection-modal.js +2 -1
  99. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  100. package/build/query/index.js +5 -12
  101. package/build/query/index.js.map +1 -1
  102. package/build/site-logo/edit.js +114 -16
  103. package/build/site-logo/edit.js.map +1 -1
  104. package/build/site-logo/index.js +1 -1
  105. package/build/social-link/icons/chain.js +1 -1
  106. package/build/social-link/icons/chain.js.map +1 -1
  107. package/build/social-link/icons/mail.js +1 -1
  108. package/build/social-link/icons/mail.js.map +1 -1
  109. package/build/spacer/controls.js +25 -6
  110. package/build/spacer/controls.js.map +1 -1
  111. package/build/spacer/edit.js +129 -13
  112. package/build/spacer/edit.js.map +1 -1
  113. package/build/spacer/save.js +2 -2
  114. package/build/spacer/save.js.map +1 -1
  115. package/build/table/state.js +35 -35
  116. package/build/table/state.js.map +1 -1
  117. package/build/template-part/edit/index.js +2 -1
  118. package/build/template-part/edit/index.js.map +1 -1
  119. package/build/template-part/edit/utils/hooks.js +2 -2
  120. package/build/template-part/edit/utils/hooks.js.map +1 -1
  121. package/build/term-description/index.js +1 -2
  122. package/build/term-description/index.js.map +1 -1
  123. package/build/utils/migrate-font-family.js +12 -5
  124. package/build/utils/migrate-font-family.js.map +1 -1
  125. package/build/video/edit.native.js +4 -3
  126. package/build/video/edit.native.js.map +1 -1
  127. package/build-module/column/index.js +2 -1
  128. package/build-module/column/index.js.map +1 -1
  129. package/build-module/columns/edit.js +24 -6
  130. package/build-module/columns/edit.js.map +1 -1
  131. package/build-module/columns/index.js +2 -1
  132. package/build-module/columns/index.js.map +1 -1
  133. package/build-module/columns/utils.js +4 -8
  134. package/build-module/columns/utils.js.map +1 -1
  135. package/build-module/cover/edit/index.js +48 -52
  136. package/build-module/cover/edit/index.js.map +1 -1
  137. package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
  138. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
  139. package/build-module/cover/index.js +12 -0
  140. package/build-module/cover/index.js.map +1 -1
  141. package/build-module/cover/transforms.js +5 -1
  142. package/build-module/cover/transforms.js.map +1 -1
  143. package/build-module/details/edit.js +52 -0
  144. package/build-module/details/edit.js.map +1 -0
  145. package/build-module/details/index.js +91 -0
  146. package/build-module/details/index.js.map +1 -0
  147. package/build-module/details/save.js +20 -0
  148. package/build-module/details/save.js.map +1 -0
  149. package/build-module/details-content/edit.js +23 -0
  150. package/build-module/details-content/edit.js.map +1 -0
  151. package/build-module/details-content/index.js +76 -0
  152. package/build-module/details-content/index.js.map +1 -0
  153. package/build-module/details-content/save.js +11 -0
  154. package/build-module/details-content/save.js.map +1 -0
  155. package/build-module/details-summary/edit.js +30 -0
  156. package/build-module/details-summary/edit.js.map +1 -0
  157. package/build-module/details-summary/index.js +79 -0
  158. package/build-module/details-summary/index.js.map +1 -0
  159. package/build-module/details-summary/save.js +16 -0
  160. package/build-module/details-summary/save.js.map +1 -0
  161. package/build-module/embed/deprecated.js +4 -1
  162. package/build-module/embed/deprecated.js.map +1 -1
  163. package/build-module/embed/embed-link-settings.native.js +1 -1
  164. package/build-module/embed/embed-link-settings.native.js.map +1 -1
  165. package/build-module/embed/embed-placeholder.js +1 -1
  166. package/build-module/embed/embed-placeholder.js.map +1 -1
  167. package/build-module/embed/index.js +4 -1
  168. package/build-module/embed/index.js.map +1 -1
  169. package/build-module/embed/transforms.js +4 -1
  170. package/build-module/embed/transforms.js.map +1 -1
  171. package/build-module/embed/util.js +4 -1
  172. package/build-module/embed/util.js.map +1 -1
  173. package/build-module/file/edit.native.js +0 -2
  174. package/build-module/file/edit.native.js.map +1 -1
  175. package/build-module/gallery/use-get-media.native.js +2 -1
  176. package/build-module/gallery/use-get-media.native.js.map +1 -1
  177. package/build-module/group/edit.js +3 -1
  178. package/build-module/group/edit.js.map +1 -1
  179. package/build-module/group/index.js +3 -0
  180. package/build-module/group/index.js.map +1 -1
  181. package/build-module/image/edit.js +16 -13
  182. package/build-module/image/edit.js.map +1 -1
  183. package/build-module/image/index.js +5 -3
  184. package/build-module/image/index.js.map +1 -1
  185. package/build-module/index.js +21 -6
  186. package/build-module/index.js.map +1 -1
  187. package/build-module/index.native.js +9 -5
  188. package/build-module/index.native.js.map +1 -1
  189. package/build-module/media-text/edit.js +4 -2
  190. package/build-module/media-text/edit.js.map +1 -1
  191. package/build-module/media-text/index.js +3 -0
  192. package/build-module/media-text/index.js.map +1 -1
  193. package/build-module/media-text/media-container.js +1 -5
  194. package/build-module/media-text/media-container.js.map +1 -1
  195. package/build-module/media-text/media-container.native.js +1 -1
  196. package/build-module/media-text/media-container.native.js.map +1 -1
  197. package/build-module/navigation/deprecated.js +8 -10
  198. package/build-module/navigation/deprecated.js.map +1 -1
  199. package/build-module/navigation/edit/index.js +31 -63
  200. package/build-module/navigation/edit/index.js.map +1 -1
  201. package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
  202. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  203. package/build-module/post-author/index.js +0 -1
  204. package/build-module/post-author/index.js.map +1 -1
  205. package/build-module/post-date/edit.js +4 -2
  206. package/build-module/post-date/edit.js.map +1 -1
  207. package/build-module/post-excerpt/edit.js +2 -2
  208. package/build-module/post-excerpt/edit.js.map +1 -1
  209. package/build-module/post-featured-image/dimension-controls.js +2 -1
  210. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  211. package/build-module/post-featured-image/edit.js +16 -27
  212. package/build-module/post-featured-image/edit.js.map +1 -1
  213. package/build-module/post-time-to-read/edit.js +1 -1
  214. package/build-module/post-time-to-read/edit.js.map +1 -1
  215. package/build-module/post-time-to-read/index.js +7 -0
  216. package/build-module/post-time-to-read/index.js.map +1 -1
  217. package/build-module/query/deprecated.js +5 -2
  218. package/build-module/query/deprecated.js.map +1 -1
  219. package/build-module/query/edit/inspector-controls/create-new-post-link.js +33 -0
  220. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  221. package/build-module/query/edit/inspector-controls/index.js +12 -7
  222. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  223. package/build-module/query/edit/pattern-selection-modal.js +2 -1
  224. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  225. package/build-module/query/index.js +5 -10
  226. package/build-module/query/index.js.map +1 -1
  227. package/build-module/site-logo/edit.js +115 -18
  228. package/build-module/site-logo/edit.js.map +1 -1
  229. package/build-module/site-logo/index.js +1 -1
  230. package/build-module/social-link/icons/chain.js +1 -1
  231. package/build-module/social-link/icons/chain.js.map +1 -1
  232. package/build-module/social-link/icons/mail.js +1 -1
  233. package/build-module/social-link/icons/mail.js.map +1 -1
  234. package/build-module/spacer/controls.js +27 -9
  235. package/build-module/spacer/controls.js.map +1 -1
  236. package/build-module/spacer/edit.js +129 -14
  237. package/build-module/spacer/edit.js.map +1 -1
  238. package/build-module/spacer/save.js +3 -3
  239. package/build-module/spacer/save.js.map +1 -1
  240. package/build-module/table/state.js +35 -33
  241. package/build-module/table/state.js.map +1 -1
  242. package/build-module/template-part/edit/index.js +2 -1
  243. package/build-module/template-part/edit/index.js.map +1 -1
  244. package/build-module/template-part/edit/utils/hooks.js +2 -2
  245. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  246. package/build-module/term-description/index.js +1 -2
  247. package/build-module/term-description/index.js.map +1 -1
  248. package/build-module/utils/migrate-font-family.js +9 -1
  249. package/build-module/utils/migrate-font-family.js.map +1 -1
  250. package/build-module/video/edit.native.js +4 -3
  251. package/build-module/video/edit.native.js.map +1 -1
  252. package/build-style/columns/style-rtl.css +4 -1
  253. package/build-style/columns/style.css +4 -1
  254. package/build-style/common-rtl.css +1 -1
  255. package/build-style/common.css +1 -1
  256. package/build-style/cover/editor-rtl.css +9 -10
  257. package/build-style/cover/editor.css +9 -10
  258. package/build-style/cover/style-rtl.css +1 -1
  259. package/build-style/cover/style.css +1 -1
  260. package/build-style/details/style-rtl.css +91 -0
  261. package/build-style/details/style.css +91 -0
  262. package/build-style/details-summary/editor-rtl.css +91 -0
  263. package/build-style/details-summary/editor.css +91 -0
  264. package/build-style/details-summary/style-rtl.css +91 -0
  265. package/build-style/details-summary/style.css +91 -0
  266. package/build-style/editor-rtl.css +97 -74
  267. package/build-style/editor.css +97 -74
  268. package/build-style/file/style-rtl.css +4 -3
  269. package/build-style/file/style.css +4 -3
  270. package/build-style/html/editor-rtl.css +2 -2
  271. package/build-style/html/editor.css +2 -2
  272. package/build-style/image/editor-rtl.css +1 -1
  273. package/build-style/image/editor.css +1 -1
  274. package/build-style/post-excerpt/style-rtl.css +1 -1
  275. package/build-style/post-excerpt/style.css +1 -1
  276. package/build-style/pullquote/style-rtl.css +4 -1
  277. package/build-style/pullquote/style.css +4 -1
  278. package/build-style/query/editor-rtl.css +8 -12
  279. package/build-style/query/editor.css +8 -12
  280. package/build-style/search/style-rtl.css +2 -0
  281. package/build-style/search/style.css +2 -0
  282. package/build-style/shortcode/editor-rtl.css +15 -35
  283. package/build-style/shortcode/editor.css +15 -35
  284. package/build-style/site-logo/editor-rtl.css +46 -0
  285. package/build-style/site-logo/editor.css +46 -0
  286. package/build-style/spacer/editor-rtl.css +4 -2
  287. package/build-style/spacer/editor.css +4 -2
  288. package/build-style/style-rtl.css +25 -8
  289. package/build-style/style.css +25 -8
  290. package/build-style/template-part/editor-rtl.css +8 -12
  291. package/build-style/template-part/editor.css +8 -12
  292. package/package.json +31 -31
  293. package/src/buttons/test/__snapshots__/edit.native.js.snap +18 -0
  294. package/src/buttons/test/edit.native.js +123 -2
  295. package/src/column/block.json +2 -1
  296. package/src/columns/block.json +2 -1
  297. package/src/columns/edit.js +33 -9
  298. package/src/columns/style.scss +5 -1
  299. package/src/columns/utils.js +8 -9
  300. package/src/common.scss +1 -1
  301. package/src/cover/block.json +12 -0
  302. package/src/cover/edit/index.js +44 -37
  303. package/src/cover/edit/resizable-cover-popover.js +82 -0
  304. package/src/cover/editor.scss +20 -13
  305. package/src/cover/index.php +9 -10
  306. package/src/cover/style.scss +1 -1
  307. package/src/cover/test/edit.js +1 -1
  308. package/src/cover/transforms.js +4 -1
  309. package/src/details/block.json +54 -0
  310. package/src/details/edit.js +59 -0
  311. package/src/details/index.js +35 -0
  312. package/src/details/save.js +15 -0
  313. package/src/details/style.scss +3 -0
  314. package/src/details-content/block.json +50 -0
  315. package/src/details-content/edit.js +29 -0
  316. package/src/details-content/index.js +23 -0
  317. package/src/details-content/save.js +12 -0
  318. package/src/details-summary/block.json +53 -0
  319. package/src/details-summary/edit.js +27 -0
  320. package/src/details-summary/editor.scss +3 -0
  321. package/src/details-summary/index.js +23 -0
  322. package/src/details-summary/save.js +13 -0
  323. package/src/details-summary/style.scss +3 -0
  324. package/src/editor.scss +1 -0
  325. package/src/embed/block.json +4 -1
  326. package/src/embed/embed-link-settings.native.js +1 -1
  327. package/src/embed/embed-placeholder.js +1 -1
  328. package/src/file/edit.native.js +0 -2
  329. package/src/file/style.scss +5 -2
  330. package/src/gallery/test/index.native.js +4 -4
  331. package/src/gallery/test/use-get-media.native.js +24 -0
  332. package/src/gallery/use-get-media.native.js +1 -1
  333. package/src/group/block.json +3 -0
  334. package/src/group/edit.js +8 -2
  335. package/src/heading/test/__snapshots__/index.native.js.snap +12 -0
  336. package/src/heading/test/index.native.js +71 -0
  337. package/src/html/editor.scss +2 -21
  338. package/src/image/block.json +5 -3
  339. package/src/image/edit.js +21 -17
  340. package/src/image/editor.scss +1 -1
  341. package/src/index.js +13 -3
  342. package/src/index.native.js +9 -5
  343. package/src/list/test/edit.native.js +7 -7
  344. package/src/media-text/block.json +3 -0
  345. package/src/media-text/edit.js +2 -1
  346. package/src/media-text/media-container.js +1 -5
  347. package/src/media-text/media-container.native.js +1 -1
  348. package/src/navigation/deprecated.js +15 -19
  349. package/src/navigation/edit/index.js +32 -106
  350. package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
  351. package/src/navigation/index.php +15 -12
  352. package/src/paragraph/test/edit.native.js +616 -1
  353. package/src/post-author/block.json +0 -1
  354. package/src/post-date/edit.js +4 -0
  355. package/src/post-date/index.php +17 -8
  356. package/src/post-excerpt/edit.js +1 -1
  357. package/src/post-excerpt/index.php +3 -3
  358. package/src/post-excerpt/style.scss +2 -1
  359. package/src/post-featured-image/dimension-controls.js +5 -1
  360. package/src/post-featured-image/edit.js +14 -34
  361. package/src/post-featured-image/index.php +1 -1
  362. package/src/post-time-to-read/block.json +7 -0
  363. package/src/post-time-to-read/edit.js +1 -1
  364. package/src/post-time-to-read/index.php +3 -3
  365. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
  366. package/src/preformatted/test/edit.native.js +42 -2
  367. package/src/pullquote/style.scss +5 -1
  368. package/src/pullquote/test/edit.native.js +65 -0
  369. package/src/query/deprecated.js +4 -1
  370. package/src/query/edit/inspector-controls/create-new-post-link.js +26 -0
  371. package/src/query/edit/inspector-controls/index.js +13 -6
  372. package/src/query/edit/pattern-selection-modal.js +1 -0
  373. package/src/query/editor.scss +8 -11
  374. package/src/query/index.js +1 -7
  375. package/src/quote/test/edit.native.js +88 -0
  376. package/src/search/index.php +1 -1
  377. package/src/search/style.scss +3 -0
  378. package/src/shortcode/editor.scss +6 -5
  379. package/src/site-logo/block.json +1 -1
  380. package/src/site-logo/edit.js +123 -9
  381. package/src/site-logo/editor.scss +57 -0
  382. package/src/social-link/icons/chain.js +1 -1
  383. package/src/social-link/icons/mail.js +1 -1
  384. package/src/social-link/index.php +2 -2
  385. package/src/spacer/controls.js +42 -17
  386. package/src/spacer/edit.js +176 -18
  387. package/src/spacer/editor.scss +2 -1
  388. package/src/spacer/save.js +3 -3
  389. package/src/style.scss +2 -0
  390. package/src/table/state.js +83 -66
  391. package/src/template-part/edit/index.js +1 -0
  392. package/src/template-part/edit/utils/hooks.js +2 -2
  393. package/src/template-part/editor.scss +9 -11
  394. package/src/term-description/block.json +1 -2
  395. package/src/utils/migrate-font-family.js +8 -1
  396. package/src/verse/test/edit.native.js +28 -0
  397. package/src/video/edit.native.js +2 -2
  398. package/tsconfig.json +1 -0
  399. package/build/cover/edit/resizable-cover.js.map +0 -1
  400. package/build/media-text/media-container-icon.js +0 -27
  401. package/build/media-text/media-container-icon.js.map +0 -1
  402. package/build/query/hooks.js +0 -72
  403. package/build/query/hooks.js.map +0 -1
  404. package/build/utils/clean-empty-object.js +0 -34
  405. package/build/utils/clean-empty-object.js.map +0 -1
  406. package/build-module/cover/edit/resizable-cover.js.map +0 -1
  407. package/build-module/media-text/media-container-icon.js +0 -17
  408. package/build-module/media-text/media-container-icon.js.map +0 -1
  409. package/build-module/query/hooks.js +0 -59
  410. package/build-module/query/hooks.js.map +0 -1
  411. package/build-module/utils/clean-empty-object.js +0 -25
  412. package/build-module/utils/clean-empty-object.js.map +0 -1
  413. package/src/cover/edit/resizable-cover.js +0 -61
  414. package/src/media-text/media-container-icon.js +0 -12
  415. package/src/query/hooks.js +0 -53
  416. package/src/utils/clean-empty-object.js +0 -28
@@ -24,12 +24,19 @@ import {
24
24
  ToolbarButton,
25
25
  Placeholder,
26
26
  Button,
27
+ DropZone,
28
+ FlexItem,
29
+ __experimentalItemGroup as ItemGroup,
30
+ __experimentalHStack as HStack,
31
+ __experimentalTruncate as Truncate,
27
32
  } from '@wordpress/components';
28
33
  import { useViewportMatch } from '@wordpress/compose';
29
34
  import {
30
35
  BlockControls,
31
36
  InspectorControls,
32
37
  MediaPlaceholder,
38
+ MediaUpload,
39
+ MediaUploadCheck,
33
40
  MediaReplaceFlow,
34
41
  useBlockProps,
35
42
  store as blockEditorStore,
@@ -349,6 +356,45 @@ const SiteLogo = ( {
349
356
  );
350
357
  };
351
358
 
359
+ // This is a light wrapper around MediaReplaceFlow because the block has two
360
+ // different MediaReplaceFlows, one for the inspector and one for the toolbar.
361
+ function SiteLogoReplaceFlow( { onRemoveLogo, ...mediaReplaceProps } ) {
362
+ return (
363
+ <MediaReplaceFlow
364
+ { ...mediaReplaceProps }
365
+ allowedTypes={ ALLOWED_MEDIA_TYPES }
366
+ accept={ ACCEPT_MEDIA_STRING }
367
+ >
368
+ <MenuItem onClick={ onRemoveLogo }>{ __( 'Reset' ) }</MenuItem>
369
+ </MediaReplaceFlow>
370
+ );
371
+ }
372
+
373
+ const InspectorLogoPreview = ( { mediaItemData = {}, itemGroupProps } ) => {
374
+ const {
375
+ alt_text: alt,
376
+ source_url: logoUrl,
377
+ slug: logoSlug,
378
+ media_details: logoMediaDetails,
379
+ } = mediaItemData;
380
+ const logoLabel = logoMediaDetails?.sizes?.full?.file || logoSlug;
381
+ return (
382
+ <ItemGroup { ...itemGroupProps } as="span">
383
+ <HStack justify="flex-start" as="span">
384
+ <img src={ logoUrl } alt={ alt } />
385
+ <FlexItem as="span">
386
+ <Truncate
387
+ numberOfLines={ 1 }
388
+ className="block-library-site-logo__inspector-media-replace-title"
389
+ >
390
+ { logoLabel }
391
+ </Truncate>
392
+ </FlexItem>
393
+ </HStack>
394
+ </ItemGroup>
395
+ );
396
+ };
397
+
352
398
  export default function LogoEdit( {
353
399
  attributes,
354
400
  className,
@@ -365,6 +411,7 @@ export default function LogoEdit( {
365
411
  siteIconId,
366
412
  mediaItemData,
367
413
  isRequestingMediaItem,
414
+ mediaUpload,
368
415
  } = useSelect( ( select ) => {
369
416
  const { canUser, getEntityRecord, getEditedEntityRecord } =
370
417
  select( coreStore );
@@ -396,6 +443,7 @@ export default function LogoEdit( {
396
443
  mediaItemData: mediaItem,
397
444
  isRequestingMediaItem: _isRequestingMediaItem,
398
445
  siteIconId: _siteIconId,
446
+ mediaUpload: select( blockEditorStore ).getSettings().mediaUpload,
399
447
  };
400
448
  }, [] );
401
449
 
@@ -461,17 +509,29 @@ export default function LogoEdit( {
461
509
  createErrorNotice( message, { type: 'snackbar' } );
462
510
  };
463
511
 
512
+ const onFilesDrop = ( filesList ) => {
513
+ mediaUpload( {
514
+ allowedTypes: [ 'image' ],
515
+ filesList,
516
+ onFileChange( [ image ] ) {
517
+ if ( isBlobURL( image?.url ) ) {
518
+ return;
519
+ }
520
+ onInitialSelectLogo( image );
521
+ },
522
+ onError: onUploadError,
523
+ } );
524
+ };
525
+
526
+ const mediaReplaceFlowProps = {
527
+ mediaURL: logoUrl,
528
+ onSelect: onSelectLogo,
529
+ onError: onUploadError,
530
+ onRemoveLogo,
531
+ };
464
532
  const controls = canUserEdit && logoUrl && (
465
533
  <BlockControls group="other">
466
- <MediaReplaceFlow
467
- mediaURL={ logoUrl }
468
- allowedTypes={ ALLOWED_MEDIA_TYPES }
469
- accept={ ACCEPT_MEDIA_STRING }
470
- onSelect={ onSelectLogo }
471
- onError={ onUploadError }
472
- >
473
- <MenuItem onClick={ onRemoveLogo }>{ __( 'Reset' ) }</MenuItem>
474
- </MediaReplaceFlow>
534
+ <SiteLogoReplaceFlow { ...mediaReplaceFlowProps } />
475
535
  </BlockControls>
476
536
  );
477
537
 
@@ -530,9 +590,63 @@ export default function LogoEdit( {
530
590
 
531
591
  const label = __( 'Add a site logo' );
532
592
 
593
+ const mediaInspectorPanel = ( canUserEdit || logoUrl ) && (
594
+ <InspectorControls>
595
+ <PanelBody title={ __( 'Media' ) }>
596
+ <div className="block-library-site-logo__inspector-media-replace-container">
597
+ { ! canUserEdit && !! logoUrl && (
598
+ <InspectorLogoPreview
599
+ mediaItemData={ mediaItemData }
600
+ itemGroupProps={ {
601
+ isBordered: true,
602
+ className:
603
+ 'block-library-site-logo__inspector-readonly-logo-preview',
604
+ } }
605
+ />
606
+ ) }
607
+ { canUserEdit && !! logoUrl && (
608
+ <SiteLogoReplaceFlow
609
+ { ...mediaReplaceFlowProps }
610
+ name={
611
+ <InspectorLogoPreview
612
+ mediaItemData={ mediaItemData }
613
+ />
614
+ }
615
+ popoverProps={ {} }
616
+ />
617
+ ) }
618
+ { canUserEdit && ! logoUrl && (
619
+ <MediaUploadCheck>
620
+ <MediaUpload
621
+ onSelect={ onInitialSelectLogo }
622
+ allowedTypes={ ALLOWED_MEDIA_TYPES }
623
+ render={ ( { open } ) => (
624
+ <div className="block-library-site-logo__inspector-upload-container">
625
+ <Button
626
+ onClick={ open }
627
+ variant="secondary"
628
+ >
629
+ { isLoading ? (
630
+ <Spinner />
631
+ ) : (
632
+ __( 'Add media' )
633
+ ) }
634
+ </Button>
635
+ <DropZone onFilesDrop={ onFilesDrop } />
636
+ </div>
637
+ ) }
638
+ />
639
+ </MediaUploadCheck>
640
+ ) }
641
+ </div>
642
+ </PanelBody>
643
+ </InspectorControls>
644
+ );
645
+
533
646
  return (
534
647
  <div { ...blockProps }>
535
648
  { controls }
649
+ { mediaInspectorPanel }
536
650
  { !! logoUrl && logoImage }
537
651
  { ! logoUrl && ! canUserEdit && (
538
652
  <Placeholder className="site-logo_placeholder">
@@ -93,3 +93,60 @@
93
93
  }
94
94
  }
95
95
  }
96
+
97
+ .block-library-site-logo__inspector-upload-container {
98
+ position: relative;
99
+ // Since there is no option to skip rendering the drag'n'drop icon in drop
100
+ // zone, we hide it for now.
101
+ .components-drop-zone__content-icon {
102
+ display: none;
103
+ }
104
+ }
105
+
106
+ .block-library-site-logo__inspector-upload-container,
107
+ .block-library-site-logo__inspector-media-replace-container {
108
+ button.components-button {
109
+ color: $gray-900;
110
+ box-shadow: inset 0 0 0 1px $gray-400;
111
+ width: 100%;
112
+ display: block;
113
+ height: $grid-unit-50;
114
+
115
+ &:hover {
116
+ color: var(--wp-admin-theme-color);
117
+ }
118
+
119
+ &:focus {
120
+ box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
121
+ }
122
+ }
123
+
124
+ .block-library-site-logo__inspector-media-replace-title {
125
+ word-break: break-all;
126
+ // The Button component is white-space: nowrap, and that won't work with line-clamp.
127
+ white-space: normal;
128
+
129
+ // Without this, the ellipsis can sometimes be partially hidden by the Button padding.
130
+ text-align: start;
131
+ text-align-last: center;
132
+ }
133
+ }
134
+
135
+ .block-library-site-logo__inspector-media-replace-container {
136
+ .components-dropdown {
137
+ display: block;
138
+ }
139
+
140
+ img {
141
+ width: $grid-unit-50 * 0.5;
142
+ aspect-ratio: 1;
143
+ box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
144
+ border-radius: 50% !important;
145
+ }
146
+
147
+ .block-library-site-logo__inspector-readonly-logo-preview {
148
+ padding: 6px 12px;
149
+ display: flex;
150
+ height: $grid-unit-50;
151
+ }
152
+ }
@@ -5,6 +5,6 @@ import { Path, SVG } from '@wordpress/primitives';
5
5
 
6
6
  export const ChainIcon = () => (
7
7
  <SVG width="24" height="24" viewBox="0 0 24 24" version="1.1">
8
- <Path d="M19.647,16.706a1.134,1.134,0,0,0-.343-.833l-2.549-2.549a1.134,1.134,0,0,0-.833-.343,1.168,1.168,0,0,0-.883.392l.233.226q.2.189.264.264a2.922,2.922,0,0,1,.184.233.986.986,0,0,1,.159.312,1.242,1.242,0,0,1,.043.337,1.172,1.172,0,0,1-1.176,1.176,1.237,1.237,0,0,1-.337-.043,1,1,0,0,1-.312-.159,2.76,2.76,0,0,1-.233-.184q-.073-.068-.264-.264l-.226-.233a1.19,1.19,0,0,0-.4.895,1.134,1.134,0,0,0,.343.833L15.837,19.3a1.13,1.13,0,0,0,.833.331,1.18,1.18,0,0,0,.833-.318l1.8-1.789a1.12,1.12,0,0,0,.343-.821Zm-8.615-8.64a1.134,1.134,0,0,0-.343-.833L8.163,4.7a1.134,1.134,0,0,0-.833-.343,1.184,1.184,0,0,0-.833.331L4.7,6.473a1.12,1.12,0,0,0-.343.821,1.134,1.134,0,0,0,.343.833l2.549,2.549a1.13,1.13,0,0,0,.833.331,1.184,1.184,0,0,0,.883-.38L8.728,10.4q-.2-.189-.264-.264A2.922,2.922,0,0,1,8.28,9.9a.986.986,0,0,1-.159-.312,1.242,1.242,0,0,1-.043-.337A1.172,1.172,0,0,1,9.254,8.079a1.237,1.237,0,0,1,.337.043,1,1,0,0,1,.312.159,2.761,2.761,0,0,1,.233.184q.073.068.264.264l.226.233a1.19,1.19,0,0,0,.4-.895ZM22,16.706a3.343,3.343,0,0,1-1.042,2.488l-1.8,1.789a3.536,3.536,0,0,1-4.988-.025l-2.525-2.537a3.384,3.384,0,0,1-1.017-2.488,3.448,3.448,0,0,1,1.078-2.561l-1.078-1.078a3.434,3.434,0,0,1-2.549,1.078,3.4,3.4,0,0,1-2.5-1.029L3.029,9.794A3.4,3.4,0,0,1,2,7.294,3.343,3.343,0,0,1,3.042,4.806l1.8-1.789A3.384,3.384,0,0,1,7.331,2a3.357,3.357,0,0,1,2.5,1.042l2.525,2.537a3.384,3.384,0,0,1,1.017,2.488,3.448,3.448,0,0,1-1.078,2.561l1.078,1.078a3.551,3.551,0,0,1,5.049-.049l2.549,2.549A3.4,3.4,0,0,1,22,16.706Z" />
8
+ <Path d="M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z" />
9
9
  </SVG>
10
10
  );
@@ -5,6 +5,6 @@ import { Path, SVG } from '@wordpress/primitives';
5
5
 
6
6
  export const MailIcon = () => (
7
7
  <SVG width="24" height="24" viewBox="0 0 24 24" version="1.1">
8
- <Path d="M20,4H4C2.895,4,2,4.895,2,6v12c0,1.105,0.895,2,2,2h16c1.105,0,2-0.895,2-2V6C22,4.895,21.105,4,20,4z M20,8.236l-8,4.882 L4,8.236V6h16V8.236z" />
8
+ <Path d="M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm.5 12c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V9.8l7.5 5.6 7.5-5.6V17zm0-9.1L12 13.6 4.5 7.9V7c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v.9z" />
9
9
  </SVG>
10
10
  );
@@ -144,7 +144,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
144
144
  ),
145
145
  'chain' => array(
146
146
  'name' => 'Link',
147
- 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.647,16.706a1.134,1.134,0,0,0-.343-.833l-2.549-2.549a1.134,1.134,0,0,0-.833-.343,1.168,1.168,0,0,0-.883.392l.233.226q.2.189.264.264a2.922,2.922,0,0,1,.184.233.986.986,0,0,1,.159.312,1.242,1.242,0,0,1,.043.337,1.172,1.172,0,0,1-1.176,1.176,1.237,1.237,0,0,1-.337-.043,1,1,0,0,1-.312-.159,2.76,2.76,0,0,1-.233-.184q-.073-.068-.264-.264l-.226-.233a1.19,1.19,0,0,0-.4.895,1.134,1.134,0,0,0,.343.833L15.837,19.3a1.13,1.13,0,0,0,.833.331,1.18,1.18,0,0,0,.833-.318l1.8-1.789a1.12,1.12,0,0,0,.343-.821Zm-8.615-8.64a1.134,1.134,0,0,0-.343-.833L8.163,4.7a1.134,1.134,0,0,0-.833-.343,1.184,1.184,0,0,0-.833.331L4.7,6.473a1.12,1.12,0,0,0-.343.821,1.134,1.134,0,0,0,.343.833l2.549,2.549a1.13,1.13,0,0,0,.833.331,1.184,1.184,0,0,0,.883-.38L8.728,10.4q-.2-.189-.264-.264A2.922,2.922,0,0,1,8.28,9.9a.986.986,0,0,1-.159-.312,1.242,1.242,0,0,1-.043-.337A1.172,1.172,0,0,1,9.254,8.079a1.237,1.237,0,0,1,.337.043,1,1,0,0,1,.312.159,2.761,2.761,0,0,1,.233.184q.073.068.264.264l.226.233a1.19,1.19,0,0,0,.4-.895ZM22,16.706a3.343,3.343,0,0,1-1.042,2.488l-1.8,1.789a3.536,3.536,0,0,1-4.988-.025l-2.525-2.537a3.384,3.384,0,0,1-1.017-2.488,3.448,3.448,0,0,1,1.078-2.561l-1.078-1.078a3.434,3.434,0,0,1-2.549,1.078,3.4,3.4,0,0,1-2.5-1.029L3.029,9.794A3.4,3.4,0,0,1,2,7.294,3.343,3.343,0,0,1,3.042,4.806l1.8-1.789A3.384,3.384,0,0,1,7.331,2a3.357,3.357,0,0,1,2.5,1.042l2.525,2.537a3.384,3.384,0,0,1,1.017,2.488,3.448,3.448,0,0,1-1.078,2.561l1.078,1.078a3.551,3.551,0,0,1,5.049-.049l2.549,2.549A3.4,3.4,0,0,1,22,16.706Z"></path></svg>',
147
+ 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M15.6,7.2H14v1.5h1.6c2,0,3.7,1.7,3.7,3.7s-1.7,3.7-3.7,3.7H14v1.5h1.6c2.8,0,5.2-2.3,5.2-5.2,0-2.9-2.3-5.2-5.2-5.2zM4.7,12.4c0-2,1.7-3.7,3.7-3.7H10V7.2H8.4c-2.9,0-5.2,2.3-5.2,5.2,0,2.9,2.3,5.2,5.2,5.2H10v-1.5H8.4c-2,0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z"></path></svg>',
148
148
  ),
149
149
  'codepen' => array(
150
150
  'name' => 'CodePen',
@@ -208,7 +208,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
208
208
  ),
209
209
  'mail' => array(
210
210
  'name' => 'Mail',
211
- 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M20,4H4C2.895,4,2,4.895,2,6v12c0,1.105,0.895,2,2,2h16c1.105,0,2-0.895,2-2V6C22,4.895,21.105,4,20,4z M20,8.236l-8,4.882 L4,8.236V6h16V8.236z"></path></svg>',
211
+ 'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19,5H5c-1.1,0-2,.9-2,2v10c0,1.1.9,2,2,2h14c1.1,0,2-.9,2-2V7c0-1.1-.9-2-2-2zm.5,12c0,.3-.2.5-.5.5H5c-.3,0-.5-.2-.5-.5V9.8l7.5,5.6,7.5-5.6V17zm0-9.1L12,13.6,4.5,7.9V7c0-.3.2-.5.5-.5h14c.3,0,.5.2.5.5v.9z"></path></svg>',
212
212
  ),
213
213
  'mastodon' => array(
214
214
  'name' => 'Mastodon',
@@ -2,14 +2,21 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { InspectorControls, useSetting } from '@wordpress/block-editor';
6
5
  import {
6
+ InspectorControls,
7
+ useSetting,
8
+ __experimentalSpacingSizesControl as SpacingSizesControl,
9
+ isValueSpacingPreset,
10
+ } from '@wordpress/block-editor';
11
+ import {
12
+ BaseControl,
7
13
  PanelBody,
8
14
  __experimentalUseCustomUnits as useCustomUnits,
9
15
  __experimentalUnitControl as UnitControl,
10
16
  __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
11
17
  } from '@wordpress/components';
12
18
  import { useInstanceId } from '@wordpress/compose';
19
+ import { View } from '@wordpress/primitives';
13
20
 
14
21
  /**
15
22
  * Internal dependencies
@@ -18,7 +25,7 @@ import { MIN_SPACER_SIZE } from './constants';
18
25
 
19
26
  function DimensionInput( { label, onChange, isResizing, value = '' } ) {
20
27
  const inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );
21
-
28
+ const spacingSizes = useSetting( 'spacing.spacingSizes' );
22
29
  // In most contexts the spacer size cannot meaningfully be set to a
23
30
  // percentage, since this is relative to the parent container. This
24
31
  // unit is disabled from the UI.
@@ -38,28 +45,46 @@ function DimensionInput( { label, onChange, isResizing, value = '' } ) {
38
45
  } );
39
46
 
40
47
  const handleOnChange = ( unprocessedValue ) => {
41
- onChange( unprocessedValue );
48
+ onChange( unprocessedValue.all );
42
49
  };
43
50
 
44
51
  // Force the unit to update to `px` when the Spacer is being resized.
45
52
  const [ parsedQuantity, parsedUnit ] =
46
53
  parseQuantityAndUnitFromRawValue( value );
47
- const computedValue = [
48
- parsedQuantity,
49
- isResizing ? 'px' : parsedUnit,
50
- ].join( '' );
54
+ const computedValue = isValueSpacingPreset( value )
55
+ ? value
56
+ : [ parsedQuantity, isResizing ? 'px' : parsedUnit ].join( '' );
51
57
 
52
58
  return (
53
- <UnitControl
54
- label={ label }
55
- id={ inputId }
56
- isResetValueOnUnitChange
57
- min={ MIN_SPACER_SIZE }
58
- onChange={ handleOnChange }
59
- __unstableInputWidth={ '80px' }
60
- value={ computedValue }
61
- units={ units }
62
- />
59
+ <>
60
+ { ( ! spacingSizes || spacingSizes?.length === 0 ) && (
61
+ <BaseControl label={ label } id={ inputId }>
62
+ <UnitControl
63
+ id={ inputId }
64
+ isResetValueOnUnitChange
65
+ min={ MIN_SPACER_SIZE }
66
+ onChange={ handleOnChange }
67
+ style={ { maxWidth: 80 } }
68
+ value={ computedValue }
69
+ units={ units }
70
+ />
71
+ </BaseControl>
72
+ ) }
73
+
74
+ { spacingSizes?.length > 0 && (
75
+ <View className="tools-panel-item-spacing">
76
+ <SpacingSizesControl
77
+ values={ { all: computedValue } }
78
+ onChange={ handleOnChange }
79
+ label={ label }
80
+ sides={ [ 'all' ] }
81
+ units={ units }
82
+ allowReset={ false }
83
+ splitOnAxis={ false }
84
+ />
85
+ </View>
86
+ ) }
87
+ </>
63
88
  );
64
89
  }
65
90
 
@@ -6,10 +6,17 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { useBlockProps } from '@wordpress/block-editor';
9
+ import {
10
+ useBlockProps,
11
+ useSetting,
12
+ getCustomValueFromPreset,
13
+ getSpacingPresetCssVar,
14
+ store as blockEditorStore,
15
+ } from '@wordpress/block-editor';
10
16
  import { ResizableBox } from '@wordpress/components';
11
17
  import { useState, useEffect } from '@wordpress/element';
12
18
  import { View } from '@wordpress/primitives';
19
+ import { useSelect } from '@wordpress/data';
13
20
 
14
21
  /**
15
22
  * Internal dependencies
@@ -79,16 +86,28 @@ const SpacerEdit = ( {
79
86
  toggleSelection,
80
87
  context,
81
88
  __unstableParentLayout: parentLayout,
89
+ className,
82
90
  } ) => {
91
+ const disableCustomSpacingSizes = useSelect( ( select ) => {
92
+ const editorSettings = select( blockEditorStore ).getSettings();
93
+ return editorSettings?.disableCustomSpacingSizes;
94
+ } );
83
95
  const { orientation } = context;
84
96
  const { orientation: parentOrientation, type } = parentLayout || {};
97
+ // Check if the spacer is inside a flex container.
98
+ const isFlexLayout = type === 'flex';
85
99
  // If the spacer is inside a flex container, it should either inherit the orientation
86
100
  // of the parent or use the flex default orientation.
87
101
  const inheritedOrientation =
88
- ! parentOrientation && type === 'flex'
102
+ ! parentOrientation && isFlexLayout
89
103
  ? 'horizontal'
90
104
  : parentOrientation || orientation;
91
- const { height, width } = attributes;
105
+ const { height, width, style: blockStyle = {} } = attributes;
106
+
107
+ const { layout = {} } = blockStyle;
108
+ const { selfStretch, flexSize } = layout;
109
+
110
+ const spacingSizes = useSetting( 'spacing.spacingSizes' );
92
111
 
93
112
  const [ isResizing, setIsResizing ] = useState( false );
94
113
  const [ temporaryHeight, setTemporaryHeight ] = useState( null );
@@ -100,30 +119,80 @@ const SpacerEdit = ( {
100
119
  const handleOnVerticalResizeStop = ( newHeight ) => {
101
120
  onResizeStop();
102
121
 
122
+ if ( isFlexLayout ) {
123
+ setAttributes( {
124
+ style: {
125
+ ...blockStyle,
126
+ layout: {
127
+ ...layout,
128
+ flexSize: newHeight,
129
+ selfStretch: 'fixed',
130
+ },
131
+ },
132
+ } );
133
+ }
134
+
103
135
  setAttributes( { height: newHeight } );
104
136
  setTemporaryHeight( null );
105
137
  };
106
138
 
107
139
  const handleOnHorizontalResizeStop = ( newWidth ) => {
108
140
  onResizeStop();
141
+
142
+ if ( isFlexLayout ) {
143
+ setAttributes( {
144
+ style: {
145
+ ...blockStyle,
146
+ layout: {
147
+ ...layout,
148
+ flexSize: newWidth,
149
+ selfStretch: 'fixed',
150
+ },
151
+ },
152
+ } );
153
+ }
154
+
109
155
  setAttributes( { width: newWidth } );
110
156
  setTemporaryWidth( null );
111
157
  };
112
158
 
159
+ const getHeightForVerticalBlocks = () => {
160
+ if ( isFlexLayout ) {
161
+ return undefined;
162
+ }
163
+ return temporaryHeight || getSpacingPresetCssVar( height ) || undefined;
164
+ };
165
+
166
+ const getWidthForHorizontalBlocks = () => {
167
+ if ( isFlexLayout ) {
168
+ return undefined;
169
+ }
170
+ return temporaryWidth || getSpacingPresetCssVar( width ) || undefined;
171
+ };
172
+
173
+ const sizeConditionalOnOrientation =
174
+ inheritedOrientation === 'horizontal'
175
+ ? temporaryWidth || flexSize
176
+ : temporaryHeight || flexSize;
177
+
113
178
  const style = {
114
179
  height:
115
180
  inheritedOrientation === 'horizontal'
116
181
  ? 24
117
- : temporaryHeight || height || undefined,
182
+ : getHeightForVerticalBlocks(),
118
183
  width:
119
184
  inheritedOrientation === 'horizontal'
120
- ? temporaryWidth || width || undefined
185
+ ? getWidthForHorizontalBlocks()
121
186
  : undefined,
122
187
  // In vertical flex containers, the spacer shrinks to nothing without a minimum width.
123
188
  minWidth:
124
- inheritedOrientation === 'vertical' && type === 'flex'
189
+ inheritedOrientation === 'vertical' && isFlexLayout
125
190
  ? 48
126
191
  : undefined,
192
+ // Add flex-basis so temporary sizes are respected.
193
+ flexBasis: isFlexLayout ? sizeConditionalOnOrientation : undefined,
194
+ // Remove flex-grow when resizing.
195
+ flexGrow: isFlexLayout && isResizing ? 0 : undefined,
127
196
  };
128
197
 
129
198
  const resizableBoxWithOrientation = ( blockOrientation ) => {
@@ -179,26 +248,115 @@ const SpacerEdit = ( {
179
248
  };
180
249
 
181
250
  useEffect( () => {
182
- if ( inheritedOrientation === 'horizontal' && ! width ) {
251
+ if (
252
+ isFlexLayout &&
253
+ selfStretch !== 'fill' &&
254
+ selfStretch !== 'fit' &&
255
+ ! flexSize
256
+ ) {
257
+ if ( inheritedOrientation === 'horizontal' ) {
258
+ // If spacer is moving from a vertical container to a horizontal container,
259
+ // it might not have width but have height instead.
260
+ const newSize =
261
+ getCustomValueFromPreset( width, spacingSizes ) ||
262
+ getCustomValueFromPreset( height, spacingSizes ) ||
263
+ '100px';
264
+ setAttributes( {
265
+ width: '0px',
266
+ style: {
267
+ ...blockStyle,
268
+ layout: {
269
+ ...layout,
270
+ flexSize: newSize,
271
+ selfStretch: 'fixed',
272
+ },
273
+ },
274
+ } );
275
+ } else {
276
+ const newSize =
277
+ getCustomValueFromPreset( height, spacingSizes ) ||
278
+ getCustomValueFromPreset( width, spacingSizes ) ||
279
+ '100px';
280
+ setAttributes( {
281
+ height: '0px',
282
+ style: {
283
+ ...blockStyle,
284
+ layout: {
285
+ ...layout,
286
+ flexSize: newSize,
287
+ selfStretch: 'fixed',
288
+ },
289
+ },
290
+ } );
291
+ }
292
+ } else if (
293
+ isFlexLayout &&
294
+ ( selfStretch === 'fill' || selfStretch === 'fit' )
295
+ ) {
296
+ if ( inheritedOrientation === 'horizontal' ) {
297
+ setAttributes( {
298
+ width: undefined,
299
+ } );
300
+ } else {
301
+ setAttributes( {
302
+ height: undefined,
303
+ } );
304
+ }
305
+ } else if ( ! isFlexLayout && ( selfStretch || flexSize ) ) {
306
+ if ( inheritedOrientation === 'horizontal' ) {
307
+ setAttributes( {
308
+ width: flexSize,
309
+ } );
310
+ } else {
311
+ setAttributes( {
312
+ height: flexSize,
313
+ } );
314
+ }
183
315
  setAttributes( {
184
- height: '0px',
185
- width: '72px',
316
+ style: {
317
+ ...blockStyle,
318
+ layout: {
319
+ ...layout,
320
+ flexSize: undefined,
321
+ selfStretch: undefined,
322
+ },
323
+ },
186
324
  } );
187
325
  }
188
- }, [] );
326
+ }, [
327
+ blockStyle,
328
+ flexSize,
329
+ height,
330
+ inheritedOrientation,
331
+ isFlexLayout,
332
+ layout,
333
+ selfStretch,
334
+ setAttributes,
335
+ spacingSizes,
336
+ width,
337
+ ] );
189
338
 
190
339
  return (
191
340
  <>
192
- <View { ...useBlockProps( { style } ) }>
341
+ <View
342
+ { ...useBlockProps( {
343
+ style,
344
+ className: classnames( className, {
345
+ 'custom-sizes-disabled': disableCustomSpacingSizes,
346
+ } ),
347
+ } ) }
348
+ >
193
349
  { resizableBoxWithOrientation( inheritedOrientation ) }
194
350
  </View>
195
- <SpacerControls
196
- setAttributes={ setAttributes }
197
- height={ temporaryHeight || height }
198
- width={ temporaryWidth || width }
199
- orientation={ inheritedOrientation }
200
- isResizing={ isResizing }
201
- />
351
+ { ! isFlexLayout && (
352
+ <SpacerControls
353
+ setAttributes={ setAttributes }
354
+ height={ temporaryHeight || height }
355
+ width={ temporaryWidth || width }
356
+ orientation={ inheritedOrientation }
357
+ isResizing={ isResizing }
358
+ />
359
+ ) }
202
360
  </>
203
361
  );
204
362
  };
@@ -17,7 +17,8 @@
17
17
  }
18
18
 
19
19
  .wp-block-spacer.is-hovered .block-library-spacer__resize-container,
20
- .block-library-spacer__resize-container.has-show-handle {
20
+ .block-library-spacer__resize-container.has-show-handle,
21
+ .wp-block-spacer.is-selected.custom-sizes-disabled {
21
22
  background: rgba($black, 0.1);
22
23
 
23
24
  .is-dark-theme & {
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useBlockProps } from '@wordpress/block-editor';
4
+ import { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';
5
5
 
6
6
  export default function save( { attributes: { height, width } } ) {
7
7
  return (
8
8
  <div
9
9
  { ...useBlockProps.save( {
10
10
  style: {
11
- height,
12
- width,
11
+ height: getSpacingPresetCssVar( height ),
12
+ width: getSpacingPresetCssVar( width ),
13
13
  },
14
14
  'aria-hidden': true,
15
15
  } ) }
package/src/style.scss CHANGED
@@ -11,6 +11,8 @@
11
11
  @import "./comments-pagination/style.scss";
12
12
  @import "./comment-template/style.scss";
13
13
  @import "./cover/style.scss";
14
+ @import "./details/style.scss";
15
+ @import "./details-summary/style.scss";
14
16
  @import "./embed/style.scss";
15
17
  @import "./file/style.scss";
16
18
  @import "./gallery/style.scss";