@wordpress/block-library 9.48.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 (519) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/build/columns/transforms.cjs +65 -0
  3. package/build/columns/transforms.cjs.map +2 -2
  4. package/build/gallery/edit.cjs +212 -331
  5. package/build/gallery/edit.cjs.map +2 -2
  6. package/build/gallery/transforms.cjs +43 -0
  7. package/build/gallery/transforms.cjs.map +2 -2
  8. package/build/heading/edit.cjs +0 -1
  9. package/build/heading/edit.cjs.map +2 -2
  10. package/build/list/edit.cjs +1 -8
  11. package/build/list/edit.cjs.map +2 -2
  12. package/build/list/ordered-list-settings.cjs +1 -44
  13. package/build/list/ordered-list-settings.cjs.map +2 -2
  14. package/build/list-item/hooks/use-merge.cjs +47 -24
  15. package/build/list-item/hooks/use-merge.cjs.map +2 -2
  16. package/build/navigation/edit/index.cjs +15 -26
  17. package/build/navigation/edit/index.cjs.map +2 -2
  18. package/build/navigation-link/edit.cjs +0 -1
  19. package/build/navigation-link/edit.cjs.map +2 -2
  20. package/build/navigation-submenu/edit.cjs +2 -1
  21. package/build/navigation-submenu/edit.cjs.map +2 -2
  22. package/build/paragraph/deprecated.cjs +1 -0
  23. package/build/paragraph/deprecated.cjs.map +2 -2
  24. package/build/paragraph/edit.cjs +10 -1
  25. package/build/paragraph/edit.cjs.map +3 -3
  26. package/build/playlist/block.json +12 -0
  27. package/build/playlist/edit.cjs +27 -1
  28. package/build/playlist/edit.cjs.map +2 -2
  29. package/build/playlist/save.cjs +8 -1
  30. package/build/playlist/save.cjs.map +2 -2
  31. package/build/playlist/view.cjs +1 -0
  32. package/build/playlist/view.cjs.map +2 -2
  33. package/build/post-time-to-read/index.cjs +1 -1
  34. package/build/post-time-to-read/index.cjs.map +2 -2
  35. package/build/post-time-to-read/variations.cjs +1 -1
  36. package/build/post-time-to-read/variations.cjs.map +2 -2
  37. package/build/pullquote/edit.cjs +2 -7
  38. package/build/pullquote/edit.cjs.map +2 -2
  39. package/build/quote/edit.cjs +4 -9
  40. package/build/quote/edit.cjs.map +2 -2
  41. package/build/shortcode/transforms.cjs +2 -2
  42. package/build/shortcode/transforms.cjs.map +2 -2
  43. package/build/utils/waveform-player.cjs +42 -9
  44. package/build/utils/waveform-player.cjs.map +2 -2
  45. package/build/utils/waveform-utils.cjs +6 -4
  46. package/build/utils/waveform-utils.cjs.map +2 -2
  47. package/build/video/edit-common-settings.cjs +3 -6
  48. package/build/video/edit-common-settings.cjs.map +2 -2
  49. package/build-module/columns/transforms.mjs +65 -0
  50. package/build-module/columns/transforms.mjs.map +2 -2
  51. package/build-module/gallery/edit.mjs +214 -334
  52. package/build-module/gallery/edit.mjs.map +2 -2
  53. package/build-module/gallery/transforms.mjs +43 -0
  54. package/build-module/gallery/transforms.mjs.map +2 -2
  55. package/build-module/heading/edit.mjs +1 -2
  56. package/build-module/heading/edit.mjs.map +2 -2
  57. package/build-module/list/edit.mjs +2 -9
  58. package/build-module/list/edit.mjs.map +2 -2
  59. package/build-module/list/ordered-list-settings.mjs +1 -45
  60. package/build-module/list/ordered-list-settings.mjs.map +2 -2
  61. package/build-module/list-item/hooks/use-merge.mjs +48 -25
  62. package/build-module/list-item/hooks/use-merge.mjs.map +2 -2
  63. package/build-module/navigation/edit/index.mjs +16 -33
  64. package/build-module/navigation/edit/index.mjs.map +2 -2
  65. package/build-module/navigation-link/edit.mjs +0 -1
  66. package/build-module/navigation-link/edit.mjs.map +2 -2
  67. package/build-module/navigation-submenu/edit.mjs +2 -1
  68. package/build-module/navigation-submenu/edit.mjs.map +2 -2
  69. package/build-module/paragraph/deprecated.mjs +1 -0
  70. package/build-module/paragraph/deprecated.mjs.map +2 -2
  71. package/build-module/paragraph/edit.mjs +12 -2
  72. package/build-module/paragraph/edit.mjs.map +2 -2
  73. package/build-module/playlist/block.json +12 -0
  74. package/build-module/playlist/edit.mjs +27 -1
  75. package/build-module/playlist/edit.mjs.map +2 -2
  76. package/build-module/playlist/save.mjs +8 -1
  77. package/build-module/playlist/save.mjs.map +2 -2
  78. package/build-module/playlist/view.mjs +1 -0
  79. package/build-module/playlist/view.mjs.map +2 -2
  80. package/build-module/post-time-to-read/index.mjs +1 -1
  81. package/build-module/post-time-to-read/index.mjs.map +2 -2
  82. package/build-module/post-time-to-read/variations.mjs +2 -2
  83. package/build-module/post-time-to-read/variations.mjs.map +2 -2
  84. package/build-module/pullquote/edit.mjs +2 -7
  85. package/build-module/pullquote/edit.mjs.map +2 -2
  86. package/build-module/quote/edit.mjs +5 -10
  87. package/build-module/quote/edit.mjs.map +2 -2
  88. package/build-module/shortcode/transforms.mjs +2 -2
  89. package/build-module/shortcode/transforms.mjs.map +2 -2
  90. package/build-module/utils/waveform-player.mjs +44 -11
  91. package/build-module/utils/waveform-player.mjs.map +2 -2
  92. package/build-module/utils/waveform-utils.mjs +6 -4
  93. package/build-module/utils/waveform-utils.mjs.map +2 -2
  94. package/build-module/video/edit-common-settings.mjs +4 -7
  95. package/build-module/video/edit-common-settings.mjs.map +2 -2
  96. package/build-style/comment-template/style-rtl.css +1 -0
  97. package/build-style/comment-template/style.css +1 -0
  98. package/build-style/common-rtl.css +30 -10
  99. package/build-style/common.css +30 -10
  100. package/build-style/cover/style-rtl.css +2 -1
  101. package/build-style/cover/style.css +2 -1
  102. package/build-style/editor-rtl.css +22 -11
  103. package/build-style/editor.css +22 -11
  104. package/build-style/form-input/style-rtl.css +2 -0
  105. package/build-style/form-input/style.css +2 -0
  106. package/build-style/gallery/style-rtl.css +4 -2
  107. package/build-style/gallery/style.css +4 -2
  108. package/build-style/media-text/style-rtl.css +2 -1
  109. package/build-style/media-text/style.css +2 -1
  110. package/build-style/playlist/style-rtl.css +3 -0
  111. package/build-style/playlist/style.css +3 -0
  112. package/build-style/query/editor-rtl.css +8 -4
  113. package/build-style/query/editor.css +8 -4
  114. package/build-style/read-more/style-rtl.css +1 -0
  115. package/build-style/read-more/style.css +1 -0
  116. package/build-style/reset-rtl.css +3 -1
  117. package/build-style/reset.css +3 -1
  118. package/build-style/search/style-rtl.css +3 -1
  119. package/build-style/search/style.css +3 -1
  120. package/build-style/site-logo/editor-rtl.css +2 -1
  121. package/build-style/site-logo/editor.css +2 -1
  122. package/build-style/style-rtl.css +53 -17
  123. package/build-style/style.css +53 -17
  124. package/build-style/tab/style-rtl.css +3 -1
  125. package/build-style/tab/style.css +3 -1
  126. package/build-style/template-part/editor-rtl.css +8 -4
  127. package/build-style/template-part/editor.css +8 -4
  128. package/build-style/video/style-rtl.css +2 -1
  129. package/build-style/video/style.css +2 -1
  130. package/package.json +49 -45
  131. package/src/accordion/README.md +97 -0
  132. package/src/accordion-heading/README.md +81 -0
  133. package/src/accordion-item/README.md +85 -0
  134. package/src/accordion-panel/README.md +74 -0
  135. package/src/archives/README.md +56 -0
  136. package/src/audio/README.md +55 -0
  137. package/src/avatar/README.md +74 -0
  138. package/src/block/README.md +56 -0
  139. package/src/breadcrumbs/README.md +67 -0
  140. package/src/button/README.md +93 -0
  141. package/src/buttons/README.md +80 -0
  142. package/src/calendar/README.md +51 -0
  143. package/src/categories/README.md +69 -0
  144. package/src/code/README.md +55 -0
  145. package/src/column/README.md +72 -0
  146. package/src/columns/README.md +90 -0
  147. package/src/columns/test/transforms.js +164 -0
  148. package/src/columns/transforms.js +74 -0
  149. package/src/comment-author-avatar/README.md +63 -0
  150. package/src/comment-author-name/README.md +67 -0
  151. package/src/comment-content/README.md +61 -0
  152. package/src/comment-date/README.md +67 -0
  153. package/src/comment-edit-link/README.md +67 -0
  154. package/src/comment-reply-link/README.md +63 -0
  155. package/src/comment-template/README.md +60 -0
  156. package/src/comments/README.md +88 -0
  157. package/src/comments-pagination/README.md +77 -0
  158. package/src/comments-pagination-next/README.md +64 -0
  159. package/src/comments-pagination-numbers/README.md +64 -0
  160. package/src/comments-pagination-previous/README.md +64 -0
  161. package/src/comments-title/README.md +70 -0
  162. package/src/common.scss +63 -10
  163. package/src/cover/README.md +111 -0
  164. package/src/details/README.md +65 -0
  165. package/src/embed/README.md +56 -0
  166. package/src/file/README.md +60 -0
  167. package/src/footnotes/README.md +64 -0
  168. package/src/form/README.md +90 -0
  169. package/src/form-input/README.md +74 -0
  170. package/src/form-submission-notification/README.md +50 -0
  171. package/src/form-submit-button/README.md +54 -0
  172. package/src/freeform/README.md +49 -0
  173. package/src/gallery/README.md +115 -0
  174. package/src/gallery/edit.js +213 -350
  175. package/src/gallery/test/transforms.js +155 -0
  176. package/src/gallery/transforms.js +47 -0
  177. package/src/group/README.md +80 -0
  178. package/src/heading/README.md +60 -0
  179. package/src/heading/edit.js +1 -2
  180. package/src/home-link/README.md +66 -0
  181. package/src/home-link/index.php +3 -15
  182. package/src/html/README.md +48 -0
  183. package/src/icon/README.md +63 -0
  184. package/src/image/README.md +102 -0
  185. package/src/image/index.php +4 -4
  186. package/src/latest-comments/README.md +57 -0
  187. package/src/latest-posts/README.md +71 -0
  188. package/src/list/README.md +70 -0
  189. package/src/list/edit.js +2 -9
  190. package/src/list/ordered-list-settings.js +46 -92
  191. package/src/list-item/README.md +71 -0
  192. package/src/list-item/hooks/use-merge.js +53 -46
  193. package/src/loginout/README.md +56 -0
  194. package/src/math/README.md +50 -0
  195. package/src/media-text/README.md +92 -0
  196. package/src/missing/README.md +55 -0
  197. package/src/more/README.md +49 -0
  198. package/src/navigation/README.md +115 -0
  199. package/src/navigation/edit/index.js +10 -30
  200. package/src/navigation-link/README.md +93 -0
  201. package/src/navigation-link/edit.js +0 -1
  202. package/src/navigation-link/index.php +1 -15
  203. package/src/navigation-overlay-close/README.md +48 -0
  204. package/src/navigation-submenu/README.md +84 -0
  205. package/src/navigation-submenu/edit.js +1 -0
  206. package/src/navigation-submenu/index.php +1 -17
  207. package/src/nextpage/README.md +50 -0
  208. package/src/page-list/README.md +84 -0
  209. package/src/page-list/index.php +3 -15
  210. package/src/page-list-item/README.md +77 -0
  211. package/src/paragraph/README.md +70 -0
  212. package/src/paragraph/deprecated.js +1 -0
  213. package/src/paragraph/edit.js +13 -1
  214. package/src/pattern/README.md +45 -0
  215. package/src/playlist/README.md +86 -0
  216. package/src/playlist/block.json +12 -0
  217. package/src/playlist/edit.js +27 -0
  218. package/src/playlist/index.php +10 -3
  219. package/src/playlist/save.js +9 -1
  220. package/src/playlist/style.scss +7 -0
  221. package/src/playlist/view.js +1 -0
  222. package/src/playlist-track/README.md +69 -0
  223. package/src/post-author/README.md +78 -0
  224. package/src/post-author-biography/README.md +59 -0
  225. package/src/post-author-name/README.md +63 -0
  226. package/src/post-author-name/index.php +1 -1
  227. package/src/post-comment/README.md +61 -0
  228. package/src/post-comments-count/README.md +58 -0
  229. package/src/post-comments-form/README.md +59 -0
  230. package/src/post-comments-link/README.md +60 -0
  231. package/src/post-content/README.md +71 -0
  232. package/src/post-date/README.md +65 -0
  233. package/src/post-date/index.php +1 -1
  234. package/src/post-excerpt/README.md +66 -0
  235. package/src/post-featured-image/README.md +85 -0
  236. package/src/post-featured-image/index.php +1 -1
  237. package/src/post-navigation-link/README.md +63 -0
  238. package/src/post-template/README.md +71 -0
  239. package/src/post-terms/README.md +65 -0
  240. package/src/post-time-to-read/README.md +63 -0
  241. package/src/post-time-to-read/index.js +1 -1
  242. package/src/post-time-to-read/variations.js +2 -2
  243. package/src/post-title/README.md +69 -0
  244. package/src/preformatted/README.md +50 -0
  245. package/src/pullquote/README.md +64 -0
  246. package/src/pullquote/edit.js +1 -7
  247. package/src/query/README.md +64 -0
  248. package/src/query-no-results/README.md +65 -0
  249. package/src/query-pagination/README.md +79 -0
  250. package/src/query-pagination-next/README.md +67 -0
  251. package/src/query-pagination-numbers/README.md +65 -0
  252. package/src/query-pagination-previous/README.md +67 -0
  253. package/src/query-title/README.md +65 -0
  254. package/src/query-total/README.md +66 -0
  255. package/src/quote/README.md +75 -0
  256. package/src/quote/edit.js +3 -9
  257. package/src/read-more/README.md +61 -0
  258. package/src/read-more/index.php +2 -2
  259. package/src/rss/README.md +62 -0
  260. package/src/search/README.md +66 -0
  261. package/src/separator/README.md +62 -0
  262. package/src/shortcode/README.md +44 -0
  263. package/src/shortcode/transforms.js +2 -2
  264. package/src/site-logo/README.md +72 -0
  265. package/src/site-tagline/README.md +56 -0
  266. package/src/site-title/README.md +57 -0
  267. package/src/social-link/README.md +64 -0
  268. package/src/social-links/README.md +98 -0
  269. package/src/spacer/README.md +53 -0
  270. package/src/tab/README.md +69 -0
  271. package/src/tab-list/README.md +79 -0
  272. package/src/tab-panel/README.md +75 -0
  273. package/src/tab-panels/README.md +75 -0
  274. package/src/table/README.md +71 -0
  275. package/src/table-of-contents/README.md +61 -0
  276. package/src/tabs/README.md +83 -0
  277. package/src/tag-cloud/README.md +62 -0
  278. package/src/template-part/README.md +48 -0
  279. package/src/term-count/README.md +59 -0
  280. package/src/term-description/README.md +60 -0
  281. package/src/term-name/README.md +65 -0
  282. package/src/term-template/README.md +65 -0
  283. package/src/terms-query/README.md +58 -0
  284. package/src/text-columns/README.md +51 -0
  285. package/src/utils/test/waveform-player.js +254 -0
  286. package/src/utils/waveform-player.js +90 -18
  287. package/src/utils/waveform-utils.js +15 -11
  288. package/src/verse/README.md +58 -0
  289. package/src/video/README.md +58 -0
  290. package/src/video/edit-common-settings.js +4 -7
  291. package/src/audio/edit.native.js +0 -250
  292. package/src/audio/style.native.scss +0 -13
  293. package/src/audio/test/__snapshots__/edit.native.js.snap +0 -546
  294. package/src/audio/test/__snapshots__/transforms.native.js.snap +0 -25
  295. package/src/audio/test/edit.native.js +0 -132
  296. package/src/audio/test/transforms.native.js +0 -43
  297. package/src/audio/transforms.native.js +0 -12
  298. package/src/block/edit-title.native.js +0 -67
  299. package/src/block/edit.native.js +0 -247
  300. package/src/block/editor.native.scss +0 -125
  301. package/src/block/test/__snapshots__/transforms.native.js.snap +0 -15
  302. package/src/block/test/edit.native.js +0 -262
  303. package/src/block/test/transforms.native.js +0 -40
  304. package/src/button/color-background.native.js +0 -41
  305. package/src/button/edit.native.js +0 -567
  306. package/src/button/editor.native.scss +0 -70
  307. package/src/button/rich-text.android.scss +0 -6
  308. package/src/button/rich-text.ios.scss +0 -6
  309. package/src/buttons/edit.native.js +0 -157
  310. package/src/buttons/editor.native.scss +0 -11
  311. package/src/buttons/test/__snapshots__/edit.native.js.snap +0 -99
  312. package/src/buttons/test/__snapshots__/transforms.native.js.snap +0 -31
  313. package/src/buttons/test/edit.native.js +0 -485
  314. package/src/buttons/test/transforms.native.js +0 -48
  315. package/src/buttons/transforms.native.js +0 -12
  316. package/src/code/edit.native.js +0 -70
  317. package/src/code/test/__snapshots__/edit.native.js.snap +0 -13
  318. package/src/code/test/edit.native.js +0 -65
  319. package/src/code/theme.native.scss +0 -22
  320. package/src/code/transforms.native.js +0 -12
  321. package/src/column/column-preview.native.js +0 -58
  322. package/src/column/edit.native.js +0 -273
  323. package/src/column/editor.native.scss +0 -75
  324. package/src/columns/columnCalculations.native.js +0 -178
  325. package/src/columns/edit.native.js +0 -507
  326. package/src/columns/editor.native.scss +0 -17
  327. package/src/columns/test/__snapshots__/edit.native.js.snap +0 -305
  328. package/src/columns/test/__snapshots__/transforms.native.js.snap +0 -61
  329. package/src/columns/test/edit.native.js +0 -496
  330. package/src/columns/test/transforms.native.js +0 -89
  331. package/src/columns/transforms.native.js +0 -12
  332. package/src/cover/controls.native.js +0 -307
  333. package/src/cover/edit.native.js +0 -708
  334. package/src/cover/focal-point-settings-button.native.js +0 -53
  335. package/src/cover/overlay-color-settings.native.js +0 -106
  336. package/src/cover/style.native.scss +0 -220
  337. package/src/cover/test/__snapshots__/edit.native.js.snap +0 -105
  338. package/src/cover/test/__snapshots__/transforms.native.js.snap +0 -73
  339. package/src/cover/test/edit.native.js +0 -701
  340. package/src/cover/test/transforms.native.js +0 -116
  341. package/src/cover/transforms.native.js +0 -12
  342. package/src/cover/use-cover-is-dark.native.js +0 -51
  343. package/src/embed/edit.native.js +0 -345
  344. package/src/embed/embed-controls.native.js +0 -65
  345. package/src/embed/embed-link-settings.native.js +0 -99
  346. package/src/embed/embed-loading.native.js +0 -29
  347. package/src/embed/embed-no-preview.native.js +0 -230
  348. package/src/embed/embed-placeholder.native.js +0 -178
  349. package/src/embed/embed-preview.native.js +0 -157
  350. package/src/embed/styles.native.scss +0 -196
  351. package/src/embed/test/__snapshots__/index.native.js.snap +0 -191
  352. package/src/embed/test/__snapshots__/transforms.native.js.snap +0 -23
  353. package/src/embed/test/index.native.js +0 -1125
  354. package/src/embed/test/transforms.native.js +0 -44
  355. package/src/embed/transforms.native.js +0 -12
  356. package/src/embed/wp-embed-preview.native.js +0 -80
  357. package/src/file/edit.native.js +0 -605
  358. package/src/file/style.native.scss +0 -79
  359. package/src/file/test/__snapshots__/edit.native.js.snap +0 -580
  360. package/src/file/test/__snapshots__/transforms.native.js.snap +0 -19
  361. package/src/file/test/edit.native.js +0 -93
  362. package/src/file/test/transforms.native.js +0 -43
  363. package/src/file/transforms.native.js +0 -12
  364. package/src/freeform/edit.native.js +0 -13
  365. package/src/freeform/test/__snapshots__/index.native.js.snap +0 -7
  366. package/src/freeform/test/__snapshots__/transforms.native.js.snap +0 -19
  367. package/src/freeform/test/index.native.js +0 -57
  368. package/src/freeform/test/transforms.native.js +0 -39
  369. package/src/gallery/gallery-styles.native.scss +0 -8
  370. package/src/gallery/gallery.native.js +0 -124
  371. package/src/gallery/styles.native.scss +0 -7
  372. package/src/gallery/test/__snapshots__/index.native.js.snap +0 -177
  373. package/src/gallery/test/__snapshots__/transforms.native.js.snap +0 -53
  374. package/src/gallery/test/helpers.native.js +0 -106
  375. package/src/gallery/test/index.native.js +0 -700
  376. package/src/gallery/test/transforms.native.js +0 -53
  377. package/src/gallery/test/use-get-media.native.js +0 -24
  378. package/src/gallery/transforms.native.js +0 -12
  379. package/src/gallery/use-get-media.native.js +0 -49
  380. package/src/group/edit.native.js +0 -137
  381. package/src/group/editor.native.scss +0 -56
  382. package/src/group/test/__snapshots__/edit.native.js.snap +0 -19
  383. package/src/group/test/__snapshots__/transforms.native.js.snap +0 -35
  384. package/src/group/test/edit.native.js +0 -100
  385. package/src/group/test/transforms.native.js +0 -73
  386. package/src/heading/edit.native.js +0 -159
  387. package/src/heading/test/__snapshots__/index.native.js.snap +0 -43
  388. package/src/heading/test/__snapshots__/transforms.native.js.snap +0 -47
  389. package/src/heading/test/index.native.js +0 -257
  390. package/src/heading/test/transforms.native.js +0 -46
  391. package/src/heading/transforms.native.js +0 -12
  392. package/src/html/transforms.native.js +0 -11
  393. package/src/image/edit.native.js +0 -959
  394. package/src/image/styles.native.scss +0 -70
  395. package/src/image/test/__snapshots__/transforms.native.js.snap +0 -49
  396. package/src/image/test/edit.native.js +0 -459
  397. package/src/image/test/transforms.native.js +0 -49
  398. package/src/image/transforms.native.js +0 -12
  399. package/src/index.native.js +0 -274
  400. package/src/latest-posts/edit.native.js +0 -294
  401. package/src/latest-posts/style.native.scss +0 -47
  402. package/src/latest-posts/test/__snapshots__/edit.native.js.snap +0 -3
  403. package/src/latest-posts/test/__snapshots__/transforms.native.js.snap +0 -15
  404. package/src/latest-posts/test/edit.native.js +0 -49
  405. package/src/latest-posts/test/transforms.native.js +0 -61
  406. package/src/list/tag-name.native.js +0 -12
  407. package/src/list/test/__snapshots__/edit.native.js.snap +0 -121
  408. package/src/list/test/__snapshots__/transforms.native.js.snap +0 -85
  409. package/src/list/test/edit.native.js +0 -602
  410. package/src/list/test/transforms.native.js +0 -56
  411. package/src/list/transforms.native.js +0 -12
  412. package/src/list-item/edit.native.js +0 -175
  413. package/src/list-item/hooks/use-enter.native.js +0 -81
  414. package/src/list-item/icons.native.js +0 -34
  415. package/src/list-item/list-style-type.native.js +0 -146
  416. package/src/list-item/style.native.scss +0 -57
  417. package/src/media-text/edit.native.js +0 -417
  418. package/src/media-text/icon-retry.native.js +0 -11
  419. package/src/media-text/media-container.native.js +0 -393
  420. package/src/media-text/style.native.scss +0 -191
  421. package/src/media-text/test/__snapshots__/transforms.native.js.snap +0 -73
  422. package/src/media-text/test/edit.native.js +0 -58
  423. package/src/media-text/test/transforms.native.js +0 -116
  424. package/src/media-text/transforms.native.js +0 -12
  425. package/src/missing/edit.native.js +0 -294
  426. package/src/missing/style.native.scss +0 -79
  427. package/src/missing/test/__snapshots__/edit.native.js.snap +0 -110
  428. package/src/missing/test/edit-integration.native.js +0 -168
  429. package/src/missing/test/edit.native.js +0 -81
  430. package/src/more/edit.native.js +0 -36
  431. package/src/more/editor.native.scss +0 -21
  432. package/src/more/test/__snapshots__/edit.native.js.snap +0 -7
  433. package/src/more/test/__snapshots__/transforms.native.js.snap +0 -19
  434. package/src/more/test/edit.native.js +0 -41
  435. package/src/more/test/transforms.native.js +0 -42
  436. package/src/more/transforms.native.js +0 -12
  437. package/src/navigation-link/shared/build-css-font-sizes.php +0 -43
  438. package/src/nextpage/edit.native.js +0 -58
  439. package/src/nextpage/editor.native.scss +0 -21
  440. package/src/nextpage/test/__snapshots__/transforms.native.js.snap +0 -19
  441. package/src/nextpage/test/transforms.native.js +0 -42
  442. package/src/nextpage/transforms.native.js +0 -12
  443. package/src/paragraph/edit.native.js +0 -116
  444. package/src/paragraph/test/__snapshots__/edit.native.js.snap +0 -88
  445. package/src/paragraph/test/__snapshots__/transforms.native.js.snap +0 -65
  446. package/src/paragraph/test/edit.native.js +0 -999
  447. package/src/paragraph/test/transforms.native.js +0 -51
  448. package/src/paragraph/transforms.native.js +0 -12
  449. package/src/preformatted/edit.native.js +0 -48
  450. package/src/preformatted/styles.native.scss +0 -30
  451. package/src/preformatted/test/__snapshots__/edit.native.js.snap +0 -95
  452. package/src/preformatted/test/__snapshots__/transforms.native.js.snap +0 -37
  453. package/src/preformatted/test/edit.native.js +0 -111
  454. package/src/preformatted/test/transforms.native.js +0 -47
  455. package/src/preformatted/transforms.native.js +0 -12
  456. package/src/pullquote/blockquote.native.js +0 -39
  457. package/src/pullquote/blockquote.native.scss +0 -8
  458. package/src/pullquote/edit.native.js +0 -128
  459. package/src/pullquote/figure.native.js +0 -33
  460. package/src/pullquote/figure.native.scss +0 -16
  461. package/src/pullquote/test/__snapshots__/transforms.native.js.snap +0 -47
  462. package/src/pullquote/test/edit.native.js +0 -73
  463. package/src/pullquote/test/transforms.native.js +0 -46
  464. package/src/pullquote/transforms.native.js +0 -12
  465. package/src/quote/test/__snapshots__/transforms.native.js.snap +0 -49
  466. package/src/quote/test/edit.native.js +0 -94
  467. package/src/quote/test/transforms.native.js +0 -69
  468. package/src/quote/transforms.native.js +0 -12
  469. package/src/search/edit.native.js +0 -486
  470. package/src/search/style.native.scss +0 -99
  471. package/src/search/test/__snapshots__/edit.native.js.snap +0 -827
  472. package/src/search/test/__snapshots__/transforms.native.js.snap +0 -15
  473. package/src/search/test/edit.native.js +0 -170
  474. package/src/search/test/transforms.native.js +0 -40
  475. package/src/separator/separator-settings.native.js +0 -3
  476. package/src/separator/test/__snapshots__/edit.native.js.snap +0 -7
  477. package/src/separator/test/__snapshots__/transforms.native.js.snap +0 -25
  478. package/src/separator/test/edit.native.js +0 -41
  479. package/src/separator/test/transforms.native.js +0 -42
  480. package/src/separator/transforms.native.js +0 -12
  481. package/src/shortcode/edit.native.js +0 -77
  482. package/src/shortcode/style.native.scss +0 -44
  483. package/src/shortcode/test/__snapshots__/edit.native.js.snap +0 -9
  484. package/src/shortcode/test/__snapshots__/transforms.native.js.snap +0 -19
  485. package/src/shortcode/test/edit.native.js +0 -70
  486. package/src/shortcode/test/transforms.native.js +0 -42
  487. package/src/shortcode/transforms.native.js +0 -12
  488. package/src/social-link/edit.native.js +0 -219
  489. package/src/social-link/editor.native.scss +0 -18
  490. package/src/social-links/edit.native.js +0 -147
  491. package/src/social-links/editor.native.scss +0 -25
  492. package/src/social-links/test/__snapshots__/edit.native.js.snap +0 -57
  493. package/src/social-links/test/__snapshots__/transforms.native.js.snap +0 -31
  494. package/src/social-links/test/edit.native.js +0 -266
  495. package/src/social-links/test/transforms.native.js +0 -53
  496. package/src/spacer/controls.native.js +0 -86
  497. package/src/spacer/edit.native.js +0 -110
  498. package/src/spacer/editor.native.scss +0 -18
  499. package/src/spacer/save.native.js +0 -18
  500. package/src/spacer/test/__snapshots__/index.native.js.snap +0 -43
  501. package/src/spacer/test/__snapshots__/transforms.native.js.snap +0 -25
  502. package/src/spacer/test/index.native.js +0 -257
  503. package/src/spacer/test/transforms.native.js +0 -42
  504. package/src/table/transforms.native.js +0 -11
  505. package/src/text-columns/transforms.native.js +0 -12
  506. package/src/utils/init-block.native.js +0 -40
  507. package/src/utils/transformation-categories.native.js +0 -47
  508. package/src/verse/test/__snapshots__/edit.native.js.snap +0 -13
  509. package/src/verse/test/__snapshots__/transforms.native.js.snap +0 -31
  510. package/src/verse/test/edit.native.js +0 -118
  511. package/src/verse/test/transforms.native.js +0 -46
  512. package/src/verse/transforms.native.js +0 -12
  513. package/src/video/edit.native.js +0 -406
  514. package/src/video/icon-retry.native.js +0 -11
  515. package/src/video/style.native.scss +0 -81
  516. package/src/video/test/__snapshots__/transforms.native.js.snap +0 -41
  517. package/src/video/test/edit.native.js +0 -53
  518. package/src/video/test/transforms.native.js +0 -49
  519. 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 );