@wordpress/block-library 8.18.1-next.5a1d1283.0 → 8.19.1

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 (386) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -1
  3. package/build/block/edit.js +53 -2
  4. package/build/block/edit.js.map +1 -1
  5. package/build/button/edit.js +7 -4
  6. package/build/button/edit.js.map +1 -1
  7. package/build/button/index.js +11 -2
  8. package/build/button/index.js.map +1 -1
  9. package/build/button/save.js +10 -4
  10. package/build/button/save.js.map +1 -1
  11. package/build/buttons/edit.js +12 -3
  12. package/build/buttons/edit.js.map +1 -1
  13. package/build/code/edit.js +8 -2
  14. package/build/code/edit.js.map +1 -1
  15. package/build/code/index.js +7 -1
  16. package/build/code/index.js.map +1 -1
  17. package/build/column/index.js +1 -0
  18. package/build/column/index.js.map +1 -1
  19. package/build/columns/index.js +2 -0
  20. package/build/columns/index.js.map +1 -1
  21. package/build/file/edit.native.js +1 -1
  22. package/build/file/edit.native.js.map +1 -1
  23. package/build/file/index.js +2 -1
  24. package/build/file/index.js.map +1 -1
  25. package/build/file/utils/index.js +1 -15
  26. package/build/file/utils/index.js.map +1 -1
  27. package/build/file/view.js +14 -1
  28. package/build/file/view.js.map +1 -1
  29. package/build/footnotes/edit.js +12 -2
  30. package/build/footnotes/edit.js.map +1 -1
  31. package/build/gallery/edit.js +1 -1
  32. package/build/gallery/edit.js.map +1 -1
  33. package/build/group/edit.js +0 -1
  34. package/build/group/edit.js.map +1 -1
  35. package/build/group/index.js +4 -0
  36. package/build/group/index.js.map +1 -1
  37. package/build/heading/edit.js +0 -1
  38. package/build/heading/edit.js.map +1 -1
  39. package/build/heading/index.js +2 -0
  40. package/build/heading/index.js.map +1 -1
  41. package/build/heading/transforms.js +3 -6
  42. package/build/heading/transforms.js.map +1 -1
  43. package/build/image/deprecated.js +191 -7
  44. package/build/image/deprecated.js.map +1 -1
  45. package/build/image/edit.js +27 -12
  46. package/build/image/edit.js.map +1 -1
  47. package/build/image/image.js +75 -40
  48. package/build/image/image.js.map +1 -1
  49. package/build/image/index.js +7 -4
  50. package/build/image/index.js.map +1 -1
  51. package/build/image/{view-interactivity.js → view.js} +1 -1
  52. package/build/image/view.js.map +1 -0
  53. package/build/list/deprecated.js +93 -1
  54. package/build/list/deprecated.js.map +1 -1
  55. package/build/list/edit.js +10 -10
  56. package/build/list/edit.js.map +1 -1
  57. package/build/list/ordered-list-settings.js +10 -10
  58. package/build/list/ordered-list-settings.js.map +1 -1
  59. package/build/list/save.js +4 -2
  60. package/build/list/save.js.map +1 -1
  61. package/build/list/utils.js +21 -2
  62. package/build/list/utils.js.map +1 -1
  63. package/build/navigation/constants.js +1 -1
  64. package/build/navigation/constants.js.map +1 -1
  65. package/build/navigation/index.js +4 -2
  66. package/build/navigation/index.js.map +1 -1
  67. package/build/navigation/view.js +168 -82
  68. package/build/navigation/view.js.map +1 -1
  69. package/build/navigation-link/edit.js +3 -9
  70. package/build/navigation-link/edit.js.map +1 -1
  71. package/build/navigation-link/transforms.js +24 -0
  72. package/build/navigation-link/transforms.js.map +1 -1
  73. package/build/page-list/edit.js +2 -1
  74. package/build/page-list/edit.js.map +1 -1
  75. package/build/pattern/edit.js +2 -0
  76. package/build/pattern/edit.js.map +1 -1
  77. package/build/post-comments-form/edit.js +10 -2
  78. package/build/post-comments-form/edit.js.map +1 -1
  79. package/build/post-comments-form/form.js +5 -3
  80. package/build/post-comments-form/form.js.map +1 -1
  81. package/build/post-content/edit.js +8 -7
  82. package/build/post-content/edit.js.map +1 -1
  83. package/build/post-content/index.js +3 -0
  84. package/build/post-content/index.js.map +1 -1
  85. package/build/post-featured-image/overlay.js +2 -1
  86. package/build/post-featured-image/overlay.js.map +1 -1
  87. package/build/preformatted/edit.js +4 -1
  88. package/build/preformatted/edit.js.map +1 -1
  89. package/build/preformatted/index.js +1 -1
  90. package/build/preformatted/index.js.map +1 -1
  91. package/build/pullquote/deprecated.js +6 -7
  92. package/build/pullquote/deprecated.js.map +1 -1
  93. package/build/query/edit/enhanced-pagination-modal.js +56 -0
  94. package/build/query/edit/enhanced-pagination-modal.js.map +1 -0
  95. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +42 -0
  96. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
  97. package/build/query/edit/inspector-controls/index.js +8 -25
  98. package/build/query/edit/inspector-controls/index.js.map +1 -1
  99. package/build/query/edit/query-content.js +8 -2
  100. package/build/query/edit/query-content.js.map +1 -1
  101. package/build/query/utils.js +19 -0
  102. package/build/query/utils.js.map +1 -1
  103. package/build/query/view.js +21 -6
  104. package/build/query/view.js.map +1 -1
  105. package/build/search/index.js +1 -0
  106. package/build/search/index.js.map +1 -1
  107. package/build/search/view.js +81 -150
  108. package/build/search/view.js.map +1 -1
  109. package/build/social-link/edit.native.js +3 -1
  110. package/build/social-link/edit.native.js.map +1 -1
  111. package/build/table/edit.js +7 -7
  112. package/build/table/edit.js.map +1 -1
  113. package/build/table-of-contents/edit.js +2 -130
  114. package/build/table-of-contents/edit.js.map +1 -1
  115. package/build/table-of-contents/hooks.js +145 -0
  116. package/build/table-of-contents/hooks.js.map +1 -0
  117. package/build/table-of-contents/index.js +2 -1
  118. package/build/table-of-contents/index.js.map +1 -1
  119. package/build/verse/edit.js +4 -1
  120. package/build/verse/edit.js.map +1 -1
  121. package/build/verse/index.js +1 -1
  122. package/build/verse/index.js.map +1 -1
  123. package/build-module/block/edit.js +54 -3
  124. package/build-module/block/edit.js.map +1 -1
  125. package/build-module/button/edit.js +7 -4
  126. package/build-module/button/edit.js.map +1 -1
  127. package/build-module/button/index.js +11 -2
  128. package/build-module/button/index.js.map +1 -1
  129. package/build-module/button/save.js +10 -4
  130. package/build-module/button/save.js.map +1 -1
  131. package/build-module/buttons/edit.js +12 -3
  132. package/build-module/buttons/edit.js.map +1 -1
  133. package/build-module/code/edit.js +8 -2
  134. package/build-module/code/edit.js.map +1 -1
  135. package/build-module/code/index.js +7 -1
  136. package/build-module/code/index.js.map +1 -1
  137. package/build-module/column/index.js +1 -0
  138. package/build-module/column/index.js.map +1 -1
  139. package/build-module/columns/index.js +2 -0
  140. package/build-module/columns/index.js.map +1 -1
  141. package/build-module/file/edit.native.js +1 -1
  142. package/build-module/file/edit.native.js.map +1 -1
  143. package/build-module/file/index.js +2 -1
  144. package/build-module/file/index.js.map +1 -1
  145. package/build-module/file/utils/index.js +0 -13
  146. package/build-module/file/utils/index.js.map +1 -1
  147. package/build-module/file/view.js +14 -2
  148. package/build-module/file/view.js.map +1 -1
  149. package/build-module/footnotes/edit.js +12 -2
  150. package/build-module/footnotes/edit.js.map +1 -1
  151. package/build-module/gallery/edit.js +1 -1
  152. package/build-module/gallery/edit.js.map +1 -1
  153. package/build-module/group/edit.js +0 -1
  154. package/build-module/group/edit.js.map +1 -1
  155. package/build-module/group/index.js +4 -0
  156. package/build-module/group/index.js.map +1 -1
  157. package/build-module/heading/edit.js +0 -1
  158. package/build-module/heading/edit.js.map +1 -1
  159. package/build-module/heading/index.js +2 -0
  160. package/build-module/heading/index.js.map +1 -1
  161. package/build-module/heading/transforms.js +3 -6
  162. package/build-module/heading/transforms.js.map +1 -1
  163. package/build-module/image/deprecated.js +191 -7
  164. package/build-module/image/deprecated.js.map +1 -1
  165. package/build-module/image/edit.js +27 -12
  166. package/build-module/image/edit.js.map +1 -1
  167. package/build-module/image/image.js +77 -42
  168. package/build-module/image/image.js.map +1 -1
  169. package/build-module/image/index.js +7 -4
  170. package/build-module/image/index.js.map +1 -1
  171. package/build-module/image/{view-interactivity.js → view.js} +1 -1
  172. package/build-module/image/view.js.map +1 -0
  173. package/build-module/list/deprecated.js +95 -3
  174. package/build-module/list/deprecated.js.map +1 -1
  175. package/build-module/list/edit.js +10 -10
  176. package/build-module/list/edit.js.map +1 -1
  177. package/build-module/list/ordered-list-settings.js +10 -10
  178. package/build-module/list/ordered-list-settings.js.map +1 -1
  179. package/build-module/list/save.js +4 -2
  180. package/build-module/list/save.js.map +1 -1
  181. package/build-module/list/utils.js +20 -2
  182. package/build-module/list/utils.js.map +1 -1
  183. package/build-module/navigation/constants.js +1 -1
  184. package/build-module/navigation/constants.js.map +1 -1
  185. package/build-module/navigation/index.js +4 -2
  186. package/build-module/navigation/index.js.map +1 -1
  187. package/build-module/navigation/view.js +168 -83
  188. package/build-module/navigation/view.js.map +1 -1
  189. package/build-module/navigation-link/edit.js +3 -9
  190. package/build-module/navigation-link/edit.js.map +1 -1
  191. package/build-module/navigation-link/transforms.js +24 -0
  192. package/build-module/navigation-link/transforms.js.map +1 -1
  193. package/build-module/page-list/edit.js +2 -1
  194. package/build-module/page-list/edit.js.map +1 -1
  195. package/build-module/pattern/edit.js +2 -0
  196. package/build-module/pattern/edit.js.map +1 -1
  197. package/build-module/post-comments-form/edit.js +10 -2
  198. package/build-module/post-comments-form/edit.js.map +1 -1
  199. package/build-module/post-comments-form/form.js +5 -3
  200. package/build-module/post-comments-form/form.js.map +1 -1
  201. package/build-module/post-content/edit.js +8 -7
  202. package/build-module/post-content/edit.js.map +1 -1
  203. package/build-module/post-content/index.js +3 -0
  204. package/build-module/post-content/index.js.map +1 -1
  205. package/build-module/post-featured-image/overlay.js +2 -1
  206. package/build-module/post-featured-image/overlay.js.map +1 -1
  207. package/build-module/preformatted/edit.js +4 -1
  208. package/build-module/preformatted/edit.js.map +1 -1
  209. package/build-module/preformatted/index.js +1 -1
  210. package/build-module/preformatted/index.js.map +1 -1
  211. package/build-module/pullquote/deprecated.js +6 -7
  212. package/build-module/pullquote/deprecated.js.map +1 -1
  213. package/build-module/query/edit/enhanced-pagination-modal.js +50 -0
  214. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -0
  215. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +35 -0
  216. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
  217. package/build-module/query/edit/inspector-controls/index.js +9 -26
  218. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  219. package/build-module/query/edit/query-content.js +8 -2
  220. package/build-module/query/edit/query-content.js.map +1 -1
  221. package/build-module/query/utils.js +17 -0
  222. package/build-module/query/utils.js.map +1 -1
  223. package/build-module/query/view.js +21 -6
  224. package/build-module/query/view.js.map +1 -1
  225. package/build-module/search/index.js +1 -0
  226. package/build-module/search/index.js.map +1 -1
  227. package/build-module/search/view.js +81 -151
  228. package/build-module/search/view.js.map +1 -1
  229. package/build-module/social-link/edit.native.js +3 -1
  230. package/build-module/social-link/edit.native.js.map +1 -1
  231. package/build-module/table/edit.js +7 -7
  232. package/build-module/table/edit.js.map +1 -1
  233. package/build-module/table-of-contents/edit.js +3 -131
  234. package/build-module/table-of-contents/edit.js.map +1 -1
  235. package/build-module/table-of-contents/hooks.js +137 -0
  236. package/build-module/table-of-contents/hooks.js.map +1 -0
  237. package/build-module/table-of-contents/index.js +2 -1
  238. package/build-module/table-of-contents/index.js.map +1 -1
  239. package/build-module/verse/edit.js +4 -1
  240. package/build-module/verse/edit.js.map +1 -1
  241. package/build-module/verse/index.js +1 -1
  242. package/build-module/verse/index.js.map +1 -1
  243. package/build-style/cover/style-rtl.css +9 -0
  244. package/build-style/cover/style.css +9 -0
  245. package/build-style/editor-rtl.css +15 -9
  246. package/build-style/editor.css +15 -9
  247. package/build-style/file/style-rtl.css +5 -0
  248. package/build-style/file/style.css +5 -0
  249. package/build-style/heading/style-rtl.css +13 -0
  250. package/build-style/heading/style.css +13 -0
  251. package/build-style/navigation-link/editor-rtl.css +0 -9
  252. package/build-style/navigation-link/editor.css +0 -9
  253. package/build-style/paragraph/editor-rtl.css +5 -0
  254. package/build-style/paragraph/editor.css +5 -0
  255. package/build-style/paragraph/style-rtl.css +5 -0
  256. package/build-style/paragraph/style.css +5 -0
  257. package/build-style/post-navigation-link/style-rtl.css +3 -0
  258. package/build-style/post-navigation-link/style.css +3 -0
  259. package/build-style/query/editor-rtl.css +10 -0
  260. package/build-style/query/editor.css +10 -0
  261. package/build-style/query/style-rtl.css +1 -1
  262. package/build-style/query/style.css +1 -1
  263. package/build-style/reset-rtl.css +27 -27
  264. package/build-style/reset.css +27 -27
  265. package/build-style/style-rtl.css +35 -0
  266. package/build-style/style.css +35 -0
  267. package/package.json +33 -34
  268. package/src/audio/test/__snapshots__/edit.native.js.snap +78 -106
  269. package/src/avatar/index.php +2 -2
  270. package/src/block/edit.js +58 -2
  271. package/src/block/test/edit.native.js +2 -3
  272. package/src/button/block.json +11 -2
  273. package/src/button/edit.js +27 -11
  274. package/src/button/save.js +10 -4
  275. package/src/buttons/edit.js +13 -3
  276. package/src/buttons/test/edit.native.js +28 -24
  277. package/src/calendar/index.php +2 -2
  278. package/src/code/block.json +2 -1
  279. package/src/code/edit.js +13 -1
  280. package/src/code/index.js +5 -0
  281. package/src/column/block.json +1 -0
  282. package/src/columns/block.json +2 -0
  283. package/src/comment-template/index.php +1 -1
  284. package/src/comments-pagination-next/index.php +1 -1
  285. package/src/comments-pagination-previous/index.php +1 -1
  286. package/src/cover/style.scss +12 -1
  287. package/src/cover/test/edit.js +10 -10
  288. package/src/cover/test/edit.native.js +18 -27
  289. package/src/embed/test/index.native.js +30 -45
  290. package/src/file/block.json +2 -1
  291. package/src/file/edit.native.js +1 -1
  292. package/src/file/index.php +21 -21
  293. package/src/file/style.scss +6 -1
  294. package/src/file/test/__snapshots__/edit.native.js.snap +162 -218
  295. package/src/file/utils/index.js +0 -15
  296. package/src/file/view.js +14 -5
  297. package/src/footnotes/edit.js +13 -1
  298. package/src/gallery/edit.js +1 -1
  299. package/src/gallery/index.php +1 -1
  300. package/src/group/block.json +4 -0
  301. package/src/group/edit.js +0 -1
  302. package/src/heading/block.json +2 -0
  303. package/src/heading/edit.js +0 -1
  304. package/src/heading/style.scss +4 -0
  305. package/src/heading/transforms.js +1 -6
  306. package/src/image/block.json +7 -4
  307. package/src/image/deprecated.js +210 -7
  308. package/src/image/edit.js +43 -29
  309. package/src/image/image.js +86 -43
  310. package/src/image/index.php +253 -28
  311. package/src/latest-posts/index.php +1 -1
  312. package/src/list/deprecated.js +84 -3
  313. package/src/list/edit.js +6 -3
  314. package/src/list/ordered-list-settings.js +20 -5
  315. package/src/list/save.js +10 -1
  316. package/src/list/test/edit.native.js +2 -4
  317. package/src/list/utils.js +22 -1
  318. package/src/navigation/block.json +4 -2
  319. package/src/navigation/constants.js +1 -0
  320. package/src/navigation/index.php +87 -123
  321. package/src/navigation/view.js +192 -96
  322. package/src/navigation-link/edit.js +21 -36
  323. package/src/navigation-link/editor.scss +0 -8
  324. package/src/navigation-link/transforms.js +22 -0
  325. package/src/page-list/edit.js +2 -1
  326. package/src/paragraph/editor.scss +5 -0
  327. package/src/paragraph/style.scss +5 -0
  328. package/src/pattern/edit.js +1 -0
  329. package/src/pattern/index.php +5 -5
  330. package/src/post-comments-form/edit.js +10 -0
  331. package/src/post-comments-form/form.js +7 -1
  332. package/src/post-content/block.json +3 -0
  333. package/src/post-content/edit.js +14 -6
  334. package/src/post-excerpt/index.php +2 -2
  335. package/src/post-featured-image/index.php +2 -2
  336. package/src/post-featured-image/overlay.js +1 -0
  337. package/src/post-navigation-link/index.php +0 -5
  338. package/src/post-navigation-link/style.scss +4 -0
  339. package/src/post-template/index.php +1 -1
  340. package/src/post-terms/index.php +5 -2
  341. package/src/preformatted/edit.js +5 -0
  342. package/src/preformatted/index.js +1 -1
  343. package/src/pullquote/deprecated.js +8 -13
  344. package/src/query/edit/enhanced-pagination-modal.js +65 -0
  345. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +49 -0
  346. package/src/query/edit/inspector-controls/index.js +9 -45
  347. package/src/query/edit/query-content.js +8 -0
  348. package/src/query/editor.scss +10 -0
  349. package/src/query/index.php +31 -16
  350. package/src/query/style.scss +2 -2
  351. package/src/query/utils.js +22 -0
  352. package/src/query/view.js +19 -10
  353. package/src/query-pagination-next/index.php +2 -1
  354. package/src/query-pagination-previous/index.php +2 -1
  355. package/src/reset.scss +1 -1
  356. package/src/search/block.json +1 -0
  357. package/src/search/index.php +47 -4
  358. package/src/search/test/__snapshots__/edit.native.js.snap +265 -363
  359. package/src/search/view.js +70 -169
  360. package/src/social-link/edit.native.js +1 -1
  361. package/src/social-link/editor.native.scss +4 -0
  362. package/src/table/edit.js +21 -19
  363. package/src/table-of-contents/block.json +2 -1
  364. package/src/table-of-contents/edit.js +5 -162
  365. package/src/table-of-contents/hooks.js +156 -0
  366. package/src/verse/edit.js +5 -0
  367. package/src/verse/index.js +1 -1
  368. package/src/verse/test/edit.native.js +2 -3
  369. package/build/file/view-interactivity.js +0 -22
  370. package/build/file/view-interactivity.js.map +0 -1
  371. package/build/image/view-interactivity.js.map +0 -1
  372. package/build/navigation/view-interactivity.js +0 -172
  373. package/build/navigation/view-interactivity.js.map +0 -1
  374. package/build/navigation/view-modal.js +0 -115
  375. package/build/navigation/view-modal.js.map +0 -1
  376. package/build-module/file/view-interactivity.js +0 -18
  377. package/build-module/file/view-interactivity.js.map +0 -1
  378. package/build-module/image/view-interactivity.js.map +0 -1
  379. package/build-module/navigation/view-interactivity.js +0 -169
  380. package/build-module/navigation/view-interactivity.js.map +0 -1
  381. package/build-module/navigation/view-modal.js +0 -112
  382. package/build-module/navigation/view-modal.js.map +0 -1
  383. package/src/file/view-interactivity.js +0 -18
  384. package/src/navigation/view-interactivity.js +0 -196
  385. package/src/navigation/view-modal.js +0 -127
  386. /package/src/image/{view-interactivity.js → view.js} +0 -0
@@ -33,6 +33,12 @@
33
33
  "selector": "figcaption",
34
34
  "__experimentalRole": "content"
35
35
  },
36
+ "lightbox": {
37
+ "type": "object",
38
+ "enabled": {
39
+ "type": "boolean"
40
+ }
41
+ },
36
42
  "title": {
37
43
  "type": "string",
38
44
  "source": "attribute",
@@ -90,9 +96,6 @@
90
96
  },
91
97
  "supports": {
92
98
  "anchor": true,
93
- "behaviors": {
94
- "lightbox": true
95
- },
96
99
  "color": {
97
100
  "text": false,
98
101
  "background": false
@@ -128,5 +131,5 @@
128
131
  ],
129
132
  "editorStyle": "wp-block-image-editor",
130
133
  "style": "wp-block-image",
131
- "viewScript": "file:./view-interactivity.min.js"
134
+ "viewScript": "file:./view.min.js"
132
135
  }
@@ -632,9 +632,6 @@ const v6 = {
632
632
  },
633
633
  supports: {
634
634
  anchor: true,
635
- behaviors: {
636
- lightbox: true,
637
- },
638
635
  color: {
639
636
  text: false,
640
637
  background: false,
@@ -830,9 +827,6 @@ const v7 = {
830
827
  },
831
828
  supports: {
832
829
  anchor: true,
833
- behaviors: {
834
- lightbox: true,
835
- },
836
830
  color: {
837
831
  text: false,
838
832
  background: false,
@@ -947,4 +941,213 @@ const v7 = {
947
941
  },
948
942
  };
949
943
 
950
- export default [ v7, v6, v5, v4, v3, v2, v1 ];
944
+ const v8 = {
945
+ attributes: {
946
+ align: {
947
+ type: 'string',
948
+ },
949
+ behaviors: {
950
+ type: 'object',
951
+ },
952
+ url: {
953
+ type: 'string',
954
+ source: 'attribute',
955
+ selector: 'img',
956
+ attribute: 'src',
957
+ __experimentalRole: 'content',
958
+ },
959
+ alt: {
960
+ type: 'string',
961
+ source: 'attribute',
962
+ selector: 'img',
963
+ attribute: 'alt',
964
+ default: '',
965
+ __experimentalRole: 'content',
966
+ },
967
+ caption: {
968
+ type: 'string',
969
+ source: 'html',
970
+ selector: 'figcaption',
971
+ __experimentalRole: 'content',
972
+ },
973
+ title: {
974
+ type: 'string',
975
+ source: 'attribute',
976
+ selector: 'img',
977
+ attribute: 'title',
978
+ __experimentalRole: 'content',
979
+ },
980
+ href: {
981
+ type: 'string',
982
+ source: 'attribute',
983
+ selector: 'figure > a',
984
+ attribute: 'href',
985
+ __experimentalRole: 'content',
986
+ },
987
+ rel: {
988
+ type: 'string',
989
+ source: 'attribute',
990
+ selector: 'figure > a',
991
+ attribute: 'rel',
992
+ },
993
+ linkClass: {
994
+ type: 'string',
995
+ source: 'attribute',
996
+ selector: 'figure > a',
997
+ attribute: 'class',
998
+ },
999
+ id: {
1000
+ type: 'number',
1001
+ __experimentalRole: 'content',
1002
+ },
1003
+ width: {
1004
+ type: 'string',
1005
+ },
1006
+ height: {
1007
+ type: 'string',
1008
+ },
1009
+ aspectRatio: {
1010
+ type: 'string',
1011
+ },
1012
+ scale: {
1013
+ type: 'string',
1014
+ },
1015
+ sizeSlug: {
1016
+ type: 'string',
1017
+ },
1018
+ linkDestination: {
1019
+ type: 'string',
1020
+ },
1021
+ linkTarget: {
1022
+ type: 'string',
1023
+ source: 'attribute',
1024
+ selector: 'figure > a',
1025
+ attribute: 'target',
1026
+ },
1027
+ },
1028
+ supports: {
1029
+ anchor: true,
1030
+ color: {
1031
+ text: false,
1032
+ background: false,
1033
+ },
1034
+ filter: {
1035
+ duotone: true,
1036
+ },
1037
+ __experimentalBorder: {
1038
+ color: true,
1039
+ radius: true,
1040
+ width: true,
1041
+ __experimentalSkipSerialization: true,
1042
+ __experimentalDefaultControls: {
1043
+ color: true,
1044
+ radius: true,
1045
+ width: true,
1046
+ },
1047
+ },
1048
+ },
1049
+ migrate( { width, height, ...attributes } ) {
1050
+ const {
1051
+ behaviors: {
1052
+ lightbox: { enabled },
1053
+ },
1054
+ } = attributes;
1055
+ const newAttributes = {
1056
+ ...attributes,
1057
+ lightbox: {
1058
+ enabled,
1059
+ },
1060
+ };
1061
+ delete newAttributes.behaviors;
1062
+ return newAttributes;
1063
+ },
1064
+ isEligible( attributes ) {
1065
+ return !! attributes.behaviors;
1066
+ },
1067
+ save( { attributes } ) {
1068
+ const {
1069
+ url,
1070
+ alt,
1071
+ caption,
1072
+ align,
1073
+ href,
1074
+ rel,
1075
+ linkClass,
1076
+ width,
1077
+ height,
1078
+ aspectRatio,
1079
+ scale,
1080
+ id,
1081
+ linkTarget,
1082
+ sizeSlug,
1083
+ title,
1084
+ } = attributes;
1085
+
1086
+ const newRel = ! rel ? undefined : rel;
1087
+ const borderProps = getBorderClassesAndStyles( attributes );
1088
+
1089
+ const classes = classnames( {
1090
+ [ `align${ align }` ]: align,
1091
+ [ `size-${ sizeSlug }` ]: sizeSlug,
1092
+ 'is-resized': width || height,
1093
+ 'has-custom-border':
1094
+ !! borderProps.className ||
1095
+ ( borderProps.style &&
1096
+ Object.keys( borderProps.style ).length > 0 ),
1097
+ } );
1098
+
1099
+ const imageClasses = classnames( borderProps.className, {
1100
+ [ `wp-image-${ id }` ]: !! id,
1101
+ } );
1102
+
1103
+ const image = (
1104
+ <img
1105
+ src={ url }
1106
+ alt={ alt }
1107
+ className={ imageClasses || undefined }
1108
+ style={ {
1109
+ ...borderProps.style,
1110
+ aspectRatio,
1111
+ objectFit: scale,
1112
+ width,
1113
+ height,
1114
+ } }
1115
+ title={ title }
1116
+ />
1117
+ );
1118
+
1119
+ const figure = (
1120
+ <>
1121
+ { href ? (
1122
+ <a
1123
+ className={ linkClass }
1124
+ href={ href }
1125
+ target={ linkTarget }
1126
+ rel={ newRel }
1127
+ >
1128
+ { image }
1129
+ </a>
1130
+ ) : (
1131
+ image
1132
+ ) }
1133
+ { ! RichText.isEmpty( caption ) && (
1134
+ <RichText.Content
1135
+ className={ __experimentalGetElementClassName(
1136
+ 'caption'
1137
+ ) }
1138
+ tagName="figcaption"
1139
+ value={ caption }
1140
+ />
1141
+ ) }
1142
+ </>
1143
+ );
1144
+
1145
+ return (
1146
+ <figure { ...useBlockProps.save( { className: classes } ) }>
1147
+ { figure }
1148
+ </figure>
1149
+ );
1150
+ },
1151
+ };
1152
+
1153
+ export default [ v8, v7, v6, v5, v4, v3, v2, v1 ];
package/src/image/edit.js CHANGED
@@ -77,18 +77,18 @@ const isTemporaryImage = ( id, url ) => ! id && isBlobURL( url );
77
77
  export const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );
78
78
 
79
79
  /**
80
- * Checks if WP generated default image size. Size generation is skipped
80
+ * Checks if WP generated the specified image size. Size generation is skipped
81
81
  * when the image is smaller than the said size.
82
82
  *
83
83
  * @param {Object} image
84
- * @param {string} defaultSize
84
+ * @param {string} size
85
85
  *
86
86
  * @return {boolean} Whether or not it has default image size.
87
87
  */
88
- function hasDefaultSize( image, defaultSize ) {
88
+ function hasSize( image, size ) {
89
89
  return (
90
- 'url' in ( image?.sizes?.[ defaultSize ] ?? {} ) ||
91
- 'source_url' in ( image?.media_details?.sizes?.[ defaultSize ] ?? {} )
90
+ 'url' in ( image?.sizes?.[ size ] ?? {} ) ||
91
+ 'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )
92
92
  );
93
93
  }
94
94
 
@@ -111,6 +111,8 @@ export function ImageEdit( {
111
111
  width,
112
112
  height,
113
113
  sizeSlug,
114
+ aspectRatio,
115
+ scale,
114
116
  } = attributes;
115
117
  const [ temporaryURL, setTemporaryURL ] = useState();
116
118
 
@@ -166,7 +168,16 @@ export function ImageEdit( {
166
168
 
167
169
  setTemporaryURL();
168
170
 
169
- let mediaAttributes = pickRelevantMediaFiles( media, imageDefaultSize );
171
+ // Try to use the previous selected image size if its available
172
+ // otherwise try the default image size or fallback to "full"
173
+ let newSize = 'full';
174
+ if ( sizeSlug && hasSize( media, sizeSlug ) ) {
175
+ newSize = sizeSlug;
176
+ } else if ( hasSize( media, imageDefaultSize ) ) {
177
+ newSize = imageDefaultSize;
178
+ }
179
+
180
+ let mediaAttributes = pickRelevantMediaFiles( media, newSize );
170
181
 
171
182
  // If a caption text was meanwhile written by the user,
172
183
  // make sure the text is not overwritten by empty captions.
@@ -180,11 +191,7 @@ export function ImageEdit( {
180
191
  // Reset the dimension attributes if changing to a different image.
181
192
  if ( ! media.id || media.id !== id ) {
182
193
  additionalAttributes = {
183
- // Fallback to size "full" if there's no default image size.
184
- // It means the image is smaller, and the block will use a full-size URL.
185
- sizeSlug: hasDefaultSize( media, imageDefaultSize )
186
- ? imageDefaultSize
187
- : 'full',
194
+ sizeSlug: newSize,
188
195
  };
189
196
  } else {
190
197
  // Keep the same url when selecting the same file, so "Resolution"
@@ -335,7 +342,16 @@ export function ImageEdit( {
335
342
  instructions={ __(
336
343
  'Upload an image file, pick one from your media library, or add one with a URL.'
337
344
  ) }
338
- style={ isSelected ? undefined : borderProps.style }
345
+ style={ {
346
+ aspectRatio:
347
+ ! ( width && height ) && aspectRatio
348
+ ? aspectRatio
349
+ : undefined,
350
+ width: height && aspectRatio ? '100%' : width,
351
+ height: width && aspectRatio ? '100%' : height,
352
+ objectFit: scale,
353
+ ...borderProps.style,
354
+ } }
339
355
  >
340
356
  { content }
341
357
  </Placeholder>
@@ -344,23 +360,21 @@ export function ImageEdit( {
344
360
 
345
361
  return (
346
362
  <figure { ...blockProps }>
347
- { ( temporaryURL || url ) && (
348
- <Image
349
- temporaryURL={ temporaryURL }
350
- attributes={ attributes }
351
- setAttributes={ setAttributes }
352
- isSelected={ isSelected }
353
- insertBlocksAfter={ insertBlocksAfter }
354
- onReplace={ onReplace }
355
- onSelectImage={ onSelectImage }
356
- onSelectURL={ onSelectURL }
357
- onUploadError={ onUploadError }
358
- containerRef={ ref }
359
- context={ context }
360
- clientId={ clientId }
361
- blockEditingMode={ blockEditingMode }
362
- />
363
- ) }
363
+ <Image
364
+ temporaryURL={ temporaryURL }
365
+ attributes={ attributes }
366
+ setAttributes={ setAttributes }
367
+ isSelected={ isSelected }
368
+ insertBlocksAfter={ insertBlocksAfter }
369
+ onReplace={ onReplace }
370
+ onSelectImage={ onSelectImage }
371
+ onSelectURL={ onSelectURL }
372
+ onUploadError={ onUploadError }
373
+ containerRef={ ref }
374
+ context={ context }
375
+ clientId={ clientId }
376
+ blockEditingMode={ blockEditingMode }
377
+ />
364
378
  { ! url && blockEditingMode === 'default' && (
365
379
  <BlockControls group="block">
366
380
  <BlockAlignmentControl
@@ -7,6 +7,7 @@ import {
7
7
  ResizableBox,
8
8
  Spinner,
9
9
  TextareaControl,
10
+ ToggleControl,
10
11
  TextControl,
11
12
  ToolbarButton,
12
13
  ToolbarGroup,
@@ -23,6 +24,7 @@ import {
23
24
  __experimentalImageURLInputUI as ImageURLInputUI,
24
25
  MediaReplaceFlow,
25
26
  store as blockEditorStore,
27
+ useSetting,
26
28
  BlockAlignmentControl,
27
29
  __experimentalImageEditor as ImageEditor,
28
30
  __experimentalGetElementClassName,
@@ -113,6 +115,7 @@ export default function Image( {
113
115
  scale,
114
116
  linkTarget,
115
117
  sizeSlug,
118
+ lightbox,
116
119
  } = attributes;
117
120
 
118
121
  // The only supported unit is px, so we can parseInt to strip the px here.
@@ -171,6 +174,7 @@ export default function Image( {
171
174
  },
172
175
  [ clientId ]
173
176
  );
177
+
174
178
  const { replaceBlocks, toggleSelection } = useDispatch( blockEditorStore );
175
179
  const { createErrorNotice, createSuccessNotice } =
176
180
  useDispatch( noticesStore );
@@ -365,6 +369,62 @@ export default function Image( {
365
369
  availableUnits: [ 'px' ],
366
370
  } );
367
371
 
372
+ const lightboxSetting = useSetting( 'lightbox' );
373
+
374
+ const showLightboxToggle =
375
+ lightboxSetting === true || lightboxSetting?.allowEditing === true;
376
+
377
+ const lightboxChecked =
378
+ lightbox?.enabled || ( ! lightbox && lightboxSetting?.enabled );
379
+
380
+ const dimensionsControl = (
381
+ <DimensionsTool
382
+ value={ { width, height, scale, aspectRatio } }
383
+ onChange={ ( {
384
+ width: newWidth,
385
+ height: newHeight,
386
+ scale: newScale,
387
+ aspectRatio: newAspectRatio,
388
+ } ) => {
389
+ // Rebuilding the object forces setting `undefined`
390
+ // for values that are removed since setAttributes
391
+ // doesn't do anything with keys that aren't set.
392
+ setAttributes( {
393
+ // CSS includes `height: auto`, but we need
394
+ // `width: auto` to fix the aspect ratio when
395
+ // only height is set due to the width and
396
+ // height attributes set via the server.
397
+ width: ! newWidth && newHeight ? 'auto' : newWidth,
398
+ height: newHeight,
399
+ scale: newScale,
400
+ aspectRatio: newAspectRatio,
401
+ } );
402
+ } }
403
+ defaultScale="cover"
404
+ defaultAspectRatio="auto"
405
+ scaleOptions={ scaleOptions }
406
+ unitsOptions={ dimensionsUnitsOptions }
407
+ />
408
+ );
409
+
410
+ const resetAll = () => {
411
+ setAttributes( {
412
+ width: undefined,
413
+ height: undefined,
414
+ scale: undefined,
415
+ aspectRatio: undefined,
416
+ lightbox: undefined,
417
+ } );
418
+ };
419
+
420
+ const sizeControls = (
421
+ <InspectorControls>
422
+ <ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>
423
+ { isResizable && dimensionsControl }
424
+ </ToolsPanel>
425
+ </InspectorControls>
426
+ );
427
+
368
428
  const controls = (
369
429
  <>
370
430
  <BlockControls group="block">
@@ -443,17 +503,7 @@ export default function Image( {
443
503
  </BlockControls>
444
504
  ) }
445
505
  <InspectorControls>
446
- <ToolsPanel
447
- label={ __( 'Settings' ) }
448
- resetAll={ () =>
449
- setAttributes( {
450
- width: undefined,
451
- height: undefined,
452
- scale: undefined,
453
- aspectRatio: undefined,
454
- } )
455
- }
456
- >
506
+ <ToolsPanel label={ __( 'Settings' ) } resetAll={ resetAll }>
457
507
  { ! multiImageSelection && (
458
508
  <ToolsPanelItem
459
509
  label={ __( 'Alternative text' ) }
@@ -482,43 +532,32 @@ export default function Image( {
482
532
  />
483
533
  </ToolsPanelItem>
484
534
  ) }
485
- { isResizable && (
486
- <DimensionsTool
487
- value={ { width, height, scale, aspectRatio } }
488
- onChange={ ( {
489
- width: newWidth,
490
- height: newHeight,
491
- scale: newScale,
492
- aspectRatio: newAspectRatio,
493
- } ) => {
494
- // Rebuilding the object forces setting `undefined`
495
- // for values that are removed since setAttributes
496
- // doesn't do anything with keys that aren't set.
497
- setAttributes( {
498
- // CSS includes `height: auto`, but we need
499
- // `width: auto` to fix the aspect ratio when
500
- // only height is set due to the width and
501
- // height attributes set via the server.
502
- width:
503
- ! newWidth && newHeight
504
- ? 'auto'
505
- : newWidth,
506
- height: newHeight,
507
- scale: newScale,
508
- aspectRatio: newAspectRatio,
509
- } );
510
- } }
511
- defaultScale="cover"
512
- defaultAspectRatio="auto"
513
- scaleOptions={ scaleOptions }
514
- unitsOptions={ dimensionsUnitsOptions }
515
- />
516
- ) }
535
+ { isResizable && dimensionsControl }
517
536
  <ResolutionTool
518
537
  value={ sizeSlug }
519
538
  onChange={ updateImage }
520
539
  options={ imageSizeOptions }
521
540
  />
541
+ { showLightboxToggle && (
542
+ <ToolsPanelItem
543
+ hasValue={ () => !! lightbox }
544
+ label={ __( 'Expand on Click' ) }
545
+ onDeselect={ () => {
546
+ setAttributes( { lightbox: undefined } );
547
+ } }
548
+ isShownByDefault={ true }
549
+ >
550
+ <ToggleControl
551
+ label={ __( 'Expand on Click' ) }
552
+ checked={ lightboxChecked }
553
+ onChange={ ( newValue ) => {
554
+ setAttributes( {
555
+ lightbox: { enabled: newValue },
556
+ } );
557
+ } }
558
+ />
559
+ </ToolsPanelItem>
560
+ ) }
522
561
  </ToolsPanel>
523
562
  </InspectorControls>
524
563
  <InspectorControls group="advanced">
@@ -726,6 +765,10 @@ export default function Image( {
726
765
  );
727
766
  }
728
767
 
768
+ if ( ! url && ! temporaryURL ) {
769
+ return sizeControls;
770
+ }
771
+
729
772
  return (
730
773
  <>
731
774
  { /* Hide controls during upload to avoid component remount,