@wordpress/block-library 10.1.1-next.v.202607070741.0 → 10.3.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 (580) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/build/accordion/block.json +1 -0
  3. package/build/accordion-panel/block.json +1 -0
  4. package/build/button/edit.cjs +18 -8
  5. package/build/button/edit.cjs.map +2 -2
  6. package/build/code/edit.cjs +3 -1
  7. package/build/code/edit.cjs.map +2 -2
  8. package/build/cover/block.json +12 -0
  9. package/build/cover/edit/block-controls.cjs +14 -5
  10. package/build/cover/edit/block-controls.cjs.map +2 -2
  11. package/build/cover/edit/embed-video-url-input.cjs +5 -3
  12. package/build/cover/edit/embed-video-url-input.cjs.map +3 -3
  13. package/build/cover/edit/index.cjs +76 -32
  14. package/build/cover/edit/index.cjs.map +2 -2
  15. package/build/cover/embed-video-utils.cjs +17 -7
  16. package/build/cover/embed-video-utils.cjs.map +2 -2
  17. package/build/details/transforms.cjs +1 -3
  18. package/build/details/transforms.cjs.map +2 -2
  19. package/build/embed/edit.cjs +1 -1
  20. package/build/embed/edit.cjs.map +2 -2
  21. package/build/embed/embed-placeholder.cjs +1 -2
  22. package/build/embed/embed-placeholder.cjs.map +2 -2
  23. package/build/file/edit.cjs +4 -3
  24. package/build/file/edit.cjs.map +2 -2
  25. package/build/file/transforms.cjs +25 -60
  26. package/build/file/transforms.cjs.map +2 -2
  27. package/build/gallery/block.json +4 -2
  28. package/build/gallery/dynamic-gallery.cjs +104 -61
  29. package/build/gallery/dynamic-gallery.cjs.map +3 -3
  30. package/build/gallery/edit.cjs +1 -1
  31. package/build/gallery/edit.cjs.map +3 -3
  32. package/build/gallery/gap-styles.cjs +49 -13
  33. package/build/gallery/gap-styles.cjs.map +3 -3
  34. package/build/gallery/use-dynamic-gallery.cjs +15 -8
  35. package/build/gallery/use-dynamic-gallery.cjs.map +2 -2
  36. package/build/group/transforms.cjs +1 -1
  37. package/build/group/transforms.cjs.map +2 -2
  38. package/build/heading/edit.cjs +1 -1
  39. package/build/heading/edit.cjs.map +2 -2
  40. package/build/html/modal.cjs +63 -54
  41. package/build/html/modal.cjs.map +3 -3
  42. package/build/icon/block.json +5 -3
  43. package/build/icon/components/custom-inserter/icon-grid.cjs +25 -12
  44. package/build/icon/components/custom-inserter/icon-grid.cjs.map +2 -2
  45. package/build/icon/components/custom-inserter/index.cjs +100 -31
  46. package/build/icon/components/custom-inserter/index.cjs.map +3 -3
  47. package/build/icon/edit.cjs +11 -12
  48. package/build/icon/edit.cjs.map +2 -2
  49. package/build/image/block.json +1 -1
  50. package/build/image/edit.cjs +1 -35
  51. package/build/image/edit.cjs.map +2 -2
  52. package/build/image/image.cjs +23 -18
  53. package/build/image/image.cjs.map +3 -3
  54. package/build/image/transforms.cjs +78 -0
  55. package/build/image/transforms.cjs.map +3 -3
  56. package/build/image/use-open-image-media-editor-modal.cjs +6 -2
  57. package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
  58. package/build/index.cjs +18 -8
  59. package/build/index.cjs.map +2 -2
  60. package/build/latest-posts/edit.cjs +5 -8
  61. package/build/latest-posts/edit.cjs.map +2 -2
  62. package/build/list-item/edit.cjs +1 -1
  63. package/build/list-item/edit.cjs.map +2 -2
  64. package/build/list-item/hooks/use-enter.cjs +14 -17
  65. package/build/list-item/hooks/use-enter.cjs.map +3 -3
  66. package/build/list-item/hooks/use-indent-list-item.cjs +10 -2
  67. package/build/list-item/hooks/use-indent-list-item.cjs.map +2 -2
  68. package/build/list-item/hooks/use-space.cjs +3 -2
  69. package/build/list-item/hooks/use-space.cjs.map +3 -3
  70. package/build/math/edit.cjs +39 -56
  71. package/build/math/edit.cjs.map +3 -3
  72. package/build/media-text/edit.cjs +2 -1
  73. package/build/media-text/edit.cjs.map +2 -2
  74. package/build/more/edit.cjs +2 -2
  75. package/build/more/edit.cjs.map +2 -2
  76. package/build/navigation/edit/index.cjs +30 -16
  77. package/build/navigation/edit/index.cjs.map +3 -3
  78. package/build/navigation/edit/use-layout-custom-properties.cjs +72 -0
  79. package/build/navigation/edit/use-layout-custom-properties.cjs.map +7 -0
  80. package/build/navigation/view.cjs +9 -6
  81. package/build/navigation/view.cjs.map +2 -2
  82. package/build/navigation-link/edit.cjs +3 -3
  83. package/build/navigation-link/edit.cjs.map +2 -2
  84. package/build/navigation-link/link-ui/index.cjs +2 -2
  85. package/build/navigation-link/link-ui/index.cjs.map +2 -2
  86. package/build/paragraph/edit.cjs +5 -2
  87. package/build/paragraph/edit.cjs.map +3 -3
  88. package/build/paragraph/index.cjs +4 -1
  89. package/build/paragraph/index.cjs.map +2 -2
  90. package/build/paragraph/use-enter.cjs +3 -7
  91. package/build/paragraph/use-enter.cjs.map +3 -3
  92. package/build/playlist/block.json +29 -10
  93. package/build/playlist/context.cjs +2 -1
  94. package/build/playlist/context.cjs.map +2 -2
  95. package/build/playlist/edit.cjs +328 -39
  96. package/build/playlist/edit.cjs.map +3 -3
  97. package/build/playlist/index.cjs +1 -1
  98. package/build/playlist/index.cjs.map +2 -2
  99. package/build/playlist/utils.cjs +37 -8
  100. package/build/playlist/utils.cjs.map +2 -2
  101. package/build/playlist/view.cjs +83 -13
  102. package/build/playlist/view.cjs.map +2 -2
  103. package/build/playlist-track/block.json +4 -2
  104. package/build/playlist-track/edit.cjs +115 -70
  105. package/build/playlist-track/edit.cjs.map +2 -2
  106. package/build/post-content/block.json +1 -0
  107. package/build/post-content/edit.cjs +36 -15
  108. package/build/post-content/edit.cjs.map +2 -2
  109. package/build/post-featured-image/edit.cjs +3 -2
  110. package/build/post-featured-image/edit.cjs.map +2 -2
  111. package/build/post-template/block.json +2 -1
  112. package/build/post-template/edit.cjs +10 -1
  113. package/build/post-template/edit.cjs.map +2 -2
  114. package/build/post-terms/edit.cjs +2 -2
  115. package/build/post-terms/edit.cjs.map +2 -2
  116. package/build/post-title/edit.cjs +2 -2
  117. package/build/post-title/edit.cjs.map +2 -2
  118. package/build/preformatted/edit.cjs +3 -1
  119. package/build/preformatted/edit.cjs.map +2 -2
  120. package/build/pullquote/block.json +3 -1
  121. package/build/pullquote/edit.cjs +5 -3
  122. package/build/pullquote/edit.cjs.map +2 -2
  123. package/build/query/block.json +3 -2
  124. package/build/query/edit/inspector-controls/index.cjs +42 -5
  125. package/build/query/edit/inspector-controls/index.cjs.map +2 -2
  126. package/build/query/edit/inspector-controls/offset-controls.cjs +1 -2
  127. package/build/query/edit/inspector-controls/offset-controls.cjs.map +2 -2
  128. package/build/query/edit/inspector-controls/pages-control.cjs +0 -1
  129. package/build/query/edit/inspector-controls/pages-control.cjs.map +2 -2
  130. package/build/query/edit/query-content.cjs +10 -3
  131. package/build/query/edit/query-content.cjs.map +2 -2
  132. package/build/query/index.cjs +2 -1
  133. package/build/query/index.cjs.map +2 -2
  134. package/build/quote/block.json +3 -1
  135. package/build/quote/transforms.cjs +1 -3
  136. package/build/quote/transforms.cjs.map +2 -2
  137. package/build/read-more/edit.cjs +3 -1
  138. package/build/read-more/edit.cjs.map +2 -2
  139. package/build/rss/edit.cjs +0 -1
  140. package/build/rss/edit.cjs.map +2 -2
  141. package/build/site-tagline/edit.cjs +3 -1
  142. package/build/site-tagline/edit.cjs.map +2 -2
  143. package/build/site-title/edit.cjs +3 -1
  144. package/build/site-title/edit.cjs.map +2 -2
  145. package/build/social-links/edit.cjs +11 -4
  146. package/build/social-links/edit.cjs.map +2 -2
  147. package/build/tab-list/block.json +4 -3
  148. package/build/tab-list/edit.cjs +67 -11
  149. package/build/tab-list/edit.cjs.map +3 -3
  150. package/build/tab-list/tab-movers.cjs +87 -0
  151. package/build/tab-list/tab-movers.cjs.map +7 -0
  152. package/build/tab-panel/block.json +1 -6
  153. package/build/tab-panel/edit.cjs +16 -24
  154. package/build/tab-panel/edit.cjs.map +2 -2
  155. package/build/tab-panels/block.json +0 -1
  156. package/build/table/edit.cjs +1 -1
  157. package/build/table/edit.cjs.map +2 -2
  158. package/build/tabs/block.json +0 -5
  159. package/build/tabs/edit.cjs +4 -39
  160. package/build/tabs/edit.cjs.map +3 -3
  161. package/build/tabs/use-tab-actions.cjs +23 -1
  162. package/build/tabs/use-tab-actions.cjs.map +2 -2
  163. package/build/tabs/use-tab-list-items-sync.cjs +19 -1
  164. package/build/tabs/use-tab-list-items-sync.cjs.map +2 -2
  165. package/build/term-name/block.json +1 -3
  166. package/build/term-name/deprecated.cjs +105 -0
  167. package/build/term-name/deprecated.cjs.map +7 -0
  168. package/build/term-name/edit.cjs +11 -37
  169. package/build/term-name/edit.cjs.map +3 -3
  170. package/build/term-name/index.cjs +3 -1
  171. package/build/term-name/index.cjs.map +3 -3
  172. package/build/utils/caption.cjs +2 -2
  173. package/build/utils/caption.cjs.map +2 -2
  174. package/build/utils/waveform-player.cjs +138 -22
  175. package/build/utils/waveform-player.cjs.map +2 -2
  176. package/build/utils/waveform-utils.cjs +315 -17
  177. package/build/utils/waveform-utils.cjs.map +2 -2
  178. package/build/verse/edit.cjs +3 -1
  179. package/build/verse/edit.cjs.map +2 -2
  180. package/build/video/edit.cjs +2 -11
  181. package/build/video/edit.cjs.map +3 -3
  182. package/build/video/tracks-editor.cjs +0 -1
  183. package/build/video/tracks-editor.cjs.map +2 -2
  184. package/build-module/accordion/block.json +1 -0
  185. package/build-module/accordion-panel/block.json +1 -0
  186. package/build-module/button/edit.mjs +19 -14
  187. package/build-module/button/edit.mjs.map +2 -2
  188. package/build-module/code/edit.mjs +3 -1
  189. package/build-module/code/edit.mjs.map +2 -2
  190. package/build-module/cover/block.json +12 -0
  191. package/build-module/cover/edit/block-controls.mjs +14 -5
  192. package/build-module/cover/edit/block-controls.mjs.map +2 -2
  193. package/build-module/cover/edit/embed-video-url-input.mjs +5 -4
  194. package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
  195. package/build-module/cover/edit/index.mjs +79 -35
  196. package/build-module/cover/edit/index.mjs.map +2 -2
  197. package/build-module/cover/embed-video-utils.mjs +16 -7
  198. package/build-module/cover/embed-video-utils.mjs.map +2 -2
  199. package/build-module/details/transforms.mjs +2 -7
  200. package/build-module/details/transforms.mjs.map +2 -2
  201. package/build-module/embed/edit.mjs +1 -1
  202. package/build-module/embed/edit.mjs.map +2 -2
  203. package/build-module/embed/embed-placeholder.mjs +1 -2
  204. package/build-module/embed/embed-placeholder.mjs.map +2 -2
  205. package/build-module/file/edit.mjs +4 -3
  206. package/build-module/file/edit.mjs.map +2 -2
  207. package/build-module/file/transforms.mjs +25 -60
  208. package/build-module/file/transforms.mjs.map +2 -2
  209. package/build-module/gallery/block.json +4 -2
  210. package/build-module/gallery/dynamic-gallery.mjs +104 -61
  211. package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
  212. package/build-module/gallery/edit.mjs +3 -3
  213. package/build-module/gallery/edit.mjs.map +2 -2
  214. package/build-module/gallery/gap-styles.mjs +53 -14
  215. package/build-module/gallery/gap-styles.mjs.map +2 -2
  216. package/build-module/gallery/use-dynamic-gallery.mjs +16 -9
  217. package/build-module/gallery/use-dynamic-gallery.mjs.map +2 -2
  218. package/build-module/group/transforms.mjs +2 -5
  219. package/build-module/group/transforms.mjs.map +2 -2
  220. package/build-module/heading/edit.mjs +1 -1
  221. package/build-module/heading/edit.mjs.map +2 -2
  222. package/build-module/html/modal.mjs +68 -55
  223. package/build-module/html/modal.mjs.map +2 -2
  224. package/build-module/icon/block.json +5 -3
  225. package/build-module/icon/components/custom-inserter/icon-grid.mjs +25 -12
  226. package/build-module/icon/components/custom-inserter/icon-grid.mjs.map +2 -2
  227. package/build-module/icon/components/custom-inserter/index.mjs +102 -33
  228. package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
  229. package/build-module/icon/edit.mjs +11 -12
  230. package/build-module/icon/edit.mjs.map +2 -2
  231. package/build-module/image/block.json +1 -1
  232. package/build-module/image/edit.mjs +1 -35
  233. package/build-module/image/edit.mjs.map +2 -2
  234. package/build-module/image/image.mjs +23 -18
  235. package/build-module/image/image.mjs.map +2 -2
  236. package/build-module/image/transforms.mjs +78 -0
  237. package/build-module/image/transforms.mjs.map +2 -2
  238. package/build-module/image/use-open-image-media-editor-modal.mjs +6 -2
  239. package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
  240. package/build-module/index.mjs +18 -8
  241. package/build-module/index.mjs.map +2 -2
  242. package/build-module/latest-posts/edit.mjs +5 -8
  243. package/build-module/latest-posts/edit.mjs.map +2 -2
  244. package/build-module/list-item/edit.mjs +1 -1
  245. package/build-module/list-item/edit.mjs.map +2 -2
  246. package/build-module/list-item/hooks/use-enter.mjs +15 -21
  247. package/build-module/list-item/hooks/use-enter.mjs.map +2 -2
  248. package/build-module/list-item/hooks/use-indent-list-item.mjs +10 -2
  249. package/build-module/list-item/hooks/use-indent-list-item.mjs.map +2 -2
  250. package/build-module/list-item/hooks/use-space.mjs +4 -6
  251. package/build-module/list-item/hooks/use-space.mjs.map +2 -2
  252. package/build-module/math/edit.mjs +41 -60
  253. package/build-module/math/edit.mjs.map +2 -2
  254. package/build-module/media-text/edit.mjs +2 -1
  255. package/build-module/media-text/edit.mjs.map +2 -2
  256. package/build-module/more/edit.mjs +2 -2
  257. package/build-module/more/edit.mjs.map +2 -2
  258. package/build-module/navigation/edit/index.mjs +30 -16
  259. package/build-module/navigation/edit/index.mjs.map +2 -2
  260. package/build-module/navigation/edit/use-layout-custom-properties.mjs +51 -0
  261. package/build-module/navigation/edit/use-layout-custom-properties.mjs.map +7 -0
  262. package/build-module/navigation/view.mjs +9 -6
  263. package/build-module/navigation/view.mjs.map +2 -2
  264. package/build-module/navigation-link/edit.mjs +3 -3
  265. package/build-module/navigation-link/edit.mjs.map +2 -2
  266. package/build-module/navigation-link/link-ui/index.mjs +2 -2
  267. package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
  268. package/build-module/paragraph/edit.mjs +6 -2
  269. package/build-module/paragraph/edit.mjs.map +2 -2
  270. package/build-module/paragraph/index.mjs +4 -1
  271. package/build-module/paragraph/index.mjs.map +2 -2
  272. package/build-module/paragraph/use-enter.mjs +4 -11
  273. package/build-module/paragraph/use-enter.mjs.map +2 -2
  274. package/build-module/playlist/block.json +29 -10
  275. package/build-module/playlist/context.mjs +2 -1
  276. package/build-module/playlist/context.mjs.map +2 -2
  277. package/build-module/playlist/edit.mjs +331 -41
  278. package/build-module/playlist/edit.mjs.map +2 -2
  279. package/build-module/playlist/index.mjs +1 -1
  280. package/build-module/playlist/index.mjs.map +2 -2
  281. package/build-module/playlist/utils.mjs +35 -7
  282. package/build-module/playlist/utils.mjs.map +2 -2
  283. package/build-module/playlist/view.mjs +89 -14
  284. package/build-module/playlist/view.mjs.map +2 -2
  285. package/build-module/playlist-track/block.json +4 -2
  286. package/build-module/playlist-track/edit.mjs +117 -71
  287. package/build-module/playlist-track/edit.mjs.map +2 -2
  288. package/build-module/post-content/block.json +1 -0
  289. package/build-module/post-content/edit.mjs +37 -15
  290. package/build-module/post-content/edit.mjs.map +2 -2
  291. package/build-module/post-featured-image/edit.mjs +3 -2
  292. package/build-module/post-featured-image/edit.mjs.map +2 -2
  293. package/build-module/post-template/block.json +2 -1
  294. package/build-module/post-template/edit.mjs +10 -1
  295. package/build-module/post-template/edit.mjs.map +2 -2
  296. package/build-module/post-terms/edit.mjs +2 -2
  297. package/build-module/post-terms/edit.mjs.map +2 -2
  298. package/build-module/post-title/edit.mjs +2 -2
  299. package/build-module/post-title/edit.mjs.map +2 -2
  300. package/build-module/preformatted/edit.mjs +3 -1
  301. package/build-module/preformatted/edit.mjs.map +2 -2
  302. package/build-module/pullquote/block.json +3 -1
  303. package/build-module/pullquote/edit.mjs +5 -3
  304. package/build-module/pullquote/edit.mjs.map +2 -2
  305. package/build-module/query/block.json +3 -2
  306. package/build-module/query/edit/inspector-controls/index.mjs +44 -6
  307. package/build-module/query/edit/inspector-controls/index.mjs.map +2 -2
  308. package/build-module/query/edit/inspector-controls/offset-controls.mjs +2 -3
  309. package/build-module/query/edit/inspector-controls/offset-controls.mjs.map +2 -2
  310. package/build-module/query/edit/inspector-controls/pages-control.mjs +0 -1
  311. package/build-module/query/edit/inspector-controls/pages-control.mjs.map +2 -2
  312. package/build-module/query/edit/query-content.mjs +10 -3
  313. package/build-module/query/edit/query-content.mjs.map +2 -2
  314. package/build-module/query/index.mjs +2 -1
  315. package/build-module/query/index.mjs.map +2 -2
  316. package/build-module/quote/block.json +3 -1
  317. package/build-module/quote/transforms.mjs +2 -4
  318. package/build-module/quote/transforms.mjs.map +2 -2
  319. package/build-module/read-more/edit.mjs +3 -1
  320. package/build-module/read-more/edit.mjs.map +2 -2
  321. package/build-module/rss/edit.mjs +0 -1
  322. package/build-module/rss/edit.mjs.map +2 -2
  323. package/build-module/site-tagline/edit.mjs +3 -1
  324. package/build-module/site-tagline/edit.mjs.map +2 -2
  325. package/build-module/site-title/edit.mjs +3 -1
  326. package/build-module/site-title/edit.mjs.map +2 -2
  327. package/build-module/social-links/edit.mjs +11 -4
  328. package/build-module/social-links/edit.mjs.map +2 -2
  329. package/build-module/tab-list/block.json +4 -3
  330. package/build-module/tab-list/edit.mjs +74 -13
  331. package/build-module/tab-list/edit.mjs.map +2 -2
  332. package/build-module/tab-list/tab-movers.mjs +59 -0
  333. package/build-module/tab-list/tab-movers.mjs.map +7 -0
  334. package/build-module/tab-panel/block.json +1 -6
  335. package/build-module/tab-panel/edit.mjs +17 -25
  336. package/build-module/tab-panel/edit.mjs.map +2 -2
  337. package/build-module/tab-panels/block.json +0 -1
  338. package/build-module/table/edit.mjs +1 -1
  339. package/build-module/table/edit.mjs.map +2 -2
  340. package/build-module/tabs/block.json +0 -5
  341. package/build-module/tabs/edit.mjs +5 -45
  342. package/build-module/tabs/edit.mjs.map +2 -2
  343. package/build-module/tabs/use-tab-actions.mjs +23 -1
  344. package/build-module/tabs/use-tab-actions.mjs.map +2 -2
  345. package/build-module/tabs/use-tab-list-items-sync.mjs +19 -1
  346. package/build-module/tabs/use-tab-list-items-sync.mjs.map +2 -2
  347. package/build-module/term-name/block.json +1 -3
  348. package/build-module/term-name/deprecated.mjs +74 -0
  349. package/build-module/term-name/deprecated.mjs.map +7 -0
  350. package/build-module/term-name/edit.mjs +11 -28
  351. package/build-module/term-name/edit.mjs.map +2 -2
  352. package/build-module/term-name/index.mjs +3 -1
  353. package/build-module/term-name/index.mjs.map +2 -2
  354. package/build-module/utils/caption.mjs +2 -2
  355. package/build-module/utils/caption.mjs.map +2 -2
  356. package/build-module/utils/waveform-player.mjs +144 -23
  357. package/build-module/utils/waveform-player.mjs.map +2 -2
  358. package/build-module/utils/waveform-utils.mjs +310 -16
  359. package/build-module/utils/waveform-utils.mjs.map +2 -2
  360. package/build-module/verse/edit.mjs +3 -1
  361. package/build-module/verse/edit.mjs.map +2 -2
  362. package/build-module/video/edit.mjs +2 -11
  363. package/build-module/video/edit.mjs.map +2 -2
  364. package/build-module/video/tracks-editor.mjs +0 -1
  365. package/build-module/video/tracks-editor.mjs.map +2 -2
  366. package/build-style/cover/editor-rtl.css +3 -0
  367. package/build-style/cover/editor.css +3 -0
  368. package/build-style/editor-rtl.css +61 -59
  369. package/build-style/editor.css +61 -59
  370. package/build-style/icon/editor-rtl.css +80 -10
  371. package/build-style/icon/editor.css +80 -10
  372. package/build-style/image/editor-rtl.css +3 -32
  373. package/build-style/image/editor.css +3 -32
  374. package/build-style/more/editor-rtl.css +2 -2
  375. package/build-style/more/editor.css +2 -2
  376. package/build-style/navigation/editor-rtl.css +3 -4
  377. package/build-style/navigation/editor.css +3 -4
  378. package/build-style/navigation-link/editor-rtl.css +1 -1
  379. package/build-style/navigation-link/editor.css +1 -1
  380. package/build-style/nextpage/editor-rtl.css +2 -2
  381. package/build-style/nextpage/editor.css +2 -2
  382. package/build-style/playlist/editor-rtl.css +4 -3
  383. package/build-style/playlist/editor.css +4 -3
  384. package/build-style/playlist/style-rtl.css +81 -5
  385. package/build-style/playlist/style.css +81 -5
  386. package/build-style/playlist-track/style-rtl.css +10 -0
  387. package/build-style/playlist-track/style.css +10 -0
  388. package/build-style/pullquote/editor-rtl.css +4 -0
  389. package/build-style/pullquote/editor.css +4 -0
  390. package/build-style/style-rtl.css +91 -5
  391. package/build-style/style.css +91 -5
  392. package/build-style/tab-list/editor-rtl.css +101 -0
  393. package/build-style/tab-list/editor.css +101 -0
  394. package/build-style/video/editor-rtl.css +1 -1
  395. package/build-style/video/editor.css +1 -1
  396. package/build-types/table-of-contents/list.d.ts +1 -1
  397. package/build-types/table-of-contents/list.d.ts.map +1 -1
  398. package/package.json +47 -45
  399. package/src/accordion/README.md +1 -0
  400. package/src/accordion/block.json +1 -0
  401. package/src/accordion-panel/block.json +1 -0
  402. package/src/breadcrumbs/index.php +3 -1
  403. package/src/button/edit.js +21 -15
  404. package/src/button/index.php +1 -1
  405. package/src/code/edit.js +7 -2
  406. package/src/cover/README.md +60 -0
  407. package/src/cover/block.json +12 -0
  408. package/src/cover/edit/block-controls.js +26 -11
  409. package/src/cover/edit/embed-video-url-input.js +5 -4
  410. package/src/cover/edit/index.js +109 -46
  411. package/src/cover/editor.scss +6 -0
  412. package/src/cover/embed-video-utils.js +38 -13
  413. package/src/cover/index.php +9 -2
  414. package/src/details/transforms.js +2 -7
  415. package/src/editor.scss +1 -0
  416. package/src/embed/edit.js +3 -1
  417. package/src/embed/embed-placeholder.js +9 -8
  418. package/src/file/edit.js +8 -8
  419. package/src/file/transforms.js +28 -60
  420. package/src/form/index.php +6 -4
  421. package/src/gallery/README.md +1 -1
  422. package/src/gallery/block.json +4 -2
  423. package/src/gallery/dynamic-gallery.js +133 -74
  424. package/src/gallery/edit.js +3 -3
  425. package/src/gallery/gap-styles.js +79 -20
  426. package/src/gallery/index.php +103 -43
  427. package/src/gallery/use-dynamic-gallery.js +27 -12
  428. package/src/group/transforms.js +2 -5
  429. package/src/heading/edit.js +1 -1
  430. package/src/html/modal.js +13 -2
  431. package/src/icon/README.md +1 -3
  432. package/src/icon/block.json +5 -3
  433. package/src/icon/components/custom-inserter/icon-grid.js +40 -11
  434. package/src/icon/components/custom-inserter/index.js +98 -25
  435. package/src/icon/edit.js +11 -17
  436. package/src/icon/editor.scss +33 -11
  437. package/src/image/README.md +1 -1
  438. package/src/image/block.json +1 -1
  439. package/src/image/edit.js +1 -57
  440. package/src/image/editor.scss +6 -44
  441. package/src/image/image.js +56 -27
  442. package/src/image/test/use-open-image-media-editor-modal.js +37 -1
  443. package/src/image/transforms.js +128 -0
  444. package/src/image/use-open-image-media-editor-modal.js +8 -1
  445. package/src/index.js +19 -7
  446. package/src/latest-posts/edit.js +5 -8
  447. package/src/latest-posts/index.php +49 -18
  448. package/src/list-item/edit.js +1 -1
  449. package/src/list-item/hooks/use-enter.js +15 -22
  450. package/src/list-item/hooks/use-indent-list-item.js +10 -1
  451. package/src/list-item/hooks/use-space.js +4 -6
  452. package/src/math/edit.js +42 -59
  453. package/src/media-text/edit.js +1 -0
  454. package/src/media-text/editor.scss +1 -0
  455. package/src/media-text/index.php +11 -2
  456. package/src/more/edit.js +7 -4
  457. package/src/more/editor.scss +1 -1
  458. package/src/navigation/edit/index.js +52 -36
  459. package/src/navigation/edit/test/layout-custom-properties.js +138 -0
  460. package/src/navigation/edit/use-layout-custom-properties.js +84 -0
  461. package/src/navigation/editor.scss +1 -2
  462. package/src/navigation/index.php +123 -12
  463. package/src/navigation/test/view.js +51 -0
  464. package/src/navigation/view.js +15 -14
  465. package/src/navigation-link/edit.js +11 -7
  466. package/src/navigation-link/editor.scss +1 -1
  467. package/src/navigation-link/index.php +70 -3
  468. package/src/navigation-link/link-ui/index.js +2 -1
  469. package/src/navigation-link/test/__snapshots__/hooks.js.snap +1 -1
  470. package/src/navigation-submenu/index.php +6 -3
  471. package/src/nextpage/editor.scss +1 -1
  472. package/src/page-list/index.php +4 -3
  473. package/src/paragraph/edit.js +9 -2
  474. package/src/paragraph/index.js +4 -1
  475. package/src/paragraph/use-enter.js +4 -11
  476. package/src/pattern/index.php +5 -5
  477. package/src/playlist/README.md +17 -18
  478. package/src/playlist/block.json +29 -10
  479. package/src/playlist/context.js +1 -0
  480. package/src/playlist/edit.js +395 -59
  481. package/src/playlist/editor.scss +4 -5
  482. package/src/playlist/index.js +1 -1
  483. package/src/playlist/index.php +71 -22
  484. package/src/playlist/style.scss +54 -1
  485. package/src/playlist/test/edit-component.js +139 -0
  486. package/src/playlist/test/edit.js +43 -2
  487. package/src/playlist/utils.js +49 -10
  488. package/src/playlist/view.js +97 -16
  489. package/src/playlist-track/README.md +3 -3
  490. package/src/playlist-track/block.json +4 -2
  491. package/src/playlist-track/edit.js +116 -75
  492. package/src/playlist-track/index.php +26 -11
  493. package/src/playlist-track/style.scss +10 -0
  494. package/src/playlist-track/test/edit.js +253 -0
  495. package/src/post-content/README.md +1 -0
  496. package/src/post-content/block.json +1 -0
  497. package/src/post-content/edit.js +45 -16
  498. package/src/post-excerpt/index.php +4 -1
  499. package/src/post-featured-image/edit.js +3 -2
  500. package/src/post-featured-image/index.php +4 -1
  501. package/src/post-template/README.md +1 -0
  502. package/src/post-template/block.json +2 -1
  503. package/src/post-template/edit.js +9 -0
  504. package/src/post-terms/edit.js +7 -4
  505. package/src/post-title/edit.js +5 -3
  506. package/src/preformatted/edit.js +7 -2
  507. package/src/pullquote/README.md +1 -0
  508. package/src/pullquote/block.json +3 -1
  509. package/src/pullquote/edit.js +9 -4
  510. package/src/pullquote/editor.scss +6 -0
  511. package/src/query/README.md +2 -1
  512. package/src/query/block.json +3 -2
  513. package/src/query/edit/inspector-controls/index.js +47 -4
  514. package/src/query/edit/inspector-controls/offset-controls.js +2 -3
  515. package/src/query/edit/inspector-controls/pages-control.js +0 -1
  516. package/src/query/edit/query-content.js +19 -3
  517. package/src/query/index.js +1 -0
  518. package/src/quote/README.md +1 -0
  519. package/src/quote/block.json +3 -1
  520. package/src/quote/transforms.js +2 -4
  521. package/src/read-more/edit.js +7 -2
  522. package/src/rss/edit.js +0 -1
  523. package/src/rss/index.php +10 -4
  524. package/src/site-tagline/edit.js +7 -2
  525. package/src/site-title/edit.js +7 -2
  526. package/src/social-link/index.php +19 -9
  527. package/src/social-links/edit.js +21 -12
  528. package/src/tab-list/README.md +4 -5
  529. package/src/tab-list/block.json +4 -3
  530. package/src/tab-list/edit.js +92 -28
  531. package/src/tab-list/editor.scss +9 -0
  532. package/src/tab-list/index.php +9 -4
  533. package/src/tab-list/tab-movers.js +72 -0
  534. package/src/tab-panel/README.md +4 -6
  535. package/src/tab-panel/block.json +1 -6
  536. package/src/tab-panel/edit.js +20 -33
  537. package/src/tab-panels/README.md +5 -3
  538. package/src/tab-panels/block.json +0 -1
  539. package/src/table/edit.js +1 -1
  540. package/src/table-of-contents/index.php +386 -1
  541. package/src/tabs/README.md +18 -9
  542. package/src/tabs/block.json +0 -5
  543. package/src/tabs/edit.js +7 -64
  544. package/src/tabs/use-tab-actions.js +32 -3
  545. package/src/tabs/use-tab-list-items-sync.js +24 -4
  546. package/src/tag-cloud/index.php +3 -2
  547. package/src/template-part/index.php +3 -17
  548. package/src/term-name/README.md +1 -1
  549. package/src/term-name/block.json +1 -3
  550. package/src/term-name/deprecated.js +74 -0
  551. package/src/term-name/edit.js +2 -18
  552. package/src/term-name/index.js +2 -0
  553. package/src/utils/caption.js +7 -4
  554. package/src/utils/media-control.scss +1 -5
  555. package/src/utils/test/waveform-player.js +297 -34
  556. package/src/utils/test/waveform-utils.js +473 -5
  557. package/src/utils/waveform-player.js +189 -59
  558. package/src/utils/waveform-utils.js +443 -40
  559. package/src/verse/edit.js +7 -2
  560. package/src/video/edit.js +0 -8
  561. package/src/video/editor.scss +1 -1
  562. package/src/video/index.php +2 -2
  563. package/src/video/tracks-editor.js +0 -1
  564. package/build/image/animated-gif-convert-control.cjs +0 -105
  565. package/build/image/animated-gif-convert-control.cjs.map +0 -7
  566. package/build/utils/gif-conversion-attributes.cjs +0 -40
  567. package/build/utils/gif-conversion-attributes.cjs.map +0 -7
  568. package/build/video/gif-restore-control.cjs +0 -73
  569. package/build/video/gif-restore-control.cjs.map +0 -7
  570. package/build-module/image/animated-gif-convert-control.mjs +0 -87
  571. package/build-module/image/animated-gif-convert-control.mjs.map +0 -7
  572. package/build-module/utils/gif-conversion-attributes.mjs +0 -15
  573. package/build-module/utils/gif-conversion-attributes.mjs.map +0 -7
  574. package/build-module/video/gif-restore-control.mjs +0 -55
  575. package/build-module/video/gif-restore-control.mjs.map +0 -7
  576. package/src/image/animated-gif-convert-control.js +0 -135
  577. package/src/image/test/animated-gif-convert-control.js +0 -276
  578. package/src/utils/gif-conversion-attributes.js +0 -30
  579. package/src/utils/test/gif-conversion-attributes.js +0 -60
  580. package/src/video/gif-restore-control.js +0 -92
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/navigation-link/edit.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { useMergeRefs, useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getColors } from '../navigation/edit/utils';\nimport {\n\tControls,\n\tLinkUI,\n\tuseEntityBinding,\n\tgetInvalidLinkHelpText,\n\tuseHandleLinkChange,\n\tuseIsInvalidLink,\n\tInvalidDraftDisplay,\n\tuseEnableLinkStatusValidation,\n\tuseIsDraggingWithin,\n\tselectLabelText,\n} from './shared';\n\nconst DEFAULT_BLOCK = { name: 'core/navigation-link' };\nconst NESTING_BLOCK_NAMES = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\nfunction getMissingText( type ) {\n\tlet missingText = '';\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\t\t/* translators: label for missing post in navigation link block */\n\t\t\tmissingText = __( 'Select post' );\n\t\t\tbreak;\n\t\tcase 'page':\n\t\t\t/* translators: label for missing page in navigation link block */\n\t\t\tmissingText = __( 'Select page' );\n\t\t\tbreak;\n\t\tcase 'category':\n\t\t\t/* translators: label for missing category in navigation link block */\n\t\t\tmissingText = __( 'Select category' );\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\t/* translators: label for missing tag in navigation link block */\n\t\t\tmissingText = __( 'Select tag' );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t/* translators: label for missing values in navigation link block */\n\t\t\tmissingText = __( 'Add link' );\n\t}\n\n\treturn missingText;\n}\n\nexport default function NavigationLinkEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { id, label, type, url, description, kind, metadata } = attributes;\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\t// Have the link editing ui open on mount when lacking a url and selected.\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add label…' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\t// A link is \"new\" only if it has an undefined label\n\t// After the link is created, even if no label is provided, it's set to an empty string.\n\tconst isNewLink = useRef( label === undefined );\n\t// Track whether we should focus the submenu appender when closing the link UI\n\tconst shouldSelectSubmenuAppenderOnClose = useRef( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t\tparentBlockClientId,\n\t\tisSubmenu,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockName = getBlockName( rootClientId );\n\t\t\tconst isTopLevel = parentBlockName === 'core/navigation';\n\t\t\tconst rootNavigationClientId = isTopLevel\n\t\t\t\t? rootClientId\n\t\t\t\t: getBlockParentsByBlockName(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'core/navigation'\n\t\t\t\t )[ 0 ];\n\n\t\t\t// Get the immediate parent - if it's a submenu, use it; otherwise use the navigation block\n\t\t\tconst parentBlockId =\n\t\t\t\tparentBlockName === 'core/navigation-submenu'\n\t\t\t\t\t? rootClientId\n\t\t\t\t\t: rootNavigationClientId;\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, NESTING_BLOCK_NAMES )\n\t\t\t\t\t\t.length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink: isTopLevel,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tparentBlockClientId: parentBlockId,\n\t\t\t\tisSubmenu: parentBlockName === 'core/navigation-submenu',\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\n\tconst validateLinkStatus = useEnableLinkStatusValidation( clientId );\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t// URL binding logic\n\tconst { hasUrlBinding, isBoundEntityAvailable, entityRecord } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\tconst handleLinkChange = useHandleLinkChange( {\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tallowTextUpdate: true,\n\t} );\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\n\t);\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tconst transformToSubmenu = useCallback( () => {\n\t\tlet innerBlocks = getBlocks( clientId );\n\t\tif ( innerBlocks.length === 0 ) {\n\t\t\tinnerBlocks = [ createBlock( 'core/navigation-link' ) ];\n\t\t\tselectBlock( innerBlocks[ 0 ].clientId );\n\t\t}\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t}, [ getBlocks, clientId, selectBlock, replaceBlock, attributes ] );\n\n\t// On mount, if this is a new link without a URL and it's selected,\n\t// select the parent block (submenu or navigation) instead to keep the appender visible.\n\t// This helps us return focus to the appender if the user closes the link ui without creating a link.\n\t// If we leave focus on this block, then when we close the link without creating a link, focus will\n\t// be lost during the new block selection process.\n\tuseEffect( () => {\n\t\tif ( isNewLink.current && isSelected ) {\n\t\t\tselectBlock( parentBlockClientId );\n\t\t}\n\t}, [] ); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [\n\t\thasChildren,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\ttransformToSubmenu,\n\t] );\n\n\t// Handle link UI when a new link is created\n\tuseEffect( () => {\n\t\t// We know if a link was just created from our link UI if\n\t\t// 1. isNewLink.current is true\n\t\t// 2. url has a value\n\t\t// 3. isLinkOpen is true\n\t\tif ( ! isNewLink.current || ! url || ! isLinkOpen ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure this only runs once\n\t\tisNewLink.current = false;\n\n\t\t// We just created a link and the block is now selected.\n\t\t// If the label looks like a URL, focus and select the label text.\n\t\tif ( isURL( prependHTTP( label ) ) && /^.+\\.[a-z]+/.test( label ) ) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText( ref );\n\t\t} else {\n\t\t\t// If the link was just created, we want to select the block so the inspector controls\n\t\t\t// are accurate.\n\t\t\tselectBlock( clientId, null );\n\n\t\t\t// Edge case: When the created link is the first child of a submenu, the focus will have\n\t\t\t// originated from the add submenu toolbar button. In this case, we need to return focus\n\t\t\t// to the submenu appender if the user closes the link ui using the keyboard.\n\t\t\t// Check if this is the first and only child of a newly created submenu.\n\t\t\tif ( isSubmenu ) {\n\t\t\t\tconst parentBlocks = getBlocks( parentBlockClientId );\n\t\t\t\t// If this is the only child, then this is a new submenu.\n\t\t\t\t// Set the flag to select the submenu appender when the link ui is closed.\n\t\t\t\tif (\n\t\t\t\t\tparentBlocks.length === 1 &&\n\t\t\t\t\tparentBlocks[ 0 ].clientId === clientId\n\t\t\t\t) {\n\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ url, isLinkOpen, isNewLink, label ] );\n\n\t/**\n\t * Removes the current link if set.\n\t */\n\tfunction removeLink() {\n\t\t// Reset all attributes that comprise the link.\n\t\t// It is critical that all attributes are reset\n\t\t// to their default values otherwise this may\n\t\t// in advertently trigger side effects because\n\t\t// the values will have \"changed\".\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlabel: undefined,\n\t\t\tid: undefined,\n\t\t\tkind: undefined,\n\t\t\ttype: undefined,\n\t\t\topensInNewTab: false,\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelLink );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst instanceId = useInstanceId( NavigationLinkEdit );\n\tconst hasMissingEntity = hasUrlBinding && ! isBoundEntityAvailable;\n\tconst missingEntityDescriptionId = hasMissingEntity\n\t\t? sprintf( 'navigation-link-edit-%d-desc', instanceId )\n\t\t: undefined;\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t} ),\n\t\t'aria-describedby': missingEntityDescriptionId,\n\t\t'aria-invalid': hasMissingEntity,\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\n\t);\n\n\tconst needsValidLink =\n\t\t( ! url && ! ( hasUrlBinding && isBoundEntityAvailable ) ) ||\n\t\tisInvalid ||\n\t\tisDraft ||\n\t\t( hasUrlBinding && ! isBoundEntityAvailable );\n\n\tif ( needsValidLink ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': needsValidLink,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\tconst invalidLinkHelpText = getInvalidLinkHelpText();\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isAtMaxNesting && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"submenu\"\n\t\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\t\ttitle={ __( 'Add submenu' ) }\n\t\t\t\t\t\t\tonClick={ transformToSubmenu }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ hasMissingEntity && (\n\t\t\t\t\t<VisuallyHidden id={ missingEntityDescriptionId }>\n\t\t\t\t\t\t{ invalidLinkHelpText }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<a className={ classes }>\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{ ! url && ! metadata?.bindings?.url ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isInvalid && ! isDraft && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: labelValue,\n\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isInvalid || isDraft ) && (\n\t\t\t\t\t\t\t\t<InvalidDraftDisplay\n\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\tisInvalid={ isInvalid }\n\t\t\t\t\t\t\t\t\tisDraft={ isDraft }\n\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-link__label\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tref={ linkUIref }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tentity={ {\n\t\t\t\t\t\t\t\tentityRecord,\n\t\t\t\t\t\t\t\thasBinding: hasUrlBinding,\n\t\t\t\t\t\t\t\tisEntityAvailable: isBoundEntityAvailable,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\t// If there is no link and no binding, remove the auto-inserted block.\n\t\t\t\t\t\t\t\t// This avoids empty blocks which can provided a poor UX.\n\t\t\t\t\t\t\t\t// Don't remove if binding exists (even if entity is unavailable) so user can fix it.\n\t\t\t\t\t\t\t\tif ( ! url && ! hasUrlBinding ) {\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Edge case: If this is the first child of a new submenu, focus the submenu's appender\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = false;\n\n\t\t\t\t\t\t\t\t\t// The appender is the next sibling in the DOM after the current block\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlistItemRef.current?.nextElementSibling\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tconst appenderButton =\n\t\t\t\t\t\t\t\t\t\t\tlistItemRef.current.nextElementSibling.querySelector(\n\t\t\t\t\t\t\t\t\t\t\t\t'.block-editor-button-block-appender'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif ( appenderButton ) {\n\t\t\t\t\t\t\t\t\t\t\tappenderButton.focus();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ handleLinkChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,mBAAmB;AAC5B,SAAS,WAAW,mBA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gBACV,OAAQ;AAAA,gBACR,UAAW,CAAE,eACZ,cAAe;AAAA,kBACd,OAAO;AAAA,gBACR,CAAE;AAAA,gBAEH,SAAU;AAAA,gBACV;AAAA,gBACA,wBAAyB,MACxB;AAAA,kBACC;AAAA,oBACC;AAAA,kBACD;AAAA,gBACD;AAAA,gBAED,cAAa;AAAA,kBACZ;AAAA,gBACD;AAAA,gBACA,aAAc;AAAA,gBACd,8BAA4B;AAAA;AAAA,YAC7B;AAAA,YACE,eACD,oBAAC,UAAK,WAAU,yCACb,uBACH;AAAA,aAEF;AAAA,WAEG,aAAa,YAChB;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAU;AAAA;AAAA,UACX;AAAA,WAEF;AAAA,QAEC,cACD;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN;AAAA,YACA,MAAO;AAAA,YACP,QAAS;AAAA,cACR;AAAA,cACA,YAAY;AAAA,cACZ,mBAAmB;AAAA,YACpB;AAAA,YACA,SAAU,MAAM;AACf,4BAAe,KAAM;AAIrB,kBAAK,CAAE,OAAO,CAAE,eAAgB;AAC/B,0BAAW,CAAC,CAAE;AACd;AAAA,cACD;AAGA,kBACC,mCAAmC,SAClC;AACD,mDAAmC,UAAU;AAG7C,oBACC,YAAY,SAAS,oBACpB;AACD,wBAAM,iBACL,YAAY,QAAQ,mBAAmB;AAAA,oBACtC;AAAA,kBACD;AACD,sBAAK,gBAAiB;AACrB,mCAAe,MAAM;AAAA,kBACtB;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,YACA,QAAS;AAAA,YACT,UAAW;AAAA,YACX,UAAW;AAAA;AAAA,QACZ;AAAA,SAEF;AAAA,MACA,oBAAC,SAAM,GAAG,kBAAmB;AAAA,OAC9B;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef, useCallback } from '@wordpress/element';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport { useMergeRefs, useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getColors } from '../navigation/edit/utils';\nimport {\n\tControls,\n\tLinkUI,\n\tuseEntityBinding,\n\tgetInvalidLinkHelpText,\n\tuseHandleLinkChange,\n\tuseIsInvalidLink,\n\tInvalidDraftDisplay,\n\tuseEnableLinkStatusValidation,\n\tuseIsDraggingWithin,\n\tselectLabelText,\n} from './shared';\n\nconst DEFAULT_BLOCK = { name: 'core/navigation-link' };\nconst NESTING_BLOCK_NAMES = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n];\n\nfunction getMissingText( type ) {\n\tlet missingText = '';\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\t\t/* translators: label for missing post in navigation link block */\n\t\t\tmissingText = __( 'Select post' );\n\t\t\tbreak;\n\t\tcase 'page':\n\t\t\t/* translators: label for missing page in navigation link block */\n\t\t\tmissingText = __( 'Select page' );\n\t\t\tbreak;\n\t\tcase 'category':\n\t\t\t/* translators: label for missing category in navigation link block */\n\t\t\tmissingText = __( 'Select category' );\n\t\t\tbreak;\n\t\tcase 'tag':\n\t\t\t/* translators: label for missing tag in navigation link block */\n\t\t\tmissingText = __( 'Select tag' );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t/* translators: label for missing values in navigation link block */\n\t\t\tmissingText = __( 'Add link' );\n\t}\n\n\treturn missingText;\n}\n\nexport default function NavigationLinkEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { id, label, type, url, description, kind, metadata } = attributes;\n\tconst { maxNestingLevel } = context;\n\n\tconst {\n\t\treplaceBlock,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tselectBlock,\n\t} = useDispatch( blockEditorStore );\n\t// Have the link editing ui open on mount when lacking a url and selected.\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( isSelected && ! url );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add label…' );\n\tconst ref = useRef();\n\tconst linkUIref = useRef();\n\t// A link is \"new\" only if it has an undefined label\n\t// After the link is created, even if no label is provided, it's set to an empty string.\n\tconst isNewLink = useRef( label === undefined );\n\t// Track whether we should focus the submenu appender when closing the link UI\n\tconst shouldSelectSubmenuAppenderOnClose = useRef( false );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t\tparentBlockClientId,\n\t\tisSubmenu,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockName = getBlockName( rootClientId );\n\t\t\tconst isTopLevel = parentBlockName === 'core/navigation';\n\t\t\tconst rootNavigationClientId = isTopLevel\n\t\t\t\t? rootClientId\n\t\t\t\t: getBlockParentsByBlockName(\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t'core/navigation'\n\t\t\t\t )[ 0 ];\n\n\t\t\t// Get the immediate parent - if it's a submenu, use it; otherwise use the navigation block\n\t\t\tconst parentBlockId =\n\t\t\t\tparentBlockName === 'core/navigation-submenu'\n\t\t\t\t\t? rootClientId\n\t\t\t\t\t: rootNavigationClientId;\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, NESTING_BLOCK_NAMES )\n\t\t\t\t\t\t.length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink: isTopLevel,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tparentBlockClientId: parentBlockId,\n\t\t\t\tisSubmenu: parentBlockName === 'core/navigation-submenu',\n\t\t\t};\n\t\t},\n\t\t[ clientId, maxNestingLevel ]\n\t);\n\n\tconst validateLinkStatus = useEnableLinkStatusValidation( clientId );\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t// URL binding logic\n\tconst { hasUrlBinding, isBoundEntityAvailable, entityRecord } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\tconst handleLinkChange = useHandleLinkChange( {\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tallowTextUpdate: true,\n\t} );\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\n\t);\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tconst transformToSubmenu = useCallback( () => {\n\t\tlet innerBlocks = getBlocks( clientId );\n\t\tif ( innerBlocks.length === 0 ) {\n\t\t\tinnerBlocks = [ createBlock( 'core/navigation-link' ) ];\n\t\t\tselectBlock( innerBlocks[ 0 ].clientId );\n\t\t}\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t}, [ getBlocks, clientId, selectBlock, replaceBlock, attributes ] );\n\n\t// On mount, if this is a new link without a URL and it's selected,\n\t// select the parent block (submenu or navigation) instead to keep the appender visible.\n\t// This helps us return focus to the appender if the user closes the link ui without creating a link.\n\t// If we leave focus on this block, then when we close the link without creating a link, focus will\n\t// be lost during the new block selection process.\n\tuseEffect( () => {\n\t\tif ( isNewLink.current && isSelected ) {\n\t\t\tselectBlock( parentBlockClientId );\n\t\t}\n\t}, [] ); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [\n\t\thasChildren,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\ttransformToSubmenu,\n\t] );\n\n\t// Handle link UI when a new link is created\n\tuseEffect( () => {\n\t\t// We know if a link was just created from our link UI if\n\t\t// 1. isNewLink.current is true\n\t\t// 2. url has a value\n\t\t// 3. isLinkOpen is true\n\t\tif ( ! isNewLink.current || ! url || ! isLinkOpen ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Ensure this only runs once\n\t\tisNewLink.current = false;\n\n\t\t// We just created a link and the block is now selected.\n\t\t// If the label looks like a URL, focus and select the label text.\n\t\tif ( isURL( prependHTTP( label ) ) && /^.+\\.[a-z]+/.test( label ) ) {\n\t\t\t// Focus and select the label text.\n\t\t\tselectLabelText( ref );\n\t\t} else {\n\t\t\t// If the link was just created, we want to select the block so the inspector controls\n\t\t\t// are accurate.\n\t\t\tselectBlock( clientId, null );\n\n\t\t\t// Edge case: When the created link is the first child of a submenu, the focus will have\n\t\t\t// originated from the add submenu toolbar button. In this case, we need to return focus\n\t\t\t// to the submenu appender if the user closes the link ui using the keyboard.\n\t\t\t// Check if this is the first and only child of a newly created submenu.\n\t\t\tif ( isSubmenu ) {\n\t\t\t\tconst parentBlocks = getBlocks( parentBlockClientId );\n\t\t\t\t// If this is the only child, then this is a new submenu.\n\t\t\t\t// Set the flag to select the submenu appender when the link ui is closed.\n\t\t\t\tif (\n\t\t\t\t\tparentBlocks.length === 1 &&\n\t\t\t\t\tparentBlocks[ 0 ].clientId === clientId\n\t\t\t\t) {\n\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ url, isLinkOpen, isNewLink, label ] );\n\n\t/**\n\t * Removes the current link if set.\n\t */\n\tfunction removeLink() {\n\t\t// Reset all attributes that comprise the link.\n\t\t// It is critical that all attributes are reset\n\t\t// to their default values otherwise this may\n\t\t// in advertently trigger side effects because\n\t\t// the values will have \"changed\".\n\t\tsetAttributes( {\n\t\t\turl: undefined,\n\t\t\tlabel: undefined,\n\t\t\tid: undefined,\n\t\t\tkind: undefined,\n\t\t\ttype: undefined,\n\t\t\topensInNewTab: false,\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelLink );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If this link is a child of a parent submenu item, the parent submenu item event will also open, closing this popover\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst instanceId = useInstanceId( NavigationLinkEdit );\n\tconst hasMissingEntity = hasUrlBinding && ! isBoundEntityAvailable;\n\tconst missingEntityDescriptionId = hasMissingEntity\n\t\t? sprintf( 'navigation-link-edit-%d-desc', instanceId )\n\t\t: undefined;\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasChildren,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t} ),\n\t\t'aria-describedby': missingEntityDescriptionId,\n\t\t'aria-invalid': hasMissingEntity,\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\t\tdirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\n\t);\n\n\tconst needsValidLink =\n\t\t( ! url && ! ( hasUrlBinding && isBoundEntityAvailable ) ) ||\n\t\tisInvalid ||\n\t\tisDraft ||\n\t\t( hasUrlBinding && ! isBoundEntityAvailable );\n\n\tif ( needsValidLink ) {\n\t\tblockProps.onClick = () => {\n\t\t\tsetIsLinkOpen( true );\n\t\t};\n\t}\n\n\tconst classes = clsx( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': needsValidLink,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\tconst invalidLinkHelpText = getInvalidLinkHelpText();\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! isAtMaxNesting && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"submenu\"\n\t\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\t\ttitle={ __( 'Add submenu' ) }\n\t\t\t\t\t\t\tonClick={ transformToSubmenu }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ hasMissingEntity && (\n\t\t\t\t\t<VisuallyHidden id={ missingEntityDescriptionId }>\n\t\t\t\t\t\t{ invalidLinkHelpText }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<a className={ classes }>\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{ ! url && ! metadata?.bindings?.url ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isInvalid && ! isDraft && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: labelValue,\n\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\t\t\t__unstableOnSplitAtEnd={\n\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter\n\t\t\t\t\t\t\t\t\t\t\t\t? () =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinsertBlocksAfter(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t\t'Navigation link text'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ( isInvalid || isDraft ) && (\n\t\t\t\t\t\t\t\t<InvalidDraftDisplay\n\t\t\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\t\t\tisInvalid={ isInvalid }\n\t\t\t\t\t\t\t\t\tisDraft={ isDraft }\n\t\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-link__label\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tref={ linkUIref }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tentity={ {\n\t\t\t\t\t\t\t\tentityRecord,\n\t\t\t\t\t\t\t\thasBinding: hasUrlBinding,\n\t\t\t\t\t\t\t\tisEntityAvailable: isBoundEntityAvailable,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t\t// If there is no link and no binding, remove the auto-inserted block.\n\t\t\t\t\t\t\t\t// This avoids empty blocks which can provided a poor UX.\n\t\t\t\t\t\t\t\t// Don't remove if binding exists (even if entity is unavailable) so user can fix it.\n\t\t\t\t\t\t\t\t// `onReplace` is undefined when the block can't be removed.\n\t\t\t\t\t\t\t\tif ( ! url && ! hasUrlBinding && onReplace ) {\n\t\t\t\t\t\t\t\t\tonReplace( [] );\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// Edge case: If this is the first child of a new submenu, focus the submenu's appender\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tshouldSelectSubmenuAppenderOnClose.current = false;\n\n\t\t\t\t\t\t\t\t\t// The appender is the next sibling in the DOM after the current block\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tlistItemRef.current?.nextElementSibling\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tconst appenderButton =\n\t\t\t\t\t\t\t\t\t\t\tlistItemRef.current.nextElementSibling.querySelector(\n\t\t\t\t\t\t\t\t\t\t\t\t'.block-editor-button-block-appender'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tif ( appenderButton ) {\n\t\t\t\t\t\t\t\t\t\t\tappenderButton.focus();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ handleLinkChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,mBAAmB;AAC5B,SAAS,WAAW,mBAAmB;AACvC,SAAS,eAAe,oBAAoB;AAC5C,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,OACM;AACP,SAAS,OAAO,mBAAmB;AACnC,SAAS,UAAU,WAAW,QAAQ,mBAAmB;AACzD,SAAS,sBAAsB;AAC/B,SAAS,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AAA;AAAA,YAC7B;AAAA,YACE,eACD,oBAAC,UAAK,WAAU,yCACb,uBACH;AAAA,aAEF;AAAA,WAEG,aAAa,YAChB;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAU;AAAA;AAAA,UACX;AAAA,WAEF;AAAA,QAEC,cACD;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN;AAAA,YACA,MAAO;AAAA,YACP,QAAS;AAAA,cACR;AAAA,cACA,YAAY;AAAA,cACZ,mBAAmB;AAAA,YACpB;AAAA,YACA,SAAU,MAAM;AACf,4BAAe,KAAM;AAKrB,kBAAK,CAAE,OAAO,CAAE,iBAAiB,WAAY;AAC5C,0BAAW,CAAC,CAAE;AACd;AAAA,cACD;AAGA,kBACC,mCAAmC,SAClC;AACD,mDAAmC,UAAU;AAG7C,oBACC,YAAY,SAAS,oBACpB;AACD,wBAAM,iBACL,YAAY,QAAQ,mBAAmB;AAAA,oBACtC;AAAA,kBACD;AACD,sBAAK,gBAAiB;AACrB,mCAAe,MAAM;AAAA,kBACtB;AAAA,gBACD;AAAA,cACD;AAAA,YACD;AAAA,YACA,QAAS;AAAA,YACT,UAAW;AAAA,YACX,UAAW;AAAA;AAAA,QACZ;AAAA,SAEF;AAAA,MACA,oBAAC,SAAM,GAAG,kBAAmB;AAAA,OAC9B;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -196,8 +196,8 @@ function UnforwardedLinkUI(props, ref) {
196
196
  setAddingPage: () => {
197
197
  setAddingPage(true);
198
198
  },
199
- canAddPage: permissions?.canCreate && type === "page",
200
- canAddBlock: blockEditingMode === "default"
199
+ canAddPage: blockEditingMode !== "disabled" && permissions?.canCreate && type === "page",
200
+ canAddBlock: blockEditingMode !== "disabled"
201
201
  }
202
202
  );
203
203
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/navigation-link/link-ui/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML, focus } from '@wordpress/dom';\nimport {\n\tPopover,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { LinkControl, useBlockEditingMode } from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { LinkUIPageCreator } from './page-creator';\nimport LinkUIBlockInserter from './block-inserter';\nimport { useEntityBinding, useLinkPreview } from '../shared';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\t// How many results to show initially and per search.\n\tconst perPage = 20;\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type, perPage };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category', perPage };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag', perPage };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format', perPage };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type, perPage };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type, perPage };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// for custom link which has no type\n\t\t\t\t// always show pages as initial suggestions\n\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\tperPage,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction UnforwardedLinkUI( props, ref ) {\n\tconst { label, url, opensInNewTab, type, kind, id } = props.link;\n\n\tconst { entityRecord, hasBinding, isEntityAvailable } = props.entity || {};\n\n\tconst { image, badges } = useLinkPreview( {\n\t\turl,\n\t\tentityRecord,\n\t\ttype,\n\t\thasBinding,\n\t\tisEntityAvailable,\n\t} );\n\n\tconst { clientId } = props;\n\tconst postType = type || 'page';\n\n\tconst [ addingBlock, setAddingBlock ] = useState( false );\n\tconst [ addingPage, setAddingPage ] = useState( false );\n\tconst [ shouldFocusPane, setShouldFocusPane ] = useState( null );\n\t// Stable initial value for LinkControl's uncontrolled inputValue prop.\n\t// We track the search with the searchInputValueRef, then update the\n\t// initialSearchValue state with the observed searchInputValueRef\n\t// when mounting the LinkControl. If LinkControl becomes a fully\n\t// controlled component, then we can remove this extra complexity.\n\tconst [ initialSearchValue, setInitialSearchValue ] = useState( '' );\n\t// Tracks the live search input between renders without causing re-renders.\n\tconst searchInputValueRef = useRef( '' );\n\t// Call this instead of setting searchInputValueRef.current and\n\t// setInitialSearchValue separately, to keep both in sync.\n\tconst updateSearchValue = ( value ) => {\n\t\tsearchInputValueRef.current = value;\n\t\tsetInitialSearchValue( value );\n\t};\n\tconst linkControlWrapperRef = useRef();\n\tconst addPageButtonRef = useRef();\n\tconst addBlockButtonRef = useRef();\n\tconst permissions = useResourcePermissions( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t} );\n\n\t// Use the entity binding hook to get binding status\n\tconst { isBoundEntityAvailable } = useEntityBinding( {\n\t\tclientId,\n\t\tattributes: props.link,\n\t} );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.\n\tconst link = useMemo(\n\t\t() => ( {\n\t\t\turl,\n\t\t\topensInNewTab,\n\t\t\ttitle: label && stripHTML( label ),\n\t\t\tentityTitle: entityRecord?.title?.rendered || entityRecord?.name,\n\t\t\tkind,\n\t\t\ttype,\n\t\t\tid,\n\t\t\timage,\n\t\t\tbadges,\n\t\t} ),\n\t\t[\n\t\t\tlabel,\n\t\t\topensInNewTab,\n\t\t\turl,\n\t\t\tkind,\n\t\t\ttype,\n\t\t\tid,\n\t\t\timage,\n\t\t\tbadges,\n\t\t\tentityRecord,\n\t\t]\n\t);\n\n\tconst handlePageCreated = ( pageLink ) => {\n\t\t// Set the new page as the current link\n\t\tprops.onChange( pageLink );\n\t\t// Return to main Link UI and focus the first focusable element\n\t\tsetAddingPage( false );\n\t\tsetShouldFocusPane( true );\n\t\t// Clear search input value\n\t\tupdateSearchValue( '' );\n\t};\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__title'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__description'\n\t);\n\n\t// Focus management when transitioning between panes\n\tuseEffect( () => {\n\t\tif ( shouldFocusPane && linkControlWrapperRef.current ) {\n\t\t\t// If we have a specific element to focus, focus it\n\t\t\tif ( shouldFocusPane?.current ) {\n\t\t\t\t// Focus the specific element passed\n\t\t\t\tshouldFocusPane.current.focus();\n\t\t\t} else {\n\t\t\t\t// Focus the first tabbable element (keyboard-accessible, excluding tabindex=\"-1\")\n\t\t\t\tconst tabbableElements = focus.tabbable.find(\n\t\t\t\t\tlinkControlWrapperRef.current\n\t\t\t\t);\n\t\t\t\tconst nextFocusTarget =\n\t\t\t\t\ttabbableElements[ 0 ] || linkControlWrapperRef.current;\n\t\t\t\tnextFocusTarget.focus();\n\t\t\t}\n\n\t\t\t// Reset the state\n\t\t\tsetShouldFocusPane( false );\n\t\t}\n\t}, [ shouldFocusPane ] );\n\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ ref }\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t{ ! addingBlock && ! addingPage && (\n\t\t\t\t<div\n\t\t\t\t\tref={ linkControlWrapperRef }\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-labelledby={ dialogTitleId }\n\t\t\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add link' ) }</h2>\n\n\t\t\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Search for and add a link to your Navigation.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\thasTextControl\n\t\t\t\t\t\thasRichPreviews\n\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t\twithCreateSuggestion={ false }\n\t\t\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\t\tonInputChange={ ( value ) => {\n\t\t\t\t\t\t\t// Observe the input value so we can pass the value to the page creator\n\t\t\t\t\t\t\t// and restore it on back button click\n\t\t\t\t\t\t\tsearchInputValueRef.current = value;\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tinputValue={ initialSearchValue }\n\t\t\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\t\t\thandleEntities={ isBoundEntityAvailable }\n\t\t\t\t\t\tforceIsEditingLink={ link?.url ? false : undefined }\n\t\t\t\t\t\trenderControlBottom={ () => {\n\t\t\t\t\t\t\t// Don't show the tools when there is submitted link (preview state).\n\t\t\t\t\t\t\tif ( link?.url?.length ) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkUITools\n\t\t\t\t\t\t\t\t\taddPageButtonRef={ addPageButtonRef }\n\t\t\t\t\t\t\t\t\taddBlockButtonRef={ addBlockButtonRef }\n\t\t\t\t\t\t\t\t\tsetAddingBlock={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsetAddingPage={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tcanAddPage={\n\t\t\t\t\t\t\t\t\t\tpermissions?.canCreate &&\n\t\t\t\t\t\t\t\t\t\ttype === 'page'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcanAddBlock={\n\t\t\t\t\t\t\t\t\t\tblockEditingMode === 'default'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ addingBlock && (\n\t\t\t\t<LinkUIBlockInserter\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingBlock( false );\n\t\t\t\t\t\tsetShouldFocusPane( addBlockButtonRef );\n\t\t\t\t\t\tupdateSearchValue( searchInputValueRef.current );\n\t\t\t\t\t} }\n\t\t\t\t\tonBlockInsert={ props?.onBlockInsert }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ addingPage && (\n\t\t\t\t<LinkUIPageCreator\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingPage( false );\n\t\t\t\t\t\tsetShouldFocusPane( addPageButtonRef );\n\t\t\t\t\t\tupdateSearchValue( searchInputValueRef.current );\n\t\t\t\t\t} }\n\t\t\t\t\tonPageCreated={ handlePageCreated }\n\t\t\t\t\tinitialTitle={\n\t\t\t\t\t\tsearchInputValueRef.current &&\n\t\t\t\t\t\t! isURL( searchInputValueRef.current )\n\t\t\t\t\t\t\t? searchInputValueRef.current\n\t\t\t\t\t\t\t: ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nexport const LinkUI = forwardRef( UnforwardedLinkUI );\n\nconst LinkUITools = ( {\n\taddPageButtonRef,\n\taddBlockButtonRef,\n\tsetAddingBlock,\n\tsetAddingPage,\n\tcanAddPage,\n\tcanAddBlock,\n} ) => {\n\tconst blockInserterAriaRole = 'listbox';\n\n\t// Don't render anything if neither button should be shown\n\tif ( ! canAddPage && ! canAddBlock ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 0 } className=\"link-ui-tools\">\n\t\t\t{ canAddPage && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addPageButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ canAddBlock && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addBlockButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add block' ) }\n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AwB;AAG9B,MAAK,CAAE,cAAc,CAAE,aAAc;AACpC,WAAO;AAAA,EACR;AAEA,SACC,qBAAC,UAAO,SAAU,GAAI,WAAU,iBAC7B;AAAA,kBACD;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,KAAM;AAAA,QACN,MAAO;AAAA,QACP,SAAU,CAAE,MAAO;AAClB,YAAE,eAAe;AACjB,wBAAe,IAAK;AAAA,QACrB;AAAA,QACA,iBAAgB;AAAA,QAEd,aAAI,aAAc;AAAA;AAAA,IACrB;AAAA,IAEC,eACD;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,KAAM;AAAA,QACN,MAAO;AAAA,QACP,SAAU,CAAE,MAAO;AAClB,YAAE,eAAe;AACjB,yBAAgB,IAAK;AAAA,QACtB;AAAA,QACA,iBAAgB;AAAA,QAEd,aAAI,WAAY;AAAA;AAAA,IACnB;AAAA,KAEF;AAEF;AAEA,IAAO,kBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML, focus } from '@wordpress/dom';\nimport {\n\tPopover,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { LinkControl, useBlockEditingMode } from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { LinkUIPageCreator } from './page-creator';\nimport LinkUIBlockInserter from './block-inserter';\nimport { useEntityBinding, useLinkPreview } from '../shared';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\t// How many results to show initially and per search.\n\tconst perPage = 20;\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type, perPage };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category', perPage };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag', perPage };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format', perPage };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type, perPage };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type, perPage };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// for custom link which has no type\n\t\t\t\t// always show pages as initial suggestions\n\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\tperPage,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction UnforwardedLinkUI( props, ref ) {\n\tconst { label, url, opensInNewTab, type, kind, id } = props.link;\n\n\tconst { entityRecord, hasBinding, isEntityAvailable } = props.entity || {};\n\n\tconst { image, badges } = useLinkPreview( {\n\t\turl,\n\t\tentityRecord,\n\t\ttype,\n\t\thasBinding,\n\t\tisEntityAvailable,\n\t} );\n\n\tconst { clientId } = props;\n\tconst postType = type || 'page';\n\n\tconst [ addingBlock, setAddingBlock ] = useState( false );\n\tconst [ addingPage, setAddingPage ] = useState( false );\n\tconst [ shouldFocusPane, setShouldFocusPane ] = useState( null );\n\t// Stable initial value for LinkControl's uncontrolled inputValue prop.\n\t// We track the search with the searchInputValueRef, then update the\n\t// initialSearchValue state with the observed searchInputValueRef\n\t// when mounting the LinkControl. If LinkControl becomes a fully\n\t// controlled component, then we can remove this extra complexity.\n\tconst [ initialSearchValue, setInitialSearchValue ] = useState( '' );\n\t// Tracks the live search input between renders without causing re-renders.\n\tconst searchInputValueRef = useRef( '' );\n\t// Call this instead of setting searchInputValueRef.current and\n\t// setInitialSearchValue separately, to keep both in sync.\n\tconst updateSearchValue = ( value ) => {\n\t\tsearchInputValueRef.current = value;\n\t\tsetInitialSearchValue( value );\n\t};\n\tconst linkControlWrapperRef = useRef();\n\tconst addPageButtonRef = useRef();\n\tconst addBlockButtonRef = useRef();\n\tconst permissions = useResourcePermissions( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t} );\n\n\t// Use the entity binding hook to get binding status\n\tconst { isBoundEntityAvailable } = useEntityBinding( {\n\t\tclientId,\n\t\tattributes: props.link,\n\t} );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.\n\tconst link = useMemo(\n\t\t() => ( {\n\t\t\turl,\n\t\t\topensInNewTab,\n\t\t\ttitle: label && stripHTML( label ),\n\t\t\tentityTitle: entityRecord?.title?.rendered || entityRecord?.name,\n\t\t\tkind,\n\t\t\ttype,\n\t\t\tid,\n\t\t\timage,\n\t\t\tbadges,\n\t\t} ),\n\t\t[\n\t\t\tlabel,\n\t\t\topensInNewTab,\n\t\t\turl,\n\t\t\tkind,\n\t\t\ttype,\n\t\t\tid,\n\t\t\timage,\n\t\t\tbadges,\n\t\t\tentityRecord,\n\t\t]\n\t);\n\n\tconst handlePageCreated = ( pageLink ) => {\n\t\t// Set the new page as the current link\n\t\tprops.onChange( pageLink );\n\t\t// Return to main Link UI and focus the first focusable element\n\t\tsetAddingPage( false );\n\t\tsetShouldFocusPane( true );\n\t\t// Clear search input value\n\t\tupdateSearchValue( '' );\n\t};\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__title'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__description'\n\t);\n\n\t// Focus management when transitioning between panes\n\tuseEffect( () => {\n\t\tif ( shouldFocusPane && linkControlWrapperRef.current ) {\n\t\t\t// If we have a specific element to focus, focus it\n\t\t\tif ( shouldFocusPane?.current ) {\n\t\t\t\t// Focus the specific element passed\n\t\t\t\tshouldFocusPane.current.focus();\n\t\t\t} else {\n\t\t\t\t// Focus the first tabbable element (keyboard-accessible, excluding tabindex=\"-1\")\n\t\t\t\tconst tabbableElements = focus.tabbable.find(\n\t\t\t\t\tlinkControlWrapperRef.current\n\t\t\t\t);\n\t\t\t\tconst nextFocusTarget =\n\t\t\t\t\ttabbableElements[ 0 ] || linkControlWrapperRef.current;\n\t\t\t\tnextFocusTarget.focus();\n\t\t\t}\n\n\t\t\t// Reset the state\n\t\t\tsetShouldFocusPane( false );\n\t\t}\n\t}, [ shouldFocusPane ] );\n\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ ref }\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t{ ! addingBlock && ! addingPage && (\n\t\t\t\t<div\n\t\t\t\t\tref={ linkControlWrapperRef }\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-labelledby={ dialogTitleId }\n\t\t\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add link' ) }</h2>\n\n\t\t\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Search for and add a link to your Navigation.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\thasTextControl\n\t\t\t\t\t\thasRichPreviews\n\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t\twithCreateSuggestion={ false }\n\t\t\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\t\tonInputChange={ ( value ) => {\n\t\t\t\t\t\t\t// Observe the input value so we can pass the value to the page creator\n\t\t\t\t\t\t\t// and restore it on back button click\n\t\t\t\t\t\t\tsearchInputValueRef.current = value;\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tinputValue={ initialSearchValue }\n\t\t\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\t\t\thandleEntities={ isBoundEntityAvailable }\n\t\t\t\t\t\tforceIsEditingLink={ link?.url ? false : undefined }\n\t\t\t\t\t\trenderControlBottom={ () => {\n\t\t\t\t\t\t\t// Don't show the tools when there is submitted link (preview state).\n\t\t\t\t\t\t\tif ( link?.url?.length ) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkUITools\n\t\t\t\t\t\t\t\t\taddPageButtonRef={ addPageButtonRef }\n\t\t\t\t\t\t\t\t\taddBlockButtonRef={ addBlockButtonRef }\n\t\t\t\t\t\t\t\t\tsetAddingBlock={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsetAddingPage={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tcanAddPage={\n\t\t\t\t\t\t\t\t\t\tblockEditingMode !== 'disabled' &&\n\t\t\t\t\t\t\t\t\t\tpermissions?.canCreate &&\n\t\t\t\t\t\t\t\t\t\ttype === 'page'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcanAddBlock={\n\t\t\t\t\t\t\t\t\t\tblockEditingMode !== 'disabled'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ addingBlock && (\n\t\t\t\t<LinkUIBlockInserter\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingBlock( false );\n\t\t\t\t\t\tsetShouldFocusPane( addBlockButtonRef );\n\t\t\t\t\t\tupdateSearchValue( searchInputValueRef.current );\n\t\t\t\t\t} }\n\t\t\t\t\tonBlockInsert={ props?.onBlockInsert }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ addingPage && (\n\t\t\t\t<LinkUIPageCreator\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingPage( false );\n\t\t\t\t\t\tsetShouldFocusPane( addPageButtonRef );\n\t\t\t\t\t\tupdateSearchValue( searchInputValueRef.current );\n\t\t\t\t\t} }\n\t\t\t\t\tonPageCreated={ handlePageCreated }\n\t\t\t\t\tinitialTitle={\n\t\t\t\t\t\tsearchInputValueRef.current &&\n\t\t\t\t\t\t! isURL( searchInputValueRef.current )\n\t\t\t\t\t\t\t? searchInputValueRef.current\n\t\t\t\t\t\t\t: ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nexport const LinkUI = forwardRef( UnforwardedLinkUI );\n\nconst LinkUITools = ( {\n\taddPageButtonRef,\n\taddBlockButtonRef,\n\tsetAddingBlock,\n\tsetAddingPage,\n\tcanAddPage,\n\tcanAddBlock,\n} ) => {\n\tconst blockInserterAriaRole = 'listbox';\n\n\t// Don't render anything if neither button should be shown\n\tif ( ! canAddPage && ! canAddBlock ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 0 } className=\"link-ui-tools\">\n\t\t\t{ canAddPage && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addPageButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ canAddBlock && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addBlockButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n};\n\nexport default LinkUITools;\n"],
5
+ "mappings": ";AAGA,SAAS,uBAAuB,WAAW,aAAa;AACxD;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,UAAU;AACnB,SAAS,aAAa,2BAA2B;AACjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B;AACvC,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,aAAa;AAKtB,SAAS,yBAAyB;AAClC,OAAO,yBAAyB;AAChC,SAAS,kBAAkB,sBAAsB;AA+K5C,SACC,KADD;AArKE,SAAS,oBAAqB,MAAM,MAAO;AAEjD,QAAM,UAAU;AAEhB,UAAS,MAAO;AAAA,I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AI,WAAY;AAAA;AAAA,IACnB;AAAA,KAEF;AAEF;AAEA,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -13,15 +13,18 @@ import {
13
13
  useBlockProps,
14
14
  useSettings,
15
15
  useBlockEditingMode,
16
+ privateApis as blockEditorPrivateApis,
16
17
  store as blockEditorStore
17
18
  } from "@wordpress/block-editor";
18
19
  import { useSelect } from "@wordpress/data";
19
20
  import { getBlockSupport } from "@wordpress/blocks";
20
21
  import { formatLTR } from "@wordpress/icons";
22
+ import { useContext } from "@wordpress/element";
21
23
  import { useOnEnter } from "./use-enter.mjs";
22
24
  import useDeprecatedAlign from "./deprecated-attributes.mjs";
23
25
  import { unlock } from "../lock-unlock.mjs";
24
26
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
27
+ var { PrivateBlockContext } = unlock(blockEditorPrivateApis);
25
28
  function ParagraphRTLControl({ direction, setDirection }) {
26
29
  return isRTL() && /* @__PURE__ */ jsx(
27
30
  ToolbarButton,
@@ -108,6 +111,7 @@ function ParagraphBlock({
108
111
  style: { direction }
109
112
  });
110
113
  const blockEditingMode = useBlockEditingMode();
114
+ const { ariaLabel } = useContext(PrivateBlockContext);
111
115
  return /* @__PURE__ */ jsxs(Fragment, { children: [
112
116
  blockEditingMode === "default" && /* @__PURE__ */ jsx(BlockControls, { group: "block", children: /* @__PURE__ */ jsx(
113
117
  ParagraphRTLControl,
@@ -136,9 +140,9 @@ function ParagraphBlock({
136
140
  onMerge: mergeBlocks,
137
141
  onReplace,
138
142
  onRemove,
139
- "aria-label": RichText.isEmpty(content) ? __(
143
+ "aria-label": ariaLabel ?? (RichText.isEmpty(content) ? __(
140
144
  "Empty block; start writing or type forward slash to choose a block"
141
- ) : __("Block: Paragraph"),
145
+ ) : __("Block: Paragraph")),
142
146
  "data-empty": RichText.isEmpty(content),
143
147
  placeholder: placeholder || __("Type / to choose a block"),
144
148
  "data-custom-placeholder": placeholder ? true : void 0,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/paragraph/edit.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { formatLTR } from '@wordpress/icons';\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\nimport useDeprecatedAlign from './deprecated-attributes';\nimport { unlock } from '../lock-unlock';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLTR }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction DropCapControl( { clientId, attributes, setAttributes, name } ) {\n\t// Please do not add a useSelect call to the paragraph block unconditionally.\n\t// Every useSelect added to a (frequently used) block will degrade load\n\t// and type performance. By moving it within InspectorControls, the subscription is\n\t// now only added for the selected block(s).\n\tconst [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );\n\tconst hasSelectedStyleState = useSelect(\n\t\t( select ) => {\n\t\t\tconst { hasSelectedStyleState: hasSelectedBlockStyleState } =\n\t\t\t\tunlock( select( blockEditorStore ) );\n\n\t\t\treturn hasSelectedBlockStyleState( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! isDropCapFeatureEnabled || hasSelectedStyleState ) {\n\t\treturn null;\n\t}\n\n\tconst { style, dropCap } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( textAlign ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Show a large initial letter.' );\n\t}\n\n\tconst isDropCapControlEnabledByDefault = getBlockSupport(\n\t\tname,\n\t\t'typography.defaultControls.dropCap',\n\t\tfalse\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"typography\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\tisShownByDefault={ isDropCapControlEnabledByDefault }\n\t\t\t\tonDeselect={ () => setAttributes( { dropCap: false } ) }\n\t\t\t\tresetAllFilter={ () => ( { dropCap: false } ) }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\tonChange={ () => setAttributes( { dropCap: ! dropCap } ) }\n\t\t\t\t\thelp={ helpText }\n\t\t\t\t\tdisabled={ hasDropCapDisabled( textAlign ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n\tisSelected: isSingleSelected,\n\tname,\n} ) {\n\tconst { content, direction, dropCap, placeholder, style } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\tuseDeprecatedAlign( attributes.align, style, setAttributes );\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: clsx( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( textAlign ) ? false : dropCap,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\t\tdirection={ direction }\n\t\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<DropCapControl\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tRichText.isEmpty( content )\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Block: Paragraph' )\n\t\t\t\t}\n\t\t\t\tdata-empty={ RichText.isEmpty( content ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/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,aACtB,oBAAC,iBAAc,OAAM,SACpB;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,cAAe,CAAE,iBAChB,cAAe,EAAE,WAAW,aAAa,CAAE;AAAA;AAAA,IAE7C,GACD;AAAA,IAEC,oBACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IAED;AAAA,MAAC;AAAA;AAAA,QACA,YAAW;AAAA,QACX,SAAQ;AAAA,QACN,GAAG;AAAA,QACL,OAAQ;AAAA,QACR,UAAW,CAAE,eACZ,cAAe,EAAE,SAAS,WAAW,CAAE;AAAA,QAExC,SAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA,cACC,SAAS,QAAS,OAAQ,IACvB;AAAA,UACA;AAAA,QACA,IACA,GAAI,kBAAmB;AAAA,QAE3B,cAAa,SAAS,QAAS,OAAQ;AAAA,QACvC,aAAc,eAAe,GAAI,0BAA2B;AAAA,QAC5D,2BAA0B,cAAc,OAAO;AAAA,QAC/C,2BAAyB;AAAA,QACzB,sCAAoC;AAAA;AAAA,IACrC;AAAA,KACD;AAEF;AAEA,IAAO,eAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n\tuseBlockEditingMode,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { formatLTR } from '@wordpress/icons';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useOnEnter } from './use-enter';\nimport useDeprecatedAlign from './deprecated-attributes';\nimport { unlock } from '../lock-unlock';\n\nconst { PrivateBlockContext } = unlock( blockEditorPrivateApis );\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLTR }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction DropCapControl( { clientId, attributes, setAttributes, name } ) {\n\t// Please do not add a useSelect call to the paragraph block unconditionally.\n\t// Every useSelect added to a (frequently used) block will degrade load\n\t// and type performance. By moving it within InspectorControls, the subscription is\n\t// now only added for the selected block(s).\n\tconst [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );\n\tconst hasSelectedStyleState = useSelect(\n\t\t( select ) => {\n\t\t\tconst { hasSelectedStyleState: hasSelectedBlockStyleState } =\n\t\t\t\tunlock( select( blockEditorStore ) );\n\n\t\t\treturn hasSelectedBlockStyleState( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! isDropCapFeatureEnabled || hasSelectedStyleState ) {\n\t\treturn null;\n\t}\n\n\tconst { style, dropCap } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( textAlign ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Show a large initial letter.' );\n\t}\n\n\tconst isDropCapControlEnabledByDefault = getBlockSupport(\n\t\tname,\n\t\t'typography.defaultControls.dropCap',\n\t\tfalse\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"typography\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\tisShownByDefault={ isDropCapControlEnabledByDefault }\n\t\t\t\tonDeselect={ () => setAttributes( { dropCap: false } ) }\n\t\t\t\tresetAllFilter={ () => ( { dropCap: false } ) }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\tonChange={ () => setAttributes( { dropCap: ! dropCap } ) }\n\t\t\t\t\thelp={ helpText }\n\t\t\t\t\tdisabled={ hasDropCapDisabled( textAlign ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n\tisSelected: isSingleSelected,\n\tname,\n} ) {\n\tconst { content, direction, dropCap, placeholder, style } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\tuseDeprecatedAlign( attributes.align, style, setAttributes );\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: clsx( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( textAlign ) ? false : dropCap,\n\t\t} ),\n\t\tstyle: { direction },\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst { ariaLabel } = useContext( PrivateBlockContext );\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\t\tdirection={ direction }\n\t\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<DropCapControl\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\taria-label={\n\t\t\t\t\tariaLabel ??\n\t\t\t\t\t( RichText.isEmpty( content )\n\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Block: Paragraph' ) )\n\t\t\t\t}\n\t\t\t\tdata-empty={ RichText.isEmpty( content ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,IAAI,aAAa;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,EACA,gCAAgC;AAAA,OAC1B;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf,SAAS;AAAA,OACH;AACP,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAK3B,SAAS,kBAAkB;AAC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AAC;AAAA;AAAA,QACA,YAAW;AAAA,QACX,SAAQ;AAAA,QACN,GAAG;AAAA,QACL,OAAQ;AAAA,QACR,UAAW,CAAE,eACZ,cAAe,EAAE,SAAS,WAAW,CAAE;AAAA,QAExC,SAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA,cACC,cACE,SAAS,QAAS,OAAQ,IACzB;AAAA,UACA;AAAA,QACA,IACA,GAAI,kBAAmB;AAAA,QAE3B,cAAa,SAAS,QAAS,OAAQ;AAAA,QACvC,aAAc,eAAe,GAAI,0BAA2B;AAAA,QAC5D,2BAA0B,cAAc,OAAO;AAAA,QAC/C,2BAAyB;AAAA,QACzB,sCAAoC;AAAA;AAAA,IACrC;AAAA,KACD;AAEF;AAEA,IAAO,eAAQ;",
6
6
  "names": []
7
7
  }
@@ -9,10 +9,13 @@ import metadata from "./block.json";
9
9
  import save from "./save.mjs";
10
10
  import transforms from "./transforms.mjs";
11
11
  import { unlock } from "../lock-unlock.mjs";
12
- var { fieldsKey, formKey } = unlock(blocksPrivateApis);
12
+ var { fieldsKey, formKey, editableRootKey } = unlock(blocksPrivateApis);
13
13
  var { name } = metadata;
14
14
  var settings = {
15
15
  icon,
16
+ // Opt into the editing host behaviour privately. It's a Symbol setting
17
+ // rather than a public `supports` key so it stays an internal detail.
18
+ [editableRootKey]: true,
16
19
  example: {
17
20
  attributes: {
18
21
  content: __(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/paragraph/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { paragraph as icon } from '@wordpress/icons';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __(\n\t\t\t\t'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'\n\t\t\t),\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif (\n\t\t\t( context === 'list-view' || context === 'breadcrumb' ) &&\n\t\t\tcustomName\n\t\t) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\tif ( customName ) {\n\t\t\t\treturn customName;\n\t\t\t}\n\n\t\t\tconst { content } = attributes;\n\t\t\treturn ! content || content.length === 0 ? __( 'Empty' ) : content;\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nif ( window.__experimentalContentOnlyInspectorFields ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'content',\n\t\t\tlabel: __( 'Content' ),\n\t\t\ttype: 'text',\n\t\t\tEdit: 'rich-text', // TODO: replace with custom component\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'content' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
5
- "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,aAAa,YAAY;AAClC,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,QAAQ,IAAI,OAAQ,iBAAkB;AAEzD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,SAAS;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,aAAa,YAAY,UAAU;AAEzC,SACG,YAAY,eAAe,YAAY,iBACzC,YACC;AACD,aAAO;AAAA,IACR;AAEA,QAAK,YAAY,iBAAkB;AAClC,UAAK,YAAa;AACjB,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,QAAQ,IAAI;AACpB,aAAO,CAAE,WAAW,QAAQ,WAAW,IAAI,GAAI,OAAQ,IAAI;AAAA,IAC5D;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAK,OAAO,0CAA2C;AACtD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,SAAU;AAAA,MACrB,MAAM;AAAA,MACN,MAAM;AAAA;AAAA,IACP;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,SAAU;AAAA,EACrB;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { paragraph as icon } from '@wordpress/icons';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { fieldsKey, formKey, editableRootKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\t// Opt into the editing host behaviour privately. It's a Symbol setting\n\t// rather than a public `supports` key so it stays an internal detail.\n\t[ editableRootKey ]: true,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __(\n\t\t\t\t'In a village of La Mancha, the name of which I have no desire to call to mind, there lived not long since one of those gentlemen that keep a lance in the lance-rack, an old buckler, a lean hack, and a greyhound for coursing.'\n\t\t\t),\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst customName = attributes?.metadata?.name;\n\n\t\tif (\n\t\t\t( context === 'list-view' || context === 'breadcrumb' ) &&\n\t\t\tcustomName\n\t\t) {\n\t\t\treturn customName;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\tif ( customName ) {\n\t\t\t\treturn customName;\n\t\t\t}\n\n\t\t\tconst { content } = attributes;\n\t\t\treturn ! content || content.length === 0 ? __( 'Empty' ) : content;\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nif ( window.__experimentalContentOnlyInspectorFields ) {\n\tsettings[ fieldsKey ] = [\n\t\t{\n\t\t\tid: 'content',\n\t\t\tlabel: __( 'Content' ),\n\t\t\ttype: 'text',\n\t\t\tEdit: 'rich-text', // TODO: replace with custom component\n\t\t},\n\t];\n\tsettings[ formKey ] = {\n\t\tfields: [ 'content' ],\n\t};\n}\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,aAAa,YAAY;AAClC,SAAS,eAAe,yBAAyB;AAKjD,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO,UAAU;AACjB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,WAAW,SAAS,gBAAgB,IAAI,OAAQ,iBAAkB;AAE1E,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA;AAAA;AAAA,EAGA,CAAE,eAAgB,GAAG;AAAA,EACrB,SAAS;AAAA,IACR,YAAY;AAAA,MACX,SAAS;AAAA,QACR;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,aAAa,YAAY,UAAU;AAEzC,SACG,YAAY,eAAe,YAAY,iBACzC,YACC;AACD,aAAO;AAAA,IACR;AAEA,QAAK,YAAY,iBAAkB;AAClC,UAAK,YAAa;AACjB,eAAO;AAAA,MACR;AAEA,YAAM,EAAE,QAAQ,IAAI;AACpB,aAAO,CAAE,WAAW,QAAQ,WAAW,IAAI,GAAI,OAAQ,IAAI;AAAA,IAC5D;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAK,OAAO,0CAA2C;AACtD,WAAU,SAAU,IAAI;AAAA,IACvB;AAAA,MACC,IAAI;AAAA,MACJ,OAAO,GAAI,SAAU;AAAA,MACrB,MAAM;AAAA,MACN,MAAM;AAAA;AAAA,IACP;AAAA,EACD;AACA,WAAU,OAAQ,IAAI;AAAA,IACrB,QAAQ,CAAE,SAAU;AAAA,EACrB;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,7 @@
1
1
  // packages/block-library/src/paragraph/use-enter.js
2
2
  import { useRef } from "@wordpress/element";
3
- import {
4
- useRefEffect,
5
- privateApis as composePrivateApis
6
- } from "@wordpress/compose";
3
+ import { useRefEffect } from "@wordpress/compose";
4
+ import { privateApis as richTextPrivateApis } from "@wordpress/rich-text";
7
5
  import { ENTER } from "@wordpress/keycodes";
8
6
  import { useSelect, useDispatch, useRegistry } from "@wordpress/data";
9
7
  import { store as blockEditorStore } from "@wordpress/block-editor";
@@ -14,7 +12,7 @@ import {
14
12
  getDefaultBlockName
15
13
  } from "@wordpress/blocks";
16
14
  import { unlock } from "../lock-unlock.mjs";
17
- var { subscribeDelegatedListener } = unlock(composePrivateApis);
15
+ var { subscribeOwnedListener } = unlock(richTextPrivateApis);
18
16
  function useOnEnter(props) {
19
17
  const { batch } = useRegistry();
20
18
  const { moveBlocksToPosition, replaceBlocks, selectionChange } = useDispatch(blockEditorStore);
@@ -91,12 +89,7 @@ function useOnEnter(props) {
91
89
  selectionChange(middle.clientId);
92
90
  });
93
91
  }
94
- return subscribeDelegatedListener(
95
- element,
96
- "keydown",
97
- onKeyDown,
98
- true
99
- );
92
+ return subscribeOwnedListener(element, "keydown", onKeyDown, true);
100
93
  }, []);
101
94
  }
102
95
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/paragraph/use-enter.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport {\n\tuseRefEffect,\n\tprivateApis as composePrivateApis,\n} from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\thasBlockSupport,\n\tcreateBlock,\n\tcloneBlock,\n\tgetDefaultBlockName,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { subscribeDelegatedListener } = unlock( composePrivateApis );\n\nexport function useOnEnter( props ) {\n\tconst { batch } = useRegistry();\n\tconst { moveBlocksToPosition, replaceBlocks, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockOrder,\n\t\tgetBlockName,\n\t\tgetBlock,\n\t\tcanInsertBlockType,\n\t} = useSelect( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { content, clientId } = propsRef.current;\n\n\t\t\t// The paragraph should be empty.\n\t\t\tif ( content.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst wrapperClientId = getBlockRootClientId( clientId );\n\n\t\t\tif (\n\t\t\t\t! hasBlockSupport(\n\t\t\t\t\tgetBlockName( wrapperClientId ),\n\t\t\t\t\t'__experimentalOnEnter',\n\t\t\t\t\tfalse\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst order = getBlockOrder( wrapperClientId );\n\t\t\tconst position = order.indexOf( clientId );\n\n\t\t\t// If it is the last block, exit.\n\t\t\tif ( position === order.length - 1 ) {\n\t\t\t\tlet newWrapperClientId = wrapperClientId;\n\n\t\t\t\twhile (\n\t\t\t\t\t! canInsertBlockType(\n\t\t\t\t\t\tgetBlockName( clientId ),\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tnewWrapperClientId =\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId );\n\t\t\t\t}\n\n\t\t\t\tif ( typeof newWrapperClientId === 'string' ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t[ clientId ],\n\t\t\t\t\t\twrapperClientId,\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId ),\n\t\t\t\t\t\tgetBlockIndex( newWrapperClientId ) + 1\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst defaultBlockName = getDefaultBlockName();\n\t\t\tconst wrapperBlockName = getBlockName( wrapperClientId );\n\t\t\tconst grandparentClientId = getBlockRootClientId( wrapperClientId );\n\n\t\t\tif (\n\t\t\t\t! canInsertBlockType( defaultBlockName, grandparentClientId ) ||\n\t\t\t\t! canInsertBlockType( wrapperBlockName, grandparentClientId )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// If it is in the middle, split the block in two.\n\t\t\tconst wrapperBlock = getBlock( wrapperClientId );\n\t\t\tconst head = cloneBlock( {\n\t\t\t\t...wrapperBlock,\n\t\t\t\tinnerBlocks: wrapperBlock.innerBlocks.slice( 0, position ),\n\t\t\t} );\n\t\t\tconst middle = createBlock( defaultBlockName );\n\t\t\tconst tail = cloneBlock( {\n\t\t\t\t...wrapperBlock,\n\t\t\t\tinnerBlocks: wrapperBlock.innerBlocks.slice( position + 1 ),\n\t\t\t} );\n\n\t\t\tbatch( () => {\n\t\t\t\treplaceBlocks( wrapperClientId, [ head, middle, tail ] );\n\t\t\t\t// The selected paragraph is a descendant of the replaced\n\t\t\t\t// wrapper, so `replaceBlocks` leaves the selection stale.\n\t\t\t\t// Move it to the new default block explicitly.\n\t\t\t\tselectionChange( middle.clientId );\n\t\t\t} );\n\t\t}\n\n\t\t// Capture phase so we run before writing-flow's ancestor-bubble\n\t\t// keydown handlers that gate on `event.defaultPrevented`.\n\t\treturn subscribeDelegatedListener(\n\t\t\telement,\n\t\t\t'keydown',\n\t\t\tonKeyDown,\n\t\t\ttrue\n\t\t);\n\t}, [] );\n}\n"],
5
- "mappings": ";AAGA,SAAS,cAAc;AACvB;AAAA,EACC;AAAA,EACA,eAAe;AAAA,OACT;AACP,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AAA,YACzC,cAAe,kBAAmB,IAAI;AAAA,UACvC;AAAA,QACD;AACA;AAAA,MACD;AAEA,YAAM,mBAAmB,oBAAoB;AAC7C,YAAM,mBAAmB,aAAc,eAAgB;AACvD,YAAM,sBAAsB,qBAAsB,eAAgB;AAElE,UACC,CAAE,mBAAoB,kBAAkB,mBAAoB,KAC5D,CAAE,mBAAoB,kBAAkB,mBAAoB,GAC3D;AACD;AAAA,MACD;AAEA,YAAM,eAAe;AAGrB,YAAM,eAAe,SAAU,eAAgB;AAC/C,YAAM,OAAO,WAAY;AAAA,QACxB,GAAG;AAAA,QACH,aAAa,aAAa,YAAY,MAAO,GAAG,QAAS;AAAA,MAC1D,CAAE;AACF,YAAM,SAAS,YAAa,gBAAiB;AAC7C,YAAM,OAAO,WAAY;AAAA,QACxB,GAAG;AAAA,QACH,aAAa,aAAa,YAAY,MAAO,WAAW,CAAE;AAAA,MAC3D,CAAE;AAEF,YAAO,MAAM;AACZ,sBAAe,iBAAiB,CAAE,MAAM,QAAQ,IAAK,CAAE;AAIvD,wBAAiB,OAAO,QAAS;AAAA,MAClC,CAAE;AAAA,IACH;AAIA,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD,GAAG,CAAC,CAAE;AACP;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { privateApis as richTextPrivateApis } from '@wordpress/rich-text';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\thasBlockSupport,\n\tcreateBlock,\n\tcloneBlock,\n\tgetDefaultBlockName,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\nconst { subscribeOwnedListener } = unlock( richTextPrivateApis );\n\nexport function useOnEnter( props ) {\n\tconst { batch } = useRegistry();\n\tconst { moveBlocksToPosition, replaceBlocks, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockRootClientId,\n\t\tgetBlockIndex,\n\t\tgetBlockOrder,\n\t\tgetBlockName,\n\t\tgetBlock,\n\t\tcanInsertBlockType,\n\t} = useSelect( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== ENTER ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { content, clientId } = propsRef.current;\n\n\t\t\t// The paragraph should be empty.\n\t\t\tif ( content.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst wrapperClientId = getBlockRootClientId( clientId );\n\n\t\t\tif (\n\t\t\t\t! hasBlockSupport(\n\t\t\t\t\tgetBlockName( wrapperClientId ),\n\t\t\t\t\t'__experimentalOnEnter',\n\t\t\t\t\tfalse\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst order = getBlockOrder( wrapperClientId );\n\t\t\tconst position = order.indexOf( clientId );\n\n\t\t\t// If it is the last block, exit.\n\t\t\tif ( position === order.length - 1 ) {\n\t\t\t\tlet newWrapperClientId = wrapperClientId;\n\n\t\t\t\twhile (\n\t\t\t\t\t! canInsertBlockType(\n\t\t\t\t\t\tgetBlockName( clientId ),\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tnewWrapperClientId =\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId );\n\t\t\t\t}\n\n\t\t\t\tif ( typeof newWrapperClientId === 'string' ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t[ clientId ],\n\t\t\t\t\t\twrapperClientId,\n\t\t\t\t\t\tgetBlockRootClientId( newWrapperClientId ),\n\t\t\t\t\t\tgetBlockIndex( newWrapperClientId ) + 1\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst defaultBlockName = getDefaultBlockName();\n\t\t\tconst wrapperBlockName = getBlockName( wrapperClientId );\n\t\t\tconst grandparentClientId = getBlockRootClientId( wrapperClientId );\n\n\t\t\tif (\n\t\t\t\t! canInsertBlockType( defaultBlockName, grandparentClientId ) ||\n\t\t\t\t! canInsertBlockType( wrapperBlockName, grandparentClientId )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// If it is in the middle, split the block in two.\n\t\t\tconst wrapperBlock = getBlock( wrapperClientId );\n\t\t\tconst head = cloneBlock( {\n\t\t\t\t...wrapperBlock,\n\t\t\t\tinnerBlocks: wrapperBlock.innerBlocks.slice( 0, position ),\n\t\t\t} );\n\t\t\tconst middle = createBlock( defaultBlockName );\n\t\t\tconst tail = cloneBlock( {\n\t\t\t\t...wrapperBlock,\n\t\t\t\tinnerBlocks: wrapperBlock.innerBlocks.slice( position + 1 ),\n\t\t\t} );\n\n\t\t\tbatch( () => {\n\t\t\t\treplaceBlocks( wrapperClientId, [ head, middle, tail ] );\n\t\t\t\t// The selected paragraph is a descendant of the replaced\n\t\t\t\t// wrapper, so `replaceBlocks` leaves the selection stale.\n\t\t\t\t// Move it to the new default block explicitly.\n\t\t\t\tselectionChange( middle.clientId );\n\t\t\t} );\n\t\t}\n\n\t\t// Capture phase so we run before writing-flow's ancestor-bubble\n\t\t// keydown handlers that gate on `event.defaultPrevented`.\n\t\treturn subscribeOwnedListener( element, 'keydown', onKeyDown, true );\n\t}, [] );\n}\n"],
5
+ "mappings": ";AAGA,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,eAAe,2BAA2B;AACnD,SAAS,aAAa;AACtB,SAAS,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IAAI;AAAA,UACvC;AAAA,QACD;AACA;AAAA,MACD;AAEA,YAAM,mBAAmB,oBAAoB;AAC7C,YAAM,mBAAmB,aAAc,eAAgB;AACvD,YAAM,sBAAsB,qBAAsB,eAAgB;AAElE,UACC,CAAE,mBAAoB,kBAAkB,mBAAoB,KAC5D,CAAE,mBAAoB,kBAAkB,mBAAoB,GAC3D;AACD;AAAA,MACD;AAEA,YAAM,eAAe;AAGrB,YAAM,eAAe,SAAU,eAAgB;AAC/C,YAAM,OAAO,WAAY;AAAA,QACxB,GAAG;AAAA,QACH,aAAa,aAAa,YAAY,MAAO,GAAG,QAAS;AAAA,MAC1D,CAAE;AACF,YAAM,SAAS,YAAa,gBAAiB;AAC7C,YAAM,OAAO,WAAY;AAAA,QACxB,GAAG;AAAA,QACH,aAAa,aAAa,YAAY,MAAO,WAAW,CAAE;AAAA,MAC3D,CAAE;AAEF,YAAO,MAAM;AACZ,sBAAe,iBAAiB,CAAE,MAAM,QAAQ,IAAK,CAAE;AAIvD,wBAAiB,OAAO,QAAS;AAAA,MAClC,CAAE;AAAA,IACH;AAIA,WAAO,uBAAwB,SAAS,WAAW,WAAW,IAAK;AAAA,EACpE,GAAG,CAAC,CAAE;AACP;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "$schema": "https://schemas.wp.org/trunk/block.json",
3
3
  "apiVersion": 3,
4
- "__experimental": true,
5
4
  "name": "core/playlist",
6
5
  "title": "Playlist",
7
6
  "category": "media",
@@ -26,6 +25,10 @@
26
25
  "type": "boolean",
27
26
  "default": true
28
27
  },
28
+ "showPlayButtonArtwork": {
29
+ "type": "boolean",
30
+ "default": false
31
+ },
29
32
  "showArtists": {
30
33
  "type": "boolean",
31
34
  "default": true
@@ -38,12 +41,30 @@
38
41
  "type": "boolean",
39
42
  "default": true
40
43
  },
44
+ "waveformStyle": {
45
+ "type": "string",
46
+ "enum": [ "bars", "mirror", "line", "blocks", "dots", "seekbar" ],
47
+ "default": "bars"
48
+ },
49
+ "waveformColor": {
50
+ "type": "string"
51
+ },
52
+ "waveformGradient": {
53
+ "type": "string"
54
+ },
55
+ "waveformBackgroundColor": {
56
+ "type": "string"
57
+ },
58
+ "waveformBackgroundGradient": {
59
+ "type": "string"
60
+ },
41
61
  "caption": {
42
62
  "type": "string"
43
63
  }
44
64
  },
45
65
  "providesContext": {
46
- "showArtists": "showArtists"
66
+ "showArtists": "showArtists",
67
+ "showImages": "showImages"
47
68
  },
48
69
  "supports": {
49
70
  "anchor": true,
@@ -70,16 +91,14 @@
70
91
  "spacing": {
71
92
  "margin": true,
72
93
  "padding": true
94
+ },
95
+ "typography": {
96
+ "fontSize": true,
97
+ "__experimentalDefaultControls": {
98
+ "fontSize": true
99
+ }
73
100
  }
74
101
  },
75
- "styles": [
76
- { "name": "bars", "label": "Bars", "isDefault": true },
77
- { "name": "mirror", "label": "Mirror" },
78
- { "name": "line", "label": "Line" },
79
- { "name": "blocks", "label": "Blocks" },
80
- { "name": "dots", "label": "Dots" },
81
- { "name": "seekbar", "label": "Seekbar" }
82
- ],
83
102
  "editorStyle": "wp-block-playlist-editor",
84
103
  "style": "wp-block-playlist"
85
104
  }
@@ -3,7 +3,8 @@ import { createContext } from "@wordpress/element";
3
3
  var PlaylistContext = createContext({
4
4
  currentTrackClientId: null,
5
5
  setCurrentTrackClientId: () => {
6
- }
6
+ },
7
+ addTracks: void 0
7
8
  });
8
9
  export {
9
10
  PlaylistContext
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/playlist/context.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const PlaylistContext = createContext( {\n\tcurrentTrackClientId: null,\n\tsetCurrentTrackClientId: () => {},\n} );\n"],
5
- "mappings": ";AAGA,SAAS,qBAAqB;AAEvB,IAAM,kBAAkB,cAAe;AAAA,EAC7C,sBAAsB;AAAA,EACtB,yBAAyB,MAAM;AAAA,EAAC;AACjC,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const PlaylistContext = createContext( {\n\tcurrentTrackClientId: null,\n\tsetCurrentTrackClientId: () => {},\n\taddTracks: undefined,\n} );\n"],
5
+ "mappings": ";AAGA,SAAS,qBAAqB;AAEvB,IAAM,kBAAkB,cAAe;AAAA,EAC7C,sBAAsB;AAAA,EACtB,yBAAyB,MAAM;AAAA,EAAC;AAAA,EAChC,WAAW;AACZ,CAAE;",
6
6
  "names": []
7
7
  }