@wordpress/block-library 8.18.0 → 8.19.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 (393) 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/edit.native.js +5 -5
  18. package/build/column/edit.native.js.map +1 -1
  19. package/build/column/index.js +1 -0
  20. package/build/column/index.js.map +1 -1
  21. package/build/columns/index.js +2 -0
  22. package/build/columns/index.js.map +1 -1
  23. package/build/file/edit.native.js +1 -1
  24. package/build/file/edit.native.js.map +1 -1
  25. package/build/file/index.js +2 -1
  26. package/build/file/index.js.map +1 -1
  27. package/build/file/utils/index.js +1 -15
  28. package/build/file/utils/index.js.map +1 -1
  29. package/build/file/view.js +14 -1
  30. package/build/file/view.js.map +1 -1
  31. package/build/footnotes/edit.js +14 -5
  32. package/build/footnotes/edit.js.map +1 -1
  33. package/build/gallery/edit.js +1 -1
  34. package/build/gallery/edit.js.map +1 -1
  35. package/build/group/edit.js +0 -1
  36. package/build/group/edit.js.map +1 -1
  37. package/build/group/index.js +5 -0
  38. package/build/group/index.js.map +1 -1
  39. package/build/heading/edit.js +0 -1
  40. package/build/heading/edit.js.map +1 -1
  41. package/build/heading/index.js +2 -0
  42. package/build/heading/index.js.map +1 -1
  43. package/build/heading/transforms.js +3 -6
  44. package/build/heading/transforms.js.map +1 -1
  45. package/build/image/deprecated.js +191 -7
  46. package/build/image/deprecated.js.map +1 -1
  47. package/build/image/edit.js +27 -12
  48. package/build/image/edit.js.map +1 -1
  49. package/build/image/image.js +75 -40
  50. package/build/image/image.js.map +1 -1
  51. package/build/image/index.js +7 -4
  52. package/build/image/index.js.map +1 -1
  53. package/build/image/{view-interactivity.js → view.js} +1 -1
  54. package/build/image/view.js.map +1 -0
  55. package/build/list/deprecated.js +93 -1
  56. package/build/list/deprecated.js.map +1 -1
  57. package/build/list/edit.js +10 -10
  58. package/build/list/edit.js.map +1 -1
  59. package/build/list/ordered-list-settings.js +10 -10
  60. package/build/list/ordered-list-settings.js.map +1 -1
  61. package/build/list/save.js +4 -2
  62. package/build/list/save.js.map +1 -1
  63. package/build/list/utils.js +21 -2
  64. package/build/list/utils.js.map +1 -1
  65. package/build/navigation/constants.js +1 -1
  66. package/build/navigation/constants.js.map +1 -1
  67. package/build/navigation/index.js +4 -2
  68. package/build/navigation/index.js.map +1 -1
  69. package/build/navigation/view.js +168 -82
  70. package/build/navigation/view.js.map +1 -1
  71. package/build/navigation-link/edit.js +3 -9
  72. package/build/navigation-link/edit.js.map +1 -1
  73. package/build/navigation-link/transforms.js +24 -0
  74. package/build/navigation-link/transforms.js.map +1 -1
  75. package/build/page-list/edit.js +2 -1
  76. package/build/page-list/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/post-terms/use-post-terms.js +3 -2
  88. package/build/post-terms/use-post-terms.js.map +1 -1
  89. package/build/preformatted/edit.js +4 -1
  90. package/build/preformatted/edit.js.map +1 -1
  91. package/build/preformatted/index.js +1 -1
  92. package/build/preformatted/index.js.map +1 -1
  93. package/build/pullquote/deprecated.js +6 -7
  94. package/build/pullquote/deprecated.js.map +1 -1
  95. package/build/query/edit/enhanced-pagination-modal.js +56 -0
  96. package/build/query/edit/enhanced-pagination-modal.js.map +1 -0
  97. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +42 -0
  98. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
  99. package/build/query/edit/inspector-controls/index.js +8 -25
  100. package/build/query/edit/inspector-controls/index.js.map +1 -1
  101. package/build/query/edit/query-content.js +8 -2
  102. package/build/query/edit/query-content.js.map +1 -1
  103. package/build/query/utils.js +19 -0
  104. package/build/query/utils.js.map +1 -1
  105. package/build/query/view.js +4 -5
  106. package/build/query/view.js.map +1 -1
  107. package/build/search/index.js +1 -0
  108. package/build/search/index.js.map +1 -1
  109. package/build/search/view.js +81 -150
  110. package/build/search/view.js.map +1 -1
  111. package/build/social-link/edit.native.js +3 -1
  112. package/build/social-link/edit.native.js.map +1 -1
  113. package/build/table/edit.js +7 -7
  114. package/build/table/edit.js.map +1 -1
  115. package/build/table-of-contents/edit.js +2 -130
  116. package/build/table-of-contents/edit.js.map +1 -1
  117. package/build/table-of-contents/hooks.js +145 -0
  118. package/build/table-of-contents/hooks.js.map +1 -0
  119. package/build/table-of-contents/index.js +2 -1
  120. package/build/table-of-contents/index.js.map +1 -1
  121. package/build/verse/edit.js +4 -1
  122. package/build/verse/edit.js.map +1 -1
  123. package/build/verse/index.js +1 -1
  124. package/build/verse/index.js.map +1 -1
  125. package/build-module/block/edit.js +54 -3
  126. package/build-module/block/edit.js.map +1 -1
  127. package/build-module/button/edit.js +7 -4
  128. package/build-module/button/edit.js.map +1 -1
  129. package/build-module/button/index.js +11 -2
  130. package/build-module/button/index.js.map +1 -1
  131. package/build-module/button/save.js +10 -4
  132. package/build-module/button/save.js.map +1 -1
  133. package/build-module/buttons/edit.js +12 -3
  134. package/build-module/buttons/edit.js.map +1 -1
  135. package/build-module/code/edit.js +8 -2
  136. package/build-module/code/edit.js.map +1 -1
  137. package/build-module/code/index.js +7 -1
  138. package/build-module/code/index.js.map +1 -1
  139. package/build-module/column/edit.native.js +5 -5
  140. package/build-module/column/edit.native.js.map +1 -1
  141. package/build-module/column/index.js +1 -0
  142. package/build-module/column/index.js.map +1 -1
  143. package/build-module/columns/index.js +2 -0
  144. package/build-module/columns/index.js.map +1 -1
  145. package/build-module/file/edit.native.js +1 -1
  146. package/build-module/file/edit.native.js.map +1 -1
  147. package/build-module/file/index.js +2 -1
  148. package/build-module/file/index.js.map +1 -1
  149. package/build-module/file/utils/index.js +0 -13
  150. package/build-module/file/utils/index.js.map +1 -1
  151. package/build-module/file/view.js +14 -2
  152. package/build-module/file/view.js.map +1 -1
  153. package/build-module/footnotes/edit.js +14 -5
  154. package/build-module/footnotes/edit.js.map +1 -1
  155. package/build-module/gallery/edit.js +1 -1
  156. package/build-module/gallery/edit.js.map +1 -1
  157. package/build-module/group/edit.js +0 -1
  158. package/build-module/group/edit.js.map +1 -1
  159. package/build-module/group/index.js +5 -0
  160. package/build-module/group/index.js.map +1 -1
  161. package/build-module/heading/edit.js +0 -1
  162. package/build-module/heading/edit.js.map +1 -1
  163. package/build-module/heading/index.js +2 -0
  164. package/build-module/heading/index.js.map +1 -1
  165. package/build-module/heading/transforms.js +3 -6
  166. package/build-module/heading/transforms.js.map +1 -1
  167. package/build-module/image/deprecated.js +191 -7
  168. package/build-module/image/deprecated.js.map +1 -1
  169. package/build-module/image/edit.js +27 -12
  170. package/build-module/image/edit.js.map +1 -1
  171. package/build-module/image/image.js +77 -42
  172. package/build-module/image/image.js.map +1 -1
  173. package/build-module/image/index.js +7 -4
  174. package/build-module/image/index.js.map +1 -1
  175. package/build-module/image/{view-interactivity.js → view.js} +1 -1
  176. package/build-module/image/view.js.map +1 -0
  177. package/build-module/list/deprecated.js +95 -3
  178. package/build-module/list/deprecated.js.map +1 -1
  179. package/build-module/list/edit.js +10 -10
  180. package/build-module/list/edit.js.map +1 -1
  181. package/build-module/list/ordered-list-settings.js +10 -10
  182. package/build-module/list/ordered-list-settings.js.map +1 -1
  183. package/build-module/list/save.js +4 -2
  184. package/build-module/list/save.js.map +1 -1
  185. package/build-module/list/utils.js +20 -2
  186. package/build-module/list/utils.js.map +1 -1
  187. package/build-module/navigation/constants.js +1 -1
  188. package/build-module/navigation/constants.js.map +1 -1
  189. package/build-module/navigation/index.js +4 -2
  190. package/build-module/navigation/index.js.map +1 -1
  191. package/build-module/navigation/view.js +168 -83
  192. package/build-module/navigation/view.js.map +1 -1
  193. package/build-module/navigation-link/edit.js +3 -9
  194. package/build-module/navigation-link/edit.js.map +1 -1
  195. package/build-module/navigation-link/transforms.js +24 -0
  196. package/build-module/navigation-link/transforms.js.map +1 -1
  197. package/build-module/page-list/edit.js +2 -1
  198. package/build-module/page-list/edit.js.map +1 -1
  199. package/build-module/post-comments-form/edit.js +10 -2
  200. package/build-module/post-comments-form/edit.js.map +1 -1
  201. package/build-module/post-comments-form/form.js +5 -3
  202. package/build-module/post-comments-form/form.js.map +1 -1
  203. package/build-module/post-content/edit.js +8 -7
  204. package/build-module/post-content/edit.js.map +1 -1
  205. package/build-module/post-content/index.js +3 -0
  206. package/build-module/post-content/index.js.map +1 -1
  207. package/build-module/post-featured-image/overlay.js +2 -1
  208. package/build-module/post-featured-image/overlay.js.map +1 -1
  209. package/build-module/post-terms/use-post-terms.js +3 -2
  210. package/build-module/post-terms/use-post-terms.js.map +1 -1
  211. package/build-module/preformatted/edit.js +4 -1
  212. package/build-module/preformatted/edit.js.map +1 -1
  213. package/build-module/preformatted/index.js +1 -1
  214. package/build-module/preformatted/index.js.map +1 -1
  215. package/build-module/pullquote/deprecated.js +6 -7
  216. package/build-module/pullquote/deprecated.js.map +1 -1
  217. package/build-module/query/edit/enhanced-pagination-modal.js +50 -0
  218. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -0
  219. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +35 -0
  220. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
  221. package/build-module/query/edit/inspector-controls/index.js +9 -26
  222. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  223. package/build-module/query/edit/query-content.js +8 -2
  224. package/build-module/query/edit/query-content.js.map +1 -1
  225. package/build-module/query/utils.js +17 -0
  226. package/build-module/query/utils.js.map +1 -1
  227. package/build-module/query/view.js +4 -5
  228. package/build-module/query/view.js.map +1 -1
  229. package/build-module/search/index.js +1 -0
  230. package/build-module/search/index.js.map +1 -1
  231. package/build-module/search/view.js +81 -151
  232. package/build-module/search/view.js.map +1 -1
  233. package/build-module/social-link/edit.native.js +3 -1
  234. package/build-module/social-link/edit.native.js.map +1 -1
  235. package/build-module/table/edit.js +7 -7
  236. package/build-module/table/edit.js.map +1 -1
  237. package/build-module/table-of-contents/edit.js +3 -131
  238. package/build-module/table-of-contents/edit.js.map +1 -1
  239. package/build-module/table-of-contents/hooks.js +137 -0
  240. package/build-module/table-of-contents/hooks.js.map +1 -0
  241. package/build-module/table-of-contents/index.js +2 -1
  242. package/build-module/table-of-contents/index.js.map +1 -1
  243. package/build-module/verse/edit.js +4 -1
  244. package/build-module/verse/edit.js.map +1 -1
  245. package/build-module/verse/index.js +1 -1
  246. package/build-module/verse/index.js.map +1 -1
  247. package/build-style/cover/style-rtl.css +9 -0
  248. package/build-style/cover/style.css +9 -0
  249. package/build-style/editor-rtl.css +15 -9
  250. package/build-style/editor.css +15 -9
  251. package/build-style/file/style-rtl.css +5 -0
  252. package/build-style/file/style.css +5 -0
  253. package/build-style/heading/style-rtl.css +13 -0
  254. package/build-style/heading/style.css +13 -0
  255. package/build-style/navigation-link/editor-rtl.css +0 -9
  256. package/build-style/navigation-link/editor.css +0 -9
  257. package/build-style/paragraph/editor-rtl.css +5 -0
  258. package/build-style/paragraph/editor.css +5 -0
  259. package/build-style/paragraph/style-rtl.css +5 -0
  260. package/build-style/paragraph/style.css +5 -0
  261. package/build-style/post-navigation-link/style-rtl.css +3 -0
  262. package/build-style/post-navigation-link/style.css +3 -0
  263. package/build-style/query/editor-rtl.css +10 -0
  264. package/build-style/query/editor.css +10 -0
  265. package/build-style/query/style-rtl.css +1 -1
  266. package/build-style/query/style.css +1 -1
  267. package/build-style/reset-rtl.css +27 -27
  268. package/build-style/reset.css +27 -27
  269. package/build-style/style-rtl.css +35 -0
  270. package/build-style/style.css +35 -0
  271. package/package.json +32 -33
  272. package/src/audio/test/__snapshots__/edit.native.js.snap +78 -106
  273. package/src/avatar/index.php +2 -2
  274. package/src/block/edit.js +58 -2
  275. package/src/block/test/edit.native.js +2 -3
  276. package/src/button/block.json +11 -2
  277. package/src/button/edit.js +27 -11
  278. package/src/button/save.js +10 -4
  279. package/src/buttons/edit.js +13 -3
  280. package/src/buttons/test/edit.native.js +28 -24
  281. package/src/calendar/index.php +2 -2
  282. package/src/code/block.json +2 -1
  283. package/src/code/edit.js +13 -1
  284. package/src/code/index.js +5 -0
  285. package/src/column/block.json +1 -0
  286. package/src/column/edit.native.js +4 -4
  287. package/src/columns/block.json +2 -0
  288. package/src/columns/test/__snapshots__/edit.native.js.snap +14 -0
  289. package/src/columns/test/edit.native.js +47 -17
  290. package/src/comment-template/index.php +1 -1
  291. package/src/comments-pagination-next/index.php +1 -1
  292. package/src/comments-pagination-previous/index.php +1 -1
  293. package/src/cover/style.scss +12 -1
  294. package/src/cover/test/edit.js +7 -7
  295. package/src/cover/test/edit.native.js +18 -27
  296. package/src/embed/test/index.native.js +30 -45
  297. package/src/file/block.json +2 -1
  298. package/src/file/edit.native.js +1 -1
  299. package/src/file/index.php +19 -21
  300. package/src/file/style.scss +6 -1
  301. package/src/file/test/__snapshots__/edit.native.js.snap +162 -218
  302. package/src/file/utils/index.js +0 -15
  303. package/src/file/view.js +14 -5
  304. package/src/footnotes/edit.js +16 -2
  305. package/src/gallery/edit.js +1 -1
  306. package/src/gallery/index.php +1 -1
  307. package/src/group/block.json +5 -0
  308. package/src/group/edit.js +0 -1
  309. package/src/heading/block.json +2 -0
  310. package/src/heading/edit.js +0 -1
  311. package/src/heading/style.scss +4 -0
  312. package/src/heading/transforms.js +1 -6
  313. package/src/image/block.json +7 -4
  314. package/src/image/deprecated.js +210 -7
  315. package/src/image/edit.js +43 -29
  316. package/src/image/image.js +86 -43
  317. package/src/image/index.php +251 -28
  318. package/src/latest-posts/index.php +1 -1
  319. package/src/list/deprecated.js +84 -3
  320. package/src/list/edit.js +6 -3
  321. package/src/list/ordered-list-settings.js +20 -5
  322. package/src/list/save.js +10 -1
  323. package/src/list/test/edit.native.js +2 -4
  324. package/src/list/utils.js +22 -1
  325. package/src/navigation/block.json +4 -2
  326. package/src/navigation/constants.js +1 -0
  327. package/src/navigation/index.php +85 -123
  328. package/src/navigation/view.js +192 -96
  329. package/src/navigation-link/edit.js +21 -36
  330. package/src/navigation-link/editor.scss +0 -8
  331. package/src/navigation-link/transforms.js +22 -0
  332. package/src/page-list/edit.js +2 -1
  333. package/src/paragraph/editor.scss +5 -0
  334. package/src/paragraph/style.scss +5 -0
  335. package/src/pattern/index.php +2 -2
  336. package/src/post-comments-form/edit.js +10 -0
  337. package/src/post-comments-form/form.js +7 -1
  338. package/src/post-content/block.json +3 -0
  339. package/src/post-content/edit.js +14 -6
  340. package/src/post-excerpt/index.php +2 -2
  341. package/src/post-featured-image/index.php +2 -2
  342. package/src/post-featured-image/overlay.js +1 -0
  343. package/src/post-navigation-link/index.php +5 -1
  344. package/src/post-navigation-link/style.scss +4 -0
  345. package/src/post-template/index.php +1 -1
  346. package/src/post-terms/index.php +5 -2
  347. package/src/post-terms/use-post-terms.js +4 -2
  348. package/src/preformatted/edit.js +5 -0
  349. package/src/preformatted/index.js +1 -1
  350. package/src/pullquote/deprecated.js +8 -13
  351. package/src/query/edit/enhanced-pagination-modal.js +65 -0
  352. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +49 -0
  353. package/src/query/edit/inspector-controls/index.js +9 -45
  354. package/src/query/edit/query-content.js +8 -0
  355. package/src/query/editor.scss +10 -0
  356. package/src/query/index.php +29 -16
  357. package/src/query/style.scss +2 -2
  358. package/src/query/utils.js +22 -0
  359. package/src/query/view.js +5 -5
  360. package/src/query-pagination-next/index.php +1 -1
  361. package/src/query-pagination-previous/index.php +1 -1
  362. package/src/reset.scss +1 -1
  363. package/src/search/block.json +1 -0
  364. package/src/search/index.php +45 -4
  365. package/src/search/test/__snapshots__/edit.native.js.snap +265 -363
  366. package/src/search/view.js +70 -169
  367. package/src/social-link/edit.native.js +1 -1
  368. package/src/social-link/editor.native.scss +4 -0
  369. package/src/table/edit.js +21 -19
  370. package/src/table-of-contents/block.json +2 -1
  371. package/src/table-of-contents/edit.js +5 -162
  372. package/src/table-of-contents/hooks.js +156 -0
  373. package/src/verse/edit.js +5 -0
  374. package/src/verse/index.js +1 -1
  375. package/src/verse/test/edit.native.js +2 -3
  376. package/build/file/view-interactivity.js +0 -22
  377. package/build/file/view-interactivity.js.map +0 -1
  378. package/build/image/view-interactivity.js.map +0 -1
  379. package/build/navigation/view-interactivity.js +0 -172
  380. package/build/navigation/view-interactivity.js.map +0 -1
  381. package/build/navigation/view-modal.js +0 -115
  382. package/build/navigation/view-modal.js.map +0 -1
  383. package/build-module/file/view-interactivity.js +0 -18
  384. package/build-module/file/view-interactivity.js.map +0 -1
  385. package/build-module/image/view-interactivity.js.map +0 -1
  386. package/build-module/navigation/view-interactivity.js +0 -169
  387. package/build-module/navigation/view-interactivity.js.map +0 -1
  388. package/build-module/navigation/view-modal.js +0 -112
  389. package/build-module/navigation/view-modal.js.map +0 -1
  390. package/src/file/view-interactivity.js +0 -18
  391. package/src/navigation/view-interactivity.js +0 -196
  392. package/src/navigation/view-modal.js +0 -127
  393. /package/src/image/{view-interactivity.js → view.js} +0 -0
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @param array $attributes The block attributes.
13
13
  * @param string $content The block content.
14
- * @param WP_Block $block The block object.
14
+ * @param WP_Block $block The block object.
15
15
  * @return string Returns the block content with the data-id attribute added.
16
16
  */
17
17
  function render_block_core_image( $attributes, $content, $block ) {
@@ -31,54 +31,277 @@ function render_block_core_image( $attributes, $content, $block ) {
31
31
  $processor->set_attribute( 'data-id', $attributes['data-id'] );
32
32
  }
33
33
 
34
- $should_load_view_script = false;
35
- $link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
36
- // Get the lightbox setting from the block attributes.
37
- if ( isset( $attributes['behaviors']['lightbox'] ) ) {
38
- $lightbox_settings = $attributes['behaviors']['lightbox'];
39
- // If the lightbox setting is not set in the block attributes, get it from the theme.json file.
40
- } else {
41
- $theme_data = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()->get_data();
42
- if ( isset( $theme_data['behaviors']['blocks'][ $block->name ]['lightbox'] ) ) {
43
- $lightbox_settings = $theme_data['behaviors']['blocks'][ $block->name ]['lightbox'];
44
- } else {
45
- $lightbox_settings = null;
46
- }
47
- }
34
+ $lightbox_enabled = false;
35
+ $link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
36
+ $lightbox_settings = block_core_image_get_lightbox_settings( $block->parsed_block );
48
37
 
49
- // If the lightbox is enabled, the image is not linked, and the Interactivity API is enabled, load the view script.
50
- if ( isset( $lightbox_settings['enabled'] ) &&
51
- true === $lightbox_settings['enabled'] &&
52
- 'none' === $link_destination
53
- ) {
54
- $should_load_view_script = true;
38
+ // If the lightbox is enabled and the image is not linked, flag the lightbox to be rendered.
39
+ if ( isset( $lightbox_settings ) && 'none' === $link_destination ) {
40
+
41
+ if ( isset( $lightbox_settings['enabled'] ) && true === $lightbox_settings['enabled'] ) {
42
+ $lightbox_enabled = true;
43
+ }
55
44
  }
56
45
 
57
46
  // If at least one block in the page has the lightbox, mark the block type as interactive.
58
- if ( $should_load_view_script ) {
47
+ if ( $lightbox_enabled ) {
59
48
  $block->block_type->supports['interactivity'] = true;
60
49
  }
61
50
 
51
+ // Determine whether the view script should be enqueued or not.
62
52
  $view_js_file = 'wp-block-image-view';
63
53
  if ( ! wp_script_is( $view_js_file ) ) {
64
54
  $script_handles = $block->block_type->view_script_handles;
65
55
 
66
56
  // If the script is not needed, and it is still in the `view_script_handles`, remove it.
67
- if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
57
+ if ( ! $lightbox_enabled && in_array( $view_js_file, $script_handles, true ) ) {
68
58
  $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
69
59
  }
70
60
  // If the script is needed, but it was previously removed, add it again.
71
- if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
61
+ if ( $lightbox_enabled && ! in_array( $view_js_file, $script_handles, true ) ) {
72
62
  $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
73
63
  }
74
64
  }
75
65
 
66
+ if ( $lightbox_enabled ) {
67
+ return block_core_image_render_lightbox( $processor->get_updated_html(), $block->parsed_block );
68
+ }
69
+
76
70
  return $processor->get_updated_html();
77
71
  }
78
72
 
79
- /**
80
- * Registers the `core/image` block on server.
81
- */
73
+ /**
74
+ * Add the lightboxEnabled flag to the block data.
75
+ *
76
+ * This is used to determine whether the lightbox should be rendered or not.
77
+ *
78
+ * @param array $block Block data.
79
+ * @return array Filtered block data.
80
+ */
81
+ function block_core_image_get_lightbox_settings( $block ) {
82
+ // Get the lightbox setting from the block attributes.
83
+ if ( isset( $block['attrs']['lightbox'] ) ) {
84
+ $lightbox_settings = $block['attrs']['lightbox'];
85
+ // If the lightbox setting is not set in the block attributes,
86
+ // check the legacy lightbox settings that are set using the
87
+ // `gutenberg_should_render_lightbox` filter.
88
+ // We can remove this elseif statement when the legacy lightbox settings are removed.
89
+ } elseif ( isset( $block['legacyLightboxSettings'] ) ) {
90
+ $lightbox_settings = $block['legacyLightboxSettings'];
91
+ }
92
+
93
+ if ( ! isset( $lightbox_settings ) ) {
94
+ $lightbox_settings = gutenberg_get_global_settings( array( 'lightbox' ), array( 'block_name' => 'core/image' ) );
95
+
96
+ // If not present in global settings, check the top-level global settings.
97
+ //
98
+ // NOTE: If no block-level settings are found, the previous call to
99
+ // `gutenberg_get_global_settings` will return the whole `theme.json`
100
+ // structure in which case we can check if the "lightbox" key is present at
101
+ // the top-level of the global settings and use its value.
102
+ if ( isset( $lightbox_settings['lightbox'] ) ) {
103
+ $lightbox_settings = gutenberg_get_global_settings( array( 'lightbox' ) );
104
+ }
105
+ }
106
+
107
+ return $lightbox_settings ?? null;
108
+ }
109
+
110
+ /**
111
+ * Add the directives and layout needed for the lightbox behavior.
112
+ *
113
+ * @param string $block_content Rendered block content.
114
+ * @param array $block Block object.
115
+ * @return string Filtered block content.
116
+ */
117
+ function block_core_image_render_lightbox( $block_content, $block ) {
118
+ $processor = new WP_HTML_Tag_Processor( $block_content );
119
+
120
+ $aria_label = __( 'Enlarge image', 'gutenberg' );
121
+
122
+ $alt_attribute = $processor->get_attribute( 'alt' );
123
+
124
+ if ( null !== $alt_attribute ) {
125
+ $alt_attribute = trim( $alt_attribute );
126
+ }
127
+
128
+ if ( $alt_attribute ) {
129
+ /* translators: %s: Image alt text. */
130
+ $aria_label = sprintf( __( 'Enlarge image: %s', 'gutenberg' ), $alt_attribute );
131
+ }
132
+ $content = $processor->get_updated_html();
133
+
134
+ // Currently, we are only enabling the zoom animation.
135
+ $lightbox_animation = 'zoom';
136
+
137
+ // We want to store the src in the context so we can set it dynamically when the lightbox is opened.
138
+ $z = new WP_HTML_Tag_Processor( $content );
139
+ $z->next_tag( 'img' );
140
+
141
+ if ( isset( $block['attrs']['id'] ) ) {
142
+ $img_uploaded_src = wp_get_attachment_url( $block['attrs']['id'] );
143
+ $img_metadata = wp_get_attachment_metadata( $block['attrs']['id'] );
144
+ $img_width = $img_metadata['width'];
145
+ $img_height = $img_metadata['height'];
146
+ } else {
147
+ $img_uploaded_src = $z->get_attribute( 'src' );
148
+ $img_width = 'none';
149
+ $img_height = 'none';
150
+ }
151
+
152
+ if ( isset( $block['attrs']['scale'] ) ) {
153
+ $scale_attr = $block['attrs']['scale'];
154
+ } else {
155
+ $scale_attr = false;
156
+ }
157
+
158
+ $w = new WP_HTML_Tag_Processor( $content );
159
+ $w->next_tag( 'figure' );
160
+ $w->add_class( 'wp-lightbox-container' );
161
+ $w->set_attribute( 'data-wp-interactive', true );
162
+
163
+ $w->set_attribute(
164
+ 'data-wp-context',
165
+ sprintf(
166
+ '{ "core":
167
+ { "image":
168
+ { "imageLoaded": false,
169
+ "initialized": false,
170
+ "lightboxEnabled": false,
171
+ "hideAnimationEnabled": false,
172
+ "preloadInitialized": false,
173
+ "lightboxAnimation": "%s",
174
+ "imageUploadedSrc": "%s",
175
+ "imageCurrentSrc": "",
176
+ "targetWidth": "%s",
177
+ "targetHeight": "%s",
178
+ "scaleAttr": "%s"
179
+ }
180
+ }
181
+ }',
182
+ $lightbox_animation,
183
+ $img_uploaded_src,
184
+ $img_width,
185
+ $img_height,
186
+ $scale_attr
187
+ )
188
+ );
189
+ $w->next_tag( 'img' );
190
+ $w->set_attribute( 'data-wp-init', 'effects.core.image.setCurrentSrc' );
191
+ $w->set_attribute( 'data-wp-on--load', 'actions.core.image.handleLoad' );
192
+ $w->set_attribute( 'data-wp-effect', 'effects.core.image.setButtonStyles' );
193
+ $body_content = $w->get_updated_html();
194
+
195
+ // Wrap the image in the body content with a button.
196
+ $img = null;
197
+ preg_match( '/<img[^>]+>/', $body_content, $img );
198
+ $button =
199
+ '<button
200
+ type="button"
201
+ aria-haspopup="dialog"
202
+ aria-label="' . esc_attr( $aria_label ) . '"
203
+ data-wp-on--click="actions.core.image.showLightbox"
204
+ data-wp-style--width="context.core.image.imageButtonWidth"
205
+ data-wp-style--height="context.core.image.imageButtonHeight"
206
+ data-wp-style--left="context.core.image.imageButtonLeft"
207
+ data-wp-style--top="context.core.image.imageButtonTop"
208
+ >
209
+ </button>'
210
+ . $img[0];
211
+ $body_content = preg_replace( '/<img[^>]+>/', $button, $body_content );
212
+
213
+ // We need both a responsive image and an enlarged image to animate
214
+ // the zoom seamlessly on slow internet connections; the responsive
215
+ // image is a copy of the one in the body, which animates immediately
216
+ // as the lightbox is opened, while the enlarged one is a full-sized
217
+ // version that will likely still be loading as the animation begins.
218
+ $m = new WP_HTML_Tag_Processor( $content );
219
+ $m->next_tag( 'figure' );
220
+ $m->add_class( 'responsive-image' );
221
+ $m->next_tag( 'img' );
222
+ // We want to set the 'src' attribute to an empty string in the responsive image
223
+ // because otherwise, as of this writing, the wp_filter_content_tags() function in
224
+ // WordPress will automatically add a 'srcset' attribute to the image, which will at
225
+ // times cause the incorrectly sized image to be loaded in the lightbox on Firefox.
226
+ // Because of this, we bind the 'src' attribute explicitly the current src to reliably
227
+ // use the exact same image as in the content when the lightbox is first opened while
228
+ // we wait for the larger image to load.
229
+ $m->set_attribute( 'src', '' );
230
+ $m->set_attribute( 'data-wp-bind--src', 'context.core.image.imageCurrentSrc' );
231
+ $m->set_attribute( 'data-wp-style--object-fit', 'selectors.core.image.lightboxObjectFit' );
232
+ $initial_image_content = $m->get_updated_html();
233
+
234
+ $q = new WP_HTML_Tag_Processor( $content );
235
+ $q->next_tag( 'figure' );
236
+ $q->add_class( 'enlarged-image' );
237
+ $q->next_tag( 'img' );
238
+
239
+ // We set the 'src' attribute to an empty string to prevent the browser from loading the image
240
+ // on initial page load, then bind the attribute to a selector that returns the full-sized image src when
241
+ // the lightbox is opened. We could use 'loading=lazy' in combination with the 'hidden' attribute to
242
+ // accomplish the same behavior, but that approach breaks progressive loading of the image in Safari
243
+ // and Chrome (see https://github.com/WordPress/gutenberg/pull/52765#issuecomment-1674008151). Until that
244
+ // is resolved, manually setting the 'src' seems to be the best solution to load the large image on demand.
245
+ $q->set_attribute( 'src', '' );
246
+ $q->set_attribute( 'data-wp-bind--src', 'selectors.core.image.enlargedImgSrc' );
247
+ $q->set_attribute( 'data-wp-style--object-fit', 'selectors.core.image.lightboxObjectFit' );
248
+ $enlarged_image_content = $q->get_updated_html();
249
+
250
+ $background_color = esc_attr( wp_get_global_styles( array( 'color', 'background' ) ) );
251
+
252
+ $close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
253
+ $close_button_color = esc_attr( wp_get_global_styles( array( 'color', 'text' ) ) );
254
+ $dialog_label = $alt_attribute ? esc_attr( $alt_attribute ) : esc_attr__( 'Image', 'gutenberg' );
255
+ $close_button_label = esc_attr__( 'Close', 'gutenberg' );
256
+
257
+ $lightbox_html = <<<HTML
258
+ <div data-wp-body="" class="wp-lightbox-overlay $lightbox_animation"
259
+ data-wp-bind--role="selectors.core.image.roleAttribute"
260
+ aria-label="$dialog_label"
261
+ data-wp-class--initialized="context.core.image.initialized"
262
+ data-wp-class--active="context.core.image.lightboxEnabled"
263
+ data-wp-class--hideAnimationEnabled="context.core.image.hideAnimationEnabled"
264
+ data-wp-bind--aria-hidden="!context.core.image.lightboxEnabled"
265
+ aria-hidden="true"
266
+ data-wp-bind--aria-modal="context.core.image.lightboxEnabled"
267
+ aria-modal="false"
268
+ data-wp-effect="effects.core.image.initLightbox"
269
+ data-wp-on--keydown="actions.core.image.handleKeydown"
270
+ data-wp-on--mousewheel="actions.core.image.hideLightbox"
271
+ data-wp-on--click="actions.core.image.hideLightbox"
272
+ >
273
+ <button type="button" aria-label="$close_button_label" style="fill: $close_button_color" class="close-button" data-wp-on--click="actions.core.image.hideLightbox">
274
+ $close_button_icon
275
+ </button>
276
+ <div class="lightbox-image-container">$initial_image_content</div>
277
+ <div class="lightbox-image-container">$enlarged_image_content</div>
278
+ <div class="scrim" style="background-color: $background_color"></div>
279
+ </div>
280
+ HTML;
281
+
282
+ return str_replace( '</figure>', $lightbox_html . '</figure>', $body_content );
283
+ }
284
+
285
+ /**
286
+ * Ensure that the view script has the `wp-interactivity` dependency.
287
+ *
288
+ * @since 6.4.0
289
+ */
290
+ function block_core_image_ensure_interactivity_dependency() {
291
+ global $wp_scripts;
292
+ if (
293
+ isset( $wp_scripts->registered['wp-block-image-view'] ) &&
294
+ ! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-image-view']->deps, true )
295
+ ) {
296
+ $wp_scripts->registered['wp-block-image-view']->deps[] = 'wp-interactivity';
297
+ }
298
+ }
299
+
300
+ add_action( 'wp_print_scripts', 'block_core_image_ensure_interactivity_dependency' );
301
+
302
+ /**
303
+ * Registers the `core/image` block on server.
304
+ */
82
305
  function register_block_core_image() {
83
306
  register_block_type_from_metadata(
84
307
  __DIR__ . '/image',
@@ -87,4 +310,4 @@ function register_block_core_image() {
87
310
  )
88
311
  );
89
312
  }
90
- add_action( 'init', 'register_block_core_image' );
313
+ add_action( 'init', 'register_block_core_image' );
@@ -48,7 +48,7 @@ function render_block_core_latest_posts( $attributes ) {
48
48
  $block_core_latest_posts_excerpt_length = $attributes['excerptLength'];
49
49
  add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
50
50
 
51
- $filter_latest_posts_excerpt_more = static function( $more ) use ( $attributes ) {
51
+ $filter_latest_posts_excerpt_more = static function ( $more ) use ( $attributes ) {
52
52
  $use_excerpt = 'excerpt' === $attributes['displayPostContentRadio'];
53
53
  /* translators: %1$s is a URL to a post, excerpt truncation character, default … */
54
54
  return $use_excerpt ? sprintf( __( ' … <a href="%1$s" rel="noopener noreferrer">Read more</a>' ), esc_url( get_permalink() ) ) : $more;
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { RichText, useBlockProps } from '@wordpress/block-editor';
4
+ import { RichText, InnerBlocks, useBlockProps } from '@wordpress/block-editor';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
9
  import migrateFontFamily from '../utils/migrate-font-family';
10
- import { migrateToListV2 } from './utils';
10
+ import { migrateToListV2, migrateTypeToInlineStyle } from './utils';
11
11
 
12
12
  const v0 = {
13
13
  attributes: {
@@ -138,6 +138,87 @@ const v1 = {
138
138
  migrate: migrateToListV2,
139
139
  };
140
140
 
141
+ // In #53301 changed to use the inline style instead of type attribute.
142
+ const v2 = {
143
+ attributes: {
144
+ ordered: {
145
+ type: 'boolean',
146
+ default: false,
147
+ __experimentalRole: 'content',
148
+ },
149
+ values: {
150
+ type: 'string',
151
+ source: 'html',
152
+ selector: 'ol,ul',
153
+ multiline: 'li',
154
+ __unstableMultilineWrapperTags: [ 'ol', 'ul' ],
155
+ default: '',
156
+ __experimentalRole: 'content',
157
+ },
158
+ type: {
159
+ type: 'string',
160
+ },
161
+ start: {
162
+ type: 'number',
163
+ },
164
+ reversed: {
165
+ type: 'boolean',
166
+ },
167
+ placeholder: {
168
+ type: 'string',
169
+ },
170
+ },
171
+ supports: {
172
+ anchor: true,
173
+ className: false,
174
+ typography: {
175
+ fontSize: true,
176
+ lineHeight: true,
177
+ __experimentalFontFamily: true,
178
+ __experimentalFontWeight: true,
179
+ __experimentalFontStyle: true,
180
+ __experimentalTextTransform: true,
181
+ __experimentalTextDecoration: true,
182
+ __experimentalLetterSpacing: true,
183
+ __experimentalDefaultControls: {
184
+ fontSize: true,
185
+ },
186
+ },
187
+ color: {
188
+ gradients: true,
189
+ link: true,
190
+ __experimentalDefaultControls: {
191
+ background: true,
192
+ text: true,
193
+ },
194
+ },
195
+ spacing: {
196
+ margin: true,
197
+ padding: true,
198
+ __experimentalDefaultControls: {
199
+ margin: false,
200
+ padding: false,
201
+ },
202
+ },
203
+ __unstablePasteTextInline: true,
204
+ __experimentalSelector: 'ol,ul',
205
+ __experimentalSlashInserter: true,
206
+ },
207
+ isEligible( { type } ) {
208
+ return !! type;
209
+ },
210
+ save( { attributes } ) {
211
+ const { ordered, type, reversed, start } = attributes;
212
+ const TagName = ordered ? 'ol' : 'ul';
213
+ return (
214
+ <TagName { ...useBlockProps.save( { type, reversed, start } ) }>
215
+ <InnerBlocks.Content />
216
+ </TagName>
217
+ );
218
+ },
219
+ migrate: migrateTypeToInlineStyle,
220
+ };
221
+
141
222
  /**
142
223
  * New deprecations need to be placed first
143
224
  * for them to have higher priority.
@@ -146,4 +227,4 @@ const v1 = {
146
227
  *
147
228
  * See block-deprecation.md
148
229
  */
149
- export default [ v1, v0 ];
230
+ export default [ v2, v1, v0 ];
package/src/list/edit.js CHANGED
@@ -124,9 +124,14 @@ function IndentUI( { clientId } ) {
124
124
  }
125
125
 
126
126
  export default function Edit( { attributes, setAttributes, clientId, style } ) {
127
+ const { ordered, type, reversed, start } = attributes;
127
128
  const blockProps = useBlockProps( {
128
- ...( Platform.isNative && { style } ),
129
+ style: {
130
+ ...( Platform.isNative && style ),
131
+ listStyleType: ordered && type !== 'decimal' ? type : undefined,
132
+ },
129
133
  } );
134
+
130
135
  const innerBlocksProps = useInnerBlocksProps( blockProps, {
131
136
  allowedBlocks: [ 'core/list-item' ],
132
137
  template: TEMPLATE,
@@ -140,7 +145,6 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) {
140
145
  __experimentalCaptureToolbars: true,
141
146
  } );
142
147
  useMigrateOnLoad( attributes, clientId );
143
- const { ordered, type, reversed, start } = attributes;
144
148
 
145
149
  const controls = (
146
150
  <BlockControls group="block">
@@ -172,7 +176,6 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) {
172
176
  ordered={ ordered }
173
177
  reversed={ reversed }
174
178
  start={ start }
175
- type={ type }
176
179
  { ...innerBlocksProps }
177
180
  />
178
181
  { controls }
@@ -33,11 +33,26 @@ const OrderedListSettings = ( { setAttributes, reversed, start, type } ) => (
33
33
  __nextHasNoMarginBottom
34
34
  label={ __( 'Numbering style' ) }
35
35
  options={ [
36
- { value: '1', label: __( 'Numbers' ) },
37
- { value: 'A', label: __( 'Uppercase letters' ) },
38
- { value: 'a', label: __( 'Lowercase letters' ) },
39
- { value: 'I', label: __( 'Uppercase Roman numerals' ) },
40
- { value: 'i', label: __( 'Lowercase Roman numerals' ) },
36
+ {
37
+ label: __( 'Numbers' ),
38
+ value: 'decimal',
39
+ },
40
+ {
41
+ label: __( 'Uppercase letters' ),
42
+ value: 'upper-alpha',
43
+ },
44
+ {
45
+ label: __( 'Lowercase letters' ),
46
+ value: 'lower-alpha',
47
+ },
48
+ {
49
+ label: __( 'Uppercase Roman numerals' ),
50
+ value: 'upper-roman',
51
+ },
52
+ {
53
+ label: __( 'Lowercase Roman numerals' ),
54
+ value: 'lower-roman',
55
+ },
41
56
  ] }
42
57
  value={ type }
43
58
  onChange={ ( newValue ) => setAttributes( { type: newValue } ) }
package/src/list/save.js CHANGED
@@ -7,7 +7,16 @@ export default function save( { attributes } ) {
7
7
  const { ordered, type, reversed, start } = attributes;
8
8
  const TagName = ordered ? 'ol' : 'ul';
9
9
  return (
10
- <TagName { ...useBlockProps.save( { type, reversed, start } ) }>
10
+ <TagName
11
+ { ...useBlockProps.save( {
12
+ reversed,
13
+ start,
14
+ style: {
15
+ listStyleType:
16
+ ordered && type !== 'decimal' ? type : undefined,
17
+ },
18
+ } ) }
19
+ >
11
20
  <InnerBlocks.Content />
12
21
  </TagName>
13
22
  );
@@ -423,11 +423,9 @@ describe( 'List block', () => {
423
423
 
424
424
  <!-- wp:list-item -->
425
425
  <li>Two</li>
426
- <!-- /wp:list-item --></ul>
427
- <!-- /wp:list -->
426
+ <!-- /wp:list-item -->
428
427
 
429
- <!-- wp:list -->
430
- <ul><!-- wp:list-item -->
428
+ <!-- wp:list-item -->
431
429
  <li>Three</li>
432
430
  <!-- /wp:list-item --></ul>
433
431
  <!-- /wp:list -->"
package/src/list/utils.js CHANGED
@@ -3,7 +3,15 @@
3
3
  */
4
4
  import { createBlock, rawHandler } from '@wordpress/blocks';
5
5
 
6
+ const LIST_STYLES = {
7
+ A: 'upper-alpha',
8
+ a: 'lower-alpha',
9
+ I: 'upper-roman',
10
+ i: 'lower-roman',
11
+ };
12
+
6
13
  export function createListBlockFromDOMElement( listElement ) {
14
+ const type = listElement.getAttribute( 'type' );
7
15
  const listAttributes = {
8
16
  ordered: 'OL' === listElement.tagName,
9
17
  anchor: listElement.id === '' ? undefined : listElement.id,
@@ -11,7 +19,7 @@ export function createListBlockFromDOMElement( listElement ) {
11
19
  ? parseInt( listElement.getAttribute( 'start' ), 10 )
12
20
  : undefined,
13
21
  reversed: listElement.hasAttribute( 'reversed' ) ? true : undefined,
14
- type: listElement.getAttribute( 'type' ) ?? undefined,
22
+ type: type && LIST_STYLES[ type ] ? LIST_STYLES[ type ] : undefined,
15
23
  };
16
24
 
17
25
  const innerBlocks = Array.from( listElement.children ).map(
@@ -78,3 +86,16 @@ export function migrateToListV2( attributes ) {
78
86
  listBlock.innerBlocks,
79
87
  ];
80
88
  }
89
+
90
+ export function migrateTypeToInlineStyle( attributes ) {
91
+ const { type } = attributes;
92
+
93
+ if ( type && LIST_STYLES[ type ] ) {
94
+ return {
95
+ ...attributes,
96
+ type: LIST_STYLES[ type ],
97
+ };
98
+ }
99
+
100
+ return attributes;
101
+ }
@@ -91,6 +91,7 @@
91
91
  },
92
92
  "supports": {
93
93
  "align": [ "wide", "full" ],
94
+ "ariaLabel": true,
94
95
  "html": false,
95
96
  "inserter": true,
96
97
  "typography": {
@@ -131,9 +132,10 @@
131
132
  }
132
133
  }
133
134
  }
134
- }
135
+ },
136
+ "interactivity": true
135
137
  },
136
- "viewScript": [ "file:./view.min.js", "file:./view-modal.min.js" ],
138
+ "viewScript": "file:./view.min.js",
137
139
  "editorStyle": "wp-block-navigation-editor",
138
140
  "style": "wp-block-navigation"
139
141
  }
@@ -13,6 +13,7 @@ export const ALLOWED_BLOCKS = [
13
13
  'core/site-logo',
14
14
  'core/navigation-submenu',
15
15
  'core/loginout',
16
+ 'core/buttons',
16
17
  ];
17
18
 
18
19
  export const PRIORITIZED_INSERTER_BLOCKS = [