@wordpress/block-library 8.0.0 → 8.1.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 (450) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/categories/edit.js +1 -1
  3. package/build/categories/edit.js.map +1 -1
  4. package/build/cover/edit/inspector-controls.js +1 -1
  5. package/build/cover/edit/inspector-controls.js.map +1 -1
  6. package/build/freeform/edit.js +21 -6
  7. package/build/freeform/edit.js.map +1 -1
  8. package/build/freeform/modal.js +97 -0
  9. package/build/freeform/modal.js.map +1 -0
  10. package/build/gallery/edit.js +13 -2
  11. package/build/gallery/edit.js.map +1 -1
  12. package/build/gallery/gallery.js +2 -16
  13. package/build/gallery/gallery.js.map +1 -1
  14. package/build/image/image.js +1 -0
  15. package/build/image/image.js.map +1 -1
  16. package/build/media-text/edit.js +1 -0
  17. package/build/media-text/edit.js.map +1 -1
  18. package/build/missing/edit.native.js +2 -2
  19. package/build/missing/edit.native.js.map +1 -1
  20. package/build/navigation/edit/index.js +3 -4
  21. package/build/navigation/edit/index.js.map +1 -1
  22. package/build/navigation/edit/menu-inspector-controls.js +29 -7
  23. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  24. package/build/navigation/edit/navigation-menu-selector.js +11 -8
  25. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  26. package/build/navigation/edit/utils.js +81 -0
  27. package/build/navigation/edit/utils.js.map +1 -1
  28. package/build/navigation-link/edit.js +4 -58
  29. package/build/navigation-link/edit.js.map +1 -1
  30. package/build/navigation-submenu/edit.js +7 -72
  31. package/build/navigation-submenu/edit.js.map +1 -1
  32. package/build/page-list/edit.js +16 -15
  33. package/build/page-list/edit.js.map +1 -1
  34. package/build/page-list/index.js +29 -2
  35. package/build/page-list/index.js.map +1 -1
  36. package/build/page-list-item/edit.js +9 -5
  37. package/build/page-list-item/edit.js.map +1 -1
  38. package/build/post-featured-image/overlay.js +0 -1
  39. package/build/post-featured-image/overlay.js.map +1 -1
  40. package/build/query/edit/index.js +2 -1
  41. package/build/query/edit/index.js.map +1 -1
  42. package/build/query/edit/inspector-controls/index.js +10 -5
  43. package/build/query/edit/inspector-controls/index.js.map +1 -1
  44. package/build/query/edit/inspector-controls/taxonomy-controls.js +101 -37
  45. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  46. package/build/query/edit/query-content.js +2 -3
  47. package/build/query/edit/query-content.js.map +1 -1
  48. package/build/query/edit/query-placeholder.js +17 -12
  49. package/build/query/edit/query-placeholder.js.map +1 -1
  50. package/build/query/utils.js +73 -1
  51. package/build/query/utils.js.map +1 -1
  52. package/build/search/edit.js +2 -2
  53. package/build/search/edit.js.map +1 -1
  54. package/build/social-link/edit.js.map +1 -1
  55. package/build/social-links/edit.js +0 -1
  56. package/build/social-links/edit.js.map +1 -1
  57. package/build/table-of-contents/edit.js +1 -1
  58. package/build/table-of-contents/edit.js.map +1 -1
  59. package/build/template-part/edit/advanced-controls.js +11 -1
  60. package/build/template-part/edit/advanced-controls.js.map +1 -1
  61. package/build/template-part/edit/import-controls.js +160 -0
  62. package/build/template-part/edit/import-controls.js.map +1 -0
  63. package/build/template-part/edit/index.js +2 -1
  64. package/build/template-part/edit/index.js.map +1 -1
  65. package/build/template-part/edit/utils/transformers.js +48 -0
  66. package/build/template-part/edit/utils/transformers.js.map +1 -0
  67. package/build-module/categories/edit.js +1 -1
  68. package/build-module/categories/edit.js.map +1 -1
  69. package/build-module/cover/edit/inspector-controls.js +3 -3
  70. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  71. package/build-module/freeform/edit.js +22 -8
  72. package/build-module/freeform/edit.js.map +1 -1
  73. package/build-module/freeform/modal.js +90 -0
  74. package/build-module/freeform/modal.js.map +1 -0
  75. package/build-module/gallery/edit.js +14 -3
  76. package/build-module/gallery/edit.js.map +1 -1
  77. package/build-module/gallery/gallery.js +3 -16
  78. package/build-module/gallery/gallery.js.map +1 -1
  79. package/build-module/image/image.js +1 -0
  80. package/build-module/image/image.js.map +1 -1
  81. package/build-module/media-text/edit.js +1 -0
  82. package/build-module/media-text/edit.js.map +1 -1
  83. package/build-module/missing/edit.native.js +2 -2
  84. package/build-module/missing/edit.native.js.map +1 -1
  85. package/build-module/navigation/edit/index.js +3 -4
  86. package/build-module/navigation/edit/index.js.map +1 -1
  87. package/build-module/navigation/edit/menu-inspector-controls.js +30 -9
  88. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  89. package/build-module/navigation/edit/navigation-menu-selector.js +12 -9
  90. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  91. package/build-module/navigation/edit/utils.js +75 -0
  92. package/build-module/navigation/edit/utils.js.map +1 -1
  93. package/build-module/navigation-link/edit.js +4 -59
  94. package/build-module/navigation-link/edit.js.map +1 -1
  95. package/build-module/navigation-submenu/edit.js +6 -72
  96. package/build-module/navigation-submenu/edit.js.map +1 -1
  97. package/build-module/page-list/edit.js +17 -15
  98. package/build-module/page-list/edit.js.map +1 -1
  99. package/build-module/page-list/index.js +30 -3
  100. package/build-module/page-list/index.js.map +1 -1
  101. package/build-module/page-list-item/edit.js +9 -6
  102. package/build-module/page-list-item/edit.js.map +1 -1
  103. package/build-module/post-featured-image/overlay.js +0 -1
  104. package/build-module/post-featured-image/overlay.js.map +1 -1
  105. package/build-module/query/edit/index.js +2 -1
  106. package/build-module/query/edit/index.js.map +1 -1
  107. package/build-module/query/edit/inspector-controls/index.js +10 -5
  108. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  109. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +99 -35
  110. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  111. package/build-module/query/edit/query-content.js +1 -1
  112. package/build-module/query/edit/query-content.js.map +1 -1
  113. package/build-module/query/edit/query-placeholder.js +16 -12
  114. package/build-module/query/edit/query-placeholder.js.map +1 -1
  115. package/build-module/query/utils.js +69 -0
  116. package/build-module/query/utils.js.map +1 -1
  117. package/build-module/search/edit.js +2 -2
  118. package/build-module/search/edit.js.map +1 -1
  119. package/build-module/social-link/edit.js +2 -2
  120. package/build-module/social-link/edit.js.map +1 -1
  121. package/build-module/social-links/edit.js +0 -1
  122. package/build-module/social-links/edit.js.map +1 -1
  123. package/build-module/table-of-contents/edit.js +1 -1
  124. package/build-module/table-of-contents/edit.js.map +1 -1
  125. package/build-module/template-part/edit/advanced-controls.js +10 -1
  126. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  127. package/build-module/template-part/edit/import-controls.js +146 -0
  128. package/build-module/template-part/edit/import-controls.js.map +1 -0
  129. package/build-module/template-part/edit/index.js +2 -1
  130. package/build-module/template-part/edit/index.js.map +1 -1
  131. package/build-module/template-part/edit/utils/transformers.js +40 -0
  132. package/build-module/template-part/edit/utils/transformers.js.map +1 -0
  133. package/build-style/archives/editor-rtl.css +3 -3
  134. package/build-style/archives/editor.css +3 -3
  135. package/build-style/archives/style-rtl.css +3 -3
  136. package/build-style/archives/style.css +3 -3
  137. package/build-style/audio/editor-rtl.css +3 -3
  138. package/build-style/audio/editor.css +3 -3
  139. package/build-style/audio/style-rtl.css +3 -3
  140. package/build-style/audio/style.css +3 -3
  141. package/build-style/audio/theme-rtl.css +3 -3
  142. package/build-style/audio/theme.css +3 -3
  143. package/build-style/avatar/editor-rtl.css +3 -3
  144. package/build-style/avatar/editor.css +3 -3
  145. package/build-style/avatar/style-rtl.css +3 -3
  146. package/build-style/avatar/style.css +3 -3
  147. package/build-style/block/editor-rtl.css +3 -3
  148. package/build-style/block/editor.css +3 -3
  149. package/build-style/button/editor-rtl.css +3 -3
  150. package/build-style/button/editor.css +3 -3
  151. package/build-style/button/style-rtl.css +3 -3
  152. package/build-style/button/style.css +3 -3
  153. package/build-style/buttons/editor-rtl.css +3 -3
  154. package/build-style/buttons/editor.css +3 -3
  155. package/build-style/buttons/style-rtl.css +3 -3
  156. package/build-style/buttons/style.css +3 -3
  157. package/build-style/calendar/style-rtl.css +3 -3
  158. package/build-style/calendar/style.css +3 -3
  159. package/build-style/categories/editor-rtl.css +3 -3
  160. package/build-style/categories/editor.css +3 -3
  161. package/build-style/categories/style-rtl.css +3 -3
  162. package/build-style/categories/style.css +3 -3
  163. package/build-style/classic-rtl.css +3 -3
  164. package/build-style/classic.css +3 -3
  165. package/build-style/code/editor-rtl.css +3 -3
  166. package/build-style/code/editor.css +3 -3
  167. package/build-style/code/style-rtl.css +3 -3
  168. package/build-style/code/style.css +3 -3
  169. package/build-style/code/theme-rtl.css +3 -3
  170. package/build-style/code/theme.css +3 -3
  171. package/build-style/columns/editor-rtl.css +3 -3
  172. package/build-style/columns/editor.css +3 -3
  173. package/build-style/columns/style-rtl.css +3 -3
  174. package/build-style/columns/style.css +3 -3
  175. package/build-style/comment-author-avatar/editor-rtl.css +3 -3
  176. package/build-style/comment-author-avatar/editor.css +3 -3
  177. package/build-style/comment-content/style-rtl.css +3 -3
  178. package/build-style/comment-content/style.css +3 -3
  179. package/build-style/comment-template/style-rtl.css +3 -3
  180. package/build-style/comment-template/style.css +3 -3
  181. package/build-style/comments/editor-rtl.css +3 -3
  182. package/build-style/comments/editor.css +3 -3
  183. package/build-style/comments/style-rtl.css +3 -3
  184. package/build-style/comments/style.css +3 -3
  185. package/build-style/comments-pagination/editor-rtl.css +3 -3
  186. package/build-style/comments-pagination/editor.css +3 -3
  187. package/build-style/comments-pagination/style-rtl.css +3 -3
  188. package/build-style/comments-pagination/style.css +3 -3
  189. package/build-style/comments-pagination-numbers/editor-rtl.css +3 -3
  190. package/build-style/comments-pagination-numbers/editor.css +3 -3
  191. package/build-style/comments-title/editor-rtl.css +3 -3
  192. package/build-style/comments-title/editor.css +3 -3
  193. package/build-style/common-rtl.css +3 -3
  194. package/build-style/common.css +3 -3
  195. package/build-style/cover/editor-rtl.css +3 -3
  196. package/build-style/cover/editor.css +3 -3
  197. package/build-style/cover/style-rtl.css +3 -3
  198. package/build-style/cover/style.css +3 -3
  199. package/build-style/editor-elements-rtl.css +3 -3
  200. package/build-style/editor-elements.css +3 -3
  201. package/build-style/editor-rtl.css +7 -9
  202. package/build-style/editor.css +7 -9
  203. package/build-style/elements-rtl.css +3 -3
  204. package/build-style/elements.css +3 -3
  205. package/build-style/embed/editor-rtl.css +3 -3
  206. package/build-style/embed/editor.css +3 -3
  207. package/build-style/embed/style-rtl.css +3 -3
  208. package/build-style/embed/style.css +3 -3
  209. package/build-style/embed/theme-rtl.css +3 -3
  210. package/build-style/embed/theme.css +3 -3
  211. package/build-style/file/editor-rtl.css +3 -3
  212. package/build-style/file/editor.css +3 -3
  213. package/build-style/file/style-rtl.css +3 -3
  214. package/build-style/file/style.css +3 -3
  215. package/build-style/freeform/editor-rtl.css +3 -3
  216. package/build-style/freeform/editor.css +3 -3
  217. package/build-style/gallery/editor-rtl.css +3 -3
  218. package/build-style/gallery/editor.css +3 -3
  219. package/build-style/gallery/style-rtl.css +3 -3
  220. package/build-style/gallery/style.css +3 -3
  221. package/build-style/gallery/theme-rtl.css +3 -3
  222. package/build-style/gallery/theme.css +3 -3
  223. package/build-style/group/editor-rtl.css +3 -3
  224. package/build-style/group/editor.css +3 -3
  225. package/build-style/group/style-rtl.css +3 -3
  226. package/build-style/group/style.css +3 -3
  227. package/build-style/group/theme-rtl.css +3 -3
  228. package/build-style/group/theme.css +3 -3
  229. package/build-style/heading/style-rtl.css +3 -3
  230. package/build-style/heading/style.css +3 -3
  231. package/build-style/html/editor-rtl.css +3 -3
  232. package/build-style/html/editor.css +3 -3
  233. package/build-style/image/editor-rtl.css +3 -3
  234. package/build-style/image/editor.css +3 -3
  235. package/build-style/image/style-rtl.css +3 -3
  236. package/build-style/image/style.css +3 -3
  237. package/build-style/image/theme-rtl.css +3 -3
  238. package/build-style/image/theme.css +3 -3
  239. package/build-style/latest-comments/style-rtl.css +3 -3
  240. package/build-style/latest-comments/style.css +3 -3
  241. package/build-style/latest-posts/editor-rtl.css +3 -3
  242. package/build-style/latest-posts/editor.css +3 -3
  243. package/build-style/latest-posts/style-rtl.css +3 -3
  244. package/build-style/latest-posts/style.css +3 -3
  245. package/build-style/list/style-rtl.css +3 -3
  246. package/build-style/list/style.css +3 -3
  247. package/build-style/media-text/editor-rtl.css +3 -3
  248. package/build-style/media-text/editor.css +3 -3
  249. package/build-style/media-text/style-rtl.css +3 -3
  250. package/build-style/media-text/style.css +3 -3
  251. package/build-style/more/editor-rtl.css +3 -3
  252. package/build-style/more/editor.css +3 -3
  253. package/build-style/navigation/editor-rtl.css +3 -9
  254. package/build-style/navigation/editor.css +3 -9
  255. package/build-style/navigation/style-rtl.css +3 -4
  256. package/build-style/navigation/style.css +3 -4
  257. package/build-style/navigation-link/editor-rtl.css +3 -3
  258. package/build-style/navigation-link/editor.css +3 -3
  259. package/build-style/navigation-link/style-rtl.css +3 -3
  260. package/build-style/navigation-link/style.css +3 -3
  261. package/build-style/navigation-submenu/editor-rtl.css +3 -3
  262. package/build-style/navigation-submenu/editor.css +3 -3
  263. package/build-style/nextpage/editor-rtl.css +3 -3
  264. package/build-style/nextpage/editor.css +3 -3
  265. package/build-style/page-list/editor-rtl.css +7 -3
  266. package/build-style/page-list/editor.css +7 -3
  267. package/build-style/page-list/style-rtl.css +3 -3
  268. package/build-style/page-list/style.css +3 -3
  269. package/build-style/paragraph/editor-rtl.css +3 -3
  270. package/build-style/paragraph/editor.css +3 -3
  271. package/build-style/paragraph/style-rtl.css +3 -3
  272. package/build-style/paragraph/style.css +3 -3
  273. package/build-style/post-author/style-rtl.css +3 -3
  274. package/build-style/post-author/style.css +3 -3
  275. package/build-style/post-comments-form/editor-rtl.css +3 -3
  276. package/build-style/post-comments-form/editor.css +3 -3
  277. package/build-style/post-comments-form/style-rtl.css +3 -3
  278. package/build-style/post-comments-form/style.css +3 -3
  279. package/build-style/post-date/style-rtl.css +3 -3
  280. package/build-style/post-date/style.css +3 -3
  281. package/build-style/post-excerpt/editor-rtl.css +3 -3
  282. package/build-style/post-excerpt/editor.css +3 -3
  283. package/build-style/post-excerpt/style-rtl.css +3 -3
  284. package/build-style/post-excerpt/style.css +3 -3
  285. package/build-style/post-featured-image/editor-rtl.css +3 -3
  286. package/build-style/post-featured-image/editor.css +3 -3
  287. package/build-style/post-featured-image/style-rtl.css +3 -3
  288. package/build-style/post-featured-image/style.css +3 -3
  289. package/build-style/post-navigation-link/style-rtl.css +3 -3
  290. package/build-style/post-navigation-link/style.css +3 -3
  291. package/build-style/post-template/editor-rtl.css +3 -3
  292. package/build-style/post-template/editor.css +3 -3
  293. package/build-style/post-template/style-rtl.css +3 -3
  294. package/build-style/post-template/style.css +3 -3
  295. package/build-style/post-terms/style-rtl.css +3 -3
  296. package/build-style/post-terms/style.css +3 -3
  297. package/build-style/post-title/style-rtl.css +3 -3
  298. package/build-style/post-title/style.css +3 -3
  299. package/build-style/preformatted/style-rtl.css +3 -3
  300. package/build-style/preformatted/style.css +3 -3
  301. package/build-style/pullquote/editor-rtl.css +3 -3
  302. package/build-style/pullquote/editor.css +3 -3
  303. package/build-style/pullquote/style-rtl.css +3 -3
  304. package/build-style/pullquote/style.css +3 -3
  305. package/build-style/pullquote/theme-rtl.css +3 -3
  306. package/build-style/pullquote/theme.css +3 -3
  307. package/build-style/query/editor-rtl.css +3 -3
  308. package/build-style/query/editor.css +3 -3
  309. package/build-style/query-pagination/editor-rtl.css +3 -3
  310. package/build-style/query-pagination/editor.css +3 -3
  311. package/build-style/query-pagination/style-rtl.css +3 -3
  312. package/build-style/query-pagination/style.css +3 -3
  313. package/build-style/query-pagination-numbers/editor-rtl.css +3 -3
  314. package/build-style/query-pagination-numbers/editor.css +3 -3
  315. package/build-style/query-title/style-rtl.css +3 -3
  316. package/build-style/query-title/style.css +3 -3
  317. package/build-style/quote/style-rtl.css +3 -3
  318. package/build-style/quote/style.css +3 -3
  319. package/build-style/quote/theme-rtl.css +3 -3
  320. package/build-style/quote/theme.css +3 -3
  321. package/build-style/read-more/style-rtl.css +3 -3
  322. package/build-style/read-more/style.css +3 -3
  323. package/build-style/reset-rtl.css +3 -3
  324. package/build-style/reset.css +3 -3
  325. package/build-style/rss/editor-rtl.css +3 -3
  326. package/build-style/rss/editor.css +3 -3
  327. package/build-style/rss/style-rtl.css +3 -3
  328. package/build-style/rss/style.css +3 -3
  329. package/build-style/search/editor-rtl.css +3 -3
  330. package/build-style/search/editor.css +3 -3
  331. package/build-style/search/style-rtl.css +3 -3
  332. package/build-style/search/style.css +3 -3
  333. package/build-style/search/theme-rtl.css +3 -3
  334. package/build-style/search/theme.css +3 -3
  335. package/build-style/separator/editor-rtl.css +3 -3
  336. package/build-style/separator/editor.css +3 -3
  337. package/build-style/separator/style-rtl.css +3 -3
  338. package/build-style/separator/style.css +3 -3
  339. package/build-style/separator/theme-rtl.css +3 -3
  340. package/build-style/separator/theme.css +3 -3
  341. package/build-style/shortcode/editor-rtl.css +3 -3
  342. package/build-style/shortcode/editor.css +3 -3
  343. package/build-style/site-logo/editor-rtl.css +3 -3
  344. package/build-style/site-logo/editor.css +3 -3
  345. package/build-style/site-logo/style-rtl.css +3 -3
  346. package/build-style/site-logo/style.css +3 -3
  347. package/build-style/site-tagline/editor-rtl.css +3 -3
  348. package/build-style/site-tagline/editor.css +3 -3
  349. package/build-style/site-title/editor-rtl.css +3 -3
  350. package/build-style/site-title/editor.css +3 -3
  351. package/build-style/site-title/style-rtl.css +3 -3
  352. package/build-style/site-title/style.css +3 -3
  353. package/build-style/social-link/editor-rtl.css +3 -3
  354. package/build-style/social-link/editor.css +3 -3
  355. package/build-style/social-links/editor-rtl.css +3 -3
  356. package/build-style/social-links/editor.css +3 -3
  357. package/build-style/social-links/style-rtl.css +3 -3
  358. package/build-style/social-links/style.css +3 -3
  359. package/build-style/spacer/editor-rtl.css +3 -3
  360. package/build-style/spacer/editor.css +3 -3
  361. package/build-style/spacer/style-rtl.css +3 -3
  362. package/build-style/spacer/style.css +3 -3
  363. package/build-style/style-rtl.css +13 -5
  364. package/build-style/style.css +13 -5
  365. package/build-style/table/editor-rtl.css +3 -3
  366. package/build-style/table/editor.css +3 -3
  367. package/build-style/table/style-rtl.css +9 -3
  368. package/build-style/table/style.css +9 -3
  369. package/build-style/table/theme-rtl.css +3 -9
  370. package/build-style/table/theme.css +3 -9
  371. package/build-style/tag-cloud/style-rtl.css +3 -3
  372. package/build-style/tag-cloud/style.css +3 -3
  373. package/build-style/template-part/editor-rtl.css +3 -3
  374. package/build-style/template-part/editor.css +3 -3
  375. package/build-style/template-part/theme-rtl.css +3 -3
  376. package/build-style/template-part/theme.css +3 -3
  377. package/build-style/text-columns/editor-rtl.css +3 -3
  378. package/build-style/text-columns/editor.css +3 -3
  379. package/build-style/text-columns/style-rtl.css +3 -3
  380. package/build-style/text-columns/style.css +3 -3
  381. package/build-style/theme-rtl.css +3 -9
  382. package/build-style/theme.css +3 -9
  383. package/build-style/verse/style-rtl.css +7 -4
  384. package/build-style/verse/style.css +7 -4
  385. package/build-style/video/editor-rtl.css +3 -3
  386. package/build-style/video/editor.css +3 -3
  387. package/build-style/video/style-rtl.css +3 -3
  388. package/build-style/video/style.css +3 -3
  389. package/build-style/video/theme-rtl.css +3 -3
  390. package/build-style/video/theme.css +3 -3
  391. package/package.json +29 -29
  392. package/src/categories/edit.js +1 -1
  393. package/src/comments/index.php +0 -1
  394. package/src/cover/edit/inspector-controls.js +4 -4
  395. package/src/freeform/edit.js +48 -29
  396. package/src/freeform/modal.js +111 -0
  397. package/src/gallery/edit.js +17 -2
  398. package/src/gallery/gallery.js +3 -13
  399. package/src/image/image.js +1 -0
  400. package/src/latest-posts/test/__snapshots__/edit.native.js.snap +3 -0
  401. package/src/latest-posts/test/edit.native.js +49 -0
  402. package/src/media-text/edit.js +1 -0
  403. package/src/missing/edit.native.js +13 -6
  404. package/src/more/test/__snapshots__/edit.native.js.snap +7 -0
  405. package/src/more/test/edit.native.js +41 -0
  406. package/src/navigation/edit/index.js +3 -4
  407. package/src/navigation/edit/menu-inspector-controls.js +70 -29
  408. package/src/navigation/edit/navigation-menu-selector.js +19 -9
  409. package/src/navigation/edit/utils.js +82 -0
  410. package/src/navigation/editor.scss +0 -7
  411. package/src/navigation/index.php +32 -0
  412. package/src/navigation/style.scss +0 -1
  413. package/src/navigation-link/edit.js +5 -58
  414. package/src/navigation-link/index.php +32 -0
  415. package/src/navigation-submenu/edit.js +29 -100
  416. package/src/navigation-submenu/index.php +32 -0
  417. package/src/page-list/block.json +18 -1
  418. package/src/page-list/edit.js +30 -22
  419. package/src/page-list/editor.scss +4 -0
  420. package/src/page-list/index.js +8 -2
  421. package/src/page-list/index.php +9 -10
  422. package/src/page-list-item/edit.js +17 -9
  423. package/src/post-featured-image/overlay.js +0 -1
  424. package/src/query/edit/index.js +1 -0
  425. package/src/query/edit/inspector-controls/index.js +49 -38
  426. package/src/query/edit/inspector-controls/taxonomy-controls.js +102 -38
  427. package/src/query/edit/query-content.js +2 -1
  428. package/src/query/edit/query-placeholder.js +15 -14
  429. package/src/query/utils.js +59 -1
  430. package/src/search/edit.js +2 -2
  431. package/src/separator/test/__snapshots__/edit.native.js.snap +7 -0
  432. package/src/separator/test/edit.native.js +41 -0
  433. package/src/social-link/edit.js +3 -3
  434. package/src/social-links/edit.js +0 -1
  435. package/src/table/style.scss +8 -0
  436. package/src/table/theme.scss +0 -8
  437. package/src/table-of-contents/edit.js +1 -1
  438. package/src/template-part/edit/advanced-controls.js +12 -0
  439. package/src/template-part/edit/import-controls.js +180 -0
  440. package/src/template-part/edit/index.js +1 -0
  441. package/src/template-part/edit/utils/transformers.js +37 -0
  442. package/src/verse/style.scss +4 -1
  443. package/src/verse/test/__snapshots__/edit.native.js.snap +13 -0
  444. package/src/verse/test/edit.native.js +40 -33
  445. package/tsconfig.tsbuildinfo +1 -1
  446. package/build/query/constants.js +0 -16
  447. package/build/query/constants.js.map +0 -1
  448. package/build-module/query/constants.js +0 -7
  449. package/build-module/query/constants.js.map +0 -1
  450. package/src/query/constants.js +0 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation/edit/utils.js"],"names":["getComputedStyle","node","ownerDocument","defaultView","detectColors","colorsDetectionElement","setColor","setBackground","color","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE"],"mappings":"AAAA,SAASA,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,CAACC,aAAL,CAAmBC,WAAnB,CAA+BH,gBAA/B,CAAiDC,IAAjD,CAAP;AACA;;AAED,OAAO,SAASG,YAAT,CACNC,sBADM,EAENC,QAFM,EAGNC,aAHM,EAIL;AACD,MAAK,CAAEF,sBAAP,EAAgC;AAC/B;AACA;;AACDC,EAAAA,QAAQ,CAAEN,gBAAgB,CAAEK,sBAAF,CAAhB,CAA2CG,KAA7C,CAAR;AAEA,MAAIC,mBAAmB,GAAGJ,sBAA1B;AACA,MAAIK,eAAe,GAClBV,gBAAgB,CAAES,mBAAF,CAAhB,CAAwCC,eADzC;;AAEA,SACCA,eAAe,KAAK,kBAApB,IACAD,mBAAmB,CAACE,UADpB,IAEAF,mBAAmB,CAACE,UAApB,CAA+BC,QAA/B,KACCH,mBAAmB,CAACE,UAApB,CAA+BE,YAJjC,EAKE;AACDJ,IAAAA,mBAAmB,GAAGA,mBAAmB,CAACE,UAA1C;AACAD,IAAAA,eAAe,GACdV,gBAAgB,CAAES,mBAAF,CAAhB,CAAwCC,eADzC;AAEA;;AAEDH,EAAAA,aAAa,CAAEG,eAAF,CAAb;AACA","sourcesContent":["function getComputedStyle( node ) {\n\treturn node.ownerDocument.defaultView.getComputedStyle( node );\n}\n\nexport function detectColors(\n\tcolorsDetectionElement,\n\tsetColor,\n\tsetBackground\n) {\n\tif ( ! colorsDetectionElement ) {\n\t\treturn;\n\t}\n\tsetColor( getComputedStyle( colorsDetectionElement ).color );\n\n\tlet backgroundColorNode = colorsDetectionElement;\n\tlet backgroundColor =\n\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\twhile (\n\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\tbackgroundColorNode.parentNode &&\n\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t) {\n\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\tbackgroundColor =\n\t\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\t}\n\n\tsetBackground( backgroundColor );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation/edit/utils.js"],"names":["classnames","getComputedStyle","node","ownerDocument","defaultView","detectColors","colorsDetectionElement","setColor","setBackground","color","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE","getColors","context","isSubMenu","textColor","customTextColor","customBackgroundColor","overlayTextColor","customOverlayTextColor","overlayBackgroundColor","customOverlayBackgroundColor","style","colors","text","background","getNavigationChildBlockProps","innerBlocksColors","className"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;;AAEA,SAASC,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,CAACC,aAAL,CAAmBC,WAAnB,CAA+BH,gBAA/B,CAAiDC,IAAjD,CAAP;AACA;;AAED,OAAO,SAASG,YAAT,CACNC,sBADM,EAENC,QAFM,EAGNC,aAHM,EAIL;AACD,MAAK,CAAEF,sBAAP,EAAgC;AAC/B;AACA;;AACDC,EAAAA,QAAQ,CAAEN,gBAAgB,CAAEK,sBAAF,CAAhB,CAA2CG,KAA7C,CAAR;AAEA,MAAIC,mBAAmB,GAAGJ,sBAA1B;AACA,MAAIK,eAAe,GAClBV,gBAAgB,CAAES,mBAAF,CAAhB,CAAwCC,eADzC;;AAEA,SACCA,eAAe,KAAK,kBAApB,IACAD,mBAAmB,CAACE,UADpB,IAEAF,mBAAmB,CAACE,UAApB,CAA+BC,QAA/B,KACCH,mBAAmB,CAACE,UAApB,CAA+BE,YAJjC,EAKE;AACDJ,IAAAA,mBAAmB,GAAGA,mBAAmB,CAACE,UAA1C;AACAD,IAAAA,eAAe,GACdV,gBAAgB,CAAES,mBAAF,CAAhB,CAAwCC,eAD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eAAP,GAAyBY,sBAAzB;AACA,GAFM,MAEA,IAAK,CAAC,CAAEH,qBAAR,EAAgC;AACtCM,IAAAA,MAAM,CAACN,qBAAP,GAA+BA,qBAA/B;AACA,GAFM,MAEA,IAAK,CAAC,CAAET,eAAR,EAA0B;AAChCe,IAAAA,MAAM,CAACf,eAAP,GAAyBA,eAAzB;AACA,GAFM,MAEA,IAAK,CAAC,EAAEc,KAAF,aAAEA,KAAF,gCAAEA,KAAK,CAAEhB,KAAT,0CAAE,cAAcmB,UAAhB,CAAN,EAAmC;AACzCF,IAAAA,MAAM,CAACP,eAAP,GAAyBM,KAAK,CAAChB,KAAN,CAAYmB,UAArC;AACA;;AAED,SAAOF,MAAP;AACA;AAED,OAAO,SAASG,4BAAT,CAAuCC,iBAAvC,EAA2D;AACjE,SAAO;AACNC,IAAAA,SAAS,EAAE/B,UAAU,CAAE,wCAAF,EAA4C;AAChE,wBAAkB,CAAC,EAClB8B,iBAAiB,CAACZ,SAAlB,IAA+BY,iBAAiB,CAACX,eAD/B,CAD6C;AAIhE,OAAG,OAAOW,iBAAiB,CAACZ,SAAW,QAAvC,GACC,CAAC,CAAEY,iBAAiB,CAACZ,SAL0C;AAMhE,wBAAkB,CAAC,EAClBY,iBAAiB,CAACnB,eAAlB,IACAmB,iBAAiB,CAACV,qBAFA,CAN6C;AAUhE,OAAG,OAAOU,iBAAiB,CAACnB,eAAiB,mBAA7C,GACC,CAAC,CAAEmB,iBAAiB,CAACnB;AAX0C,KAA5C,CADf;AAcNc,IAAAA,KAAK,EAAE;AACNhB,MAAAA,KAAK,EAAEqB,iBAAiB,CAACX,eADnB;AAENR,MAAAA,eAAe,EAAEmB,iBAAiB,CAACV;AAF7B;AAdD,GAAP;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\nfunction getComputedStyle( node ) {\n\treturn node.ownerDocument.defaultView.getComputedStyle( node );\n}\n\nexport function detectColors(\n\tcolorsDetectionElement,\n\tsetColor,\n\tsetBackground\n) {\n\tif ( ! colorsDetectionElement ) {\n\t\treturn;\n\t}\n\tsetColor( getComputedStyle( colorsDetectionElement ).color );\n\n\tlet backgroundColorNode = colorsDetectionElement;\n\tlet backgroundColor =\n\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\twhile (\n\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\tbackgroundColorNode.parentNode &&\n\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t) {\n\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\tbackgroundColor =\n\t\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\t}\n\n\tsetBackground( backgroundColor );\n}\n\n/**\n * Determine the colors for a menu.\n *\n * Order of priority is:\n * 1: Overlay custom colors (if submenu)\n * 2: Overlay theme colors (if submenu)\n * 3: Custom colors\n * 4: Theme colors\n * 5: Global styles\n *\n * @param {Object} context\n * @param {boolean} isSubMenu\n */\nexport function getColors( context, isSubMenu ) {\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t\toverlayTextColor,\n\t\tcustomOverlayTextColor,\n\t\toverlayBackgroundColor,\n\t\tcustomOverlayBackgroundColor,\n\t\tstyle,\n\t} = context;\n\n\tconst colors = {};\n\n\tif ( isSubMenu && !! customOverlayTextColor ) {\n\t\tcolors.customTextColor = customOverlayTextColor;\n\t} else if ( isSubMenu && !! overlayTextColor ) {\n\t\tcolors.textColor = overlayTextColor;\n\t} else if ( !! customTextColor ) {\n\t\tcolors.customTextColor = customTextColor;\n\t} else if ( !! textColor ) {\n\t\tcolors.textColor = textColor;\n\t} else if ( !! style?.color?.text ) {\n\t\tcolors.customTextColor = style.color.text;\n\t}\n\n\tif ( isSubMenu && !! customOverlayBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customOverlayBackgroundColor;\n\t} else if ( isSubMenu && !! overlayBackgroundColor ) {\n\t\tcolors.backgroundColor = overlayBackgroundColor;\n\t} else if ( !! customBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customBackgroundColor;\n\t} else if ( !! backgroundColor ) {\n\t\tcolors.backgroundColor = backgroundColor;\n\t} else if ( !! style?.color?.background ) {\n\t\tcolors.customTextColor = style.color.background;\n\t}\n\n\treturn colors;\n}\n\nexport function getNavigationChildBlockProps( innerBlocksColors ) {\n\treturn {\n\t\tclassName: classnames( 'wp-block-navigation__submenu-container', {\n\t\t\t'has-text-color': !! (\n\t\t\t\tinnerBlocksColors.textColor || innerBlocksColors.customTextColor\n\t\t\t),\n\t\t\t[ `has-${ innerBlocksColors.textColor }-color` ]:\n\t\t\t\t!! innerBlocksColors.textColor,\n\t\t\t'has-background': !! (\n\t\t\t\tinnerBlocksColors.backgroundColor ||\n\t\t\t\tinnerBlocksColors.customBackgroundColor\n\t\t\t),\n\t\t\t[ `has-${ innerBlocksColors.backgroundColor }-background-color` ]:\n\t\t\t\t!! innerBlocksColors.backgroundColor,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: innerBlocksColors.customTextColor,\n\t\t\tbackgroundColor: innerBlocksColors.customBackgroundColor,\n\t\t},\n\t};\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * External dependencies
@@ -16,7 +16,7 @@ import { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';
16
16
  import { __ } from '@wordpress/i18n';
17
17
  import { BlockControls, InspectorControls, RichText, useBlockProps, store as blockEditorStore, getColorClassName, useInnerBlocksProps } from '@wordpress/block-editor';
18
18
  import { isURL, prependHTTP } from '@wordpress/url';
19
- import { Fragment, useState, useEffect, useRef } from '@wordpress/element';
19
+ import { useState, useEffect, useRef } from '@wordpress/element';
20
20
  import { placeCaretAtHorizontalEdge, __unstableStripHTML as stripHTML } from '@wordpress/dom';
21
21
  import { link as linkIcon, addSubmenu } from '@wordpress/icons';
22
22
  import { store as coreStore, useResourcePermissions } from '@wordpress/core-data';
@@ -93,6 +93,7 @@ const {
93
93
  };
94
94
  import { LinkUI } from './link-ui';
95
95
  import { updateAttributes } from './update-attributes';
96
+ import { getColors } from '../navigation/edit/utils';
96
97
  /**
97
98
  * A React hook to determine if it's dragging within the target element.
98
99
  *
@@ -143,63 +144,6 @@ const useIsDraggingWithin = elementRef => {
143
144
  }, []);
144
145
  return isDraggingWithin;
145
146
  };
146
- /**
147
- * Determine the colors for a menu.
148
- *
149
- * Order of priority is:
150
- * 1: Overlay custom colors (if submenu)
151
- * 2: Overlay theme colors (if submenu)
152
- * 3: Custom colors
153
- * 4: Theme colors
154
- * 5: Global styles
155
- *
156
- * @param {Object} context
157
- * @param {boolean} isSubMenu
158
- */
159
-
160
-
161
- function getColors(context, isSubMenu) {
162
- var _style$color, _style$color2;
163
-
164
- const {
165
- textColor,
166
- customTextColor,
167
- backgroundColor,
168
- customBackgroundColor,
169
- overlayTextColor,
170
- customOverlayTextColor,
171
- overlayBackgroundColor,
172
- customOverlayBackgroundColor,
173
- style
174
- } = context;
175
- const colors = {};
176
-
177
- if (isSubMenu && !!customOverlayTextColor) {
178
- colors.customTextColor = customOverlayTextColor;
179
- } else if (isSubMenu && !!overlayTextColor) {
180
- colors.textColor = overlayTextColor;
181
- } else if (!!customTextColor) {
182
- colors.customTextColor = customTextColor;
183
- } else if (!!textColor) {
184
- colors.textColor = textColor;
185
- } else if (!!(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.text)) {
186
- colors.customTextColor = style.color.text;
187
- }
188
-
189
- if (isSubMenu && !!customOverlayBackgroundColor) {
190
- colors.customBackgroundColor = customOverlayBackgroundColor;
191
- } else if (isSubMenu && !!overlayBackgroundColor) {
192
- colors.backgroundColor = overlayBackgroundColor;
193
- } else if (!!customBackgroundColor) {
194
- colors.customBackgroundColor = customBackgroundColor;
195
- } else if (!!backgroundColor) {
196
- colors.backgroundColor = backgroundColor;
197
- } else if (!!(style !== null && style !== void 0 && (_style$color2 = style.color) !== null && _style$color2 !== void 0 && _style$color2.background)) {
198
- colors.customTextColor = style.color.background;
199
- }
200
-
201
- return colors;
202
- }
203
147
 
204
148
  const useIsInvalidLink = (kind, type, id) => {
205
149
  const isPostType = kind === 'post-type' || type === 'post' || type === 'page';
@@ -514,6 +458,7 @@ export default function NavigationLinkEdit(_ref) {
514
458
  label: __('URL'),
515
459
  autoComplete: "off"
516
460
  }), createElement(TextareaControl, {
461
+ __nextHasNoMarginBottom: true,
517
462
  value: description || '',
518
463
  onChange: descriptionValue => {
519
464
  setAttributes({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation-link/edit.js"],"names":["classnames","unescape","createBlock","useSelect","useDispatch","PanelBody","TextControl","TextareaControl","ToolbarButton","Tooltip","ToolbarGroup","KeyboardShortcuts","displayShortcut","isKeyboardEvent","ENTER","__","BlockControls","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","useInnerBlocksProps","isURL","prependHTTP","Fragment","useState","useEffect","useRef","placeCaretAtHorizontalEdge","__unstableStripHTML","stripHTML","link","linkIcon","addSubmenu","coreStore","useResourcePermissions","useMergeRefs","LinkUI","updateAttributes","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","getColors","context","isSubMenu","textColor","customTextColor","backgroundColor","customBackgroundColor","overlayTextColor","customOverlayTextColor","overlayBackgroundColor","customOverlayBackgroundColor","style","colors","color","text","background","useIsInvalidLink","kind","type","id","isPostType","hasId","Number","isInteger","postStatus","select","getEntityRecord","status","isInvalid","isDraft","getMissingText","missingText","NavigationLinkEdit","attributes","isSelected","setAttributes","insertBlocksAfter","mergeBlocks","onReplace","clientId","label","url","description","rel","title","maxNestingLevel","replaceBlock","__unstableMarkNextChangeAsNotPersistent","isLinkOpen","setIsLinkOpen","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","pagesPermissions","postsPermissions","innerBlocks","isAtMaxNesting","isTopLevelLink","isParentOfSelectedBlock","hasChildren","getBlocks","getBlockCount","getBlockName","getBlockRootClientId","hasSelectedInnerBlock","getBlockParentsByBlockName","name","length","transformToSubmenu","newSubmenu","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","removeLink","userCanCreate","canCreate","onKeyDown","primary","keyCode","blockProps","className","ALLOWED_BLOCKS","DEFAULT_BLOCK","innerBlocksProps","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","renderAppender","onClick","classes","placeholderText","tooltipText","labelValue","urlValue","descriptionValue","titleValue","relValue","enter","trim","updatedValue"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,SADD,EAECC,WAFD,EAGCC,eAHD,EAICC,aAJD,EAKCC,OALD,EAMCC,YAND,EAOCC,iBAPD,QAQO,uBARP;AASA,SAASC,eAAT,EAA0BC,eAA1B,EAA2CC,KAA3C,QAAwD,qBAAxD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,aADD,EAECC,iBAFD,EAGCC,QAHD,EAICC,aAJD,EAKCC,KAAK,IAAIC,gBALV,EAMCC,iBAND,EAOCC,mBAPD,QAQO,yBARP;AASA,SAASC,KAAT,EAAgBC,WAAhB,QAAmC,gBAAnC;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,SAA7B,EAAwCC,MAAxC,QAAsD,oBAAtD;AACA,SACCC,0BADD,EAECC,mBAAmB,IAAIC,SAFxB,QAGO,gBAHP;AAIA,SAASC,IAAI,IAAIC,QAAjB,EAA2BC,UAA3B,QAA6C,kBAA7C;AAC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gB,CACf4H,YADe,EAEf1E,aAFe,EAGfF,UAHe,CAAhB;AAKA;AAdF,IApGF,CAFD,EAwHC,qBAAU4D,gBAAV,CAxHD,CAnED,CADD;AAgMA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { unescape } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tTooltip,\n\tToolbarGroup,\n\tKeyboardShortcuts,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';\nimport { __ } 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 { Fragment, useState, useEffect, useRef } from '@wordpress/element';\nimport {\n\tplaceCaretAtHorizontalEdge,\n\t__unstableStripHTML as stripHTML,\n} from '@wordpress/dom';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport {\n\tstore as coreStore,\n\tuseResourcePermissions,\n} from '@wordpress/core-data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { name } from './block.json';\nimport { LinkUI } from './link-ui';\nimport { updateAttributes } from './update-attributes';\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * Determine the colors for a menu.\n *\n * Order of priority is:\n * 1: Overlay custom colors (if submenu)\n * 2: Overlay theme colors (if submenu)\n * 3: Custom colors\n * 4: Theme colors\n * 5: Global styles\n *\n * @param {Object} context\n * @param {boolean} isSubMenu\n */\nfunction getColors( context, isSubMenu ) {\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t\toverlayTextColor,\n\t\tcustomOverlayTextColor,\n\t\toverlayBackgroundColor,\n\t\tcustomOverlayBackgroundColor,\n\t\tstyle,\n\t} = context;\n\n\tconst colors = {};\n\n\tif ( isSubMenu && !! customOverlayTextColor ) {\n\t\tcolors.customTextColor = customOverlayTextColor;\n\t} else if ( isSubMenu && !! overlayTextColor ) {\n\t\tcolors.textColor = overlayTextColor;\n\t} else if ( !! customTextColor ) {\n\t\tcolors.customTextColor = customTextColor;\n\t} else if ( !! textColor ) {\n\t\tcolors.textColor = textColor;\n\t} else if ( !! style?.color?.text ) {\n\t\tcolors.customTextColor = style.color.text;\n\t}\n\n\tif ( isSubMenu && !! customOverlayBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customOverlayBackgroundColor;\n\t} else if ( isSubMenu && !! overlayBackgroundColor ) {\n\t\tcolors.backgroundColor = overlayBackgroundColor;\n\t} else if ( !! customBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customBackgroundColor;\n\t} else if ( !! backgroundColor ) {\n\t\tcolors.backgroundColor = backgroundColor;\n\t} else if ( !! style?.color?.background ) {\n\t\tcolors.customTextColor = style.color.background;\n\t}\n\n\treturn colors;\n}\n\nconst useIsInvalidLink = ( kind, type, id ) => {\n\tconst isPostType =\n\t\tkind === 'post-type' || type === 'post' || type === 'page';\n\tconst hasId = Number.isInteger( id );\n\tconst postStatus = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPostType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', type, id )?.status;\n\t\t},\n\t\t[ isPostType, type, id ]\n\t);\n\n\t// Check Navigation Link validity if:\n\t// 1. Link is 'post-type'.\n\t// 2. It has an id.\n\t// 3. It's neither null, nor undefined, as valid items might be either of those while loading.\n\t// If those conditions are met, check if\n\t// 1. The post status is published.\n\t// 2. The Navigation Link item has no label.\n\t// If either of those is true, invalidate.\n\tconst isInvalid =\n\t\tisPostType && hasId && postStatus && 'trash' === postStatus;\n\tconst isDraft = 'draft' === postStatus;\n\n\treturn [ isInvalid, isDraft ];\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, rel, title, kind } = attributes;\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink( kind, type, id );\n\tconst { maxNestingLevel } = context;\n\n\tconst { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\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\n\tconst pagesPermissions = useResourcePermissions( 'pages' );\n\tconst postsPermissions = useResourcePermissions( 'posts' );\n\n\tconst {\n\t\tinnerBlocks,\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocks,\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\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, [\n\t\t\t\t\t\tname,\n\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t] ).length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink:\n\t\t\t\t\tgetBlockName( getBlockRootClientId( clientId ) ) ===\n\t\t\t\t\t'core/navigation',\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};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level as those should\n\t\t// only be created via user interactions. Mark this change as\n\t\t// not persistent to avoid undo level creation.\n\t\t// See https://github.com/WordPress/gutenberg/issues/34564.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { isTopLevelLink } );\n\t}, [ isTopLevelLink ] );\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tfunction transformToSubmenu() {\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks.length > 0\n\t\t\t\t? innerBlocks\n\t\t\t\t: [ createBlock( 'core/navigation-link' ) ]\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t}\n\n\tuseEffect( () => {\n\t\t// Show the LinkControl on mount if the URL is empty\n\t\t// ( When adding a new menu item)\n\t\t// This can't be done in the useState call because it conflicts\n\t\t// with the autofocus behavior of the BlockListBlock component.\n\t\tif ( ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [ url ] );\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [ hasChildren ] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t} else {\n\t\t\t\t// Focus it (but do not select).\n\t\t\t\tplaceCaretAtHorizontalEdge( ref.current, true );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\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\tsetAttributes( {\n\t\t\turl: '',\n\t\t\tlabel: '',\n\t\t\tid: '',\n\t\t\tkind: '',\n\t\t\ttype: '',\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tlet userCanCreate = false;\n\tif ( ! type || type === 'page' ) {\n\t\tuserCanCreate = pagesPermissions.canCreate;\n\t} else if ( type === 'post' ) {\n\t\tuserCanCreate = postsPermissions.canCreate;\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 (\n\t\t\tisKeyboardEvent.primary( event, 'k' ) ||\n\t\t\t( ! url && event.keyCode === ENTER )\n\t\t) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: classnames( '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\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst ALLOWED_BLOCKS = [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t\t'core/page-list',\n\t];\n\tconst DEFAULT_BLOCK = {\n\t\tname: 'core/navigation-link',\n\t};\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\t__experimentalDefaultBlock: DEFAULT_BLOCK,\n\t\t__experimentalDirectInsert: true,\n\t\trenderAppender: false,\n\t} );\n\n\tif ( ! url || isInvalid || isDraft ) {\n\t\tblockProps.onClick = () => setIsLinkOpen( true );\n\t}\n\n\tconst classes = classnames( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': ! url || isInvalid || isDraft,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\t/* translators: Whether the navigation link is Invalid or a Draft. */\n\tconst placeholderText = `(${\n\t\tisInvalid ? __( 'Invalid' ) : __( 'Draft' )\n\t})`;\n\tconst tooltipText =\n\t\tisInvalid || isDraft\n\t\t\t? __( 'This item has been deleted, or is a draft' )\n\t\t\t: __( 'This item is missing a link' );\n\n\treturn (\n\t\t<Fragment>\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={ () => setIsLinkOpen( true ) }\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{ /* Warning, this duplicated in packages/block-library/src/navigation-submenu/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ label ? stripHTML( label ) : '' }\n\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Label' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'URL' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { description: descriptionValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link title' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\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 ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<Tooltip position=\"top center\" text={ tooltipText }>\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-link__missing_text-tooltip\">\n\t\t\t\t\t\t\t\t\t\t{ tooltipText }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t</Tooltip>\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\tallowedFormats={ [\n\t\t\t\t\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tif ( ! url ) {\n\t\t\t\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\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/>\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<div className=\"wp-block-navigation-link__placeholder-text wp-block-navigation-link__label\">\n\t\t\t\t\t\t\t\t\t<KeyboardShortcuts\n\t\t\t\t\t\t\t\t\t\tshortcuts={ {\n\t\t\t\t\t\t\t\t\t\t\tenter: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tisSelected &&\n\t\t\t\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true ),\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\t<Tooltip\n\t\t\t\t\t\t\t\t\t\tposition=\"top center\"\n\t\t\t\t\t\t\t\t\t\ttext={ tooltipText }\n\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\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\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\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\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Some attributes are stored in an escaped form. It's a legacy issue.\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Ideally they would be stored in a raw, unescaped form.\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Unescape is used here to \"recover\" the escaped characters\n\t\t\t\t\t\t\t\t\t\t\t\t\t// so they display without encoding.\n\t\t\t\t\t\t\t\t\t\t\t\t\t// See `updateAttributes` for more details.\n\t\t\t\t\t\t\t\t\t\t\t\t\t`${ unescape(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t\t\t\t) } ${ placeholderText }`.trim()\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</span>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-link__missing_text-tooltip\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ tooltipText }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t\t\t</div>\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\tclassName=\"wp-block-navigation-link__inline-link-input\"\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\tonClose={ () => setIsLinkOpen( false ) }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\thasCreateSuggestion={ userCanCreate }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\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</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</Fragment>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation-link/edit.js"],"names":["classnames","unescape","createBlock","useSelect","useDispatch","PanelBody","TextControl","TextareaControl","ToolbarButton","Tooltip","ToolbarGroup","KeyboardShortcuts","displayShortcut","isKeyboardEvent","ENTER","__","BlockControls","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","useInnerBlocksProps","isURL","prependHTTP","useState","useEffect","useRef","placeCaretAtHorizontalEdge","__unstableStripHTML","stripHTML","link","linkIcon","addSubmenu","coreStore","useResourcePermissions","useMergeRefs","LinkUI","updateAttributes","getColors","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","useIsInvalidLink","kind","type","id","isPostType","hasId","Number","isInteger","postStatus","select","getEntityRecord","status","isInvalid","isDraft","getMissingText","missingText","NavigationLinkEdit","attributes","isSelected","setAttributes","insertBlocksAfter","mergeBlocks","onReplace","context","clientId","label","url","description","rel","title","maxNestingLevel","replaceBlock","__unstableMarkNextChangeAsNotPersistent","isLinkOpen","setIsLinkOpen","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","pagesPermissions","postsPermissions","innerBlocks","isAtMaxNesting","isTopLevelLink","isParentOfSelectedBlock","hasChildren","getBlocks","getBlockCount","getBlockName","getBlockRootClientId","hasSelectedInnerBlock","getBlockParentsByBlockName","name","length","transformToSubmenu","newSubmenu","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","removeLink","userCanCreate","canCreate","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","keyCode","blockProps","className","style","color","ALLOWED_BLOCKS","DEFAULT_BLOCK","innerBlocksProps","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","renderAppender","onClick","classes","placeholderText","tooltipText","labelValue","urlValue","descriptionValue","titleValue","relValue","enter","trim","updatedValue"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,QAAT,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,SADD,EAECC,WAFD,EAGCC,eAHD,EAICC,aAJD,EAKCC,OALD,EAMCC,YAND,EAOCC,iBAPD,QAQO,uBARP;AASA,SAASC,eAAT,EAA0BC,eAA1B,EAA2CC,KAA3C,QAAwD,qBAAxD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,aADD,EAECC,iBAFD,EAGCC,QAHD,EAICC,aAJD,EAKCC,KAAK,IAAIC,gBALV,EAMCC,iBAND,EAOCC,mBAPD,QAQO,yBARP;AASA,SAASC,KAAT,EAAgBC,WAAhB,QAAmC,gBAAnC;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,MAA9B,QAA4C,oBAA5C;AACA,SACCC,0BADD,EAECC,mBAAmB,IAAIC,SAFxB,QAGO,gBAHP;AAIA,SAASC,IAAI,IAAIC,QAAjB,EAA2BC,UAA3B,QAA6C,kBAA7C;AACA,SACCd,KAAK,IAAIe,SADV,EAECC,sBAFD,QAGO,sBAHP;AAIA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAASC,MAAT,QAAuB,WAAvB;AACA,SAASC,gBAAT,QAAiC,qBAAjC;AACA,SAASC,SAAT,QAA0B,0BAA1B;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AA,IAAI,EAAG0D;AAFR,KAIC,8BACC;AACC,kBAAapI,EAAE,CACd,sBADc;AADhB,KAME;AACA;AACA;AACA;AACA;AACC,KAAGd,QAAQ,CACX+E,KADW,CAET,IAAIkE,eAAiB,EAFxB,CAE0BQ,IAF1B,EAXF,CADD,EAiBC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGP,WADH,CAjBD,CAJD,CARD,CA/CF,CAdF,EAmGG3D,UAAU,IACX,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,QAAQ,EAAGT,QAFZ;AAGC,IAAA,IAAI,EAAGP,UAHR;AAIC,IAAA,OAAO,EAAG,MAAMiB,aAAa,CAAE,KAAF,CAJ9B;AAKC,IAAA,MAAM,EAAGC,aALV;AAMC,IAAA,mBAAmB,EAAGkC,aANvB;AAOC,IAAA,QAAQ,EAAGD,UAPZ;AAQC,IAAA,QAAQ,EAAKgC,YAAF,IAAoB;AAC9BpH,MAAAA,gBAAgB,CACfoH,YADe,EAEfjF,aAFe,EAGfF,UAHe,CAAhB;AAKA;AAdF,IApGF,CAFD,EAwHC,qBAAUmE,gBAAV,CAxHD,CApED,CADD;AAiMA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { unescape } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tTooltip,\n\tToolbarGroup,\n\tKeyboardShortcuts,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';\nimport { __ } 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 } from '@wordpress/element';\nimport {\n\tplaceCaretAtHorizontalEdge,\n\t__unstableStripHTML as stripHTML,\n} from '@wordpress/dom';\nimport { link as linkIcon, addSubmenu } from '@wordpress/icons';\nimport {\n\tstore as coreStore,\n\tuseResourcePermissions,\n} from '@wordpress/core-data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { name } from './block.json';\nimport { LinkUI } from './link-ui';\nimport { updateAttributes } from './update-attributes';\nimport { getColors } from '../navigation/edit/utils';\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\nconst useIsInvalidLink = ( kind, type, id ) => {\n\tconst isPostType =\n\t\tkind === 'post-type' || type === 'post' || type === 'page';\n\tconst hasId = Number.isInteger( id );\n\tconst postStatus = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isPostType ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'postType', type, id )?.status;\n\t\t},\n\t\t[ isPostType, type, id ]\n\t);\n\n\t// Check Navigation Link validity if:\n\t// 1. Link is 'post-type'.\n\t// 2. It has an id.\n\t// 3. It's neither null, nor undefined, as valid items might be either of those while loading.\n\t// If those conditions are met, check if\n\t// 1. The post status is published.\n\t// 2. The Navigation Link item has no label.\n\t// If either of those is true, invalidate.\n\tconst isInvalid =\n\t\tisPostType && hasId && postStatus && 'trash' === postStatus;\n\tconst isDraft = 'draft' === postStatus;\n\n\treturn [ isInvalid, isDraft ];\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, rel, title, kind } = attributes;\n\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink( kind, type, id );\n\tconst { maxNestingLevel } = context;\n\n\tconst { replaceBlock, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\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\n\tconst pagesPermissions = useResourcePermissions( 'pages' );\n\tconst postsPermissions = useResourcePermissions( 'posts' );\n\n\tconst {\n\t\tinnerBlocks,\n\t\tisAtMaxNesting,\n\t\tisTopLevelLink,\n\t\tisParentOfSelectedBlock,\n\t\thasChildren,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocks,\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\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, [\n\t\t\t\t\t\tname,\n\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t] ).length >= maxNestingLevel,\n\t\t\t\tisTopLevelLink:\n\t\t\t\t\tgetBlockName( getBlockRootClientId( clientId ) ) ===\n\t\t\t\t\t'core/navigation',\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};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level as those should\n\t\t// only be created via user interactions. Mark this change as\n\t\t// not persistent to avoid undo level creation.\n\t\t// See https://github.com/WordPress/gutenberg/issues/34564.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { isTopLevelLink } );\n\t}, [ isTopLevelLink ] );\n\n\t/**\n\t * Transform to submenu block.\n\t */\n\tfunction transformToSubmenu() {\n\t\tconst newSubmenu = createBlock(\n\t\t\t'core/navigation-submenu',\n\t\t\tattributes,\n\t\t\tinnerBlocks.length > 0\n\t\t\t\t? innerBlocks\n\t\t\t\t: [ createBlock( 'core/navigation-link' ) ]\n\t\t);\n\t\treplaceBlock( clientId, newSubmenu );\n\t}\n\n\tuseEffect( () => {\n\t\t// Show the LinkControl on mount if the URL is empty\n\t\t// ( When adding a new menu item)\n\t\t// This can't be done in the useState call because it conflicts\n\t\t// with the autofocus behavior of the BlockListBlock component.\n\t\tif ( ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [ url ] );\n\n\tuseEffect( () => {\n\t\t// If block has inner blocks, transform to Submenu.\n\t\tif ( hasChildren ) {\n\t\t\ttransformToSubmenu();\n\t\t}\n\t}, [ hasChildren ] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t} else {\n\t\t\t\t// Focus it (but do not select).\n\t\t\t\tplaceCaretAtHorizontalEdge( ref.current, true );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\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\tsetAttributes( {\n\t\t\turl: '',\n\t\t\tlabel: '',\n\t\t\tid: '',\n\t\t\tkind: '',\n\t\t\ttype: '',\n\t\t} );\n\n\t\t// Close the link editing UI.\n\t\tsetIsLinkOpen( false );\n\t}\n\n\tlet userCanCreate = false;\n\tif ( ! type || type === 'page' ) {\n\t\tuserCanCreate = pagesPermissions.canCreate;\n\t} else if ( type === 'post' ) {\n\t\tuserCanCreate = postsPermissions.canCreate;\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 (\n\t\t\tisKeyboardEvent.primary( event, 'k' ) ||\n\t\t\t( ! url && event.keyCode === ENTER )\n\t\t) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: classnames( '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\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\tconst ALLOWED_BLOCKS = [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t\t'core/page-list',\n\t];\n\tconst DEFAULT_BLOCK = {\n\t\tname: 'core/navigation-link',\n\t};\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\t__experimentalDefaultBlock: DEFAULT_BLOCK,\n\t\t__experimentalDirectInsert: true,\n\t\trenderAppender: false,\n\t} );\n\n\tif ( ! url || isInvalid || isDraft ) {\n\t\tblockProps.onClick = () => setIsLinkOpen( true );\n\t}\n\n\tconst classes = classnames( 'wp-block-navigation-item__content', {\n\t\t'wp-block-navigation-link__placeholder': ! url || isInvalid || isDraft,\n\t} );\n\n\tconst missingText = getMissingText( type );\n\t/* translators: Whether the navigation link is Invalid or a Draft. */\n\tconst placeholderText = `(${\n\t\tisInvalid ? __( 'Invalid' ) : __( 'Draft' )\n\t})`;\n\tconst tooltipText =\n\t\tisInvalid || isDraft\n\t\t\t? __( 'This item has been deleted, or is a draft' )\n\t\t\t: __( 'This item is missing a link' );\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={ () => setIsLinkOpen( true ) }\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{ /* Warning, this duplicated in packages/block-library/src/navigation-submenu/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ label ? stripHTML( label ) : '' }\n\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Label' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'URL' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { description: descriptionValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link title' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\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 ? (\n\t\t\t\t\t\t<div className=\"wp-block-navigation-link__placeholder-text\">\n\t\t\t\t\t\t\t<Tooltip position=\"top center\" text={ tooltipText }>\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<span>{ missingText }</span>\n\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-link__missing_text-tooltip\">\n\t\t\t\t\t\t\t\t\t\t{ tooltipText }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t</Tooltip>\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\tallowedFormats={ [\n\t\t\t\t\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tif ( ! url ) {\n\t\t\t\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\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/>\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<div className=\"wp-block-navigation-link__placeholder-text wp-block-navigation-link__label\">\n\t\t\t\t\t\t\t\t\t<KeyboardShortcuts\n\t\t\t\t\t\t\t\t\t\tshortcuts={ {\n\t\t\t\t\t\t\t\t\t\t\tenter: () =>\n\t\t\t\t\t\t\t\t\t\t\t\tisSelected &&\n\t\t\t\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true ),\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\t<Tooltip\n\t\t\t\t\t\t\t\t\t\tposition=\"top center\"\n\t\t\t\t\t\t\t\t\t\ttext={ tooltipText }\n\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\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\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\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\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Some attributes are stored in an escaped form. It's a legacy issue.\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Ideally they would be stored in a raw, unescaped form.\n\t\t\t\t\t\t\t\t\t\t\t\t\t// Unescape is used here to \"recover\" the escaped characters\n\t\t\t\t\t\t\t\t\t\t\t\t\t// so they display without encoding.\n\t\t\t\t\t\t\t\t\t\t\t\t\t// See `updateAttributes` for more details.\n\t\t\t\t\t\t\t\t\t\t\t\t\t`${ unescape(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t\t\t\t) } ${ placeholderText }`.trim()\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</span>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-link__missing_text-tooltip\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ tooltipText }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t\t\t\t</div>\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\tclassName=\"wp-block-navigation-link__inline-link-input\"\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\tonClose={ () => setIsLinkOpen( false ) }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\thasCreateSuggestion={ userCanCreate }\n\t\t\t\t\t\t\tonRemove={ removeLink }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\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</a>\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * External dependencies
@@ -14,7 +14,7 @@ import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
14
14
  import { __ } from '@wordpress/i18n';
15
15
  import { BlockControls, InnerBlocks, useInnerBlocksProps, InspectorControls, RichText, useBlockProps, store as blockEditorStore, getColorClassName } from '@wordpress/block-editor';
16
16
  import { isURL, prependHTTP } from '@wordpress/url';
17
- import { Fragment, useState, useEffect, useRef } from '@wordpress/element';
17
+ import { useState, useEffect, useRef } from '@wordpress/element';
18
18
  import { placeCaretAtHorizontalEdge } from '@wordpress/dom';
19
19
  import { link as linkIcon, removeSubmenu } from '@wordpress/icons';
20
20
  import { useResourcePermissions } from '@wordpress/core-data';
@@ -80,6 +80,7 @@ const {
80
80
  };
81
81
  import { LinkUI } from '../navigation-link/link-ui';
82
82
  import { updateAttributes } from '../navigation-link/update-attributes';
83
+ import { getColors, getNavigationChildBlockProps } from '../navigation/edit/utils';
83
84
  const ALLOWED_BLOCKS = ['core/navigation-link', 'core/navigation-submenu', 'core/page-list'];
84
85
  const DEFAULT_BLOCK = {
85
86
  name: 'core/navigation-link'
@@ -134,63 +135,6 @@ const useIsDraggingWithin = elementRef => {
134
135
  }, []);
135
136
  return isDraggingWithin;
136
137
  };
137
- /**
138
- * Determine the colors for a menu.
139
- *
140
- * Order of priority is:
141
- * 1: Overlay custom colors (if submenu)
142
- * 2: Overlay theme colors (if submenu)
143
- * 3: Custom colors
144
- * 4: Theme colors
145
- * 5: Global styles
146
- *
147
- * @param {Object} context
148
- * @param {boolean} isSubMenu
149
- */
150
-
151
-
152
- function getColors(context, isSubMenu) {
153
- var _style$color, _style$color2;
154
-
155
- const {
156
- textColor,
157
- customTextColor,
158
- backgroundColor,
159
- customBackgroundColor,
160
- overlayTextColor,
161
- customOverlayTextColor,
162
- overlayBackgroundColor,
163
- customOverlayBackgroundColor,
164
- style
165
- } = context;
166
- const colors = {};
167
-
168
- if (isSubMenu && !!customOverlayTextColor) {
169
- colors.customTextColor = customOverlayTextColor;
170
- } else if (isSubMenu && !!overlayTextColor) {
171
- colors.textColor = overlayTextColor;
172
- } else if (!!customTextColor) {
173
- colors.customTextColor = customTextColor;
174
- } else if (!!textColor) {
175
- colors.textColor = textColor;
176
- } else if (!!(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.text)) {
177
- colors.customTextColor = style.color.text;
178
- }
179
-
180
- if (isSubMenu && !!customOverlayBackgroundColor) {
181
- colors.customBackgroundColor = customOverlayBackgroundColor;
182
- } else if (isSubMenu && !!overlayBackgroundColor) {
183
- colors.backgroundColor = overlayBackgroundColor;
184
- } else if (!!customBackgroundColor) {
185
- colors.customBackgroundColor = customBackgroundColor;
186
- } else if (!!backgroundColor) {
187
- colors.backgroundColor = backgroundColor;
188
- } else if (!!(style !== null && style !== void 0 && (_style$color2 = style.color) !== null && _style$color2 !== void 0 && _style$color2.background)) {
189
- colors.customTextColor = style.color.background;
190
- }
191
-
192
- return colors;
193
- }
194
138
  /**
195
139
  * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
196
140
  */
@@ -400,19 +344,8 @@ export default function NavigationSubmenuEdit(_ref) {
400
344
 
401
345
  const innerBlocksColors = getColors(context, true);
402
346
  const allowedBlocks = isAtMaxNesting ? ALLOWED_BLOCKS.filter(blockName => blockName !== 'core/navigation-submenu') : ALLOWED_BLOCKS;
403
- const innerBlocksProps = useInnerBlocksProps({
404
- className: classnames('wp-block-navigation__submenu-container', {
405
- 'is-parent-of-selected-block': isParentOfSelectedBlock,
406
- 'has-text-color': !!(innerBlocksColors.textColor || innerBlocksColors.customTextColor),
407
- [`has-${innerBlocksColors.textColor}-color`]: !!innerBlocksColors.textColor,
408
- 'has-background': !!(innerBlocksColors.backgroundColor || innerBlocksColors.customBackgroundColor),
409
- [`has-${innerBlocksColors.backgroundColor}-background-color`]: !!innerBlocksColors.backgroundColor
410
- }),
411
- style: {
412
- color: innerBlocksColors.customTextColor,
413
- backgroundColor: innerBlocksColors.customBackgroundColor
414
- }
415
- }, {
347
+ const navigationChildBlockProps = getNavigationChildBlockProps(innerBlocksColors);
348
+ const innerBlocksProps = useInnerBlocksProps(navigationChildBlockProps, {
416
349
  allowedBlocks,
417
350
  __experimentalDefaultBlock: DEFAULT_BLOCK,
418
351
  __experimentalDirectInsert: true,
@@ -471,6 +404,7 @@ export default function NavigationSubmenuEdit(_ref) {
471
404
  label: __('URL'),
472
405
  autoComplete: "off"
473
406
  }), createElement(TextareaControl, {
407
+ __nextHasNoMarginBottom: true,
474
408
  value: description || '',
475
409
  onChange: descriptionValue => {
476
410
  setAttributes({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"names":["classnames","useSelect","useDispatch","PanelBody","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","displayShortcut","isKeyboardEvent","__","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","Fragment","useState","useEffect","useRef","placeCaretAtHorizontalEdge","link","linkIcon","removeSubmenu","useResourcePermissions","speak","createBlock","useMergeRefs","usePrevious","ItemSubmenuIcon","LinkUI","updateAttributes","ALLOWED_BLOCKS","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","getColors","context","isSubMenu","textColor","customTextColor","backgroundColor","customBackgroundColor","overlayTextColor","customOverlayTextColor","overlayBackgroundColor","customOverlayBackgroundColor","style","colors","color","text","background","NavigationSubmenuEdit","attributes","isSelected","setAttributes","mergeBlocks","onReplace","clientId","label","type","url","description","rel","title","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","__unstableMarkNextChangeAsNotPersistent","replaceBlock","isLinkOpen","setIsLinkOpen","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","pagesPermissions","postsPermissions","isAtMaxNesting","isTopLevelItem","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasChildren","selectedBlockHasChildren","onlyDescendantIsEmptyLink","select","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","getBlockCount","getBlockOrder","_onlyDescendantIsEmptyLink","selectedBlockId","selectedBlockChildren","length","singleBlock","prevHasChildren","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","userCanCreate","canCreate","onKeyDown","primary","blockProps","className","innerBlocksColors","allowedBlocks","filter","blockName","innerBlocksProps","__experimentalDefaultBlock","__experimentalDirectInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","labelValue","urlValue","descriptionValue","titleValue","relValue","updatedValue"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,SADD,EAECC,WAFD,EAGCC,eAHD,EAICC,aAJD,EAKCC,YALD,QAMO,uBANP;AAOA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,qBAAjD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,aADD,EAECC,WAFD,EAGCC,mBAHD,EAICC,iBAJD,EAKCC,QALD,EAMCC,aAND,EAOCC,KAAK,IAAIC,gBAPV,EAQCC,iBARD,QASO,yBATP;AAUA,SAASC,KAAT,EAAgBC,WAAhB,QAAmC,gBAAnC;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,SAA7B,EAAwCC,MAAxC,QAAsD,oBAAtD;AACA,SAASC,0BAAT,QAA2C,gBAA3C;AACA,SAASC,IAAI,IAAIC,QAAjB,EAA2BC,aAA3B,QAAgD,kBAAhD;AACA,SAASC,sBAAT,QAAuC,sBAAvC;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,EAAuBC,WAAvB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rH,MAAAA,gBAAgB,CACfqH,YADe,EAEfhF,aAFe,EAGfF,UAHe,CAAhB;AAKA;AAjBF,IA9BF,CAFD,EAqDG,CAAEY,eAAe,IAAIE,mBAArB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,eAAD,OADD,CAtDF,EA0DC,qBAAUqD,gBAAV,CA1DD,CAxED,CADD;AAuIA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { Fragment, useState, useEffect, useRef } from '@wordpress/element';\nimport { placeCaretAtHorizontalEdge } from '@wordpress/dom';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { name } from './block.json';\nimport { LinkUI } from '../navigation-link/link-ui';\nimport { updateAttributes } from '../navigation-link/update-attributes';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n];\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/navigation-link',\n};\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * Determine the colors for a menu.\n *\n * Order of priority is:\n * 1: Overlay custom colors (if submenu)\n * 2: Overlay theme colors (if submenu)\n * 3: Custom colors\n * 4: Theme colors\n * 5: Global styles\n *\n * @param {Object} context\n * @param {boolean} isSubMenu\n */\nfunction getColors( context, isSubMenu ) {\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t\toverlayTextColor,\n\t\tcustomOverlayTextColor,\n\t\toverlayBackgroundColor,\n\t\tcustomOverlayBackgroundColor,\n\t\tstyle,\n\t} = context;\n\n\tconst colors = {};\n\n\tif ( isSubMenu && !! customOverlayTextColor ) {\n\t\tcolors.customTextColor = customOverlayTextColor;\n\t} else if ( isSubMenu && !! overlayTextColor ) {\n\t\tcolors.textColor = overlayTextColor;\n\t} else if ( !! customTextColor ) {\n\t\tcolors.customTextColor = customTextColor;\n\t} else if ( !! textColor ) {\n\t\tcolors.textColor = textColor;\n\t} else if ( !! style?.color?.text ) {\n\t\tcolors.customTextColor = style.color.text;\n\t}\n\n\tif ( isSubMenu && !! customOverlayBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customOverlayBackgroundColor;\n\t} else if ( isSubMenu && !! overlayBackgroundColor ) {\n\t\tcolors.backgroundColor = overlayBackgroundColor;\n\t} else if ( !! customBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customBackgroundColor;\n\t} else if ( !! backgroundColor ) {\n\t\tcolors.backgroundColor = backgroundColor;\n\t} else if ( !! style?.color?.background ) {\n\t\tcolors.customTextColor = style.color.background;\n\t}\n\n\treturn colors;\n}\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, type, url, description, rel, title } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\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 text…' );\n\tconst ref = useRef();\n\n\tconst pagesPermissions = useResourcePermissions( 'pages' );\n\tconst postsPermissions = useResourcePermissions( 'posts' );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelItem,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, name ).length >=\n\t\t\t\t\tmaxNestingLevel,\n\t\t\t\tisTopLevelItem:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, name ).length === 0,\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\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t// Store the colors from context as attributes for rendering.\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level as those should\n\t\t// only be created via user interactions. Mark this change as\n\t\t// not persistent to avoid undo level creation.\n\t\t// See https://github.com/WordPress/gutenberg/issues/34564.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { isTopLevelItem } );\n\t}, [ isTopLevelItem ] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t} else {\n\t\t\t\t// Focus it (but do not select).\n\t\t\t\tplaceCaretAtHorizontalEdge( ref.current, true );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\tlet userCanCreate = false;\n\tif ( ! type || type === 'page' ) {\n\t\tuserCanCreate = pagesPermissions.canCreate;\n\t} else if ( type === 'post' ) {\n\t\tuserCanCreate = postsPermissions.canCreate;\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelItem );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: classnames( '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\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\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\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks = isAtMaxNesting\n\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t )\n\t\t: ALLOWED_BLOCKS;\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: classnames( 'wp-block-navigation__submenu-container', {\n\t\t\t\t'is-parent-of-selected-block': isParentOfSelectedBlock,\n\t\t\t\t'has-text-color': !! (\n\t\t\t\t\tinnerBlocksColors.textColor ||\n\t\t\t\t\tinnerBlocksColors.customTextColor\n\t\t\t\t),\n\t\t\t\t[ `has-${ innerBlocksColors.textColor }-color` ]:\n\t\t\t\t\t!! innerBlocksColors.textColor,\n\t\t\t\t'has-background': !! (\n\t\t\t\t\tinnerBlocksColors.backgroundColor ||\n\t\t\t\t\tinnerBlocksColors.customBackgroundColor\n\t\t\t\t),\n\t\t\t\t[ `has-${ innerBlocksColors.backgroundColor }-background-color` ]:\n\t\t\t\t\t!! innerBlocksColors.backgroundColor,\n\t\t\t} ),\n\t\t\tstyle: {\n\t\t\t\tcolor: innerBlocksColors.customTextColor,\n\t\t\t\tbackgroundColor: innerBlocksColors.customBackgroundColor,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tallowedBlocks,\n\t\t\t__experimentalDefaultBlock: DEFAULT_BLOCK,\n\t\t\t__experimentalDirectInsert: true,\n\n\t\t\t// Ensure block toolbar is not too far removed from item\n\t\t\t// being edited.\n\t\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t\t__experimentalCaptureToolbars: true,\n\n\t\t\trenderAppender:\n\t\t\t\tisSelected ||\n\t\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\t\thasChildren\n\t\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t\t: false,\n\t\t}\n\t);\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ () => setIsLinkOpen( true ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tisDisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-link/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ label || '' }\n\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Label' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'URL' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link title' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{\n\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\tallowedFormats={ [\n\t\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\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{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-link__inline-link-input\"\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\tonClose={ () => setIsLinkOpen( false ) }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\thasCreateSuggestion={ userCanCreate }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\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</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</Fragment>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"names":["classnames","useSelect","useDispatch","PanelBody","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","displayShortcut","isKeyboardEvent","__","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","useState","useEffect","useRef","placeCaretAtHorizontalEdge","link","linkIcon","removeSubmenu","useResourcePermissions","speak","createBlock","useMergeRefs","usePrevious","ItemSubmenuIcon","LinkUI","updateAttributes","getColors","getNavigationChildBlockProps","ALLOWED_BLOCKS","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","NavigationSubmenuEdit","attributes","isSelected","setAttributes","mergeBlocks","onReplace","context","clientId","label","type","url","description","rel","title","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","__unstableMarkNextChangeAsNotPersistent","replaceBlock","isLinkOpen","setIsLinkOpen","popoverAnchor","setPopoverAnchor","listItemRef","itemLabelPlaceholder","ref","pagesPermissions","postsPermissions","isAtMaxNesting","isTopLevelItem","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasChildren","selectedBlockHasChildren","onlyDescendantIsEmptyLink","select","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","getBlockCount","getBlockOrder","_onlyDescendantIsEmptyLink","selectedBlockId","selectedBlockChildren","length","singleBlock","prevHasChildren","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","userCanCreate","canCreate","textColor","customTextColor","backgroundColor","customBackgroundColor","onKeyDown","primary","blockProps","className","style","color","innerBlocksColors","allowedBlocks","filter","blockName","navigationChildBlockProps","innerBlocksProps","__experimentalDefaultBlock","__experimentalDirectInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","labelValue","urlValue","descriptionValue","titleValue","relValue","updatedValue"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,SADD,EAECC,WAFD,EAGCC,eAHD,EAICC,aAJD,EAKCC,YALD,QAMO,uBANP;AAOA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,qBAAjD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,aADD,EAECC,WAFD,EAGCC,mBAHD,EAICC,iBAJD,EAKCC,QALD,EAMCC,aAND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AAA,4BAA4B,MAZ7B;AAaC,IAAA,cAAc,EAAG,CAChB,WADgB,EAEhB,aAFgB,EAGhB,YAHgB,EAIhB,oBAJgB,CAblB;AAmBC,IAAA,OAAO,EAAG,MAAM;AACf,UAAK,CAAER,mBAAF,IAAyB,CAAEN,GAAhC,EAAsC;AACrCU,QAAAA,aAAa,CAAE,IAAF,CAAb;AACA;AACD;AAvBF,IAHF,EA6BG,CAAEJ,mBAAF,IAAyBG,UAAzB,IACD,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,QAAQ,EAAGZ,QAFZ;AAGC,IAAA,IAAI,EAAGN,UAHR;AAIC,IAAA,OAAO,EAAG,MAAMmB,aAAa,CAAE,KAAF,CAJ9B;AAKC,IAAA,MAAM,EAAGC,aALV;AAMC,IAAA,mBAAmB,EAAGsC,aANvB;AAOC,IAAA,QAAQ,EAAG,MAAM;AAChBxD,MAAAA,aAAa,CAAE;AAAEO,QAAAA,GAAG,EAAE;AAAP,OAAF,CAAb;AACApC,MAAAA,KAAK,CAAEpB,EAAE,CAAE,eAAF,CAAJ,EAAyB,WAAzB,CAAL;AACA,KAVF;AAWC,IAAA,QAAQ,EAAKyI,YAAF,IAAoB;AAC9B/G,MAAAA,gBAAgB,CACf+G,YADe,EAEfxF,aAFe,EAGfF,UAHe,CAAhB;AAKA;AAjBF,IA9BF,CAFD,EAqDG,CAAEa,eAAe,IAAIE,mBAArB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,eAAD,OADD,CAtDF,EA0DC,qBAAU4D,gBAAV,CA1DD,CAzED,CADD;AAwIA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { placeCaretAtHorizontalEdge } from '@wordpress/dom';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { name } from './block.json';\nimport { LinkUI } from '../navigation-link/link-ui';\nimport { updateAttributes } from '../navigation-link/update-attributes';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n];\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/navigation-link',\n};\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, type, url, description, rel, title } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\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 text…' );\n\tconst ref = useRef();\n\n\tconst pagesPermissions = useResourcePermissions( 'pages' );\n\tconst postsPermissions = useResourcePermissions( 'posts' );\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelItem,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, name ).length >=\n\t\t\t\t\tmaxNestingLevel,\n\t\t\t\tisTopLevelItem:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, name ).length === 0,\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\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t// Store the colors from context as attributes for rendering.\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level as those should\n\t\t// only be created via user interactions. Mark this change as\n\t\t// not persistent to avoid undo level creation.\n\t\t// See https://github.com/WordPress/gutenberg/issues/34564.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { isTopLevelItem } );\n\t}, [ isTopLevelItem ] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t} else {\n\t\t\t\t// Focus it (but do not select).\n\t\t\t\tplaceCaretAtHorizontalEdge( ref.current, true );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\tlet userCanCreate = false;\n\tif ( ! type || type === 'page' ) {\n\t\tuserCanCreate = pagesPermissions.canCreate;\n\t} else if ( type === 'post' ) {\n\t\tuserCanCreate = postsPermissions.canCreate;\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelItem );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: classnames( '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\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\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\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks = isAtMaxNesting\n\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t )\n\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock: DEFAULT_BLOCK,\n\t\t__experimentalDirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\n\t} );\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ () => setIsLinkOpen( true ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tisDisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t{ /* Warning, this duplicated in packages/block-library/src/navigation-link/edit.js */ }\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ label || '' }\n\t\t\t\t\t\tonChange={ ( labelValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { label: labelValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Label' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ url || '' }\n\t\t\t\t\t\tonChange={ ( urlValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { url: urlValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'URL' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link title' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{\n\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\tallowedFormats={ [\n\t\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\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{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<LinkUI\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-link__inline-link-input\"\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\tonClose={ () => setIsLinkOpen( false ) }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\thasCreateSuggestion={ userCanCreate }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\t\tupdateAttributes(\n\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\tattributes\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</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}