@wordpress/block-library 7.3.10 → 7.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 (752) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +3 -2
  3. package/babel-plugin.js +154 -0
  4. package/build/archives/edit.js +1 -1
  5. package/build/archives/edit.js.map +1 -1
  6. package/build/audio/edit.js +5 -17
  7. package/build/audio/edit.js.map +1 -1
  8. package/build/audio/edit.native.js +1 -1
  9. package/build/audio/edit.native.js.map +1 -1
  10. package/build/block/edit.js +10 -9
  11. package/build/block/edit.js.map +1 -1
  12. package/build/button/edit.native.js +7 -3
  13. package/build/button/edit.native.js.map +1 -1
  14. package/build/button/index.js +1 -0
  15. package/build/button/index.js.map +1 -1
  16. package/build/categories/edit.js +9 -4
  17. package/build/categories/edit.js.map +1 -1
  18. package/build/categories/index.js +5 -1
  19. package/build/categories/index.js.map +1 -1
  20. package/build/column/index.js +10 -0
  21. package/build/column/index.js.map +1 -1
  22. package/build/comment-author-avatar/index.js +1 -0
  23. package/build/comment-author-avatar/index.js.map +1 -1
  24. package/build/comment-template/edit.js +1 -3
  25. package/build/comment-template/edit.js.map +1 -1
  26. package/build/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  27. package/{build-module/comments-query-loop → build/comments}/edit/comments-inspector-controls.js.map +1 -1
  28. package/build/{comments-query-loop → comments}/edit.js +2 -2
  29. package/build/comments/edit.js.map +1 -0
  30. package/build/{comments-query-loop → comments}/index.js +1 -1
  31. package/build/comments/index.js.map +1 -0
  32. package/build/{comments-query-loop → comments}/save.js +2 -2
  33. package/build/comments/save.js.map +1 -0
  34. package/build/comments-title/index.js +1 -1
  35. package/build/comments-title/index.js.map +1 -1
  36. package/build/cover/controls.native.js +2 -3
  37. package/build/cover/controls.native.js.map +1 -1
  38. package/build/cover/edit/block-controls.js +115 -0
  39. package/build/cover/edit/block-controls.js.map +1 -0
  40. package/build/cover/edit/cover-placeholder.js +49 -0
  41. package/build/cover/edit/cover-placeholder.js.map +1 -0
  42. package/build/cover/edit/index.js +333 -0
  43. package/build/cover/edit/index.js.map +1 -0
  44. package/build/cover/edit/inspector-controls.js +224 -0
  45. package/build/cover/edit/inspector-controls.js.map +1 -0
  46. package/build/cover/edit/resizable-cover.js +67 -0
  47. package/build/cover/edit/resizable-cover.js.map +1 -0
  48. package/build/cover/edit/use-cover-is-dark.js +81 -0
  49. package/build/cover/edit/use-cover-is-dark.js.map +1 -0
  50. package/build/cover/edit.native.js +36 -16
  51. package/build/cover/edit.native.js.map +1 -1
  52. package/build/cover/focal-point-settings-button.native.js.map +1 -1
  53. package/build/cover/shared.js +9 -0
  54. package/build/cover/shared.js.map +1 -1
  55. package/build/cover/transforms.js +77 -6
  56. package/build/cover/transforms.js.map +1 -1
  57. package/build/cover/use-cover-is-dark.native.js +60 -0
  58. package/build/cover/use-cover-is-dark.native.js.map +1 -0
  59. package/build/embed/edit.js +12 -18
  60. package/build/embed/edit.js.map +1 -1
  61. package/build/embed/edit.native.js +1 -7
  62. package/build/embed/edit.native.js.map +1 -1
  63. package/build/embed/embed-preview.js +1 -1
  64. package/build/embed/embed-preview.js.map +1 -1
  65. package/build/embed/util.js +29 -4
  66. package/build/embed/util.js.map +1 -1
  67. package/build/file/edit.native.js +0 -1
  68. package/build/file/edit.native.js.map +1 -1
  69. package/build/file/inspector.js +2 -4
  70. package/build/file/inspector.js.map +1 -1
  71. package/build/gallery/edit.js +3 -2
  72. package/build/gallery/edit.js.map +1 -1
  73. package/build/gallery/gallery.js +1 -1
  74. package/build/gallery/gallery.js.map +1 -1
  75. package/build/gallery/shared.js +2 -2
  76. package/build/gallery/shared.js.map +1 -1
  77. package/build/gallery/use-get-media.js +2 -1
  78. package/build/gallery/use-get-media.js.map +1 -1
  79. package/build/gallery/use-short-code-transform.js +19 -18
  80. package/build/gallery/use-short-code-transform.js.map +1 -1
  81. package/build/gallery/v1/edit.js +1 -1
  82. package/build/gallery/v1/edit.js.map +1 -1
  83. package/build/gallery/v1/gallery.js +1 -1
  84. package/build/gallery/v1/gallery.js.map +1 -1
  85. package/build/group/index.js +1 -0
  86. package/build/group/index.js.map +1 -1
  87. package/build/heading/edit.js +6 -2
  88. package/build/heading/edit.js.map +1 -1
  89. package/build/heading/index.js +1 -0
  90. package/build/heading/index.js.map +1 -1
  91. package/build/heading/transforms.js +9 -4
  92. package/build/heading/transforms.js.map +1 -1
  93. package/build/html/edit.js +2 -2
  94. package/build/html/edit.js.map +1 -1
  95. package/build/image/edit.js +9 -8
  96. package/build/image/edit.js.map +1 -1
  97. package/build/image/edit.native.js +1 -2
  98. package/build/image/edit.native.js.map +1 -1
  99. package/build/image/image.js +2 -2
  100. package/build/image/image.js.map +1 -1
  101. package/build/index.js +48 -12
  102. package/build/index.js.map +1 -1
  103. package/build/index.native.js +14 -3
  104. package/build/index.native.js.map +1 -1
  105. package/build/is-block-metadata-experimental.js +18 -0
  106. package/build/is-block-metadata-experimental.js.map +1 -0
  107. package/build/latest-comments/edit.js +1 -1
  108. package/build/latest-comments/edit.js.map +1 -1
  109. package/build/latest-posts/edit.js +30 -4
  110. package/build/latest-posts/edit.js.map +1 -1
  111. package/build/latest-posts/edit.native.js +49 -0
  112. package/build/latest-posts/edit.native.js.map +1 -1
  113. package/build/list/transforms.js +6 -0
  114. package/build/list/transforms.js.map +1 -1
  115. package/build/list/v2/edit.js +2 -1
  116. package/build/list/v2/edit.js.map +1 -1
  117. package/build/list/v2/migrate.js +1 -0
  118. package/build/list/v2/migrate.js.map +1 -1
  119. package/build/list/v2/transforms.js +46 -9
  120. package/build/list/v2/transforms.js.map +1 -1
  121. package/build/list-item/edit.js +7 -9
  122. package/build/list-item/edit.js.map +1 -1
  123. package/build/list-item/hooks/index.js +24 -0
  124. package/build/list-item/hooks/index.js.map +1 -1
  125. package/build/list-item/hooks/use-backspace.js +59 -0
  126. package/build/list-item/hooks/use-backspace.js.map +1 -0
  127. package/build/list-item/hooks/use-enter.js +6 -9
  128. package/build/list-item/hooks/use-enter.js.map +1 -1
  129. package/build/list-item/hooks/use-indent-list-item.js +33 -39
  130. package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
  131. package/build/list-item/hooks/use-space.js +54 -0
  132. package/build/list-item/hooks/use-space.js.map +1 -0
  133. package/build/list-item/hooks/use-split.js +30 -0
  134. package/build/list-item/hooks/use-split.js.map +1 -0
  135. package/build/list-item/index.js +1 -0
  136. package/build/list-item/index.js.map +1 -1
  137. package/build/list-item/utils.js +1 -1
  138. package/build/list-item/utils.js.map +1 -1
  139. package/build/loginout/edit.js +1 -1
  140. package/build/loginout/edit.js.map +1 -1
  141. package/build/media-text/edit.js +1 -2
  142. package/build/media-text/edit.js.map +1 -1
  143. package/build/media-text/edit.native.js +3 -2
  144. package/build/media-text/edit.native.js.map +1 -1
  145. package/build/media-text/media-container.native.js +2 -4
  146. package/build/media-text/media-container.native.js.map +1 -1
  147. package/build/media-text/transforms.js +137 -8
  148. package/build/media-text/transforms.js.map +1 -1
  149. package/build/navigation/edit/index.js +86 -81
  150. package/build/navigation/edit/index.js.map +1 -1
  151. package/build/navigation/edit/inner-blocks.js +1 -5
  152. package/build/navigation/edit/inner-blocks.js.map +1 -1
  153. package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
  154. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  155. package/build/navigation/index.js +1 -1
  156. package/build/navigation/use-navigation-entities.js +3 -3
  157. package/build/navigation/use-navigation-entities.js.map +1 -1
  158. package/build/navigation/view-modal.js +62 -0
  159. package/build/navigation/view-modal.js.map +1 -0
  160. package/build/navigation/view.js +1 -34
  161. package/build/navigation/view.js.map +1 -1
  162. package/build/navigation-link/edit.js +1 -1
  163. package/build/navigation-link/edit.js.map +1 -1
  164. package/build/navigation-link/fallback-variations.js +1 -1
  165. package/build/navigation-link/fallback-variations.js.map +1 -1
  166. package/build/navigation-link/hooks.js +1 -1
  167. package/build/navigation-link/hooks.js.map +1 -1
  168. package/build/page-list/convert-to-links-modal.js +1 -1
  169. package/build/page-list/convert-to-links-modal.js.map +1 -1
  170. package/build/page-list/edit.js +1 -1
  171. package/build/page-list/edit.js.map +1 -1
  172. package/build/paragraph/edit.js +10 -0
  173. package/build/paragraph/edit.js.map +1 -1
  174. package/build/paragraph/edit.native.js +6 -2
  175. package/build/paragraph/edit.native.js.map +1 -1
  176. package/build/paragraph/use-enter.js +94 -0
  177. package/build/paragraph/use-enter.js.map +1 -0
  178. package/build/post-author/edit.js +2 -2
  179. package/build/post-author/edit.js.map +1 -1
  180. package/build/post-author-name/index.js +1 -0
  181. package/build/post-author-name/index.js.map +1 -1
  182. package/build/post-comment/index.js +2 -1
  183. package/build/post-comment/index.js.map +1 -1
  184. package/build/post-comments/edit.js +14 -35
  185. package/build/post-comments/edit.js.map +1 -1
  186. package/build/post-comments/index.js +1 -1
  187. package/build/post-comments-count/index.js +1 -0
  188. package/build/post-comments-count/index.js.map +1 -1
  189. package/build/post-comments-form/edit.js +37 -24
  190. package/build/post-comments-form/edit.js.map +1 -1
  191. package/build/post-comments-form/form.js +48 -0
  192. package/build/post-comments-form/form.js.map +1 -0
  193. package/build/post-comments-link/index.js +1 -0
  194. package/build/post-comments-link/index.js.map +1 -1
  195. package/build/post-excerpt/edit.js +1 -1
  196. package/build/post-excerpt/edit.js.map +1 -1
  197. package/build/post-featured-image/edit.js +1 -1
  198. package/build/post-featured-image/edit.js.map +1 -1
  199. package/build/post-template/edit.js +7 -2
  200. package/build/post-template/edit.js.map +1 -1
  201. package/build/post-terms/edit.js +35 -4
  202. package/build/post-terms/edit.js.map +1 -1
  203. package/build/post-terms/hooks.js +33 -0
  204. package/build/post-terms/hooks.js.map +1 -0
  205. package/build/post-terms/index.js +20 -5
  206. package/build/post-terms/index.js.map +1 -1
  207. package/build/post-title/index.js +1 -1
  208. package/build/post-title/index.js.map +1 -1
  209. package/build/pullquote/edit.js +1 -1
  210. package/build/pullquote/edit.js.map +1 -1
  211. package/build/pullquote/edit.native.js +1 -1
  212. package/build/pullquote/edit.native.js.map +1 -1
  213. package/build/query/edit/inspector-controls/index.js +26 -17
  214. package/build/query/edit/inspector-controls/index.js.map +1 -1
  215. package/build/query/edit/inspector-controls/parent-control.js +148 -0
  216. package/build/query/edit/inspector-controls/parent-control.js.map +1 -0
  217. package/build/query/edit/inspector-controls/sticky-control.js +41 -0
  218. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -0
  219. package/build/query/index.js +2 -1
  220. package/build/query/index.js.map +1 -1
  221. package/build/query/utils.js +28 -2
  222. package/build/query/utils.js.map +1 -1
  223. package/build/query-title/index.js +1 -1
  224. package/build/query-title/index.js.map +1 -1
  225. package/build/query-title/variations.js +1 -1
  226. package/build/query-title/variations.js.map +1 -1
  227. package/build/quote/edit.js +3 -2
  228. package/build/quote/edit.js.map +1 -1
  229. package/build/quote/index.js +7 -0
  230. package/build/quote/index.js.map +1 -1
  231. package/build/quote/v2/edit.js +12 -4
  232. package/build/quote/v2/edit.js.map +1 -1
  233. package/build/rss/edit.js +1 -1
  234. package/build/rss/edit.js.map +1 -1
  235. package/build/search/edit.js +12 -9
  236. package/build/search/edit.js.map +1 -1
  237. package/build/separator/index.js +3 -0
  238. package/build/separator/index.js.map +1 -1
  239. package/build/site-logo/edit.js +1 -1
  240. package/build/site-logo/edit.js.map +1 -1
  241. package/build/spacer/constants.js +9 -0
  242. package/build/spacer/constants.js.map +1 -0
  243. package/build/spacer/controls.js +3 -3
  244. package/build/spacer/controls.js.map +1 -1
  245. package/build/spacer/controls.native.js +2 -2
  246. package/build/spacer/controls.native.js.map +1 -1
  247. package/build/spacer/edit.js +5 -6
  248. package/build/spacer/edit.js.map +1 -1
  249. package/build/table/edit.js +23 -4
  250. package/build/table/edit.js.map +1 -1
  251. package/build/table-of-contents/edit.js +138 -66
  252. package/build/table-of-contents/edit.js.map +1 -1
  253. package/build/table-of-contents/index.js +13 -3
  254. package/build/table-of-contents/index.js.map +1 -1
  255. package/build/table-of-contents/list.js +16 -9
  256. package/build/table-of-contents/list.js.map +1 -1
  257. package/build/table-of-contents/save.js +40 -0
  258. package/build/table-of-contents/save.js.map +1 -0
  259. package/build/table-of-contents/utils.js +11 -77
  260. package/build/table-of-contents/utils.js.map +1 -1
  261. package/build/tag-cloud/edit.js +1 -1
  262. package/build/tag-cloud/edit.js.map +1 -1
  263. package/build/template-part/edit/index.js +7 -3
  264. package/build/template-part/edit/index.js.map +1 -1
  265. package/build/template-part/edit/inner-blocks.js +3 -8
  266. package/build/template-part/edit/inner-blocks.js.map +1 -1
  267. package/build/video/edit.js +5 -9
  268. package/build/video/edit.js.map +1 -1
  269. package/build/video/edit.native.js +1 -1
  270. package/build/video/edit.native.js.map +1 -1
  271. package/build-module/archives/edit.js +1 -1
  272. package/build-module/archives/edit.js.map +1 -1
  273. package/build-module/audio/edit.js +6 -18
  274. package/build-module/audio/edit.js.map +1 -1
  275. package/build-module/audio/edit.native.js +1 -1
  276. package/build-module/audio/edit.native.js.map +1 -1
  277. package/build-module/block/edit.js +11 -10
  278. package/build-module/block/edit.js.map +1 -1
  279. package/build-module/button/edit.native.js +7 -3
  280. package/build-module/button/edit.native.js.map +1 -1
  281. package/build-module/button/index.js +1 -0
  282. package/build-module/button/index.js.map +1 -1
  283. package/build-module/categories/edit.js +9 -4
  284. package/build-module/categories/edit.js.map +1 -1
  285. package/build-module/categories/index.js +5 -1
  286. package/build-module/categories/index.js.map +1 -1
  287. package/build-module/column/index.js +10 -0
  288. package/build-module/column/index.js.map +1 -1
  289. package/build-module/comment-author-avatar/index.js +1 -0
  290. package/build-module/comment-author-avatar/index.js.map +1 -1
  291. package/build-module/comment-template/edit.js +1 -3
  292. package/build-module/comment-template/edit.js.map +1 -1
  293. package/build-module/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  294. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -0
  295. package/build-module/{comments-query-loop → comments}/edit.js +1 -1
  296. package/build-module/comments/edit.js.map +1 -0
  297. package/build-module/{comments-query-loop → comments}/index.js +1 -1
  298. package/build-module/comments/index.js.map +1 -0
  299. package/build-module/{comments-query-loop → comments}/save.js +1 -1
  300. package/build-module/comments/save.js.map +1 -0
  301. package/build-module/comments-title/index.js +1 -1
  302. package/build-module/comments-title/index.js.map +1 -1
  303. package/build-module/cover/controls.native.js +2 -3
  304. package/build-module/cover/controls.native.js.map +1 -1
  305. package/build-module/cover/edit/block-controls.js +104 -0
  306. package/build-module/cover/edit/block-controls.js.map +1 -0
  307. package/build-module/cover/edit/cover-placeholder.js +38 -0
  308. package/build-module/cover/edit/cover-placeholder.js.map +1 -0
  309. package/build-module/cover/edit/index.js +307 -0
  310. package/build-module/cover/edit/index.js.map +1 -0
  311. package/build-module/cover/edit/inspector-controls.js +215 -0
  312. package/build-module/cover/edit/inspector-controls.js.map +1 -0
  313. package/build-module/cover/edit/resizable-cover.js +55 -0
  314. package/build-module/cover/edit/resizable-cover.js.map +1 -0
  315. package/build-module/cover/edit/use-cover-is-dark.js +70 -0
  316. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -0
  317. package/build-module/cover/edit.native.js +35 -17
  318. package/build-module/cover/edit.native.js.map +1 -1
  319. package/build-module/cover/focal-point-settings-button.native.js.map +1 -1
  320. package/build-module/cover/shared.js +7 -0
  321. package/build-module/cover/shared.js.map +1 -1
  322. package/build-module/cover/transforms.js +74 -6
  323. package/build-module/cover/transforms.js.map +1 -1
  324. package/build-module/cover/use-cover-is-dark.native.js +51 -0
  325. package/build-module/cover/use-cover-is-dark.native.js.map +1 -0
  326. package/build-module/embed/edit.js +13 -19
  327. package/build-module/embed/edit.js.map +1 -1
  328. package/build-module/embed/edit.native.js +2 -8
  329. package/build-module/embed/edit.native.js.map +1 -1
  330. package/build-module/embed/embed-preview.js +2 -2
  331. package/build-module/embed/embed-preview.js.map +1 -1
  332. package/build-module/embed/util.js +25 -3
  333. package/build-module/embed/util.js.map +1 -1
  334. package/build-module/file/edit.native.js +0 -1
  335. package/build-module/file/edit.native.js.map +1 -1
  336. package/build-module/file/inspector.js +2 -4
  337. package/build-module/file/inspector.js.map +1 -1
  338. package/build-module/gallery/edit.js +3 -2
  339. package/build-module/gallery/edit.js.map +1 -1
  340. package/build-module/gallery/gallery.js +2 -2
  341. package/build-module/gallery/gallery.js.map +1 -1
  342. package/build-module/gallery/shared.js +2 -2
  343. package/build-module/gallery/shared.js.map +1 -1
  344. package/build-module/gallery/use-get-media.js +2 -1
  345. package/build-module/gallery/use-get-media.js.map +1 -1
  346. package/build-module/gallery/use-short-code-transform.js +19 -18
  347. package/build-module/gallery/use-short-code-transform.js.map +1 -1
  348. package/build-module/gallery/v1/edit.js +1 -1
  349. package/build-module/gallery/v1/edit.js.map +1 -1
  350. package/build-module/gallery/v1/gallery.js +2 -2
  351. package/build-module/gallery/v1/gallery.js.map +1 -1
  352. package/build-module/group/index.js +1 -0
  353. package/build-module/group/index.js.map +1 -1
  354. package/build-module/heading/edit.js +6 -2
  355. package/build-module/heading/edit.js.map +1 -1
  356. package/build-module/heading/index.js +1 -0
  357. package/build-module/heading/index.js.map +1 -1
  358. package/build-module/heading/transforms.js +9 -4
  359. package/build-module/heading/transforms.js.map +1 -1
  360. package/build-module/html/edit.js +2 -2
  361. package/build-module/html/edit.js.map +1 -1
  362. package/build-module/image/edit.js +10 -9
  363. package/build-module/image/edit.js.map +1 -1
  364. package/build-module/image/edit.native.js +1 -2
  365. package/build-module/image/edit.native.js.map +1 -1
  366. package/build-module/image/image.js +3 -3
  367. package/build-module/image/image.js.map +1 -1
  368. package/build-module/index.js +43 -11
  369. package/build-module/index.js.map +1 -1
  370. package/build-module/index.native.js +14 -3
  371. package/build-module/index.native.js.map +1 -1
  372. package/build-module/is-block-metadata-experimental.js +16 -0
  373. package/build-module/is-block-metadata-experimental.js.map +1 -0
  374. package/build-module/latest-comments/edit.js +1 -1
  375. package/build-module/latest-comments/edit.js.map +1 -1
  376. package/build-module/latest-posts/edit.js +29 -5
  377. package/build-module/latest-posts/edit.js.map +1 -1
  378. package/build-module/latest-posts/edit.native.js +51 -2
  379. package/build-module/latest-posts/edit.native.js.map +1 -1
  380. package/build-module/list/transforms.js +6 -0
  381. package/build-module/list/transforms.js.map +1 -1
  382. package/build-module/list/v2/edit.js +2 -1
  383. package/build-module/list/v2/edit.js.map +1 -1
  384. package/build-module/list/v2/migrate.js +1 -3
  385. package/build-module/list/v2/migrate.js.map +1 -1
  386. package/build-module/list/v2/transforms.js +46 -9
  387. package/build-module/list/v2/transforms.js.map +1 -1
  388. package/build-module/list-item/edit.js +8 -9
  389. package/build-module/list-item/edit.js.map +1 -1
  390. package/build-module/list-item/hooks/index.js +3 -0
  391. package/build-module/list-item/hooks/index.js.map +1 -1
  392. package/build-module/list-item/hooks/use-backspace.js +44 -0
  393. package/build-module/list-item/hooks/use-backspace.js.map +1 -0
  394. package/build-module/list-item/hooks/use-enter.js +6 -9
  395. package/build-module/list-item/hooks/use-enter.js.map +1 -1
  396. package/build-module/list-item/hooks/use-indent-list-item.js +33 -38
  397. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
  398. package/build-module/list-item/hooks/use-space.js +40 -0
  399. package/build-module/list-item/hooks/use-space.js.map +1 -0
  400. package/build-module/list-item/hooks/use-split.js +19 -0
  401. package/build-module/list-item/hooks/use-split.js.map +1 -0
  402. package/build-module/list-item/index.js +1 -0
  403. package/build-module/list-item/index.js.map +1 -1
  404. package/build-module/list-item/utils.js +1 -1
  405. package/build-module/list-item/utils.js.map +1 -1
  406. package/build-module/loginout/edit.js +1 -1
  407. package/build-module/loginout/edit.js.map +1 -1
  408. package/build-module/media-text/edit.js +1 -2
  409. package/build-module/media-text/edit.js.map +1 -1
  410. package/build-module/media-text/edit.native.js +3 -2
  411. package/build-module/media-text/edit.native.js.map +1 -1
  412. package/build-module/media-text/media-container.native.js +2 -4
  413. package/build-module/media-text/media-container.native.js.map +1 -1
  414. package/build-module/media-text/transforms.js +137 -8
  415. package/build-module/media-text/transforms.js.map +1 -1
  416. package/build-module/navigation/edit/index.js +87 -82
  417. package/build-module/navigation/edit/index.js.map +1 -1
  418. package/build-module/navigation/edit/inner-blocks.js +2 -6
  419. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  420. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
  421. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  422. package/build-module/navigation/index.js +1 -1
  423. package/build-module/navigation/use-navigation-entities.js +1 -1
  424. package/build-module/navigation/use-navigation-entities.js.map +1 -1
  425. package/build-module/navigation/view-modal.js +56 -0
  426. package/build-module/navigation/view-modal.js.map +1 -0
  427. package/build-module/navigation/view.js +1 -30
  428. package/build-module/navigation/view.js.map +1 -1
  429. package/build-module/navigation-link/edit.js +1 -1
  430. package/build-module/navigation-link/edit.js.map +1 -1
  431. package/build-module/navigation-link/fallback-variations.js +1 -1
  432. package/build-module/navigation-link/fallback-variations.js.map +1 -1
  433. package/build-module/navigation-link/hooks.js +2 -2
  434. package/build-module/navigation-link/hooks.js.map +1 -1
  435. package/build-module/page-list/convert-to-links-modal.js +1 -1
  436. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  437. package/build-module/page-list/edit.js +1 -1
  438. package/build-module/page-list/edit.js.map +1 -1
  439. package/build-module/paragraph/edit.js +9 -0
  440. package/build-module/paragraph/edit.js.map +1 -1
  441. package/build-module/paragraph/edit.native.js +6 -2
  442. package/build-module/paragraph/edit.native.js.map +1 -1
  443. package/build-module/paragraph/use-enter.js +81 -0
  444. package/build-module/paragraph/use-enter.js.map +1 -0
  445. package/build-module/post-author/edit.js +2 -2
  446. package/build-module/post-author/edit.js.map +1 -1
  447. package/build-module/post-author-name/index.js +1 -0
  448. package/build-module/post-author-name/index.js.map +1 -1
  449. package/build-module/post-comment/index.js +2 -1
  450. package/build-module/post-comment/index.js.map +1 -1
  451. package/build-module/post-comments/edit.js +13 -35
  452. package/build-module/post-comments/edit.js.map +1 -1
  453. package/build-module/post-comments/index.js +1 -1
  454. package/build-module/post-comments-count/index.js +1 -0
  455. package/build-module/post-comments-count/index.js.map +1 -1
  456. package/build-module/post-comments-form/edit.js +38 -26
  457. package/build-module/post-comments-form/edit.js.map +1 -1
  458. package/build-module/post-comments-form/form.js +39 -0
  459. package/build-module/post-comments-form/form.js.map +1 -0
  460. package/build-module/post-comments-link/index.js +1 -0
  461. package/build-module/post-comments-link/index.js.map +1 -1
  462. package/build-module/post-excerpt/edit.js +1 -1
  463. package/build-module/post-excerpt/edit.js.map +1 -1
  464. package/build-module/post-featured-image/edit.js +1 -1
  465. package/build-module/post-featured-image/edit.js.map +1 -1
  466. package/build-module/post-template/edit.js +7 -2
  467. package/build-module/post-template/edit.js.map +1 -1
  468. package/build-module/post-terms/edit.js +35 -6
  469. package/build-module/post-terms/edit.js.map +1 -1
  470. package/build-module/post-terms/hooks.js +25 -0
  471. package/build-module/post-terms/hooks.js.map +1 -0
  472. package/build-module/post-terms/index.js +18 -8
  473. package/build-module/post-terms/index.js.map +1 -1
  474. package/build-module/post-title/index.js +1 -1
  475. package/build-module/post-title/index.js.map +1 -1
  476. package/build-module/pullquote/edit.js +2 -2
  477. package/build-module/pullquote/edit.js.map +1 -1
  478. package/build-module/pullquote/edit.native.js +2 -2
  479. package/build-module/pullquote/edit.native.js.map +1 -1
  480. package/build-module/query/edit/inspector-controls/index.js +24 -17
  481. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  482. package/build-module/query/edit/inspector-controls/parent-control.js +135 -0
  483. package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -0
  484. package/build-module/query/edit/inspector-controls/sticky-control.js +31 -0
  485. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -0
  486. package/build-module/query/index.js +2 -1
  487. package/build-module/query/index.js.map +1 -1
  488. package/build-module/query/utils.js +21 -0
  489. package/build-module/query/utils.js.map +1 -1
  490. package/build-module/query-title/index.js +1 -1
  491. package/build-module/query-title/index.js.map +1 -1
  492. package/build-module/query-title/variations.js +2 -2
  493. package/build-module/query-title/variations.js.map +1 -1
  494. package/build-module/quote/edit.js +4 -3
  495. package/build-module/quote/edit.js.map +1 -1
  496. package/build-module/quote/index.js +2 -1
  497. package/build-module/quote/index.js.map +1 -1
  498. package/build-module/quote/v2/edit.js +12 -5
  499. package/build-module/quote/v2/edit.js.map +1 -1
  500. package/build-module/rss/edit.js +1 -1
  501. package/build-module/rss/edit.js.map +1 -1
  502. package/build-module/search/edit.js +12 -9
  503. package/build-module/search/edit.js.map +1 -1
  504. package/build-module/separator/index.js +3 -0
  505. package/build-module/separator/index.js.map +1 -1
  506. package/build-module/site-logo/edit.js +1 -1
  507. package/build-module/site-logo/edit.js.map +1 -1
  508. package/build-module/spacer/constants.js +2 -0
  509. package/build-module/spacer/constants.js.map +1 -0
  510. package/build-module/spacer/controls.js +2 -2
  511. package/build-module/spacer/controls.js.map +1 -1
  512. package/build-module/spacer/controls.native.js +1 -1
  513. package/build-module/spacer/controls.native.js.map +1 -1
  514. package/build-module/spacer/edit.js +1 -1
  515. package/build-module/spacer/edit.js.map +1 -1
  516. package/build-module/table/edit.js +26 -7
  517. package/build-module/table/edit.js.map +1 -1
  518. package/build-module/table-of-contents/edit.js +136 -68
  519. package/build-module/table-of-contents/edit.js.map +1 -1
  520. package/build-module/table-of-contents/index.js +12 -3
  521. package/build-module/table-of-contents/index.js.map +1 -1
  522. package/build-module/table-of-contents/list.js +18 -10
  523. package/build-module/table-of-contents/list.js.map +1 -1
  524. package/build-module/table-of-contents/save.js +28 -0
  525. package/build-module/table-of-contents/save.js.map +1 -0
  526. package/build-module/table-of-contents/utils.js +11 -73
  527. package/build-module/table-of-contents/utils.js.map +1 -1
  528. package/build-module/tag-cloud/edit.js +1 -1
  529. package/build-module/tag-cloud/edit.js.map +1 -1
  530. package/build-module/template-part/edit/index.js +8 -4
  531. package/build-module/template-part/edit/index.js.map +1 -1
  532. package/build-module/template-part/edit/inner-blocks.js +4 -9
  533. package/build-module/template-part/edit/inner-blocks.js.map +1 -1
  534. package/build-module/video/edit.js +6 -10
  535. package/build-module/video/edit.js.map +1 -1
  536. package/build-module/video/edit.native.js +1 -1
  537. package/build-module/video/edit.native.js.map +1 -1
  538. package/build-style/{comments-query-loop → comments}/editor-rtl.css +0 -0
  539. package/build-style/{comments-query-loop → comments}/editor.css +0 -0
  540. package/build-style/common-rtl.css +32 -0
  541. package/build-style/common.css +32 -0
  542. package/build-style/cover/style-rtl.css +0 -4
  543. package/build-style/cover/style.css +0 -4
  544. package/build-style/editor-rtl.css +16 -10
  545. package/build-style/editor.css +16 -10
  546. package/build-style/image/editor-rtl.css +1 -1
  547. package/build-style/image/editor.css +1 -1
  548. package/build-style/navigation/style-rtl.css +3 -0
  549. package/build-style/navigation/style.css +3 -0
  550. package/build-style/separator/editor-rtl.css +1 -0
  551. package/build-style/separator/editor.css +1 -0
  552. package/build-style/style-rtl.css +73 -4
  553. package/build-style/style.css +73 -4
  554. package/build-style/table/editor-rtl.css +8 -0
  555. package/build-style/table/editor.css +8 -0
  556. package/build-style/table/style-rtl.css +38 -0
  557. package/build-style/table/style.css +38 -0
  558. package/build-style/video/editor-rtl.css +2 -5
  559. package/build-style/video/editor.css +2 -5
  560. package/build-types/table-of-contents/list.d.ts +12 -0
  561. package/build-types/table-of-contents/list.d.ts.map +1 -0
  562. package/build-types/table-of-contents/utils.d.ts +24 -0
  563. package/build-types/table-of-contents/utils.d.ts.map +1 -0
  564. package/package.json +30 -29
  565. package/src/archives/edit.js +1 -1
  566. package/src/audio/edit.js +7 -10
  567. package/src/audio/edit.native.js +1 -1
  568. package/src/avatar/block.json +0 -1
  569. package/src/avatar/index.php +2 -2
  570. package/src/block/edit.js +39 -42
  571. package/src/block/test/edit.native.js +1 -1
  572. package/src/button/block.json +1 -0
  573. package/src/button/edit.native.js +6 -3
  574. package/src/categories/block.json +5 -1
  575. package/src/categories/edit.js +9 -3
  576. package/src/categories/index.php +1 -0
  577. package/src/column/block.json +10 -0
  578. package/src/comment-author-avatar/block.json +1 -0
  579. package/src/comment-template/edit.js +1 -5
  580. package/src/{comments-query-loop → comments}/block.json +1 -1
  581. package/src/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
  582. package/src/{comments-query-loop → comments}/edit.js +1 -1
  583. package/src/{comments-query-loop → comments}/editor.scss +0 -0
  584. package/src/{comments-query-loop → comments}/index.js +0 -0
  585. package/src/{comments-query-loop → comments}/save.js +1 -3
  586. package/src/comments-title/index.js +1 -1
  587. package/src/common.scss +24 -1
  588. package/src/cover/controls.native.js +1 -2
  589. package/src/cover/edit/block-controls.js +119 -0
  590. package/src/cover/edit/cover-placeholder.js +39 -0
  591. package/src/cover/edit/index.js +381 -0
  592. package/src/cover/edit/inspector-controls.js +286 -0
  593. package/src/cover/edit/resizable-cover.js +55 -0
  594. package/src/cover/edit/use-cover-is-dark.js +71 -0
  595. package/src/cover/edit.native.js +40 -14
  596. package/src/cover/editor.scss +1 -1
  597. package/src/cover/focal-point-settings-button.native.js +1 -1
  598. package/src/cover/shared.js +4 -0
  599. package/src/cover/style.native.scss +4 -0
  600. package/src/cover/style.scss +0 -4
  601. package/src/cover/test/__snapshots__/edit.native.js.snap +6 -6
  602. package/src/cover/test/block-controls.js +62 -0
  603. package/src/cover/test/transforms.js +301 -0
  604. package/src/cover/transforms.js +112 -7
  605. package/src/cover/use-cover-is-dark.native.js +51 -0
  606. package/src/editor.scss +1 -1
  607. package/src/embed/edit.js +19 -24
  608. package/src/embed/edit.native.js +9 -14
  609. package/src/embed/embed-preview.js +4 -2
  610. package/src/embed/util.js +34 -2
  611. package/src/file/edit.native.js +0 -1
  612. package/src/file/inspector.js +1 -3
  613. package/src/gallery/edit.js +3 -2
  614. package/src/gallery/gallery.js +2 -2
  615. package/src/gallery/shared.js +3 -2
  616. package/src/gallery/use-get-media.js +2 -1
  617. package/src/gallery/use-short-code-transform.js +19 -16
  618. package/src/gallery/v1/edit.js +1 -1
  619. package/src/gallery/v1/gallery.js +2 -2
  620. package/src/group/block.json +1 -0
  621. package/src/heading/block.json +1 -0
  622. package/src/heading/edit.js +5 -2
  623. package/src/heading/transforms.js +4 -3
  624. package/src/html/edit.js +2 -2
  625. package/src/image/edit.js +11 -5
  626. package/src/image/edit.native.js +1 -2
  627. package/src/image/editor.scss +1 -1
  628. package/src/image/image.js +9 -3
  629. package/src/image/test/edit.native.js +7 -7
  630. package/src/index.js +52 -30
  631. package/src/index.native.js +12 -2
  632. package/src/is-block-metadata-experimental.js +19 -0
  633. package/src/latest-comments/edit.js +1 -1
  634. package/src/latest-posts/edit.js +27 -2
  635. package/src/latest-posts/edit.native.js +56 -1
  636. package/src/list/transforms.js +7 -0
  637. package/src/list/v2/edit.js +1 -0
  638. package/src/list/v2/migrate.js +1 -1
  639. package/src/list/v2/transforms.js +35 -0
  640. package/src/list-item/block.json +2 -1
  641. package/src/list-item/edit.js +17 -10
  642. package/src/list-item/hooks/index.js +3 -0
  643. package/src/list-item/hooks/use-backspace.js +52 -0
  644. package/src/list-item/hooks/use-enter.js +9 -16
  645. package/src/list-item/hooks/use-indent-list-item.js +50 -63
  646. package/src/list-item/hooks/use-space.js +48 -0
  647. package/src/list-item/hooks/use-split.js +24 -0
  648. package/src/list-item/utils.js +1 -1
  649. package/src/loginout/edit.js +1 -1
  650. package/src/media-text/edit.js +1 -2
  651. package/src/media-text/edit.native.js +4 -2
  652. package/src/media-text/media-container.native.js +2 -4
  653. package/src/media-text/transforms.js +154 -0
  654. package/src/navigation/block.json +1 -1
  655. package/src/navigation/edit/index.js +175 -169
  656. package/src/navigation/edit/inner-blocks.js +1 -8
  657. package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
  658. package/src/navigation/index.php +5 -0
  659. package/src/navigation/style.scss +3 -0
  660. package/src/navigation/use-navigation-entities.js +1 -1
  661. package/src/navigation/view-modal.js +68 -0
  662. package/src/navigation/view.js +0 -35
  663. package/src/navigation-link/edit.js +1 -1
  664. package/src/navigation-link/fallback-variations.js +1 -1
  665. package/src/navigation-link/hooks.js +2 -2
  666. package/src/navigation-link/test/__snapshots__/hooks.js.snap +4 -4
  667. package/src/page-list/convert-to-links-modal.js +1 -1
  668. package/src/page-list/edit.js +1 -4
  669. package/src/paragraph/edit.js +6 -0
  670. package/src/paragraph/edit.native.js +13 -1
  671. package/src/paragraph/use-enter.js +103 -0
  672. package/src/post-author/edit.js +25 -23
  673. package/src/post-author-name/block.json +1 -0
  674. package/src/post-comment/block.json +2 -1
  675. package/src/post-comments/block.json +1 -1
  676. package/src/post-comments/edit.js +13 -43
  677. package/src/post-comments/index.php +2 -0
  678. package/src/post-comments-count/block.json +1 -0
  679. package/src/post-comments-form/edit.js +50 -58
  680. package/src/post-comments-form/form.js +40 -0
  681. package/src/post-comments-link/block.json +1 -0
  682. package/src/post-excerpt/edit.js +1 -1
  683. package/src/post-featured-image/edit.js +1 -1
  684. package/src/post-template/edit.js +5 -0
  685. package/src/post-terms/block.json +8 -0
  686. package/src/post-terms/edit.js +47 -1
  687. package/src/post-terms/hooks.js +27 -0
  688. package/src/post-terms/index.js +14 -7
  689. package/src/post-terms/index.php +50 -2
  690. package/src/post-title/index.js +1 -1
  691. package/src/pullquote/edit.js +2 -2
  692. package/src/pullquote/edit.native.js +2 -2
  693. package/src/query/block.json +2 -1
  694. package/src/query/edit/inspector-controls/index.js +25 -11
  695. package/src/query/edit/inspector-controls/parent-control.js +133 -0
  696. package/src/query/edit/inspector-controls/sticky-control.js +25 -0
  697. package/src/query/utils.js +22 -0
  698. package/src/query-title/index.js +1 -1
  699. package/src/query-title/variations.js +2 -2
  700. package/src/quote/block.json +1 -0
  701. package/src/quote/edit.js +5 -2
  702. package/src/quote/index.js +1 -1
  703. package/src/quote/v2/edit.js +7 -2
  704. package/src/rss/edit.js +1 -1
  705. package/src/search/edit.js +14 -7
  706. package/src/search/index.php +85 -34
  707. package/src/separator/block.json +3 -0
  708. package/src/separator/editor.scss +1 -0
  709. package/src/site-logo/edit.js +1 -1
  710. package/src/spacer/constants.js +1 -0
  711. package/src/spacer/controls.js +2 -2
  712. package/src/spacer/controls.native.js +1 -1
  713. package/src/spacer/edit.js +1 -2
  714. package/src/table/edit.js +30 -6
  715. package/src/table/editor.scss +13 -0
  716. package/src/table/style.scss +52 -0
  717. package/src/table-of-contents/block.json +9 -2
  718. package/src/table-of-contents/edit.js +155 -75
  719. package/src/table-of-contents/index.js +2 -0
  720. package/src/table-of-contents/list.tsx +46 -0
  721. package/src/table-of-contents/save.js +25 -0
  722. package/src/table-of-contents/utils.ts +71 -0
  723. package/src/tag-cloud/block.json +1 -1
  724. package/src/tag-cloud/edit.js +1 -1
  725. package/src/template-part/edit/index.js +25 -15
  726. package/src/template-part/edit/inner-blocks.js +2 -10
  727. package/src/video/edit.js +8 -7
  728. package/src/video/edit.native.js +1 -1
  729. package/src/video/editor.scss +3 -6
  730. package/test/babel-plugin.js +67 -0
  731. package/tsconfig.json +11 -0
  732. package/tsconfig.tsbuildinfo +1 -0
  733. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +0 -1
  734. package/build/comments-query-loop/edit.js.map +0 -1
  735. package/build/comments-query-loop/index.js.map +0 -1
  736. package/build/comments-query-loop/save.js.map +0 -1
  737. package/build/cover/edit.js +0 -668
  738. package/build/cover/edit.js.map +0 -1
  739. package/build/post-terms/variations.js +0 -37
  740. package/build/post-terms/variations.js.map +0 -1
  741. package/build-module/comments-query-loop/edit.js.map +0 -1
  742. package/build-module/comments-query-loop/index.js.map +0 -1
  743. package/build-module/comments-query-loop/save.js.map +0 -1
  744. package/build-module/cover/edit.js +0 -645
  745. package/build-module/cover/edit.js.map +0 -1
  746. package/build-module/post-terms/variations.js +0 -27
  747. package/build-module/post-terms/variations.js.map +0 -1
  748. package/src/cover/edit.js +0 -827
  749. package/src/post-terms/variations.js +0 -28
  750. package/src/table-of-contents/index.php +0 -346
  751. package/src/table-of-contents/list.js +0 -28
  752. package/src/table-of-contents/utils.js +0 -126
@@ -0,0 +1,51 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { colord } from 'colord';
5
+ /**
6
+ * WordPress dependencies
7
+ */
8
+
9
+ import { useEffect, useState } from '@wordpress/element';
10
+ /**
11
+ * useCoverIsDark is a hook that returns a boolean variable specifying if the cover
12
+ * background is dark or not.
13
+ *
14
+ * @param {?boolean} initialValue Initial value.
15
+ * @param {?string} url Url of the media background.
16
+ * @param {?number} dimRatio Transparency of the overlay color. If an image and
17
+ * color are set, dimRatio is used to decide what is used
18
+ * for background darkness checking purposes.
19
+ * @param {?string} overlayColor String containing the overlay color value if one exists.
20
+ *
21
+ * @return {boolean} True if the cover background is considered "dark" and false otherwise.
22
+ */
23
+
24
+ export default function useCoverIsDark() {
25
+ let initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
26
+ let url = arguments.length > 1 ? arguments[1] : undefined;
27
+ let dimRatio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 50;
28
+ let overlayColor = arguments.length > 3 ? arguments[3] : undefined;
29
+ const [isDark, setIsDark] = useState(initialValue);
30
+ useEffect(() => {
31
+ // If opacity is greater than 50 the dominant color is the overlay color,
32
+ // so use that color for the dark mode computation.
33
+ if (dimRatio > 50 || !url) {
34
+ if (!overlayColor) {
35
+ // If no overlay color exists the overlay color is black (isDark )
36
+ setIsDark(true);
37
+ return;
38
+ }
39
+
40
+ setIsDark(colord(overlayColor).isDark());
41
+ }
42
+ }, [overlayColor, dimRatio > 50 || !url, setIsDark]);
43
+ useEffect(() => {
44
+ if (!url && !overlayColor) {
45
+ // Reset isDark.
46
+ setIsDark(false);
47
+ }
48
+ }, [!url && !overlayColor, setIsDark]);
49
+ return isDark;
50
+ }
51
+ //# sourceMappingURL=use-cover-is-dark.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/cover/use-cover-is-dark.native.js"],"names":["colord","useEffect","useState","useCoverIsDark","initialValue","url","dimRatio","overlayColor","isDark","setIsDark"],"mappings":"AAAA;AACA;AACA;AAEA,SAASA,MAAT,QAAuB,QAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,GAKb;AAAA,MAJDC,YAIC,uEAJc,KAId;AAAA,MAHDC,GAGC;AAAA,MAFDC,QAEC,uEAFU,EAEV;AAAA,MADDC,YACC;AACD,QAAM,CAAEC,MAAF,EAAUC,SAAV,IAAwBP,QAAQ,CAAEE,YAAF,CAAtC;AACAH,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA;AACA,QAAKK,QAAQ,GAAG,EAAX,IAAiB,CAAED,GAAxB,EAA8B;AAC7B,UAAK,CAAEE,YAAP,EAAsB;AACrB;AACAE,QAAAA,SAAS,CAAE,IAAF,CAAT;AACA;AACA;;AACDA,MAAAA,SAAS,CAAET,MAAM,CAAEO,YAAF,CAAN,CAAuBC,MAAvB,EAAF,CAAT;AACA;AACD,GAXQ,EAWN,CAAED,YAAF,EAAgBD,QAAQ,GAAG,EAAX,IAAiB,CAAED,GAAnC,EAAwCI,SAAxC,CAXM,CAAT;AAYAR,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAK,CAAEI,GAAF,IAAS,CAAEE,YAAhB,EAA+B;AAC9B;AACAE,MAAAA,SAAS,CAAE,KAAF,CAAT;AACA;AACD,GALQ,EAKN,CAAE,CAAEJ,GAAF,IAAS,CAAEE,YAAb,EAA2BE,SAA3B,CALM,CAAT;AAMA,SAAOD,MAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\n\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * useCoverIsDark is a hook that returns a boolean variable specifying if the cover\n * background is dark or not.\n *\n * @param {?boolean} initialValue Initial value.\n * @param {?string} url Url of the media background.\n * @param {?number} dimRatio Transparency of the overlay color. If an image and\n * color are set, dimRatio is used to decide what is used\n * for background darkness checking purposes.\n * @param {?string} overlayColor String containing the overlay color value if one exists.\n *\n * @return {boolean} True if the cover background is considered \"dark\" and false otherwise.\n */\nexport default function useCoverIsDark(\n\tinitialValue = false,\n\turl,\n\tdimRatio = 50,\n\toverlayColor\n) {\n\tconst [ isDark, setIsDark ] = useState( initialValue );\n\tuseEffect( () => {\n\t\t// If opacity is greater than 50 the dominant color is the overlay color,\n\t\t// so use that color for the dark mode computation.\n\t\tif ( dimRatio > 50 || ! url ) {\n\t\t\tif ( ! overlayColor ) {\n\t\t\t\t// If no overlay color exists the overlay color is black (isDark )\n\t\t\t\tsetIsDark( true );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetIsDark( colord( overlayColor ).isDark() );\n\t\t}\n\t}, [ overlayColor, dimRatio > 50 || ! url, setIsDark ] );\n\tuseEffect( () => {\n\t\tif ( ! url && ! overlayColor ) {\n\t\t\t// Reset isDark.\n\t\t\tsetIsDark( false );\n\t\t}\n\t}, [ ! url && ! overlayColor, setIsDark ] );\n\treturn isDark;\n}\n"]}
@@ -3,7 +3,7 @@ import { createElement, Fragment } from "@wordpress/element";
3
3
  /**
4
4
  * Internal dependencies
5
5
  */
6
- import { createUpgradedEmbedBlock, getClassNames, fallback, getAttributesFromPreview, getEmbedInfoByProvider } from './util';
6
+ import { createUpgradedEmbedBlock, getClassNames, fallback, getEmbedInfoByProvider, getMergedAttributesWithPreview } from './util';
7
7
  import EmbedControls from './embed-controls';
8
8
  import { embedContentIcon } from './icons';
9
9
  import EmbedLoading from './embed-loading';
@@ -92,17 +92,15 @@ const EmbedEdit = props => {
92
92
  };
93
93
  }, [attributesUrl]);
94
94
  /**
95
- * @return {Object} Attributes derived from the preview, merged with the current attributes.
95
+ * Returns the attributes derived from the preview, merged with the current attributes.
96
+ *
97
+ * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
98
+ * @return {Object} Merged attributes.
96
99
  */
97
100
 
98
- const getMergedAttributes = () => {
99
- const {
100
- allowResponsive,
101
- className
102
- } = attributes;
103
- return { ...attributes,
104
- ...getAttributesFromPreview(preview, title, className, responsive, allowResponsive)
105
- };
101
+ const getMergedAttributes = function () {
102
+ let ignorePreviousClassName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
103
+ return getMergedAttributesWithPreview(attributes, preview, title, responsive, ignorePreviousClassName);
106
104
  };
107
105
 
108
106
  const toggleResponsive = () => {
@@ -137,15 +135,11 @@ const EmbedEdit = props => {
137
135
 
138
136
  useEffect(() => {
139
137
  if (preview && !isEditingURL) {
140
- // Even though we set attributes that get derived from the preview,
141
- // we don't access them directly because for the initial render,
142
- // the `setAttributes` call will not have taken effect. If we're
143
- // rendering responsive content, setting the responsive classes
144
- // after the preview has been rendered can result in unwanted
145
- // clipping or scrollbars. The `getAttributesFromPreview` function
146
- // that `getMergedAttributes` uses is memoized so that we're not
147
- // calculating them on every render.
148
- setAttributes(getMergedAttributes());
138
+ // When obtaining an incoming preview, we set the attributes derived from
139
+ // the preview data. In this case when getting the merged attributes,
140
+ // we ignore the previous classname because it might not match the expected
141
+ // classes by the new preview.
142
+ setAttributes(getMergedAttributes(true));
149
143
 
150
144
  if (onReplace) {
151
145
  const upgradedBlock = createUpgradedEmbedBlock(props, getMergedAttributes());
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/edit.js"],"names":["createUpgradedEmbedBlock","getClassNames","fallback","getAttributesFromPreview","getEmbedInfoByProvider","EmbedControls","embedContentIcon","EmbedLoading","EmbedPlaceholder","EmbedPreview","classnames","__","_x","sprintf","useState","useEffect","useDispatch","useSelect","useBlockProps","store","coreStore","View","EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","icon","setURL","isEditingURL","setIsEditingURL","invalidateResolution","preview","fetching","themeSupportsResponsive","cannotEmbed","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","allowResponsive","className","toggleResponsive","newAllowResponsive","newURL","replace","upgradedBlock","blockProps","label","showEmbedPlaceholder","event","preventDefault","target","value","caption","classFromPreview"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,wBADD,EAECC,aAFD,EAGCC,QAHD,EAICC,wBAJD,EAKCC,sBALD,QAMO,QANP;AAOA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,IAAT,QAAqB,uBAArB;;AAEA,MAAMC,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,EAAExB,EAAE,CAAE,OAAF,EAAW,aAAX,CADe;AAExByB,IAAAA,IAAI,EAAE/B;AAFkB,GAAzB;AAIA,QAAM;AAAE+B,IAAAA,IAAF;AAAQD,IAAAA;AAAR,MACLhC,sBAAsB,CAAEqB,gBA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JP;AAKC,IAAA,IAAI,EAAG2B,IALR;AAMC,IAAA,OAAO,EAAGqB,OANX;AAOC,IAAA,eAAe,EAAKD,KAAF,IACjB3C,aAAa,CAAE;AAAE4C,MAAAA,OAAO,EAAED;AAAX,KAAF,CARf;AAUC,IAAA,UAAU,EAAG7C,UAVd;AAWC,IAAA,IAAI,EAAGO,IAXR;AAYC,IAAA,KAAK,EAAGiC,KAZT;AAaC,IAAA,iBAAiB,EAAGrC;AAbrB,IADD,CATD,CADD;AA6BA,CAlOD;;AAoOA,eAAeX,SAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetAttributesFromPreview,\n\tgetEmbedInfoByProvider,\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 {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\tgetThemeSupports,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! attributesUrl ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( attributesUrl );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\tthemeSupportsResponsive: getThemeSupports()[\n\t\t\t\t\t'responsive-embeds'\n\t\t\t\t],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t};\n\t\t},\n\t\t[ attributesUrl ]\n\t);\n\n\t/**\n\t * @return {Object} Attributes derived from the preview, merged with the current attributes.\n\t */\n\tconst getMergedAttributes = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\treturn {\n\t\t\t...attributes,\n\t\t\t...getAttributesFromPreview(\n\t\t\t\tpreview,\n\t\t\t\ttitle,\n\t\t\t\tclassName,\n\t\t\t\tresponsive,\n\t\t\t\tallowResponsive\n\t\t\t),\n\t\t};\n\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// Even though we set attributes that get derived from the preview,\n\t\t\t// we don't access them directly because for the initial render,\n\t\t\t// the `setAttributes` call will not have taken effect. If we're\n\t\t\t// rendering responsive content, setting the responsive classes\n\t\t\t// after the preview has been rendered can result in unwanted\n\t\t\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t\t\t// that `getMergedAttributes` uses is memoized so that we're not\n\t\t\t// calculating them on every render.\n\t\t\tsetAttributes( getMergedAttributes() );\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":["createUpgradedEmbedBlock","getClassNames","fallback","getEmbedInfoByProvider","getMergedAttributesWithPreview","EmbedControls","embedContentIcon","EmbedLoading","EmbedPlaceholder","EmbedPreview","classnames","__","_x","sprintf","useState","useEffect","useDispatch","useSelect","useBlockProps","store","coreStore","View","EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","icon","setURL","isEditingURL","setIsEditingURL","invalidateResolution","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":";;AAAA;AACA;AACA;AACA,SACCA,wBADD,EAECC,aAFD,EAGCC,QAHD,EAICC,sBAJD,EAKCC,8BALD,QAMO,QANP;AAOA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,IAAT,QAAqB,uBAArB;;AAEA,MAAMC,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,EAAExB,EAAE,CAAE,OAAF,EAAW,aAAX,CADe;AAExByB,IAAAA,IAAI,EAAE/B;AAFkB,GAAzB;AAIA,QAAM;AAAE+B,IAAAA,IAAF;AAAQD,IAAAA;AAAR,MACLjC,sBAAs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AAO,EAAGsB,OANX;AAOC,IAAA,eAAe,EAAKD,KAAF,IACjB5C,aAAa,CAAE;AAAE6C,MAAAA,OAAO,EAAED;AAAX,KAAF,CARf;AAUC,IAAA,UAAU,EAAG9C,UAVd;AAWC,IAAA,IAAI,EAAGO,IAXR;AAYC,IAAA,KAAK,EAAGkC,KAZT;AAaC,IAAA,iBAAiB,EAAGtC;AAbrB,IADD,CATD,CADD;AA6BA,CA7ND;;AA+NA,eAAeX,SAAf","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 {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\tgetThemeSupports,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! attributesUrl ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( attributesUrl );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\tthemeSupportsResponsive: getThemeSupports()[\n\t\t\t\t\t'responsive-embeds'\n\t\t\t\t],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t};\n\t\t},\n\t\t[ attributesUrl ]\n\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"]}
@@ -3,7 +3,7 @@ import { createElement, Fragment } from "@wordpress/element";
3
3
  /**
4
4
  * Internal dependencies
5
5
  */
6
- import { createUpgradedEmbedBlock, getClassNames, fallback, getAttributesFromPreview, getEmbedInfoByProvider } from './util';
6
+ import { createUpgradedEmbedBlock, getClassNames, fallback, getEmbedInfoByProvider, getMergedAttributesWithPreview } from './util';
7
7
  import EmbedControls from './embed-controls';
8
8
  import { embedContentIcon } from './icons';
9
9
  import EmbedLoading from './embed-loading';
@@ -115,13 +115,7 @@ const EmbedEdit = props => {
115
115
 
116
116
  const getMergedAttributes = function () {
117
117
  let ignorePreviousClassName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
118
- const {
119
- allowResponsive,
120
- className
121
- } = attributes;
122
- return { ...attributes,
123
- ...getAttributesFromPreview(preview, title, ignorePreviousClassName ? undefined : className, responsive, allowResponsive)
124
- };
118
+ return getMergedAttributesWithPreview(attributes, preview, title, responsive, ignorePreviousClassName);
125
119
  };
126
120
 
127
121
  const toggleResponsive = () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/edit.native.js"],"names":["createUpgradedEmbedBlock","getClassNames","fallback","getAttributesFromPreview","getEmbedInfoByProvider","EmbedControls","embedContentIcon","EmbedLoading","EmbedPlaceholder","EmbedPreview","EmbedLinkSettings","classnames","_x","useCallback","useState","useEffect","useDispatch","useSelect","useBlockProps","store","blockEditorStore","coreStore","View","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","embedInfoByProvider","wasBlockJustInserted","select","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","ignorePreviousClassName","allowResponsive","className","toggleResponsive","newAllowResponsive","newURL","replace","upgradedBlock","onEditURL","value","blockProps","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","event"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,wBADD,EAECC,aAFD,EAGCC,QAHD,EAICC,wBAJD,EAKCC,sBALD,QAMO,QANP;AAOA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASC,gBAAT,QAAiC,SAAjC;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,QAAtB,EAAgCC,SAAhC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,UAF3B;AAGC,IAAA,eAAe,EAAGuC,eAHnB;AAIC,IAAA,gBAAgB,EAAGE,gBAJpB;AAKC,IAAA,GAAG,EAAGxC,GALP;AAMC,IAAA,SAAS,EAAGoD,SANb;AAOC,IAAA,SAAS,EAAGP;AAPb,IADD,EAUC,cAAC,IAAD,EAAWE,UAAX,EACC,cAAC,YAAD;AACC,IAAA,KAAK,EAAGnD,KADT;AAEC,IAAA,SAAS,EAAG2C,SAFb;AAGC,IAAA,QAAQ,EAAGjC,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,EAAGa,OATX;AAUC,IAAA,qBAAqB,EAAGgC,qBAVzB;AAWC,IAAA,WAAW,EAAGpD,WAXf;AAYC,IAAA,IAAI,EAAGiC,IAZR;AAaC,IAAA,GAAG,EAAG/B,GAbP;AAcC,IAAA,kBAAkB,EAAG,CAAEU;AAdxB,IADD,CAVD,CA1BF,EAwDC,cAAC,iBAAD,CACC;AADD;AAEC,IAAA,SAAS,MAFV;AAGC,IAAA,KAAK,EAAGV,GAHT;AAIC,IAAA,KAAK,EAAGoD,SAJT;AAKC,IAAA,SAAS,EAAGrC,oBALb;AAMC,IAAA,OAAO,EAAG,MAAMC,uBAAuB,CAAE,KAAF,CANxC;AAOC,IAAA,QAAQ,EAAG6B,SAPZ;AAQC,IAAA,eAAe;AARhB,IAxDD,CADD;AAqEA,CA3QD;;AA6QA,eAAepD,SAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetAttributesFromPreview,\n\tgetEmbedInfoByProvider,\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 ] = useState(\n\t\tisEditingURL\n\t);\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tgetThemeSupports,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! url ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t'getEmbedPreview',\n\t\t\t\t[ url ]\n\t\t\t);\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\tthemeSupportsResponsive: getThemeSupports()[\n\t\t\t\t\t'responsive-embeds'\n\t\t\t\t],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t};\n\t\t},\n\t\t[ url ]\n\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\tconst { allowResponsive, className } = attributes;\n\t\treturn {\n\t\t\t...attributes,\n\t\t\t...getAttributesFromPreview(\n\t\t\t\tpreview,\n\t\t\t\ttitle,\n\t\t\t\tignorePreviousClassName ? undefined : className,\n\t\t\t\tresponsive,\n\t\t\t\tallowResponsive\n\t\t\t),\n\t\t};\n\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( () => setShowEmbedBottomSheet( isEditingURL ), [\n\t\tisEditingURL,\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":["createUpgradedEmbedBlock","getClassNames","fallback","getEmbedInfoByProvider","getMergedAttributesWithPreview","EmbedControls","embedContentIcon","EmbedLoading","EmbedPlaceholder","EmbedPreview","EmbedLinkSettings","classnames","_x","useCallback","useState","useEffect","useDispatch","useSelect","useBlockProps","store","blockEditorStore","coreStore","View","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","embedInfoByProvider","wasBlockJustInserted","select","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","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":";;AAAA;AACA;AACA;A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AAQC,IAAA,eAAe;AARhB,IAxDD,CADD;AAqEA,CAtQD;;AAwQA,eAAepD,SAAf","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 ] = useState(\n\t\tisEditingURL\n\t);\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tgetThemeSupports,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! url ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t'getEmbedPreview',\n\t\t\t\t[ url ]\n\t\t\t);\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\tthemeSupportsResponsive: getThemeSupports()[\n\t\t\t\t\t'responsive-embeds'\n\t\t\t\t],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t};\n\t\t},\n\t\t[ url ]\n\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( () => setShowEmbedBottomSheet( isEditingURL ), [\n\t\tisEditingURL,\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"]}
@@ -17,7 +17,7 @@ import { __, sprintf } from '@wordpress/i18n';
17
17
  import { Placeholder, SandBox } from '@wordpress/components';
18
18
  import { RichText, BlockIcon } from '@wordpress/block-editor';
19
19
  import { Component } from '@wordpress/element';
20
- import { createBlock } from '@wordpress/blocks';
20
+ import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
21
21
  /**
22
22
  * Internal dependencies
23
23
  */
@@ -128,7 +128,7 @@ class EmbedPreview extends Component {
128
128
  value: caption,
129
129
  onChange: onCaptionChange,
130
130
  inlineToolbar: true,
131
- __unstableOnSplitAtEnd: () => insertBlocksAfter(createBlock('core/paragraph'))
131
+ __unstableOnSplitAtEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName()))
132
132
  }));
133
133
  }
134
134
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/embed-preview.js"],"names":["getPhotoHtml","classnames","__","sprintf","Placeholder","SandBox","RichText","BlockIcon","Component","createBlock","WpEmbedPreview","EmbedPreview","constructor","arguments","hideOverlay","bind","state","interactive","getDerivedStateFromProps","nextProps","isSelected","setState","render","preview","previewable","url","type","caption","onCaptionChange","className","icon","label","insertBlocksAfter","props","scripts","html","parsedHost","URL","host","split","parsedHostBaseUrl","splice","length","join","iframeTitle","sandboxClassnames","embedWrapper","isEmpty"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,QAA7B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,mBAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,uBAArC;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,yBAApC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;;AAEA,MAAMC,YAAN,SAA2BH,SAA3B,CAAqC;AACpCI,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AACA,SAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBC,IAAjB,CAAuB,IAAvB,CAAnB;AACA,SAAKC,KAAL,GAAa;AACZC,MAAAA,WAAW,EAAE;AADD,KAAb;AAGA;;AAE8B,SAAxBC,wBAAwB,CAAEC,SAAF,EAAaH,KAAb,EAAqB;AACnD,QAAK,CAAEG,SAAS,CAACC,UAAZ,IAA0BJ,KAAK,CAACC,WAArC,EAAmD;AAClD;AACA;AACA;AACA,aAAO;AAAEA,QAAAA,WAAW,EAAE;AAAf,OAAP;AACA;;AAED,WAAO,IAAP;AACA;;AAEDH,EAAAA,WAAW,GAAG;AACb;AACA;AACA;AACA;AACA;AACA,SAAKO,QAAL,CAAe;AAAEJ,MAAAA,WAAW,EAAE;AAAf,KAAf;AACA;;AAEDK,EAAAA,MAAM,GAAG;AACR,UAAM;AACLC,MAAAA,OADK;AAELC,MAAAA,WAFK;AAGLC,MAAA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,0CADX;AAEC,MAAA,SAAS,EAAG,KAAKH;AAFlB,MATF,CAJF;AAoBA;;AAEA,WACC;AACC,MAAA,SAAS,EAAGb,UAAU,CAAE4B,SAAF,EAAa,gBAAb,EAA+B;AACpD,yBAAiB,YAAYH;AADuB,OAA/B;AADvB,OAKGF,WAAW,GACZsB,YADY,GAGZ,cAAC,WAAD;AACC,MAAA,IAAI,EAAG,cAAC,SAAD;AAAW,QAAA,IAAI,EAAGhB,IAAlB;AAAyB,QAAA,UAAU;AAAnC,QADR;AAEC,MAAA,KAAK,EAAGC;AAFT,OAIC;AAAG,MAAA,SAAS,EAAC;AAAb,OACC;AAAG,MAAA,IAAI,EAAGN;AAAV,OAAkBA,GAAlB,CADD,CAJD,EAOC;AAAG,MAAA,SAAS,EAAC;AAAb,OACGtB,OAAO;AACR;AACAD,IAAAA,EAAE,CACD,4DADC,CAFM,EAKRsC,iBALQ,CADV,CAPD,CARF,EA0BG,CAAE,CAAElC,QAAQ,CAACyC,OAAT,CAAkBpB,OAAlB,CAAF,IAAiCP,UAAnC,KACD,cAAC,QAAD;AACC,MAAA,OAAO,EAAC,YADT;AAEC,MAAA,WAAW,EAAGlB,EAAE,CAAE,aAAF,CAFjB;AAGC,MAAA,KAAK,EAAGyB,OAHT;AAIC,MAAA,QAAQ,EAAGC,eAJZ;AAKC,MAAA,aAAa,MALd;AAMC,MAAA,sBAAsB,EAAG,MACxBI,iBAAiB,CAAEvB,WAAW,CAAE,gBAAF,CAAb;AAPnB,MA3BF,CADD;AAyCA;;AAjImC;;AAoIrC,eAAeE,YAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getPhotoHtml } from './util';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames/dedupe';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, SandBox } from '@wordpress/components';\nimport { RichText, BlockIcon } from '@wordpress/block-editor';\nimport { Component } from '@wordpress/element';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport WpEmbedPreview from './wp-embed-preview';\n\nclass EmbedPreview extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.hideOverlay = this.hideOverlay.bind( this );\n\t\tthis.state = {\n\t\t\tinteractive: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromProps( nextProps, state ) {\n\t\tif ( ! nextProps.isSelected && state.interactive ) {\n\t\t\t// We only want to change this when the block is not selected, because changing it when\n\t\t\t// the block becomes selected makes the overlap disappear too early. Hiding the overlay\n\t\t\t// happens on mouseup when the overlay is clicked.\n\t\t\treturn { interactive: false };\n\t\t}\n\n\t\treturn null;\n\t}\n\n\thideOverlay() {\n\t\t// This is called onMouseUp on the overlay. We can't respond to the `isSelected` prop\n\t\t// changing, because that happens on mouse down, and the overlay immediately disappears,\n\t\t// and the mouse event can end up in the preview content. We can't use onClick on\n\t\t// the overlay to hide it either, because then the editor misses the mouseup event, and\n\t\t// thinks we're multi-selecting blocks.\n\t\tthis.setState( { interactive: true } );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tpreview,\n\t\t\tpreviewable,\n\t\t\turl,\n\t\t\ttype,\n\t\t\tcaption,\n\t\t\tonCaptionChange,\n\t\t\tisSelected,\n\t\t\tclassName,\n\t\t\ticon,\n\t\t\tlabel,\n\t\t\tinsertBlocksAfter,\n\t\t} = this.props;\n\t\tconst { scripts } = preview;\n\t\tconst { interactive } = this.state;\n\n\t\tconst html = 'photo' === type ? getPhotoHtml( preview ) : preview.html;\n\t\tconst parsedHost = new URL( url ).host.split( '.' );\n\t\tconst parsedHostBaseUrl = parsedHost\n\t\t\t.splice( parsedHost.length - 2, parsedHost.length - 1 )\n\t\t\t.join( '.' );\n\t\tconst iframeTitle = sprintf(\n\t\t\t// translators: %s: host providing embed content e.g: www.youtube.com\n\t\t\t__( 'Embedded content from %s' ),\n\t\t\tparsedHostBaseUrl\n\t\t);\n\t\tconst sandboxClassnames = classnames(\n\t\t\ttype,\n\t\t\tclassName,\n\t\t\t'wp-block-embed__wrapper'\n\t\t);\n\n\t\t// Disabled because the overlay div doesn't actually have a role or functionality\n\t\t// as far as the user is concerned. We're just catching the first click so that\n\t\t// the block can be selected without interacting with the embed preview that the overlay covers.\n\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\tconst embedWrapper =\n\t\t\t'wp-embed' === type ? (\n\t\t\t\t<WpEmbedPreview html={ html } />\n\t\t\t) : (\n\t\t\t\t<div className=\"wp-block-embed__wrapper\">\n\t\t\t\t\t<SandBox\n\t\t\t\t\t\thtml={ html }\n\t\t\t\t\t\tscripts={ scripts }\n\t\t\t\t\t\ttitle={ iframeTitle }\n\t\t\t\t\t\ttype={ sandboxClassnames }\n\t\t\t\t\t\tonFocus={ this.hideOverlay }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! interactive && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-library-embed__interactive-overlay\"\n\t\t\t\t\t\t\tonMouseUp={ this.hideOverlay }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n\n\t\treturn (\n\t\t\t<figure\n\t\t\t\tclassName={ classnames( className, 'wp-block-embed', {\n\t\t\t\t\t'is-type-video': 'video' === type,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ previewable ? (\n\t\t\t\t\tembedWrapper\n\t\t\t\t) : (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t>\n\t\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t\t<a href={ url }>{ url }</a>\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: host providing embed content e.g: www.youtube.com */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\"Embedded content from %s can't be previewed in the editor.\"\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tparsedHostBaseUrl\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</Placeholder>\n\t\t\t\t) }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ onCaptionChange }\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t);\n\t}\n}\n\nexport default EmbedPreview;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/embed/embed-preview.js"],"names":["getPhotoHtml","classnames","__","sprintf","Placeholder","SandBox","RichText","BlockIcon","Component","createBlock","getDefaultBlockName","WpEmbedPreview","EmbedPreview","constructor","arguments","hideOverlay","bind","state","interactive","getDerivedStateFromProps","nextProps","isSelected","setState","render","preview","previewable","url","type","caption","onCaptionChange","className","icon","label","insertBlocksAfter","props","scripts","html","parsedHost","URL","host","split","parsedHostBaseUrl","splice","length","join","iframeTitle","sandboxClassnames","embedWrapper","isEmpty"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,QAA7B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,mBAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,uBAArC;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAo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GN;AAAV,OAAkBA,GAAlB,CADD,CAJD,EAOC;AAAG,MAAA,SAAS,EAAC;AAAb,OACGvB,OAAO;AACR;AACAD,IAAAA,EAAE,CACD,4DADC,CAFM,EAKRuC,iBALQ,CADV,CAPD,CARF,EA0BG,CAAE,CAAEnC,QAAQ,CAAC0C,OAAT,CAAkBpB,OAAlB,CAAF,IAAiCP,UAAnC,KACD,cAAC,QAAD;AACC,MAAA,OAAO,EAAC,YADT;AAEC,MAAA,WAAW,EAAGnB,EAAE,CAAE,aAAF,CAFjB;AAGC,MAAA,KAAK,EAAG0B,OAHT;AAIC,MAAA,QAAQ,EAAGC,eAJZ;AAKC,MAAA,aAAa,MALd;AAMC,MAAA,sBAAsB,EAAG,MACxBI,iBAAiB,CAChBxB,WAAW,CAAEC,mBAAmB,EAArB,CADK;AAPnB,MA3BF,CADD;AA2CA;;AAnImC;;AAsIrC,eAAeE,YAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getPhotoHtml } from './util';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames/dedupe';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, SandBox } from '@wordpress/components';\nimport { RichText, BlockIcon } from '@wordpress/block-editor';\nimport { Component } from '@wordpress/element';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport WpEmbedPreview from './wp-embed-preview';\n\nclass EmbedPreview extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.hideOverlay = this.hideOverlay.bind( this );\n\t\tthis.state = {\n\t\t\tinteractive: false,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromProps( nextProps, state ) {\n\t\tif ( ! nextProps.isSelected && state.interactive ) {\n\t\t\t// We only want to change this when the block is not selected, because changing it when\n\t\t\t// the block becomes selected makes the overlap disappear too early. Hiding the overlay\n\t\t\t// happens on mouseup when the overlay is clicked.\n\t\t\treturn { interactive: false };\n\t\t}\n\n\t\treturn null;\n\t}\n\n\thideOverlay() {\n\t\t// This is called onMouseUp on the overlay. We can't respond to the `isSelected` prop\n\t\t// changing, because that happens on mouse down, and the overlay immediately disappears,\n\t\t// and the mouse event can end up in the preview content. We can't use onClick on\n\t\t// the overlay to hide it either, because then the editor misses the mouseup event, and\n\t\t// thinks we're multi-selecting blocks.\n\t\tthis.setState( { interactive: true } );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tpreview,\n\t\t\tpreviewable,\n\t\t\turl,\n\t\t\ttype,\n\t\t\tcaption,\n\t\t\tonCaptionChange,\n\t\t\tisSelected,\n\t\t\tclassName,\n\t\t\ticon,\n\t\t\tlabel,\n\t\t\tinsertBlocksAfter,\n\t\t} = this.props;\n\t\tconst { scripts } = preview;\n\t\tconst { interactive } = this.state;\n\n\t\tconst html = 'photo' === type ? getPhotoHtml( preview ) : preview.html;\n\t\tconst parsedHost = new URL( url ).host.split( '.' );\n\t\tconst parsedHostBaseUrl = parsedHost\n\t\t\t.splice( parsedHost.length - 2, parsedHost.length - 1 )\n\t\t\t.join( '.' );\n\t\tconst iframeTitle = sprintf(\n\t\t\t// translators: %s: host providing embed content e.g: www.youtube.com\n\t\t\t__( 'Embedded content from %s' ),\n\t\t\tparsedHostBaseUrl\n\t\t);\n\t\tconst sandboxClassnames = classnames(\n\t\t\ttype,\n\t\t\tclassName,\n\t\t\t'wp-block-embed__wrapper'\n\t\t);\n\n\t\t// Disabled because the overlay div doesn't actually have a role or functionality\n\t\t// as far as the user is concerned. We're just catching the first click so that\n\t\t// the block can be selected without interacting with the embed preview that the overlay covers.\n\t\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\t\tconst embedWrapper =\n\t\t\t'wp-embed' === type ? (\n\t\t\t\t<WpEmbedPreview html={ html } />\n\t\t\t) : (\n\t\t\t\t<div className=\"wp-block-embed__wrapper\">\n\t\t\t\t\t<SandBox\n\t\t\t\t\t\thtml={ html }\n\t\t\t\t\t\tscripts={ scripts }\n\t\t\t\t\t\ttitle={ iframeTitle }\n\t\t\t\t\t\ttype={ sandboxClassnames }\n\t\t\t\t\t\tonFocus={ this.hideOverlay }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! interactive && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-library-embed__interactive-overlay\"\n\t\t\t\t\t\t\tonMouseUp={ this.hideOverlay }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n\n\t\treturn (\n\t\t\t<figure\n\t\t\t\tclassName={ classnames( className, 'wp-block-embed', {\n\t\t\t\t\t'is-type-video': 'video' === type,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ previewable ? (\n\t\t\t\t\tembedWrapper\n\t\t\t\t) : (\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } showColors /> }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t>\n\t\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t\t<a href={ url }>{ url }</a>\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p className=\"components-placeholder__error\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: host providing embed content e.g: www.youtube.com */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\"Embedded content from %s can't be previewed in the editor.\"\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tparsedHostBaseUrl\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</Placeholder>\n\t\t\t\t) }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ onCaptionChange }\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t);\n\t}\n}\n\nexport default EmbedPreview;\n"]}
@@ -117,9 +117,10 @@ export const findMoreSuitableBlock = url => {
117
117
  };
118
118
  export const isFromWordPress = html => html && html.includes('class="wp-embedded-content"');
119
119
  export const getPhotoHtml = photo => {
120
- // 100% width for the preview so it fits nicely into the document, some "thumbnails" are
121
- // actually the full size photo. If thumbnails not found, use full image.
122
- const imageUrl = photo.thumbnail_url || photo.url;
120
+ // If full image url not found use thumbnail.
121
+ const imageUrl = photo.url || photo.thumbnail_url; // 100% width for the preview so it fits nicely into the document, some "thumbnails" are
122
+ // actually the full size photo.
123
+
123
124
  const photoPreview = createElement("p", null, createElement("img", {
124
125
  src: imageUrl,
125
126
  alt: photo.title,
@@ -328,4 +329,25 @@ export const getAttributesFromPreview = memoize(function (preview, title, curren
328
329
  attributes.className = getClassNames(html, currentClassNames, isResponsive && allowResponsive);
329
330
  return attributes;
330
331
  });
332
+ /**
333
+ * Returns the attributes derived from the preview, merged with the current attributes.
334
+ *
335
+ * @param {Object} currentAttributes The current attributes of the block.
336
+ * @param {Object} preview The preview data.
337
+ * @param {string} title The block's title, e.g. Twitter.
338
+ * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.
339
+ * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
340
+ * @return {Object} Merged attributes.
341
+ */
342
+
343
+ export const getMergedAttributesWithPreview = function (currentAttributes, preview, title, isResponsive) {
344
+ let ignorePreviousClassName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
345
+ const {
346
+ allowResponsive,
347
+ className
348
+ } = currentAttributes;
349
+ return { ...currentAttributes,
350
+ ...getAttributesFromPreview(preview, title, ignorePreviousClassName ? undefined : className, isResponsive, allowResponsive)
351
+ };
352
+ };
331
353
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/util.js"],"names":["ASPECT_RATIOS","WP_EMBED_TYPE","kebabCase","classnames","memoize","renderToString","createBlock","getBlockType","getBlockVariations","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","shouldCreateNewBlock","wpVariation","removeAspectRatioClasses","existingClassNames","aspectRatioClassNames","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"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,aAAxB,QAA6C,aAA7C;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,QAA1B;AACA,OAAOC,UAAP,MAAuB,mBAAvB;AACA,OAAOC,OAAP,MAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SACCC,WADD,EAECC,YAFD,EAGCC,kBAHD,QAIO,mBAJP;AAMA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM;AAAEC,EAAAA,IAAI,EAAEC;AAAR,IAAgCC,QAAtC;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,sBAAsB,GAAKC,QAA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;AAAQoD,IAAAA,aAAa,EAAEC;AAAvB,MAAwC1C,OAA9C;AACA,QAAME,gBAAgB,GAAGlC,SAAS,CACjC,CAAE0E,YAAY,IAAI9C,KAAlB,EAA0B+C,WAA1B,EADiC,CAAlC;;AAIA,MAAKvD,eAAe,CAAEC,IAAF,CAApB,EAA+B;AAC9Bc,IAAAA,IAAI,GAAGpC,aAAP;AACA;;AAED,MAAKsB,IAAI,IAAI,YAAYc,IAAzB,EAAgC;AAC/BF,IAAAA,UAAU,CAACE,IAAX,GAAkBA,IAAlB;AACAF,IAAAA,UAAU,CAACC,gBAAX,GAA8BA,gBAA9B;AACA;;AAEDD,EAAAA,UAAU,CAACa,SAAX,GAAuBC,aAAa,CACnC1B,IADmC,EAEnCkD,iBAFmC,EAGnCC,YAAY,IAAIxB,eAHmB,CAApC;AAMA,SAAOf,UAAP;AACA,CAtC6C,CAAxC","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// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo. If thumbnails not found, use full image.\n\tconst imageUrl = photo.thumbnail_url || photo.url;\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"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/embed/util.js"],"names":["ASPECT_RATIOS","WP_EMBED_TYPE","kebabCase","classnames","memoize","renderToString","createBlock","getBlockType","getBlockVariations","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","shouldCreateNewBlock","wpVariation","removeAspectRatioClasses","existingClassNames","aspectRatioClassNames","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":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,aAAxB,QAA6C,aAA7C;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,QAA1B;AACA,OAAOC,UAAP,MAAuB,mBAAvB;AACA,OAAOC,OAAP,MAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SACCC,WADD,EAECC,YAFD,EAGCC,kBAHD,QAIO,mBAJP;AAMA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM;AAAEC,EAAAA,IAAI,EAAEC;AAAR,IAAgCC,QAAtC;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,sBAAsB,GAAKC,QAAF;AAAA;;AAAA,gCACrCL,kBAAkB,CAAEE,mBAAF,CADmB,wDACrC,oBAA2CI,IAA3C,CACC;AAAA,QAAE;AAAEL,MAAAA;AAAF,KAAF;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,IAAI9C,KAAlB,EAA0B+C,WAA1B,EADiC,CAAlC;;AAIA,MAAKvD,eAAe,CAAEC,IAAF,CAApB,EAA+B;AAC9Bc,IAAAA,IAAI,GAAGpC,aAAP;AACA;;AAED,MAAKsB,IAAI,IAAI,YAAYc,IAAzB,EAAgC;AAC/BF,IAAAA,UAAU,CAACE,IAAX,GAAkBA,IAAlB;AACAF,IAAAA,UAAU,CAACC,gBAAX,GAA8BA,gBAA9B;AACA;;AAEDD,EAAAA,UAAU,CAACa,SAAX,GAAuBC,aAAa,CACnC1B,IADmC,EAEnCkD,iBAFmC,EAGnCC,YAAY,IAAIxB,eAHmB,CAApC;AAMA,SAAOf,UAAP;AACA,CAtC6C,CAAxC;AAyCP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAM2C,8BAA8B,GAAG,UAC7CC,iBAD6C,EAE7C7C,OAF6C,EAG7CJ,KAH6C,EAI7C4C,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,CAC1BtC,OAD0B,EAE1BJ,KAF0B,EAG1BkD,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"]}
@@ -397,7 +397,6 @@ export class FileEdit extends Component {
397
397
  return createElement(TouchableWithoutFeedback, {
398
398
  accessible: !isSelected,
399
399
  onPress: this.onFilePressed,
400
- onLongPress: openMediaOptions,
401
400
  disabled: !isSelected
402
401
  }, createElement(View, {
403
402
  onLayout: this.onLayout,