@wordpress/block-library 8.0.0 → 8.2.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 (558) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +1 -1
  3. package/build/archives/edit.js +1 -0
  4. package/build/archives/edit.js.map +1 -1
  5. package/build/audio/edit.js +2 -0
  6. package/build/audio/edit.js.map +1 -1
  7. package/build/categories/edit.js +1 -1
  8. package/build/categories/edit.js.map +1 -1
  9. package/build/comments/edit/comments-inspector-controls.js +9 -3
  10. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  11. package/build/cover/edit/inspector-controls.js +1 -1
  12. package/build/cover/edit/inspector-controls.js.map +1 -1
  13. package/build/embed/embed-preview.js +1 -0
  14. package/build/embed/embed-preview.js.map +1 -1
  15. package/build/file/inspector.js +1 -0
  16. package/build/file/inspector.js.map +1 -1
  17. package/build/freeform/edit.js +21 -6
  18. package/build/freeform/edit.js.map +1 -1
  19. package/build/freeform/modal.js +97 -0
  20. package/build/freeform/modal.js.map +1 -0
  21. package/build/gallery/edit.js +15 -2
  22. package/build/gallery/edit.js.map +1 -1
  23. package/build/gallery/gallery.js +3 -16
  24. package/build/gallery/gallery.js.map +1 -1
  25. package/build/gallery/v1/edit.js +2 -0
  26. package/build/gallery/v1/edit.js.map +1 -1
  27. package/build/group/edit.js +1 -0
  28. package/build/group/edit.js.map +1 -1
  29. package/build/group/index.js +3 -0
  30. package/build/group/index.js.map +1 -1
  31. package/build/image/image.js +7 -10
  32. package/build/image/image.js.map +1 -1
  33. package/build/latest-posts/edit.js +11 -8
  34. package/build/latest-posts/edit.js.map +1 -1
  35. package/build/media-text/edit.js +1 -0
  36. package/build/media-text/edit.js.map +1 -1
  37. package/build/missing/edit.native.js +2 -2
  38. package/build/missing/edit.native.js.map +1 -1
  39. package/build/navigation/edit/index.js +9 -7
  40. package/build/navigation/edit/index.js.map +1 -1
  41. package/build/navigation/edit/menu-inspector-controls.js +81 -22
  42. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  43. package/build/navigation/edit/navigation-menu-selector.js +15 -10
  44. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  45. package/build/navigation/edit/utils.js +81 -0
  46. package/build/navigation/edit/utils.js.map +1 -1
  47. package/build/navigation/leaf-more-menu.js +95 -0
  48. package/build/navigation/leaf-more-menu.js.map +1 -0
  49. package/build/navigation-link/edit.js +10 -61
  50. package/build/navigation-link/edit.js.map +1 -1
  51. package/build/navigation-link/update-attributes.js +3 -3
  52. package/build/navigation-link/update-attributes.js.map +1 -1
  53. package/build/navigation-submenu/edit.js +7 -72
  54. package/build/navigation-submenu/edit.js.map +1 -1
  55. package/build/page-list/edit.js +16 -15
  56. package/build/page-list/edit.js.map +1 -1
  57. package/build/page-list/index.js +29 -2
  58. package/build/page-list/index.js.map +1 -1
  59. package/build/page-list-item/edit.js +9 -5
  60. package/build/page-list-item/edit.js.map +1 -1
  61. package/build/page-list-item/index.js +2 -1
  62. package/build/page-list-item/index.js.map +1 -1
  63. package/build/post-author/edit.js +2 -0
  64. package/build/post-author/edit.js.map +1 -1
  65. package/build/post-featured-image/dimension-controls.js +1 -0
  66. package/build/post-featured-image/dimension-controls.js.map +1 -1
  67. package/build/post-featured-image/overlay.js +0 -1
  68. package/build/post-featured-image/overlay.js.map +1 -1
  69. package/build/query/edit/index.js +2 -1
  70. package/build/query/edit/index.js.map +1 -1
  71. package/build/query/edit/inspector-controls/index.js +11 -5
  72. package/build/query/edit/inspector-controls/index.js.map +1 -1
  73. package/build/query/edit/inspector-controls/order-control.js +1 -0
  74. package/build/query/edit/inspector-controls/order-control.js.map +1 -1
  75. package/build/query/edit/inspector-controls/sticky-control.js +1 -0
  76. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -1
  77. package/build/query/edit/inspector-controls/taxonomy-controls.js +101 -37
  78. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  79. package/build/query/edit/query-content.js +10 -4
  80. package/build/query/edit/query-content.js.map +1 -1
  81. package/build/query/edit/query-placeholder.js +17 -12
  82. package/build/query/edit/query-placeholder.js.map +1 -1
  83. package/build/query/utils.js +73 -1
  84. package/build/query/utils.js.map +1 -1
  85. package/build/search/edit.js +2 -2
  86. package/build/search/edit.js.map +1 -1
  87. package/build/social-link/edit.js +2 -1
  88. package/build/social-link/edit.js.map +1 -1
  89. package/build/social-links/edit.js +0 -1
  90. package/build/social-links/edit.js.map +1 -1
  91. package/build/table/edit.js +1 -0
  92. package/build/table/edit.js.map +1 -1
  93. package/build/table-of-contents/edit.js +1 -1
  94. package/build/table-of-contents/edit.js.map +1 -1
  95. package/build/tag-cloud/edit.js +1 -0
  96. package/build/tag-cloud/edit.js.map +1 -1
  97. package/build/template-part/edit/advanced-controls.js +23 -2
  98. package/build/template-part/edit/advanced-controls.js.map +1 -1
  99. package/build/template-part/edit/import-controls.js +160 -0
  100. package/build/template-part/edit/import-controls.js.map +1 -0
  101. package/build/template-part/edit/index.js +2 -1
  102. package/build/template-part/edit/index.js.map +1 -1
  103. package/build/template-part/edit/utils/transformers.js +48 -0
  104. package/build/template-part/edit/utils/transformers.js.map +1 -0
  105. package/build/video/edit-common-settings.js +6 -5
  106. package/build/video/edit-common-settings.js.map +1 -1
  107. package/build/video/edit.js +1 -0
  108. package/build/video/edit.js.map +1 -1
  109. package/build/video/tracks-editor.js +1 -0
  110. package/build/video/tracks-editor.js.map +1 -1
  111. package/build-module/archives/edit.js +1 -0
  112. package/build-module/archives/edit.js.map +1 -1
  113. package/build-module/audio/edit.js +2 -0
  114. package/build-module/audio/edit.js.map +1 -1
  115. package/build-module/categories/edit.js +1 -1
  116. package/build-module/categories/edit.js.map +1 -1
  117. package/build-module/comments/edit/comments-inspector-controls.js +9 -3
  118. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  119. package/build-module/cover/edit/inspector-controls.js +3 -3
  120. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  121. package/build-module/embed/embed-preview.js +1 -0
  122. package/build-module/embed/embed-preview.js.map +1 -1
  123. package/build-module/file/inspector.js +1 -0
  124. package/build-module/file/inspector.js.map +1 -1
  125. package/build-module/freeform/edit.js +22 -8
  126. package/build-module/freeform/edit.js.map +1 -1
  127. package/build-module/freeform/modal.js +90 -0
  128. package/build-module/freeform/modal.js.map +1 -0
  129. package/build-module/gallery/edit.js +16 -3
  130. package/build-module/gallery/edit.js.map +1 -1
  131. package/build-module/gallery/gallery.js +4 -16
  132. package/build-module/gallery/gallery.js.map +1 -1
  133. package/build-module/gallery/v1/edit.js +2 -0
  134. package/build-module/gallery/v1/edit.js.map +1 -1
  135. package/build-module/group/edit.js +1 -0
  136. package/build-module/group/edit.js.map +1 -1
  137. package/build-module/group/index.js +3 -0
  138. package/build-module/group/index.js.map +1 -1
  139. package/build-module/image/image.js +7 -10
  140. package/build-module/image/image.js.map +1 -1
  141. package/build-module/latest-posts/edit.js +12 -9
  142. package/build-module/latest-posts/edit.js.map +1 -1
  143. package/build-module/media-text/edit.js +1 -0
  144. package/build-module/media-text/edit.js.map +1 -1
  145. package/build-module/missing/edit.native.js +2 -2
  146. package/build-module/missing/edit.native.js.map +1 -1
  147. package/build-module/navigation/edit/index.js +9 -7
  148. package/build-module/navigation/edit/index.js.map +1 -1
  149. package/build-module/navigation/edit/menu-inspector-controls.js +80 -25
  150. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  151. package/build-module/navigation/edit/navigation-menu-selector.js +16 -11
  152. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  153. package/build-module/navigation/edit/utils.js +75 -0
  154. package/build-module/navigation/edit/utils.js.map +1 -1
  155. package/build-module/navigation/leaf-more-menu.js +76 -0
  156. package/build-module/navigation/leaf-more-menu.js.map +1 -0
  157. package/build-module/navigation-link/edit.js +10 -62
  158. package/build-module/navigation-link/edit.js.map +1 -1
  159. package/build-module/navigation-link/update-attributes.js +3 -3
  160. package/build-module/navigation-link/update-attributes.js.map +1 -1
  161. package/build-module/navigation-submenu/edit.js +6 -72
  162. package/build-module/navigation-submenu/edit.js.map +1 -1
  163. package/build-module/page-list/edit.js +17 -15
  164. package/build-module/page-list/edit.js.map +1 -1
  165. package/build-module/page-list/index.js +30 -3
  166. package/build-module/page-list/index.js.map +1 -1
  167. package/build-module/page-list-item/edit.js +9 -6
  168. package/build-module/page-list-item/edit.js.map +1 -1
  169. package/build-module/page-list-item/index.js +2 -1
  170. package/build-module/page-list-item/index.js.map +1 -1
  171. package/build-module/post-author/edit.js +2 -0
  172. package/build-module/post-author/edit.js.map +1 -1
  173. package/build-module/post-featured-image/dimension-controls.js +1 -0
  174. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  175. package/build-module/post-featured-image/overlay.js +0 -1
  176. package/build-module/post-featured-image/overlay.js.map +1 -1
  177. package/build-module/query/edit/index.js +2 -1
  178. package/build-module/query/edit/index.js.map +1 -1
  179. package/build-module/query/edit/inspector-controls/index.js +11 -5
  180. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  181. package/build-module/query/edit/inspector-controls/order-control.js +1 -0
  182. package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
  183. package/build-module/query/edit/inspector-controls/sticky-control.js +1 -0
  184. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -1
  185. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +99 -35
  186. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  187. package/build-module/query/edit/query-content.js +9 -2
  188. package/build-module/query/edit/query-content.js.map +1 -1
  189. package/build-module/query/edit/query-placeholder.js +16 -12
  190. package/build-module/query/edit/query-placeholder.js.map +1 -1
  191. package/build-module/query/utils.js +69 -0
  192. package/build-module/query/utils.js.map +1 -1
  193. package/build-module/search/edit.js +2 -2
  194. package/build-module/search/edit.js.map +1 -1
  195. package/build-module/social-link/edit.js +4 -3
  196. package/build-module/social-link/edit.js.map +1 -1
  197. package/build-module/social-links/edit.js +0 -1
  198. package/build-module/social-links/edit.js.map +1 -1
  199. package/build-module/table/edit.js +1 -0
  200. package/build-module/table/edit.js.map +1 -1
  201. package/build-module/table-of-contents/edit.js +1 -1
  202. package/build-module/table-of-contents/edit.js.map +1 -1
  203. package/build-module/tag-cloud/edit.js +1 -0
  204. package/build-module/tag-cloud/edit.js.map +1 -1
  205. package/build-module/template-part/edit/advanced-controls.js +22 -2
  206. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  207. package/build-module/template-part/edit/import-controls.js +146 -0
  208. package/build-module/template-part/edit/import-controls.js.map +1 -0
  209. package/build-module/template-part/edit/index.js +2 -1
  210. package/build-module/template-part/edit/index.js.map +1 -1
  211. package/build-module/template-part/edit/utils/transformers.js +40 -0
  212. package/build-module/template-part/edit/utils/transformers.js.map +1 -0
  213. package/build-module/video/edit-common-settings.js +6 -5
  214. package/build-module/video/edit-common-settings.js.map +1 -1
  215. package/build-module/video/edit.js +1 -0
  216. package/build-module/video/edit.js.map +1 -1
  217. package/build-module/video/tracks-editor.js +1 -0
  218. package/build-module/video/tracks-editor.js.map +1 -1
  219. package/build-style/archives/editor-rtl.css +3 -3
  220. package/build-style/archives/editor.css +3 -3
  221. package/build-style/archives/style-rtl.css +3 -3
  222. package/build-style/archives/style.css +3 -3
  223. package/build-style/audio/editor-rtl.css +3 -3
  224. package/build-style/audio/editor.css +3 -3
  225. package/build-style/audio/style-rtl.css +3 -3
  226. package/build-style/audio/style.css +3 -3
  227. package/build-style/audio/theme-rtl.css +3 -3
  228. package/build-style/audio/theme.css +3 -3
  229. package/build-style/avatar/editor-rtl.css +3 -3
  230. package/build-style/avatar/editor.css +3 -3
  231. package/build-style/avatar/style-rtl.css +3 -3
  232. package/build-style/avatar/style.css +3 -3
  233. package/build-style/block/editor-rtl.css +3 -3
  234. package/build-style/block/editor.css +3 -3
  235. package/build-style/button/editor-rtl.css +3 -3
  236. package/build-style/button/editor.css +3 -3
  237. package/build-style/button/style-rtl.css +3 -3
  238. package/build-style/button/style.css +3 -3
  239. package/build-style/buttons/editor-rtl.css +3 -3
  240. package/build-style/buttons/editor.css +3 -3
  241. package/build-style/buttons/style-rtl.css +3 -3
  242. package/build-style/buttons/style.css +3 -3
  243. package/build-style/calendar/style-rtl.css +3 -3
  244. package/build-style/calendar/style.css +3 -3
  245. package/build-style/categories/editor-rtl.css +3 -3
  246. package/build-style/categories/editor.css +3 -3
  247. package/build-style/categories/style-rtl.css +3 -3
  248. package/build-style/categories/style.css +3 -3
  249. package/build-style/classic-rtl.css +3 -3
  250. package/build-style/classic.css +3 -3
  251. package/build-style/code/editor-rtl.css +3 -3
  252. package/build-style/code/editor.css +3 -3
  253. package/build-style/code/style-rtl.css +3 -3
  254. package/build-style/code/style.css +3 -3
  255. package/build-style/code/theme-rtl.css +3 -3
  256. package/build-style/code/theme.css +3 -3
  257. package/build-style/columns/editor-rtl.css +3 -3
  258. package/build-style/columns/editor.css +3 -3
  259. package/build-style/columns/style-rtl.css +3 -3
  260. package/build-style/columns/style.css +3 -3
  261. package/build-style/comment-author-avatar/editor-rtl.css +3 -3
  262. package/build-style/comment-author-avatar/editor.css +3 -3
  263. package/build-style/comment-content/style-rtl.css +3 -3
  264. package/build-style/comment-content/style.css +3 -3
  265. package/build-style/comment-template/style-rtl.css +3 -3
  266. package/build-style/comment-template/style.css +3 -3
  267. package/build-style/comments/editor-rtl.css +3 -3
  268. package/build-style/comments/editor.css +3 -3
  269. package/build-style/comments/style-rtl.css +3 -3
  270. package/build-style/comments/style.css +3 -3
  271. package/build-style/comments-pagination/editor-rtl.css +3 -3
  272. package/build-style/comments-pagination/editor.css +3 -3
  273. package/build-style/comments-pagination/style-rtl.css +3 -3
  274. package/build-style/comments-pagination/style.css +3 -3
  275. package/build-style/comments-pagination-numbers/editor-rtl.css +3 -3
  276. package/build-style/comments-pagination-numbers/editor.css +3 -3
  277. package/build-style/comments-title/editor-rtl.css +3 -3
  278. package/build-style/comments-title/editor.css +3 -3
  279. package/build-style/common-rtl.css +3 -3
  280. package/build-style/common.css +3 -3
  281. package/build-style/cover/editor-rtl.css +3 -3
  282. package/build-style/cover/editor.css +3 -3
  283. package/build-style/cover/style-rtl.css +3 -3
  284. package/build-style/cover/style.css +3 -3
  285. package/build-style/editor-elements-rtl.css +3 -3
  286. package/build-style/editor-elements.css +3 -3
  287. package/build-style/editor-rtl.css +7 -9
  288. package/build-style/editor.css +7 -9
  289. package/build-style/elements-rtl.css +3 -3
  290. package/build-style/elements.css +3 -3
  291. package/build-style/embed/editor-rtl.css +3 -3
  292. package/build-style/embed/editor.css +3 -3
  293. package/build-style/embed/style-rtl.css +3 -3
  294. package/build-style/embed/style.css +3 -3
  295. package/build-style/embed/theme-rtl.css +3 -3
  296. package/build-style/embed/theme.css +3 -3
  297. package/build-style/file/editor-rtl.css +3 -3
  298. package/build-style/file/editor.css +3 -3
  299. package/build-style/file/style-rtl.css +3 -3
  300. package/build-style/file/style.css +3 -3
  301. package/build-style/freeform/editor-rtl.css +3 -3
  302. package/build-style/freeform/editor.css +3 -3
  303. package/build-style/gallery/editor-rtl.css +3 -3
  304. package/build-style/gallery/editor.css +3 -3
  305. package/build-style/gallery/style-rtl.css +3 -3
  306. package/build-style/gallery/style.css +3 -3
  307. package/build-style/gallery/theme-rtl.css +3 -3
  308. package/build-style/gallery/theme.css +3 -3
  309. package/build-style/group/editor-rtl.css +3 -3
  310. package/build-style/group/editor.css +3 -3
  311. package/build-style/group/style-rtl.css +3 -3
  312. package/build-style/group/style.css +3 -3
  313. package/build-style/group/theme-rtl.css +3 -3
  314. package/build-style/group/theme.css +3 -3
  315. package/build-style/heading/style-rtl.css +3 -3
  316. package/build-style/heading/style.css +3 -3
  317. package/build-style/html/editor-rtl.css +3 -3
  318. package/build-style/html/editor.css +3 -3
  319. package/build-style/image/editor-rtl.css +3 -3
  320. package/build-style/image/editor.css +3 -3
  321. package/build-style/image/style-rtl.css +3 -3
  322. package/build-style/image/style.css +3 -3
  323. package/build-style/image/theme-rtl.css +3 -3
  324. package/build-style/image/theme.css +3 -3
  325. package/build-style/latest-comments/style-rtl.css +3 -3
  326. package/build-style/latest-comments/style.css +3 -3
  327. package/build-style/latest-posts/editor-rtl.css +3 -3
  328. package/build-style/latest-posts/editor.css +3 -3
  329. package/build-style/latest-posts/style-rtl.css +3 -3
  330. package/build-style/latest-posts/style.css +3 -3
  331. package/build-style/list/style-rtl.css +3 -3
  332. package/build-style/list/style.css +3 -3
  333. package/build-style/media-text/editor-rtl.css +3 -3
  334. package/build-style/media-text/editor.css +3 -3
  335. package/build-style/media-text/style-rtl.css +3 -3
  336. package/build-style/media-text/style.css +3 -3
  337. package/build-style/more/editor-rtl.css +3 -3
  338. package/build-style/more/editor.css +3 -3
  339. package/build-style/navigation/editor-rtl.css +3 -9
  340. package/build-style/navigation/editor.css +3 -9
  341. package/build-style/navigation/style-rtl.css +3 -4
  342. package/build-style/navigation/style.css +3 -4
  343. package/build-style/navigation-link/editor-rtl.css +3 -3
  344. package/build-style/navigation-link/editor.css +3 -3
  345. package/build-style/navigation-link/style-rtl.css +3 -3
  346. package/build-style/navigation-link/style.css +3 -3
  347. package/build-style/navigation-submenu/editor-rtl.css +3 -3
  348. package/build-style/navigation-submenu/editor.css +3 -3
  349. package/build-style/nextpage/editor-rtl.css +3 -3
  350. package/build-style/nextpage/editor.css +3 -3
  351. package/build-style/page-list/editor-rtl.css +7 -3
  352. package/build-style/page-list/editor.css +7 -3
  353. package/build-style/page-list/style-rtl.css +3 -3
  354. package/build-style/page-list/style.css +3 -3
  355. package/build-style/paragraph/editor-rtl.css +3 -3
  356. package/build-style/paragraph/editor.css +3 -3
  357. package/build-style/paragraph/style-rtl.css +3 -3
  358. package/build-style/paragraph/style.css +3 -3
  359. package/build-style/post-author/style-rtl.css +3 -3
  360. package/build-style/post-author/style.css +3 -3
  361. package/build-style/post-comments-form/editor-rtl.css +3 -3
  362. package/build-style/post-comments-form/editor.css +3 -3
  363. package/build-style/post-comments-form/style-rtl.css +3 -3
  364. package/build-style/post-comments-form/style.css +3 -3
  365. package/build-style/post-date/style-rtl.css +3 -3
  366. package/build-style/post-date/style.css +3 -3
  367. package/build-style/post-excerpt/editor-rtl.css +3 -3
  368. package/build-style/post-excerpt/editor.css +3 -3
  369. package/build-style/post-excerpt/style-rtl.css +3 -3
  370. package/build-style/post-excerpt/style.css +3 -3
  371. package/build-style/post-featured-image/editor-rtl.css +3 -3
  372. package/build-style/post-featured-image/editor.css +3 -3
  373. package/build-style/post-featured-image/style-rtl.css +3 -3
  374. package/build-style/post-featured-image/style.css +3 -3
  375. package/build-style/post-navigation-link/style-rtl.css +3 -3
  376. package/build-style/post-navigation-link/style.css +3 -3
  377. package/build-style/post-template/editor-rtl.css +3 -3
  378. package/build-style/post-template/editor.css +3 -3
  379. package/build-style/post-template/style-rtl.css +3 -3
  380. package/build-style/post-template/style.css +3 -3
  381. package/build-style/post-terms/style-rtl.css +3 -3
  382. package/build-style/post-terms/style.css +3 -3
  383. package/build-style/post-title/style-rtl.css +3 -3
  384. package/build-style/post-title/style.css +3 -3
  385. package/build-style/preformatted/style-rtl.css +3 -3
  386. package/build-style/preformatted/style.css +3 -3
  387. package/build-style/pullquote/editor-rtl.css +3 -3
  388. package/build-style/pullquote/editor.css +3 -3
  389. package/build-style/pullquote/style-rtl.css +3 -3
  390. package/build-style/pullquote/style.css +3 -3
  391. package/build-style/pullquote/theme-rtl.css +3 -3
  392. package/build-style/pullquote/theme.css +3 -3
  393. package/build-style/query/editor-rtl.css +3 -3
  394. package/build-style/query/editor.css +3 -3
  395. package/build-style/query-pagination/editor-rtl.css +3 -3
  396. package/build-style/query-pagination/editor.css +3 -3
  397. package/build-style/query-pagination/style-rtl.css +3 -3
  398. package/build-style/query-pagination/style.css +3 -3
  399. package/build-style/query-pagination-numbers/editor-rtl.css +3 -3
  400. package/build-style/query-pagination-numbers/editor.css +3 -3
  401. package/build-style/query-title/style-rtl.css +3 -3
  402. package/build-style/query-title/style.css +3 -3
  403. package/build-style/quote/style-rtl.css +3 -3
  404. package/build-style/quote/style.css +3 -3
  405. package/build-style/quote/theme-rtl.css +3 -3
  406. package/build-style/quote/theme.css +3 -3
  407. package/build-style/read-more/style-rtl.css +3 -3
  408. package/build-style/read-more/style.css +3 -3
  409. package/build-style/reset-rtl.css +3 -3
  410. package/build-style/reset.css +3 -3
  411. package/build-style/rss/editor-rtl.css +3 -3
  412. package/build-style/rss/editor.css +3 -3
  413. package/build-style/rss/style-rtl.css +3 -3
  414. package/build-style/rss/style.css +3 -3
  415. package/build-style/search/editor-rtl.css +3 -3
  416. package/build-style/search/editor.css +3 -3
  417. package/build-style/search/style-rtl.css +3 -3
  418. package/build-style/search/style.css +3 -3
  419. package/build-style/search/theme-rtl.css +3 -3
  420. package/build-style/search/theme.css +3 -3
  421. package/build-style/separator/editor-rtl.css +3 -3
  422. package/build-style/separator/editor.css +3 -3
  423. package/build-style/separator/style-rtl.css +3 -3
  424. package/build-style/separator/style.css +3 -3
  425. package/build-style/separator/theme-rtl.css +3 -3
  426. package/build-style/separator/theme.css +3 -3
  427. package/build-style/shortcode/editor-rtl.css +3 -3
  428. package/build-style/shortcode/editor.css +3 -3
  429. package/build-style/site-logo/editor-rtl.css +3 -3
  430. package/build-style/site-logo/editor.css +3 -3
  431. package/build-style/site-logo/style-rtl.css +3 -3
  432. package/build-style/site-logo/style.css +3 -3
  433. package/build-style/site-tagline/editor-rtl.css +3 -3
  434. package/build-style/site-tagline/editor.css +3 -3
  435. package/build-style/site-title/editor-rtl.css +3 -3
  436. package/build-style/site-title/editor.css +3 -3
  437. package/build-style/site-title/style-rtl.css +3 -3
  438. package/build-style/site-title/style.css +3 -3
  439. package/build-style/social-link/editor-rtl.css +3 -3
  440. package/build-style/social-link/editor.css +3 -3
  441. package/build-style/social-links/editor-rtl.css +3 -3
  442. package/build-style/social-links/editor.css +3 -3
  443. package/build-style/social-links/style-rtl.css +3 -3
  444. package/build-style/social-links/style.css +3 -3
  445. package/build-style/spacer/editor-rtl.css +3 -3
  446. package/build-style/spacer/editor.css +3 -3
  447. package/build-style/spacer/style-rtl.css +3 -3
  448. package/build-style/spacer/style.css +3 -3
  449. package/build-style/style-rtl.css +13 -5
  450. package/build-style/style.css +13 -5
  451. package/build-style/table/editor-rtl.css +3 -3
  452. package/build-style/table/editor.css +3 -3
  453. package/build-style/table/style-rtl.css +9 -3
  454. package/build-style/table/style.css +9 -3
  455. package/build-style/table/theme-rtl.css +3 -9
  456. package/build-style/table/theme.css +3 -9
  457. package/build-style/tag-cloud/style-rtl.css +3 -3
  458. package/build-style/tag-cloud/style.css +3 -3
  459. package/build-style/template-part/editor-rtl.css +3 -3
  460. package/build-style/template-part/editor.css +3 -3
  461. package/build-style/template-part/theme-rtl.css +3 -3
  462. package/build-style/template-part/theme.css +3 -3
  463. package/build-style/text-columns/editor-rtl.css +3 -3
  464. package/build-style/text-columns/editor.css +3 -3
  465. package/build-style/text-columns/style-rtl.css +3 -3
  466. package/build-style/text-columns/style.css +3 -3
  467. package/build-style/theme-rtl.css +3 -9
  468. package/build-style/theme.css +3 -9
  469. package/build-style/verse/style-rtl.css +7 -4
  470. package/build-style/verse/style.css +7 -4
  471. package/build-style/video/editor-rtl.css +3 -3
  472. package/build-style/video/editor.css +3 -3
  473. package/build-style/video/style-rtl.css +3 -3
  474. package/build-style/video/style.css +3 -3
  475. package/build-style/video/theme-rtl.css +3 -3
  476. package/build-style/video/theme.css +3 -3
  477. package/package.json +29 -29
  478. package/src/archives/edit.js +1 -0
  479. package/src/audio/edit.js +2 -0
  480. package/src/categories/edit.js +1 -1
  481. package/src/comments/edit/comments-inspector-controls.js +12 -2
  482. package/src/comments/index.php +0 -1
  483. package/src/cover/edit/inspector-controls.js +4 -4
  484. package/src/embed/embed-preview.js +1 -0
  485. package/src/file/inspector.js +1 -0
  486. package/src/freeform/edit.js +48 -29
  487. package/src/freeform/modal.js +111 -0
  488. package/src/gallery/edit.js +19 -2
  489. package/src/gallery/gallery.js +4 -13
  490. package/src/gallery/v1/edit.js +2 -0
  491. package/src/group/block.json +3 -0
  492. package/src/group/edit.js +1 -0
  493. package/src/image/image.js +27 -36
  494. package/src/latest-posts/edit.js +6 -7
  495. package/src/latest-posts/test/__snapshots__/edit.native.js.snap +3 -0
  496. package/src/latest-posts/test/edit.native.js +49 -0
  497. package/src/media-text/edit.js +1 -0
  498. package/src/missing/edit.native.js +13 -6
  499. package/src/more/test/__snapshots__/edit.native.js.snap +7 -0
  500. package/src/more/test/edit.native.js +41 -0
  501. package/src/navigation/edit/index.js +6 -4
  502. package/src/navigation/edit/menu-inspector-controls.js +115 -44
  503. package/src/navigation/edit/navigation-menu-selector.js +24 -11
  504. package/src/navigation/edit/utils.js +82 -0
  505. package/src/navigation/editor.scss +0 -7
  506. package/src/navigation/index.php +32 -0
  507. package/src/navigation/leaf-more-menu.js +93 -0
  508. package/src/navigation/style.scss +0 -1
  509. package/src/navigation-link/edit.js +23 -65
  510. package/src/navigation-link/index.php +62 -3
  511. package/src/navigation-link/update-attributes.js +1 -1
  512. package/src/navigation-submenu/edit.js +29 -100
  513. package/src/navigation-submenu/index.php +34 -2
  514. package/src/page-list/block.json +18 -1
  515. package/src/page-list/edit.js +30 -22
  516. package/src/page-list/editor.scss +4 -0
  517. package/src/page-list/index.js +8 -2
  518. package/src/page-list/index.php +14 -10
  519. package/src/page-list-item/block.json +2 -1
  520. package/src/page-list-item/edit.js +17 -9
  521. package/src/post-author/edit.js +2 -0
  522. package/src/post-featured-image/dimension-controls.js +1 -0
  523. package/src/post-featured-image/overlay.js +0 -1
  524. package/src/query/edit/index.js +1 -0
  525. package/src/query/edit/inspector-controls/index.js +50 -38
  526. package/src/query/edit/inspector-controls/order-control.js +1 -0
  527. package/src/query/edit/inspector-controls/sticky-control.js +1 -0
  528. package/src/query/edit/inspector-controls/taxonomy-controls.js +102 -38
  529. package/src/query/edit/query-content.js +15 -1
  530. package/src/query/edit/query-placeholder.js +15 -14
  531. package/src/query/utils.js +59 -1
  532. package/src/rss/index.php +1 -1
  533. package/src/search/edit.js +2 -2
  534. package/src/separator/test/__snapshots__/edit.native.js.snap +7 -0
  535. package/src/separator/test/edit.native.js +41 -0
  536. package/src/social-link/edit.js +5 -4
  537. package/src/social-links/edit.js +0 -1
  538. package/src/table/edit.js +1 -0
  539. package/src/table/style.scss +8 -0
  540. package/src/table/theme.scss +0 -8
  541. package/src/table-of-contents/edit.js +1 -1
  542. package/src/tag-cloud/edit.js +1 -0
  543. package/src/template-part/edit/advanced-controls.js +36 -0
  544. package/src/template-part/edit/import-controls.js +180 -0
  545. package/src/template-part/edit/index.js +1 -0
  546. package/src/template-part/edit/utils/transformers.js +37 -0
  547. package/src/verse/style.scss +4 -1
  548. package/src/verse/test/__snapshots__/edit.native.js.snap +13 -0
  549. package/src/verse/test/edit.native.js +40 -33
  550. package/src/video/edit-common-settings.js +6 -5
  551. package/src/video/edit.js +1 -0
  552. package/src/video/tracks-editor.js +1 -0
  553. package/tsconfig.tsbuildinfo +1 -1
  554. package/build/query/constants.js +0 -16
  555. package/build/query/constants.js.map +0 -1
  556. package/build-module/query/constants.js +0 -7
  557. package/build-module/query/constants.js.map +0 -1
  558. package/src/query/constants.js +0 -7
@@ -1,10 +1,19 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.detectColors = detectColors;
9
+ exports.getColors = getColors;
10
+ exports.getNavigationChildBlockProps = getNavigationChildBlockProps;
11
+
12
+ var _classnames = _interopRequireDefault(require("classnames"));
7
13
 
14
+ /**
15
+ * External dependencies
16
+ */
8
17
  function getComputedStyle(node) {
9
18
  return node.ownerDocument.defaultView.getComputedStyle(node);
10
19
  }
@@ -25,4 +34,76 @@ function detectColors(colorsDetectionElement, setColor, setBackground) {
25
34
 
26
35
  setBackground(backgroundColor);
27
36
  }
37
+ /**
38
+ * Determine the colors for a menu.
39
+ *
40
+ * Order of priority is:
41
+ * 1: Overlay custom colors (if submenu)
42
+ * 2: Overlay theme colors (if submenu)
43
+ * 3: Custom colors
44
+ * 4: Theme colors
45
+ * 5: Global styles
46
+ *
47
+ * @param {Object} context
48
+ * @param {boolean} isSubMenu
49
+ */
50
+
51
+
52
+ function getColors(context, isSubMenu) {
53
+ var _style$color, _style$color2;
54
+
55
+ const {
56
+ textColor,
57
+ customTextColor,
58
+ backgroundColor,
59
+ customBackgroundColor,
60
+ overlayTextColor,
61
+ customOverlayTextColor,
62
+ overlayBackgroundColor,
63
+ customOverlayBackgroundColor,
64
+ style
65
+ } = context;
66
+ const colors = {};
67
+
68
+ if (isSubMenu && !!customOverlayTextColor) {
69
+ colors.customTextColor = customOverlayTextColor;
70
+ } else if (isSubMenu && !!overlayTextColor) {
71
+ colors.textColor = overlayTextColor;
72
+ } else if (!!customTextColor) {
73
+ colors.customTextColor = customTextColor;
74
+ } else if (!!textColor) {
75
+ colors.textColor = textColor;
76
+ } else if (!!(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.text)) {
77
+ colors.customTextColor = style.color.text;
78
+ }
79
+
80
+ if (isSubMenu && !!customOverlayBackgroundColor) {
81
+ colors.customBackgroundColor = customOverlayBackgroundColor;
82
+ } else if (isSubMenu && !!overlayBackgroundColor) {
83
+ colors.backgroundColor = overlayBackgroundColor;
84
+ } else if (!!customBackgroundColor) {
85
+ colors.customBackgroundColor = customBackgroundColor;
86
+ } else if (!!backgroundColor) {
87
+ colors.backgroundColor = backgroundColor;
88
+ } else if (!!(style !== null && style !== void 0 && (_style$color2 = style.color) !== null && _style$color2 !== void 0 && _style$color2.background)) {
89
+ colors.customTextColor = style.color.background;
90
+ }
91
+
92
+ return colors;
93
+ }
94
+
95
+ function getNavigationChildBlockProps(innerBlocksColors) {
96
+ return {
97
+ className: (0, _classnames.default)('wp-block-navigation__submenu-container', {
98
+ 'has-text-color': !!(innerBlocksColors.textColor || innerBlocksColors.customTextColor),
99
+ [`has-${innerBlocksColors.textColor}-color`]: !!innerBlocksColors.textColor,
100
+ 'has-background': !!(innerBlocksColors.backgroundColor || innerBlocksColors.customBackgroundColor),
101
+ [`has-${innerBlocksColors.backgroundColor}-background-color`]: !!innerBlocksColors.backgroundColor
102
+ }),
103
+ style: {
104
+ color: innerBlocksColors.customTextColor,
105
+ backgroundColor: innerBlocksColors.customBackgroundColor
106
+ }
107
+ };
108
+ }
28
109
  //# sourceMappingURL=utils.js.map
@@ -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;;AAEM,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":["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":";;;;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,SAASA,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,CAACC,aAAL,CAAmBC,WAAnB,CAA+BH,gBAA/B,CAAiDC,IAAjD,CAAP;AACA;;AAEM,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,gBAA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AA,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"]}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.LeafMoreMenu = void 0;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _blocks = require("@wordpress/blocks");
15
+
16
+ var _icons = require("@wordpress/icons");
17
+
18
+ var _components = require("@wordpress/components");
19
+
20
+ var _data = require("@wordpress/data");
21
+
22
+ var _blockEditor = require("@wordpress/block-editor");
23
+
24
+ var _i18n = require("@wordpress/i18n");
25
+
26
+ /**
27
+ * WordPress dependencies
28
+ */
29
+ const POPOVER_PROPS = {
30
+ className: 'block-editor-block-settings-menu__popover',
31
+ position: 'bottom right',
32
+ variant: 'toolbar'
33
+ };
34
+
35
+ const LeafMoreMenu = props => {
36
+ const {
37
+ clientId,
38
+ block
39
+ } = props;
40
+ const {
41
+ insertBlock,
42
+ replaceBlock,
43
+ removeBlocks,
44
+ replaceInnerBlocks
45
+ } = (0, _data.useDispatch)(_blockEditor.store);
46
+ const label = (0, _i18n.sprintf)(
47
+ /* translators: %s: block name */
48
+ (0, _i18n.__)('Remove %s'), (0, _blockEditor.BlockTitle)({
49
+ clientId,
50
+ maximumLength: 25
51
+ }));
52
+ return (0, _element.createElement)(_components.DropdownMenu, (0, _extends2.default)({
53
+ icon: _icons.moreVertical,
54
+ label: (0, _i18n.__)('Options'),
55
+ className: "block-editor-block-settings-menu",
56
+ popoverProps: POPOVER_PROPS,
57
+ noIcons: true
58
+ }, props), _ref => {
59
+ let {
60
+ onClose
61
+ } = _ref;
62
+ return (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)(_components.MenuItem, {
63
+ icon: _icons.addSubmenu,
64
+ onClick: () => {
65
+ const updateSelectionOnInsert = false;
66
+ const newLink = (0, _blocks.createBlock)('core/navigation-link');
67
+
68
+ if (block.name === 'core/navigation-submenu') {
69
+ insertBlock(newLink, block.innerBlocks.length, clientId, updateSelectionOnInsert);
70
+ } else {
71
+ // Convert to a submenu if the block currently isn't one.
72
+ const newSubmenu = (0, _blocks.createBlock)('core/navigation-submenu', block.attributes, block.innerBlocks); // The following must happen as two independent actions.
73
+ // Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds
74
+ // selector to determine which block is "active". As the UX needs the newLink to be
75
+ // the "active" block it must be the last block to be inserted.
76
+ // Therefore the Submenu is first created and **then** the newLink is inserted
77
+ // thus ensuring it is the last inserted block.
78
+
79
+ replaceBlock(clientId, newSubmenu);
80
+ replaceInnerBlocks(newSubmenu.clientId, [newLink], updateSelectionOnInsert);
81
+ }
82
+
83
+ onClose();
84
+ }
85
+ }, (0, _i18n.__)('Add submenu item')), (0, _element.createElement)(_components.MenuItem, {
86
+ onClick: () => {
87
+ removeBlocks([clientId], false);
88
+ onClose();
89
+ }
90
+ }, label));
91
+ });
92
+ };
93
+
94
+ exports.LeafMoreMenu = LeafMoreMenu;
95
+ //# sourceMappingURL=leaf-more-menu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation/leaf-more-menu.js"],"names":["POPOVER_PROPS","className","position","variant","LeafMoreMenu","props","clientId","block","insertBlock","replaceBlock","removeBlocks","replaceInnerBlocks","blockEditorStore","label","maximumLength","moreVertical","onClose","addSubmenu","updateSelectionOnInsert","newLink","name","innerBlocks","length","newSubmenu","attributes"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AARA;AACA;AACA;AAQA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,2CADU;AAErBC,EAAAA,QAAQ,EAAE,cAFW;AAGrBC,EAAAA,OAAO,EAAE;AAHY,CAAtB;;AAMO,MAAMC,YAAY,GAAKC,KAAF,IAAa;AACxC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAsBF,KAA5B;AAEA,QAAM;AAAEG,IAAAA,WAAF;AAAeC,IAAAA,YAAf;AAA6BC,IAAAA,YAA7B;AAA2CC,IAAAA;AAA3C,MACL,uBAAaC,kBAAb,CADD;AAGA,QAAMC,KAAK,GAAG;AACb;AACA,gBAAI,WAAJ,CA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1CD,CADC;AAAA,GARH,CADD;AAgEA,CA5EM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { addSubmenu, moreVertical } from '@wordpress/icons';\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore, BlockTitle } from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\n\nconst POPOVER_PROPS = {\n\tclassName: 'block-editor-block-settings-menu__popover',\n\tposition: 'bottom right',\n\tvariant: 'toolbar',\n};\n\nexport const LeafMoreMenu = ( props ) => {\n\tconst { clientId, block } = props;\n\n\tconst { insertBlock, replaceBlock, removeBlocks, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst label = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Remove %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tclassName=\"block-editor-block-settings-menu\"\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tnoIcons\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tconst updateSelectionOnInsert = false;\n\t\t\t\t\t\t\tconst newLink = createBlock(\n\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( block.name === 'core/navigation-submenu' ) {\n\t\t\t\t\t\t\t\tinsertBlock(\n\t\t\t\t\t\t\t\t\tnewLink,\n\t\t\t\t\t\t\t\t\tblock.innerBlocks.length,\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Convert to a submenu if the block currently isn't one.\n\t\t\t\t\t\t\t\tconst newSubmenu = createBlock(\n\t\t\t\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t// The following must happen as two independent actions.\n\t\t\t\t\t\t\t\t// Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds\n\t\t\t\t\t\t\t\t// selector to determine which block is \"active\". As the UX needs the newLink to be\n\t\t\t\t\t\t\t\t// the \"active\" block it must be the last block to be inserted.\n\t\t\t\t\t\t\t\t// Therefore the Submenu is first created and **then** the newLink is inserted\n\t\t\t\t\t\t\t\t// thus ensuring it is the last inserted block.\n\t\t\t\t\t\t\t\treplaceBlock( clientId, newSubmenu );\n\n\t\t\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\t\t\tnewSubmenu.clientId,\n\t\t\t\t\t\t\t\t\t[ newLink ],\n\t\t\t\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Add submenu item' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tremoveBlocks( [ clientId ], false );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n};\n"]}
@@ -39,6 +39,8 @@ var _linkUi = require("./link-ui");
39
39
 
40
40
  var _updateAttributes = require("./update-attributes");
41
41
 
42
+ var _utils = require("../navigation/edit/utils");
43
+
42
44
  /**
43
45
  * External dependencies
44
46
  */
@@ -166,63 +168,6 @@ const useIsDraggingWithin = elementRef => {
166
168
  }, []);
167
169
  return isDraggingWithin;
168
170
  };
169
- /**
170
- * Determine the colors for a menu.
171
- *
172
- * Order of priority is:
173
- * 1: Overlay custom colors (if submenu)
174
- * 2: Overlay theme colors (if submenu)
175
- * 3: Custom colors
176
- * 4: Theme colors
177
- * 5: Global styles
178
- *
179
- * @param {Object} context
180
- * @param {boolean} isSubMenu
181
- */
182
-
183
-
184
- function getColors(context, isSubMenu) {
185
- var _style$color, _style$color2;
186
-
187
- const {
188
- textColor,
189
- customTextColor,
190
- backgroundColor,
191
- customBackgroundColor,
192
- overlayTextColor,
193
- customOverlayTextColor,
194
- overlayBackgroundColor,
195
- customOverlayBackgroundColor,
196
- style
197
- } = context;
198
- const colors = {};
199
-
200
- if (isSubMenu && !!customOverlayTextColor) {
201
- colors.customTextColor = customOverlayTextColor;
202
- } else if (isSubMenu && !!overlayTextColor) {
203
- colors.textColor = overlayTextColor;
204
- } else if (!!customTextColor) {
205
- colors.customTextColor = customTextColor;
206
- } else if (!!textColor) {
207
- colors.textColor = textColor;
208
- } else if (!!(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.text)) {
209
- colors.customTextColor = style.color.text;
210
- }
211
-
212
- if (isSubMenu && !!customOverlayBackgroundColor) {
213
- colors.customBackgroundColor = customOverlayBackgroundColor;
214
- } else if (isSubMenu && !!overlayBackgroundColor) {
215
- colors.backgroundColor = overlayBackgroundColor;
216
- } else if (!!customBackgroundColor) {
217
- colors.customBackgroundColor = customBackgroundColor;
218
- } else if (!!backgroundColor) {
219
- colors.backgroundColor = backgroundColor;
220
- } else if (!!(style !== null && style !== void 0 && (_style$color2 = style.color) !== null && _style$color2 !== void 0 && _style$color2.background)) {
221
- colors.customTextColor = style.color.background;
222
- }
223
-
224
- return colors;
225
- }
226
171
 
227
172
  const useIsInvalidLink = (kind, type, id) => {
228
173
  const isPostType = kind === 'post-type' || type === 'post' || type === 'page';
@@ -454,7 +399,7 @@ function NavigationLinkEdit(_ref) {
454
399
  customTextColor,
455
400
  backgroundColor,
456
401
  customBackgroundColor
457
- } = getColors(context, !isTopLevelLink);
402
+ } = (0, _utils.getColors)(context, !isTopLevelLink);
458
403
 
459
404
  function onKeyDown(event) {
460
405
  if (_keycodes.isKeyboardEvent.primary(event, 'k') || !url && event.keyCode === _keycodes.ENTER) {
@@ -484,7 +429,10 @@ function NavigationLinkEdit(_ref) {
484
429
  const DEFAULT_BLOCK = {
485
430
  name: 'core/navigation-link'
486
431
  };
487
- const innerBlocksProps = (0, _blockEditor.useInnerBlocksProps)(blockProps, {
432
+ const innerBlocksProps = (0, _blockEditor.useInnerBlocksProps)({ ...blockProps,
433
+ className: 'remove-outline' // Remove the outline from the inner blocks container.
434
+
435
+ }, {
488
436
  allowedBlocks: ALLOWED_BLOCKS,
489
437
  __experimentalDefaultBlock: DEFAULT_BLOCK,
490
438
  __experimentalDirectInsert: true,
@@ -528,13 +476,14 @@ function NavigationLinkEdit(_ref) {
528
476
  }), (0, _element.createElement)(_components.TextControl, {
529
477
  value: url || '',
530
478
  onChange: urlValue => {
531
- setAttributes({
479
+ (0, _updateAttributes.updateAttributes)({
532
480
  url: urlValue
533
- });
481
+ }, setAttributes, attributes);
534
482
  },
535
483
  label: (0, _i18n.__)('URL'),
536
484
  autoComplete: "off"
537
485
  }), (0, _element.createElement)(_components.TextareaControl, {
486
+ __nextHasNoMarginBottom: true,
538
487
  value: description || '',
539
488
  onChange: descriptionValue => {
540
489
  setAttributes({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation-link/edit.js"],"names":["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","coreStore","status","isInvalid","isDraft","getMissingText","missingText","NavigationLinkEdit","attributes","isSelected","setAttributes","insertBlocksAfter","mergeBlocks","onReplace","clientId","label","url","description","rel","title","maxNestingLevel","replaceBlock","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","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","isKeyboardEvent","primary","keyCode","ENTER","blockProps","className","ALLOWED_BLOCKS","DEFAULT_BLOCK","innerBlocksProps","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","renderAppender","onClick","classes","placeholderText","tooltipText","linkIcon","displayShortcut","addSubmenu","labelValue","urlValue","descriptionValue","titleValue","relValue","enter","trim","updatedValue"],"mappings":";;;;;;;;;AAgCA;;AA7BA;;AACA;;AAKA;;AACA;;AACA;;AASA;;AACA;;AACA;;AASA;;AAEA;;AAIA;;AACA;;AAIA;;AAMA;;AACA;;AAjDA;AACA;AACA;;AAIA;AACA;AACA;;AAoCA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAKC,UAAF,IAAkB;AAC7C,QAAM,CAAEC,gBAAF,EAAoBC,mBAApB,IAA4C,uB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AAU,IACX,4BAAC,cAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,QAAQ,EAAGV,QAFZ;AAGC,IAAA,IAAI,EAAGN,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,EAAK+B,YAAF,IAAoB;AAC9B,8CACCA,YADD,EAEChF,aAFD,EAGCF,UAHD;AAKA;AAdF,IApGF,CAFD,EAwHC,mCAAU+D,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":["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","coreStore","status","isInvalid","isDraft","getMissingText","missingText","NavigationLinkEdit","attributes","isSelected","setAttributes","insertBlocksAfter","mergeBlocks","onReplace","context","clientId","label","url","description","rel","title","maxNestingLevel","replaceBlock","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","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","isKeyboardEvent","primary","keyCode","ENTER","blockProps","className","style","color","ALLOWED_BLOCKS","DEFAULT_BLOCK","innerBlocksProps","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","renderAppender","onClick","classes","placeholderText","tooltipText","linkIcon","displayShortcut","addSubmenu","labelValue","urlValue","descriptionValue","titleValue","relValue","enter","trim","updatedValue"],"mappings":";;;;;;;;;AAgCA;;AA7BA;;AACA;;AAKA;;AACA;;AACA;;AASA;;AACA;;AACA;;AASA;;AAEA;;AAIA;;AACA;;AAIA;;AAMA;;AACA;;AACA;;AAlDA;AACA;AACA;;AAIA;AACA;AACA;;AAoCA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAKC,UAAF,IAAkB;AAC7C,QAAM,CAAEC,gBAAF,EAAoBC,mBAApB,IAA4C,uBAAU,KAAV,CAAlD;AAEA,0BAAW,MAAM;AAChB,UAAM;AAAEC,MAAAA;AAAF,QAAoBH,UAAU,CAACI,OAArC;;AAEA,aAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACjC;AACAC,MAAAA,eAAe,CAAED,KAAF,CAAf;AACA,KANe,CAQhB;;;AACA,aAASE,aAAT,GAAyB;AACxBN,MAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACA;;AAED,aAASK,eAAT,CAA0BD,KAA1B,EAAkC;AACjC;AACA,UAAKN,UAAU,CAACI,OAAX,CAAmBK,QAAnB,CAA6BH,KAAK,CAACI,MAAnC,CAAL,EAAmD;AAClDR,QAAAA,mBAAmB,CAAE,IAAF,CAAnB;AACA,OAFD,MAEO;AACNA,QAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACA;AACD,KApBe,CAsBhB;AACA;AACA;;;AACAC,IAAAA,aAAa,CAACQ,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AAa,CAAE,IAAF;AAHH;AADb,IADD,EAQC,4BAAC,mBAAD;AACC,IAAA,QAAQ,EAAC,YADV;AAEC,IAAA,IAAI,EAAG4D;AAFR,KAIC,qDACC;AACC,kBAAa,cACZ,sBADY;AADd,KAME;AACA;AACA;AACA;AACA;AACC,KAAG,sBACHtE,KADG,CAED,IAAIqE,eAAiB,EAFxB,CAE0BW,IAF1B,EAXF,CADD,EAiBC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGV,WADH,CAjBD,CAJD,CARD,CA/CF,CAdF,EAmGG7D,UAAU,IACX,4BAAC,cAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,QAAQ,EAAGV,QAFZ;AAGC,IAAA,IAAI,EAAGP,UAHR;AAIC,IAAA,OAAO,EAAG,MAAMkB,aAAa,CAAE,KAAF,CAJ9B;AAKC,IAAA,MAAM,EAAGC,aALV;AAMC,IAAA,mBAAmB,EAAGkC,aANvB;AAOC,IAAA,QAAQ,EAAGD,UAPZ;AAQC,IAAA,QAAQ,EAAKqC,YAAF,IAAoB;AAC9B,8CACCA,YADD,EAECvF,aAFD,EAGCF,UAHD;AAKA;AAdF,IApGF,CAFD,EAwHC,mCAAUsE,gBAAV,CAxHD,CAxED,CADD;AAqMA","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\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\t...blockProps,\n\t\t\tclassName: 'remove-outline', // Remove the outline from the inner blocks container.\n\t\t},\n\t\t{\n\t\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\t\t__experimentalDefaultBlock: DEFAULT_BLOCK,\n\t\t\t__experimentalDirectInsert: true,\n\t\t\trenderAppender: false,\n\t\t}\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\tupdateAttributes(\n\t\t\t\t\t\t\t\t{ url: urlValue },\n\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t\t);\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"]}
@@ -83,9 +83,9 @@ const updateAttributes = function () {
83
83
  const isCustomLink = !newKind && !isBuiltInType || newKind === 'custom';
84
84
  const kind = isCustomLink ? 'custom' : newKind;
85
85
  setAttributes({ // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
86
- ...(newUrl && {
87
- url: encodeURI((0, _url.safeDecodeURI)(newUrl))
88
- }),
86
+ ...{
87
+ url: newUrl ? encodeURI((0, _url.safeDecodeURI)(newUrl)) : newUrl
88
+ },
89
89
  ...(label && {
90
90
  label
91
91
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/navigation-link/update-attributes.js"],"names":["updateAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","url","newUrl","opensInNewTab","id","newKind","newType","newLabelWithoutHttp","replace","newUrlWithoutHttp","useNewLabel","isBuiltInType","indexOf","isCustomLink","encodeURI","undefined","Number","isInteger"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,YAI3B;AAAA,MAHJC,YAGI,uEAHW,EAGX;AAAA,MAFJC,aAEI;AAAA,MADJC,eACI,uEADc,EACd;AACJ,QAAM;AACLC,IAAAA,KAAK,EAAEC,aAAa,GAAG,EADlB;AAELC,IAAAA,IAAI,EAAEC,YAAY,GAAG,EAFhB;AAGLC,IAAAA,IAAI,EAAEC,YAAY,GAAG;AAHhB,MAIFN,eAJJ;AAMA,QAAM;AACLO,IAAAA,KAAK,EAAEC,QAAQ,GAAG,EADb;AACiB;AACtBC,IA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Ad,CAHc;AAId,QAAKsB,SAAS,KAAKZ,aAAd,IAA+B;AAAEA,MAAAA;AAAF,KAApC,CAJc;AAKd,QAAKC,EAAE,IAAIY,MAAM,CAACC,SAAP,CAAkBb,EAAlB,CAAN,IAAgC;AAAEA,MAAAA;AAAF,KAArC,CALc;AAMd,QAAKT,IAAI,IAAI;AAAEA,MAAAA;AAAF,KAAb,CANc;AAOd,QAAKE,IAAI,IAAIA,IAAI,KAAK,KAAjB,IAA0B;AAAEA,MAAAA;AAAF,KAA/B;AAPc,GAAF,CAAb;AASA,CAlEM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { safeDecodeURI } from '@wordpress/url';\nimport { escapeHTML } from '@wordpress/escape-html';\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\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/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n *\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\turl: newUrl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst newLabelWithoutHttp = newLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl.replace( /http(s?):\\/\\//gi, '' );\n\n\tconst useNewLabel =\n\t\tnewLabel &&\n\t\tnewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( newLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/navigation-link/update-attributes.js"],"names":["updateAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","kind","originalKind","type","originalType","title","newLabel","url","newUrl","opensInNewTab","id","newKind","newType","newLabelWithoutHttp","replace","newUrlWithoutHttp","useNewLabel","isBuiltInType","indexOf","isCustomLink","encodeURI","undefined","Number","isInteger"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAMA,gBAAgB,GAAG,YAI3B;AAAA,MAHJC,YAGI,uEAHW,EAGX;AAAA,MAFJC,aAEI;AAAA,MADJC,eACI,uEADc,EACd;AACJ,QAAM;AACLC,IAAAA,KAAK,EAAEC,aAAa,GAAG,EADlB;AAELC,IAAAA,IAAI,EAAEC,YAAY,GAAG,EAFhB;AAGLC,IAAAA,IAAI,EAAEC,YAAY,GAAG;AAHhB,MAIFN,eAJJ;AAMA,QAAM;AACLO,IAAAA,KAAK,EAAEC,QAAQ,GAAG,EADb;AACiB;AACtBC,IAAAA,GAAG,EAAEC,MAAM,GAAG,EAFT;AAGLC,IAAAA,aAHK;AAILC,IAAAA,EAJK;AAKLT,IAAAA,IAAI,EAAEU,OAAO,GAAGT,YALX;AAMLC,IAAAA,IAAI,EAAES,OAAO,GAAGR;AANX,MAOFR,YAPJ;AASA,QAAMiB,mBAAmB,GAAGP,QAAQ,CAACQ,OAAT,CAAkB,iBAAlB,EAAqC,EAArC,CAA5B;AACA,QAAMC,iBAAiB,GAAGP,MAAM,CAACM,OAAP,CAAgB,iBAAhB,EAAmC,EAAnC,CAA1B;AAEA,QAAME,WAAW,GAChBV,QAAQ,IACRA,QAAQ,KAAKN,aADb,IAEA;AACA;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press/url';\nimport { escapeHTML } from '@wordpress/escape-html';\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\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/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n *\n */\n\nexport const updateAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\n\tconst {\n\t\ttitle: newLabel = '', // the title of any provided Post.\n\t\turl: newUrl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst newLabelWithoutHttp = newLabel.replace( /http(s?):\\/\\//gi, '' );\n\tconst newUrlWithoutHttp = newUrl.replace( /http(s?):\\/\\//gi, '' );\n\n\tconst useNewLabel =\n\t\tnewLabel &&\n\t\tnewLabel !== originalLabel &&\n\t\t// LinkControl without the title field relies\n\t\t// on the check below. Specifically, it assumes that\n\t\t// the URL is the same as a title.\n\t\t// This logic a) looks suspicious and b) should really\n\t\t// live in the LinkControl and not here. It's a great\n\t\t// candidate for future refactoring.\n\t\tnewLabelWithoutHttp !== newUrlWithoutHttp;\n\n\t// Unfortunately this causes the escaping model to be inverted.\n\t// The escaped content is stored in the block attributes (and ultimately in the database),\n\t// and then the raw data is \"recovered\" when outputting into the DOM.\n\t// It would be preferable to store the **raw** data in the block attributes and escape it in JS.\n\t// Why? Because there isn't one way to escape data. Depending on the context, you need to do\n\t// different transforms. It doesn't make sense to me to choose one of them for the purposes of storage.\n\t// See also:\n\t// - https://github.com/WordPress/gutenberg/pull/41063\n\t// - https://github.com/WordPress/gutenberg/pull/18617.\n\tconst label = useNewLabel\n\t\t? escapeHTML( newLabel )\n\t\t: originalLabel || escapeHTML( newUrlWithoutHttp );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...{ url: newUrl ? encodeURI( safeDecodeURI( newUrl ) ) : newUrl },\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n"]}