@wordpress/block-library 9.47.0 → 9.48.1

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 (552) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/columns/transforms.cjs +65 -0
  3. package/build/columns/transforms.cjs.map +2 -2
  4. package/build/comments/edit/placeholder.cjs +1 -1
  5. package/build/comments/edit/placeholder.cjs.map +2 -2
  6. package/build/cover/edit/inspector-controls.cjs +16 -4
  7. package/build/cover/edit/inspector-controls.cjs.map +2 -2
  8. package/build/gallery/edit.cjs +212 -331
  9. package/build/gallery/edit.cjs.map +2 -2
  10. package/build/gallery/transforms.cjs +43 -0
  11. package/build/gallery/transforms.cjs.map +2 -2
  12. package/build/heading/edit.cjs +0 -1
  13. package/build/heading/edit.cjs.map +2 -2
  14. package/build/image/image.cjs +14 -3
  15. package/build/image/image.cjs.map +2 -2
  16. package/build/image/use-open-image-media-editor-modal.cjs +8 -2
  17. package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
  18. package/build/list/edit.cjs +1 -8
  19. package/build/list/edit.cjs.map +2 -2
  20. package/build/list/ordered-list-settings.cjs +1 -44
  21. package/build/list/ordered-list-settings.cjs.map +2 -2
  22. package/build/list-item/hooks/use-merge.cjs +47 -24
  23. package/build/list-item/hooks/use-merge.cjs.map +2 -2
  24. package/build/navigation/edit/index.cjs +15 -26
  25. package/build/navigation/edit/index.cjs.map +2 -2
  26. package/build/navigation-link/edit.cjs +0 -1
  27. package/build/navigation-link/edit.cjs.map +2 -2
  28. package/build/navigation-submenu/edit.cjs +2 -1
  29. package/build/navigation-submenu/edit.cjs.map +2 -2
  30. package/build/paragraph/deprecated.cjs +1 -0
  31. package/build/paragraph/deprecated.cjs.map +2 -2
  32. package/build/paragraph/edit.cjs +10 -1
  33. package/build/paragraph/edit.cjs.map +3 -3
  34. package/build/playlist/block.json +12 -0
  35. package/build/playlist/edit.cjs +27 -1
  36. package/build/playlist/edit.cjs.map +2 -2
  37. package/build/playlist/save.cjs +8 -1
  38. package/build/playlist/save.cjs.map +2 -2
  39. package/build/playlist/view.cjs +1 -0
  40. package/build/playlist/view.cjs.map +2 -2
  41. package/build/post-featured-image/edit.cjs +6 -4
  42. package/build/post-featured-image/edit.cjs.map +2 -2
  43. package/build/post-time-to-read/index.cjs +1 -1
  44. package/build/post-time-to-read/index.cjs.map +2 -2
  45. package/build/post-time-to-read/variations.cjs +1 -1
  46. package/build/post-time-to-read/variations.cjs.map +2 -2
  47. package/build/pullquote/edit.cjs +2 -7
  48. package/build/pullquote/edit.cjs.map +2 -2
  49. package/build/quote/edit.cjs +4 -9
  50. package/build/quote/edit.cjs.map +2 -2
  51. package/build/shortcode/transforms.cjs +2 -2
  52. package/build/shortcode/transforms.cjs.map +2 -2
  53. package/build/site-logo/edit.cjs +4 -1
  54. package/build/site-logo/edit.cjs.map +2 -2
  55. package/build/utils/waveform-player.cjs +42 -9
  56. package/build/utils/waveform-player.cjs.map +2 -2
  57. package/build/utils/waveform-utils.cjs +6 -4
  58. package/build/utils/waveform-utils.cjs.map +2 -2
  59. package/build/video/edit-common-settings.cjs +3 -6
  60. package/build/video/edit-common-settings.cjs.map +2 -2
  61. package/build-module/columns/transforms.mjs +65 -0
  62. package/build-module/columns/transforms.mjs.map +2 -2
  63. package/build-module/comments/edit/placeholder.mjs +1 -1
  64. package/build-module/comments/edit/placeholder.mjs.map +2 -2
  65. package/build-module/cover/edit/inspector-controls.mjs +16 -4
  66. package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
  67. package/build-module/gallery/edit.mjs +214 -334
  68. package/build-module/gallery/edit.mjs.map +2 -2
  69. package/build-module/gallery/transforms.mjs +43 -0
  70. package/build-module/gallery/transforms.mjs.map +2 -2
  71. package/build-module/heading/edit.mjs +1 -2
  72. package/build-module/heading/edit.mjs.map +2 -2
  73. package/build-module/image/image.mjs +15 -3
  74. package/build-module/image/image.mjs.map +2 -2
  75. package/build-module/image/use-open-image-media-editor-modal.mjs +8 -2
  76. package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
  77. package/build-module/list/edit.mjs +2 -9
  78. package/build-module/list/edit.mjs.map +2 -2
  79. package/build-module/list/ordered-list-settings.mjs +1 -45
  80. package/build-module/list/ordered-list-settings.mjs.map +2 -2
  81. package/build-module/list-item/hooks/use-merge.mjs +48 -25
  82. package/build-module/list-item/hooks/use-merge.mjs.map +2 -2
  83. package/build-module/navigation/edit/index.mjs +16 -33
  84. package/build-module/navigation/edit/index.mjs.map +2 -2
  85. package/build-module/navigation-link/edit.mjs +0 -1
  86. package/build-module/navigation-link/edit.mjs.map +2 -2
  87. package/build-module/navigation-submenu/edit.mjs +2 -1
  88. package/build-module/navigation-submenu/edit.mjs.map +2 -2
  89. package/build-module/paragraph/deprecated.mjs +1 -0
  90. package/build-module/paragraph/deprecated.mjs.map +2 -2
  91. package/build-module/paragraph/edit.mjs +12 -2
  92. package/build-module/paragraph/edit.mjs.map +2 -2
  93. package/build-module/playlist/block.json +12 -0
  94. package/build-module/playlist/edit.mjs +27 -1
  95. package/build-module/playlist/edit.mjs.map +2 -2
  96. package/build-module/playlist/save.mjs +8 -1
  97. package/build-module/playlist/save.mjs.map +2 -2
  98. package/build-module/playlist/view.mjs +1 -0
  99. package/build-module/playlist/view.mjs.map +2 -2
  100. package/build-module/post-featured-image/edit.mjs +6 -4
  101. package/build-module/post-featured-image/edit.mjs.map +2 -2
  102. package/build-module/post-time-to-read/index.mjs +1 -1
  103. package/build-module/post-time-to-read/index.mjs.map +2 -2
  104. package/build-module/post-time-to-read/variations.mjs +2 -2
  105. package/build-module/post-time-to-read/variations.mjs.map +2 -2
  106. package/build-module/pullquote/edit.mjs +2 -7
  107. package/build-module/pullquote/edit.mjs.map +2 -2
  108. package/build-module/quote/edit.mjs +5 -10
  109. package/build-module/quote/edit.mjs.map +2 -2
  110. package/build-module/shortcode/transforms.mjs +2 -2
  111. package/build-module/shortcode/transforms.mjs.map +2 -2
  112. package/build-module/site-logo/edit.mjs +5 -1
  113. package/build-module/site-logo/edit.mjs.map +2 -2
  114. package/build-module/utils/waveform-player.mjs +44 -11
  115. package/build-module/utils/waveform-player.mjs.map +2 -2
  116. package/build-module/utils/waveform-utils.mjs +6 -4
  117. package/build-module/utils/waveform-utils.mjs.map +2 -2
  118. package/build-module/video/edit-common-settings.mjs +4 -7
  119. package/build-module/video/edit-common-settings.mjs.map +2 -2
  120. package/build-style/comment-template/style-rtl.css +1 -0
  121. package/build-style/comment-template/style.css +1 -0
  122. package/build-style/common-rtl.css +30 -10
  123. package/build-style/common.css +30 -10
  124. package/build-style/cover/style-rtl.css +2 -1
  125. package/build-style/cover/style.css +2 -1
  126. package/build-style/editor-rtl.css +22 -11
  127. package/build-style/editor.css +22 -11
  128. package/build-style/form-input/style-rtl.css +2 -0
  129. package/build-style/form-input/style.css +2 -0
  130. package/build-style/gallery/style-rtl.css +4 -2
  131. package/build-style/gallery/style.css +4 -2
  132. package/build-style/media-text/style-rtl.css +2 -1
  133. package/build-style/media-text/style.css +2 -1
  134. package/build-style/playlist/style-rtl.css +3 -0
  135. package/build-style/playlist/style.css +3 -0
  136. package/build-style/query/editor-rtl.css +8 -4
  137. package/build-style/query/editor.css +8 -4
  138. package/build-style/read-more/style-rtl.css +1 -0
  139. package/build-style/read-more/style.css +1 -0
  140. package/build-style/reset-rtl.css +3 -1
  141. package/build-style/reset.css +3 -1
  142. package/build-style/search/style-rtl.css +3 -1
  143. package/build-style/search/style.css +3 -1
  144. package/build-style/site-logo/editor-rtl.css +2 -1
  145. package/build-style/site-logo/editor.css +2 -1
  146. package/build-style/style-rtl.css +53 -17
  147. package/build-style/style.css +53 -17
  148. package/build-style/tab/style-rtl.css +3 -1
  149. package/build-style/tab/style.css +3 -1
  150. package/build-style/template-part/editor-rtl.css +8 -4
  151. package/build-style/template-part/editor.css +8 -4
  152. package/build-style/video/style-rtl.css +2 -1
  153. package/build-style/video/style.css +2 -1
  154. package/package.json +51 -47
  155. package/src/accordion/README.md +97 -0
  156. package/src/accordion-heading/README.md +81 -0
  157. package/src/accordion-item/README.md +85 -0
  158. package/src/accordion-panel/README.md +74 -0
  159. package/src/archives/README.md +56 -0
  160. package/src/audio/README.md +55 -0
  161. package/src/avatar/README.md +74 -0
  162. package/src/block/README.md +56 -0
  163. package/src/breadcrumbs/README.md +67 -0
  164. package/src/button/README.md +93 -0
  165. package/src/buttons/README.md +80 -0
  166. package/src/calendar/README.md +51 -0
  167. package/src/categories/README.md +69 -0
  168. package/src/code/README.md +55 -0
  169. package/src/column/README.md +72 -0
  170. package/src/columns/README.md +90 -0
  171. package/src/columns/test/transforms.js +164 -0
  172. package/src/columns/transforms.js +74 -0
  173. package/src/comment-author-avatar/README.md +63 -0
  174. package/src/comment-author-name/README.md +67 -0
  175. package/src/comment-content/README.md +61 -0
  176. package/src/comment-date/README.md +67 -0
  177. package/src/comment-edit-link/README.md +67 -0
  178. package/src/comment-reply-link/README.md +63 -0
  179. package/src/comment-template/README.md +60 -0
  180. package/src/comments/README.md +88 -0
  181. package/src/comments/edit/placeholder.js +1 -1
  182. package/src/comments-pagination/README.md +77 -0
  183. package/src/comments-pagination-next/README.md +64 -0
  184. package/src/comments-pagination-numbers/README.md +64 -0
  185. package/src/comments-pagination-previous/README.md +64 -0
  186. package/src/comments-title/README.md +70 -0
  187. package/src/common.scss +63 -10
  188. package/src/cover/README.md +111 -0
  189. package/src/cover/edit/inspector-controls.js +61 -45
  190. package/src/cover/test/edit.js +38 -0
  191. package/src/details/README.md +65 -0
  192. package/src/embed/README.md +56 -0
  193. package/src/file/README.md +60 -0
  194. package/src/footnotes/README.md +64 -0
  195. package/src/form/README.md +90 -0
  196. package/src/form-input/README.md +74 -0
  197. package/src/form-submission-notification/README.md +50 -0
  198. package/src/form-submit-button/README.md +54 -0
  199. package/src/freeform/README.md +49 -0
  200. package/src/gallery/README.md +115 -0
  201. package/src/gallery/edit.js +213 -350
  202. package/src/gallery/test/transforms.js +155 -0
  203. package/src/gallery/transforms.js +47 -0
  204. package/src/group/README.md +80 -0
  205. package/src/heading/README.md +60 -0
  206. package/src/heading/edit.js +1 -2
  207. package/src/home-link/README.md +66 -0
  208. package/src/home-link/index.php +3 -15
  209. package/src/html/README.md +48 -0
  210. package/src/icon/README.md +63 -0
  211. package/src/image/README.md +102 -0
  212. package/src/image/image.js +50 -35
  213. package/src/image/index.php +4 -4
  214. package/src/image/test/use-open-image-media-editor-modal.js +41 -0
  215. package/src/image/use-open-image-media-editor-modal.js +7 -1
  216. package/src/latest-comments/README.md +57 -0
  217. package/src/latest-posts/README.md +71 -0
  218. package/src/list/README.md +70 -0
  219. package/src/list/edit.js +2 -9
  220. package/src/list/ordered-list-settings.js +46 -92
  221. package/src/list-item/README.md +71 -0
  222. package/src/list-item/hooks/use-merge.js +53 -46
  223. package/src/loginout/README.md +56 -0
  224. package/src/math/README.md +50 -0
  225. package/src/media-text/README.md +92 -0
  226. package/src/missing/README.md +55 -0
  227. package/src/more/README.md +49 -0
  228. package/src/navigation/README.md +115 -0
  229. package/src/navigation/edit/index.js +10 -30
  230. package/src/navigation-link/README.md +93 -0
  231. package/src/navigation-link/edit.js +0 -1
  232. package/src/navigation-link/index.php +1 -15
  233. package/src/navigation-link/test/__snapshots__/hooks.js.snap +45 -134
  234. package/src/navigation-overlay-close/README.md +48 -0
  235. package/src/navigation-submenu/README.md +84 -0
  236. package/src/navigation-submenu/edit.js +1 -0
  237. package/src/navigation-submenu/index.php +1 -17
  238. package/src/nextpage/README.md +50 -0
  239. package/src/page-list/README.md +84 -0
  240. package/src/page-list/index.php +3 -15
  241. package/src/page-list-item/README.md +77 -0
  242. package/src/paragraph/README.md +70 -0
  243. package/src/paragraph/deprecated.js +1 -0
  244. package/src/paragraph/edit.js +13 -1
  245. package/src/pattern/README.md +45 -0
  246. package/src/playlist/README.md +86 -0
  247. package/src/playlist/block.json +12 -0
  248. package/src/playlist/edit.js +27 -0
  249. package/src/playlist/index.php +10 -3
  250. package/src/playlist/save.js +9 -1
  251. package/src/playlist/style.scss +7 -0
  252. package/src/playlist/view.js +1 -0
  253. package/src/playlist-track/README.md +69 -0
  254. package/src/post-author/README.md +78 -0
  255. package/src/post-author-biography/README.md +59 -0
  256. package/src/post-author-name/README.md +63 -0
  257. package/src/post-author-name/index.php +1 -1
  258. package/src/post-comment/README.md +61 -0
  259. package/src/post-comments-count/README.md +58 -0
  260. package/src/post-comments-form/README.md +59 -0
  261. package/src/post-comments-link/README.md +60 -0
  262. package/src/post-content/README.md +71 -0
  263. package/src/post-date/README.md +65 -0
  264. package/src/post-date/index.php +1 -1
  265. package/src/post-excerpt/README.md +66 -0
  266. package/src/post-featured-image/README.md +85 -0
  267. package/src/post-featured-image/edit.js +15 -10
  268. package/src/post-featured-image/index.php +1 -1
  269. package/src/post-navigation-link/README.md +63 -0
  270. package/src/post-template/README.md +71 -0
  271. package/src/post-terms/README.md +65 -0
  272. package/src/post-time-to-read/README.md +63 -0
  273. package/src/post-time-to-read/index.js +1 -1
  274. package/src/post-time-to-read/variations.js +2 -2
  275. package/src/post-title/README.md +69 -0
  276. package/src/preformatted/README.md +50 -0
  277. package/src/pullquote/README.md +64 -0
  278. package/src/pullquote/edit.js +1 -7
  279. package/src/query/README.md +64 -0
  280. package/src/query-no-results/README.md +65 -0
  281. package/src/query-pagination/README.md +79 -0
  282. package/src/query-pagination-next/README.md +67 -0
  283. package/src/query-pagination-numbers/README.md +65 -0
  284. package/src/query-pagination-previous/README.md +67 -0
  285. package/src/query-title/README.md +65 -0
  286. package/src/query-total/README.md +66 -0
  287. package/src/quote/README.md +75 -0
  288. package/src/quote/edit.js +3 -9
  289. package/src/read-more/README.md +61 -0
  290. package/src/read-more/index.php +2 -2
  291. package/src/rss/README.md +62 -0
  292. package/src/search/README.md +66 -0
  293. package/src/separator/README.md +62 -0
  294. package/src/shortcode/README.md +44 -0
  295. package/src/shortcode/transforms.js +2 -2
  296. package/src/site-logo/README.md +72 -0
  297. package/src/site-logo/edit.js +5 -0
  298. package/src/site-tagline/README.md +56 -0
  299. package/src/site-title/README.md +57 -0
  300. package/src/social-link/README.md +64 -0
  301. package/src/social-links/README.md +98 -0
  302. package/src/spacer/README.md +53 -0
  303. package/src/tab/README.md +69 -0
  304. package/src/tab-list/README.md +79 -0
  305. package/src/tab-panel/README.md +75 -0
  306. package/src/tab-panels/README.md +75 -0
  307. package/src/table/README.md +71 -0
  308. package/src/table-of-contents/README.md +61 -0
  309. package/src/tabs/README.md +83 -0
  310. package/src/tag-cloud/README.md +62 -0
  311. package/src/template-part/README.md +48 -0
  312. package/src/term-count/README.md +59 -0
  313. package/src/term-description/README.md +60 -0
  314. package/src/term-name/README.md +65 -0
  315. package/src/term-template/README.md +65 -0
  316. package/src/terms-query/README.md +58 -0
  317. package/src/text-columns/README.md +51 -0
  318. package/src/utils/test/waveform-player.js +254 -0
  319. package/src/utils/waveform-player.js +90 -18
  320. package/src/utils/waveform-utils.js +15 -11
  321. package/src/verse/README.md +58 -0
  322. package/src/video/README.md +58 -0
  323. package/src/video/edit-common-settings.js +4 -7
  324. package/src/audio/edit.native.js +0 -250
  325. package/src/audio/style.native.scss +0 -13
  326. package/src/audio/test/__snapshots__/edit.native.js.snap +0 -546
  327. package/src/audio/test/__snapshots__/transforms.native.js.snap +0 -25
  328. package/src/audio/test/edit.native.js +0 -132
  329. package/src/audio/test/transforms.native.js +0 -43
  330. package/src/audio/transforms.native.js +0 -12
  331. package/src/block/edit-title.native.js +0 -67
  332. package/src/block/edit.native.js +0 -247
  333. package/src/block/editor.native.scss +0 -125
  334. package/src/block/test/__snapshots__/transforms.native.js.snap +0 -15
  335. package/src/block/test/edit.native.js +0 -262
  336. package/src/block/test/transforms.native.js +0 -40
  337. package/src/button/color-background.native.js +0 -41
  338. package/src/button/edit.native.js +0 -567
  339. package/src/button/editor.native.scss +0 -70
  340. package/src/button/rich-text.android.scss +0 -6
  341. package/src/button/rich-text.ios.scss +0 -6
  342. package/src/buttons/edit.native.js +0 -157
  343. package/src/buttons/editor.native.scss +0 -11
  344. package/src/buttons/test/__snapshots__/edit.native.js.snap +0 -99
  345. package/src/buttons/test/__snapshots__/transforms.native.js.snap +0 -31
  346. package/src/buttons/test/edit.native.js +0 -485
  347. package/src/buttons/test/transforms.native.js +0 -48
  348. package/src/buttons/transforms.native.js +0 -12
  349. package/src/code/edit.native.js +0 -70
  350. package/src/code/test/__snapshots__/edit.native.js.snap +0 -13
  351. package/src/code/test/edit.native.js +0 -65
  352. package/src/code/theme.native.scss +0 -22
  353. package/src/code/transforms.native.js +0 -12
  354. package/src/column/column-preview.native.js +0 -58
  355. package/src/column/edit.native.js +0 -273
  356. package/src/column/editor.native.scss +0 -75
  357. package/src/columns/columnCalculations.native.js +0 -178
  358. package/src/columns/edit.native.js +0 -507
  359. package/src/columns/editor.native.scss +0 -17
  360. package/src/columns/test/__snapshots__/edit.native.js.snap +0 -305
  361. package/src/columns/test/__snapshots__/transforms.native.js.snap +0 -61
  362. package/src/columns/test/edit.native.js +0 -496
  363. package/src/columns/test/transforms.native.js +0 -89
  364. package/src/columns/transforms.native.js +0 -12
  365. package/src/cover/controls.native.js +0 -307
  366. package/src/cover/edit.native.js +0 -708
  367. package/src/cover/focal-point-settings-button.native.js +0 -53
  368. package/src/cover/overlay-color-settings.native.js +0 -106
  369. package/src/cover/style.native.scss +0 -220
  370. package/src/cover/test/__snapshots__/edit.native.js.snap +0 -105
  371. package/src/cover/test/__snapshots__/transforms.native.js.snap +0 -73
  372. package/src/cover/test/edit.native.js +0 -701
  373. package/src/cover/test/transforms.native.js +0 -116
  374. package/src/cover/transforms.native.js +0 -12
  375. package/src/cover/use-cover-is-dark.native.js +0 -51
  376. package/src/embed/edit.native.js +0 -345
  377. package/src/embed/embed-controls.native.js +0 -65
  378. package/src/embed/embed-link-settings.native.js +0 -99
  379. package/src/embed/embed-loading.native.js +0 -29
  380. package/src/embed/embed-no-preview.native.js +0 -230
  381. package/src/embed/embed-placeholder.native.js +0 -178
  382. package/src/embed/embed-preview.native.js +0 -157
  383. package/src/embed/styles.native.scss +0 -196
  384. package/src/embed/test/__snapshots__/index.native.js.snap +0 -191
  385. package/src/embed/test/__snapshots__/transforms.native.js.snap +0 -23
  386. package/src/embed/test/index.native.js +0 -1125
  387. package/src/embed/test/transforms.native.js +0 -44
  388. package/src/embed/transforms.native.js +0 -12
  389. package/src/embed/wp-embed-preview.native.js +0 -80
  390. package/src/file/edit.native.js +0 -605
  391. package/src/file/style.native.scss +0 -79
  392. package/src/file/test/__snapshots__/edit.native.js.snap +0 -580
  393. package/src/file/test/__snapshots__/transforms.native.js.snap +0 -19
  394. package/src/file/test/edit.native.js +0 -93
  395. package/src/file/test/transforms.native.js +0 -43
  396. package/src/file/transforms.native.js +0 -12
  397. package/src/freeform/edit.native.js +0 -13
  398. package/src/freeform/test/__snapshots__/index.native.js.snap +0 -7
  399. package/src/freeform/test/__snapshots__/transforms.native.js.snap +0 -19
  400. package/src/freeform/test/index.native.js +0 -57
  401. package/src/freeform/test/transforms.native.js +0 -39
  402. package/src/gallery/gallery-styles.native.scss +0 -8
  403. package/src/gallery/gallery.native.js +0 -124
  404. package/src/gallery/styles.native.scss +0 -7
  405. package/src/gallery/test/__snapshots__/index.native.js.snap +0 -177
  406. package/src/gallery/test/__snapshots__/transforms.native.js.snap +0 -53
  407. package/src/gallery/test/helpers.native.js +0 -106
  408. package/src/gallery/test/index.native.js +0 -700
  409. package/src/gallery/test/transforms.native.js +0 -53
  410. package/src/gallery/test/use-get-media.native.js +0 -24
  411. package/src/gallery/transforms.native.js +0 -12
  412. package/src/gallery/use-get-media.native.js +0 -49
  413. package/src/group/edit.native.js +0 -137
  414. package/src/group/editor.native.scss +0 -56
  415. package/src/group/test/__snapshots__/edit.native.js.snap +0 -19
  416. package/src/group/test/__snapshots__/transforms.native.js.snap +0 -35
  417. package/src/group/test/edit.native.js +0 -100
  418. package/src/group/test/transforms.native.js +0 -73
  419. package/src/heading/edit.native.js +0 -159
  420. package/src/heading/test/__snapshots__/index.native.js.snap +0 -43
  421. package/src/heading/test/__snapshots__/transforms.native.js.snap +0 -47
  422. package/src/heading/test/index.native.js +0 -257
  423. package/src/heading/test/transforms.native.js +0 -46
  424. package/src/heading/transforms.native.js +0 -12
  425. package/src/html/transforms.native.js +0 -11
  426. package/src/image/edit.native.js +0 -959
  427. package/src/image/styles.native.scss +0 -70
  428. package/src/image/test/__snapshots__/transforms.native.js.snap +0 -49
  429. package/src/image/test/edit.native.js +0 -459
  430. package/src/image/test/transforms.native.js +0 -49
  431. package/src/image/transforms.native.js +0 -12
  432. package/src/index.native.js +0 -274
  433. package/src/latest-posts/edit.native.js +0 -294
  434. package/src/latest-posts/style.native.scss +0 -47
  435. package/src/latest-posts/test/__snapshots__/edit.native.js.snap +0 -3
  436. package/src/latest-posts/test/__snapshots__/transforms.native.js.snap +0 -15
  437. package/src/latest-posts/test/edit.native.js +0 -49
  438. package/src/latest-posts/test/transforms.native.js +0 -61
  439. package/src/list/tag-name.native.js +0 -12
  440. package/src/list/test/__snapshots__/edit.native.js.snap +0 -121
  441. package/src/list/test/__snapshots__/transforms.native.js.snap +0 -85
  442. package/src/list/test/edit.native.js +0 -602
  443. package/src/list/test/transforms.native.js +0 -56
  444. package/src/list/transforms.native.js +0 -12
  445. package/src/list-item/edit.native.js +0 -175
  446. package/src/list-item/hooks/use-enter.native.js +0 -81
  447. package/src/list-item/icons.native.js +0 -34
  448. package/src/list-item/list-style-type.native.js +0 -146
  449. package/src/list-item/style.native.scss +0 -57
  450. package/src/media-text/edit.native.js +0 -417
  451. package/src/media-text/icon-retry.native.js +0 -11
  452. package/src/media-text/media-container.native.js +0 -393
  453. package/src/media-text/style.native.scss +0 -191
  454. package/src/media-text/test/__snapshots__/transforms.native.js.snap +0 -73
  455. package/src/media-text/test/edit.native.js +0 -58
  456. package/src/media-text/test/transforms.native.js +0 -116
  457. package/src/media-text/transforms.native.js +0 -12
  458. package/src/missing/edit.native.js +0 -294
  459. package/src/missing/style.native.scss +0 -79
  460. package/src/missing/test/__snapshots__/edit.native.js.snap +0 -110
  461. package/src/missing/test/edit-integration.native.js +0 -168
  462. package/src/missing/test/edit.native.js +0 -81
  463. package/src/more/edit.native.js +0 -36
  464. package/src/more/editor.native.scss +0 -21
  465. package/src/more/test/__snapshots__/edit.native.js.snap +0 -7
  466. package/src/more/test/__snapshots__/transforms.native.js.snap +0 -19
  467. package/src/more/test/edit.native.js +0 -41
  468. package/src/more/test/transforms.native.js +0 -42
  469. package/src/more/transforms.native.js +0 -12
  470. package/src/navigation-link/shared/build-css-font-sizes.php +0 -43
  471. package/src/nextpage/edit.native.js +0 -58
  472. package/src/nextpage/editor.native.scss +0 -21
  473. package/src/nextpage/test/__snapshots__/transforms.native.js.snap +0 -19
  474. package/src/nextpage/test/transforms.native.js +0 -42
  475. package/src/nextpage/transforms.native.js +0 -12
  476. package/src/paragraph/edit.native.js +0 -116
  477. package/src/paragraph/test/__snapshots__/edit.native.js.snap +0 -88
  478. package/src/paragraph/test/__snapshots__/transforms.native.js.snap +0 -65
  479. package/src/paragraph/test/edit.native.js +0 -999
  480. package/src/paragraph/test/transforms.native.js +0 -51
  481. package/src/paragraph/transforms.native.js +0 -12
  482. package/src/preformatted/edit.native.js +0 -48
  483. package/src/preformatted/styles.native.scss +0 -30
  484. package/src/preformatted/test/__snapshots__/edit.native.js.snap +0 -95
  485. package/src/preformatted/test/__snapshots__/transforms.native.js.snap +0 -37
  486. package/src/preformatted/test/edit.native.js +0 -111
  487. package/src/preformatted/test/transforms.native.js +0 -47
  488. package/src/preformatted/transforms.native.js +0 -12
  489. package/src/pullquote/blockquote.native.js +0 -39
  490. package/src/pullquote/blockquote.native.scss +0 -8
  491. package/src/pullquote/edit.native.js +0 -128
  492. package/src/pullquote/figure.native.js +0 -33
  493. package/src/pullquote/figure.native.scss +0 -16
  494. package/src/pullquote/test/__snapshots__/transforms.native.js.snap +0 -47
  495. package/src/pullquote/test/edit.native.js +0 -73
  496. package/src/pullquote/test/transforms.native.js +0 -46
  497. package/src/pullquote/transforms.native.js +0 -12
  498. package/src/quote/test/__snapshots__/transforms.native.js.snap +0 -49
  499. package/src/quote/test/edit.native.js +0 -94
  500. package/src/quote/test/transforms.native.js +0 -69
  501. package/src/quote/transforms.native.js +0 -12
  502. package/src/search/edit.native.js +0 -486
  503. package/src/search/style.native.scss +0 -99
  504. package/src/search/test/__snapshots__/edit.native.js.snap +0 -827
  505. package/src/search/test/__snapshots__/transforms.native.js.snap +0 -15
  506. package/src/search/test/edit.native.js +0 -170
  507. package/src/search/test/transforms.native.js +0 -40
  508. package/src/separator/separator-settings.native.js +0 -3
  509. package/src/separator/test/__snapshots__/edit.native.js.snap +0 -7
  510. package/src/separator/test/__snapshots__/transforms.native.js.snap +0 -25
  511. package/src/separator/test/edit.native.js +0 -41
  512. package/src/separator/test/transforms.native.js +0 -42
  513. package/src/separator/transforms.native.js +0 -12
  514. package/src/shortcode/edit.native.js +0 -77
  515. package/src/shortcode/style.native.scss +0 -44
  516. package/src/shortcode/test/__snapshots__/edit.native.js.snap +0 -9
  517. package/src/shortcode/test/__snapshots__/transforms.native.js.snap +0 -19
  518. package/src/shortcode/test/edit.native.js +0 -70
  519. package/src/shortcode/test/transforms.native.js +0 -42
  520. package/src/shortcode/transforms.native.js +0 -12
  521. package/src/social-link/edit.native.js +0 -219
  522. package/src/social-link/editor.native.scss +0 -18
  523. package/src/social-links/edit.native.js +0 -147
  524. package/src/social-links/editor.native.scss +0 -25
  525. package/src/social-links/test/__snapshots__/edit.native.js.snap +0 -57
  526. package/src/social-links/test/__snapshots__/transforms.native.js.snap +0 -31
  527. package/src/social-links/test/edit.native.js +0 -266
  528. package/src/social-links/test/transforms.native.js +0 -53
  529. package/src/spacer/controls.native.js +0 -86
  530. package/src/spacer/edit.native.js +0 -110
  531. package/src/spacer/editor.native.scss +0 -18
  532. package/src/spacer/save.native.js +0 -18
  533. package/src/spacer/test/__snapshots__/index.native.js.snap +0 -43
  534. package/src/spacer/test/__snapshots__/transforms.native.js.snap +0 -25
  535. package/src/spacer/test/index.native.js +0 -257
  536. package/src/spacer/test/transforms.native.js +0 -42
  537. package/src/table/transforms.native.js +0 -11
  538. package/src/text-columns/transforms.native.js +0 -12
  539. package/src/utils/init-block.native.js +0 -40
  540. package/src/utils/transformation-categories.native.js +0 -47
  541. package/src/verse/test/__snapshots__/edit.native.js.snap +0 -13
  542. package/src/verse/test/__snapshots__/transforms.native.js.snap +0 -31
  543. package/src/verse/test/edit.native.js +0 -118
  544. package/src/verse/test/transforms.native.js +0 -46
  545. package/src/verse/transforms.native.js +0 -12
  546. package/src/video/edit.native.js +0 -406
  547. package/src/video/icon-retry.native.js +0 -11
  548. package/src/video/style.native.scss +0 -81
  549. package/src/video/test/__snapshots__/transforms.native.js.snap +0 -41
  550. package/src/video/test/edit.native.js +0 -53
  551. package/src/video/test/transforms.native.js +0 -49
  552. package/src/video/transforms.native.js +0 -12
@@ -1,959 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import {
5
- ActivityIndicator,
6
- Image as RNImage,
7
- TouchableWithoutFeedback,
8
- View,
9
- } from 'react-native';
10
- import { useRoute } from '@react-navigation/native';
11
-
12
- /**
13
- * WordPress dependencies
14
- */
15
- import { Component, useEffect } from '@wordpress/element';
16
- import {
17
- requestMediaImport,
18
- mediaUploadSync,
19
- requestImageFailedRetryDialog,
20
- requestImageUploadCancelDialog,
21
- requestImageFullscreenPreview,
22
- setFeaturedImage,
23
- } from '@wordpress/react-native-bridge';
24
- import {
25
- Icon as WCIcon,
26
- PanelBody,
27
- ToolbarButton,
28
- ToolbarGroup,
29
- Image,
30
- WIDE_ALIGNMENTS,
31
- LinkSettingsNavigation,
32
- BottomSheet,
33
- BottomSheetTextControl,
34
- BottomSheetSelectControl,
35
- FooterMessageControl,
36
- FooterMessageLink,
37
- WCBadge,
38
- } from '@wordpress/components';
39
- import {
40
- BlockCaption,
41
- MediaPlaceholder,
42
- MediaUpload,
43
- MediaUploadProgress,
44
- MEDIA_TYPE_IMAGE,
45
- BlockControls,
46
- InspectorControls,
47
- BlockStyles,
48
- store as blockEditorStore,
49
- blockSettingsScreens,
50
- RichText,
51
- } from '@wordpress/block-editor';
52
- import { __, _x, sprintf } from '@wordpress/i18n';
53
- import { getProtocol, hasQueryArg, isURL } from '@wordpress/url';
54
- import { doAction, hasAction } from '@wordpress/hooks';
55
- import { compose, withPreferredColorScheme } from '@wordpress/compose';
56
- import { withSelect, withDispatch } from '@wordpress/data';
57
- import {
58
- image as placeholderIcon,
59
- replace,
60
- fullscreen,
61
- textColor,
62
- } from '@wordpress/icons';
63
- import { store as coreStore } from '@wordpress/core-data';
64
- import { store as noticesStore } from '@wordpress/notices';
65
- // eslint-disable-next-line no-restricted-imports
66
- import { store as editPostStore } from '@wordpress/edit-post';
67
-
68
- /**
69
- * Internal dependencies
70
- */
71
- import styles from './styles.scss';
72
- import { getUpdatedLinkTargetSettings } from './utils';
73
-
74
- import {
75
- LINK_DESTINATION_NONE,
76
- LINK_DESTINATION_CUSTOM,
77
- LINK_DESTINATION_ATTACHMENT,
78
- LINK_DESTINATION_MEDIA,
79
- MEDIA_ID_NO_FEATURED_IMAGE_SET,
80
- } from './constants';
81
-
82
- const getUrlForSlug = ( image, sizeSlug ) => {
83
- if ( ! sizeSlug ) {
84
- return undefined;
85
- }
86
- return image?.media_details?.sizes?.[ sizeSlug ]?.source_url;
87
- };
88
-
89
- function LinkSettings( {
90
- attributes,
91
- image,
92
- isLinkSheetVisible,
93
- setMappedAttributes,
94
- } ) {
95
- const route = useRoute();
96
- const { href: url, label, linkDestination, linkTarget, rel } = attributes;
97
-
98
- // Persist attributes passed from child screen.
99
- useEffect( () => {
100
- const { inputValue: newUrl } = route.params || {};
101
-
102
- let newLinkDestination;
103
- switch ( newUrl ) {
104
- case attributes.url:
105
- newLinkDestination = LINK_DESTINATION_MEDIA;
106
- break;
107
- case image?.link:
108
- newLinkDestination = LINK_DESTINATION_ATTACHMENT;
109
- break;
110
- case '':
111
- newLinkDestination = LINK_DESTINATION_NONE;
112
- break;
113
- default:
114
- newLinkDestination = LINK_DESTINATION_CUSTOM;
115
- break;
116
- }
117
-
118
- setMappedAttributes( {
119
- url: newUrl,
120
- linkDestination: newLinkDestination,
121
- } );
122
- }, [ route.params?.inputValue ] );
123
-
124
- let valueMask;
125
- switch ( linkDestination ) {
126
- case LINK_DESTINATION_MEDIA:
127
- valueMask = __( 'Media File' );
128
- break;
129
- case LINK_DESTINATION_ATTACHMENT:
130
- valueMask = __( 'Attachment Page' );
131
- break;
132
- case LINK_DESTINATION_CUSTOM:
133
- valueMask = __( 'Custom URL' );
134
- break;
135
- default:
136
- valueMask = __( 'None' );
137
- break;
138
- }
139
-
140
- const linkSettingsOptions = {
141
- url: {
142
- valueMask,
143
- autoFocus: false,
144
- autoFill: false,
145
- },
146
- openInNewTab: {
147
- label: __( 'Open in new tab' ),
148
- },
149
- linkRel: {
150
- label: __( 'Link relation' ),
151
- placeholder: _x( 'None', 'Link rel attribute value placeholder' ),
152
- },
153
- };
154
-
155
- return (
156
- <PanelBody title={ __( 'Link Settings' ) }>
157
- <LinkSettingsNavigation
158
- isVisible={ isLinkSheetVisible }
159
- url={ url }
160
- rel={ rel }
161
- label={ label }
162
- linkTarget={ linkTarget }
163
- setAttributes={ setMappedAttributes }
164
- withBottomSheet={ false }
165
- hasPicker
166
- options={ linkSettingsOptions }
167
- showIcon={ false }
168
- onLinkCellPressed={ ( { navigation } ) => {
169
- navigation.navigate(
170
- blockSettingsScreens.imageLinkDestinations,
171
- {
172
- inputValue: attributes.href,
173
- linkDestination: attributes.linkDestination,
174
- imageUrl: attributes.url,
175
- attachmentPageUrl: image?.link,
176
- }
177
- );
178
- } }
179
- />
180
- </PanelBody>
181
- );
182
- }
183
-
184
- const UPLOAD_STATE_IDLE = 0;
185
- const UPLOAD_STATE_UPLOADING = 1;
186
- const UPLOAD_STATE_SUCCEEDED = 2;
187
- const UPLOAD_STATE_FAILED = 3;
188
-
189
- export class ImageEdit extends Component {
190
- constructor( props ) {
191
- super( props );
192
-
193
- this.state = {
194
- isCaptionSelected: false,
195
- uploadStatus: UPLOAD_STATE_IDLE,
196
- };
197
-
198
- this.replacedFeaturedImage = false;
199
-
200
- this.finishMediaUploadWithSuccess =
201
- this.finishMediaUploadWithSuccess.bind( this );
202
- this.finishMediaUploadWithFailure =
203
- this.finishMediaUploadWithFailure.bind( this );
204
- this.mediaUploadStateReset = this.mediaUploadStateReset.bind( this );
205
- this.onSelectMediaUploadOption =
206
- this.onSelectMediaUploadOption.bind( this );
207
- this.updateMediaProgress = this.updateMediaProgress.bind( this );
208
- this.updateImageURL = this.updateImageURL.bind( this );
209
- this.onSetNewTab = this.onSetNewTab.bind( this );
210
- this.onSetSizeSlug = this.onSetSizeSlug.bind( this );
211
- this.onImagePressed = this.onImagePressed.bind( this );
212
- this.onSetFeatured = this.onSetFeatured.bind( this );
213
- this.onFocusCaption = this.onFocusCaption.bind( this );
214
- this.onSelectURL = this.onSelectURL.bind( this );
215
- this.accessibilityLabelCreator =
216
- this.accessibilityLabelCreator.bind( this );
217
- this.setMappedAttributes = this.setMappedAttributes.bind( this );
218
- this.onSizeChangeValue = this.onSizeChangeValue.bind( this );
219
- }
220
-
221
- componentDidMount() {
222
- const { attributes, setAttributes } = this.props;
223
- // This will warn when we have `id` defined, while `url` is undefined.
224
- // This may help track this issue: https://github.com/wordpress-mobile/WordPress-Android/issues/9768
225
- // where a cancelled image upload was resulting in a subsequent crash.
226
- if ( attributes.id && ! attributes.url ) {
227
- // eslint-disable-next-line no-console
228
- console.warn( 'Attributes has id with no url.' );
229
- }
230
-
231
- // Detect any pasted image and start an upload.
232
- if (
233
- ! attributes.id &&
234
- attributes.url &&
235
- getProtocol( attributes.url ) === 'file:'
236
- ) {
237
- requestMediaImport( attributes.url, ( id, url ) => {
238
- if ( url ) {
239
- setAttributes( { id, url } );
240
- }
241
- } );
242
- }
243
-
244
- // Make sure we mark any temporary images as failed if they failed while
245
- // the editor wasn't open.
246
- if (
247
- attributes.id &&
248
- attributes.url &&
249
- getProtocol( attributes.url ) === 'file:'
250
- ) {
251
- mediaUploadSync();
252
- }
253
- }
254
-
255
- componentWillUnmount() {
256
- // This action will only exist if the user pressed the trash button on the block holder.
257
- if (
258
- hasAction( 'blocks.onRemoveBlockCheckUpload' ) &&
259
- this.state.uploadStatus === UPLOAD_STATE_UPLOADING
260
- ) {
261
- doAction(
262
- 'blocks.onRemoveBlockCheckUpload',
263
- this.props.attributes.id
264
- );
265
- }
266
- }
267
-
268
- componentDidUpdate( previousProps ) {
269
- const { image, attributes, setAttributes, featuredImageId } =
270
- this.props;
271
- const { url } = attributes;
272
- if ( ! previousProps.image && image ) {
273
- if ( ! hasQueryArg( url, 'w' ) && attributes?.sizeSlug ) {
274
- const updatedUrl =
275
- getUrlForSlug( image, attributes.sizeSlug ) ||
276
- image.source_url;
277
-
278
- setAttributes( { url: updatedUrl } );
279
- }
280
- }
281
-
282
- const { id } = attributes;
283
- const { id: previousId } = previousProps.attributes;
284
-
285
- // The media changed and the previous media was set as the Featured Image,
286
- // we must keep track of the previous media's featured status to act on it
287
- // once the new media has a finalized ID.
288
- if (
289
- !! id &&
290
- id !== previousId &&
291
- !! featuredImageId &&
292
- featuredImageId === previousId
293
- ) {
294
- this.replacedFeaturedImage = true;
295
- }
296
-
297
- // The media changed and now has a finalized ID (e.g. upload completed), we
298
- // should attempt to replace the featured image if applicable.
299
- if (
300
- this.replacedFeaturedImage &&
301
- !! image &&
302
- this.canImageBeFeatured()
303
- ) {
304
- this.replacedFeaturedImage = false;
305
- setFeaturedImage( id );
306
- }
307
-
308
- const { align } = attributes;
309
- const { __unstableMarkNextChangeAsNotPersistent } = this.props;
310
-
311
- // Update the attributes if the align is wide or full
312
- if ( [ 'wide', 'full' ].includes( align ) ) {
313
- __unstableMarkNextChangeAsNotPersistent();
314
- setAttributes( {
315
- width: undefined,
316
- height: undefined,
317
- aspectRatio: undefined,
318
- scale: undefined,
319
- } );
320
- }
321
- }
322
-
323
- static getDerivedStateFromProps( props, state ) {
324
- // Avoid a UI flicker in the toolbar by insuring that isCaptionSelected
325
- // is updated immediately any time the isSelected prop becomes false.
326
- return {
327
- isCaptionSelected: props.isSelected && state.isCaptionSelected,
328
- };
329
- }
330
-
331
- accessibilityLabelCreator( caption ) {
332
- // Checks if caption is empty.
333
- return RichText.isEmpty( caption )
334
- ? /* translators: accessibility text. Empty image caption. */
335
- 'Image caption. Empty'
336
- : sprintf(
337
- /* translators: accessibility text. %s: image caption. */
338
- __( 'Image caption. %s' ),
339
- caption
340
- );
341
- }
342
-
343
- onImagePressed() {
344
- const { attributes, image } = this.props;
345
-
346
- if ( this.state.uploadStatus === UPLOAD_STATE_UPLOADING ) {
347
- requestImageUploadCancelDialog( attributes.id );
348
- } else if (
349
- attributes.id &&
350
- getProtocol( attributes.url ) === 'file:'
351
- ) {
352
- requestImageFailedRetryDialog( attributes.id );
353
- } else if ( ! this.state.isCaptionSelected ) {
354
- requestImageFullscreenPreview(
355
- attributes.url,
356
- image && image.source_url
357
- );
358
- }
359
-
360
- this.setState( {
361
- isCaptionSelected: false,
362
- } );
363
- }
364
-
365
- updateMediaProgress( payload ) {
366
- const { setAttributes } = this.props;
367
- if ( payload.mediaUrl ) {
368
- setAttributes( { url: payload.mediaUrl } );
369
- }
370
-
371
- if ( this.state.uploadStatus !== UPLOAD_STATE_UPLOADING ) {
372
- this.setState( { uploadStatus: UPLOAD_STATE_UPLOADING } );
373
- }
374
- }
375
-
376
- finishMediaUploadWithSuccess( payload ) {
377
- const { setAttributes } = this.props;
378
-
379
- setAttributes( { url: payload.mediaUrl, id: payload.mediaServerId } );
380
- this.setState( { uploadStatus: UPLOAD_STATE_SUCCEEDED } );
381
- }
382
-
383
- finishMediaUploadWithFailure( payload ) {
384
- const { setAttributes } = this.props;
385
-
386
- setAttributes( { id: payload.mediaId } );
387
- this.setState( { uploadStatus: UPLOAD_STATE_FAILED } );
388
- }
389
-
390
- mediaUploadStateReset() {
391
- const { setAttributes } = this.props;
392
-
393
- setAttributes( { id: null, url: null } );
394
- this.setState( { uploadStatus: UPLOAD_STATE_IDLE } );
395
- }
396
-
397
- updateImageURL( url ) {
398
- this.props.setAttributes( {
399
- url,
400
- width: undefined,
401
- height: undefined,
402
- } );
403
- }
404
-
405
- onSetNewTab( value ) {
406
- const updatedLinkTarget = getUpdatedLinkTargetSettings(
407
- value,
408
- this.props.attributes
409
- );
410
- this.props.setAttributes( updatedLinkTarget );
411
- }
412
-
413
- onSetSizeSlug( sizeSlug ) {
414
- const { image, setAttributes } = this.props;
415
-
416
- const url = getUrlForSlug( image, sizeSlug );
417
- if ( ! url ) {
418
- return null;
419
- }
420
- setAttributes( {
421
- url,
422
- width: undefined,
423
- height: undefined,
424
- sizeSlug,
425
- } );
426
- }
427
-
428
- onSelectMediaUploadOption( media ) {
429
- const { imageDefaultSize } = this.props;
430
- const { id, url, destination } = this.props.attributes;
431
- const mediaAttributes = {
432
- id: media.id,
433
- url: media.url,
434
- caption: media.caption,
435
- alt: media.alt,
436
- };
437
-
438
- let additionalAttributes;
439
- // Reset the dimension attributes if changing to a different image.
440
- if ( ! media.id || media.id !== id ) {
441
- additionalAttributes = {
442
- width: undefined,
443
- height: undefined,
444
- sizeSlug: imageDefaultSize,
445
- };
446
- } else {
447
- // Keep the same url when selecting the same file, so "Image Size" option is not changed.
448
- additionalAttributes = { url };
449
- }
450
-
451
- let href;
452
- switch ( destination ) {
453
- case LINK_DESTINATION_MEDIA:
454
- href = media.url;
455
- break;
456
- case LINK_DESTINATION_ATTACHMENT:
457
- href = media.link;
458
- break;
459
- }
460
- mediaAttributes.href = href;
461
-
462
- this.props.setAttributes( {
463
- ...mediaAttributes,
464
- ...additionalAttributes,
465
- } );
466
- }
467
-
468
- onSelectURL( newURL ) {
469
- const { createErrorNotice, imageDefaultSize, setAttributes } =
470
- this.props;
471
-
472
- if ( isURL( newURL ) ) {
473
- this.setState( {
474
- isFetchingImage: true,
475
- } );
476
-
477
- // Use RN's Image.getSize to determine if URL is a valid image
478
- RNImage.getSize(
479
- newURL,
480
- () => {
481
- setAttributes( {
482
- url: newURL,
483
- id: undefined,
484
- width: undefined,
485
- height: undefined,
486
- sizeSlug: imageDefaultSize,
487
- } );
488
- this.setState( {
489
- isFetchingImage: false,
490
- } );
491
- },
492
- () => {
493
- createErrorNotice( __( 'Image file not found.' ) );
494
- this.setState( {
495
- isFetchingImage: false,
496
- } );
497
- }
498
- );
499
- } else {
500
- createErrorNotice( __( 'Invalid URL.' ) );
501
- }
502
- }
503
-
504
- onFocusCaption() {
505
- if ( this.props.onFocus ) {
506
- this.props.onFocus();
507
- }
508
- if ( ! this.state.isCaptionSelected ) {
509
- this.setState( {
510
- isCaptionSelected: true,
511
- } );
512
- }
513
- }
514
-
515
- getPlaceholderIcon() {
516
- return (
517
- <WCIcon
518
- icon={ placeholderIcon }
519
- { ...this.props.getStylesFromColorScheme(
520
- styles.iconPlaceholder,
521
- styles.iconPlaceholderDark
522
- ) }
523
- />
524
- );
525
- }
526
-
527
- showLoadingIndicator() {
528
- return (
529
- <View style={ styles.image__loading }>
530
- <ActivityIndicator animating />
531
- </View>
532
- );
533
- }
534
-
535
- getWidth() {
536
- const { attributes } = this.props;
537
- const { align, width } = attributes;
538
-
539
- return Object.values( WIDE_ALIGNMENTS.alignments ).includes( align )
540
- ? '100%'
541
- : width;
542
- }
543
-
544
- setMappedAttributes( { url: href, linkDestination, ...restAttributes } ) {
545
- const { setAttributes } = this.props;
546
- if ( ! href && ! linkDestination ) {
547
- linkDestination = LINK_DESTINATION_NONE;
548
- } else if ( ! linkDestination ) {
549
- linkDestination = LINK_DESTINATION_CUSTOM;
550
- }
551
-
552
- return href === undefined || href === this.props.attributes.href
553
- ? setAttributes( restAttributes )
554
- : setAttributes( {
555
- ...restAttributes,
556
- linkDestination,
557
- href,
558
- } );
559
- }
560
-
561
- getAltTextSettings() {
562
- const {
563
- attributes: { alt },
564
- } = this.props;
565
-
566
- const updateAlt = ( newAlt ) => {
567
- this.props.setAttributes( { alt: newAlt } );
568
- };
569
-
570
- return (
571
- <BottomSheetTextControl
572
- initialValue={ alt }
573
- onChange={ updateAlt }
574
- placeholder={ __( 'Add alt text' ) }
575
- label={ __( 'Alt Text' ) }
576
- icon={ textColor }
577
- footerNote={
578
- <>
579
- { __(
580
- 'Describe the purpose of the image. Leave empty if decorative.'
581
- ) }{ ' ' }
582
- <FooterMessageLink
583
- href={
584
- // translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
585
- __(
586
- 'https://www.w3.org/WAI/tutorials/images/decision-tree/'
587
- )
588
- }
589
- value={ __( 'What is alt text?' ) }
590
- />
591
- </>
592
- }
593
- />
594
- );
595
- }
596
-
597
- onSizeChangeValue( newValue ) {
598
- this.onSetSizeSlug( newValue );
599
- }
600
-
601
- onSetFeatured( mediaId ) {
602
- const { closeSettingsBottomSheet } = this.props;
603
- setFeaturedImage( mediaId );
604
- closeSettingsBottomSheet();
605
- }
606
-
607
- getFeaturedButtonPanel( isFeaturedImage ) {
608
- const { attributes, getStylesFromColorScheme } = this.props;
609
-
610
- const setFeaturedButtonStyle = getStylesFromColorScheme(
611
- styles.setFeaturedButton,
612
- styles.setFeaturedButtonDark
613
- );
614
-
615
- const removeFeaturedButton = () => (
616
- <BottomSheet.Cell
617
- label={ __( 'Remove as Featured Image' ) }
618
- labelStyle={ [
619
- setFeaturedButtonStyle,
620
- styles.removeFeaturedButton,
621
- ] }
622
- cellContainerStyle={ styles.setFeaturedButtonCellContainer }
623
- separatorType="none"
624
- onPress={ () =>
625
- this.onSetFeatured( MEDIA_ID_NO_FEATURED_IMAGE_SET )
626
- }
627
- />
628
- );
629
-
630
- const setFeaturedButton = () => (
631
- <BottomSheet.Cell
632
- label={ __( 'Set as Featured Image' ) }
633
- labelStyle={ setFeaturedButtonStyle }
634
- cellContainerStyle={ styles.setFeaturedButtonCellContainer }
635
- separatorType="none"
636
- onPress={ () => this.onSetFeatured( attributes.id ) }
637
- />
638
- );
639
-
640
- return isFeaturedImage ? removeFeaturedButton() : setFeaturedButton();
641
- }
642
-
643
- /**
644
- * Featured images must be set to a successfully uploaded self-hosted image,
645
- * which has an ID.
646
- *
647
- * @return {boolean} Boolean indicating whether or not the current may be set as featured.
648
- */
649
- canImageBeFeatured() {
650
- const {
651
- attributes: { id },
652
- } = this.props;
653
- return (
654
- typeof id !== 'undefined' &&
655
- this.state.uploadStatus !== UPLOAD_STATE_UPLOADING &&
656
- this.state.uploadStatus !== UPLOAD_STATE_FAILED
657
- );
658
- }
659
-
660
- isGif( url ) {
661
- return url.toLowerCase().includes( '.gif' );
662
- }
663
-
664
- render() {
665
- const { isCaptionSelected, isFetchingImage } = this.state;
666
- const {
667
- attributes,
668
- isSelected,
669
- image,
670
- clientId,
671
- imageDefaultSize,
672
- context,
673
- featuredImageId,
674
- wasBlockJustInserted,
675
- shouldUseFastImage,
676
- } = this.props;
677
- const { align, url, alt, id, sizeSlug, className } = attributes;
678
- const hasImageContext = context
679
- ? Object.keys( context ).length > 0
680
- : false;
681
-
682
- const imageSizes = Array.isArray( this.props.imageSizes )
683
- ? this.props.imageSizes
684
- : [];
685
- // Only map available image sizes for the user to choose.
686
- const sizeOptions = imageSizes
687
- .filter( ( { slug } ) => getUrlForSlug( image, slug ) )
688
- .map( ( { name, slug } ) => ( { value: slug, label: name } ) );
689
-
690
- let selectedSizeOption = sizeSlug || imageDefaultSize;
691
- let sizeOptionsValid = sizeOptions.find(
692
- ( option ) => option.value === selectedSizeOption
693
- );
694
-
695
- if ( ! sizeOptionsValid ) {
696
- // Default to 'full' size if the default large size is not available.
697
- sizeOptionsValid = sizeOptions.find(
698
- ( option ) => option.value === 'full'
699
- );
700
- selectedSizeOption = 'full';
701
- }
702
-
703
- const canImageBeFeatured = this.canImageBeFeatured();
704
- const isFeaturedImage =
705
- canImageBeFeatured && featuredImageId === attributes.id;
706
-
707
- const getToolbarEditButton = ( open ) => (
708
- <BlockControls>
709
- <ToolbarGroup>
710
- <ToolbarButton
711
- title={ __( 'Edit image' ) }
712
- icon={ replace }
713
- onClick={ open }
714
- />
715
- </ToolbarGroup>
716
- </BlockControls>
717
- );
718
-
719
- const getInspectorControls = () => (
720
- <InspectorControls>
721
- <PanelBody title={ __( 'Settings' ) } />
722
- <PanelBody style={ styles.panelBody }>
723
- <BlockStyles clientId={ clientId } url={ url } />
724
- </PanelBody>
725
- <PanelBody>
726
- { image && sizeOptionsValid && (
727
- <BottomSheetSelectControl
728
- icon={ fullscreen }
729
- label={ __( 'Size' ) }
730
- options={ sizeOptions }
731
- onChange={ this.onSizeChangeValue }
732
- value={ selectedSizeOption }
733
- />
734
- ) }
735
- { this.getAltTextSettings() }
736
- </PanelBody>
737
- <LinkSettings
738
- attributes={ this.props.attributes }
739
- image={ this.props.image }
740
- isLinkSheetVisible={ this.state.isLinkSheetVisible }
741
- setMappedAttributes={ this.setMappedAttributes }
742
- />
743
- <PanelBody
744
- title={ __( 'Featured Image' ) }
745
- titleStyle={ styles.featuredImagePanelTitle }
746
- >
747
- { canImageBeFeatured &&
748
- this.getFeaturedButtonPanel( isFeaturedImage ) }
749
- <FooterMessageControl
750
- label={ __(
751
- 'Changes to featured image will not be affected by the undo/redo buttons.'
752
- ) }
753
- cellContainerStyle={
754
- styles.setFeaturedButtonCellContainer
755
- }
756
- />
757
- </PanelBody>
758
- </InspectorControls>
759
- );
760
-
761
- if ( ! url ) {
762
- return (
763
- <View style={ styles.content }>
764
- { isFetchingImage && this.showLoadingIndicator() }
765
- <MediaPlaceholder
766
- allowedTypes={ [ MEDIA_TYPE_IMAGE ] }
767
- onSelect={ this.onSelectMediaUploadOption }
768
- onSelectURL={ this.onSelectURL }
769
- icon={ this.getPlaceholderIcon() }
770
- onFocus={ this.props.onFocus }
771
- autoOpenMediaUpload={
772
- isSelected && wasBlockJustInserted
773
- }
774
- />
775
- </View>
776
- );
777
- }
778
-
779
- const alignToFlex = {
780
- left: 'flex-start',
781
- center: 'center',
782
- right: 'flex-end',
783
- full: 'center',
784
- wide: 'center',
785
- };
786
-
787
- const additionalImageProps = {
788
- height: '100%',
789
- resizeMode: context?.imageCrop ? 'cover' : 'contain',
790
- };
791
-
792
- const imageContainerStyles = [
793
- context?.fixedHeight && styles.fixedHeight,
794
- ];
795
-
796
- const isGif = this.isGif( url );
797
- const badgeLabelShown = isFeaturedImage || isGif;
798
- let badgeLabelText = '';
799
- if ( isFeaturedImage ) {
800
- badgeLabelText = __( 'Featured' );
801
- } else if ( isGif ) {
802
- badgeLabelText = __( 'GIF' );
803
- }
804
-
805
- const getImageComponent = ( openMediaOptions, getMediaOptions ) => (
806
- <WCBadge label={ badgeLabelText } show={ badgeLabelShown }>
807
- <TouchableWithoutFeedback
808
- accessible={ ! isSelected }
809
- onPress={ this.onImagePressed }
810
- disabled={ ! isSelected }
811
- >
812
- <View style={ styles.content }>
813
- { isSelected && getInspectorControls() }
814
- { isSelected && getMediaOptions() }
815
- { ! this.state.isCaptionSelected &&
816
- getToolbarEditButton( openMediaOptions ) }
817
- <MediaUploadProgress
818
- enablePausedUploads
819
- coverUrl={ url }
820
- mediaId={ id }
821
- onUpdateMediaProgress={ this.updateMediaProgress }
822
- onFinishMediaUploadWithSuccess={
823
- this.finishMediaUploadWithSuccess
824
- }
825
- onFinishMediaUploadWithFailure={
826
- this.finishMediaUploadWithFailure
827
- }
828
- onMediaUploadStateReset={
829
- this.mediaUploadStateReset
830
- }
831
- renderContent={ ( {
832
- isUploadPaused,
833
- isUploadInProgress,
834
- isUploadFailed,
835
- retryMessage,
836
- } ) => {
837
- return (
838
- <View style={ imageContainerStyles }>
839
- { isFetchingImage &&
840
- this.showLoadingIndicator() }
841
- <Image
842
- align={
843
- align && alignToFlex[ align ]
844
- }
845
- alt={ alt }
846
- isSelected={
847
- isSelected &&
848
- ! isCaptionSelected
849
- }
850
- isUploadFailed={ isUploadFailed }
851
- isUploadPaused={ isUploadPaused }
852
- isUploadInProgress={
853
- isUploadInProgress
854
- }
855
- shouldUseFastImage={
856
- shouldUseFastImage
857
- }
858
- onSelectMediaUploadOption={
859
- this.onSelectMediaUploadOption
860
- }
861
- openMediaOptions={
862
- openMediaOptions
863
- }
864
- retryMessage={ retryMessage }
865
- url={ url }
866
- shapeStyle={
867
- styles[ className ] || className
868
- }
869
- width={ this.getWidth() }
870
- { ...( hasImageContext
871
- ? additionalImageProps
872
- : {} ) }
873
- />
874
- </View>
875
- );
876
- } }
877
- />
878
- </View>
879
- </TouchableWithoutFeedback>
880
- <BlockCaption
881
- clientId={ this.props.clientId }
882
- isSelected={ this.state.isCaptionSelected }
883
- accessible={ ! this.state.isCaptionSelected }
884
- accessibilityLabelCreator={ this.accessibilityLabelCreator }
885
- onFocus={ this.onFocusCaption }
886
- onBlur={ this.props.onBlur } // Always assign onBlur as props.
887
- insertBlocksAfter={ this.props.insertBlocksAfter }
888
- />
889
- </WCBadge>
890
- );
891
-
892
- return (
893
- <MediaUpload
894
- allowedTypes={ [ MEDIA_TYPE_IMAGE ] }
895
- isReplacingMedia
896
- onSelect={ this.onSelectMediaUploadOption }
897
- onSelectURL={ this.onSelectURL }
898
- render={ ( { open, getMediaOptions } ) => {
899
- return getImageComponent( open, getMediaOptions );
900
- } }
901
- />
902
- );
903
- }
904
- }
905
-
906
- export default compose( [
907
- withSelect( ( select, props ) => {
908
- const { getEntityRecord } = select( coreStore );
909
- const { getSettings, wasBlockJustInserted } =
910
- select( blockEditorStore );
911
- const { getEditedPostAttribute } = select( 'core/editor' );
912
- const {
913
- attributes: { id, url },
914
- isSelected,
915
- clientId,
916
- } = props;
917
- const { imageSizes, imageDefaultSize, capabilities } = getSettings();
918
- const isNotFileUrl = id && getProtocol( url ) !== 'file:';
919
- const featuredImageId = getEditedPostAttribute( 'featured_media' );
920
-
921
- const shouldGetMedia =
922
- ( isSelected && isNotFileUrl ) ||
923
- // Edge case to update the image after uploading if the block gets unselected
924
- // Check if it's the original image and not the resized one with queryparams.
925
- ( ! isSelected &&
926
- isNotFileUrl &&
927
- url &&
928
- ! hasQueryArg( url, 'w' ) );
929
- const image = shouldGetMedia
930
- ? getEntityRecord( 'postType', 'attachment', id )
931
- : null;
932
-
933
- return {
934
- image,
935
- imageSizes,
936
- imageDefaultSize,
937
- shouldUseFastImage: capabilities?.shouldUseFastImage === true,
938
- featuredImageId,
939
- wasBlockJustInserted: wasBlockJustInserted(
940
- clientId,
941
- 'inserter_menu'
942
- ),
943
- };
944
- } ),
945
- withDispatch( ( dispatch ) => {
946
- const { createErrorNotice } = dispatch( noticesStore );
947
- const { __unstableMarkNextChangeAsNotPersistent } =
948
- dispatch( blockEditorStore );
949
-
950
- return {
951
- __unstableMarkNextChangeAsNotPersistent,
952
- createErrorNotice,
953
- closeSettingsBottomSheet() {
954
- dispatch( editPostStore ).closeGeneralSidebar();
955
- },
956
- };
957
- } ),
958
- withPreferredColorScheme,
959
- ] )( ImageEdit );