@wordpress/block-library 8.5.0 → 8.6.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 (287) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/buttons/edit.native.js +1 -1
  3. package/build/buttons/edit.native.js.map +1 -1
  4. package/build/columns/edit.js +10 -8
  5. package/build/columns/edit.js.map +1 -1
  6. package/build/columns/edit.native.js +1 -1
  7. package/build/columns/edit.native.js.map +1 -1
  8. package/build/comments/edit/placeholder.js +8 -5
  9. package/build/comments/edit/placeholder.js.map +1 -1
  10. package/build/cover/index.js +13 -4
  11. package/build/cover/index.js.map +1 -1
  12. package/build/cover/variations.js +29 -0
  13. package/build/cover/variations.js.map +1 -0
  14. package/build/embed/edit.js +13 -14
  15. package/build/embed/edit.js.map +1 -1
  16. package/build/embed/edit.native.js +18 -14
  17. package/build/embed/edit.native.js.map +1 -1
  18. package/build/embed/util.js +39 -12
  19. package/build/embed/util.js.map +1 -1
  20. package/build/gallery/edit.js +1 -0
  21. package/build/gallery/edit.js.map +1 -1
  22. package/build/latest-posts/edit.js +10 -10
  23. package/build/latest-posts/edit.js.map +1 -1
  24. package/build/latest-posts/edit.native.js +3 -3
  25. package/build/latest-posts/edit.native.js.map +1 -1
  26. package/build/media-text/constants.js +17 -1
  27. package/build/media-text/constants.js.map +1 -1
  28. package/build/media-text/edit.js +7 -19
  29. package/build/media-text/edit.js.map +1 -1
  30. package/build/media-text/edit.native.js +6 -5
  31. package/build/media-text/edit.native.js.map +1 -1
  32. package/build/media-text/transforms.js +32 -44
  33. package/build/media-text/transforms.js.map +1 -1
  34. package/build/navigation/edit/index.js +56 -86
  35. package/build/navigation/edit/index.js.map +1 -1
  36. package/build/navigation/edit/inner-blocks.js +4 -1
  37. package/build/navigation/edit/inner-blocks.js.map +1 -1
  38. package/build/navigation/edit/menu-inspector-controls.js +2 -5
  39. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  40. package/build/navigation/edit/navigation-menu-selector.js +26 -22
  41. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  42. package/build/navigation/edit/unsaved-inner-blocks.js +14 -1
  43. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  44. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +2 -4
  45. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  46. package/build/navigation/edit/use-create-navigation-menu.js +1 -1
  47. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  48. package/build/navigation/edit/use-navigation-notice.js +1 -1
  49. package/build/navigation/edit/use-navigation-notice.js.map +1 -1
  50. package/build/navigation-link/edit.js +0 -11
  51. package/build/navigation-link/edit.js.map +1 -1
  52. package/build/navigation-link/link-ui.js +0 -1
  53. package/build/navigation-link/link-ui.js.map +1 -1
  54. package/build/navigation-submenu/edit.js +1 -13
  55. package/build/navigation-submenu/edit.js.map +1 -1
  56. package/build/page-list/edit.js +59 -45
  57. package/build/page-list/edit.js.map +1 -1
  58. package/build/page-list-item/edit.js +3 -2
  59. package/build/page-list-item/edit.js.map +1 -1
  60. package/build/post-content/edit.js +6 -1
  61. package/build/post-content/edit.js.map +1 -1
  62. package/build/post-featured-image/dimension-controls.js +0 -6
  63. package/build/post-featured-image/dimension-controls.js.map +1 -1
  64. package/build/post-featured-image/edit.js +1 -1
  65. package/build/post-featured-image/edit.js.map +1 -1
  66. package/build/pullquote/deprecated.js +3 -3
  67. package/build/pullquote/deprecated.js.map +1 -1
  68. package/build/query/edit/query-placeholder.js +3 -2
  69. package/build/query/edit/query-placeholder.js.map +1 -1
  70. package/build/query/utils.js +26 -9
  71. package/build/query/utils.js.map +1 -1
  72. package/build/table/state.js +12 -4
  73. package/build/table/state.js.map +1 -1
  74. package/build/template-part/edit/import-controls.js +4 -24
  75. package/build/template-part/edit/import-controls.js.map +1 -1
  76. package/build/template-part/edit/utils/transformers.js +69 -19
  77. package/build/template-part/edit/utils/transformers.js.map +1 -1
  78. package/build/text-columns/edit.js +3 -7
  79. package/build/text-columns/edit.js.map +1 -1
  80. package/build/text-columns/save.js +11 -13
  81. package/build/text-columns/save.js.map +1 -1
  82. package/build-module/buttons/edit.native.js +1 -1
  83. package/build-module/buttons/edit.native.js.map +1 -1
  84. package/build-module/columns/edit.js +10 -7
  85. package/build-module/columns/edit.js.map +1 -1
  86. package/build-module/columns/edit.native.js +1 -1
  87. package/build-module/columns/edit.native.js.map +1 -1
  88. package/build-module/comments/edit/placeholder.js +9 -5
  89. package/build-module/comments/edit/placeholder.js.map +1 -1
  90. package/build-module/cover/index.js +12 -4
  91. package/build-module/cover/index.js.map +1 -1
  92. package/build-module/cover/variations.js +19 -0
  93. package/build-module/cover/variations.js.map +1 -0
  94. package/build-module/embed/edit.js +14 -15
  95. package/build-module/embed/edit.js.map +1 -1
  96. package/build-module/embed/edit.native.js +19 -15
  97. package/build-module/embed/edit.native.js.map +1 -1
  98. package/build-module/embed/util.js +34 -10
  99. package/build-module/embed/util.js.map +1 -1
  100. package/build-module/gallery/edit.js +1 -0
  101. package/build-module/gallery/edit.js.map +1 -1
  102. package/build-module/latest-posts/edit.js +10 -9
  103. package/build-module/latest-posts/edit.js.map +1 -1
  104. package/build-module/latest-posts/edit.native.js +3 -3
  105. package/build-module/latest-posts/edit.native.js.map +1 -1
  106. package/build-module/media-text/constants.js +10 -0
  107. package/build-module/media-text/constants.js.map +1 -1
  108. package/build-module/media-text/edit.js +2 -14
  109. package/build-module/media-text/edit.js.map +1 -1
  110. package/build-module/media-text/edit.native.js +4 -3
  111. package/build-module/media-text/edit.native.js.map +1 -1
  112. package/build-module/media-text/transforms.js +32 -44
  113. package/build-module/media-text/transforms.js.map +1 -1
  114. package/build-module/navigation/edit/index.js +58 -88
  115. package/build-module/navigation/edit/index.js.map +1 -1
  116. package/build-module/navigation/edit/inner-blocks.js +4 -1
  117. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  118. package/build-module/navigation/edit/menu-inspector-controls.js +2 -5
  119. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  120. package/build-module/navigation/edit/navigation-menu-selector.js +25 -22
  121. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  122. package/build-module/navigation/edit/unsaved-inner-blocks.js +14 -1
  123. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  124. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +2 -4
  125. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  126. package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
  127. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  128. package/build-module/navigation/edit/use-navigation-notice.js +1 -1
  129. package/build-module/navigation/edit/use-navigation-notice.js.map +1 -1
  130. package/build-module/navigation-link/edit.js +0 -11
  131. package/build-module/navigation-link/edit.js.map +1 -1
  132. package/build-module/navigation-link/link-ui.js +0 -1
  133. package/build-module/navigation-link/link-ui.js.map +1 -1
  134. package/build-module/navigation-submenu/edit.js +1 -13
  135. package/build-module/navigation-submenu/edit.js.map +1 -1
  136. package/build-module/page-list/edit.js +61 -47
  137. package/build-module/page-list/edit.js.map +1 -1
  138. package/build-module/page-list-item/edit.js +3 -2
  139. package/build-module/page-list-item/edit.js.map +1 -1
  140. package/build-module/post-content/edit.js +6 -1
  141. package/build-module/post-content/edit.js.map +1 -1
  142. package/build-module/post-featured-image/dimension-controls.js +0 -6
  143. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  144. package/build-module/post-featured-image/edit.js +1 -1
  145. package/build-module/post-featured-image/edit.js.map +1 -1
  146. package/build-module/pullquote/deprecated.js +3 -2
  147. package/build-module/pullquote/deprecated.js.map +1 -1
  148. package/build-module/query/edit/query-placeholder.js +4 -3
  149. package/build-module/query/edit/query-placeholder.js.map +1 -1
  150. package/build-module/query/utils.js +21 -6
  151. package/build-module/query/utils.js.map +1 -1
  152. package/build-module/table/state.js +13 -5
  153. package/build-module/table/state.js.map +1 -1
  154. package/build-module/template-part/edit/import-controls.js +4 -23
  155. package/build-module/template-part/edit/import-controls.js.map +1 -1
  156. package/build-module/template-part/edit/utils/transformers.js +69 -20
  157. package/build-module/template-part/edit/utils/transformers.js.map +1 -1
  158. package/build-module/text-columns/edit.js +3 -6
  159. package/build-module/text-columns/edit.js.map +1 -1
  160. package/build-module/text-columns/save.js +11 -12
  161. package/build-module/text-columns/save.js.map +1 -1
  162. package/build-style/cover/style-rtl.css +11 -5
  163. package/build-style/cover/style.css +11 -5
  164. package/build-style/editor-rtl.css +5 -1
  165. package/build-style/editor.css +5 -1
  166. package/build-style/navigation/editor-rtl.css +1 -1
  167. package/build-style/navigation/editor.css +1 -1
  168. package/build-style/page-list/editor-rtl.css +4 -0
  169. package/build-style/page-list/editor.css +4 -0
  170. package/build-style/post-featured-image/style-rtl.css +1 -0
  171. package/build-style/post-featured-image/style.css +1 -0
  172. package/build-style/style-rtl.css +12 -5
  173. package/build-style/style.css +12 -5
  174. package/package.json +31 -31
  175. package/src/audio/test/__snapshots__/edit.native.js.snap +44 -4
  176. package/src/audio/test/__snapshots__/transforms.native.js.snap +25 -0
  177. package/src/audio/test/transforms.native.js +42 -0
  178. package/src/block/test/__snapshots__/transforms.native.js.snap +15 -0
  179. package/src/block/test/transforms.native.js +40 -0
  180. package/src/buttons/edit.native.js +1 -1
  181. package/src/buttons/test/__snapshots__/transforms.native.js.snap +31 -0
  182. package/src/buttons/test/transforms.native.js +48 -0
  183. package/src/columns/edit.js +28 -17
  184. package/src/columns/edit.native.js +1 -1
  185. package/src/columns/test/__snapshots__/transforms.native.js.snap +61 -0
  186. package/src/columns/test/transforms.native.js +91 -0
  187. package/src/comment-template/index.php +1 -2
  188. package/src/comments/edit/placeholder.js +16 -4
  189. package/src/cover/block.json +9 -3
  190. package/src/cover/index.js +2 -0
  191. package/src/cover/style.scss +16 -7
  192. package/src/cover/test/__snapshots__/transforms.native.js.snap +73 -0
  193. package/src/cover/test/transforms.native.js +112 -0
  194. package/src/cover/variations.js +20 -0
  195. package/src/embed/edit.js +16 -12
  196. package/src/embed/edit.native.js +28 -18
  197. package/src/embed/test/__snapshots__/transforms.native.js.snap +23 -0
  198. package/src/embed/test/index.js +12 -0
  199. package/src/embed/test/transforms.native.js +44 -0
  200. package/src/embed/util.js +29 -8
  201. package/src/file/test/__snapshots__/edit.native.js.snap +18 -2
  202. package/src/file/test/__snapshots__/transforms.native.js.snap +19 -0
  203. package/src/file/test/transforms.native.js +42 -0
  204. package/src/freeform/test/__snapshots__/transforms.native.js.snap +19 -0
  205. package/src/freeform/test/transforms.native.js +39 -0
  206. package/src/gallery/edit.js +3 -0
  207. package/src/gallery/test/__snapshots__/transforms.native.js.snap +53 -0
  208. package/src/gallery/test/transforms.native.js +52 -0
  209. package/src/group/test/__snapshots__/transforms.native.js.snap +35 -0
  210. package/src/group/test/transforms.native.js +75 -0
  211. package/src/heading/test/__snapshots__/transforms.native.js.snap +47 -0
  212. package/src/heading/test/transforms.native.js +46 -0
  213. package/src/image/test/__snapshots__/transforms.native.js.snap +49 -0
  214. package/src/image/test/transforms.native.js +48 -0
  215. package/src/latest-posts/edit.js +11 -16
  216. package/src/latest-posts/edit.native.js +3 -3
  217. package/src/latest-posts/test/__snapshots__/transforms.native.js.snap +15 -0
  218. package/src/latest-posts/test/transforms.native.js +61 -0
  219. package/src/list/test/__snapshots__/transforms.native.js.snap +85 -0
  220. package/src/list/test/transforms.native.js +56 -0
  221. package/src/media-text/constants.js +16 -0
  222. package/src/media-text/edit.js +8 -18
  223. package/src/media-text/edit.native.js +3 -9
  224. package/src/media-text/test/__snapshots__/transforms.native.js.snap +73 -0
  225. package/src/media-text/test/transforms.native.js +112 -0
  226. package/src/media-text/transforms.js +24 -51
  227. package/src/missing/test/__snapshots__/edit.native.js.snap +20 -2
  228. package/src/more/test/__snapshots__/transforms.native.js.snap +19 -0
  229. package/src/more/test/transforms.native.js +42 -0
  230. package/src/navigation/edit/index.js +104 -107
  231. package/src/navigation/edit/inner-blocks.js +3 -0
  232. package/src/navigation/edit/menu-inspector-controls.js +2 -7
  233. package/src/navigation/edit/navigation-menu-selector.js +41 -25
  234. package/src/navigation/edit/unsaved-inner-blocks.js +46 -33
  235. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +82 -83
  236. package/src/navigation/edit/use-create-navigation-menu.js +1 -1
  237. package/src/navigation/edit/use-navigation-notice.js +1 -1
  238. package/src/navigation/editor.scss +23 -20
  239. package/src/navigation/index.php +18 -39
  240. package/src/navigation-link/edit.js +0 -9
  241. package/src/navigation-link/index.php +5 -8
  242. package/src/navigation-link/link-ui.js +0 -1
  243. package/src/navigation-submenu/edit.js +0 -10
  244. package/src/navigation-submenu/index.php +23 -6
  245. package/src/nextpage/test/__snapshots__/transforms.native.js.snap +19 -0
  246. package/src/nextpage/test/transforms.native.js +42 -0
  247. package/src/page-list/edit.js +78 -44
  248. package/src/page-list/editor.scss +6 -0
  249. package/src/page-list-item/edit.js +2 -3
  250. package/src/paragraph/test/__snapshots__/transforms.native.js.snap +59 -0
  251. package/src/paragraph/test/transforms.native.js +50 -0
  252. package/src/post-content/edit.js +5 -1
  253. package/src/post-excerpt/index.php +1 -2
  254. package/src/post-featured-image/dimension-controls.js +0 -8
  255. package/src/post-featured-image/edit.js +1 -1
  256. package/src/post-featured-image/style.scss +1 -0
  257. package/src/preformatted/test/__snapshots__/transforms.native.js.snap +31 -0
  258. package/src/preformatted/test/transforms.native.js +42 -0
  259. package/src/pullquote/deprecated.js +2 -6
  260. package/src/pullquote/test/__snapshots__/transforms.native.js.snap +47 -0
  261. package/src/pullquote/test/transforms.native.js +46 -0
  262. package/src/query/edit/query-placeholder.js +10 -5
  263. package/src/query/test/utils.js +33 -1
  264. package/src/query/utils.js +19 -6
  265. package/src/quote/test/__snapshots__/transforms.native.js.snap +39 -0
  266. package/src/quote/test/transforms.native.js +67 -0
  267. package/src/search/test/__snapshots__/edit.native.js.snap +11 -1
  268. package/src/search/test/__snapshots__/transforms.native.js.snap +15 -0
  269. package/src/search/test/transforms.native.js +40 -0
  270. package/src/separator/test/__snapshots__/transforms.native.js.snap +19 -0
  271. package/src/separator/test/transforms.native.js +42 -0
  272. package/src/shortcode/test/__snapshots__/transforms.native.js.snap +19 -0
  273. package/src/shortcode/test/transforms.native.js +42 -0
  274. package/src/social-links/test/__snapshots__/transforms.native.js.snap +31 -0
  275. package/src/social-links/test/transforms.native.js +53 -0
  276. package/src/spacer/test/__snapshots__/transforms.native.js.snap +19 -0
  277. package/src/spacer/test/transforms.native.js +42 -0
  278. package/src/table/state.js +8 -17
  279. package/src/template-part/edit/import-controls.js +2 -29
  280. package/src/template-part/edit/utils/transformers.js +96 -19
  281. package/src/text-columns/edit.js +1 -6
  282. package/src/text-columns/save.js +1 -6
  283. package/src/verse/test/__snapshots__/transforms.native.js.snap +25 -0
  284. package/src/verse/test/transforms.native.js +42 -0
  285. package/src/video/test/__snapshots__/transforms.native.js.snap +41 -0
  286. package/src/video/test/transforms.native.js +48 -0
  287. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/edit.js"],"names":["EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","icon","embedContentIcon","setURL","isEditingURL","setIsEditingURL","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","ignorePreviousClassName","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","upgradedBlock","blockProps","label","showEmbedPlaceholder","event","preventDefault","target","value","caption","classFromPreview"],"mappings":";;;;;;;;;AAyBA;;AAtBA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AA7BA;A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EAAGnB,UAH3B;AAIC,IAAA,eAAe,EAAGuC,eAJnB;AAKC,IAAA,gBAAgB,EAAGD,gBALpB;AAMC,IAAA,oBAAoB,EAAG,MAAMxB,eAAe,CAAE,IAAF;AAN7C,IADD,EASC,4BAAC,gBAAD,EAAW+B,UAAX,EACC,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAG5B,OADX;AAEC,IAAA,WAAW,EAAGlB,WAFf;AAGC,IAAA,SAAS,EAAGyC,SAHb;AAIC,IAAA,GAAG,EAAGvC,GAJP;AAKC,IAAA,IAAI,EAAG6B,IALR;AAMC,IAAA,OAAO,EAAGsB,OANX;AAOC,IAAA,eAAe,EAAKD,KAAF,IACjB9C,aAAa,CAAE;AAAE+C,MAAAA,OAAO,EAAED;AAAX,KAAF,CARf;AAUC,IAAA,UAAU,EAAGhD,UAVd;AAWC,IAAA,IAAI,EAAGO,IAXR;AAYC,IAAA,KAAK,EAAGoC,KAZT;AAaC,IAAA,iBAAiB,EAAGxC;AAbrB,IADD,CATD,CADD;AA6BA,CA3ND;;eA6NeX,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: {\n\t\t\tproviderNameSlug,\n\t\t\tpreviewable,\n\t\t\tresponsive,\n\t\t\turl: attributesUrl,\n\t\t},\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst { icon, title } =\n\t\tgetEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;\n\n\tconst [ url, setURL ] = useState( attributesUrl );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! attributesUrl ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\t\tconst previewIsFallback =\n\t\t\t\t\tisPreviewEmbedFallback( attributesUrl );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ attributesUrl ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = ( ignorePreviousClassName = false ) =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive,\n\t\t\tignorePreviousClassName\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, attributesUrl ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview, we set the attributes derived from\n\t\t\t// the preview data. In this case when getting the merged attributes,\n\t\t\t// we ignore the previous classname because it might not match the expected\n\t\t\t// classes by the new preview.\n\t\t\tsetAttributes( getMergedAttributes( true ) );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tgetMergedAttributes()\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// translators: %s: type of embed e.g: \"YouTube\", \"Twitter\", etc. \"Embed\" is used when no specific type exists\n\tconst label = sprintf( __( '%s URL' ), title );\n\n\t// No preview, or we can't embed the current URL, or we've clicked the edit button.\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL;\n\n\tif ( showEmbedPlaceholder ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\tif ( event ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\tsetAttributes( { url } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\tonChange={ ( event ) => setURL( event.target.value ) }\n\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [ url ] );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\tcaption,\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\treturn (\n\t\t<>\n\t\t\t<EmbedControls\n\t\t\t\tshowEditButton={ preview && ! cannotEmbed }\n\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\tswitchBackToURLInput={ () => setIsEditingURL( true ) }\n\t\t\t/>\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPreview\n\t\t\t\t\tpreview={ preview }\n\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\turl={ url }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcaption={ caption }\n\t\t\t\t\tonCaptionChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/embed/edit.js"],"names":["EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","icon","embedContentIcon","setURL","isEditingURL","setIsEditingURL","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","mergedAttributes","upgradedBlock","blockProps","label","showEmbedPlaceholder","event","preventDefault","blockClass","target","value","caption","classFromPreview"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AAQA,MAAMA,SAAS,GAAKC,KAAF,IAAa;AAC9B,QAAM;AACLC,IAAAA,UAAU,EAAE;AACXC,MAAAA,gBADW;AAEXC,MAAAA,WAFW;AAGXC,MAAAA,UAHW;AAIXC,MAAAA,GAAG,EAAEC;AAJM,KADP;AAOLL,IAAAA,UAPK;AAQLM,IAAAA,UARK;AASLC,IAAAA,SATK;AAULC,IAAAA,aAVK;AAWLC,IAAAA,iBAXK;AAYLC,IAAAA;AAZK,MAaFX,KAbJ;AAeA,QAAMY,gBAAgB,GAAG;AACxBC,IAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,aAAb,CADiB;AAExBC,IAAAA,IAAI,EAAEC;AAFkB,GAAzB;AAIA,QAAM;AAAED,IAAAA,IAAF;AAAQD,IAAAA;AAAR,MACL,kCAAwBX,gBAAxB,KAA8CU,gBAD/C;AAGA,QAAM,CAAEP,GAAF,EAAOW,MAAP,IAAkB,uBAAUV,aAAV,CAAxB;AACA,QAAM,CAAEW,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA2B,uBAAaC,eAAb,CAAjC;AAEA,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA,uBAArB;AAA8CC,IAAAA;AAA9C,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F,EAAqB,CAAEd,GAAF,CAArB,CAApB;AACA;AAxBF,MADD,CADD;AA8BA,GA/K6B,CAiL9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAM;AACLoD,IAAAA,OADK;AAELvB,IAAAA,IAFK;AAGLQ,IAAAA,eAHK;AAILC,IAAAA,SAAS,EAAEe;AAJN,MAKFlB,mBAAmB,EALvB;AAMA,QAAMG,SAAS,GAAG,yBAAYe,gBAAZ,EAA8B1D,KAAK,CAAC2C,SAApC,CAAlB;AAEA,SACC,qDACC,4BAAC,sBAAD;AACC,IAAA,cAAc,EAAGtB,OAAO,IAAI,CAAEG,WAD/B;AAEC,IAAA,uBAAuB,EAAGD,uBAF3B;AAGC,IAAA,uBAAuB,EAAGnB,UAH3B;AAIC,IAAA,eAAe,EAAGsC,eAJnB;AAKC,IAAA,gBAAgB,EAAGD,gBALpB;AAMC,IAAA,oBAAoB,EAAG,MAAMvB,eAAe,CAAE,IAAF;AAN7C,IADD,EASC,4BAAC,gBAAD,EAAW+B,UAAX,EACC,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAG5B,OADX;AAEC,IAAA,WAAW,EAAGlB,WAFf;AAGC,IAAA,SAAS,EAAGwC,SAHb;AAIC,IAAA,GAAG,EAAGtC,GAJP;AAKC,IAAA,IAAI,EAAG6B,IALR;AAMC,IAAA,OAAO,EAAGuB,OANX;AAOC,IAAA,eAAe,EAAKD,KAAF,IACjB/C,aAAa,CAAE;AAAEgD,MAAAA,OAAO,EAAED;AAAX,KAAF,CARf;AAUC,IAAA,UAAU,EAAGjD,UAVd;AAWC,IAAA,IAAI,EAAGO,IAXR;AAYC,IAAA,KAAK,EAAGoC,KAZT;AAaC,IAAA,iBAAiB,EAAGxC;AAbrB,IADD,CATD,CADD;AA6BA,CA9ND;;eAgOeX,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tremoveAspectRatioClasses,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: {\n\t\t\tproviderNameSlug,\n\t\t\tpreviewable,\n\t\t\tresponsive,\n\t\t\turl: attributesUrl,\n\t\t},\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst { icon, title } =\n\t\tgetEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;\n\n\tconst [ url, setURL ] = useState( attributesUrl );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! attributesUrl ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\t\tconst previewIsFallback =\n\t\t\t\t\tisPreviewEmbedFallback( attributesUrl );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ attributesUrl ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = () =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, attributesUrl, cannotEmbed, fetching ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview,\n\t\t\t// we set the attributes derived from the preview data.\n\t\t\tconst mergedAttributes = getMergedAttributes();\n\t\t\tsetAttributes( mergedAttributes );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tmergedAttributes\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// translators: %s: type of embed e.g: \"YouTube\", \"Twitter\", etc. \"Embed\" is used when no specific type exists\n\tconst label = sprintf( __( '%s URL' ), title );\n\n\t// No preview, or we can't embed the current URL, or we've clicked the edit button.\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL;\n\n\tif ( showEmbedPlaceholder ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\tif ( event ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If the embed URL was changed, we need to reset the aspect ratio class.\n\t\t\t\t\t\t// To do this we have to remove the existing ratio class so it can be recalculated.\n\t\t\t\t\t\tconst blockClass = removeAspectRatioClasses(\n\t\t\t\t\t\t\tattributes.className\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\tsetAttributes( { url, className: blockClass } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\tonChange={ ( event ) => setURL( event.target.value ) }\n\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [ url ] );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\tcaption,\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\treturn (\n\t\t<>\n\t\t\t<EmbedControls\n\t\t\t\tshowEditButton={ preview && ! cannotEmbed }\n\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\tswitchBackToURLInput={ () => setIsEditingURL( true ) }\n\t\t\t/>\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPreview\n\t\t\t\t\tpreview={ preview }\n\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\turl={ url }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcaption={ caption }\n\t\t\t\t\tonCaptionChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
@@ -130,14 +130,10 @@ const EmbedEdit = props => {
130
130
  /**
131
131
  * Returns the attributes derived from the preview, merged with the current attributes.
132
132
  *
133
- * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
134
133
  * @return {Object} Merged attributes.
135
134
  */
136
135
 
137
- const getMergedAttributes = function () {
138
- let ignorePreviousClassName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
139
- return (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive, ignorePreviousClassName);
140
- };
136
+ const getMergedAttributes = () => (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive);
141
137
 
142
138
  const toggleResponsive = () => {
143
139
  const {
@@ -166,18 +162,17 @@ const EmbedEdit = props => {
166
162
  setAttributes({
167
163
  url: newURL
168
164
  });
169
- }, [preview === null || preview === void 0 ? void 0 : preview.html, url]); // Handle incoming preview.
165
+ }, [preview === null || preview === void 0 ? void 0 : preview.html, url, cannotEmbed, fetching]); // Handle incoming preview.
170
166
 
171
167
  (0, _element.useEffect)(() => {
172
168
  if (preview && !isEditingURL) {
173
- // When obtaining an incoming preview, we set the attributes derived from
174
- // the preview data. In this case when getting the merged attributes,
175
- // we ignore the previous classname because it might not match the expected
176
- // classes by the new preview.
177
- setAttributes(getMergedAttributes(true));
169
+ // When obtaining an incoming preview,
170
+ // we set the attributes derived from the preview data.
171
+ const mergedAttributes = getMergedAttributes();
172
+ setAttributes(mergedAttributes);
178
173
 
179
174
  if (onReplace) {
180
- const upgradedBlock = (0, _util.createUpgradedEmbedBlock)(props, getMergedAttributes());
175
+ const upgradedBlock = (0, _util.createUpgradedEmbedBlock)(props, mergedAttributes);
181
176
 
182
177
  if (upgradedBlock) {
183
178
  onReplace(upgradedBlock);
@@ -187,14 +182,23 @@ const EmbedEdit = props => {
187
182
  }, [preview, isEditingURL]);
188
183
  (0, _element.useEffect)(() => setShowEmbedBottomSheet(isEditingURL), [isEditingURL]);
189
184
  const onEditURL = (0, _element.useCallback)(value => {
190
- // The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,
185
+ // If the embed URL was changed, we need to reset the aspect ratio class.
186
+ // To do this we have to remove the existing ratio class so it can be recalculated.
187
+ if (attributes.url !== value) {
188
+ const blockClass = (0, _util.removeAspectRatioClasses)(attributes.className);
189
+ setAttributes({
190
+ className: blockClass
191
+ });
192
+ } // The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,
191
193
  // otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL
192
194
  // for creating the new block.
195
+
196
+
193
197
  setAttributes({
194
198
  url: value
195
199
  });
196
200
  setIsEditingURL(false);
197
- }, []);
201
+ }, [attributes, setAttributes]);
198
202
  const blockProps = (0, _blockEditor.useBlockProps)();
199
203
 
200
204
  if (fetching) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/edit.native.js"],"names":["PREVIEWABLE_PROVIDERS","NOT_PREVIEWABLE_WP_EMBED_PROVIDERS","WP_EMBED_TYPE","EmbedEdit","props","attributes","align","providerNameSlug","previewable","responsive","url","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","clientId","defaultEmbedInfo","title","icon","embedContentIcon","embedInfoByProvider","wasBlockJustInserted","select","blockEditorStore","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","ignorePreviousClassName","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","upgradedBlock","onEditURL","value","blockProps","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","event"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AAIA;;AACA;;AAjCA;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AAWA;AACA;AACA,MAAMA,qBAAqB,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,WAAxB,EAAqC,OAArC,CAA9B,C,CACA;AACA;;AACA,MAAMC,kCAAkC,GAAG,CAAE,WAAF,CAA3C;AAEA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,SAAS,GAAKC,KAAF,IAAa;AAC9B,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,gBAAT;AAA2BC,MAAAA,WAA3B;AAAwCC,MAAAA,UAAxC;AAAoDC,MAAAA;AAApD,KADP;AAELL,IAAAA,UAFK;AAGLM,IAAAA,UAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,aALK;AAMLC,IAAAA,iBANK;AAOLC,IAAAA,OAPK;AAQLC,IAAAA;AARK,MASFZ,KATJ;AAWA,QAAMa,gBAAgB,GAAG;AACxBC,IAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,aAAb,CADiB;AAExBC,IAAAA,IAAI,EAAEC;AAFkB,GAAzB;AAIA,QAAMC,mBAAmB,GAAG,kCAAwBd,gBAAxB,CAA5B;AACA,QAAM;AAAEY,IAAAA,IAAF;AAAQD,IAAAA;AAAR,MAAkBG,mBAAmB,IAAIJ,gBAA/C;AAEA,QAAM;AAAEK,IAAAA;AAAF,MAA2B,qBAC9BC,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,IADD,EAUC,4BAAC,gBAAD,EAAWE,UAAX,EACC,4BAAC,qBAAD;AACC,IAAA,KAAK,EAAGtD,KADT;AAEC,IAAA,SAAS,EAAG+C,SAFb;AAGC,IAAA,QAAQ,EAAGrC,QAHZ;AAIC,IAAA,IAAI,EAAGG,IAJR;AAKC,IAAA,iBAAiB,EAAGL,iBALrB;AAMC,IAAA,UAAU,EAAGH,UANd;AAOC,IAAA,KAAK,EAAGO,KAPT;AAQC,IAAA,OAAO,EAAGH,OARX;AASC,IAAA,OAAO,EAAGgB,OATX;AAUC,IAAA,qBAAqB,EAAGgC,qBAVzB;AAWC,IAAA,WAAW,EAAGvD,WAXf;AAYC,IAAA,IAAI,EAAGoC,IAZR;AAaC,IAAA,GAAG,EAAGlC,GAbP;AAcC,IAAA,kBAAkB,EAAG,CAAEW;AAdxB,IADD,CAVD,CA1BF,EAwDC,4BAAC,0BAAD,CACC;AADD;AAEC,IAAA,SAAS,MAFV;AAGC,IAAA,KAAK,EAAGX,GAHT;AAIC,IAAA,KAAK,EAAGuD,SAJT;AAKC,IAAA,SAAS,EAAGtC,oBALb;AAMC,IAAA,OAAO,EAAG,MAAMC,uBAAuB,CAAE,KAAF,CANxC;AAOC,IAAA,QAAQ,EAAG8B,SAPZ;AAQC,IAAA,eAAe;AARhB,IAxDD,CADD;AAqEA,CAnQD;;eAqQevD,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\nimport EmbedLinkSettings from './embed-link-settings';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useCallback, useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\n// The inline preview feature will be released progressible, for this reason\n// the embed will only be considered previewable for the following providers list.\nconst PREVIEWABLE_PROVIDERS = [ 'youtube', 'twitter', 'instagram', 'vimeo' ];\n// Some providers are rendering the inline preview as a WordPress embed and\n// are not supported yet, so we need to disallow them with a fixed providers list.\nconst NOT_PREVIEWABLE_WP_EMBED_PROVIDERS = [ 'pinterest' ];\n\nconst WP_EMBED_TYPE = 'wp-embed';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: { align, providerNameSlug, previewable, responsive, url },\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t\tclientId,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );\n\tconst { icon, title } = embedInfoByProvider || defaultEmbedInfo;\n\n\tconst { wasBlockJustInserted } = useSelect(\n\t\t( select ) => ( {\n\t\t\twasBlockJustInserted: select(\n\t\t\t\tblockEditorStore\n\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst [ isEditingURL, setIsEditingURL ] = useState(\n\t\tisSelected && wasBlockJustInserted && ! url\n\t);\n\tconst [ showEmbedBottomSheet, setShowEmbedBottomSheet ] =\n\t\tuseState( isEditingURL );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\thasFinishedResolution,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! url ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t\t'getEmbedPreview',\n\t\t\t\t\t[ url ]\n\t\t\t\t);\n\t\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ url ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = ( ignorePreviousClassName = false ) =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive,\n\t\t\tignorePreviousClassName\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = url.replace( /\\/$/, '' );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, url ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview, we set the attributes derived from\n\t\t\t// the preview data. In this case when getting the merged attributes,\n\t\t\t// we ignore the previous classname because it might not match the expected\n\t\t\t// classes by the new preview.\n\t\t\tsetAttributes( getMergedAttributes( true ) );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tgetMergedAttributes()\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tuseEffect(\n\t\t() => setShowEmbedBottomSheet( isEditingURL ),\n\t\t[ isEditingURL ]\n\t);\n\n\tconst onEditURL = useCallback( ( value ) => {\n\t\t// The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,\n\t\t// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL\n\t\t// for creating the new block.\n\t\tsetAttributes( { url: value } );\n\t\tsetIsEditingURL( false );\n\t}, [] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed;\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\tconst isProviderPreviewable =\n\t\tPREVIEWABLE_PROVIDERS.includes( providerNameSlug ) ||\n\t\t// For WordPress embeds, we enable the inline preview for all its providers\n\t\t// except the ones that are not supported yet.\n\t\t( WP_EMBED_TYPE === type &&\n\t\t\t! NOT_PREVIEWABLE_WP_EMBED_PROVIDERS.includes( providerNameSlug ) );\n\n\tconst linkLabel = WP_EMBED_TYPE === type ? 'WordPress' : title;\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmbedPlaceholder ? (\n\t\t\t\t<>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus( event );\n\t\t\t\t\t\t\t\tsetIsEditingURL( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\topenEmbedLinkSettings={ () =>\n\t\t\t\t\t\t\t\tsetShowEmbedBottomSheet( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<EmbedControls\n\t\t\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tlinkLabel={ linkLabel }\n\t\t\t\t\t\tonEditURL={ onEditURL }\n\t\t\t\t\t/>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPreview\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tisProviderPreviewable={ isProviderPreviewable }\n\t\t\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tisDefaultEmbedInfo={ ! embedInfoByProvider }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<EmbedLinkSettings\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus\n\t\t\t\tvalue={ url }\n\t\t\t\tlabel={ linkLabel }\n\t\t\t\tisVisible={ showEmbedBottomSheet }\n\t\t\t\tonClose={ () => setShowEmbedBottomSheet( false ) }\n\t\t\t\tonSubmit={ onEditURL }\n\t\t\t\twithBottomSheet\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/embed/edit.native.js"],"names":["PREVIEWABLE_PROVIDERS","NOT_PREVIEWABLE_WP_EMBED_PROVIDERS","WP_EMBED_TYPE","EmbedEdit","props","attributes","align","providerNameSlug","previewable","responsive","url","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","clientId","defaultEmbedInfo","title","icon","embedContentIcon","embedInfoByProvider","wasBlockJustInserted","select","blockEditorStore","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","mergedAttributes","upgradedBlock","onEditURL","value","blockClass","blockProps","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","event"],"mappings":";;;;;;;;;AA2BA;;AAxBA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AAIA;;AACA;;AAlCA;AACA;AACA;;AAgBA;AACA;AACA;;AAGA;AACA;AACA;AAWA;AACA;AACA,MAAMA,qBAAqB,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,WAAxB,EAAqC,OAArC,CAA9B,C,CACA;AACA;;AACA,MAAMC,kCAAkC,GAAG,CAAE,WAAF,CAA3C;AAEA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,SA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C,qBAVzB;AAWC,IAAA,WAAW,EAAGxD,WAXf;AAYC,IAAA,IAAI,EAAGoC,IAZR;AAaC,IAAA,GAAG,EAAGlC,GAbP;AAcC,IAAA,kBAAkB,EAAG,CAAEW;AAdxB,IADD,CAVD,CA1BF,EAwDC,4BAAC,0BAAD,CACC;AADD;AAEC,IAAA,SAAS,MAFV;AAGC,IAAA,KAAK,EAAGX,GAHT;AAIC,IAAA,KAAK,EAAGwD,SAJT;AAKC,IAAA,SAAS,EAAGvC,oBALb;AAMC,IAAA,OAAO,EAAG,MAAMC,uBAAuB,CAAE,KAAF,CANxC;AAOC,IAAA,QAAQ,EAAG8B,SAPZ;AAQC,IAAA,eAAe;AARhB,IAxDD,CADD;AAqEA,CA5QD;;eA8QevD,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tremoveAspectRatioClasses,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\nimport EmbedLinkSettings from './embed-link-settings';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useCallback, useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\n// The inline preview feature will be released progressible, for this reason\n// the embed will only be considered previewable for the following providers list.\nconst PREVIEWABLE_PROVIDERS = [ 'youtube', 'twitter', 'instagram', 'vimeo' ];\n// Some providers are rendering the inline preview as a WordPress embed and\n// are not supported yet, so we need to disallow them with a fixed providers list.\nconst NOT_PREVIEWABLE_WP_EMBED_PROVIDERS = [ 'pinterest' ];\n\nconst WP_EMBED_TYPE = 'wp-embed';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: { align, providerNameSlug, previewable, responsive, url },\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t\tclientId,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );\n\tconst { icon, title } = embedInfoByProvider || defaultEmbedInfo;\n\n\tconst { wasBlockJustInserted } = useSelect(\n\t\t( select ) => ( {\n\t\t\twasBlockJustInserted: select(\n\t\t\t\tblockEditorStore\n\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst [ isEditingURL, setIsEditingURL ] = useState(\n\t\tisSelected && wasBlockJustInserted && ! url\n\t);\n\tconst [ showEmbedBottomSheet, setShowEmbedBottomSheet ] =\n\t\tuseState( isEditingURL );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\thasFinishedResolution,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! url ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t\t'getEmbedPreview',\n\t\t\t\t\t[ url ]\n\t\t\t\t);\n\t\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ url ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = () =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = url.replace( /\\/$/, '' );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, url, cannotEmbed, fetching ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview,\n\t\t\t// we set the attributes derived from the preview data.\n\t\t\tconst mergedAttributes = getMergedAttributes();\n\t\t\tsetAttributes( mergedAttributes );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tmergedAttributes\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tuseEffect(\n\t\t() => setShowEmbedBottomSheet( isEditingURL ),\n\t\t[ isEditingURL ]\n\t);\n\n\tconst onEditURL = useCallback(\n\t\t( value ) => {\n\t\t\t// If the embed URL was changed, we need to reset the aspect ratio class.\n\t\t\t// To do this we have to remove the existing ratio class so it can be recalculated.\n\t\t\tif ( attributes.url !== value ) {\n\t\t\t\tconst blockClass = removeAspectRatioClasses(\n\t\t\t\t\tattributes.className\n\t\t\t\t);\n\t\t\t\tsetAttributes( { className: blockClass } );\n\t\t\t}\n\n\t\t\t// The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,\n\t\t\t// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL\n\t\t\t// for creating the new block.\n\t\t\tsetAttributes( { url: value } );\n\t\t\tsetIsEditingURL( false );\n\t\t},\n\t\t[ attributes, setAttributes ]\n\t);\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed;\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\tconst isProviderPreviewable =\n\t\tPREVIEWABLE_PROVIDERS.includes( providerNameSlug ) ||\n\t\t// For WordPress embeds, we enable the inline preview for all its providers\n\t\t// except the ones that are not supported yet.\n\t\t( WP_EMBED_TYPE === type &&\n\t\t\t! NOT_PREVIEWABLE_WP_EMBED_PROVIDERS.includes( providerNameSlug ) );\n\n\tconst linkLabel = WP_EMBED_TYPE === type ? 'WordPress' : title;\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmbedPlaceholder ? (\n\t\t\t\t<>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus( event );\n\t\t\t\t\t\t\t\tsetIsEditingURL( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\topenEmbedLinkSettings={ () =>\n\t\t\t\t\t\t\t\tsetShowEmbedBottomSheet( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<EmbedControls\n\t\t\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tlinkLabel={ linkLabel }\n\t\t\t\t\t\tonEditURL={ onEditURL }\n\t\t\t\t\t/>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPreview\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tisProviderPreviewable={ isProviderPreviewable }\n\t\t\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tisDefaultEmbedInfo={ ! embedInfoByProvider }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<EmbedLinkSettings\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus\n\t\t\t\tvalue={ url }\n\t\t\t\tlabel={ linkLabel }\n\t\t\t\tisVisible={ showEmbedBottomSheet }\n\t\t\t\tonClose={ () => setShowEmbedBottomSheet( false ) }\n\t\t\t\tonSubmit={ onEditURL }\n\t\t\t\twithBottomSheet\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
@@ -9,7 +9,7 @@ exports.createUpgradedEmbedBlock = void 0;
9
9
  exports.fallback = fallback;
10
10
  exports.getAttributesFromPreview = exports.findMoreSuitableBlock = void 0;
11
11
  exports.getClassNames = getClassNames;
12
- exports.removeAspectRatioClasses = exports.matchesPatterns = exports.isFromWordPress = exports.getPhotoHtml = exports.getMergedAttributesWithPreview = exports.getEmbedInfoByProvider = void 0;
12
+ exports.removeAspectRatioClasses = exports.matchesPatterns = exports.isFromWordPress = exports.hasAspectRatioClass = exports.getPhotoHtml = exports.getMergedAttributesWithPreview = exports.getEmbedInfoByProvider = void 0;
13
13
 
14
14
  var _element = require("@wordpress/element");
15
15
 
@@ -237,6 +237,28 @@ const createUpgradedEmbedBlock = function (props) {
237
237
  ...attributesFromPreview
238
238
  });
239
239
  };
240
+ /**
241
+ * Determine if the block already has an aspect ratio class applied.
242
+ *
243
+ * @param {string} existingClassNames Existing block classes.
244
+ * @return {boolean} True or false if the classnames contain an aspect ratio class.
245
+ */
246
+
247
+
248
+ exports.createUpgradedEmbedBlock = createUpgradedEmbedBlock;
249
+
250
+ const hasAspectRatioClass = existingClassNames => {
251
+ if (!existingClassNames) {
252
+ return false;
253
+ }
254
+
255
+ return _constants.ASPECT_RATIOS.some(_ref4 => {
256
+ let {
257
+ className
258
+ } = _ref4;
259
+ return existingClassNames.includes(className);
260
+ });
261
+ };
240
262
  /**
241
263
  * Removes all previously set aspect ratio related classes and return the rest
242
264
  * existing class names.
@@ -246,7 +268,7 @@ const createUpgradedEmbedBlock = function (props) {
246
268
  */
247
269
 
248
270
 
249
- exports.createUpgradedEmbedBlock = createUpgradedEmbedBlock;
271
+ exports.hasAspectRatioClass = hasAspectRatioClass;
250
272
 
251
273
  const removeAspectRatioClasses = existingClassNames => {
252
274
  if (!existingClassNames) {
@@ -256,10 +278,10 @@ const removeAspectRatioClasses = existingClassNames => {
256
278
  return existingClassNames;
257
279
  }
258
280
 
259
- const aspectRatioClassNames = _constants.ASPECT_RATIOS.reduce((accumulator, _ref4) => {
281
+ const aspectRatioClassNames = _constants.ASPECT_RATIOS.reduce((accumulator, _ref5) => {
260
282
  let {
261
283
  className
262
- } = _ref4;
284
+ } = _ref5;
263
285
  accumulator[className] = false;
264
286
  return accumulator;
265
287
  }, {
@@ -371,6 +393,13 @@ const getAttributesFromPreview = (0, _memize.default)(function (preview, title,
371
393
  if (html || 'photo' === type) {
372
394
  attributes.type = type;
373
395
  attributes.providerNameSlug = providerNameSlug;
396
+ } // Aspect ratio classes are removed when the embed URL is updated.
397
+ // If the embed already has an aspect ratio class, that means the URL has not changed.
398
+ // Which also means no need to regenerate it with getClassNames.
399
+
400
+
401
+ if (hasAspectRatioClass(currentClassNames)) {
402
+ return attributes;
374
403
  }
375
404
 
376
405
  attributes.className = getClassNames(html, currentClassNames, isResponsive && allowResponsive);
@@ -379,24 +408,22 @@ const getAttributesFromPreview = (0, _memize.default)(function (preview, title,
379
408
  /**
380
409
  * Returns the attributes derived from the preview, merged with the current attributes.
381
410
  *
382
- * @param {Object} currentAttributes The current attributes of the block.
383
- * @param {Object} preview The preview data.
384
- * @param {string} title The block's title, e.g. Twitter.
385
- * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.
386
- * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
411
+ * @param {Object} currentAttributes The current attributes of the block.
412
+ * @param {Object} preview The preview data.
413
+ * @param {string} title The block's title, e.g. Twitter.
414
+ * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.
387
415
  * @return {Object} Merged attributes.
388
416
  */
389
417
 
390
418
  exports.getAttributesFromPreview = getAttributesFromPreview;
391
419
 
392
- const getMergedAttributesWithPreview = function (currentAttributes, preview, title, isResponsive) {
393
- let ignorePreviousClassName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
420
+ const getMergedAttributesWithPreview = (currentAttributes, preview, title, isResponsive) => {
394
421
  const {
395
422
  allowResponsive,
396
423
  className
397
424
  } = currentAttributes;
398
425
  return { ...currentAttributes,
399
- ...getAttributesFromPreview(preview, title, ignorePreviousClassName ? undefined : className, isResponsive, allowResponsive)
426
+ ...getAttributesFromPreview(preview, title, className, isResponsive, allowResponsive)
400
427
  };
401
428
  };
402
429
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/util.js"],"names":["name","DEFAULT_EMBED_BLOCK","metadata","getEmbedInfoByProvider","provider","find","matchesPatterns","url","patterns","some","pattern","match","findMoreSuitableBlock","isFromWordPress","html","includes","getPhotoHtml","photo","imageUrl","thumbnail_url","photoPreview","title","createUpgradedEmbedBlock","props","attributesFromPreview","preview","attributes","providerNameSlug","type","restAttributes","matchedBlock","isCurrentBlockWP","WP_EMBED_TYPE","shouldCreateNewBlock","wpVariation","removeAspectRatioClasses","existingClassNames","aspectRatioClassNames","ASPECT_RATIOS","reduce","accumulator","className","getClassNames","allowResponsive","previewDocument","document","implementation","createHTMLDocument","body","innerHTML","iframe","querySelector","height","width","aspectRatio","toFixed","ratioIndex","length","potentialRatio","ratio","ratioDiff","fallback","onReplace","link","content","getAttributesFromPreview","currentClassNames","isResponsive","provider_name","providerName","toLowerCase","getMergedAttributesWithPreview","currentAttributes","ignorePreviousClassName","undefined"],"mappings":";;;;;;;;;;;;;AAeA;;AAZA;;AAKA;;AACA;;AACA;;AAMA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAQA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM;AAAEA,EAAAA,IAAI,EAAEC;AAAR,IAAgCC,QAAtC;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,sBAAsB,GAAKC,QAAF;AAAA;;AAAA,gCACrC,gCAAoBH,mBAApB,CADqC,wDACrC,oBAA2CI,IAA3C,CACC;AAAA,QAAE;AAAEL,MAAAA;AAAF,KAAF;AAAA,WAAgBA,IAAI,KAAKI,QAAzB;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Yc,IAAzB,EAAgC;AAC/BF,IAAAA,UAAU,CAACE,IAAX,GAAkBA,IAAlB;AACAF,IAAAA,UAAU,CAACC,gBAAX,GAA8BA,gBAA9B;AACA;;AAEDD,EAAAA,UAAU,CAACe,SAAX,GAAuBC,aAAa,CACnC5B,IADmC,EAEnCoD,iBAFmC,EAGnCC,YAAY,IAAIxB,eAHmB,CAApC;AAMA,SAAOjB,UAAP;AACA,CAtCsC,CAAjC;AAyCP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,MAAM6C,8BAA8B,GAAG,UAC7CC,iBAD6C,EAE7C/C,OAF6C,EAG7CJ,KAH6C,EAI7C8C,YAJ6C,EAMzC;AAAA,MADJM,uBACI,uEADsB,KACtB;AACJ,QAAM;AAAE9B,IAAAA,eAAF;AAAmBF,IAAAA;AAAnB,MAAiC+B,iBAAvC;AACA,SAAO,EACN,GAAGA,iBADG;AAEN,OAAGP,wBAAwB,CAC1BxC,OAD0B,EAE1BJ,KAF0B,EAG1BoD,uBAAuB,GAAGC,SAAH,GAAejC,SAHZ,EAI1B0B,YAJ0B,EAK1BxB,eAL0B;AAFrB,GAAP;AAUA,CAlBM","sourcesContent":["/**\n * Internal dependencies\n */\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\n\n/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\nimport classnames from 'classnames/dedupe';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test agains.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return;\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an emtpy string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator[ className ] = false;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ 'wp-has-aspect-ratio': false }\n\t);\n\treturn classnames( existingClassNames, aspectRatioClassNames );\n};\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn classnames(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive,\n\tignorePreviousClassName = false\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tignorePreviousClassName ? undefined : className,\n\t\t\tisResponsive,\n\t\t\tallowResponsive\n\t\t),\n\t};\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/embed/util.js"],"names":["name","DEFAULT_EMBED_BLOCK","metadata","getEmbedInfoByProvider","provider","find","matchesPatterns","url","patterns","some","pattern","match","findMoreSuitableBlock","isFromWordPress","html","includes","getPhotoHtml","photo","imageUrl","thumbnail_url","photoPreview","title","createUpgradedEmbedBlock","props","attributesFromPreview","preview","attributes","providerNameSlug","type","restAttributes","matchedBlock","isCurrentBlockWP","WP_EMBED_TYPE","shouldCreateNewBlock","wpVariation","hasAspectRatioClass","existingClassNames","ASPECT_RATIOS","className","removeAspectRatioClasses","aspectRatioClassNames","reduce","accumulator","getClassNames","allowResponsive","previewDocument","document","implementation","createHTMLDocument","body","innerHTML","iframe","querySelector","height","width","aspectRatio","toFixed","ratioIndex","length","potentialRatio","ratio","ratioDiff","fallback","onReplace","link","content","getAttributesFromPreview","currentClassNames","isResponsive","provider_name","providerName","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ACA;AACA;;;;AACO,MAAM8C,8BAA8B,GAAG,CAC7CC,iBAD6C,EAE7ChD,OAF6C,EAG7CJ,KAH6C,EAI7C+C,YAJ6C,KAKzC;AACJ,QAAM;AAAExB,IAAAA,eAAF;AAAmBN,IAAAA;AAAnB,MAAiCmC,iBAAvC;AAEA,SAAO,EACN,GAAGA,iBADG;AAEN,OAAGP,wBAAwB,CAC1BzC,OAD0B,EAE1BJ,KAF0B,EAG1BiB,SAH0B,EAI1B8B,YAJ0B,EAK1BxB,eAL0B;AAFrB,GAAP;AAUA,CAlBM","sourcesContent":["/**\n * Internal dependencies\n */\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\n\n/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\nimport classnames from 'classnames/dedupe';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test agains.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return;\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Determine if the block already has an aspect ratio class applied.\n *\n * @param {string} existingClassNames Existing block classes.\n * @return {boolean} True or false if the classnames contain an aspect ratio class.\n */\nexport const hasAspectRatioClass = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\treturn false;\n\t}\n\treturn ASPECT_RATIOS.some( ( { className } ) =>\n\t\texistingClassNames.includes( className )\n\t);\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an emtpy string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator[ className ] = false;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ 'wp-has-aspect-ratio': false }\n\t);\n\treturn classnames( existingClassNames, aspectRatioClassNames );\n};\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn classnames(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\t// Aspect ratio classes are removed when the embed URL is updated.\n\t\t// If the embed already has an aspect ratio class, that means the URL has not changed.\n\t\t// Which also means no need to regenerate it with getClassNames.\n\t\tif ( hasAspectRatioClass( currentClassNames ) ) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tclassName,\n\t\t\tisResponsive,\n\t\t\tallowResponsive\n\t\t),\n\t};\n};\n"]}
@@ -492,6 +492,7 @@ function GalleryEdit(props) {
492
492
  }), (imageSizeOptions === null || imageSizeOptions === void 0 ? void 0 : imageSizeOptions.length) > 0 && (0, _element.createElement)(_components.SelectControl, {
493
493
  __nextHasNoMarginBottom: true,
494
494
  label: (0, _i18n.__)('Image size'),
495
+ help: (0, _i18n.__)('Select the size of the source images.'),
495
496
  value: sizeSlug,
496
497
  options: imageSizeOptions,
497
498
  onChange: updateImagesSize,