@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
@@ -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": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,gBAAgB;AACzB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,EAChC,+BAA+B;AAAA,OACzB;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,i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,GAAI,SAAU;AAAA,UACtB,cAAe;AAAA,UAEb,gCAAsB,oBAAC,WAAQ;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,OAAQ,GAAI,sBAAuB;AAAA,UACnC,aAAc,GAAI,qBAAsB;AAAA;AAAA,MACzC;AAAA,OACD;AAAA,IAWE,iBAAiB;AAAA,KACpB;AAEF;",
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": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,gBAAgB;AACzB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,EAChC,+BAA+B;AAAA,OACzB;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,iCAAiC;AAAA,OAC3B;AAKP,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,iBAAiB,eAAe,kBAAkB;AAmCzD,SA4FC,UA5FD,KAkGG,YAlGH;AA3BF,IAAM,gBAAgB;AAAA,EACrB,EAAE,OAAO,GAAI,kBAAmB,GAAG,OAAO,YAAY;AA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kB,gBAClB,GAAI,kCAAmC;AAE1C,SACC,iCACG;AAAA,yBAAqB,aACtB,iCACC;AAAA,0BAAC,iBAAc,OAAM,SACpB;AAAA,QAAC;AAAA;AAAA,UACA,SAAU,MAAM,sBAAuB,IAAK;AAAA,UAM5C,UAAW;AAAA,UAET,aAAI,QAAS;AAAA;AAAA,MAChB,GACD;AAAA,MACE,sBACD;AAAA,QAAC;AAAA;AAAA,UACA,WAAY,MAAM;AACjB,4BAAgB;AAChB,kCAAuB,KAAM;AAAA,UAC9B;AAAA,UACA,UAAW,MAAM,sBAAuB,KAAM;AAAA;AAAA,MAC/C;AAAA,OAEF;AAAA,IAED,qBAAC,YAAS,GAAG,YACV;AAAA,yBAAmB,SACpB,oBAAC,wBAAqB,OAAQ,gBAC7B;AAAA,QAAC;AAAA;AAAA,UACA,aAAc;AAAA;AAAA,MACf,GACD,IAEA;AAAA,QAAC;AAAA;AAAA,UACA,MAAO;AAAA,UACP,OAAQ,GAAI,SAAU;AAAA,UACtB,cAAe;AAAA,UAEb,gCAAsB,oBAAC,WAAQ;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,OAAQ,GAAI,sBAAuB;AAAA,UACnC,aAAc,GAAI,qBAAsB;AAAA;AAAA,MACzC;AAAA,OACD;AAAA,IAWE,iBAAiB;AAAA,KACpB;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  // packages/block-library/src/gallery/use-dynamic-gallery.js
2
2
  import { useMemo } from "@wordpress/element";
3
- import { useDispatch, useSelect } from "@wordpress/data";
3
+ import { useDispatch, useSelect, useRegistry } from "@wordpress/data";
4
4
  import { store as blockEditorStore } from "@wordpress/block-editor";
5
5
  import { store as coreStore } from "@wordpress/core-data";
6
6
  import { createBlock } from "@wordpress/blocks";
@@ -56,7 +56,8 @@ function useDynamicGallery({
56
56
  const sourceDescriptor = getDynamicSource(dynamicContent?.source);
57
57
  const sourceOrderby = dynamicContent?.args?.orderBy ?? DEFAULT_ORDERBY;
58
58
  const sourceOrder = dynamicContent?.args?.order ?? DEFAULT_ORDER;
59
- const { replaceInnerBlocks } = useDispatch(blockEditorStore);
59
+ const registry = useRegistry();
60
+ const { replaceInnerBlocks, __unstableMarkNextChangeAsNotPersistent } = useDispatch(blockEditorStore);
60
61
  const query = useMemo(
61
62
  () => dynamicContent ? getSourceQuery(dynamicContent, { postId }) : null,
62
63
  [dynamicContent, postId]
@@ -112,15 +113,21 @@ function useDynamicGallery({
112
113
  ]
113
114
  );
114
115
  function enableDynamicMode() {
115
- setAttributes({ dynamicContent: { source: ATTACHED_MEDIA } });
116
- replaceInnerBlocks(clientId, []);
116
+ registry.batch(() => {
117
+ setAttributes({ dynamicContent: { source: ATTACHED_MEDIA } });
118
+ __unstableMarkNextChangeAsNotPersistent();
119
+ replaceInnerBlocks(clientId, []);
120
+ });
117
121
  }
118
122
  function convertToStatic() {
119
- replaceInnerBlocks(
120
- clientId,
121
- buildImageBlocks(dynamicMedia, imageAttributes)
122
- );
123
- setAttributes({ dynamicContent: void 0 });
123
+ registry.batch(() => {
124
+ replaceInnerBlocks(
125
+ clientId,
126
+ buildImageBlocks(dynamicMedia, imageAttributes)
127
+ );
128
+ __unstableMarkNextChangeAsNotPersistent();
129
+ setAttributes({ dynamicContent: void 0 });
130
+ });
124
131
  }
125
132
  function setSourceOrder(nextOrderby, nextOrder) {
126
133
  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": ";AAGA,SAAS,eAAe;AACxB,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,iBAAiB;AACn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,CAAC,CAAE;AAAA,EAClC;AAIA,WAAS,kBAAkB;AAI1B;AAAA,MACC;AAAA,MACA,iBAAkB,cAAc,eAAgB;AAAA,IACjD;AACA,kBAAe,EAAE,gBAAgB,OAAU,CAAE;AAAA,EAC9C;AAKA,WAAS,eAAgB,aAAa,WAAY;AACjD,UAAM,WAAW,EAAE,GAAG,gBAAgB,KAAK;AAC3C,WAAO,SAAS;AAChB,WAAO,SAAS;AAChB,QACC,gBAAgB,WACd,gBAAgB,mBAAmB,cAAc,gBAClD;AACD,eAAS,UAAU;AACnB,eAAS,QAAQ;AAAA,IAClB;AACA,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;",
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\tdynamicImageBl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ACA;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -69,7 +69,7 @@ function HeadingEdit(props) {
69
69
  onChange: onContentChange,
70
70
  onMerge: mergeBlocks,
71
71
  onReplace,
72
- onRemove: () => onReplace([]),
72
+ onRemove: onReplace ? () => onReplace([]) : void 0,
73
73
  placeholder: placeholder || __("Heading"),
74
74
  ...blockProps
75
75
  }
@@ -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": ";AAGA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AAKP,SAAS,gBAAgB,iBAAiB;AAC1C,OAAO,4BAA4B;AAyEjC;AAvEF,SAAS,YAAa,OAAQ;AAC7B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ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AA,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": ";AAGA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AAKP,SAAS,gBAAgB,iBAAiB;AAC1C,OAAO,4BAA4B;AAyEjC;AAvEF,SAAS,YAAa,OAAQ;AAC7B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AACJ,yBAAwB,KAAM;AAC9B,QAAM,EAAE,SAAS,OAAO,aAAa,OAAO,IAAI;AAChD,QAAM,UAAU,MAAM;AACtB,QAAM,aAAa,cAAe;AAAA,IACjC;AAAA,EACD,CAAE;AAEF,QAAM,EAAE,mBAAmB,IAAI,UAAW,CAAE,WAAY;AACvD,UAAM,EAAE,qBAAqB,YAAY,IAAI,OAAQ,gBAAiB;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,IAC/C,YAAa,gBAAiB;AAI/B,YAAW,MAAM;AAChB,QAAK,CAAE,oBAAqB;AAC3B;AAAA,IACD;AAEA,QAAK,CAAE,UAAU,SAAU;AAE1B,8CAAwC;AACxC,oBAAe;AAAA,QACd,QAAQ,eAAgB,UAAU,OAAQ;AAAA,MAC3C,CAAE;AAAA,IACH;AACA,cAAW,UAAU,MAAO;AAG5B,WAAO,MAAM,UAAW,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,SACF,eAAgB,UAAU,OAAQ,MAAM,SACxC;AACD,eAAS,SAAS,eAAgB,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,YAAY,MAAM,UAAW,CAAC,CAAE,IAAI;AAAA,MAC/C,aAAc,eAAe,GAAI,SAAU;AAAA,MACzC,GAAG;AAAA;AAAA,EACN;AAEF;AAEA,IAAO,eAAQ;",
6
6
  "names": []
7
7
  }
@@ -11,7 +11,11 @@ import {
11
11
  __experimentalVStack as VStack,
12
12
  __experimentalHStack as HStack
13
13
  } from "@wordpress/components";
14
- import { PlainText, store as blockEditorStore } from "@wordpress/block-editor";
14
+ import {
15
+ PlainText,
16
+ store as blockEditorStore,
17
+ privateApis as blockEditorPrivateApis
18
+ } from "@wordpress/block-editor";
15
19
  import { fullscreen, square } from "@wordpress/icons";
16
20
  import { useViewportMatch } from "@wordpress/compose";
17
21
  import { unlock } from "../lock-unlock.mjs";
@@ -19,12 +23,14 @@ import Preview from "./preview.mjs";
19
23
  import { parseContent, serializeContent } from "./utils.mjs";
20
24
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
25
  var { Tabs } = unlock(componentsPrivateApis);
26
+ var { useNativeUndo } = unlock(blockEditorPrivateApis);
22
27
  function HTMLEditModal({ onRequestClose, content, onUpdate }) {
23
28
  const { html, css, js } = parseContent(content);
24
29
  const [editedHtml, setEditedHtml] = useState(html);
25
30
  const [editedCss, setEditedCss] = useState(css);
26
31
  const [editedJs, setEditedJs] = useState(js);
27
32
  const [isFullscreen, setIsFullscreen] = useState(false);
33
+ const nativeUndoRef = useNativeUndo();
28
34
  const isMobileViewport = useViewportMatch("small", "<");
29
35
  const { canUserUseUnfilteredHTML } = useSelect((select) => {
30
36
  const settings = select(blockEditorStore).getSettings();
@@ -106,67 +112,74 @@ function HTMLEditModal({ onRequestClose, content, onUpdate }) {
106
112
  align: "stretch",
107
113
  gap: 8,
108
114
  children: [
109
- /* @__PURE__ */ jsxs("div", { className: "block-library-html__modal-content", children: [
110
- /* @__PURE__ */ jsx(
111
- Tabs.TabPanel,
112
- {
113
- tabId: "html",
114
- focusable: false,
115
- className: "block-library-html__modal-tab",
116
- children: /* @__PURE__ */ jsx(
117
- PlainText,
115
+ /* @__PURE__ */ jsxs(
116
+ "div",
117
+ {
118
+ ref: nativeUndoRef,
119
+ className: "block-library-html__modal-content",
120
+ children: [
121
+ /* @__PURE__ */ jsx(
122
+ Tabs.TabPanel,
118
123
  {
119
- value: editedHtml,
120
- onChange: setEditedHtml,
121
- placeholder: __("Write HTML…"),
122
- "aria-label": __("HTML"),
123
- className: "block-library-html__modal-editor",
124
- async: true
124
+ tabId: "html",
125
+ focusable: false,
126
+ className: "block-library-html__modal-tab",
127
+ children: /* @__PURE__ */ jsx(
128
+ PlainText,
129
+ {
130
+ value: editedHtml,
131
+ onChange: setEditedHtml,
132
+ placeholder: __("Write HTML…"),
133
+ "aria-label": __("HTML"),
134
+ className: "block-library-html__modal-editor",
135
+ async: true
136
+ }
137
+ )
125
138
  }
126
- )
127
- }
128
- ),
129
- canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
130
- Tabs.TabPanel,
131
- {
132
- tabId: "css",
133
- focusable: false,
134
- className: "block-library-html__modal-tab",
135
- children: /* @__PURE__ */ jsx(
136
- PlainText,
139
+ ),
140
+ canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
141
+ Tabs.TabPanel,
137
142
  {
138
- value: editedCss,
139
- onChange: setEditedCss,
140
- placeholder: __("Write CSS…"),
141
- "aria-label": __("CSS"),
142
- className: "block-library-html__modal-editor",
143
- async: true
143
+ tabId: "css",
144
+ focusable: false,
145
+ className: "block-library-html__modal-tab",
146
+ children: /* @__PURE__ */ jsx(
147
+ PlainText,
148
+ {
149
+ value: editedCss,
150
+ onChange: setEditedCss,
151
+ placeholder: __("Write CSS…"),
152
+ "aria-label": __("CSS"),
153
+ className: "block-library-html__modal-editor",
154
+ async: true
155
+ }
156
+ )
144
157
  }
145
- )
146
- }
147
- ),
148
- canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
149
- Tabs.TabPanel,
150
- {
151
- tabId: "js",
152
- focusable: false,
153
- className: "block-library-html__modal-tab",
154
- children: /* @__PURE__ */ jsx(
155
- PlainText,
158
+ ),
159
+ canUserUseUnfilteredHTML && /* @__PURE__ */ jsx(
160
+ Tabs.TabPanel,
156
161
  {
157
- value: editedJs,
158
- onChange: setEditedJs,
159
- placeholder: __(
160
- "Write JavaScript…"
161
- ),
162
- "aria-label": __("JavaScript"),
163
- className: "block-library-html__modal-editor",
164
- async: true
162
+ tabId: "js",
163
+ focusable: false,
164
+ className: "block-library-html__modal-tab",
165
+ children: /* @__PURE__ */ jsx(
166
+ PlainText,
167
+ {
168
+ value: editedJs,
169
+ onChange: setEditedJs,
170
+ placeholder: __(
171
+ "Write JavaScript…"
172
+ ),
173
+ "aria-label": __("JavaScript"),
174
+ className: "block-library-html__modal-editor",
175
+ async: true
176
+ }
177
+ )
165
178
  }
166
179
  )
167
- }
168
- )
169
- ] }),
180
+ ]
181
+ }
182
+ ),
170
183
  /* @__PURE__ */ jsx("div", { className: "block-library-html__preview", children: /* @__PURE__ */ jsx(
171
184
  Preview,
172
185
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/html/modal.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tModal,\n\tButton,\n\tFlex,\n\tNotice,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { PlainText, store as blockEditorStore } from '@wordpress/block-editor';\nimport { fullscreen, square } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport Preview from './preview';\nimport { parseContent, serializeContent } from './utils';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nexport default function HTMLEditModal( { onRequestClose, content, onUpdate } ) {\n\t// Parse content into separate sections and use as initial state\n\tconst { html, css, js } = parseContent( content );\n\tconst [ editedHtml, setEditedHtml ] = useState( html );\n\tconst [ editedCss, setEditedCss ] = useState( css );\n\tconst [ editedJs, setEditedJs ] = useState( js );\n\tconst [ isFullscreen, setIsFullscreen ] = useState( false );\n\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\n\t// Check if user has permission to save scripts and get editor styles\n\tconst { canUserUseUnfilteredHTML } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tcanUserUseUnfilteredHTML:\n\t\t\t\tsettings.__experimentalCanUserUseUnfilteredHTML,\n\t\t};\n\t}, [] );\n\n\t// Determine if we should show a warning about CSS/JS content being stripped\n\tconst hasRestrictedContent =\n\t\t! canUserUseUnfilteredHTML && ( css.trim() || js.trim() );\n\n\tconst handleUpdate = () => {\n\t\t// For users without unfiltered_html capability, strip CSS and JS content\n\t\t// to prevent kses from leaving broken content\n\t\tonUpdate(\n\t\t\tserializeContent( {\n\t\t\t\thtml: editedHtml,\n\t\t\t\tcss: canUserUseUnfilteredHTML ? editedCss : '',\n\t\t\t\tjs: canUserUseUnfilteredHTML ? editedJs : '',\n\t\t\t} )\n\t\t);\n\t};\n\tconst handleUpdateAndClose = () => {\n\t\thandleUpdate();\n\t\tonRequestClose();\n\t};\n\tconst toggleFullscreen = () => {\n\t\tsetIsFullscreen( ( prevState ) => ! prevState );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Edit HTML' ) }\n\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\tclassName=\"block-library-html__modal\"\n\t\t\t\tsize=\"large\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tisFullScreen={ isFullscreen }\n\t\t\t\t__experimentalHideHeader\n\t\t\t>\n\t\t\t\t<Tabs orientation=\"horizontal\" defaultTabId=\"html\">\n\t\t\t\t\t<VStack expanded>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-header\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"html\">HTML</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"css\">CSS</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"js\">\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisFullscreen ? square : fullscreen\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Enable/disable fullscreen'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ toggleFullscreen }\n\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ hasRestrictedContent && (\n\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-notice\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'This block contains CSS or JavaScript that will be removed when you save because you do not have permission to use unfiltered HTML.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tdirection={ isMobileViewport ? 'column' : 'row' }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tabs\"\n\t\t\t\t\t\t\talign=\"stretch\"\n\t\t\t\t\t\t\tgap={ 8 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-library-html__modal-content\">\n\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\ttabId=\"html\"\n\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\tvalue={ editedHtml }\n\t\t\t\t\t\t\t\t\t\tonChange={ setEditedHtml }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write HTML…' ) }\n\t\t\t\t\t\t\t\t\t\taria-label={ __( 'HTML' ) }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"css\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedCss }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ setEditedCss }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write CSS…' ) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'CSS' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"js\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedJs }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ setEditedJs }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Write JavaScript…'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-library-html__preview\">\n\t\t\t\t\t\t\t\t<Preview\n\t\t\t\t\t\t\t\t\tcontent={ serializeContent( {\n\t\t\t\t\t\t\t\t\t\thtml: editedHtml,\n\t\t\t\t\t\t\t\t\t\tcss: editedCss,\n\t\t\t\t\t\t\t\t\t\tjs: editedJs,\n\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-footer\"\n\t\t\t\t\t\t>\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=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\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=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ handleUpdateAndClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Update' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</VStack>\n\t\t\t\t</Tabs>\n\t\t\t</Modal>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,WAAW,SAAS,wBAAwB;AACrD,SAAS,YAAY,cAAc;AACnC,SAAS,wBAAwB;AAKjC,SAAS,cAAc;AACvB,OAAO,aAAa;AACpB,SAAS,cAAc,wBAAwB;AA+C7C,mBAmBO,KADD,YAlBN;AA7CF,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAEhC,SAAR,cAAgC,EAAE,gBAAgB,SAAS,SAAS,GAAI;AAE9E,QAAM,EAAE,MAAM,KAAK,GAAG,IAAI,aAAc,OAAQ;AAChD,QAAM,CAAE,YAAY,aAAc,IAAI,SAAU,IAAK;AACrD,QAAM,CAAE,WAAW,YAAa,IAAI,SAAU,GAAI;AAClD,QAAM,CAAE,UAAU,WAAY,IAAI,SAAU,EAAG;AAC/C,QAAM,CAAE,cAAc,eAAgB,IAAI,SAA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AA,wBACA,OAAQ;AAAA,wBACR,UAAW;AAAA,wBACX,aAAc;AAAA,0BACb;AAAA,wBACD;AAAA,wBACA,cAAa,GAAI,YAAa;AAAA,wBAC9B,WAAU;AAAA,wBACV,OAAK;AAAA;AAAA,oBACN;AAAA;AAAA,gBACD;AAAA,iBAEF;AAAA,cACA,oBAAC,SAAI,WAAU,+BACd;AAAA,gBAAC;AAAA;AAAA,kBACA,SAAU,iBAAkB;AAAA,oBAC3B,MAAM;AAAA,oBACN,KAAK;AAAA,oBACL,IAAI;AAAA,kBACL,CAAE;AAAA;AAAA,cACH,GACD;AAAA;AAAA;AAAA,QACD;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,SAAQ;AAAA,YACR,SAAU;AAAA,YACV,WAAU;AAAA,YAEV;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAQ;AAAA,kBACR,SAAU;AAAA,kBAER,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAQ;AAAA,kBACR,SAAU;AAAA,kBAER,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA;AAAA;AAAA,QACD;AAAA,SACD,GACD;AAAA;AAAA,EACD,GACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tModal,\n\tButton,\n\tFlex,\n\tNotice,\n\tprivateApis as componentsPrivateApis,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport {\n\tPlainText,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { fullscreen, square } from '@wordpress/icons';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport Preview from './preview';\nimport { parseContent, serializeContent } from './utils';\n\nconst { Tabs } = unlock( componentsPrivateApis );\nconst { useNativeUndo } = unlock( blockEditorPrivateApis );\n\nexport default function HTMLEditModal( { onRequestClose, content, onUpdate } ) {\n\t// Parse content into separate sections and use as initial state\n\tconst { html, css, js } = parseContent( content );\n\tconst [ editedHtml, setEditedHtml ] = useState( html );\n\tconst [ editedCss, setEditedCss ] = useState( css );\n\tconst [ editedJs, setEditedJs ] = useState( js );\n\tconst [ isFullscreen, setIsFullscreen ] = useState( false );\n\t// The fields hold local state that is only committed when the dialog is\n\t// saved, so undo and redo within them must remain the browser's own.\n\tconst nativeUndoRef = useNativeUndo();\n\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\n\t// Check if user has permission to save scripts and get editor styles\n\tconst { canUserUseUnfilteredHTML } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tcanUserUseUnfilteredHTML:\n\t\t\t\tsettings.__experimentalCanUserUseUnfilteredHTML,\n\t\t};\n\t}, [] );\n\n\t// Determine if we should show a warning about CSS/JS content being stripped\n\tconst hasRestrictedContent =\n\t\t! canUserUseUnfilteredHTML && ( css.trim() || js.trim() );\n\n\tconst handleUpdate = () => {\n\t\t// For users without unfiltered_html capability, strip CSS and JS content\n\t\t// to prevent kses from leaving broken content\n\t\tonUpdate(\n\t\t\tserializeContent( {\n\t\t\t\thtml: editedHtml,\n\t\t\t\tcss: canUserUseUnfilteredHTML ? editedCss : '',\n\t\t\t\tjs: canUserUseUnfilteredHTML ? editedJs : '',\n\t\t\t} )\n\t\t);\n\t};\n\tconst handleUpdateAndClose = () => {\n\t\thandleUpdate();\n\t\tonRequestClose();\n\t};\n\tconst toggleFullscreen = () => {\n\t\tsetIsFullscreen( ( prevState ) => ! prevState );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Modal\n\t\t\t\ttitle={ __( 'Edit HTML' ) }\n\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\tclassName=\"block-library-html__modal\"\n\t\t\t\tsize=\"large\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tisFullScreen={ isFullscreen }\n\t\t\t\t__experimentalHideHeader\n\t\t\t>\n\t\t\t\t<Tabs orientation=\"horizontal\" defaultTabId=\"html\">\n\t\t\t\t\t<VStack expanded>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-header\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"html\">HTML</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"css\">CSS</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t\t<Tabs.Tab tabId=\"js\">\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\tisFullscreen ? square : fullscreen\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Enable/disable fullscreen'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tonClick={ toggleFullscreen }\n\t\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ hasRestrictedContent && (\n\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-notice\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'This block contains CSS or JavaScript that will be removed when you save because you do not have permission to use unfiltered HTML.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tdirection={ isMobileViewport ? 'column' : 'row' }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tabs\"\n\t\t\t\t\t\t\talign=\"stretch\"\n\t\t\t\t\t\t\tgap={ 8 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ nativeUndoRef }\n\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-content\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\ttabId=\"html\"\n\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\tvalue={ editedHtml }\n\t\t\t\t\t\t\t\t\t\tonChange={ setEditedHtml }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write HTML…' ) }\n\t\t\t\t\t\t\t\t\t\taria-label={ __( 'HTML' ) }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"css\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedCss }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ setEditedCss }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __( 'Write CSS…' ) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'CSS' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t{ canUserUseUnfilteredHTML && (\n\t\t\t\t\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\t\t\t\t\ttabId=\"js\"\n\t\t\t\t\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-tab\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t\t\t\t\tvalue={ editedJs }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ setEditedJs }\n\t\t\t\t\t\t\t\t\t\t\tplaceholder={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Write JavaScript…'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\taria-label={ __( 'JavaScript' ) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-library-html__modal-editor\"\n\t\t\t\t\t\t\t\t\t\t\tasync\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-library-html__preview\">\n\t\t\t\t\t\t\t\t<Preview\n\t\t\t\t\t\t\t\t\tcontent={ serializeContent( {\n\t\t\t\t\t\t\t\t\t\thtml: editedHtml,\n\t\t\t\t\t\t\t\t\t\tcss: editedCss,\n\t\t\t\t\t\t\t\t\t\tjs: editedJs,\n\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t\tspacing={ 4 }\n\t\t\t\t\t\t\tclassName=\"block-library-html__modal-footer\"\n\t\t\t\t\t\t>\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=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\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=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ handleUpdateAndClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Update' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</VStack>\n\t\t\t\t</Tabs>\n\t\t\t</Modal>\n\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AAAA;AAAA,cACH,GACD;AAAA;AAAA;AAAA,QACD;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,SAAQ;AAAA,YACR,SAAU;AAAA,YACV,WAAU;AAAA,YAEV;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAQ;AAAA,kBACR,SAAU;AAAA,kBAER,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACA,uBAAqB;AAAA,kBACrB,SAAQ;AAAA,kBACR,SAAU;AAAA,kBAER,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA;AAAA;AAAA,QACD;AAAA,SACD,GACD;AAAA;AAAA,EACD,GACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -33,9 +33,11 @@
33
33
  "align": [ "left", "center", "right" ],
34
34
  "html": false,
35
35
  "color": {
36
- "background": true,
37
- "text": true,
38
- "__experimentalSkipSerialization": true
36
+ "__experimentalSkipSerialization": true,
37
+ "__experimentalDefaultControls": {
38
+ "background": true,
39
+ "text": true
40
+ }
39
41
  },
40
42
  "interactivity": {
41
43
  "clientNavigation": true
@@ -247,7 +247,7 @@ function ImageEdit({
247
247
  const src = isExternal ? url : void 0;
248
248
  const isSideloading = useSelect(
249
249
  (select) => {
250
- if (!window.__clientSideMediaProcessing && !window.__heicUploadSupport || !id) {
250
+ if (!window.__clientSideMediaProcessing || !id) {
251
251
  return false;
252
252
  }
253
253
  return select(uploadStore).isUploadingById(id);