@wordpress/block-library 8.29.0 → 8.31.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 (527) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/audio/edit.js +7 -17
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/audio/edit.native.js.map +1 -1
  5. package/build/avatar/edit.js.map +1 -1
  6. package/build/block/deprecated.js +71 -11
  7. package/build/block/deprecated.js.map +1 -1
  8. package/build/block/edit.js +65 -31
  9. package/build/block/edit.js.map +1 -1
  10. package/build/button/edit.js +2 -2
  11. package/build/button/edit.js.map +1 -1
  12. package/build/buttons/edit.native.js.map +1 -1
  13. package/build/buttons/transforms.js +16 -2
  14. package/build/buttons/transforms.js.map +1 -1
  15. package/build/code/save.js +3 -1
  16. package/build/code/save.js.map +1 -1
  17. package/build/code/transforms.js +17 -6
  18. package/build/code/transforms.js.map +1 -1
  19. package/build/columns/edit.js +3 -2
  20. package/build/columns/edit.js.map +1 -1
  21. package/build/comment-author-avatar/edit.js +1 -1
  22. package/build/comment-author-avatar/edit.js.map +1 -1
  23. package/build/cover/edit/block-controls.js +14 -3
  24. package/build/cover/edit/block-controls.js.map +1 -1
  25. package/build/cover/edit/index.js +2 -1
  26. package/build/cover/edit/index.js.map +1 -1
  27. package/build/cover/edit/inspector-controls.js.map +1 -1
  28. package/build/cover/edit/resizable-cover-popover.js +0 -6
  29. package/build/cover/edit/resizable-cover-popover.js.map +1 -1
  30. package/build/cover/edit.native.js.map +1 -1
  31. package/build/details/edit.js +1 -0
  32. package/build/details/edit.js.map +1 -1
  33. package/build/file/deprecated.js.map +1 -1
  34. package/build/file/edit.js +8 -13
  35. package/build/file/edit.js.map +1 -1
  36. package/build/file/edit.native.js.map +1 -1
  37. package/build/file/save.js.map +1 -1
  38. package/build/form-input/edit.js +1 -1
  39. package/build/form-input/edit.js.map +1 -1
  40. package/build/gallery/edit.js.map +1 -1
  41. package/build/gallery/gallery.native.js.map +1 -1
  42. package/build/gallery/v1/edit.js.map +1 -1
  43. package/build/gallery/v1/gallery.native.js.map +1 -1
  44. package/build/heading/index.js +4 -3
  45. package/build/heading/index.js.map +1 -1
  46. package/build/heading/transforms.js +17 -4
  47. package/build/heading/transforms.js.map +1 -1
  48. package/build/image/edit.js +8 -4
  49. package/build/image/edit.js.map +1 -1
  50. package/build/image/edit.native.js.map +1 -1
  51. package/build/image/image.js +22 -8
  52. package/build/image/image.js.map +1 -1
  53. package/build/latest-posts/edit.native.js.map +1 -1
  54. package/build/list/ordered-list-settings.js +1 -1
  55. package/build/list/ordered-list-settings.js.map +1 -1
  56. package/build/list-item/edit.js +1 -3
  57. package/build/list-item/edit.js.map +1 -1
  58. package/build/list-item/edit.native.js.map +1 -1
  59. package/build/list-item/hooks/index.js +0 -7
  60. package/build/list-item/hooks/index.js.map +1 -1
  61. package/build/list-item/hooks/use-indent-list-item.js +1 -0
  62. package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
  63. package/build/list-item/hooks/use-outdent-list-item.js +1 -0
  64. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  65. package/build/list-item/hooks/use-space.js +16 -7
  66. package/build/list-item/hooks/use-space.js.map +1 -1
  67. package/build/list-item/index.js +4 -1
  68. package/build/list-item/index.js.map +1 -1
  69. package/build/media-text/edit.js +33 -9
  70. package/build/media-text/edit.js.map +1 -1
  71. package/build/media-text/index.js +5 -0
  72. package/build/media-text/index.js.map +1 -1
  73. package/build/media-text/media-container.js +30 -11
  74. package/build/media-text/media-container.js.map +1 -1
  75. package/build/media-text/media-container.native.js +1 -1
  76. package/build/media-text/media-container.native.js.map +1 -1
  77. package/build/media-text/save.js +2 -2
  78. package/build/media-text/save.js.map +1 -1
  79. package/build/navigation/edit/index.js +23 -29
  80. package/build/navigation/edit/index.js.map +1 -1
  81. package/build/navigation/edit/navigation-menu-delete-control.js +12 -20
  82. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  83. package/build/navigation/edit/navigation-menu-selector.js +24 -23
  84. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  85. package/build/navigation/edit/placeholder/index.js +4 -4
  86. package/build/navigation/edit/placeholder/index.js.map +1 -1
  87. package/build/navigation/use-navigation-menu.js +15 -12
  88. package/build/navigation/use-navigation-menu.js.map +1 -1
  89. package/build/navigation-link/edit.js +12 -10
  90. package/build/navigation-link/edit.js.map +1 -1
  91. package/build/navigation-link/link-ui.js.map +1 -1
  92. package/build/navigation-submenu/edit.js +4 -0
  93. package/build/navigation-submenu/edit.js.map +1 -1
  94. package/build/paragraph/edit.native.js.map +1 -1
  95. package/build/pattern/edit.js +11 -0
  96. package/build/pattern/edit.js.map +1 -1
  97. package/build/post-author/edit.js +1 -0
  98. package/build/post-author/edit.js.map +1 -1
  99. package/build/post-excerpt/edit.js +1 -0
  100. package/build/post-excerpt/edit.js.map +1 -1
  101. package/build/post-featured-image/dimension-controls.js.map +1 -1
  102. package/build/post-featured-image/edit.js +12 -12
  103. package/build/post-featured-image/edit.js.map +1 -1
  104. package/build/post-featured-image/index.js +6 -0
  105. package/build/post-featured-image/index.js.map +1 -1
  106. package/build/post-navigation-link/edit.js +1 -0
  107. package/build/post-navigation-link/edit.js.map +1 -1
  108. package/build/post-terms/edit.js +2 -0
  109. package/build/post-terms/edit.js.map +1 -1
  110. package/build/post-title/edit.js +2 -2
  111. package/build/post-title/edit.js.map +1 -1
  112. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  113. package/build/query/utils.js +7 -5
  114. package/build/query/utils.js.map +1 -1
  115. package/build/query-pagination-next/edit.js.map +1 -1
  116. package/build/query-pagination-previous/edit.js.map +1 -1
  117. package/build/quote/deprecated.js +111 -12
  118. package/build/quote/deprecated.js.map +1 -1
  119. package/build/quote/edit.js +7 -7
  120. package/build/quote/edit.js.map +1 -1
  121. package/build/quote/index.js +1 -1
  122. package/build/quote/index.js.map +1 -1
  123. package/build/quote/save.js +2 -2
  124. package/build/quote/save.js.map +1 -1
  125. package/build/read-more/edit.js +1 -0
  126. package/build/read-more/edit.js.map +1 -1
  127. package/build/search/edit.js +3 -1
  128. package/build/search/edit.js.map +1 -1
  129. package/build/search/edit.native.js +2 -2
  130. package/build/search/edit.native.js.map +1 -1
  131. package/build/site-logo/edit.js +7 -2
  132. package/build/site-logo/edit.js.map +1 -1
  133. package/build/site-title/{edit/index.js → edit.js} +1 -1
  134. package/build/site-title/edit.js.map +1 -0
  135. package/build/social-link/edit.js +1 -1
  136. package/build/social-link/edit.js.map +1 -1
  137. package/build/social-link/icons/medium.js +1 -1
  138. package/build/social-link/icons/medium.js.map +1 -1
  139. package/build/social-link/icons/reddit.js +1 -1
  140. package/build/social-link/icons/reddit.js.map +1 -1
  141. package/build/social-links/edit.native.js.map +1 -1
  142. package/build/spacer/edit.js.map +1 -1
  143. package/build/table/deprecated.js +285 -175
  144. package/build/table/deprecated.js.map +1 -1
  145. package/build/table/index.js +1 -1
  146. package/build/table-of-contents/edit.js.map +1 -1
  147. package/build/template-part/edit/index.js +53 -1
  148. package/build/template-part/edit/index.js.map +1 -1
  149. package/build/template-part/edit/selection-modal.js +2 -8
  150. package/build/template-part/edit/selection-modal.js.map +1 -1
  151. package/build/template-part/edit/utils/map-template-part-to-block-pattern.js +30 -0
  152. package/build/template-part/edit/utils/map-template-part-to-block-pattern.js.map +1 -0
  153. package/build/utils/caption.js +15 -5
  154. package/build/utils/caption.js.map +1 -1
  155. package/build/utils/get-transformed-metadata.js +57 -0
  156. package/build/utils/get-transformed-metadata.js.map +1 -0
  157. package/build/utils/hooks.js +55 -4
  158. package/build/utils/hooks.js.map +1 -1
  159. package/build/video/edit-common-settings.js.map +1 -1
  160. package/build/video/edit.js +7 -16
  161. package/build/video/edit.js.map +1 -1
  162. package/build/video/edit.native.js +3 -8
  163. package/build/video/edit.native.js.map +1 -1
  164. package/build-module/audio/edit.js +10 -20
  165. package/build-module/audio/edit.js.map +1 -1
  166. package/build-module/audio/edit.native.js.map +1 -1
  167. package/build-module/avatar/edit.js.map +1 -1
  168. package/build-module/block/deprecated.js +71 -11
  169. package/build-module/block/deprecated.js.map +1 -1
  170. package/build-module/block/edit.js +66 -32
  171. package/build-module/block/edit.js.map +1 -1
  172. package/build-module/button/edit.js +3 -3
  173. package/build-module/button/edit.js.map +1 -1
  174. package/build-module/buttons/edit.native.js.map +1 -1
  175. package/build-module/buttons/transforms.js +16 -2
  176. package/build-module/buttons/transforms.js.map +1 -1
  177. package/build-module/code/save.js +3 -1
  178. package/build-module/code/save.js.map +1 -1
  179. package/build-module/code/transforms.js +17 -6
  180. package/build-module/code/transforms.js.map +1 -1
  181. package/build-module/columns/edit.js +3 -2
  182. package/build-module/columns/edit.js.map +1 -1
  183. package/build-module/comment-author-avatar/edit.js +1 -1
  184. package/build-module/comment-author-avatar/edit.js.map +1 -1
  185. package/build-module/cover/edit/block-controls.js +15 -4
  186. package/build-module/cover/edit/block-controls.js.map +1 -1
  187. package/build-module/cover/edit/index.js +2 -1
  188. package/build-module/cover/edit/index.js.map +1 -1
  189. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  190. package/build-module/cover/edit/resizable-cover-popover.js +1 -7
  191. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -1
  192. package/build-module/cover/edit.native.js.map +1 -1
  193. package/build-module/details/edit.js +1 -0
  194. package/build-module/details/edit.js.map +1 -1
  195. package/build-module/file/deprecated.js.map +1 -1
  196. package/build-module/file/edit.js +9 -14
  197. package/build-module/file/edit.js.map +1 -1
  198. package/build-module/file/edit.native.js.map +1 -1
  199. package/build-module/file/save.js.map +1 -1
  200. package/build-module/form-input/edit.js +1 -1
  201. package/build-module/form-input/edit.js.map +1 -1
  202. package/build-module/gallery/edit.js.map +1 -1
  203. package/build-module/gallery/gallery.native.js.map +1 -1
  204. package/build-module/gallery/v1/edit.js.map +1 -1
  205. package/build-module/gallery/v1/gallery.native.js.map +1 -1
  206. package/build-module/heading/index.js +4 -3
  207. package/build-module/heading/index.js.map +1 -1
  208. package/build-module/heading/transforms.js +17 -4
  209. package/build-module/heading/transforms.js.map +1 -1
  210. package/build-module/image/edit.js +9 -5
  211. package/build-module/image/edit.js.map +1 -1
  212. package/build-module/image/edit.native.js.map +1 -1
  213. package/build-module/image/image.js +23 -9
  214. package/build-module/image/image.js.map +1 -1
  215. package/build-module/latest-posts/edit.native.js.map +1 -1
  216. package/build-module/list/ordered-list-settings.js +1 -1
  217. package/build-module/list/ordered-list-settings.js.map +1 -1
  218. package/build-module/list-item/edit.js +2 -4
  219. package/build-module/list-item/edit.js.map +1 -1
  220. package/build-module/list-item/edit.native.js.map +1 -1
  221. package/build-module/list-item/hooks/index.js +0 -1
  222. package/build-module/list-item/hooks/index.js.map +1 -1
  223. package/build-module/list-item/hooks/use-indent-list-item.js +1 -0
  224. package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
  225. package/build-module/list-item/hooks/use-outdent-list-item.js +1 -0
  226. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  227. package/build-module/list-item/hooks/use-space.js +17 -8
  228. package/build-module/list-item/hooks/use-space.js.map +1 -1
  229. package/build-module/list-item/index.js +4 -1
  230. package/build-module/list-item/index.js.map +1 -1
  231. package/build-module/media-text/edit.js +34 -10
  232. package/build-module/media-text/edit.js.map +1 -1
  233. package/build-module/media-text/index.js +5 -0
  234. package/build-module/media-text/index.js.map +1 -1
  235. package/build-module/media-text/media-container.js +31 -12
  236. package/build-module/media-text/media-container.js.map +1 -1
  237. package/build-module/media-text/media-container.native.js +1 -1
  238. package/build-module/media-text/media-container.native.js.map +1 -1
  239. package/build-module/media-text/save.js +2 -2
  240. package/build-module/media-text/save.js.map +1 -1
  241. package/build-module/navigation/edit/index.js +24 -30
  242. package/build-module/navigation/edit/index.js.map +1 -1
  243. package/build-module/navigation/edit/navigation-menu-delete-control.js +15 -23
  244. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  245. package/build-module/navigation/edit/navigation-menu-selector.js +24 -23
  246. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  247. package/build-module/navigation/edit/placeholder/index.js +4 -4
  248. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  249. package/build-module/navigation/use-navigation-menu.js +15 -12
  250. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  251. package/build-module/navigation-link/edit.js +13 -11
  252. package/build-module/navigation-link/edit.js.map +1 -1
  253. package/build-module/navigation-link/link-ui.js.map +1 -1
  254. package/build-module/navigation-submenu/edit.js +4 -0
  255. package/build-module/navigation-submenu/edit.js.map +1 -1
  256. package/build-module/paragraph/edit.native.js.map +1 -1
  257. package/build-module/pattern/edit.js +11 -0
  258. package/build-module/pattern/edit.js.map +1 -1
  259. package/build-module/post-author/edit.js +1 -0
  260. package/build-module/post-author/edit.js.map +1 -1
  261. package/build-module/post-excerpt/edit.js +1 -0
  262. package/build-module/post-excerpt/edit.js.map +1 -1
  263. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  264. package/build-module/post-featured-image/edit.js +13 -13
  265. package/build-module/post-featured-image/edit.js.map +1 -1
  266. package/build-module/post-featured-image/index.js +6 -0
  267. package/build-module/post-featured-image/index.js.map +1 -1
  268. package/build-module/post-navigation-link/edit.js +1 -0
  269. package/build-module/post-navigation-link/edit.js.map +1 -1
  270. package/build-module/post-terms/edit.js +2 -0
  271. package/build-module/post-terms/edit.js.map +1 -1
  272. package/build-module/post-title/edit.js +2 -2
  273. package/build-module/post-title/edit.js.map +1 -1
  274. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  275. package/build-module/query/utils.js +7 -5
  276. package/build-module/query/utils.js.map +1 -1
  277. package/build-module/query-pagination-next/edit.js.map +1 -1
  278. package/build-module/query-pagination-previous/edit.js.map +1 -1
  279. package/build-module/quote/deprecated.js +112 -13
  280. package/build-module/quote/deprecated.js.map +1 -1
  281. package/build-module/quote/edit.js +7 -7
  282. package/build-module/quote/edit.js.map +1 -1
  283. package/build-module/quote/index.js +1 -1
  284. package/build-module/quote/index.js.map +1 -1
  285. package/build-module/quote/save.js +2 -2
  286. package/build-module/quote/save.js.map +1 -1
  287. package/build-module/read-more/edit.js +1 -0
  288. package/build-module/read-more/edit.js.map +1 -1
  289. package/build-module/search/edit.js +3 -1
  290. package/build-module/search/edit.js.map +1 -1
  291. package/build-module/search/edit.native.js +2 -2
  292. package/build-module/search/edit.native.js.map +1 -1
  293. package/build-module/site-logo/edit.js +7 -2
  294. package/build-module/site-logo/edit.js.map +1 -1
  295. package/build-module/site-title/{edit/index.js → edit.js} +1 -1
  296. package/build-module/site-title/edit.js.map +1 -0
  297. package/build-module/social-link/edit.js +1 -1
  298. package/build-module/social-link/edit.js.map +1 -1
  299. package/build-module/social-link/icons/medium.js +1 -1
  300. package/build-module/social-link/icons/medium.js.map +1 -1
  301. package/build-module/social-link/icons/reddit.js +1 -1
  302. package/build-module/social-link/icons/reddit.js.map +1 -1
  303. package/build-module/social-links/edit.native.js.map +1 -1
  304. package/build-module/spacer/edit.js.map +1 -1
  305. package/build-module/table/deprecated.js +286 -176
  306. package/build-module/table/deprecated.js.map +1 -1
  307. package/build-module/table/index.js +1 -1
  308. package/build-module/table-of-contents/edit.js.map +1 -1
  309. package/build-module/template-part/edit/index.js +57 -5
  310. package/build-module/template-part/edit/index.js.map +1 -1
  311. package/build-module/template-part/edit/selection-modal.js +2 -8
  312. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  313. package/build-module/template-part/edit/utils/map-template-part-to-block-pattern.js +24 -0
  314. package/build-module/template-part/edit/utils/map-template-part-to-block-pattern.js.map +1 -0
  315. package/build-module/utils/caption.js +13 -3
  316. package/build-module/utils/caption.js.map +1 -1
  317. package/build-module/utils/get-transformed-metadata.js +51 -0
  318. package/build-module/utils/get-transformed-metadata.js.map +1 -0
  319. package/build-module/utils/hooks.js +54 -3
  320. package/build-module/utils/hooks.js.map +1 -1
  321. package/build-module/video/edit-common-settings.js.map +1 -1
  322. package/build-module/video/edit.js +10 -19
  323. package/build-module/video/edit.js.map +1 -1
  324. package/build-module/video/edit.native.js +3 -8
  325. package/build-module/video/edit.native.js.map +1 -1
  326. package/build-style/common-rtl.css +1 -0
  327. package/build-style/common.css +1 -0
  328. package/build-style/cover/style-rtl.css +2 -1
  329. package/build-style/cover/style.css +2 -1
  330. package/build-style/editor-rtl.css +11 -2
  331. package/build-style/editor.css +11 -2
  332. package/build-style/file/editor-rtl.css +3 -0
  333. package/build-style/file/editor.css +3 -0
  334. package/build-style/group/editor-rtl.css +1 -1
  335. package/build-style/group/editor.css +1 -1
  336. package/build-style/media-text/editor-rtl.css +7 -1
  337. package/build-style/media-text/editor.css +7 -1
  338. package/build-style/search/style-rtl.css +2 -0
  339. package/build-style/search/style.css +2 -0
  340. package/build-style/social-links/style-rtl.css +2 -2
  341. package/build-style/social-links/style.css +2 -2
  342. package/build-style/style-rtl.css +6 -3
  343. package/build-style/style.css +6 -3
  344. package/package.json +34 -34
  345. package/src/archives/index.php +4 -0
  346. package/src/audio/edit.js +9 -19
  347. package/src/audio/edit.native.js +3 -3
  348. package/src/avatar/edit.js +1 -1
  349. package/src/avatar/index.php +6 -0
  350. package/src/block/deprecated.js +76 -11
  351. package/src/block/edit.js +100 -32
  352. package/src/block/index.php +27 -12
  353. package/src/block/test/edit.native.js +67 -0
  354. package/src/button/edit.js +4 -3
  355. package/src/buttons/edit.native.js +1 -1
  356. package/src/buttons/transforms.js +14 -4
  357. package/src/calendar/index.php +17 -0
  358. package/src/categories/index.php +6 -0
  359. package/src/code/save.js +7 -1
  360. package/src/code/transforms.js +20 -5
  361. package/src/columns/edit.js +3 -2
  362. package/src/comment-author-avatar/edit.js +1 -1
  363. package/src/comment-author-name/index.php +4 -0
  364. package/src/comment-content/index.php +4 -0
  365. package/src/comment-date/index.php +4 -0
  366. package/src/comment-edit-link/index.php +4 -0
  367. package/src/comment-reply-link/index.php +4 -0
  368. package/src/comment-template/index.php +4 -0
  369. package/src/comments/index.php +12 -0
  370. package/src/comments-pagination/index.php +4 -0
  371. package/src/comments-pagination-next/index.php +4 -0
  372. package/src/comments-pagination-numbers/index.php +4 -0
  373. package/src/comments-pagination-previous/index.php +4 -0
  374. package/src/comments-title/index.php +4 -0
  375. package/src/cover/edit/block-controls.js +16 -2
  376. package/src/cover/edit/index.js +6 -3
  377. package/src/cover/edit/inspector-controls.js +1 -1
  378. package/src/cover/edit/resizable-cover-popover.js +1 -6
  379. package/src/cover/edit.native.js +1 -1
  380. package/src/cover/index.php +4 -0
  381. package/src/cover/style.scss +3 -2
  382. package/src/details/edit.js +1 -0
  383. package/src/file/deprecated.js +3 -3
  384. package/src/file/edit.js +10 -15
  385. package/src/file/edit.native.js +4 -4
  386. package/src/file/editor.scss +3 -0
  387. package/src/file/index.php +4 -0
  388. package/src/file/save.js +1 -1
  389. package/src/footnotes/index.php +1 -1
  390. package/src/form-input/edit.js +1 -1
  391. package/src/gallery/edit.js +3 -3
  392. package/src/gallery/gallery.native.js +1 -1
  393. package/src/gallery/index.php +6 -0
  394. package/src/gallery/test/index.native.js +1 -1
  395. package/src/gallery/v1/edit.js +2 -2
  396. package/src/gallery/v1/gallery.native.js +1 -1
  397. package/src/group/editor.scss +1 -1
  398. package/src/heading/index.js +4 -3
  399. package/src/heading/index.php +4 -0
  400. package/src/heading/transforms.js +27 -8
  401. package/src/home-link/index.php +10 -0
  402. package/src/image/edit.js +13 -5
  403. package/src/image/edit.native.js +1 -1
  404. package/src/image/editor.scss +1 -0
  405. package/src/image/image.js +34 -22
  406. package/src/image/index.php +12 -1
  407. package/src/latest-comments/index.php +4 -0
  408. package/src/latest-posts/edit.native.js +1 -1
  409. package/src/latest-posts/index.php +8 -0
  410. package/src/list/ordered-list-settings.js +1 -1
  411. package/src/list-item/edit.js +1 -2
  412. package/src/list-item/edit.native.js +1 -1
  413. package/src/list-item/hooks/index.js +0 -1
  414. package/src/list-item/hooks/use-indent-list-item.js +2 -0
  415. package/src/list-item/hooks/use-outdent-list-item.js +2 -0
  416. package/src/list-item/hooks/use-space.js +16 -9
  417. package/src/list-item/index.js +3 -0
  418. package/src/loginout/index.php +4 -0
  419. package/src/media-text/block.json +5 -0
  420. package/src/media-text/edit.js +70 -19
  421. package/src/media-text/editor.scss +7 -1
  422. package/src/media-text/index.php +70 -0
  423. package/src/media-text/media-container.js +49 -9
  424. package/src/media-text/media-container.native.js +5 -3
  425. package/src/media-text/save.js +2 -2
  426. package/src/media-text/test/edit.native.js +58 -0
  427. package/src/missing/test/edit-integration.native.js +2 -1
  428. package/src/navigation/edit/index.js +68 -72
  429. package/src/navigation/edit/navigation-menu-delete-control.js +22 -49
  430. package/src/navigation/edit/navigation-menu-selector.js +39 -21
  431. package/src/navigation/edit/placeholder/index.js +4 -4
  432. package/src/navigation/edit/test/navigation-menu-selector.js +77 -55
  433. package/src/navigation/index.php +118 -34
  434. package/src/navigation/test/use-navigation-menu.js +21 -21
  435. package/src/navigation/use-navigation-menu.js +23 -9
  436. package/src/navigation-link/edit.js +12 -13
  437. package/src/navigation-link/index.php +14 -0
  438. package/src/navigation-link/link-ui.js +2 -2
  439. package/src/navigation-submenu/edit.js +4 -0
  440. package/src/navigation-submenu/index.php +8 -0
  441. package/src/page-list/index.php +12 -0
  442. package/src/page-list-item/index.php +2 -0
  443. package/src/paragraph/edit.native.js +1 -1
  444. package/src/paragraph/test/edit.native.js +36 -0
  445. package/src/pattern/edit.js +14 -0
  446. package/src/pattern/index.php +2 -0
  447. package/src/post-author/edit.js +1 -0
  448. package/src/post-author/index.php +4 -0
  449. package/src/post-author-biography/index.php +4 -0
  450. package/src/post-author-name/index.php +4 -0
  451. package/src/post-comments-form/index.php +6 -0
  452. package/src/post-content/index.php +4 -0
  453. package/src/post-date/index.php +4 -0
  454. package/src/post-excerpt/edit.js +2 -1
  455. package/src/post-excerpt/index.php +4 -0
  456. package/src/post-featured-image/block.json +6 -0
  457. package/src/post-featured-image/dimension-controls.js +4 -4
  458. package/src/post-featured-image/edit.js +14 -12
  459. package/src/post-featured-image/index.php +15 -0
  460. package/src/post-navigation-link/edit.js +2 -1
  461. package/src/post-navigation-link/index.php +4 -0
  462. package/src/post-template/index.php +6 -0
  463. package/src/post-terms/edit.js +2 -0
  464. package/src/post-terms/index.php +6 -0
  465. package/src/post-title/edit.js +49 -43
  466. package/src/post-title/index.php +2 -0
  467. package/src/query/edit/pattern-selection-modal.js +1 -1
  468. package/src/query/index.php +2 -0
  469. package/src/query/utils.js +6 -4
  470. package/src/query-no-results/index.php +4 -0
  471. package/src/query-pagination/index.php +4 -0
  472. package/src/query-pagination-next/edit.js +1 -1
  473. package/src/query-pagination-next/index.php +4 -0
  474. package/src/query-pagination-numbers/index.php +4 -0
  475. package/src/query-pagination-previous/edit.js +1 -1
  476. package/src/query-pagination-previous/index.php +4 -0
  477. package/src/query-title/index.php +4 -0
  478. package/src/quote/block.json +1 -1
  479. package/src/quote/deprecated.js +110 -15
  480. package/src/quote/edit.js +16 -10
  481. package/src/quote/save.js +2 -2
  482. package/src/quote/test/__snapshots__/transforms.native.js.snap +2 -2
  483. package/src/read-more/edit.js +2 -1
  484. package/src/read-more/index.php +4 -0
  485. package/src/rss/index.php +4 -0
  486. package/src/search/edit.js +3 -1
  487. package/src/search/edit.native.js +6 -6
  488. package/src/search/index.php +20 -2
  489. package/src/search/style.scss +2 -0
  490. package/src/shortcode/index.php +4 -0
  491. package/src/site-logo/edit.js +11 -6
  492. package/src/site-logo/index.php +20 -0
  493. package/src/site-tagline/index.php +4 -0
  494. package/src/site-title/index.php +4 -0
  495. package/src/social-link/edit.js +2 -2
  496. package/src/social-link/icons/medium.js +1 -1
  497. package/src/social-link/icons/reddit.js +1 -1
  498. package/src/social-link/index.php +22 -9
  499. package/src/social-link/socials-with-bg.scss +1 -1
  500. package/src/social-link/socials-without-bg.scss +1 -1
  501. package/src/social-links/edit.native.js +1 -1
  502. package/src/spacer/edit.js +1 -1
  503. package/src/table/block.json +1 -1
  504. package/src/table/deprecated.js +308 -175
  505. package/src/table-of-contents/edit.js +1 -1
  506. package/src/tag-cloud/index.php +4 -0
  507. package/src/template-part/edit/index.js +91 -4
  508. package/src/template-part/edit/selection-modal.js +4 -8
  509. package/src/template-part/edit/utils/map-template-part-to-block-pattern.js +23 -0
  510. package/src/template-part/index.php +10 -0
  511. package/src/term-description/index.php +4 -0
  512. package/src/utils/caption.js +10 -1
  513. package/src/utils/get-transformed-metadata.js +65 -0
  514. package/src/utils/hooks.js +53 -3
  515. package/src/video/edit-common-settings.js +1 -1
  516. package/src/video/edit.js +10 -18
  517. package/src/video/edit.native.js +7 -8
  518. package/src/video/test/edit.native.js +0 -14
  519. package/tsconfig.json +1 -0
  520. package/build/list-item/hooks/use-copy.js +0 -39
  521. package/build/list-item/hooks/use-copy.js.map +0 -1
  522. package/build/site-title/edit/index.js.map +0 -1
  523. package/build-module/list-item/hooks/use-copy.js +0 -32
  524. package/build-module/list-item/hooks/use-copy.js.map +0 -1
  525. package/build-module/site-title/edit/index.js.map +0 -1
  526. package/src/list-item/hooks/use-copy.js +0 -38
  527. /package/src/site-title/{edit/index.js → edit.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useSelect } from '@wordpress/data';
4
+ import { useSelect, useDispatch } from '@wordpress/data';
5
5
  import {
6
6
  BlockSettingsMenuControls,
7
7
  useBlockProps,
@@ -10,11 +10,14 @@ import {
10
10
  RecursionProvider,
11
11
  useHasRecursion,
12
12
  InspectorControls,
13
+ __experimentalBlockPatternsList as BlockPatternsList,
13
14
  } from '@wordpress/block-editor';
14
- import { Spinner, Modal, MenuItem } from '@wordpress/components';
15
+ import { PanelBody, Spinner, Modal, MenuItem } from '@wordpress/components';
16
+ import { useAsyncList } from '@wordpress/compose';
15
17
  import { __, sprintf } from '@wordpress/i18n';
16
18
  import { store as coreStore } from '@wordpress/core-data';
17
19
  import { useState } from '@wordpress/element';
20
+ import { store as noticesStore } from '@wordpress/notices';
18
21
 
19
22
  /**
20
23
  * Internal dependencies
@@ -24,10 +27,12 @@ import TemplatePartSelectionModal from './selection-modal';
24
27
  import { TemplatePartAdvancedControls } from './advanced-controls';
25
28
  import TemplatePartInnerBlocks from './inner-blocks';
26
29
  import { createTemplatePartId } from './utils/create-template-part-id';
30
+ import { mapTemplatePartToBlockPattern } from './utils/map-template-part-to-block-pattern';
27
31
  import {
28
32
  useAlternativeBlockPatterns,
29
33
  useAlternativeTemplateParts,
30
34
  useTemplatePartArea,
35
+ useCreateTemplatePartFromBlocks,
31
36
  } from './utils/hooks';
32
37
 
33
38
  function ReplaceButton( {
@@ -43,7 +48,6 @@ function ReplaceButton( {
43
48
  templatePartId
44
49
  );
45
50
  const blockPatterns = useAlternativeBlockPatterns( area, clientId );
46
-
47
51
  const hasReplacements = !! templateParts.length || !! blockPatterns.length;
48
52
  const canReplace =
49
53
  isEntityAvailable &&
@@ -67,11 +71,29 @@ function ReplaceButton( {
67
71
  );
68
72
  }
69
73
 
74
+ function TemplatesList( { availableTemplates, onSelect } ) {
75
+ const shownTemplates = useAsyncList( availableTemplates );
76
+
77
+ if ( ! availableTemplates ) {
78
+ return null;
79
+ }
80
+
81
+ return (
82
+ <BlockPatternsList
83
+ label={ __( 'Templates' ) }
84
+ blockPatterns={ availableTemplates }
85
+ shownPatterns={ shownTemplates }
86
+ onClickPattern={ onSelect }
87
+ />
88
+ );
89
+ }
90
+
70
91
  export default function TemplatePartEdit( {
71
92
  attributes,
72
93
  setAttributes,
73
94
  clientId,
74
95
  } ) {
96
+ const { createSuccessNotice } = useDispatch( noticesStore );
75
97
  const currentTheme = useSelect(
76
98
  ( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,
77
99
  []
@@ -117,12 +139,28 @@ export default function TemplatePartEdit( {
117
139
  [ templatePartId, attributes.area, clientId ]
118
140
  );
119
141
 
142
+ const { templateParts } = useAlternativeTemplateParts(
143
+ area,
144
+ templatePartId
145
+ );
146
+ const blockPatterns = useAlternativeBlockPatterns( area, clientId );
147
+ const hasReplacements = !! templateParts.length || !! blockPatterns.length;
120
148
  const areaObject = useTemplatePartArea( area );
121
149
  const blockProps = useBlockProps();
122
150
  const isPlaceholder = ! slug;
123
151
  const isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;
124
152
  const TagName = tagName || areaObject.tagName;
125
153
 
154
+ const canReplace =
155
+ isEntityAvailable &&
156
+ hasReplacements &&
157
+ ( area === 'header' || area === 'footer' );
158
+
159
+ const createFromBlocks = useCreateTemplatePartFromBlocks(
160
+ area,
161
+ setAttributes
162
+ );
163
+
126
164
  // We don't want to render a missing state if we have any inner blocks.
127
165
  // A new template part is automatically created if we have any inner blocks but no entity.
128
166
  if (
@@ -154,6 +192,28 @@ export default function TemplatePartEdit( {
154
192
  );
155
193
  }
156
194
 
195
+ const partsAsPatterns = templateParts.map( ( templatePart ) =>
196
+ mapTemplatePartToBlockPattern( templatePart )
197
+ );
198
+
199
+ const onTemplatePartSelect = ( templatePart ) => {
200
+ setAttributes( {
201
+ slug: templatePart.slug,
202
+ theme: templatePart.theme,
203
+ area: undefined,
204
+ } );
205
+ createSuccessNotice(
206
+ sprintf(
207
+ /* translators: %s: template part title. */
208
+ __( 'Template Part "%s" replaced.' ),
209
+ templatePart.title?.rendered || templatePart.slug
210
+ ),
211
+ {
212
+ type: 'snackbar',
213
+ }
214
+ );
215
+ };
216
+
157
217
  return (
158
218
  <>
159
219
  <RecursionProvider uniqueId={ templatePartId }>
@@ -207,6 +267,33 @@ export default function TemplatePartEdit( {
207
267
  );
208
268
  } }
209
269
  </BlockSettingsMenuControls>
270
+
271
+ { canReplace &&
272
+ ( partsAsPatterns.length > 0 ||
273
+ blockPatterns.length > 0 ) && (
274
+ <InspectorControls>
275
+ <PanelBody title={ __( 'Replace' ) }>
276
+ <TemplatesList
277
+ availableTemplates={ partsAsPatterns }
278
+ onSelect={ ( pattern ) => {
279
+ onTemplatePartSelect(
280
+ pattern.templatePart
281
+ );
282
+ } }
283
+ />
284
+ <TemplatesList
285
+ availableTemplates={ blockPatterns }
286
+ onSelect={ ( pattern, blocks ) => {
287
+ createFromBlocks(
288
+ blocks,
289
+ pattern.title
290
+ );
291
+ } }
292
+ />
293
+ </PanelBody>
294
+ </InspectorControls>
295
+ ) }
296
+
210
297
  { isEntityAvailable && (
211
298
  <TemplatePartInnerBlocks
212
299
  tagName={ TagName }
@@ -233,7 +320,7 @@ export default function TemplatePartEdit( {
233
320
  onRequestClose={ () =>
234
321
  setIsTemplatePartSelectionOpen( false )
235
322
  }
236
- isFullScreen={ true }
323
+ isFullScreen
237
324
  >
238
325
  <TemplatePartSelectionModal
239
326
  templatePartId={ templatePartId }
@@ -5,7 +5,6 @@ import { useMemo, useState } from '@wordpress/element';
5
5
  import { __, sprintf } from '@wordpress/i18n';
6
6
  import { store as noticesStore } from '@wordpress/notices';
7
7
  import { useDispatch } from '@wordpress/data';
8
- import { parse } from '@wordpress/blocks';
9
8
  import { useAsyncList } from '@wordpress/compose';
10
9
  import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
11
10
  import {
@@ -21,7 +20,7 @@ import {
21
20
  useAlternativeTemplateParts,
22
21
  useCreateTemplatePartFromBlocks,
23
22
  } from './utils/hooks';
24
- import { createTemplatePartId } from './utils/create-template-part-id';
23
+ import { mapTemplatePartToBlockPattern } from './utils/map-template-part-to-block-pattern';
25
24
  import { searchPatterns } from '../../utils/search-patterns';
26
25
 
27
26
  export default function TemplatePartSelectionModal( {
@@ -39,12 +38,9 @@ export default function TemplatePartSelectionModal( {
39
38
  );
40
39
  // We can map template parts to block patters to reuse the BlockPatternsList UI
41
40
  const filteredTemplateParts = useMemo( () => {
42
- const partsAsPatterns = templateParts.map( ( templatePart ) => ( {
43
- name: createTemplatePartId( templatePart.theme, templatePart.slug ),
44
- title: templatePart.title.rendered,
45
- blocks: parse( templatePart.content.raw ),
46
- templatePart,
47
- } ) );
41
+ const partsAsPatterns = templateParts.map( ( templatePart ) =>
42
+ mapTemplatePartToBlockPattern( templatePart )
43
+ );
48
44
 
49
45
  return searchPatterns( partsAsPatterns, searchValue );
50
46
  }, [ templateParts, searchValue ] );
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { parse } from '@wordpress/blocks';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { createTemplatePartId } from './create-template-part-id';
10
+
11
+ /**
12
+ * This maps the properties of a template part to those of a block pattern.
13
+ * @param {Object} templatePart
14
+ * @return {Object} The template part in the shape of block pattern.
15
+ */
16
+ export function mapTemplatePartToBlockPattern( templatePart ) {
17
+ return {
18
+ name: createTemplatePartId( templatePart.theme, templatePart.slug ),
19
+ title: templatePart.title.rendered,
20
+ blocks: parse( templatePart.content.raw ),
21
+ templatePart,
22
+ };
23
+ }
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/template-part` block on the server.
10
10
  *
11
+ * @since 5.9.0
12
+ *
11
13
  * @param array $attributes The block attributes.
12
14
  *
13
15
  * @return string The render.
@@ -174,6 +176,8 @@ function render_block_core_template_part( $attributes ) {
174
176
  /**
175
177
  * Returns an array of area variation objects for the template part block.
176
178
  *
179
+ * @since 6.1.0
180
+ *
177
181
  * @param array $instance_variations The variations for instances.
178
182
  *
179
183
  * @return array Array containing the block variation objects.
@@ -212,6 +216,8 @@ function build_template_part_block_area_variations( $instance_variations ) {
212
216
  /**
213
217
  * Returns an array of instance variation objects for the template part block
214
218
  *
219
+ * @since 6.1.0
220
+ *
215
221
  * @return array Array containing the block variation objects.
216
222
  */
217
223
  function build_template_part_block_instance_variations() {
@@ -266,6 +272,8 @@ function build_template_part_block_instance_variations() {
266
272
  /**
267
273
  * Returns an array of all template part block variations.
268
274
  *
275
+ * @since 5.9.0
276
+ *
269
277
  * @return array Array containing the block variation objects.
270
278
  */
271
279
  function build_template_part_block_variations() {
@@ -276,6 +284,8 @@ function build_template_part_block_variations() {
276
284
 
277
285
  /**
278
286
  * Registers the `core/template-part` block on the server.
287
+ *
288
+ * @since 5.9.0
279
289
  */
280
290
  function register_block_core_template_part() {
281
291
  register_block_type_from_metadata(
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/term-description` block on the server.
10
10
  *
11
+ * @since 5.9.0
12
+ *
11
13
  * @param array $attributes Block attributes.
12
14
  *
13
15
  * @return string Returns the description of the current taxonomy term, if available
@@ -37,6 +39,8 @@ function render_block_core_term_description( $attributes ) {
37
39
 
38
40
  /**
39
41
  * Registers the `core/term-description` block on the server.
42
+ *
43
+ * @since 5.9.0
40
44
  */
41
45
  function register_block_core_term_description() {
42
46
  register_block_type_from_metadata(
@@ -10,14 +10,21 @@ import { useState, useEffect, useCallback } from '@wordpress/element';
10
10
  import { usePrevious } from '@wordpress/compose';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import {
13
- RichText,
14
13
  BlockControls,
15
14
  __experimentalGetElementClassName,
15
+ privateApis as blockEditorPrivateApis,
16
16
  } from '@wordpress/block-editor';
17
17
  import { ToolbarButton } from '@wordpress/components';
18
18
  import { caption as captionIcon } from '@wordpress/icons';
19
19
  import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
20
20
 
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+ import { unlock } from '../lock-unlock';
25
+
26
+ const { PrivateRichText: RichText } = unlock( blockEditorPrivateApis );
27
+
21
28
  export function Caption( {
22
29
  key = 'caption',
23
30
  attributes,
@@ -28,6 +35,7 @@ export function Caption( {
28
35
  label = __( 'Caption text' ),
29
36
  showToolbarButton = true,
30
37
  className,
38
+ disableEditing,
31
39
  } ) {
32
40
  const caption = attributes[ key ];
33
41
  const prevCaption = usePrevious( caption );
@@ -101,6 +109,7 @@ export function Caption( {
101
109
  createBlock( getDefaultBlockName() )
102
110
  )
103
111
  }
112
+ disableEditing={ disableEditing }
104
113
  />
105
114
  ) }
106
115
  </>
@@ -0,0 +1,65 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { getBlockType } from '@wordpress/blocks';
5
+
6
+ /**
7
+ * Transform the metadata attribute with only the values and bindings specified by each transform.
8
+ * Returns `undefined` if the input metadata is falsy.
9
+ *
10
+ * @param {Object} metadata Original metadata attribute from the block that is being transformed.
11
+ * @param {Object} newBlockName Name of the final block after the transformation.
12
+ * @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.
13
+ * @return {Object|undefined} New metadata object only with the relevant properties.
14
+ */
15
+ export function getTransformedMetadata(
16
+ metadata,
17
+ newBlockName,
18
+ bindingsCallback
19
+ ) {
20
+ if ( ! metadata ) {
21
+ return;
22
+ }
23
+ const { supports } = getBlockType( newBlockName );
24
+ // Fixed until an opt-in mechanism is implemented.
25
+ const BLOCK_BINDINGS_SUPPORTED_BLOCKS = [
26
+ 'core/paragraph',
27
+ 'core/heading',
28
+ 'core/image',
29
+ 'core/button',
30
+ ];
31
+ // The metadata properties that should be preserved after the transform.
32
+ const transformSupportedProps = [];
33
+ // If it support bindings, and there is a transform bindings callback, add the `id` and `bindings` properties.
34
+ if (
35
+ BLOCK_BINDINGS_SUPPORTED_BLOCKS.includes( newBlockName ) &&
36
+ bindingsCallback
37
+ ) {
38
+ transformSupportedProps.push( 'id', 'bindings' );
39
+ }
40
+ // If it support block naming (true by default), add the `name` property.
41
+ if ( supports.renaming !== false ) {
42
+ transformSupportedProps.push( 'name' );
43
+ }
44
+
45
+ // Return early if no supported properties.
46
+ if ( ! transformSupportedProps.length ) {
47
+ return;
48
+ }
49
+
50
+ const newMetadata = Object.entries( metadata ).reduce(
51
+ ( obj, [ prop, value ] ) => {
52
+ // If prop is not supported, don't add it to the new metadata object.
53
+ if ( ! transformSupportedProps.includes( prop ) ) {
54
+ return obj;
55
+ }
56
+ obj[ prop ] =
57
+ prop === 'bindings' ? bindingsCallback( value ) : value;
58
+ return obj;
59
+ },
60
+ {}
61
+ );
62
+
63
+ // Return undefined if object is empty.
64
+ return Object.keys( newMetadata ).length ? newMetadata : undefined;
65
+ }
@@ -2,6 +2,9 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
+ import { useLayoutEffect, useEffect, useRef } from '@wordpress/element';
6
+ import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
7
+ import { store as blockEditorStore } from '@wordpress/block-editor';
5
8
  import { store as coreStore } from '@wordpress/core-data';
6
9
 
7
10
  /**
@@ -19,6 +22,53 @@ export function useCanEditEntity( kind, name, recordId ) {
19
22
  );
20
23
  }
21
24
 
22
- export default {
23
- useCanEditEntity,
24
- };
25
+ /**
26
+ * Handles uploading a media file from a blob URL on mount.
27
+ *
28
+ * @param {Object} args Upload media arguments.
29
+ * @param {string} args.url Blob URL.
30
+ * @param {?Array} args.allowedTypes Array of allowed media types.
31
+ * @param {Function} args.onChange Function called when the media is uploaded.
32
+ * @param {Function} args.onError Function called when an error happens.
33
+ */
34
+ export function useUploadMediaFromBlobURL( args = {} ) {
35
+ const latestArgs = useRef( args );
36
+ const { getSettings } = useSelect( blockEditorStore );
37
+
38
+ useLayoutEffect( () => {
39
+ latestArgs.current = args;
40
+ } );
41
+
42
+ useEffect( () => {
43
+ if (
44
+ ! latestArgs.current.url ||
45
+ ! isBlobURL( latestArgs.current.url )
46
+ ) {
47
+ return;
48
+ }
49
+
50
+ const file = getBlobByURL( latestArgs.current.url );
51
+ if ( ! file ) {
52
+ return;
53
+ }
54
+
55
+ const { url, allowedTypes, onChange, onError } = latestArgs.current;
56
+ const { mediaUpload } = getSettings();
57
+
58
+ mediaUpload( {
59
+ filesList: [ file ],
60
+ allowedTypes,
61
+ onFileChange: ( [ media ] ) => {
62
+ if ( isBlobURL( media?.url ) ) {
63
+ return;
64
+ }
65
+
66
+ revokeBlobURL( url );
67
+ onChange( media );
68
+ },
69
+ onError: ( message ) => {
70
+ onError( message );
71
+ },
72
+ } );
73
+ }, [ getSettings ] );
74
+ }
@@ -84,7 +84,7 @@ const VideoSettings = ( { setAttributes, attributes } ) => {
84
84
  value={ preload }
85
85
  onChange={ onChangePreload }
86
86
  options={ options }
87
- hideCancelButton={ true }
87
+ hideCancelButton
88
88
  />
89
89
  </>
90
90
  );
package/src/video/edit.js CHANGED
@@ -6,7 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { getBlobByURL, isBlobURL } from '@wordpress/blob';
9
+ import { isBlobURL } from '@wordpress/blob';
10
10
  import {
11
11
  BaseControl,
12
12
  Button,
@@ -24,12 +24,11 @@ import {
24
24
  MediaUploadCheck,
25
25
  MediaReplaceFlow,
26
26
  useBlockProps,
27
- store as blockEditorStore,
28
27
  } from '@wordpress/block-editor';
29
28
  import { useRef, useEffect } from '@wordpress/element';
30
29
  import { __, sprintf } from '@wordpress/i18n';
31
30
  import { useInstanceId } from '@wordpress/compose';
32
- import { useDispatch, useSelect } from '@wordpress/data';
31
+ import { useDispatch } from '@wordpress/data';
33
32
  import { video as icon } from '@wordpress/icons';
34
33
  import { store as noticesStore } from '@wordpress/notices';
35
34
 
@@ -37,6 +36,7 @@ import { store as noticesStore } from '@wordpress/notices';
37
36
  * Internal dependencies
38
37
  */
39
38
  import { createUpgradedEmbedBlock } from '../embed/util';
39
+ import { useUploadMediaFromBlobURL } from '../utils/hooks';
40
40
  import VideoCommonSettings from './edit-common-settings';
41
41
  import TracksEditor from './tracks-editor';
42
42
  import Tracks from './tracks';
@@ -47,7 +47,7 @@ const placeholder = ( content ) => {
47
47
  return (
48
48
  <Placeholder
49
49
  className="block-editor-media-placeholder"
50
- withIllustration={ true }
50
+ withIllustration
51
51
  icon={ icon }
52
52
  label={ __( 'Video' ) }
53
53
  instructions={ __(
@@ -75,21 +75,13 @@ function VideoEdit( {
75
75
  const posterImageButton = useRef();
76
76
  const { id, controls, poster, src, tracks } = attributes;
77
77
  const isTemporaryVideo = ! id && isBlobURL( src );
78
- const { getSettings } = useSelect( blockEditorStore );
79
78
 
80
- useEffect( () => {
81
- if ( ! id && isBlobURL( src ) ) {
82
- const file = getBlobByURL( src );
83
- if ( file ) {
84
- getSettings().mediaUpload( {
85
- filesList: [ file ],
86
- onFileChange: ( [ media ] ) => onSelectVideo( media ),
87
- onError: onUploadError,
88
- allowedTypes: ALLOWED_MEDIA_TYPES,
89
- } );
90
- }
91
- }
92
- }, [] );
79
+ useUploadMediaFromBlobURL( {
80
+ url: src,
81
+ allowedTypes: ALLOWED_MEDIA_TYPES,
82
+ onChange: onSelectVideo,
83
+ onError: onUploadError,
84
+ } );
93
85
 
94
86
  useEffect( () => {
95
87
  // Placeholder may be rendered.
@@ -212,13 +212,13 @@ class VideoEdit extends Component {
212
212
  render() {
213
213
  const { setAttributes, attributes, isSelected, wasBlockJustInserted } =
214
214
  this.props;
215
- const { id, src, guid } = attributes;
215
+ const { id, src } = attributes;
216
216
  const { videoContainerHeight } = this.state;
217
217
 
218
218
  const toolbarEditButton = (
219
219
  <MediaUpload
220
220
  allowedTypes={ [ MEDIA_TYPE_VIDEO ] }
221
- isReplacingMedia={ true }
221
+ isReplacingMedia
222
222
  onSelect={ this.onSelectMediaUploadOption }
223
223
  onSelectURL={ this.onSelectURL }
224
224
  render={ ( { open, getMediaOptions } ) => {
@@ -236,10 +236,7 @@ class VideoEdit extends Component {
236
236
  ></MediaUpload>
237
237
  );
238
238
 
239
- // NOTE: `guid` is not part of the block's attribute definition. This case
240
- // handled here is a temporary fix until a we find a better approach.
241
- const isSourcePresent = src || ( guid && id );
242
- if ( ! isSourcePresent ) {
239
+ if ( ! src ) {
243
240
  return (
244
241
  <View style={ { flex: 1 } }>
245
242
  <MediaPlaceholder
@@ -293,8 +290,10 @@ class VideoEdit extends Component {
293
290
  } ) => {
294
291
  const showVideo =
295
292
  isURL( src ) &&
293
+ getProtocol( attributes.src ) !== 'file:' &&
296
294
  ! isUploadInProgress &&
297
295
  ! isUploadFailed;
296
+
298
297
  const icon = this.getIcon(
299
298
  isUploadFailed
300
299
  ? ICON_TYPE.RETRY
@@ -335,7 +334,7 @@ class VideoEdit extends Component {
335
334
  }
336
335
  style={ videoStyle }
337
336
  source={ { uri: src } }
338
- paused={ true }
337
+ paused
339
338
  />
340
339
  </View>
341
340
  ) }
@@ -368,7 +367,7 @@ class VideoEdit extends Component {
368
367
  } }
369
368
  />
370
369
  <BlockCaption
371
- accessible={ true }
370
+ accessible
372
371
  accessibilityLabelCreator={ ( caption ) =>
373
372
  RichText.isEmpty( caption )
374
373
  ? /* translators: accessibility text. Empty video caption. */
@@ -44,20 +44,6 @@ describe( 'Video block', () => {
44
44
  initialHtml: `
45
45
  <!-- wp:video {"id":1234} -->
46
46
  <figure class="wp-block-video"><video controls src="https://VIDEO_URL.mp4"></video></figure>
47
- <!-- /wp:video -->
48
- `,
49
- } );
50
- const addVideoButton = screen.queryByText( 'Add video' );
51
- expect( addVideoButton ).toBeNull();
52
- } );
53
-
54
- it( `should not render empty state when 'guid' and 'id' attributes are present`, async () => {
55
- await initializeEditor( {
56
- initialHtml: `
57
- <!-- wp:video {"guid":"ABCD1234","id":1234 -->
58
- <figure class="wp-block-video wp-block-embed is-type-video is-provider-videopress"><div class="wp-block-embed__wrapper">
59
- https://videopress.com/<VIDEO_ID>
60
- </div></figure>
61
47
  <!-- /wp:video -->
62
48
  `,
63
49
  } );
package/tsconfig.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/tsconfig.json",
2
3
  "extends": "../../tsconfig.base.json",
3
4
  "compilerOptions": {
4
5
  "rootDir": "src",
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = useCopy;
7
- var _compose = require("@wordpress/compose");
8
- var _blockEditor = require("@wordpress/block-editor");
9
- var _data = require("@wordpress/data");
10
- /**
11
- * WordPress dependencies
12
- */
13
-
14
- function useCopy(clientId) {
15
- const {
16
- getBlockRootClientId,
17
- getBlockName,
18
- getBlockAttributes
19
- } = (0, _data.useSelect)(_blockEditor.store);
20
- return (0, _compose.useRefEffect)(node => {
21
- function onCopy(event) {
22
- // The event propagates through all nested lists, so don't override
23
- // when copying nested list items.
24
- if (event.clipboardData.getData('__unstableWrapperBlockName')) {
25
- return;
26
- }
27
- const rootClientId = getBlockRootClientId(clientId);
28
- event.clipboardData.setData('__unstableWrapperBlockName', getBlockName(rootClientId));
29
- event.clipboardData.setData('__unstableWrapperBlockAttributes', JSON.stringify(getBlockAttributes(rootClientId)));
30
- }
31
- node.addEventListener('copy', onCopy);
32
- node.addEventListener('cut', onCopy);
33
- return () => {
34
- node.removeEventListener('copy', onCopy);
35
- node.removeEventListener('cut', onCopy);
36
- };
37
- }, []);
38
- }
39
- //# sourceMappingURL=use-copy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_compose","require","_blockEditor","_data","useCopy","clientId","getBlockRootClientId","getBlockName","getBlockAttributes","useSelect","blockEditorStore","useRefEffect","node","onCopy","event","clipboardData","getData","rootClientId","setData","JSON","stringify","addEventListener","removeEventListener"],"sources":["@wordpress/block-library/src/list-item/hooks/use-copy.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function useCopy( clientId ) {\n\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onCopy( event ) {\n\t\t\t// The event propagates through all nested lists, so don't override\n\t\t\t// when copying nested list items.\n\t\t\tif ( event.clipboardData.getData( '__unstableWrapperBlockName' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tevent.clipboardData.setData(\n\t\t\t\t'__unstableWrapperBlockName',\n\t\t\t\tgetBlockName( rootClientId )\n\t\t\t);\n\t\t\tevent.clipboardData.setData(\n\t\t\t\t'__unstableWrapperBlockAttributes',\n\t\t\t\tJSON.stringify( getBlockAttributes( rootClientId ) )\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'copy', onCopy );\n\t\tnode.addEventListener( 'cut', onCopy );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'copy', onCopy );\n\t\t\tnode.removeEventListener( 'cut', onCopy );\n\t\t};\n\t}, [] );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKe,SAASG,OAAOA,CAAEC,QAAQ,EAAG;EAC3C,MAAM;IAAEC,oBAAoB;IAAEC,YAAY;IAAEC;EAAmB,CAAC,GAC/D,IAAAC,eAAS,EAAEC,kBAAiB,CAAC;EAE9B,OAAO,IAAAC,qBAAY,EAAIC,IAAI,IAAM;IAChC,SAASC,MAAMA,CAAEC,KAAK,EAAG;MACxB;MACA;MACA,IAAKA,KAAK,CAACC,aAAa,CAACC,OAAO,CAAE,4BAA6B,CAAC,EAAG;QAClE;MACD;MAEA,MAAMC,YAAY,GAAGX,oBAAoB,CAAED,QAAS,CAAC;MACrDS,KAAK,CAACC,aAAa,CAACG,OAAO,CAC1B,4BAA4B,EAC5BX,YAAY,CAAEU,YAAa,CAC5B,CAAC;MACDH,KAAK,CAACC,aAAa,CAACG,OAAO,CAC1B,kCAAkC,EAClCC,IAAI,CAACC,SAAS,CAAEZ,kBAAkB,CAAES,YAAa,CAAE,CACpD,CAAC;IACF;IAEAL,IAAI,CAACS,gBAAgB,CAAE,MAAM,EAAER,MAAO,CAAC;IACvCD,IAAI,CAACS,gBAAgB,CAAE,KAAK,EAAER,MAAO,CAAC;IACtC,OAAO,MAAM;MACZD,IAAI,CAACU,mBAAmB,CAAE,MAAM,EAAET,MAAO,CAAC;MAC1CD,IAAI,CAACU,mBAAmB,CAAE,KAAK,EAAET,MAAO,CAAC;IAC1C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}