@wordpress/block-library 7.16.0 → 7.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/CHANGELOG.md +4 -1
  2. package/build/archives/edit.js +1 -0
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +44 -4
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/button/edit.js +1 -1
  7. package/build/button/edit.js.map +1 -1
  8. package/build/buttons/edit.native.js +1 -1
  9. package/build/buttons/edit.native.js.map +1 -1
  10. package/build/comment-template/edit.js +40 -32
  11. package/build/comment-template/edit.js.map +1 -1
  12. package/build/comment-template/index.js +6 -2
  13. package/build/comment-template/index.js.map +1 -1
  14. package/build/comments/edit/placeholder.js +1 -4
  15. package/build/comments/edit/placeholder.js.map +1 -1
  16. package/build/comments/index.js +5 -1
  17. package/build/comments/index.js.map +1 -1
  18. package/build/comments-title/edit.js +18 -1
  19. package/build/comments-title/edit.js.map +1 -1
  20. package/build/cover/edit/index.js +2 -2
  21. package/build/cover/edit/index.js.map +1 -1
  22. package/build/cover/edit/inspector-controls.js +3 -7
  23. package/build/cover/edit/inspector-controls.js.map +1 -1
  24. package/build/cover/edit/use-cover-is-dark.js +8 -7
  25. package/build/cover/edit/use-cover-is-dark.js.map +1 -1
  26. package/build/embed/deprecated.js +43 -4
  27. package/build/embed/deprecated.js.map +1 -1
  28. package/build/embed/variations.js +1 -1
  29. package/build/embed/variations.js.map +1 -1
  30. package/build/file/deprecated.js +108 -4
  31. package/build/file/deprecated.js.map +1 -1
  32. package/build/file/transforms.js +3 -9
  33. package/build/file/transforms.js.map +1 -1
  34. package/build/gallery/deprecated.js +148 -23
  35. package/build/gallery/deprecated.js.map +1 -1
  36. package/build/gallery/gallery.js +3 -2
  37. package/build/gallery/gallery.js.map +1 -1
  38. package/build/gallery/transforms.js +3 -3
  39. package/build/gallery/transforms.js.map +1 -1
  40. package/build/gallery/use-image-sizes.js +2 -1
  41. package/build/gallery/use-image-sizes.js.map +1 -1
  42. package/build/gallery/v1/edit.js +3 -2
  43. package/build/gallery/v1/edit.js.map +1 -1
  44. package/build/group/edit.js +7 -3
  45. package/build/group/edit.js.map +1 -1
  46. package/build/image/edit.native.js +1 -1
  47. package/build/image/edit.native.js.map +1 -1
  48. package/build/image/image.js +33 -12
  49. package/build/image/image.js.map +1 -1
  50. package/build/image/transforms.js +1 -7
  51. package/build/image/transforms.js.map +1 -1
  52. package/build/latest-posts/edit.js +1 -1
  53. package/build/latest-posts/edit.js.map +1 -1
  54. package/build/list/transforms.js +9 -1
  55. package/build/list/transforms.js.map +1 -1
  56. package/build/list/utils.js +4 -8
  57. package/build/list/utils.js.map +1 -1
  58. package/build/list-item/edit.js +3 -2
  59. package/build/list-item/edit.js.map +1 -1
  60. package/build/list-item/edit.native.js +3 -2
  61. package/build/list-item/edit.native.js.map +1 -1
  62. package/build/list-item/hooks/use-merge.js +19 -22
  63. package/build/list-item/hooks/use-merge.js.map +1 -1
  64. package/build/list-item/hooks/use-outdent-list-item.js +24 -10
  65. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  66. package/build/list-item/index.js +14 -1
  67. package/build/list-item/index.js.map +1 -1
  68. package/build/list-item/utils.js +14 -1
  69. package/build/list-item/utils.js.map +1 -1
  70. package/build/navigation/edit/index.js +45 -31
  71. package/build/navigation/edit/index.js.map +1 -1
  72. package/build/navigation/edit/inner-blocks.js +3 -5
  73. package/build/navigation/edit/inner-blocks.js.map +1 -1
  74. package/build/navigation/edit/unsaved-inner-blocks.js +3 -1
  75. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  76. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
  77. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  78. package/build/navigation/edit/use-create-navigation-menu.js +1 -1
  79. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  80. package/build/navigation/index.js +4 -1
  81. package/build/navigation/index.js.map +1 -1
  82. package/build/navigation-link/edit.js +5 -3
  83. package/build/navigation-link/edit.js.map +1 -1
  84. package/build/navigation-submenu/edit.js +4 -4
  85. package/build/navigation-submenu/edit.js.map +1 -1
  86. package/build/page-list/edit.js +29 -10
  87. package/build/page-list/edit.js.map +1 -1
  88. package/build/page-list/index.js +1 -5
  89. package/build/page-list/index.js.map +1 -1
  90. package/build/paragraph/edit.js +3 -11
  91. package/build/paragraph/edit.js.map +1 -1
  92. package/build/pattern/edit.js +11 -4
  93. package/build/pattern/edit.js.map +1 -1
  94. package/build/post-comments-count/index.js +4 -0
  95. package/build/post-comments-count/index.js.map +1 -1
  96. package/build/post-comments-form/form.js +1 -2
  97. package/build/post-comments-form/form.js.map +1 -1
  98. package/build/post-comments-form/index.js +4 -0
  99. package/build/post-comments-form/index.js.map +1 -1
  100. package/build/post-comments-link/index.js +4 -0
  101. package/build/post-comments-link/index.js.map +1 -1
  102. package/build/post-content/edit.js +14 -6
  103. package/build/post-content/edit.js.map +1 -1
  104. package/build/pullquote/deprecated.js +6 -6
  105. package/build/pullquote/deprecated.js.map +1 -1
  106. package/build/query/edit/inspector-controls/index.js +2 -2
  107. package/build/query/edit/inspector-controls/index.js.map +1 -1
  108. package/build/query/edit/inspector-controls/taxonomy-controls.js +79 -104
  109. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  110. package/build/search/edit.js +3 -4
  111. package/build/search/edit.js.map +1 -1
  112. package/build/site-logo/edit.js +7 -10
  113. package/build/site-logo/edit.js.map +1 -1
  114. package/build/site-tagline/edit.js +21 -9
  115. package/build/site-tagline/edit.js.map +1 -1
  116. package/build/site-title/edit/index.js +20 -8
  117. package/build/site-title/edit/index.js.map +1 -1
  118. package/build/social-link/edit.js +11 -2
  119. package/build/social-link/edit.js.map +1 -1
  120. package/build/social-link/index.js +3 -0
  121. package/build/social-link/index.js.map +1 -1
  122. package/build/spacer/controls.js +3 -7
  123. package/build/spacer/controls.js.map +1 -1
  124. package/build/table/deprecated.js +282 -27
  125. package/build/table/deprecated.js.map +1 -1
  126. package/build/table/state.js +2 -2
  127. package/build/table/state.js.map +1 -1
  128. package/build/table-of-contents/edit.js +1 -4
  129. package/build/table-of-contents/edit.js.map +1 -1
  130. package/build/tag-cloud/edit.js +1 -1
  131. package/build/tag-cloud/edit.js.map +1 -1
  132. package/build/tag-cloud/index.js +8 -0
  133. package/build/tag-cloud/index.js.map +1 -1
  134. package/build/utils/clean-empty-object.js +5 -4
  135. package/build/utils/clean-empty-object.js.map +1 -1
  136. package/build/video/deprecated.js +159 -0
  137. package/build/video/deprecated.js.map +1 -0
  138. package/build/video/edit.js +41 -5
  139. package/build/video/edit.js.map +1 -1
  140. package/build/video/index.js +3 -0
  141. package/build/video/index.js.map +1 -1
  142. package/build/video/tracks-editor.js +3 -28
  143. package/build/video/tracks-editor.js.map +1 -1
  144. package/build-module/archives/edit.js +1 -0
  145. package/build-module/archives/edit.js.map +1 -1
  146. package/build-module/audio/edit.js +46 -7
  147. package/build-module/audio/edit.js.map +1 -1
  148. package/build-module/button/edit.js +1 -1
  149. package/build-module/button/edit.js.map +1 -1
  150. package/build-module/buttons/edit.native.js +1 -1
  151. package/build-module/buttons/edit.native.js.map +1 -1
  152. package/build-module/comment-template/edit.js +38 -30
  153. package/build-module/comment-template/edit.js.map +1 -1
  154. package/build-module/comment-template/index.js +6 -2
  155. package/build-module/comment-template/index.js.map +1 -1
  156. package/build-module/comments/edit/placeholder.js +1 -3
  157. package/build-module/comments/edit/placeholder.js.map +1 -1
  158. package/build-module/comments/index.js +5 -1
  159. package/build-module/comments/index.js.map +1 -1
  160. package/build-module/comments-title/edit.js +18 -2
  161. package/build-module/comments-title/edit.js.map +1 -1
  162. package/build-module/cover/edit/index.js +2 -2
  163. package/build-module/cover/edit/index.js.map +1 -1
  164. package/build-module/cover/edit/inspector-controls.js +4 -8
  165. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  166. package/build-module/cover/edit/use-cover-is-dark.js +7 -7
  167. package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
  168. package/build-module/embed/deprecated.js +44 -5
  169. package/build-module/embed/deprecated.js.map +1 -1
  170. package/build-module/embed/variations.js +1 -1
  171. package/build-module/embed/variations.js.map +1 -1
  172. package/build-module/file/deprecated.js +108 -4
  173. package/build-module/file/deprecated.js.map +1 -1
  174. package/build-module/file/transforms.js +3 -8
  175. package/build-module/file/transforms.js.map +1 -1
  176. package/build-module/gallery/deprecated.js +147 -25
  177. package/build-module/gallery/deprecated.js.map +1 -1
  178. package/build-module/gallery/gallery.js +3 -2
  179. package/build-module/gallery/gallery.js.map +1 -1
  180. package/build-module/gallery/transforms.js +4 -4
  181. package/build-module/gallery/transforms.js.map +1 -1
  182. package/build-module/gallery/use-image-sizes.js +3 -2
  183. package/build-module/gallery/use-image-sizes.js.map +1 -1
  184. package/build-module/gallery/v1/edit.js +4 -3
  185. package/build-module/gallery/v1/edit.js.map +1 -1
  186. package/build-module/group/edit.js +7 -3
  187. package/build-module/group/edit.js.map +1 -1
  188. package/build-module/image/edit.native.js +1 -1
  189. package/build-module/image/edit.native.js.map +1 -1
  190. package/build-module/image/image.js +36 -15
  191. package/build-module/image/image.js.map +1 -1
  192. package/build-module/image/transforms.js +1 -6
  193. package/build-module/image/transforms.js.map +1 -1
  194. package/build-module/latest-posts/edit.js +2 -2
  195. package/build-module/latest-posts/edit.js.map +1 -1
  196. package/build-module/list/transforms.js +9 -1
  197. package/build-module/list/transforms.js.map +1 -1
  198. package/build-module/list/utils.js +5 -9
  199. package/build-module/list/utils.js.map +1 -1
  200. package/build-module/list-item/edit.js +3 -2
  201. package/build-module/list-item/edit.js.map +1 -1
  202. package/build-module/list-item/edit.native.js +3 -2
  203. package/build-module/list-item/edit.native.js.map +1 -1
  204. package/build-module/list-item/hooks/use-merge.js +19 -21
  205. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  206. package/build-module/list-item/hooks/use-outdent-list-item.js +24 -9
  207. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  208. package/build-module/list-item/index.js +14 -1
  209. package/build-module/list-item/index.js.map +1 -1
  210. package/build-module/list-item/utils.js +14 -1
  211. package/build-module/list-item/utils.js.map +1 -1
  212. package/build-module/navigation/edit/index.js +45 -31
  213. package/build-module/navigation/edit/index.js.map +1 -1
  214. package/build-module/navigation/edit/inner-blocks.js +3 -5
  215. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  216. package/build-module/navigation/edit/unsaved-inner-blocks.js +3 -1
  217. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  218. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
  219. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  220. package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
  221. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  222. package/build-module/navigation/index.js +4 -1
  223. package/build-module/navigation/index.js.map +1 -1
  224. package/build-module/navigation-link/edit.js +5 -4
  225. package/build-module/navigation-link/edit.js.map +1 -1
  226. package/build-module/navigation-submenu/edit.js +4 -4
  227. package/build-module/navigation-submenu/edit.js.map +1 -1
  228. package/build-module/page-list/edit.js +29 -10
  229. package/build-module/page-list/edit.js.map +1 -1
  230. package/build-module/page-list/index.js +1 -5
  231. package/build-module/page-list/index.js.map +1 -1
  232. package/build-module/paragraph/edit.js +3 -10
  233. package/build-module/paragraph/edit.js.map +1 -1
  234. package/build-module/pattern/edit.js +10 -3
  235. package/build-module/pattern/edit.js.map +1 -1
  236. package/build-module/post-comments-count/index.js +4 -0
  237. package/build-module/post-comments-count/index.js.map +1 -1
  238. package/build-module/post-comments-form/form.js +2 -3
  239. package/build-module/post-comments-form/form.js.map +1 -1
  240. package/build-module/post-comments-form/index.js +4 -0
  241. package/build-module/post-comments-form/index.js.map +1 -1
  242. package/build-module/post-comments-link/index.js +4 -0
  243. package/build-module/post-comments-link/index.js.map +1 -1
  244. package/build-module/post-content/edit.js +14 -6
  245. package/build-module/post-content/edit.js.map +1 -1
  246. package/build-module/pullquote/deprecated.js +7 -7
  247. package/build-module/pullquote/deprecated.js.map +1 -1
  248. package/build-module/query/edit/inspector-controls/index.js +4 -4
  249. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  250. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +81 -102
  251. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  252. package/build-module/search/edit.js +4 -5
  253. package/build-module/search/edit.js.map +1 -1
  254. package/build-module/site-logo/edit.js +8 -11
  255. package/build-module/site-logo/edit.js.map +1 -1
  256. package/build-module/site-tagline/edit.js +23 -11
  257. package/build-module/site-tagline/edit.js.map +1 -1
  258. package/build-module/site-title/edit/index.js +22 -10
  259. package/build-module/site-title/edit/index.js.map +1 -1
  260. package/build-module/social-link/edit.js +11 -2
  261. package/build-module/social-link/edit.js.map +1 -1
  262. package/build-module/social-link/index.js +3 -0
  263. package/build-module/social-link/index.js.map +1 -1
  264. package/build-module/spacer/controls.js +4 -8
  265. package/build-module/spacer/controls.js.map +1 -1
  266. package/build-module/table/deprecated.js +282 -27
  267. package/build-module/table/deprecated.js.map +1 -1
  268. package/build-module/table/state.js +3 -3
  269. package/build-module/table/state.js.map +1 -1
  270. package/build-module/table-of-contents/edit.js +1 -3
  271. package/build-module/table-of-contents/edit.js.map +1 -1
  272. package/build-module/tag-cloud/edit.js +1 -1
  273. package/build-module/tag-cloud/edit.js.map +1 -1
  274. package/build-module/tag-cloud/index.js +8 -0
  275. package/build-module/tag-cloud/index.js.map +1 -1
  276. package/build-module/utils/clean-empty-object.js +5 -5
  277. package/build-module/utils/clean-empty-object.js.map +1 -1
  278. package/build-module/video/deprecated.js +147 -0
  279. package/build-module/video/deprecated.js.map +1 -0
  280. package/build-module/video/edit.js +45 -9
  281. package/build-module/video/edit.js.map +1 -1
  282. package/build-module/video/index.js +2 -0
  283. package/build-module/video/index.js.map +1 -1
  284. package/build-module/video/tracks-editor.js +4 -29
  285. package/build-module/video/tracks-editor.js.map +1 -1
  286. package/build-style/archives/style-rtl.css +4 -0
  287. package/build-style/archives/style.css +4 -0
  288. package/build-style/button/style-rtl.css +1 -0
  289. package/build-style/button/style.css +1 -0
  290. package/build-style/comment-template/style-rtl.css +1 -0
  291. package/build-style/comment-template/style.css +1 -0
  292. package/build-style/comments/editor-rtl.css +1 -0
  293. package/build-style/comments/editor.css +1 -0
  294. package/build-style/comments/style-rtl.css +1 -0
  295. package/build-style/comments/style.css +1 -0
  296. package/build-style/cover/editor-rtl.css +4 -0
  297. package/build-style/cover/editor.css +4 -0
  298. package/build-style/editor-rtl.css +13 -21
  299. package/build-style/editor.css +13 -21
  300. package/build-style/group/editor-rtl.css +1 -0
  301. package/build-style/group/editor.css +1 -0
  302. package/build-style/image/editor-rtl.css +1 -1
  303. package/build-style/image/editor.css +1 -1
  304. package/build-style/navigation/editor-rtl.css +5 -4
  305. package/build-style/navigation/editor.css +5 -4
  306. package/build-style/navigation/style-rtl.css +3 -1
  307. package/build-style/navigation/style.css +3 -1
  308. package/build-style/paragraph/editor-rtl.css +0 -16
  309. package/build-style/paragraph/editor.css +0 -16
  310. package/build-style/post-comments-form/style-rtl.css +3 -0
  311. package/build-style/post-comments-form/style.css +3 -0
  312. package/build-style/site-logo/editor-rtl.css +1 -0
  313. package/build-style/site-logo/editor.css +1 -0
  314. package/build-style/style-rtl.css +16 -1
  315. package/build-style/style.css +16 -1
  316. package/build-style/tag-cloud/style-rtl.css +3 -0
  317. package/build-style/tag-cloud/style.css +3 -0
  318. package/package.json +29 -28
  319. package/src/archives/edit.js +1 -0
  320. package/src/archives/style.scss +5 -0
  321. package/src/audio/edit.js +79 -24
  322. package/src/avatar/index.php +1 -1
  323. package/src/button/edit.js +1 -1
  324. package/src/button/style.scss +2 -0
  325. package/src/buttons/edit.native.js +1 -1
  326. package/src/code/test/__snapshots__/edit.native.js.snap +13 -0
  327. package/src/code/test/edit.native.js +46 -32
  328. package/src/comment-template/block.json +6 -2
  329. package/src/comment-template/edit.js +47 -34
  330. package/src/comment-template/style.scss +2 -0
  331. package/src/comments/block.json +5 -1
  332. package/src/comments/edit/placeholder.js +1 -7
  333. package/src/comments/style.scss +2 -0
  334. package/src/comments-title/edit.js +24 -1
  335. package/src/cover/edit/index.js +2 -7
  336. package/src/cover/edit/inspector-controls.js +11 -13
  337. package/src/cover/edit/use-cover-is-dark.js +11 -11
  338. package/src/cover/editor.scss +7 -0
  339. package/src/embed/deprecated.js +53 -26
  340. package/src/embed/variations.js +1 -1
  341. package/src/file/deprecated.js +130 -2
  342. package/src/file/transforms.js +3 -8
  343. package/src/gallery/deprecated.js +129 -4
  344. package/src/gallery/gallery.js +2 -0
  345. package/src/gallery/index.php +19 -10
  346. package/src/gallery/transforms.js +8 -5
  347. package/src/gallery/use-image-sizes.js +3 -2
  348. package/src/gallery/v1/edit.js +4 -3
  349. package/src/group/edit.js +10 -2
  350. package/src/group/editor.scss +1 -0
  351. package/src/image/edit.native.js +1 -1
  352. package/src/image/editor.scss +4 -1
  353. package/src/image/image.js +75 -33
  354. package/src/image/transforms.js +1 -7
  355. package/src/latest-posts/edit.js +2 -2
  356. package/src/list/test/edit.native.js +102 -3
  357. package/src/list/transforms.js +11 -0
  358. package/src/list/utils.js +3 -11
  359. package/src/list-item/block.json +14 -1
  360. package/src/list-item/edit.js +2 -1
  361. package/src/list-item/edit.native.js +2 -1
  362. package/src/list-item/hooks/use-merge.js +4 -23
  363. package/src/list-item/hooks/use-outdent-list-item.js +9 -8
  364. package/src/navigation/block.json +4 -1
  365. package/src/navigation/edit/index.js +61 -37
  366. package/src/navigation/edit/inner-blocks.js +2 -5
  367. package/src/navigation/edit/unsaved-inner-blocks.js +9 -2
  368. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +32 -5
  369. package/src/navigation/edit/use-create-navigation-menu.js +2 -5
  370. package/src/navigation/editor.scss +5 -4
  371. package/src/navigation/index.php +103 -6
  372. package/src/navigation/style.scss +3 -1
  373. package/src/navigation-link/edit.js +6 -5
  374. package/src/navigation-link/index.php +8 -1
  375. package/src/navigation-submenu/edit.js +7 -5
  376. package/src/navigation-submenu/index.php +8 -1
  377. package/src/page-list/block.json +1 -5
  378. package/src/page-list/edit.js +36 -22
  379. package/src/page-list/index.php +8 -6
  380. package/src/paragraph/edit.js +1 -14
  381. package/src/paragraph/editor.scss +0 -20
  382. package/src/pattern/edit.js +10 -3
  383. package/src/post-comments-count/block.json +4 -0
  384. package/src/post-comments-form/block.json +4 -0
  385. package/src/post-comments-form/form.js +2 -3
  386. package/src/post-comments-form/style.scss +3 -0
  387. package/src/post-comments-link/block.json +4 -0
  388. package/src/post-content/edit.js +8 -4
  389. package/src/pullquote/deprecated.js +7 -7
  390. package/src/query/edit/inspector-controls/index.js +4 -3
  391. package/src/query/edit/inspector-controls/taxonomy-controls.js +82 -87
  392. package/src/rss/index.php +3 -3
  393. package/src/search/edit.js +7 -2
  394. package/src/search/index.php +21 -13
  395. package/src/site-logo/edit.js +12 -10
  396. package/src/site-logo/editor.scss +1 -0
  397. package/src/site-tagline/edit.js +25 -18
  398. package/src/site-title/edit/index.js +26 -12
  399. package/src/social-link/block.json +3 -0
  400. package/src/social-link/edit.js +8 -1
  401. package/src/social-link/index.php +11 -7
  402. package/src/spacer/controls.js +10 -12
  403. package/src/table/deprecated.js +587 -348
  404. package/src/table/state.js +3 -3
  405. package/src/table-of-contents/edit.js +1 -3
  406. package/src/tag-cloud/block.json +8 -0
  407. package/src/tag-cloud/edit.js +1 -1
  408. package/src/tag-cloud/style.scss +3 -0
  409. package/src/template-part/index.php +4 -0
  410. package/src/utils/clean-empty-object.js +5 -6
  411. package/src/video/deprecated.js +57 -0
  412. package/src/video/edit.js +71 -23
  413. package/src/video/index.js +2 -0
  414. package/src/video/tracks-editor.js +12 -28
  415. package/build/paragraph/drop-zone.js +0 -99
  416. package/build/paragraph/drop-zone.js.map +0 -1
  417. package/build-module/paragraph/drop-zone.js +0 -88
  418. package/build-module/paragraph/drop-zone.js.map +0 -1
  419. package/src/paragraph/drop-zone.js +0 -105
package/src/audio/edit.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  SelectControl,
14
14
  Spinner,
15
15
  ToggleControl,
16
+ ToolbarButton,
16
17
  } from '@wordpress/components';
17
18
  import {
18
19
  BlockControls,
@@ -25,12 +26,13 @@ import {
25
26
  store as blockEditorStore,
26
27
  __experimentalGetElementClassName,
27
28
  } from '@wordpress/block-editor';
28
- import { useEffect } from '@wordpress/element';
29
+ import { useEffect, useState, useCallback } from '@wordpress/element';
29
30
  import { __, _x } from '@wordpress/i18n';
30
31
  import { useDispatch, useSelect } from '@wordpress/data';
31
- import { audio as icon } from '@wordpress/icons';
32
+ import { audio as icon, caption as captionIcon } from '@wordpress/icons';
32
33
  import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
33
34
  import { store as noticesStore } from '@wordpress/notices';
35
+ import { usePrevious } from '@wordpress/compose';
34
36
 
35
37
  /**
36
38
  * Internal dependencies
@@ -48,6 +50,8 @@ function AudioEdit( {
48
50
  insertBlocksAfter,
49
51
  } ) {
50
52
  const { id, autoplay, caption, loop, preload, src } = attributes;
53
+ const prevCaption = usePrevious( caption );
54
+ const [ showCaption, setShowCaption ] = useState( !! caption );
51
55
  const isTemporaryAudio = ! id && isBlobURL( src );
52
56
  const mediaUpload = useSelect( ( select ) => {
53
57
  const { getSettings } = select( blockEditorStore );
@@ -69,6 +73,30 @@ function AudioEdit( {
69
73
  }
70
74
  }, [] );
71
75
 
76
+ // We need to show the caption when changes come from
77
+ // history navigation(undo/redo).
78
+ useEffect( () => {
79
+ if ( caption && ! prevCaption ) {
80
+ setShowCaption( true );
81
+ }
82
+ }, [ caption, prevCaption ] );
83
+
84
+ // Focus the caption when we click to add one.
85
+ const captionRef = useCallback(
86
+ ( node ) => {
87
+ if ( node && ! caption ) {
88
+ node.focus();
89
+ }
90
+ },
91
+ [ caption ]
92
+ );
93
+
94
+ useEffect( () => {
95
+ if ( ! isSelected && ! caption ) {
96
+ setShowCaption( false );
97
+ }
98
+ }, [ isSelected, caption ] );
99
+
72
100
  function toggleAttribute( attribute ) {
73
101
  return ( newValue ) => {
74
102
  setAttributes( { [ attribute ]: newValue } );
@@ -106,12 +134,20 @@ function AudioEdit( {
106
134
  if ( ! media || ! media.url ) {
107
135
  // In this case there was an error and we should continue in the editing state
108
136
  // previous attributes should be removed because they may be temporary blob urls.
109
- setAttributes( { src: undefined, id: undefined } );
137
+ setAttributes( {
138
+ src: undefined,
139
+ id: undefined,
140
+ caption: undefined,
141
+ } );
110
142
  return;
111
143
  }
112
144
  // Sets the block's attribute and updates the edit component from the
113
145
  // selected media, then switches off the editing UI.
114
- setAttributes( { src: media.url, id: media.id } );
146
+ setAttributes( {
147
+ src: media.url,
148
+ id: media.id,
149
+ caption: media.caption,
150
+ } );
115
151
  }
116
152
 
117
153
  const classes = classnames( className, {
@@ -140,6 +176,23 @@ function AudioEdit( {
140
176
 
141
177
  return (
142
178
  <>
179
+ <BlockControls group="block">
180
+ <ToolbarButton
181
+ onClick={ () => {
182
+ setShowCaption( ! showCaption );
183
+ if ( showCaption && caption ) {
184
+ setAttributes( { caption: undefined } );
185
+ }
186
+ } }
187
+ icon={ captionIcon }
188
+ isPressed={ showCaption }
189
+ label={
190
+ showCaption
191
+ ? __( 'Remove caption' )
192
+ : __( 'Add caption' )
193
+ }
194
+ />
195
+ </BlockControls>
143
196
  <BlockControls group="other">
144
197
  <MediaReplaceFlow
145
198
  mediaId={ id }
@@ -195,26 +248,28 @@ function AudioEdit( {
195
248
  <audio controls="controls" src={ src } />
196
249
  </Disabled>
197
250
  { isTemporaryAudio && <Spinner /> }
198
- { ( ! RichText.isEmpty( caption ) || isSelected ) && (
199
- <RichText
200
- tagName="figcaption"
201
- className={ __experimentalGetElementClassName(
202
- 'caption'
203
- ) }
204
- aria-label={ __( 'Audio caption text' ) }
205
- placeholder={ __( 'Add caption' ) }
206
- value={ caption }
207
- onChange={ ( value ) =>
208
- setAttributes( { caption: value } )
209
- }
210
- inlineToolbar
211
- __unstableOnSplitAtEnd={ () =>
212
- insertBlocksAfter(
213
- createBlock( getDefaultBlockName() )
214
- )
215
- }
216
- />
217
- ) }
251
+ { showCaption &&
252
+ ( ! RichText.isEmpty( caption ) || isSelected ) && (
253
+ <RichText
254
+ tagName="figcaption"
255
+ className={ __experimentalGetElementClassName(
256
+ 'caption'
257
+ ) }
258
+ ref={ captionRef }
259
+ aria-label={ __( 'Audio caption text' ) }
260
+ placeholder={ __( 'Add caption' ) }
261
+ value={ caption }
262
+ onChange={ ( value ) =>
263
+ setAttributes( { caption: value } )
264
+ }
265
+ inlineToolbar
266
+ __unstableOnSplitAtEnd={ () =>
267
+ insertBlocksAfter(
268
+ createBlock( getDefaultBlockName() )
269
+ )
270
+ }
271
+ />
272
+ ) }
218
273
  </figure>
219
274
  </>
220
275
  );
@@ -127,7 +127,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
127
127
  $label = 'aria-label="' . sprintf( esc_attr__( '(%s website link, opens in a new tab)' ), $comment->comment_author ) . '"';
128
128
  }
129
129
  // translators: %1$s: Comment Author website link. %2$s: Link target. %3$s Aria label. %4$s Avatar image.
130
- $avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', $comment->comment_author_url, esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
130
+ $avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( $comment->comment_author_url ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
131
131
  }
132
132
  return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
133
133
  }
@@ -221,7 +221,7 @@ function ButtonEdit( props ) {
221
221
  </BlockControls>
222
222
  { isSelected && ( isEditingURL || isURLSet ) && (
223
223
  <Popover
224
- position="bottom center"
224
+ placement="bottom"
225
225
  onClose={ () => {
226
226
  setIsEditingURL( false );
227
227
  richTextRef.current?.focus();
@@ -113,4 +113,6 @@ $blocks-block__margin: 0.5em;
113
113
  .wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background),
114
114
  .wp-block-button .wp-block-button__link.is-style-outline:not(.has-background) {
115
115
  background-color: transparent;
116
+ // background-image is required to overwrite a gradient background
117
+ background-image: none;
116
118
  }
@@ -139,7 +139,7 @@ export default function ButtonsEdit( {
139
139
  }
140
140
  popoverProps={ {
141
141
  position: 'bottom right',
142
- isAlternate: true,
142
+ variant: 'toolbar',
143
143
  } }
144
144
  />
145
145
  </BlockControls>
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Code renders given text without crashing 1`] = `
4
+ "<!-- wp:code -->
5
+ <pre class=\\"wp-block-code\\"><code>Sample text</code></pre>
6
+ <!-- /wp:code -->"
7
+ `;
8
+
9
+ exports[`Code renders without crashing 1`] = `
10
+ "<!-- wp:code -->
11
+ <pre class=\\"wp-block-code\\"><code></code></pre>
12
+ <!-- /wp:code -->"
13
+ `;
@@ -1,51 +1,65 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import renderer from 'react-test-renderer';
5
- import { TextInput } from 'react-native';
4
+ import {
5
+ fireEvent,
6
+ getEditorHtml,
7
+ initializeEditor,
8
+ addBlock,
9
+ getBlock,
10
+ } from 'test/helpers';
6
11
 
7
12
  /**
8
13
  * WordPress dependencies
9
14
  */
10
- import { BlockEdit } from '@wordpress/block-editor';
11
- import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { metadata, settings, name } from '../index';
17
-
18
- const Code = ( { clientId, ...props } ) => (
19
- <BlockEdit name={ name } clientId={ clientId || 0 } { ...props } />
20
- );
15
+ import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
16
+ import { registerCoreBlocks } from '@wordpress/block-library';
21
17
 
22
18
  describe( 'Code', () => {
23
19
  beforeAll( () => {
24
- registerBlockType( name, {
25
- ...metadata,
26
- ...settings,
27
- } );
20
+ // Register all core blocks
21
+ registerCoreBlocks();
28
22
  } );
29
23
 
30
24
  afterAll( () => {
31
- unregisterBlockType( name );
25
+ // Clean up registered blocks
26
+ getBlockTypes().forEach( ( block ) => {
27
+ unregisterBlockType( block.name );
28
+ } );
32
29
  } );
33
30
 
34
- it( 'renders without crashing', () => {
35
- const component = renderer.create(
36
- <Code attributes={ { content: '' } } />
37
- );
38
- const rendered = component.toJSON();
39
- expect( rendered ).toBeTruthy();
31
+ it( 'renders without crashing', async () => {
32
+ const screen = await initializeEditor();
33
+
34
+ // Add block
35
+ await addBlock( screen, 'Code' );
36
+
37
+ // Get block
38
+ const codeBlock = await getBlock( screen, 'Code' );
39
+ expect( codeBlock ).toBeVisible();
40
+
41
+ expect( getEditorHtml() ).toMatchSnapshot();
40
42
  } );
41
43
 
42
- it( 'renders given text without crashing', () => {
43
- const component = renderer.create(
44
- <Code attributes={ { content: 'sample text' } } />
45
- );
46
- const testInstance = component.root;
47
- const textInput = testInstance.findByType( TextInput );
48
- expect( textInput ).toBeTruthy();
49
- expect( textInput.props.value ).toBe( 'sample text' );
44
+ it( 'renders given text without crashing', async () => {
45
+ const initialHtml = `<!-- wp:code -->
46
+ <pre class="wp-block-code"><code>Sample text</code></pre>
47
+ <!-- /wp:code -->`;
48
+
49
+ const screen = await initializeEditor( {
50
+ initialHtml,
51
+ } );
52
+ const { getByDisplayValue } = screen;
53
+
54
+ // Get block
55
+ const codeBlock = await getBlock( screen, 'Code' );
56
+ expect( codeBlock ).toBeVisible();
57
+ fireEvent.press( codeBlock );
58
+
59
+ // Get initial text
60
+ const codeBlockText = getByDisplayValue( 'Sample text' );
61
+ expect( codeBlockText ).toBeVisible();
62
+
63
+ expect( getEditorHtml() ).toMatchSnapshot();
50
64
  } );
51
65
  } );
@@ -9,9 +9,13 @@
9
9
  "textdomain": "default",
10
10
  "usesContext": [ "postId" ],
11
11
  "supports": {
12
- "reusable": false,
13
- "html": false,
14
12
  "align": true,
13
+ "html": false,
14
+ "reusable": false,
15
+ "spacing": {
16
+ "margin": true,
17
+ "padding": true
18
+ },
15
19
  "typography": {
16
20
  "fontSize": true,
17
21
  "lineHeight": true,
@@ -37,6 +37,7 @@ const TEMPLATE = [
37
37
  *
38
38
  * @param {Object} settings Discussion Settings.
39
39
  * @param {number} [settings.perPage] - Comments per page setting or block attribute.
40
+ * @param {boolean} [settings.pageComments] - Enable break comments into pages setting.
40
41
  * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
41
42
  * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.
42
43
  *
@@ -45,42 +46,53 @@ const TEMPLATE = [
45
46
  */
46
47
  const getCommentsPlaceholder = ( {
47
48
  perPage,
49
+ pageComments,
48
50
  threadComments,
49
51
  threadCommentsDepth,
50
52
  } ) => {
51
- // In case that `threadCommentsDepth` is falsy, we default to a somewhat
52
- // arbitrary value of 3.
53
- // In case that the value is set but larger than 3 we truncate it to 3.
54
- const commentsDepth = Math.min( threadCommentsDepth || 3, 3 );
53
+ // Limit commentsDepth to 3
54
+ const commentsDepth = ! threadComments
55
+ ? 1
56
+ : Math.min( threadCommentsDepth, 3 );
55
57
 
56
- // We set a limit in order not to overload the editor of empty comments.
57
- const defaultCommentsToShow =
58
- perPage <= commentsDepth ? perPage : commentsDepth;
59
- if ( ! threadComments || defaultCommentsToShow === 1 ) {
60
- // If displaying threaded comments is disabled, we only show one comment
61
- // A commentId is negative in order to avoid conflicts with the actual comments.
62
- return [ { commentId: -1, children: [] } ];
63
- } else if ( defaultCommentsToShow === 2 ) {
64
- return [
65
- {
66
- commentId: -1,
67
- children: [ { commentId: -2, children: [] } ],
68
- },
69
- ];
70
- }
58
+ const buildChildrenComment = ( commentsLevel ) => {
59
+ // Render children comments until commentsDepth is reached
60
+ if ( commentsLevel < commentsDepth ) {
61
+ const nextLevel = commentsLevel + 1;
71
62
 
72
- // In case that the value is set but larger than 3 we truncate it to 3.
73
- return [
74
- {
75
- commentId: -1,
76
- children: [
63
+ return [
77
64
  {
78
- commentId: -2,
79
- children: [ { commentId: -3, children: [] } ],
65
+ commentId: -( commentsLevel + 3 ),
66
+ children: buildChildrenComment( nextLevel ),
80
67
  },
81
- ],
82
- },
68
+ ];
69
+ }
70
+ return [];
71
+ };
72
+
73
+ // Add the first comment and its children
74
+ const placeholderComments = [
75
+ { commentId: -1, children: buildChildrenComment( 1 ) },
83
76
  ];
77
+
78
+ // Add a second comment unless the break comments setting is active and set to less than 2, and there is one nested comment max
79
+ if ( ( ! pageComments || perPage >= 2 ) && commentsDepth < 3 ) {
80
+ placeholderComments.push( {
81
+ commentId: -2,
82
+ children: [],
83
+ } );
84
+ }
85
+
86
+ // Add a third comment unless the break comments setting is active and set to less than 3, and there aren't nested comments
87
+ if ( ( ! pageComments || perPage >= 3 ) && commentsDepth < 2 ) {
88
+ placeholderComments.push( {
89
+ commentId: -3,
90
+ children: [],
91
+ } );
92
+ }
93
+
94
+ // In case that the value is set but larger than 3 we truncate it to 3.
95
+ return placeholderComments;
84
96
  };
85
97
 
86
98
  /**
@@ -114,12 +126,11 @@ function CommentTemplateInnerBlocks( {
114
126
  : null }
115
127
 
116
128
  { /* To avoid flicker when switching active block contexts, a preview
117
- is ALWAYS rendered and the preview for the active block is hidden.
118
- This ensures that when switching the active block, the component is not
119
- mounted again but rather it only toggles the `isHidden` prop.
120
-
121
- The same strategy is used for preventing the flicker in the Post Template
122
- block. */ }
129
+ is ALWAYS rendered and the preview for the active block is hidden.
130
+ This ensures that when switching the active block, the component is not
131
+ mounted again but rather it only toggles the `isHidden` prop.
132
+ The same strategy is used for preventing the flicker in the Post Template
133
+ block. */ }
123
134
  <MemoizedCommentTemplatePreview
124
135
  blocks={ blocks }
125
136
  commentId={ comment.commentId }
@@ -239,6 +250,7 @@ export default function CommentTemplateEdit( {
239
250
  threadCommentsDepth,
240
251
  threadComments,
241
252
  commentsPerPage,
253
+ pageComments,
242
254
  } = useSelect( ( select ) => {
243
255
  const { getSettings } = select( blockEditorStore );
244
256
  return getSettings().__experimentalDiscussionSettings;
@@ -282,6 +294,7 @@ export default function CommentTemplateEdit( {
282
294
  if ( ! postId ) {
283
295
  commentTree = getCommentsPlaceholder( {
284
296
  perPage: commentsPerPage,
297
+ pageComments,
285
298
  threadComments,
286
299
  threadCommentsDepth,
287
300
  } );
@@ -1,4 +1,6 @@
1
1
  .wp-block-comment-template {
2
+ // This block has customizable padding, border-box makes that more predictable.
3
+ box-sizing: border-box;
2
4
  margin-bottom: 0;
3
5
  max-width: 100%;
4
6
  list-style: none;
@@ -18,7 +18,6 @@
18
18
  },
19
19
  "supports": {
20
20
  "align": [ "wide", "full" ],
21
- "html": false,
22
21
  "color": {
23
22
  "gradients": true,
24
23
  "link": true,
@@ -28,6 +27,11 @@
28
27
  "link": true
29
28
  }
30
29
  },
30
+ "html": false,
31
+ "spacing": {
32
+ "margin": true,
33
+ "padding": true
34
+ },
31
35
  "typography": {
32
36
  "fontSize": true,
33
37
  "lineHeight": true,
@@ -5,7 +5,6 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
5
5
  import { __, sprintf } from '@wordpress/i18n';
6
6
  import { useSelect } from '@wordpress/data';
7
7
  import { useEntityProp } from '@wordpress/core-data';
8
- import { useDisabled } from '@wordpress/compose';
9
8
 
10
9
  /**
11
10
  * Internal dependencies
@@ -22,13 +21,8 @@ export default function PostCommentsPlaceholder( { postType, postId } ) {
22
21
  .__experimentalDiscussionSettings
23
22
  );
24
23
 
25
- const disabledRef = useDisabled();
26
-
27
24
  return (
28
- <div
29
- className="wp-block-comments__legacy-placeholder"
30
- ref={ disabledRef }
31
- >
25
+ <div className="wp-block-comments__legacy-placeholder" inert="true">
32
26
  <h3>
33
27
  {
34
28
  /* translators: %s: Post title. */
@@ -1,5 +1,7 @@
1
1
  /* Styles for backwards compatibility with the legacy `post-comments` block */
2
2
  .wp-block-post-comments {
3
+ // This block has customizable padding, border-box makes that more predictable.
4
+ box-sizing: border-box;
3
5
 
4
6
  /* utility classes */
5
7
  .alignleft {
@@ -11,11 +11,13 @@ import {
11
11
  BlockControls,
12
12
  useBlockProps,
13
13
  InspectorControls,
14
+ store as blockEditorStore,
14
15
  } from '@wordpress/block-editor';
15
16
  import { __, _n, sprintf } from '@wordpress/i18n';
16
17
  import { useEntityProp } from '@wordpress/core-data';
17
18
  import { PanelBody, ToggleControl } from '@wordpress/components';
18
19
  import { useState, useEffect } from '@wordpress/element';
20
+ import { useSelect } from '@wordpress/data';
19
21
  import apiFetch from '@wordpress/api-fetch';
20
22
  import { addQueryArgs } from '@wordpress/url';
21
23
 
@@ -39,9 +41,30 @@ export default function Edit( {
39
41
  } ),
40
42
  } );
41
43
 
44
+ const {
45
+ threadCommentsDepth,
46
+ threadComments,
47
+ commentsPerPage,
48
+ pageComments,
49
+ } = useSelect( ( select ) => {
50
+ const { getSettings } = select( blockEditorStore );
51
+ return getSettings().__experimentalDiscussionSettings;
52
+ } );
53
+
42
54
  useEffect( () => {
43
55
  if ( isSiteEditor ) {
44
- setCommentsCount( 3 );
56
+ // Match the number of comments that will be shown in the comment-template/edit.js placeholder
57
+
58
+ const nestedCommentsNumber = threadComments
59
+ ? Math.min( threadCommentsDepth, 3 ) - 1
60
+ : 0;
61
+ const topLevelCommentsNumber = pageComments ? commentsPerPage : 3;
62
+
63
+ const commentsNumber =
64
+ parseInt( nestedCommentsNumber ) +
65
+ parseInt( topLevelCommentsNumber );
66
+
67
+ setCommentsCount( Math.min( commentsNumber, 3 ) );
45
68
  return;
46
69
  }
47
70
  const currentPostId = postId;
@@ -131,13 +131,7 @@ function CoverEdit( {
131
131
  createErrorNotice( message, { type: 'snackbar' } );
132
132
  };
133
133
 
134
- const mediaElement = useRef();
135
- const isCoverDark = useCoverIsDark(
136
- url,
137
- dimRatio,
138
- overlayColor.color,
139
- mediaElement
140
- );
134
+ const isCoverDark = useCoverIsDark( url, dimRatio, overlayColor.color );
141
135
 
142
136
  useEffect( () => {
143
137
  // This side-effect should not create an undo level.
@@ -201,6 +195,7 @@ function CoverEdit( {
201
195
  }
202
196
  );
203
197
 
198
+ const mediaElement = useRef();
204
199
  const currentSettings = {
205
200
  isVideoBackground,
206
201
  isImageBackground,
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import { Fragment, useMemo } from '@wordpress/element';
5
5
  import {
6
- BaseControl,
7
6
  Button,
8
7
  ExternalLink,
9
8
  FocalPointPicker,
@@ -73,18 +72,17 @@ function CoverHeightInput( {
73
72
  const min = isPx ? COVER_MIN_HEIGHT : 0;
74
73
 
75
74
  return (
76
- <BaseControl label={ __( 'Minimum height of cover' ) } id={ inputId }>
77
- <UnitControl
78
- id={ inputId }
79
- isResetValueOnUnitChange
80
- min={ min }
81
- onChange={ handleOnChange }
82
- onUnitChange={ onUnitChange }
83
- style={ { maxWidth: 80 } }
84
- units={ units }
85
- value={ computedValue }
86
- />
87
- </BaseControl>
75
+ <UnitControl
76
+ label={ __( 'Minimum height of cover' ) }
77
+ id={ inputId }
78
+ isResetValueOnUnitChange
79
+ min={ min }
80
+ onChange={ handleOnChange }
81
+ onUnitChange={ onUnitChange }
82
+ __unstableInputWidth={ '80px' }
83
+ units={ units }
84
+ value={ computedValue }
85
+ />
88
86
  );
89
87
  }
90
88
  export default function CoverInspectorControls( {
@@ -8,6 +8,7 @@ import { colord } from 'colord';
8
8
  * WordPress dependencies
9
9
  */
10
10
  import { useEffect, useState } from '@wordpress/element';
11
+ import { applyFilters } from '@wordpress/hooks';
11
12
 
12
13
  function retrieveFastAverageColor() {
13
14
  if ( ! retrieveFastAverageColor.fastAverageColor ) {
@@ -25,34 +26,33 @@ function retrieveFastAverageColor() {
25
26
  * color are set, dimRatio is used to decide what is used
26
27
  * for background darkness checking purposes.
27
28
  * @param {?string} overlayColor String containing the overlay color value if one exists.
28
- * @param {?Object} elementRef If a media background is set, elementRef should contain a reference to a
29
- * dom element that renders that media.
30
29
  *
31
30
  * @return {boolean} True if the cover background is considered "dark" and false otherwise.
32
31
  */
33
- export default function useCoverIsDark(
34
- url,
35
- dimRatio = 50,
36
- overlayColor,
37
- elementRef
38
- ) {
32
+ export default function useCoverIsDark( url, dimRatio = 50, overlayColor ) {
39
33
  const [ isDark, setIsDark ] = useState( false );
40
34
  useEffect( () => {
41
35
  // If opacity is lower than 50 the dominant color is the image or video color,
42
36
  // so use that color for the dark mode computation.
43
- if ( url && dimRatio <= 50 && elementRef.current ) {
37
+ if ( url && dimRatio <= 50 ) {
38
+ const imgCrossOrigin = applyFilters(
39
+ 'media.crossOrigin',
40
+ undefined,
41
+ url
42
+ );
44
43
  retrieveFastAverageColor()
45
- .getColorAsync( elementRef.current, {
44
+ .getColorAsync( url, {
46
45
  // Previously the default color was white, but that changed
47
46
  // in v6.0.0 so it has to be manually set now.
48
47
  defaultColor: [ 255, 255, 255, 255 ],
49
48
  // Errors that come up don't reject the promise, so error
50
49
  // logging has to be silenced with this option.
51
50
  silent: process.env.NODE_ENV === 'production',
51
+ crossOrigin: imgCrossOrigin,
52
52
  } )
53
53
  .then( ( color ) => setIsDark( color.isDark ) );
54
54
  }
55
- }, [ url, url && dimRatio <= 50 && elementRef.current, setIsDark ] );
55
+ }, [ url, url && dimRatio <= 50, setIsDark ] );
56
56
  useEffect( () => {
57
57
  // If opacity is greater than 50 the dominant color is the overlay color,
58
58
  // so use that color for the dark mode computation.