@wordpress/block-library 10.2.0 → 10.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/accordion-panel/block.json +1 -0
  3. package/build/code/edit.cjs +3 -1
  4. package/build/code/edit.cjs.map +2 -2
  5. package/build/cover/block.json +1 -0
  6. package/build/cover/edit/block-controls.cjs +3 -1
  7. package/build/cover/edit/block-controls.cjs.map +2 -2
  8. package/build/cover/edit/index.cjs +75 -31
  9. package/build/cover/edit/index.cjs.map +2 -2
  10. package/build/embed/edit.cjs +1 -1
  11. package/build/embed/edit.cjs.map +2 -2
  12. package/build/embed/embed-placeholder.cjs +1 -1
  13. package/build/embed/embed-placeholder.cjs.map +2 -2
  14. package/build/gallery/dynamic-gallery.cjs +104 -61
  15. package/build/gallery/dynamic-gallery.cjs.map +3 -3
  16. package/build/gallery/use-dynamic-gallery.cjs +15 -8
  17. package/build/gallery/use-dynamic-gallery.cjs.map +2 -2
  18. package/build/heading/edit.cjs +1 -1
  19. package/build/heading/edit.cjs.map +2 -2
  20. package/build/html/modal.cjs +63 -54
  21. package/build/html/modal.cjs.map +3 -3
  22. package/build/icon/block.json +5 -3
  23. package/build/image/edit.cjs +1 -1
  24. package/build/image/edit.cjs.map +2 -2
  25. package/build/image/image.cjs +29 -5
  26. package/build/image/image.cjs.map +3 -3
  27. package/build/image/use-open-image-media-editor-modal.cjs +6 -2
  28. package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
  29. package/build/list-item/hooks/use-indent-list-item.cjs +10 -2
  30. package/build/list-item/hooks/use-indent-list-item.cjs.map +2 -2
  31. package/build/math/edit.cjs +39 -56
  32. package/build/math/edit.cjs.map +3 -3
  33. package/build/media-text/edit.cjs +2 -1
  34. package/build/media-text/edit.cjs.map +2 -2
  35. package/build/more/edit.cjs +2 -2
  36. package/build/more/edit.cjs.map +2 -2
  37. package/build/navigation/edit/index.cjs +30 -16
  38. package/build/navigation/edit/index.cjs.map +3 -3
  39. package/build/navigation/edit/use-layout-custom-properties.cjs +72 -0
  40. package/build/navigation/edit/use-layout-custom-properties.cjs.map +7 -0
  41. package/build/navigation/view.cjs +9 -6
  42. package/build/navigation/view.cjs.map +2 -2
  43. package/build/navigation-link/edit.cjs +3 -3
  44. package/build/navigation-link/edit.cjs.map +2 -2
  45. package/build/navigation-link/link-ui/index.cjs +2 -2
  46. package/build/navigation-link/link-ui/index.cjs.map +2 -2
  47. package/build/paragraph/block.json +0 -1
  48. package/build/paragraph/edit.cjs +5 -2
  49. package/build/paragraph/edit.cjs.map +3 -3
  50. package/build/paragraph/index.cjs +4 -1
  51. package/build/paragraph/index.cjs.map +2 -2
  52. package/build/playlist/context.cjs +2 -1
  53. package/build/playlist/context.cjs.map +2 -2
  54. package/build/playlist/edit.cjs +113 -26
  55. package/build/playlist/edit.cjs.map +2 -2
  56. package/build/playlist/utils.cjs +19 -4
  57. package/build/playlist/utils.cjs.map +2 -2
  58. package/build/playlist-track/edit.cjs +21 -6
  59. package/build/playlist-track/edit.cjs.map +2 -2
  60. package/build/post-content/edit.cjs +36 -15
  61. package/build/post-content/edit.cjs.map +2 -2
  62. package/build/post-featured-image/edit.cjs +3 -2
  63. package/build/post-featured-image/edit.cjs.map +2 -2
  64. package/build/post-terms/edit.cjs +2 -2
  65. package/build/post-terms/edit.cjs.map +2 -2
  66. package/build/post-title/edit.cjs +2 -2
  67. package/build/post-title/edit.cjs.map +2 -2
  68. package/build/preformatted/edit.cjs +3 -1
  69. package/build/preformatted/edit.cjs.map +2 -2
  70. package/build/pullquote/edit.cjs +5 -3
  71. package/build/pullquote/edit.cjs.map +2 -2
  72. package/build/query/edit/inspector-controls/index.cjs +4 -1
  73. package/build/query/edit/inspector-controls/index.cjs.map +2 -2
  74. package/build/query/edit/inspector-controls/offset-controls.cjs +1 -1
  75. package/build/query/edit/inspector-controls/offset-controls.cjs.map +2 -2
  76. package/build/read-more/edit.cjs +3 -1
  77. package/build/read-more/edit.cjs.map +2 -2
  78. package/build/site-tagline/edit.cjs +3 -1
  79. package/build/site-tagline/edit.cjs.map +2 -2
  80. package/build/site-title/edit.cjs +3 -1
  81. package/build/site-title/edit.cjs.map +2 -2
  82. package/build/social-links/edit.cjs +11 -4
  83. package/build/social-links/edit.cjs.map +2 -2
  84. package/build/tab-list/block.json +2 -1
  85. package/build/tab-list/edit.cjs +2 -0
  86. package/build/tab-list/edit.cjs.map +3 -3
  87. package/build/tab-list/tab-movers.cjs +87 -0
  88. package/build/tab-list/tab-movers.cjs.map +7 -0
  89. package/build/tab-panel/edit.cjs +1 -9
  90. package/build/tab-panel/edit.cjs.map +2 -2
  91. package/build/table/edit.cjs +1 -1
  92. package/build/table/edit.cjs.map +2 -2
  93. package/build/tabs/use-tab-actions.cjs +23 -1
  94. package/build/tabs/use-tab-actions.cjs.map +2 -2
  95. package/build/utils/caption.cjs +2 -2
  96. package/build/utils/caption.cjs.map +2 -2
  97. package/build/verse/edit.cjs +3 -1
  98. package/build/verse/edit.cjs.map +2 -2
  99. package/build/video/tracks-editor.cjs +0 -1
  100. package/build/video/tracks-editor.cjs.map +2 -2
  101. package/build-module/accordion-panel/block.json +1 -0
  102. package/build-module/code/edit.mjs +3 -1
  103. package/build-module/code/edit.mjs.map +2 -2
  104. package/build-module/cover/block.json +1 -0
  105. package/build-module/cover/edit/block-controls.mjs +3 -1
  106. package/build-module/cover/edit/block-controls.mjs.map +2 -2
  107. package/build-module/cover/edit/index.mjs +78 -34
  108. package/build-module/cover/edit/index.mjs.map +2 -2
  109. package/build-module/embed/edit.mjs +1 -1
  110. package/build-module/embed/edit.mjs.map +2 -2
  111. package/build-module/embed/embed-placeholder.mjs +1 -1
  112. package/build-module/embed/embed-placeholder.mjs.map +2 -2
  113. package/build-module/gallery/dynamic-gallery.mjs +104 -61
  114. package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
  115. package/build-module/gallery/use-dynamic-gallery.mjs +16 -9
  116. package/build-module/gallery/use-dynamic-gallery.mjs.map +2 -2
  117. package/build-module/heading/edit.mjs +1 -1
  118. package/build-module/heading/edit.mjs.map +2 -2
  119. package/build-module/html/modal.mjs +68 -55
  120. package/build-module/html/modal.mjs.map +2 -2
  121. package/build-module/icon/block.json +5 -3
  122. package/build-module/image/edit.mjs +1 -1
  123. package/build-module/image/edit.mjs.map +2 -2
  124. package/build-module/image/image.mjs +19 -5
  125. package/build-module/image/image.mjs.map +2 -2
  126. package/build-module/image/use-open-image-media-editor-modal.mjs +6 -2
  127. package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
  128. package/build-module/list-item/hooks/use-indent-list-item.mjs +10 -2
  129. package/build-module/list-item/hooks/use-indent-list-item.mjs.map +2 -2
  130. package/build-module/math/edit.mjs +41 -60
  131. package/build-module/math/edit.mjs.map +2 -2
  132. package/build-module/media-text/edit.mjs +2 -1
  133. package/build-module/media-text/edit.mjs.map +2 -2
  134. package/build-module/more/edit.mjs +2 -2
  135. package/build-module/more/edit.mjs.map +2 -2
  136. package/build-module/navigation/edit/index.mjs +30 -16
  137. package/build-module/navigation/edit/index.mjs.map +2 -2
  138. package/build-module/navigation/edit/use-layout-custom-properties.mjs +51 -0
  139. package/build-module/navigation/edit/use-layout-custom-properties.mjs.map +7 -0
  140. package/build-module/navigation/view.mjs +9 -6
  141. package/build-module/navigation/view.mjs.map +2 -2
  142. package/build-module/navigation-link/edit.mjs +3 -3
  143. package/build-module/navigation-link/edit.mjs.map +2 -2
  144. package/build-module/navigation-link/link-ui/index.mjs +2 -2
  145. package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
  146. package/build-module/paragraph/block.json +0 -1
  147. package/build-module/paragraph/edit.mjs +6 -2
  148. package/build-module/paragraph/edit.mjs.map +2 -2
  149. package/build-module/paragraph/index.mjs +4 -1
  150. package/build-module/paragraph/index.mjs.map +2 -2
  151. package/build-module/playlist/context.mjs +2 -1
  152. package/build-module/playlist/context.mjs.map +2 -2
  153. package/build-module/playlist/edit.mjs +113 -27
  154. package/build-module/playlist/edit.mjs.map +2 -2
  155. package/build-module/playlist/utils.mjs +19 -4
  156. package/build-module/playlist/utils.mjs.map +2 -2
  157. package/build-module/playlist-track/edit.mjs +21 -6
  158. package/build-module/playlist-track/edit.mjs.map +2 -2
  159. package/build-module/post-content/edit.mjs +37 -15
  160. package/build-module/post-content/edit.mjs.map +2 -2
  161. package/build-module/post-featured-image/edit.mjs +3 -2
  162. package/build-module/post-featured-image/edit.mjs.map +2 -2
  163. package/build-module/post-terms/edit.mjs +2 -2
  164. package/build-module/post-terms/edit.mjs.map +2 -2
  165. package/build-module/post-title/edit.mjs +2 -2
  166. package/build-module/post-title/edit.mjs.map +2 -2
  167. package/build-module/preformatted/edit.mjs +3 -1
  168. package/build-module/preformatted/edit.mjs.map +2 -2
  169. package/build-module/pullquote/edit.mjs +5 -3
  170. package/build-module/pullquote/edit.mjs.map +2 -2
  171. package/build-module/query/edit/inspector-controls/index.mjs +5 -2
  172. package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
  173. package/build-module/query/edit/inspector-controls/offset-controls.mjs +2 -2
  174. package/build-module/query/edit/inspector-controls/offset-controls.mjs.map +2 -2
  175. package/build-module/read-more/edit.mjs +3 -1
  176. package/build-module/read-more/edit.mjs.map +2 -2
  177. package/build-module/site-tagline/edit.mjs +3 -1
  178. package/build-module/site-tagline/edit.mjs.map +2 -2
  179. package/build-module/site-title/edit.mjs +3 -1
  180. package/build-module/site-title/edit.mjs.map +2 -2
  181. package/build-module/social-links/edit.mjs +11 -4
  182. package/build-module/social-links/edit.mjs.map +2 -2
  183. package/build-module/tab-list/block.json +2 -1
  184. package/build-module/tab-list/edit.mjs +2 -0
  185. package/build-module/tab-list/edit.mjs.map +2 -2
  186. package/build-module/tab-list/tab-movers.mjs +59 -0
  187. package/build-module/tab-list/tab-movers.mjs.map +7 -0
  188. package/build-module/tab-panel/edit.mjs +1 -9
  189. package/build-module/tab-panel/edit.mjs.map +2 -2
  190. package/build-module/table/edit.mjs +1 -1
  191. package/build-module/table/edit.mjs.map +2 -2
  192. package/build-module/tabs/use-tab-actions.mjs +23 -1
  193. package/build-module/tabs/use-tab-actions.mjs.map +2 -2
  194. package/build-module/utils/caption.mjs +2 -2
  195. package/build-module/utils/caption.mjs.map +2 -2
  196. package/build-module/verse/edit.mjs +3 -1
  197. package/build-module/verse/edit.mjs.map +2 -2
  198. package/build-module/video/tracks-editor.mjs +0 -1
  199. package/build-module/video/tracks-editor.mjs.map +2 -2
  200. package/build-style/cover/editor-rtl.css +3 -0
  201. package/build-style/cover/editor.css +3 -0
  202. package/build-style/editor-rtl.css +18 -41
  203. package/build-style/editor.css +18 -41
  204. package/build-style/icon/editor-rtl.css +1 -4
  205. package/build-style/icon/editor.css +1 -4
  206. package/build-style/image/editor-rtl.css +3 -32
  207. package/build-style/image/editor.css +3 -32
  208. package/build-style/playlist/editor-rtl.css +0 -5
  209. package/build-style/playlist/editor.css +0 -5
  210. package/build-style/playlist/style-rtl.css +44 -4
  211. package/build-style/playlist/style.css +44 -4
  212. package/build-style/pullquote/editor-rtl.css +4 -0
  213. package/build-style/pullquote/editor.css +4 -0
  214. package/build-style/style-rtl.css +44 -4
  215. package/build-style/style.css +44 -4
  216. package/build-style/tab-list/editor-rtl.css +101 -0
  217. package/build-style/tab-list/editor.css +101 -0
  218. package/package.json +43 -43
  219. package/src/accordion-panel/block.json +1 -0
  220. package/src/breadcrumbs/index.php +3 -1
  221. package/src/button/index.php +1 -1
  222. package/src/code/edit.js +7 -2
  223. package/src/cover/block.json +1 -0
  224. package/src/cover/edit/block-controls.js +5 -0
  225. package/src/cover/edit/index.js +100 -35
  226. package/src/cover/editor.scss +6 -0
  227. package/src/cover/index.php +9 -2
  228. package/src/editor.scss +1 -0
  229. package/src/embed/edit.js +3 -1
  230. package/src/embed/embed-placeholder.js +9 -7
  231. package/src/form/index.php +6 -4
  232. package/src/gallery/dynamic-gallery.js +133 -74
  233. package/src/gallery/use-dynamic-gallery.js +27 -12
  234. package/src/heading/edit.js +1 -1
  235. package/src/html/modal.js +13 -2
  236. package/src/icon/README.md +1 -3
  237. package/src/icon/block.json +5 -3
  238. package/src/icon/editor.scss +1 -4
  239. package/src/image/edit.js +1 -5
  240. package/src/image/editor.scss +6 -46
  241. package/src/image/image.js +37 -3
  242. package/src/image/test/use-open-image-media-editor-modal.js +37 -1
  243. package/src/image/use-open-image-media-editor-modal.js +8 -1
  244. package/src/latest-posts/index.php +3 -2
  245. package/src/list-item/hooks/use-indent-list-item.js +10 -1
  246. package/src/math/edit.js +42 -59
  247. package/src/media-text/edit.js +1 -0
  248. package/src/media-text/index.php +11 -2
  249. package/src/more/edit.js +7 -4
  250. package/src/navigation/edit/index.js +52 -36
  251. package/src/navigation/edit/test/layout-custom-properties.js +138 -0
  252. package/src/navigation/edit/use-layout-custom-properties.js +84 -0
  253. package/src/navigation/index.php +123 -12
  254. package/src/navigation/test/view.js +51 -0
  255. package/src/navigation/view.js +15 -14
  256. package/src/navigation-link/edit.js +11 -7
  257. package/src/navigation-link/index.php +64 -0
  258. package/src/navigation-link/link-ui/index.js +2 -1
  259. package/src/navigation-link/test/__snapshots__/hooks.js.snap +1 -1
  260. package/src/page-list/index.php +4 -3
  261. package/src/paragraph/README.md +0 -1
  262. package/src/paragraph/block.json +0 -1
  263. package/src/paragraph/edit.js +9 -2
  264. package/src/paragraph/index.js +4 -1
  265. package/src/pattern/index.php +5 -5
  266. package/src/playlist/context.js +1 -0
  267. package/src/playlist/edit.js +151 -47
  268. package/src/playlist/editor.scss +0 -7
  269. package/src/playlist/index.php +14 -9
  270. package/src/playlist/style.scss +3 -0
  271. package/src/playlist/test/edit-component.js +139 -0
  272. package/src/playlist/test/edit.js +30 -0
  273. package/src/playlist/utils.js +25 -4
  274. package/src/playlist-track/edit.js +22 -5
  275. package/src/playlist-track/index.php +8 -7
  276. package/src/playlist-track/test/edit.js +87 -3
  277. package/src/post-content/edit.js +45 -16
  278. package/src/post-excerpt/index.php +4 -1
  279. package/src/post-featured-image/edit.js +3 -2
  280. package/src/post-featured-image/index.php +4 -1
  281. package/src/post-terms/edit.js +7 -4
  282. package/src/post-title/edit.js +5 -3
  283. package/src/preformatted/edit.js +7 -2
  284. package/src/pullquote/edit.js +9 -4
  285. package/src/pullquote/editor.scss +6 -0
  286. package/src/query/edit/inspector-controls/index.js +5 -2
  287. package/src/query/edit/inspector-controls/offset-controls.js +2 -2
  288. package/src/read-more/edit.js +7 -2
  289. package/src/rss/index.php +9 -3
  290. package/src/site-tagline/edit.js +7 -2
  291. package/src/site-title/edit.js +7 -2
  292. package/src/social-link/index.php +19 -9
  293. package/src/social-links/edit.js +21 -12
  294. package/src/tab-list/block.json +2 -1
  295. package/src/tab-list/edit.js +2 -0
  296. package/src/tab-list/editor.scss +9 -0
  297. package/src/tab-list/tab-movers.js +72 -0
  298. package/src/tab-panel/edit.js +1 -9
  299. package/src/table/edit.js +1 -1
  300. package/src/table-of-contents/index.php +386 -1
  301. package/src/tabs/use-tab-actions.js +32 -3
  302. package/src/tag-cloud/index.php +3 -2
  303. package/src/template-part/index.php +2 -1
  304. package/src/utils/caption.js +7 -4
  305. package/src/utils/test/waveform-utils.js +63 -0
  306. package/src/verse/edit.js +7 -2
  307. package/src/video/index.php +2 -2
  308. package/src/video/tracks-editor.js +0 -1
@@ -91,7 +91,7 @@ function EmbedPlaceholder({
91
91
  children: (0, import_i18n._x)("Try again", "button label")
92
92
  }
93
93
  ),
94
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
+ fallback && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
95
95
  import_components.Button,
96
96
  {
97
97
  __next40pxDefaultSize: true,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/embed/embed-placeholder.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tButton,\n\tPlaceholder,\n\t__experimentalInputControl as InputControl,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Link, Stack } from '@wordpress/ui';\n\nexport default function EmbedPlaceholder( {\n\ticon,\n\tlabel,\n\tvalue,\n\tonSubmit,\n\tonChange,\n\tcannotEmbed,\n\tfallback,\n\ttryAgain,\n} ) {\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\tlabel={ label }\n\t\t\tclassName=\"wp-block-embed\"\n\t\t\tinstructions={ __(\n\t\t\t\t'Paste a link to the content you want to display on your site.'\n\t\t\t) }\n\t\t>\n\t\t\t<form onSubmit={ onSubmit }>\n\t\t\t\t<InputControl\n\t\t\t\t\ttype=\"url\"\n\t\t\t\t\tvalue={ value || '' }\n\t\t\t\t\tclassName=\"wp-block-embed__placeholder-input\"\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tplaceholder={ __( 'Enter URL to embed here…' ) }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t\t<Button __next40pxDefaultSize variant=\"primary\" type=\"submit\">\n\t\t\t\t\t{ _x( 'Embed', 'button label' ) }\n\t\t\t\t</Button>\n\t\t\t</form>\n\t\t\t<div className=\"wp-block-embed__learn-more\">\n\t\t\t\t<Link\n\t\t\t\t\topenInNewTab\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/documentation/article/embeds/'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Learn more about embeds' ) }\n\t\t\t\t</Link>\n\t\t\t</div>\n\t\t\t{ cannotEmbed && (\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"md\"\n\t\t\t\t\tclassName=\"components-placeholder__error\"\n\t\t\t\t>\n\t\t\t\t\t<div className=\"components-placeholder__instructions\">\n\t\t\t\t\t\t{ __( 'Sorry, this content could not be embedded.' ) }\n\t\t\t\t\t</div>\n\t\t\t\t\t<Stack direction=\"row\" gap=\"md\" justify=\"flex-start\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ tryAgain }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Try again', 'button label' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ fallback }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Convert to link', 'button label' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</Stack>\n\t\t\t\t</Stack>\n\t\t\t) }\n\t\t</Placeholder>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuB;AACvB,wBAIO;AACP,0BAA0B;AAC1B,gBAA4B;AAclB;AAZK,SAAR,iBAAmC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO,4CAAC,iCAAU,MAAc,YAAU,MAAC;AAAA,MAC3C;AAAA,MACA,WAAU;AAAA,MACV,kBAAe;AAAA,QACd;AAAA,MACD;AAAA,MAEA;AAAA,qDAAC,UAAK,UACL;AAAA;AAAA,YAAC,kBAAAA;AAAA,YAAA;AAAA,cACA,MAAK;AAAA,cACL,OAAQ,SAAS;AAAA,cACjB,WAAU;AAAA,cACV;AAAA,cACA,qBAAmB;AAAA,cACnB,iBAAc,gBAAI,0BAA2B;AAAA,cAC7C;AAAA;AAAA,UACD;AAAA,UACA,4CAAC,4BAAO,uBAAqB,MAAC,SAAQ,WAAU,MAAK,UAClD,8BAAI,SAAS,cAAe,GAC/B;AAAA,WACD;AAAA,QACA,4CAAC,SAAI,WAAU,8BACd;AAAA,UAAC;AAAA;AAAA,YACA,cAAY;AAAA,YACZ,UAAO;AAAA,cACN;AAAA,YACD;AAAA,YAEE,8BAAI,yBAA0B;AAAA;AAAA,QACjC,GACD;AAAA,QACE,eACD;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,KAAI;AAAA,YACJ,WAAU;AAAA,YAEV;AAAA,0DAAC,SAAI,WAAU,wCACZ,8BAAI,4CAA6C,GACpD;AAAA,cACA,6CAAC,mBAAM,WAAU,OAAM,KAAI,MAAK,SAAQ,cACvC;AAAA;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,SAAU;AAAA,oBAER,8BAAI,aAAa,cAAe;AAAA;AAAA,gBACnC;AAAA,gBACA;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,SAAU;AAAA,oBAER,8BAAI,mBAAmB,cAAe;AAAA;AAAA,gBACzC;AAAA,iBACD;AAAA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tButton,\n\tPlaceholder,\n\t__experimentalInputControl as InputControl,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Link, Stack } from '@wordpress/ui';\n\nexport default function EmbedPlaceholder( {\n\ticon,\n\tlabel,\n\tvalue,\n\tonSubmit,\n\tonChange,\n\tcannotEmbed,\n\tfallback,\n\ttryAgain,\n} ) {\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\tlabel={ label }\n\t\t\tclassName=\"wp-block-embed\"\n\t\t\tinstructions={ __(\n\t\t\t\t'Paste a link to the content you want to display on your site.'\n\t\t\t) }\n\t\t>\n\t\t\t<form onSubmit={ onSubmit }>\n\t\t\t\t<InputControl\n\t\t\t\t\ttype=\"url\"\n\t\t\t\t\tvalue={ value || '' }\n\t\t\t\t\tclassName=\"wp-block-embed__placeholder-input\"\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tplaceholder={ __( 'Enter URL to embed here…' ) }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t\t<Button __next40pxDefaultSize variant=\"primary\" type=\"submit\">\n\t\t\t\t\t{ _x( 'Embed', 'button label' ) }\n\t\t\t\t</Button>\n\t\t\t</form>\n\t\t\t<div className=\"wp-block-embed__learn-more\">\n\t\t\t\t<Link\n\t\t\t\t\topenInNewTab\n\t\t\t\t\thref={ __(\n\t\t\t\t\t\t'https://wordpress.org/documentation/article/embeds/'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Learn more about embeds' ) }\n\t\t\t\t</Link>\n\t\t\t</div>\n\t\t\t{ cannotEmbed && (\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"md\"\n\t\t\t\t\tclassName=\"components-placeholder__error\"\n\t\t\t\t>\n\t\t\t\t\t<div className=\"components-placeholder__instructions\">\n\t\t\t\t\t\t{ __( 'Sorry, this content could not be embedded.' ) }\n\t\t\t\t\t</div>\n\t\t\t\t\t<Stack direction=\"row\" gap=\"md\" justify=\"flex-start\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ tryAgain }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ _x( 'Try again', 'button label' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ fallback && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\tonClick={ fallback }\n\t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cACA,6CAAC,mBAAM,WAAU,OAAM,KAAI,MAAK,SAAQ,cACvC;AAAA;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,SAAU;AAAA,oBAER,8BAAI,aAAa,cAAe;AAAA;AAAA,gBACnC;AAAA,gBACE,YACD;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,SAAU;AAAA,oBAER,8BAAI,mBAAmB,cAAe;AAAA;AAAA,gBACzC;AAAA,iBAEF;AAAA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF;AAEF;",
6
6
  "names": ["InputControl"]
7
7
  }
@@ -60,6 +60,23 @@ function OrderControl({ orderby, order, onChange }) {
60
60
  }
61
61
  );
62
62
  }
63
+ function DetachGalleryDialog({ onConfirm, onCancel }) {
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
+ import_components.__experimentalConfirmDialog,
66
+ {
67
+ isOpen: true,
68
+ title: (0, import_i18n.__)("Detach Gallery"),
69
+ __experimentalHideHeader: false,
70
+ confirmButtonText: (0, import_i18n.__)("Detach"),
71
+ onConfirm,
72
+ onCancel,
73
+ size: "medium",
74
+ children: (0, import_i18n.__)(
75
+ "The gallery displays the images attached to the post. Detaching will enable you to add, delete, or reorder images. However, new attachments will no longer be added automatically."
76
+ )
77
+ }
78
+ );
79
+ }
63
80
  function GallerySourcePanel({
64
81
  dynamic,
65
82
  dropdownMenuProps,
@@ -81,6 +98,7 @@ function GallerySourcePanel({
81
98
  } = dynamic;
82
99
  const isDynamic = !!dynamicContent;
83
100
  const [isConfirming, setIsConfirming] = (0, import_element.useState)(false);
101
+ const [isConfirmingDetach, setIsConfirmingDetach] = (0, import_element.useState)(false);
84
102
  function requestEnableDynamicMode() {
85
103
  if (hasImages) {
86
104
  setIsConfirming(true);
@@ -89,63 +107,75 @@ function GallerySourcePanel({
89
107
  }
90
108
  }
91
109
  if (isDynamic) {
92
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
93
- import_components.__experimentalToolsPanel,
94
- {
95
- label: (0, import_i18n.__)("Source"),
96
- resetAll: resetSource,
97
- dropdownMenuProps,
98
- children: [
99
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wp-block-gallery__source-settings", children: [
100
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "wp-block-gallery__source-description", children: sourceDescriptor?.description ?? (0, import_i18n.__)("Dynamic images.") }),
110
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
111
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
112
+ import_components.__experimentalToolsPanel,
113
+ {
114
+ label: (0, import_i18n.__)("Source"),
115
+ resetAll: resetSource,
116
+ dropdownMenuProps,
117
+ children: [
118
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "wp-block-gallery__source-settings", children: [
119
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "wp-block-gallery__source-description", children: sourceDescriptor?.description ?? (0, import_i18n.__)("Dynamic images.") }),
120
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
+ import_components.Button,
122
+ {
123
+ __next40pxDefaultSize: true,
124
+ variant: "secondary",
125
+ onClick: () => setIsConfirmingDetach(true),
126
+ disabled: isResolvingDynamic,
127
+ accessibleWhenDisabled: true,
128
+ children: (0, import_i18n.__)("Detach Gallery")
129
+ }
130
+ )
131
+ ] }),
132
+ hasMoreImagesThanCap && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
133
+ import_components.Notice,
134
+ {
135
+ className: "wp-block-gallery__source-notice",
136
+ status: "warning",
137
+ isDismissible: false,
138
+ children: (0, import_i18n.sprintf)(
139
+ /* translators: 1: number of images shown. 2: total number of matching images. */
140
+ (0, import_i18n.__)(
141
+ "Only the first %1$d of %2$d images will be displayed."
142
+ ),
143
+ import_dynamic_source.MAX_IMAGES,
144
+ dynamicMediaTotal
145
+ )
146
+ }
147
+ ),
101
148
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
102
- import_components.Button,
149
+ import_components.__experimentalToolsPanelItem,
103
150
  {
104
- __next40pxDefaultSize: true,
105
- variant: "secondary",
106
- onClick: convertToStatic,
107
- disabled: isResolvingDynamic,
108
- accessibleWhenDisabled: true,
109
- children: (0, import_i18n.__)("Convert to individual images")
151
+ isShownByDefault: true,
152
+ label: (0, import_i18n.__)("Order by"),
153
+ hasValue: () => sourceOrderby !== import_dynamic_source.DEFAULT_ORDERBY || sourceOrder !== import_dynamic_source.DEFAULT_ORDER,
154
+ onDeselect: () => setSourceOrder(void 0, void 0),
155
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
156
+ OrderControl,
157
+ {
158
+ orderby: sourceOrderby,
159
+ order: sourceOrder,
160
+ onChange: ({ orderby, order }) => setSourceOrder(orderby, order)
161
+ }
162
+ )
110
163
  }
111
164
  )
112
- ] }),
113
- hasMoreImagesThanCap && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
114
- import_components.Notice,
115
- {
116
- className: "wp-block-gallery__source-notice",
117
- status: "warning",
118
- isDismissible: false,
119
- children: (0, import_i18n.sprintf)(
120
- /* translators: 1: number of images shown. 2: total number of matching images. */
121
- (0, import_i18n.__)(
122
- "Only the first %1$d of %2$d images will be displayed."
123
- ),
124
- import_dynamic_source.MAX_IMAGES,
125
- dynamicMediaTotal
126
- )
127
- }
128
- ),
129
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
- import_components.__experimentalToolsPanelItem,
131
- {
132
- isShownByDefault: true,
133
- label: (0, import_i18n.__)("Order by"),
134
- hasValue: () => sourceOrderby !== import_dynamic_source.DEFAULT_ORDERBY || sourceOrder !== import_dynamic_source.DEFAULT_ORDER,
135
- onDeselect: () => setSourceOrder(void 0, void 0),
136
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
- OrderControl,
138
- {
139
- orderby: sourceOrderby,
140
- order: sourceOrder,
141
- onChange: ({ orderby, order }) => setSourceOrder(orderby, order)
142
- }
143
- )
144
- }
145
- )
146
- ]
147
- }
148
- );
165
+ ]
166
+ }
167
+ ),
168
+ isConfirmingDetach && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
169
+ DetachGalleryDialog,
170
+ {
171
+ onConfirm: () => {
172
+ convertToStatic();
173
+ setIsConfirmingDetach(false);
174
+ },
175
+ onCancel: () => setIsConfirmingDetach(false)
176
+ }
177
+ )
178
+ ] });
149
179
  }
150
180
  if (!canUseDynamicSource) {
151
181
  return null;
@@ -213,16 +243,29 @@ function GalleryDynamicView({
213
243
  convertToStatic
214
244
  } = dynamic;
215
245
  const blockEditingMode = (0, import_block_editor.useBlockEditingMode)();
246
+ const [isConfirmingDetach, setIsConfirmingDetach] = (0, import_element.useState)(false);
216
247
  const emptyInstructions = isResolvingDynamic ? (0, import_i18n.__)("Loading images…") : sourceDescriptor?.emptyMessage ?? (0, import_i18n.__)("Dynamic images will appear here.");
217
248
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
218
- blockEditingMode === "default" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { group: "other", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
219
- import_components.ToolbarButton,
220
- {
221
- onClick: convertToStatic,
222
- disabled: isResolvingDynamic,
223
- children: (0, import_i18n.__)("Convert to images")
224
- }
225
- ) }),
249
+ blockEditingMode === "default" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
250
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockControls, { group: "other", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
251
+ import_components.ToolbarButton,
252
+ {
253
+ onClick: () => setIsConfirmingDetach(true),
254
+ disabled: isResolvingDynamic,
255
+ children: (0, import_i18n.__)("Detach")
256
+ }
257
+ ) }),
258
+ isConfirmingDetach && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
259
+ DetachGalleryDialog,
260
+ {
261
+ onConfirm: () => {
262
+ convertToStatic();
263
+ setIsConfirmingDetach(false);
264
+ },
265
+ onCancel: () => setIsConfirmingDetach(false)
266
+ }
267
+ )
268
+ ] }),
226
269
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figure", { ...blockProps, children: [
227
270
  dynamicImageBlocks.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockContextProvider, { value: galleryContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
228
271
  GalleryImagesPreview,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/gallery/dynamic-gallery.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\tNotice,\n\tPanelBody,\n\tPlaceholder,\n\tSelectControl,\n\tSpinner,\n\tToolbarButton,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport {\n\tBlockContextProvider,\n\tBlockControls,\n\tuseBlockEditingMode,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { sharedIcon } from './shared-icon';\nimport { Caption } from '../utils/caption';\nimport { DEFAULT_ORDERBY, DEFAULT_ORDER, MAX_IMAGES } from './dynamic-source';\n\n/**\n * Ordering options for a dynamic gallery source. Each value is a composite\n * `\"orderby/order\"` string mapping to the matching `/wp/v2/media` collection\n * params. `menu_order` is deliberately omitted — it isn't a valid REST `orderby`\n * value, so the editor preview couldn't reproduce it (see `dynamic-source.js`).\n */\nconst ORDER_OPTIONS = [\n\t{ label: __( 'Newest to oldest' ), value: 'date/desc' },\n\t{ label: __( 'Oldest to newest' ), value: 'date/asc' },\n\t{\n\t\t/* translators: Label for ordering images by title in ascending order. */\n\t\tlabel: __( 'A → Z' ),\n\t\tvalue: 'title/asc',\n\t},\n\t{\n\t\t/* translators: Label for ordering images by title in descending order. */\n\t\tlabel: __( 'Z → A' ),\n\t\tvalue: 'title/desc',\n\t},\n];\n\n/**\n * \"Order by\" control for a dynamic gallery, mirroring the Query Loop block's\n * `OrderControl`: a single `SelectControl` whose value composites `orderby` and\n * `order`, split apart again on change.\n *\n * @param {Object} props\n * @param {string} props.orderby Current `orderby` value.\n * @param {string} props.order Current `order` value (`asc`/`desc`).\n * @param {Function} props.onChange Called with `{ orderby, order }` on change.\n */\nfunction OrderControl( { orderby, order, onChange } ) {\n\treturn (\n\t\t<SelectControl\n\t\t\tlabel={ __( 'Order by' ) }\n\t\t\tvalue={ `${ orderby }/${ order }` }\n\t\t\toptions={ ORDER_OPTIONS }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tconst [ newOrderby, newOrder ] = value.split( '/' );\n\t\t\t\tonChange( { orderby: newOrderby, order: newOrder } );\n\t\t\t} }\n\t\t/>\n\t);\n}\n\n/**\n * The Gallery block's \"Source\" inspector panel.\n *\n * In dynamic mode it shows the resolved source, a control to convert back to\n * individual images, and the source ordering. In static mode it offers the\n * entry point into dynamic mode — and, since switching discards any hand-added\n * images, owns the confirmation dialog for that one-way change. Rendered inside\n * the block's `InspectorControls`, alongside the Settings panel.\n *\n * @param {Object} props\n * @param {Object} props.dynamic The `useDynamicGallery` result.\n * @param {Object} props.dropdownMenuProps Shared ToolsPanel dropdown menu props.\n * @param {boolean} props.hasImages Whether the gallery has manually-added images.\n */\nexport function GallerySourcePanel( {\n\tdynamic,\n\tdropdownMenuProps,\n\thasImages,\n} ) {\n\tconst {\n\t\tdynamicContent,\n\t\tcanUseDynamicSource,\n\t\tsourceDescriptor,\n\t\tsourceOrderby,\n\t\tsourceOrder,\n\t\tsetSourceOrder,\n\t\tconvertToStatic,\n\t\tenableDynamicMode,\n\t\tresetSource,\n\t\tisResolvingDynamic,\n\t\thasMoreImagesThanCap,\n\t\tdynamicMediaTotal,\n\t} = dynamic;\n\tconst isDynamic = !! dynamicContent;\n\n\tconst [ isConfirming, setIsConfirming ] = useState( false );\n\n\t// Entering dynamic mode discards any hand-added images, so confirm first\n\t// when there are images to lose; otherwise switch straight away.\n\tfunction requestEnableDynamicMode() {\n\t\tif ( hasImages ) {\n\t\t\tsetIsConfirming( true );\n\t\t} else {\n\t\t\tenableDynamicMode();\n\t\t}\n\t}\n\n\tif ( isDynamic ) {\n\t\treturn (\n\t\t\t<ToolsPanel\n\t\t\t\tlabel={ __( 'Source' ) }\n\t\t\t\tresetAll={ resetSource }\n\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t>\n\t\t\t\t<div className=\"wp-block-gallery__source-settings\">\n\t\t\t\t\t<p className=\"wp-block-gallery__source-description\">\n\t\t\t\t\t\t{ sourceDescriptor?.description ??\n\t\t\t\t\t\t\t__( 'Dynamic images.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ convertToStatic }\n\t\t\t\t\t\t// Guard the race where the media is still resolving:\n\t\t\t\t\t\t// converting now would map over an incomplete (or empty)\n\t\t\t\t\t\t// list and produce a gallery missing images.\n\t\t\t\t\t\tdisabled={ isResolvingDynamic }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Convert to individual images' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t\t{ hasMoreImagesThanCap && (\n\t\t\t\t\t<Notice\n\t\t\t\t\t\tclassName=\"wp-block-gallery__source-notice\"\n\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: 1: number of images shown. 2: total number of matching images. */\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Only the first %1$d of %2$d images will be displayed.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tMAX_IMAGES,\n\t\t\t\t\t\t\tdynamicMediaTotal\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Notice>\n\t\t\t\t) }\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tisShownByDefault\n\t\t\t\t\tlabel={ __( 'Order by' ) }\n\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\tsourceOrderby !== DEFAULT_ORDERBY ||\n\t\t\t\t\t\tsourceOrder !== DEFAULT_ORDER\n\t\t\t\t\t}\n\t\t\t\t\tonDeselect={ () => setSourceOrder( undefined, undefined ) }\n\t\t\t\t>\n\t\t\t\t\t<OrderControl\n\t\t\t\t\t\torderby={ sourceOrderby }\n\t\t\t\t\t\torder={ sourceOrder }\n\t\t\t\t\t\tonChange={ ( { orderby, order } ) =>\n\t\t\t\t\t\t\tsetSourceOrder( orderby, order )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t</ToolsPanel>\n\t\t);\n\t}\n\n\t// In static mode this panel is just an entry into dynamic mode, so hide it\n\t// when there's no post type to preview against. This is intentionally\n\t// stricter than the placeholder's entry button (see `edit.js`), which stays\n\t// available anywhere because the source resolves at render time.\n\tif ( ! canUseDynamicSource ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Source' ) }>\n\t\t\t\t<div className=\"wp-block-gallery__source-settings\">\n\t\t\t\t\t{ /*\n\t\t\t\t\t * Hardcoded on purpose: this single-source entry button (and\n\t\t\t\t\t * its confirm dialog below) is temporary. Once more sources\n\t\t\t\t\t * exist it becomes a \"Choose source\" select whose options read\n\t\t\t\t\t * from each source descriptor's `title`, with help text\n\t\t\t\t\t * carrying the per-source explanation this string does today.\n\t\t\t\t\t */ }\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ requestEnableDynamicMode }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Use images attached to the post' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t</PanelBody>\n\t\t\t{ isConfirming && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen\n\t\t\t\t\ttitle={ __( 'Use images attached to the post?' ) }\n\t\t\t\t\t__experimentalHideHeader={ false }\n\t\t\t\t\tconfirmButtonText={ __( 'Use attached images' ) }\n\t\t\t\t\tonConfirm={ () => {\n\t\t\t\t\t\tenableDynamicMode();\n\t\t\t\t\t\tsetIsConfirming( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCancel={ () => setIsConfirming( false ) }\n\t\t\t\t\tsize=\"medium\"\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'The images in this gallery will be replaced, but will remain in the media library.'\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders the resolved image blocks as a read-only preview.\n *\n * `useBlockPreview` returns a `useDisabled` ref that makes its subtree inert, so\n * previewed images (including any links) aren't interactive in the editor. The\n * ref needs a real element, yet the images must stay flex children of the gallery\n * `<figure>` and sit beside an editable caption. `display: contents` resolves\n * this: the wrapper carries the ref but generates no box, so the image figures\n * remain the figure's flex items and only they are disabled — the caption sibling\n * stays editable. This relies on the gallery's image styles using descendant\n * (not direct-child) selectors, which the box-less wrapper leaves intact.\n *\n * @param {Object} props\n * @param {Object[]} props.imageBlocks Non-persisted `core/image` blocks to preview.\n */\nfunction GalleryImagesPreview( { imageBlocks } ) {\n\tconst { children, ref, className } = useBlockPreview( {\n\t\tblocks: imageBlocks,\n\t} );\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ className }\n\t\t\tstyle={ { display: 'contents' } }\n\t\t>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * Renders a dynamic-mode gallery on the canvas:\n *\n * - a block-toolbar control to convert back to individual images;\n * - the gallery `<figure>` wrapper holding a non-editable preview of the\n * resolved media (or a placeholder while resolving / when nothing is found),\n * with the gallery's provided context so the previewed images inherit\n * gallery-wide settings;\n * - an editable gallery-level caption, alongside the read-only preview;\n * - the (empty) inner blocks kept mounted so the container's `allowedBlocks: []`\n * keeps syncing to block list settings (which blocks insertion and hides the\n * List View).\n *\n * @param {Object} props\n * @param {Object} props.dynamic The `useDynamicGallery` result.\n * @param {Object} props.blockProps The gallery's `useBlockProps()` result.\n * @param {Object} props.innerBlocksProps The gallery's `useInnerBlocksProps()` result.\n * @param {Object} props.attributes The gallery block attributes.\n * @param {Function} props.setAttributes The block's `setAttributes`.\n * @param {boolean} props.isSelected Whether the gallery block is selected.\n * @param {Function} props.insertBlocksAfter Inserts blocks after the gallery.\n * @param {boolean} props.isContentLocked Whether the gallery is content-locked.\n * @param {boolean} props.multiGallerySelection Whether multiple galleries are selected.\n */\nexport function GalleryDynamicView( {\n\tdynamic,\n\tblockProps,\n\tinnerBlocksProps,\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tisContentLocked,\n\tmultiGallerySelection,\n} ) {\n\tconst {\n\t\tsourceDescriptor,\n\t\tdynamicImageBlocks,\n\t\tgalleryContext,\n\t\tisResolvingDynamic,\n\t\tconvertToStatic,\n\t} = dynamic;\n\n\t// Converting to a static gallery materializes editable inner blocks, which\n\t// is a structural change. Only offer it when the block is fully editable:\n\t// under a content lock (e.g. inside a `contentOnly` group) the editing mode\n\t// is `'contentOnly'`/`'disabled'`, where structural toolbar controls are\n\t// hidden and the conversion shouldn't be possible.\n\tconst blockEditingMode = useBlockEditingMode();\n\n\t// Empty-state copy for the preview. Framed as forward-looking (\"… will appear\n\t// here\") rather than as an error, since the same empty result covers both a\n\t// post with no matching images and a template with no post in context yet —\n\t// in either case the source simply resolves to nothing right now. The per-\n\t// source wording comes from the source descriptor.\n\tconst emptyInstructions = isResolvingDynamic\n\t\t? __( 'Loading images…' )\n\t\t: sourceDescriptor?.emptyMessage ??\n\t\t __( 'Dynamic images will appear here.' );\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tonClick={ convertToStatic }\n\t\t\t\t\t\t// Same guard as the inspector's \"Convert to individual\n\t\t\t\t\t\t// images\": both call `convertToStatic`, which would map over\n\t\t\t\t\t\t// a still-resolving (or empty) media list. (`ToolbarButton`\n\t\t\t\t\t\t// stays focusable when disabled by default.)\n\t\t\t\t\t\tdisabled={ isResolvingDynamic }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Convert to images' ) }\n\t\t\t\t\t</ToolbarButton>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ dynamicImageBlocks.length ? (\n\t\t\t\t\t<BlockContextProvider value={ galleryContext }>\n\t\t\t\t\t\t<GalleryImagesPreview\n\t\t\t\t\t\t\timageBlocks={ dynamicImageBlocks }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t) : (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ sharedIcon }\n\t\t\t\t\t\tlabel={ __( 'Gallery' ) }\n\t\t\t\t\t\tinstructions={ emptyInstructions }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isResolvingDynamic && <Spinner /> }\n\t\t\t\t\t</Placeholder>\n\t\t\t\t) }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tshowToolbarButton={\n\t\t\t\t\t\t! multiGallerySelection && ! isContentLocked\n\t\t\t\t\t}\n\t\t\t\t\tclassName=\"blocks-gallery-caption\"\n\t\t\t\t\tlabel={ __( 'Gallery caption text' ) }\n\t\t\t\t\tplaceholder={ __( 'Add gallery caption' ) }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t\t{ /*\n\t\t\t * Dynamic mode shows a preview instead of real inner blocks, but the\n\t\t\t * empty inner blocks are still rendered here for their side effect:\n\t\t\t * the `allowedBlocks: []` passed to `useInnerBlocksProps` only syncs\n\t\t\t * to block list settings while the inner blocks are mounted (via\n\t\t\t * `useNestedSettingsUpdate`). That setting is what blocks insertion\n\t\t\t * (`canInsertBlockType`) and hides the now-unusable List View\n\t\t\t * (`shouldRenderBlockListView`). With no inner blocks and no appender,\n\t\t\t * this renders no output of its own.\n\t\t\t */ }\n\t\t\t{ innerBlocksProps.children }\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAAyB;AACzB,wBAWO;AACP,0BAKO;AAKP,yBAA2B;AAC3B,qBAAwB;AACxB,4BAA2D;AAmCzD;AA3BF,IAAM,gBAAgB;AAAA,EACrB,EAAE,WAAO,gBAAI,kBAAmB,GAAG,OAAO,YAAY;AAAA,EACtD,EAAE,WAAO,gBAAI,kBAAmB,GAAG,OAAO,WAAW;AAAA,EACrD;AAAA;AAAA,IAEC,WAAO,gBAAI,OAAQ;AAAA,IACnB,OAAO;AAAA,EACR;AAAA,EACA;AAAA;AAAA,IAEC,WAAO,gBAAI,OAAQ;AAAA,IACnB,OAAO;AAAA,EACR;AACD;AAYA,SAAS,aAAc,EAAE,SAAS,OAAO,SAAS,GAAI;AACrD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAQ,gBAAI,UAAW;AAAA,MACvB,OAAQ,GAAI,OAAQ,IAAK,KAAM;AAAA,MAC/B,SAAU;AAAA,MACV,U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0BO,SAAS,mBAAoB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAOJ,QAAM,uBAAmB,yCAAoB;AAO7C,QAAM,oBAAoB,yBACvB,gBAAI,iBAAkB,IACtB,kBAAkB,oBAClB,gBAAI,kCAAmC;AAE1C,SACC,4EACG;AAAA,yBAAqB,aACtB,4CAAC,qCAAc,OAAM,SACpB;AAAA,MAAC;AAAA;AAAA,QACA,SAAU;AAAA,QAKV,UAAW;AAAA,QAET,8BAAI,mBAAoB;AAAA;AAAA,IAC3B,GACD;AAAA,IAED,6CAAC,YAAS,GAAG,YACV;AAAA,yBAAmB,SACpB,4CAAC,4CAAqB,OAAQ,gBAC7B;AAAA,QAAC;AAAA;AAAA,UACA,aAAc;AAAA;AAAA,MACf,GACD,IAEA;AAAA,QAAC;AAAA;AAAA,UACA,MAAO;AAAA,UACP,WAAQ,gBAAI,SAAU;AAAA,UACtB,cAAe;AAAA,UAEb,gCAAsB,4CAAC,6BAAQ;AAAA;AAAA,MAClC;AAAA,MAED;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,mBACC,CAAE,yBAAyB,CAAE;AAAA,UAE9B,WAAU;AAAA,UACV,WAAQ,gBAAI,sBAAuB;AAAA,UACnC,iBAAc,gBAAI,qBAAsB;AAAA;AAAA,MACzC;AAAA,OACD;AAAA,IAWE,iBAAiB;AAAA,KACpB;AAEF;",
6
- "names": ["ToolsPanel", "ToolsPanelItem", "ConfirmDialog", "useBlockPreview"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport {\n\tButton,\n\tNotice,\n\tPanelBody,\n\tPlaceholder,\n\tSelectControl,\n\tSpinner,\n\tToolbarButton,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport {\n\tBlockContextProvider,\n\tBlockControls,\n\tuseBlockEditingMode,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { sharedIcon } from './shared-icon';\nimport { Caption } from '../utils/caption';\nimport { DEFAULT_ORDERBY, DEFAULT_ORDER, MAX_IMAGES } from './dynamic-source';\n\n/**\n * Ordering options for a dynamic gallery source. Each value is a composite\n * `\"orderby/order\"` string mapping to the matching `/wp/v2/media` collection\n * params. `menu_order` is deliberately omitted — it isn't a valid REST `orderby`\n * value, so the editor preview couldn't reproduce it (see `dynamic-source.js`).\n */\nconst ORDER_OPTIONS = [\n\t{ label: __( 'Newest to oldest' ), value: 'date/desc' },\n\t{ label: __( 'Oldest to newest' ), value: 'date/asc' },\n\t{\n\t\t/* translators: Label for ordering images by title in ascending order. */\n\t\tlabel: __( 'A → Z' ),\n\t\tvalue: 'title/asc',\n\t},\n\t{\n\t\t/* translators: Label for ordering images by title in descending order. */\n\t\tlabel: __( 'Z → A' ),\n\t\tvalue: 'title/desc',\n\t},\n];\n\n/**\n * \"Order by\" control for a dynamic gallery, mirroring the Query Loop block's\n * `OrderControl`: a single `SelectControl` whose value composites `orderby` and\n * `order`, split apart again on change.\n *\n * @param {Object} props\n * @param {string} props.orderby Current `orderby` value.\n * @param {string} props.order Current `order` value (`asc`/`desc`).\n * @param {Function} props.onChange Called with `{ orderby, order }` on change.\n */\nfunction OrderControl( { orderby, order, onChange } ) {\n\treturn (\n\t\t<SelectControl\n\t\t\tlabel={ __( 'Order by' ) }\n\t\t\tvalue={ `${ orderby }/${ order }` }\n\t\t\toptions={ ORDER_OPTIONS }\n\t\t\tonChange={ ( value ) => {\n\t\t\t\tconst [ newOrderby, newOrder ] = value.split( '/' );\n\t\t\t\tonChange( { orderby: newOrderby, order: newOrder } );\n\t\t\t} }\n\t\t/>\n\t);\n}\n\n/**\n * Confirmation for leaving dynamic mode, shown from both the block toolbar and\n * the Source panel so the two entry points explain the change identically.\n *\n * Detaching keeps the images the gallery currently shows but breaks the link to\n * its source, so it's worth confirming — mirroring the dialog `GallerySourcePanel`\n * shows for the opposite direction.\n *\n * @param {Object} props\n * @param {Function} props.onConfirm Called when the user confirms detaching.\n * @param {Function} props.onCancel Called when the user dismisses the dialog.\n */\nfunction DetachGalleryDialog( { onConfirm, onCancel } ) {\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen\n\t\t\ttitle={ __( 'Detach Gallery' ) }\n\t\t\t__experimentalHideHeader={ false }\n\t\t\tconfirmButtonText={ __( 'Detach' ) }\n\t\t\tonConfirm={ onConfirm }\n\t\t\tonCancel={ onCancel }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t{ __(\n\t\t\t\t'The gallery displays the images attached to the post. Detaching will enable you to add, delete, or reorder images. However, new attachments will no longer be added automatically.'\n\t\t\t) }\n\t\t</ConfirmDialog>\n\t);\n}\n\n/**\n * The Gallery block's \"Source\" inspector panel.\n *\n * In dynamic mode it shows the resolved source, a control to detach the gallery\n * from it, and the source ordering. In static mode it offers the entry point\n * into dynamic mode. Either direction is a one-way change, so both are behind a\n * confirmation dialog this panel owns. Rendered inside the block's\n * `InspectorControls`, alongside the Settings panel.\n *\n * @param {Object} props\n * @param {Object} props.dynamic The `useDynamicGallery` result.\n * @param {Object} props.dropdownMenuProps Shared ToolsPanel dropdown menu props.\n * @param {boolean} props.hasImages Whether the gallery has manually-added images.\n */\nexport function GallerySourcePanel( {\n\tdynamic,\n\tdropdownMenuProps,\n\thasImages,\n} ) {\n\tconst {\n\t\tdynamicContent,\n\t\tcanUseDynamicSource,\n\t\tsourceDescriptor,\n\t\tsourceOrderby,\n\t\tsourceOrder,\n\t\tsetSourceOrder,\n\t\tconvertToStatic,\n\t\tenableDynamicMode,\n\t\tresetSource,\n\t\tisResolvingDynamic,\n\t\thasMoreImagesThanCap,\n\t\tdynamicMediaTotal,\n\t} = dynamic;\n\tconst isDynamic = !! dynamicContent;\n\n\tconst [ isConfirming, setIsConfirming ] = useState( false );\n\tconst [ isConfirmingDetach, setIsConfirmingDetach ] = useState( false );\n\n\t// Entering dynamic mode discards any hand-added images, so confirm first\n\t// when there are images to lose; otherwise switch straight away.\n\tfunction requestEnableDynamicMode() {\n\t\tif ( hasImages ) {\n\t\t\tsetIsConfirming( true );\n\t\t} else {\n\t\t\tenableDynamicMode();\n\t\t}\n\t}\n\n\tif ( isDynamic ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Source' ) }\n\t\t\t\t\tresetAll={ resetSource }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<div className=\"wp-block-gallery__source-settings\">\n\t\t\t\t\t\t<p className=\"wp-block-gallery__source-description\">\n\t\t\t\t\t\t\t{ sourceDescriptor?.description ??\n\t\t\t\t\t\t\t\t__( 'Dynamic images.' ) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tonClick={ () => setIsConfirmingDetach( true ) }\n\t\t\t\t\t\t\t// Guard the race where the media is still resolving:\n\t\t\t\t\t\t\t// detaching now would map over an incomplete (or\n\t\t\t\t\t\t\t// empty) list and produce a gallery missing images.\n\t\t\t\t\t\t\tdisabled={ isResolvingDynamic }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Detach Gallery' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ hasMoreImagesThanCap && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"wp-block-gallery__source-notice\"\n\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: 1: number of images shown. 2: total number of matching images. */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Only the first %1$d of %2$d images will be displayed.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tMAX_IMAGES,\n\t\t\t\t\t\t\t\tdynamicMediaTotal\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\tlabel={ __( 'Order by' ) }\n\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\tsourceOrderby !== DEFAULT_ORDERBY ||\n\t\t\t\t\t\t\tsourceOrder !== DEFAULT_ORDER\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetSourceOrder( undefined, undefined )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\torderby={ sourceOrderby }\n\t\t\t\t\t\t\torder={ sourceOrder }\n\t\t\t\t\t\t\tonChange={ ( { orderby, order } ) =>\n\t\t\t\t\t\t\t\tsetSourceOrder( orderby, order )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t\t{ isConfirmingDetach && (\n\t\t\t\t\t<DetachGalleryDialog\n\t\t\t\t\t\tonConfirm={ () => {\n\t\t\t\t\t\t\tconvertToStatic();\n\t\t\t\t\t\t\tsetIsConfirmingDetach( false );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonCancel={ () => setIsConfirmingDetach( false ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\t// In static mode this panel is just an entry into dynamic mode, so hide it\n\t// when there's no post type to preview against. This is intentionally\n\t// stricter than the placeholder's entry button (see `edit.js`), which stays\n\t// available anywhere because the source resolves at render time.\n\tif ( ! canUseDynamicSource ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Source' ) }>\n\t\t\t\t<div className=\"wp-block-gallery__source-settings\">\n\t\t\t\t\t{ /*\n\t\t\t\t\t * Hardcoded on purpose: this single-source entry button (and\n\t\t\t\t\t * its confirm dialog below) is temporary. Once more sources\n\t\t\t\t\t * exist it becomes a \"Choose source\" select whose options read\n\t\t\t\t\t * from each source descriptor's `title`, with help text\n\t\t\t\t\t * carrying the per-source explanation this string does today.\n\t\t\t\t\t */ }\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\tonClick={ requestEnableDynamicMode }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Use images attached to the post' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t</PanelBody>\n\t\t\t{ isConfirming && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen\n\t\t\t\t\ttitle={ __( 'Use images attached to the post?' ) }\n\t\t\t\t\t__experimentalHideHeader={ false }\n\t\t\t\t\tconfirmButtonText={ __( 'Use attached images' ) }\n\t\t\t\t\tonConfirm={ () => {\n\t\t\t\t\t\tenableDynamicMode();\n\t\t\t\t\t\tsetIsConfirming( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonCancel={ () => setIsConfirming( false ) }\n\t\t\t\t\tsize=\"medium\"\n\t\t\t\t>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'The images in this gallery will be replaced, but will remain in the media library.'\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders the resolved image blocks as a read-only preview.\n *\n * `useBlockPreview` returns a `useDisabled` ref that makes its subtree inert, so\n * previewed images (including any links) aren't interactive in the editor. The\n * ref needs a real element, yet the images must stay flex children of the gallery\n * `<figure>` and sit beside an editable caption. `display: contents` resolves\n * this: the wrapper carries the ref but generates no box, so the image figures\n * remain the figure's flex items and only they are disabled — the caption sibling\n * stays editable. This relies on the gallery's image styles using descendant\n * (not direct-child) selectors, which the box-less wrapper leaves intact.\n *\n * @param {Object} props\n * @param {Object[]} props.imageBlocks Non-persisted `core/image` blocks to preview.\n */\nfunction GalleryImagesPreview( { imageBlocks } ) {\n\tconst { children, ref, className } = useBlockPreview( {\n\t\tblocks: imageBlocks,\n\t} );\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ className }\n\t\t\tstyle={ { display: 'contents' } }\n\t\t>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * Renders a dynamic-mode gallery on the canvas:\n *\n * - a block-toolbar control to detach the gallery from its source, confirmed in\n * a dialog;\n * - the gallery `<figure>` wrapper holding a non-editable preview of the\n * resolved media (or a placeholder while resolving / when nothing is found),\n * with the gallery's provided context so the previewed images inherit\n * gallery-wide settings;\n * - an editable gallery-level caption, alongside the read-only preview;\n * - the (empty) inner blocks kept mounted so the container's `allowedBlocks: []`\n * keeps syncing to block list settings (which blocks insertion and hides the\n * List View).\n *\n * @param {Object} props\n * @param {Object} props.dynamic The `useDynamicGallery` result.\n * @param {Object} props.blockProps The gallery's `useBlockProps()` result.\n * @param {Object} props.innerBlocksProps The gallery's `useInnerBlocksProps()` result.\n * @param {Object} props.attributes The gallery block attributes.\n * @param {Function} props.setAttributes The block's `setAttributes`.\n * @param {boolean} props.isSelected Whether the gallery block is selected.\n * @param {Function} props.insertBlocksAfter Inserts blocks after the gallery.\n * @param {boolean} props.isContentLocked Whether the gallery is content-locked.\n * @param {boolean} props.multiGallerySelection Whether multiple galleries are selected.\n */\nexport function GalleryDynamicView( {\n\tdynamic,\n\tblockProps,\n\tinnerBlocksProps,\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tinsertBlocksAfter,\n\tisContentLocked,\n\tmultiGallerySelection,\n} ) {\n\tconst {\n\t\tsourceDescriptor,\n\t\tdynamicImageBlocks,\n\t\tgalleryContext,\n\t\tisResolvingDynamic,\n\t\tconvertToStatic,\n\t} = dynamic;\n\n\t// Detaching the gallery materializes editable inner blocks, which is a\n\t// structural change. Only offer it when the block is fully editable:\n\t// under a content lock (e.g. inside a `contentOnly` group) the editing mode\n\t// is `'contentOnly'`/`'disabled'`, where structural toolbar controls are\n\t// hidden and the conversion shouldn't be possible.\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst [ isConfirmingDetach, setIsConfirmingDetach ] = useState( false );\n\n\t// Empty-state copy for the preview. Framed as forward-looking (\"… will appear\n\t// here\") rather than as an error, since the same empty result covers both a\n\t// post with no matching images and a template with no post in context yet —\n\t// in either case the source simply resolves to nothing right now. The per-\n\t// source wording comes from the source descriptor.\n\tconst emptyInstructions = isResolvingDynamic\n\t\t? __( 'Loading images…' )\n\t\t: sourceDescriptor?.emptyMessage ??\n\t\t __( 'Dynamic images will appear here.' );\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ () => setIsConfirmingDetach( true ) }\n\t\t\t\t\t\t\t// Same guard as the inspector's \"Detach Gallery\": both end in\n\t\t\t\t\t\t\t// `convertToStatic`, which would map over a\n\t\t\t\t\t\t\t// still-resolving (or empty) media list.\n\t\t\t\t\t\t\t// (`ToolbarButton` stays focusable when disabled by\n\t\t\t\t\t\t\t// default.)\n\t\t\t\t\t\t\tdisabled={ isResolvingDynamic }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t{ isConfirmingDetach && (\n\t\t\t\t\t\t<DetachGalleryDialog\n\t\t\t\t\t\t\tonConfirm={ () => {\n\t\t\t\t\t\t\t\tconvertToStatic();\n\t\t\t\t\t\t\t\tsetIsConfirmingDetach( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonCancel={ () => setIsConfirmingDetach( false ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ dynamicImageBlocks.length ? (\n\t\t\t\t\t<BlockContextProvider value={ galleryContext }>\n\t\t\t\t\t\t<GalleryImagesPreview\n\t\t\t\t\t\t\timageBlocks={ dynamicImageBlocks }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t) : (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ sharedIcon }\n\t\t\t\t\t\tlabel={ __( 'Gallery' ) }\n\t\t\t\t\t\tinstructions={ emptyInstructions }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isResolvingDynamic && <Spinner /> }\n\t\t\t\t\t</Placeholder>\n\t\t\t\t) }\n\t\t\t\t<Caption\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tshowToolbarButton={\n\t\t\t\t\t\t! multiGallerySelection && ! isContentLocked\n\t\t\t\t\t}\n\t\t\t\t\tclassName=\"blocks-gallery-caption\"\n\t\t\t\t\tlabel={ __( 'Gallery caption text' ) }\n\t\t\t\t\tplaceholder={ __( 'Add gallery caption' ) }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t\t{ /*\n\t\t\t * Dynamic mode shows a preview instead of real inner blocks, but the\n\t\t\t * empty inner blocks are still rendered here for their side effect:\n\t\t\t * the `allowedBlocks: []` passed to `useInnerBlocksProps` only syncs\n\t\t\t * to block list settings while the inner blocks are mounted (via\n\t\t\t * `useNestedSettingsUpdate`). That setting is what blocks insertion\n\t\t\t * (`canInsertBlockType`) and hides the now-unusable List View\n\t\t\t * (`shouldRenderBlockListView`). With no inner blocks and no appender,\n\t\t\t * this renders no output of its own.\n\t\t\t */ }\n\t\t\t{ innerBlocksProps.children }\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAAyB;AACzB,wBAWO;AACP,0BAKO;AAKP,yBAA2B;AAC3B,qBAAwB;AACxB,4BAA2D;AAmCzD;AA3BF,IAAM,gBAAgB;AAAA,EACrB,EAAE,WAAO,gBAAI,kBAAmB,GAAG,OAAO,YAAY;AAAA,EACtD,EAAE,WAAO,gBAAI,kBAAmB,GAAG,OAAO,WAAW;AAAA,EACrD;AAAA;AAAA,IAEC,WAAO,gBAAI,OAAQ;AAAA,IACnB,OAAO;AAAA,EACR;AAAA,EACA;AAAA;AAAA,IAEC,WAAO,gBAAI,OAAQ;AAAA,IACnB,OAAO;AAAA,EACR;AACD;AAYA,SAAS,aAAc,EAAE,SAAS,OAAO,SAAS,GAAI;AACrD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAQ,gBAAI,UAAW;AAAA,MACvB,OAAQ,GAAI,OAAQ,IAAK,KAAM;AAAA,MAC/B,SAAU;AAAA,MACV,UAAW,CAAE,UAAW;AACvB,cAAM,CAAE,YAAY,QAAS,IAAI,MAAM,MAAO,GAAI;AAClD,iBAAU,EAAE,SAAS,YAAY,OAAO,SAAS,CAAE;AAAA,MACpD;AAAA;AAAA,EACD;AAEF;AAcA,SAAS,oBAAqB,EAAE,WAAW,SAAS,GAAI;AACvD,SACC;AAAA,IAAC,kBAAAA;AAAA,IAAA;AAAA,MACA,QAAM;AAAA,MACN,WAAQ,gBAAI,gBAA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gBAAI,SAAU;AAAA,UACtB,cAAe;AAAA,UAEb,gCAAsB,4CAAC,6BAAQ;AAAA;AAAA,MAClC;AAAA,MAED;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,mBACC,CAAE,yBAAyB,CAAE;AAAA,UAE9B,WAAU;AAAA,UACV,WAAQ,gBAAI,sBAAuB;AAAA,UACnC,iBAAc,gBAAI,qBAAsB;AAAA;AAAA,MACzC;AAAA,OACD;AAAA,IAWE,iBAAiB;AAAA,KACpB;AAEF;",
6
+ "names": ["ConfirmDialog", "ToolsPanel", "ToolsPanelItem", "useBlockPreview"]
7
7
  }
@@ -73,7 +73,8 @@ function useDynamicGallery({
73
73
  const sourceDescriptor = (0, import_dynamic_source.getDynamicSource)(dynamicContent?.source);
74
74
  const sourceOrderby = dynamicContent?.args?.orderBy ?? import_dynamic_source.DEFAULT_ORDERBY;
75
75
  const sourceOrder = dynamicContent?.args?.order ?? import_dynamic_source.DEFAULT_ORDER;
76
- const { replaceInnerBlocks } = (0, import_data.useDispatch)(import_block_editor.store);
76
+ const registry = (0, import_data.useRegistry)();
77
+ const { replaceInnerBlocks, __unstableMarkNextChangeAsNotPersistent } = (0, import_data.useDispatch)(import_block_editor.store);
77
78
  const query = (0, import_element.useMemo)(
78
79
  () => dynamicContent ? (0, import_dynamic_source.getSourceQuery)(dynamicContent, { postId }) : null,
79
80
  [dynamicContent, postId]
@@ -129,15 +130,21 @@ function useDynamicGallery({
129
130
  ]
130
131
  );
131
132
  function enableDynamicMode() {
132
- setAttributes({ dynamicContent: { source: import_dynamic_source.ATTACHED_MEDIA } });
133
- replaceInnerBlocks(clientId, []);
133
+ registry.batch(() => {
134
+ setAttributes({ dynamicContent: { source: import_dynamic_source.ATTACHED_MEDIA } });
135
+ __unstableMarkNextChangeAsNotPersistent();
136
+ replaceInnerBlocks(clientId, []);
137
+ });
134
138
  }
135
139
  function convertToStatic() {
136
- replaceInnerBlocks(
137
- clientId,
138
- buildImageBlocks(dynamicMedia, imageAttributes)
139
- );
140
- setAttributes({ dynamicContent: void 0 });
140
+ registry.batch(() => {
141
+ replaceInnerBlocks(
142
+ clientId,
143
+ buildImageBlocks(dynamicMedia, imageAttributes)
144
+ );
145
+ __unstableMarkNextChangeAsNotPersistent();
146
+ setAttributes({ dynamicContent: void 0 });
147
+ });
141
148
  }
142
149
  function setSourceOrder(nextOrderby, nextOrder) {
143
150
  const nextArgs = { ...dynamicContent?.args };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/gallery/use-dynamic-gallery.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { pickRelevantMediaFiles } from './shared';\nimport { getHrefAndDestination } from './utils';\nimport { getUpdatedLinkTargetSettings } from '../image/utils';\nimport {\n\tgetSourceQuery,\n\tgetDynamicSource,\n\tATTACHED_MEDIA,\n\tDEFAULT_ORDERBY,\n\tDEFAULT_ORDER,\n\tMAX_IMAGES,\n} from './dynamic-source';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Builds the attributes for a `core/image` block from a media (attachment)\n * record, applying the gallery-wide settings that affect how the image renders.\n *\n * Used to construct the (non-persisted) image blocks previewed in dynamic mode,\n * and the real image blocks created when a dynamic gallery is converted\n * (\"pinned\") back to individual images. The frontend equivalent is\n * `block_core_gallery_render_dynamic_image()` in `index.php`.\n *\n * @param {Object} media A media object as returned by the REST API.\n * @param {Object} galleryAttributes The gallery block's attributes.\n * @return {Object} Attributes to pass to `createBlock( 'core/image', ... )`.\n */\nfunction buildImageBlockAttributes( media, galleryAttributes ) {\n\tconst { sizeSlug, linkTo, linkTarget, aspectRatio } = galleryAttributes;\n\tconst hasAspectRatio = !! aspectRatio && aspectRatio !== 'auto';\n\n\treturn {\n\t\tid: media.id,\n\t\t...pickRelevantMediaFiles( media, sizeSlug ),\n\t\t...getHrefAndDestination( media, linkTo ),\n\t\t...getUpdatedLinkTargetSettings( linkTarget, galleryAttributes ),\n\t\tsizeSlug,\n\t\t// Raw caption, mirroring the frontend (`index.php`). Gap: the REST API\n\t\t// exposes no caption run through `wp_get_attachment_caption`, so neither\n\t\t// side applies that filter.\n\t\tcaption: media.caption?.raw || '',\n\t\talt: media.alt_text || '',\n\t\taspectRatio: hasAspectRatio ? aspectRatio : undefined,\n\t\t// Pair `scale` with `aspectRatio` so the image crops rather than stretches,\n\t\t// matching the image block's UI and the frontend (`index.php`).\n\t\tscale: hasAspectRatio ? 'cover' : undefined,\n\t};\n}\n\n/**\n * Builds a set of `core/image` blocks from the resolved media, applying the\n * gallery-wide settings. Each call mints fresh client IDs, so it can produce\n * both the editor preview and the materialized inner blocks on convert.\n *\n * @param {Object[]} media Media records from the REST API.\n * @param {Object} galleryAttributes The image-relevant gallery attributes.\n * @return {Object[]} New `core/image` block instances.\n */\nfunction buildImageBlocks( media, galleryAttributes ) {\n\treturn media.map( ( mediaItem ) =>\n\t\tcreateBlock(\n\t\t\t'core/image',\n\t\t\tbuildImageBlockAttributes( mediaItem, galleryAttributes )\n\t\t)\n\t);\n}\n\n/**\n * Bundles the Gallery block's \"dynamic mode\" source resolution and actions.\n *\n * Dynamic mode resolves the gallery's images from a configured source\n * (`attributes.dynamicContent`) instead of from manually-added inner image\n * blocks. This hook centralizes the shared, single-instance pieces — the source\n * resolution (one `getEntityRecords`), the editor-preview blocks, and the\n * mode/ordering actions — out of the block's `edit` component. Transient UI\n * concerns (e.g. the convert-to-dynamic confirmation) live in the components\n * that own them.\n *\n * @param {Object} options\n * @param {Object} options.attributes The gallery block attributes.\n * @param {Function} options.setAttributes The block's `setAttributes`.\n * @param {string} options.clientId The block client ID.\n * @param {?number} options.postId The current post ID (from block context).\n * @param {?string} options.postType The current post type (from block context).\n * @return {Object} Dynamic-mode source data and actions.\n */\nexport default function useDynamicGallery( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tpostId,\n\tpostType,\n} ) {\n\tconst { dynamicContent } = attributes;\n\n\t// Whether dynamic mode makes sense in the current editing context. A\n\t// `postType` means the block will resolve against some post at render time —\n\t// either a concrete post (post/page editor, Query Loop item) or a post-bound\n\t// template (`single`, `page`) whose post is filled in by `get_the_ID()` on the\n\t// frontend (see `index.php`). Without it (template part, pattern, generic\n\t// template) there's no post to attach to, so the source can never resolve.\n\tconst canUseDynamicSource = !! postType;\n\n\t// The descriptor for the configured source (its `title`/`description`/\n\t// `emptyMessage`), resolved once here so consumers read the copy without\n\t// re-deriving it from `dynamicContent`. `undefined` for an unknown source.\n\tconst sourceDescriptor = getDynamicSource( dynamicContent?.source );\n\n\t// Current source ordering, falling back to the shared defaults when unset.\n\tconst sourceOrderby = dynamicContent?.args?.orderBy ?? DEFAULT_ORDERBY;\n\tconst sourceOrder = dynamicContent?.args?.order ?? DEFAULT_ORDER;\n\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\n\t// Resolve the configured source to a media query. `null` (static mode, or an\n\t// unresolvable source) short-circuits the select below so no request fires.\n\tconst query = useMemo(\n\t\t() =>\n\t\t\tdynamicContent\n\t\t\t\t? getSourceQuery( dynamicContent, { postId } )\n\t\t\t\t: null,\n\t\t[ dynamicContent, postId ]\n\t);\n\n\tconst { dynamicMedia, dynamicMediaTotal, isResolvingDynamic } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! query ) {\n\t\t\t\treturn {\n\t\t\t\t\tdynamicMedia: EMPTY_ARRAY,\n\t\t\t\t\tdynamicMediaTotal: 0,\n\t\t\t\t\tisResolvingDynamic: false,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst selectorArgs = [ 'postType', 'attachment', query ];\n\t\t\treturn {\n\t\t\t\tdynamicMedia:\n\t\t\t\t\tselect( coreStore ).getEntityRecords( ...selectorArgs ) ??\n\t\t\t\t\tEMPTY_ARRAY,\n\t\t\t\t// Total matching attachments (the `X-WP-Total` header), which the\n\t\t\t\t// query's `per_page` cap doesn't bound — so it reveals when the\n\t\t\t\t// post has more attached images than are shown.\n\t\t\t\tdynamicMediaTotal:\n\t\t\t\t\tselect( coreStore ).getEntityRecordsTotalItems(\n\t\t\t\t\t\t...selectorArgs\n\t\t\t\t\t) ?? 0,\n\t\t\t\tisResolvingDynamic: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ query ]\n\t);\n\n\t// The source caps results at `MAX_IMAGES` (matching the frontend), so flag\n\t// when the post has more attached images than the gallery can show.\n\tconst hasMoreImagesThanCap = dynamicMediaTotal > MAX_IMAGES;\n\n\t// The only gallery settings that affect how an image renders, and so the\n\t// only ones `buildImageBlockAttributes` reads. Depending on this narrowed\n\t// set (rather than the whole `attributes` object) keeps the preview from\n\t// rebuilding on unrelated edits, e.g. typing in the gallery caption.\n\tconst { sizeSlug, linkTo, linkTarget, aspectRatio } = attributes;\n\tconst imageAttributes = useMemo(\n\t\t() => ( { sizeSlug, linkTo, linkTarget, aspectRatio } ),\n\t\t[ sizeSlug, linkTo, linkTarget, aspectRatio ]\n\t);\n\n\t// The (non-persisted) `core/image` blocks used for the editor preview.\n\t// Rebuilt when the resolved media or an image-relevant setting changes.\n\tconst dynamicImageBlocks = useMemo(\n\t\t() => buildImageBlocks( dynamicMedia, imageAttributes ),\n\t\t[ dynamicMedia, imageAttributes ]\n\t);\n\n\t// Context the gallery provides to its (previewed) image blocks.\n\tconst galleryContext = useMemo(\n\t\t() => ( {\n\t\t\tallowResize: attributes.allowResize ?? false,\n\t\t\timageCrop: attributes.imageCrop,\n\t\t\tfixedHeight: attributes.fixedHeight,\n\t\t\tnavigationButtonType: attributes.navigationButtonType,\n\t\t} ),\n\t\t[\n\t\t\tattributes.allowResize,\n\t\t\tattributes.imageCrop,\n\t\t\tattributes.fixedHeight,\n\t\t\tattributes.navigationButtonType,\n\t\t]\n\t);\n\n\t// Switches the gallery into dynamic mode, displaying images attached to the\n\t// current post. Clearing the inner blocks removes the manually-added images:\n\t// they're the gallery's image data, so there's nothing else to reset. The\n\t// legacy `images`/`ids` attributes aren't touched — they're back-compat shims\n\t// for the pre-innerBlocks format (see `deprecated.js`/`transforms.js`), empty\n\t// on any gallery reachable here.\n\tfunction enableDynamicMode() {\n\t\tsetAttributes( { dynamicContent: { source: ATTACHED_MEDIA } } );\n\t\treplaceInnerBlocks( clientId, [] );\n\t}\n\n\t// \"Pins\" a dynamic gallery: materializes the currently-resolved media as\n\t// real, editable image blocks and leaves dynamic mode.\n\tfunction convertToStatic() {\n\t\t// Build fresh blocks rather than reusing the preview's `dynamicImageBlocks`\n\t\t// so the materialized inner blocks get their own client IDs, distinct from\n\t\t// the (disabled) preview instances.\n\t\treplaceInnerBlocks(\n\t\t\tclientId,\n\t\t\tbuildImageBlocks( dynamicMedia, imageAttributes )\n\t\t);\n\t\tsetAttributes( { dynamicContent: undefined } );\n\t}\n\n\t// Updates the source ordering within `dynamicContent.args`. Passing\n\t// `undefined` (or the default order) strips the keys so they aren't\n\t// persisted redundantly and the ToolsPanel item reads as unset.\n\tfunction setSourceOrder( nextOrderby, nextOrder ) {\n\t\tconst nextArgs = { ...dynamicContent?.args };\n\t\tdelete nextArgs.orderBy;\n\t\tdelete nextArgs.order;\n\t\tif (\n\t\t\tnextOrderby !== undefined &&\n\t\t\t( nextOrderby !== DEFAULT_ORDERBY || nextOrder !== DEFAULT_ORDER )\n\t\t) {\n\t\t\tnextArgs.orderBy = nextOrderby;\n\t\t\tnextArgs.order = nextOrder;\n\t\t}\n\t\tconst nextSource = { ...dynamicContent };\n\t\tif ( Object.keys( nextArgs ).length ) {\n\t\t\tnextSource.args = nextArgs;\n\t\t} else {\n\t\t\tdelete nextSource.args;\n\t\t}\n\t\tsetAttributes( { dynamicContent: nextSource } );\n\t}\n\n\t// Resets the source to its bare form: keeps the source kind, drops its args.\n\tfunction resetSource() {\n\t\tsetAttributes( {\n\t\t\tdynamicContent: { source: dynamicContent.source },\n\t\t} );\n\t}\n\n\treturn {\n\t\tdynamicContent,\n\t\tcanUseDynamicSource,\n\t\tsourceDescriptor,\n\t\thasMoreImagesThanCap,\n\t\tdynamicMediaTotal,\n\t\tsourceOrderby,\n\t\tsourceOrder,\n\t\tdynamicMedia,\n\t\tdynamicImageBlocks,\n\t\tisResolvingDynamic,\n\t\tgalleryContext,\n\t\tenableDynamicMode,\n\t\tconvertToStatic,\n\t\tsetSourceOrder,\n\t\tresetSource,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,kBAAuC;AACvC,0BAA0C;AAC1C,uBAAmC;AACnC,oBAA4B;AAK5B,oBAAuC;AACvC,mBAAsC;AACtC,IAAAA,gBAA6C;AAC7C,4BAOO;AAEP,IAAM,cAAc,CAAC;AAerB,SAAS,0BAA2B,OAAO,mBAAoB;AAC9D,QAAM,EAAE,UAAU,QAAQ,YAAY,YAAY,IAAI;AACtD,QAAM,iBAAiB,CAAC,CAAE,eAAe,gBAAgB;AAEzD,SAAO;AAAA,IACN,IAAI,MAAM;AAAA,IACV,OAAG,sCAAwB,OAAO,QAAS;AAAA,IAC3C,OAAG,oCAAuB,OAAO,MAAO;AAAA,IACxC,OAAG,4CAA8B,YAAY,iBAAkB;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA,IAIA,SAAS,MAAM,SAAS,OAAO;AAAA,IAC/B,KAAK,MAAM,YAAY;AAAA,IACvB,aAAa,iBAAiB,cAAc;AAAA;AAAA;AAAA,IAG5C,OAAO,iBAAiB,UAAU;AAAA,EACnC;AACD;AAWA,SAAS,iBAAkB,OAAO,mBAAoB;AACrD,SAAO,MAAM;AAAA,IAAK,CAAE,kBACnB;AAAA,MACC;AAAA,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,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { pickRelevantMediaFiles } from './shared';\nimport { getHrefAndDestination } from './utils';\nimport { getUpdatedLinkTargetSettings } from '../image/utils';\nimport {\n\tgetSourceQuery,\n\tgetDynamicSource,\n\tATTACHED_MEDIA,\n\tDEFAULT_ORDERBY,\n\tDEFAULT_ORDER,\n\tMAX_IMAGES,\n} from './dynamic-source';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Builds the attributes for a `core/image` block from a media (attachment)\n * record, applying the gallery-wide settings that affect how the image renders.\n *\n * Used to construct the (non-persisted) image blocks previewed in dynamic mode,\n * and the real image blocks created when a dynamic gallery is converted\n * (\"pinned\") back to individual images. The frontend equivalent is\n * `block_core_gallery_render_dynamic_image()` in `index.php`.\n *\n * @param {Object} media A media object as returned by the REST API.\n * @param {Object} galleryAttributes The gallery block's attributes.\n * @return {Object} Attributes to pass to `createBlock( 'core/image', ... )`.\n */\nfunction buildImageBlockAttributes( media, galleryAttributes ) {\n\tconst { sizeSlug, linkTo, linkTarget, aspectRatio } = galleryAttributes;\n\tconst hasAspectRatio = !! aspectRatio && aspectRatio !== 'auto';\n\n\treturn {\n\t\tid: media.id,\n\t\t...pickRelevantMediaFiles( media, sizeSlug ),\n\t\t...getHrefAndDestination( media, linkTo ),\n\t\t...getUpdatedLinkTargetSettings( linkTarget, galleryAttributes ),\n\t\tsizeSlug,\n\t\t// Raw caption, mirroring the frontend (`index.php`). Gap: the REST API\n\t\t// exposes no caption run through `wp_get_attachment_caption`, so neither\n\t\t// side applies that filter.\n\t\tcaption: media.caption?.raw || '',\n\t\talt: media.alt_text || '',\n\t\taspectRatio: hasAspectRatio ? aspectRatio : undefined,\n\t\t// Pair `scale` with `aspectRatio` so the image crops rather than stretches,\n\t\t// matching the image block's UI and the frontend (`index.php`).\n\t\tscale: hasAspectRatio ? 'cover' : undefined,\n\t};\n}\n\n/**\n * Builds a set of `core/image` blocks from the resolved media, applying the\n * gallery-wide settings. Each call mints fresh client IDs, so it can produce\n * both the editor preview and the materialized inner blocks on convert.\n *\n * @param {Object[]} media Media records from the REST API.\n * @param {Object} galleryAttributes The image-relevant gallery attributes.\n * @return {Object[]} New `core/image` block instances.\n */\nfunction buildImageBlocks( media, galleryAttributes ) {\n\treturn media.map( ( mediaItem ) =>\n\t\tcreateBlock(\n\t\t\t'core/image',\n\t\t\tbuildImageBlockAttributes( mediaItem, galleryAttributes )\n\t\t)\n\t);\n}\n\n/**\n * Bundles the Gallery block's \"dynamic mode\" source resolution and actions.\n *\n * Dynamic mode resolves the gallery's images from a configured source\n * (`attributes.dynamicContent`) instead of from manually-added inner image\n * blocks. This hook centralizes the shared, single-instance pieces — the source\n * resolution (one `getEntityRecords`), the editor-preview blocks, and the\n * mode/ordering actions — out of the block's `edit` component. Transient UI\n * concerns (e.g. the convert-to-dynamic confirmation) live in the components\n * that own them.\n *\n * @param {Object} options\n * @param {Object} options.attributes The gallery block attributes.\n * @param {Function} options.setAttributes The block's `setAttributes`.\n * @param {string} options.clientId The block client ID.\n * @param {?number} options.postId The current post ID (from block context).\n * @param {?string} options.postType The current post type (from block context).\n * @return {Object} Dynamic-mode source data and actions.\n */\nexport default function useDynamicGallery( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n\tpostId,\n\tpostType,\n} ) {\n\tconst { dynamicContent } = attributes;\n\n\t// Whether dynamic mode makes sense in the current editing context. A\n\t// `postType` means the block will resolve against some post at render time —\n\t// either a concrete post (post/page editor, Query Loop item) or a post-bound\n\t// template (`single`, `page`) whose post is filled in by `get_the_ID()` on the\n\t// frontend (see `index.php`). Without it (template part, pattern, generic\n\t// template) there's no post to attach to, so the source can never resolve.\n\tconst canUseDynamicSource = !! postType;\n\n\t// The descriptor for the configured source (its `title`/`description`/\n\t// `emptyMessage`), resolved once here so consumers read the copy without\n\t// re-deriving it from `dynamicContent`. `undefined` for an unknown source.\n\tconst sourceDescriptor = getDynamicSource( dynamicContent?.source );\n\n\t// Current source ordering, falling back to the shared defaults when unset.\n\tconst sourceOrderby = dynamicContent?.args?.orderBy ?? DEFAULT_ORDERBY;\n\tconst sourceOrder = dynamicContent?.args?.order ?? DEFAULT_ORDER;\n\n\tconst registry = useRegistry();\n\tconst { replaceInnerBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Resolve the configured source to a media query. `null` (static mode, or an\n\t// unresolvable source) short-circuits the select below so no request fires.\n\tconst query = useMemo(\n\t\t() =>\n\t\t\tdynamicContent\n\t\t\t\t? getSourceQuery( dynamicContent, { postId } )\n\t\t\t\t: null,\n\t\t[ dynamicContent, postId ]\n\t);\n\n\tconst { dynamicMedia, dynamicMediaTotal, isResolvingDynamic } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! query ) {\n\t\t\t\treturn {\n\t\t\t\t\tdynamicMedia: EMPTY_ARRAY,\n\t\t\t\t\tdynamicMediaTotal: 0,\n\t\t\t\t\tisResolvingDynamic: false,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst selectorArgs = [ 'postType', 'attachment', query ];\n\t\t\treturn {\n\t\t\t\tdynamicMedia:\n\t\t\t\t\tselect( coreStore ).getEntityRecords( ...selectorArgs ) ??\n\t\t\t\t\tEMPTY_ARRAY,\n\t\t\t\t// Total matching attachments (the `X-WP-Total` header), which the\n\t\t\t\t// query's `per_page` cap doesn't bound — so it reveals when the\n\t\t\t\t// post has more attached images than are shown.\n\t\t\t\tdynamicMediaTotal:\n\t\t\t\t\tselect( coreStore ).getEntityRecordsTotalItems(\n\t\t\t\t\t\t...selectorArgs\n\t\t\t\t\t) ?? 0,\n\t\t\t\tisResolvingDynamic: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ query ]\n\t);\n\n\t// The source caps results at `MAX_IMAGES` (matching the frontend), so flag\n\t// when the post has more attached images than the gallery can show.\n\tconst hasMoreImagesThanCap = dynamicMediaTotal > MAX_IMAGES;\n\n\t// The only gallery settings that affect how an image renders, and so the\n\t// only ones `buildImageBlockAttributes` reads. Depending on this narrowed\n\t// set (rather than the whole `attributes` object) keeps the preview from\n\t// rebuilding on unrelated edits, e.g. typing in the gallery caption.\n\tconst { sizeSlug, linkTo, linkTarget, aspectRatio } = attributes;\n\tconst imageAttributes = useMemo(\n\t\t() => ( { sizeSlug, linkTo, linkTarget, aspectRatio } ),\n\t\t[ sizeSlug, linkTo, linkTarget, aspectRatio ]\n\t);\n\n\t// The (non-persisted) `core/image` blocks used for the editor preview.\n\t// Rebuilt when the resolved media or an image-relevant setting changes.\n\tconst dynamicImageBlocks = useMemo(\n\t\t() => buildImageBlocks( dynamicMedia, imageAttributes ),\n\t\t[ dynamicMedia, imageAttributes ]\n\t);\n\n\t// Context the gallery provides to its (previewed) image blocks.\n\tconst galleryContext = useMemo(\n\t\t() => ( {\n\t\t\tallowResize: attributes.allowResize ?? false,\n\t\t\timageCrop: attributes.imageCrop,\n\t\t\tfixedHeight: attributes.fixedHeight,\n\t\t\tnavigationButtonType: attributes.navigationButtonType,\n\t\t} ),\n\t\t[\n\t\t\tattributes.allowResize,\n\t\t\tattributes.imageCrop,\n\t\t\tattributes.fixedHeight,\n\t\t\tattributes.navigationButtonType,\n\t\t]\n\t);\n\n\t// Switches the gallery into dynamic mode, displaying images attached to the\n\t// current post. Clearing the inner blocks removes the manually-added images:\n\t// they're the gallery's image data, so there's nothing else to reset. The\n\t// legacy `images`/`ids` attributes aren't touched — they're back-compat shims\n\t// for the pre-innerBlocks format (see `deprecated.js`/`transforms.js`), empty\n\t// on any gallery reachable here.\n\tfunction enableDynamicMode() {\n\t\t// Batch the attribute change and the inner-block reset into a single\n\t\t// undo level: they're two halves of one mode switch, so one undo should\n\t\t// revert both. Marking the second dispatch non-persistent stops it from\n\t\t// opening a second undo level, which would otherwise leave the gallery\n\t\t// in a half-switched state (dynamic source set, images still present).\n\t\tregistry.batch( () => {\n\t\t\tsetAttributes( { dynamicContent: { source: ATTACHED_MEDIA } } );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\treplaceInnerBlocks( clientId, [] );\n\t\t} );\n\t}\n\n\t// \"Pins\" a dynamic gallery: materializes the currently-resolved media as\n\t// real, editable image blocks and leaves dynamic mode.\n\tfunction convertToStatic() {\n\t\t// Batch the inner-block materialization and the attribute change into a\n\t\t// single undo level so one undo reverts the whole conversion (see\n\t\t// `enableDynamicMode`). Build fresh blocks rather than reusing the\n\t\t// preview's `dynamicImageBlocks` so the materialized inner blocks get\n\t\t// their own client IDs, distinct from the (disabled) preview instances.\n\t\tregistry.batch( () => {\n\t\t\treplaceInnerBlocks(\n\t\t\t\tclientId,\n\t\t\t\tbuildImageBlocks( dynamicMedia, imageAttributes )\n\t\t\t);\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { dynamicContent: undefined } );\n\t\t} );\n\t}\n\n\t// Updates the source ordering within `dynamicContent.args`. Passing\n\t// `undefined` (or the default order) strips the keys so they aren't\n\t// persisted redundantly and the ToolsPanel item reads as unset.\n\tfunction setSourceOrder( nextOrderby, nextOrder ) {\n\t\tconst nextArgs = { ...dynamicContent?.args };\n\t\tdelete nextArgs.orderBy;\n\t\tdelete nextArgs.order;\n\t\tif (\n\t\t\tnextOrderby !== undefined &&\n\t\t\t( nextOrderby !== DEFAULT_ORDERBY || nextOrder !== DEFAULT_ORDER )\n\t\t) {\n\t\t\tnextArgs.orderBy = nextOrderby;\n\t\t\tnextArgs.order = nextOrder;\n\t\t}\n\t\tconst nextSource = { ...dynamicContent };\n\t\tif ( Object.keys( nextArgs ).length ) {\n\t\t\tnextSource.args = nextArgs;\n\t\t} else {\n\t\t\tdelete nextSource.args;\n\t\t}\n\t\tsetAttributes( { dynamicContent: nextSource } );\n\t}\n\n\t// Resets the source to its bare form: keeps the source kind, drops its args.\n\tfunction resetSource() {\n\t\tsetAttributes( {\n\t\t\tdynamicContent: { source: dynamicContent.source },\n\t\t} );\n\t}\n\n\treturn {\n\t\tdynamicContent,\n\t\tcanUseDynamicSource,\n\t\tsourceDescriptor,\n\t\thasMoreImagesThanCap,\n\t\tdynamicMediaTotal,\n\t\tsourceOrderby,\n\t\tsourceOrder,\n\t\tdynamicMedia,\n\t\tdynamicImageBlocks,\n\t\tisResolvingDynamic,\n\t\tgalleryContext,\n\t\tenableDynamicMode,\n\t\tconvertToStatic,\n\t\tsetSourceOrder,\n\t\tresetSource,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,kBAAoD;AACpD,0BAA0C;AAC1C,uBAAmC;AACnC,oBAA4B;AAK5B,oBAAuC;AACvC,mBAAsC;AACtC,IAAAA,gBAA6C;AAC7C,4BAOO;AAEP,IAAM,cAAc,CAAC;AAerB,SAAS,0BAA2B,OAAO,mBAAoB;AAC9D,QAAM,EAAE,UAAU,QAAQ,YAAY,YAAY,IAAI;AACtD,QAAM,iBAAiB,CAAC,CAAE,eAAe,gBAAgB;AAEzD,SAAO;AAAA,IACN,IAAI,MAAM;AAAA,IACV,OAAG,sCAAwB,OAAO,QAAS;AAAA,IAC3C,OAAG,oCAAuB,OAAO,MAAO;AAAA,IACxC,OAAG,4CAA8B,YAAY,iBAAkB;AAAA,IAC/D;AAAA;AAAA;AAAA;AAAA,IAIA,SAAS,MAAM,SAAS,OAAO;AAAA,IAC/B,KAAK,M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A,UAAM,aAAa,EAAE,GAAG,eAAe;AACvC,QAAK,OAAO,KAAM,QAAS,EAAE,QAAS;AACrC,iBAAW,OAAO;AAAA,IACnB,OAAO;AACN,aAAO,WAAW;AAAA,IACnB;AACA,kBAAe,EAAE,gBAAgB,WAAW,CAAE;AAAA,EAC/C;AAGA,WAAS,cAAc;AACtB,kBAAe;AAAA,MACd,gBAAgB,EAAE,QAAQ,eAAe,OAAO;AAAA,IACjD,CAAE;AAAA,EACH;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": ["import_utils", "blockEditorStore", "coreStore"]
7
7
  }
@@ -99,7 +99,7 @@ function HeadingEdit(props) {
99
99
  onChange: onContentChange,
100
100
  onMerge: mergeBlocks,
101
101
  onReplace,
102
- onRemove: () => onReplace([]),
102
+ onRemove: onReplace ? () => onReplace([]) : void 0,
103
103
  placeholder: placeholder || (0, import_i18n.__)("Heading"),
104
104
  ...blockProps
105
105
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/heading/edit.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { generateAnchor, setAnchor } from './autogenerate-anchors';\nimport useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';\n\nfunction HeadingEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tmergeBlocks,\n\t\tonReplace,\n\t\tstyle,\n\t\tclientId,\n\t} = props;\n\tuseDeprecatedTextAlign( props );\n\tconst { content, level, placeholder, anchor } = attributes;\n\tconst tagName = 'h' + level;\n\tconst blockProps = useBlockProps( {\n\t\tstyle,\n\t} );\n\n\tconst { canGenerateAnchors } = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount, getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tcanGenerateAnchors:\n\t\t\t\t!! settings.generateAnchors ||\n\t\t\t\tgetGlobalBlockCount( 'core/table-of-contents' ) > 0,\n\t\t};\n\t}, [] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Initially set anchor for headings that have content but no anchor set.\n\t// This is used when transforming a block to heading, or for legacy anchors.\n\tuseEffect( () => {\n\t\tif ( ! canGenerateAnchors ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! anchor && content ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tanchor: generateAnchor( clientId, content ),\n\t\t\t} );\n\t\t}\n\t\tsetAnchor( clientId, anchor );\n\n\t\t// Remove anchor map when block unmounts.\n\t\treturn () => setAnchor( clientId, null );\n\t}, [\n\t\tanchor,\n\t\tcontent,\n\t\tclientId,\n\t\tcanGenerateAnchors,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst onContentChange = ( value ) => {\n\t\tconst newAttrs = { content: value };\n\t\tif (\n\t\t\tcanGenerateAnchors &&\n\t\t\t( ! anchor ||\n\t\t\t\t! value ||\n\t\t\t\tgenerateAnchor( clientId, content ) === anchor )\n\t\t) {\n\t\t\tnewAttrs.anchor = generateAnchor( clientId, value );\n\t\t}\n\t\tsetAttributes( newAttrs );\n\t};\n\n\treturn (\n\t\t<RichText\n\t\t\tidentifier=\"content\"\n\t\t\ttagName={ tagName }\n\t\t\tvalue={ content }\n\t\t\tonChange={ onContentChange }\n\t\t\tonMerge={ mergeBlocks }\n\t\t\tonReplace={ onReplace }\n\t\t\tonRemove={ () => onReplace( [] ) }\n\t\t\tplaceholder={ placeholder || __( 'Heading' ) }\n\t\t\t{ ...blockProps }\n\t\t/>\n\t);\n}\n\nexport default HeadingEdit;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,qBAA0B;AAC1B,kBAAuC;AACvC,0BAIO;AAKP,kCAA0C;AAC1C,8CAAmC;AAyEjC;AAvEF,SAAS,YAAa,OAAQ;AAC7B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,8CAAAA,SAAwB,KAAM;AAC9B,QAAM,EAAE,SAAS,OAAO,aAAa,OAAO,IAAI;AAChD,QAAM,UAAU,MAAM;AACtB,QAAM,iBAAa,mCAAe;AAAA,IACjC;AAAA,EACD,CAAE;AAEF,QAAM,EAAE,mBAAmB,QAAI,uBAAW,CAAE,WAAY;AACvD,UAAM,EAAE,qBAAqB,YAAY,IAAI,OAAQ,oBAAAC,KAAiB;AACtE,UAAM,WAAW,YAAY;AAE7B,WAAO;AAAA,MACN,oBACC,CAAC,CAAE,SAAS,mBACZ,oBAAqB,wBAAyB,IAAI;AAAA,IACpD;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,wCAAwC,QAC/C,yBAAa,oBAAAA,KAAiB;AAI/B,gCAAW,MAAM;AAChB,QAAK,CAAE,oBAAqB;AAC3B;AAAA,IACD;AAEA,QAAK,CAAE,UAAU,SAAU;AAE1B,8CAAwC;AACxC,oBAAe;AAAA,QACd,YAAQ,4CAAgB,UAAU,OAAQ;AAAA,MAC3C,CAAE;AAAA,IACH;AACA,+CAAW,UAAU,MAAO;AAG5B,WAAO,UAAM,uCAAW,UAAU,IAAK;AAAA,EACxC,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,QAAM,kBAAkB,CAAE,UAAW;AACpC,UAAM,WAAW,EAAE,SAAS,MAAM;AAClC,QACC,uBACE,CAAE,UACH,CAAE,aACF,4CAAgB,UAAU,OAAQ,MAAM,SACxC;AACD,eAAS,aAAS,4CAAgB,UAAU,KAAM;AAAA,IACnD;AACA,kBAAe,QAAS;AAAA,EACzB;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,YAAW;AAAA,MACX;AAAA,MACA,OAAQ;AAAA,MACR,UAAW;AAAA,MACX,SAAU;AAAA,MACV;AAAA,MACA,UAAW,MAAM,UAAW,CAAC,CAAE;AAAA,MAC/B,aAAc,mBAAe,gBAAI,SAAU;AAAA,MACzC,GAAG;AAAA;AAAA,EACN;AAEF;AAEA,IAAO,eAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { generateAnchor, setAnchor } from './autogenerate-anchors';\nimport useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';\n\nfunction HeadingEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tsetAttributes,\n\t\tmergeBlocks,\n\t\tonReplace,\n\t\tstyle,\n\t\tclientId,\n\t} = props;\n\tuseDeprecatedTextAlign( props );\n\tconst { content, level, placeholder, anchor } = attributes;\n\tconst tagName = 'h' + level;\n\tconst blockProps = useBlockProps( {\n\t\tstyle,\n\t} );\n\n\tconst { canGenerateAnchors } = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount, getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\n\t\treturn {\n\t\t\tcanGenerateAnchors:\n\t\t\t\t!! settings.generateAnchors ||\n\t\t\t\tgetGlobalBlockCount( 'core/table-of-contents' ) > 0,\n\t\t};\n\t}, [] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Initially set anchor for headings that have content but no anchor set.\n\t// This is used when transforming a block to heading, or for legacy anchors.\n\tuseEffect( () => {\n\t\tif ( ! canGenerateAnchors ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! anchor && content ) {\n\t\t\t// This side-effect should not create an undo level.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tanchor: generateAnchor( clientId, content ),\n\t\t\t} );\n\t\t}\n\t\tsetAnchor( clientId, anchor );\n\n\t\t// Remove anchor map when block unmounts.\n\t\treturn () => setAnchor( clientId, null );\n\t}, [\n\t\tanchor,\n\t\tcontent,\n\t\tclientId,\n\t\tcanGenerateAnchors,\n\t\tsetAttributes,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t] );\n\n\tconst onContentChange = ( value ) => {\n\t\tconst newAttrs = { content: value };\n\t\tif (\n\t\t\tcanGenerateAnchors &&\n\t\t\t( ! anchor ||\n\t\t\t\t! value ||\n\t\t\t\tgenerateAnchor( clientId, content ) === anchor )\n\t\t) {\n\t\t\tnewAttrs.anchor = generateAnchor( clientId, value );\n\t\t}\n\t\tsetAttributes( newAttrs );\n\t};\n\n\treturn (\n\t\t<RichText\n\t\t\tidentifier=\"content\"\n\t\t\ttagName={ tagName }\n\t\t\tvalue={ content }\n\t\t\tonChange={ onContentChange }\n\t\t\tonMerge={ mergeBlocks }\n\t\t\tonReplace={ onReplace }\n\t\t\tonRemove={ onReplace ? () => onReplace( [] ) : undefined }\n\t\t\tplaceholder={ placeholder || __( 'Heading' ) }\n\t\t\t{ ...blockProps }\n\t\t/>\n\t);\n}\n\nexport default HeadingEdit;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAA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