@wordpress/editor 14.13.0 → 14.13.1-next.a9f418477.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 (304) hide show
  1. package/README.md +8 -28
  2. package/build/bindings/post-meta.js +2 -3
  3. package/build/bindings/post-meta.js.map +1 -1
  4. package/build/components/autocompleters/user.js +1 -3
  5. package/build/components/autocompleters/user.js.map +1 -1
  6. package/build/components/collab-sidebar/constants.js +2 -1
  7. package/build/components/collab-sidebar/constants.js.map +1 -1
  8. package/build/components/collab-sidebar/index.js +108 -43
  9. package/build/components/collab-sidebar/index.js.map +1 -1
  10. package/build/components/collab-sidebar/utils.js +32 -0
  11. package/build/components/collab-sidebar/utils.js.map +1 -1
  12. package/build/components/document-bar/index.js +3 -1
  13. package/build/components/document-bar/index.js.map +1 -1
  14. package/build/components/entities-saved-states/index.js +6 -6
  15. package/build/components/entities-saved-states/index.js.map +1 -1
  16. package/build/components/error-boundary/index.js +26 -13
  17. package/build/components/error-boundary/index.js.map +1 -1
  18. package/build/components/header/index.js +5 -2
  19. package/build/components/header/index.js.map +1 -1
  20. package/build/components/index.js +10 -26
  21. package/build/components/index.js.map +1 -1
  22. package/build/components/post-actions/actions.js +29 -2
  23. package/build/components/post-actions/actions.js.map +1 -1
  24. package/build/components/post-actions/index.js +1 -1
  25. package/build/components/post-actions/index.js.map +1 -1
  26. package/build/components/post-actions/set-as-homepage.js +170 -0
  27. package/build/components/post-actions/set-as-homepage.js.map +1 -0
  28. package/build/components/post-author/constants.js +1 -1
  29. package/build/components/post-author/constants.js.map +1 -1
  30. package/build/components/post-author/hook.js +1 -0
  31. package/build/components/post-author/hook.js.map +1 -1
  32. package/build/components/post-card-panel/index.js +1 -3
  33. package/build/components/post-card-panel/index.js.map +1 -1
  34. package/build/components/post-fields/index.js +3 -3
  35. package/build/components/post-fields/index.js.map +1 -1
  36. package/build/components/post-publish-button/index.js +4 -2
  37. package/build/components/post-publish-button/index.js.map +1 -1
  38. package/build/components/post-publish-button/post-publish-button-or-toggle.js +32 -37
  39. package/build/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -1
  40. package/build/components/post-publish-panel/maybe-upload-media.js +0 -1
  41. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  42. package/build/components/post-publish-panel/media-util.js +0 -1
  43. package/build/components/post-publish-panel/media-util.js.map +1 -1
  44. package/build/components/post-publish-panel/postpublish.js +103 -117
  45. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  46. package/build/components/post-publish-panel/prepublish.js +1 -1
  47. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  48. package/build/components/post-trash/check.js +4 -4
  49. package/build/components/post-trash/check.js.map +1 -1
  50. package/build/components/post-url/index.js +2 -1
  51. package/build/components/post-url/index.js.map +1 -1
  52. package/build/components/provider/index.js +9 -1
  53. package/build/components/provider/index.js.map +1 -1
  54. package/build/components/save-publish-panels/index.js +3 -1
  55. package/build/components/save-publish-panels/index.js.map +1 -1
  56. package/build/components/template-part-menu-items/convert-to-template-part.js +2 -3
  57. package/build/components/template-part-menu-items/convert-to-template-part.js.map +1 -1
  58. package/build/components/visual-editor/index.js +2 -1
  59. package/build/components/visual-editor/index.js.map +1 -1
  60. package/build/dataviews/store/private-actions.js +17 -9
  61. package/build/dataviews/store/private-actions.js.map +1 -1
  62. package/build/private-apis.js +2 -2
  63. package/build/private-apis.js.map +1 -1
  64. package/build/store/constants.js +0 -1
  65. package/build/store/constants.js.map +1 -1
  66. package/build/store/private-actions.js +0 -1
  67. package/build/store/private-actions.js.map +1 -1
  68. package/build/store/selectors.js +1 -1
  69. package/build/store/selectors.js.map +1 -1
  70. package/build/utils/pageTypeBadge.js +3 -10
  71. package/build/utils/pageTypeBadge.js.map +1 -1
  72. package/build-module/bindings/post-meta.js +2 -3
  73. package/build-module/bindings/post-meta.js.map +1 -1
  74. package/build-module/components/autocompleters/user.js +1 -3
  75. package/build-module/components/autocompleters/user.js.map +1 -1
  76. package/build-module/components/collab-sidebar/constants.js +1 -0
  77. package/build-module/components/collab-sidebar/constants.js.map +1 -1
  78. package/build-module/components/collab-sidebar/index.js +111 -46
  79. package/build-module/components/collab-sidebar/index.js.map +1 -1
  80. package/build-module/components/collab-sidebar/utils.js +31 -0
  81. package/build-module/components/collab-sidebar/utils.js.map +1 -1
  82. package/build-module/components/document-bar/index.js +3 -1
  83. package/build-module/components/document-bar/index.js.map +1 -1
  84. package/build-module/components/entities-saved-states/index.js +6 -6
  85. package/build-module/components/entities-saved-states/index.js.map +1 -1
  86. package/build-module/components/error-boundary/index.js +28 -15
  87. package/build-module/components/error-boundary/index.js.map +1 -1
  88. package/build-module/components/header/index.js +5 -2
  89. package/build-module/components/header/index.js.map +1 -1
  90. package/build-module/components/index.js +0 -2
  91. package/build-module/components/index.js.map +1 -1
  92. package/build-module/components/post-actions/actions.js +29 -2
  93. package/build-module/components/post-actions/actions.js.map +1 -1
  94. package/build-module/components/post-actions/index.js +1 -1
  95. package/build-module/components/post-actions/index.js.map +1 -1
  96. package/build-module/components/post-actions/set-as-homepage.js +162 -0
  97. package/build-module/components/post-actions/set-as-homepage.js.map +1 -0
  98. package/build-module/components/post-author/constants.js +1 -1
  99. package/build-module/components/post-author/constants.js.map +1 -1
  100. package/build-module/components/post-author/hook.js +1 -0
  101. package/build-module/components/post-author/hook.js.map +1 -1
  102. package/build-module/components/post-card-panel/index.js +1 -3
  103. package/build-module/components/post-card-panel/index.js.map +1 -1
  104. package/build-module/components/post-fields/index.js +3 -3
  105. package/build-module/components/post-fields/index.js.map +1 -1
  106. package/build-module/components/post-publish-button/index.js +4 -2
  107. package/build-module/components/post-publish-button/index.js.map +1 -1
  108. package/build-module/components/post-publish-button/post-publish-button-or-toggle.js +34 -38
  109. package/build-module/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -1
  110. package/build-module/components/post-publish-panel/maybe-upload-media.js +0 -1
  111. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  112. package/build-module/components/post-publish-panel/media-util.js +0 -1
  113. package/build-module/components/post-publish-panel/media-util.js.map +1 -1
  114. package/build-module/components/post-publish-panel/postpublish.js +104 -118
  115. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  116. package/build-module/components/post-publish-panel/prepublish.js +1 -1
  117. package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
  118. package/build-module/components/post-trash/check.js +4 -4
  119. package/build-module/components/post-trash/check.js.map +1 -1
  120. package/build-module/components/post-url/index.js +2 -1
  121. package/build-module/components/post-url/index.js.map +1 -1
  122. package/build-module/components/provider/index.js +10 -2
  123. package/build-module/components/provider/index.js.map +1 -1
  124. package/build-module/components/save-publish-panels/index.js +3 -1
  125. package/build-module/components/save-publish-panels/index.js.map +1 -1
  126. package/build-module/components/template-part-menu-items/convert-to-template-part.js +1 -1
  127. package/build-module/components/template-part-menu-items/convert-to-template-part.js.map +1 -1
  128. package/build-module/components/visual-editor/index.js +2 -1
  129. package/build-module/components/visual-editor/index.js.map +1 -1
  130. package/build-module/dataviews/store/private-actions.js +17 -9
  131. package/build-module/dataviews/store/private-actions.js.map +1 -1
  132. package/build-module/private-apis.js +1 -1
  133. package/build-module/private-apis.js.map +1 -1
  134. package/build-module/store/constants.js +0 -1
  135. package/build-module/store/constants.js.map +1 -1
  136. package/build-module/store/private-actions.js +0 -1
  137. package/build-module/store/private-actions.js.map +1 -1
  138. package/build-module/store/selectors.js +1 -1
  139. package/build-module/store/selectors.js.map +1 -1
  140. package/build-module/utils/pageTypeBadge.js +3 -10
  141. package/build-module/utils/pageTypeBadge.js.map +1 -1
  142. package/build-style/style-rtl.css +41 -64
  143. package/build-style/style.css +41 -64
  144. package/build-types/bindings/post-meta.d.ts.map +1 -1
  145. package/build-types/components/autocompleters/user.d.ts +7 -3
  146. package/build-types/components/autocompleters/user.d.ts.map +1 -1
  147. package/build-types/components/collab-sidebar/constants.d.ts +1 -0
  148. package/build-types/components/collab-sidebar/constants.d.ts.map +1 -1
  149. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  150. package/build-types/components/collab-sidebar/utils.d.ts +10 -0
  151. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  152. package/build-types/components/document-bar/index.d.ts.map +1 -1
  153. package/build-types/components/entities-saved-states/index.d.ts +5 -5
  154. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  155. package/build-types/components/error-boundary/index.d.ts.map +1 -1
  156. package/build-types/components/header/index.d.ts.map +1 -1
  157. package/build-types/components/index.d.ts +0 -2
  158. package/build-types/components/index.d.ts.map +1 -1
  159. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +1 -1
  160. package/build-types/components/media-categories/index.d.ts.map +1 -1
  161. package/build-types/components/pattern-duplicate-modal/index.d.ts.map +1 -1
  162. package/build-types/components/pattern-rename-modal/index.d.ts.map +1 -1
  163. package/build-types/components/post-actions/actions.d.ts +1 -1
  164. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  165. package/build-types/components/post-actions/set-as-homepage.d.ts +10 -0
  166. package/build-types/components/post-actions/set-as-homepage.d.ts.map +1 -0
  167. package/build-types/components/post-author/hook.d.ts.map +1 -1
  168. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  169. package/build-types/components/post-fields/index.d.ts +3 -1
  170. package/build-types/components/post-fields/index.d.ts.map +1 -1
  171. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  172. package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts +1 -13
  173. package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts.map +1 -1
  174. package/build-types/components/post-publish-panel/postpublish.d.ts +4 -2
  175. package/build-types/components/post-publish-panel/postpublish.d.ts.map +1 -1
  176. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +4 -4
  177. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  178. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +4 -4
  179. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  180. package/build-types/components/post-title/constants.d.ts.map +1 -1
  181. package/build-types/components/post-trash/check.d.ts +6 -6
  182. package/build-types/components/post-trash/check.d.ts.map +1 -1
  183. package/build-types/components/post-url/index.d.ts +5 -2
  184. package/build-types/components/post-url/index.d.ts.map +1 -1
  185. package/build-types/components/provider/index.d.ts.map +1 -1
  186. package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
  187. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  188. package/build-types/dataviews/api.d.ts.map +1 -1
  189. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  190. package/build-types/dataviews/store/reducer.d.ts +1 -1
  191. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -1
  192. package/build-types/hooks/pattern-overrides.d.ts.map +1 -1
  193. package/build-types/lock-unlock.d.ts +2 -2
  194. package/build-types/store/actions.d.ts +7 -9
  195. package/build-types/store/actions.d.ts.map +1 -1
  196. package/build-types/store/private-actions.d.ts +1 -1
  197. package/build-types/store/private-actions.d.ts.map +1 -1
  198. package/build-types/store/reducer.d.ts +1 -1
  199. package/build-types/store/selectors.d.ts +2 -2
  200. package/build-types/store/selectors.d.ts.map +1 -1
  201. package/build-types/utils/pageTypeBadge.d.ts +3 -1
  202. package/build-types/utils/pageTypeBadge.d.ts.map +1 -1
  203. package/package.json +36 -36
  204. package/src/bindings/post-meta.js +2 -5
  205. package/src/components/autocompleters/user.js +1 -3
  206. package/src/components/collab-sidebar/constants.js +1 -0
  207. package/src/components/collab-sidebar/index.js +115 -47
  208. package/src/components/collab-sidebar/style.scss +13 -0
  209. package/src/components/collab-sidebar/utils.js +36 -0
  210. package/src/components/document-bar/index.js +3 -1
  211. package/src/components/editor-interface/style.scss +2 -1
  212. package/src/components/entities-saved-states/index.js +6 -9
  213. package/src/components/error-boundary/index.js +30 -16
  214. package/src/components/error-boundary/style.scss +5 -1
  215. package/src/components/header/index.js +17 -5
  216. package/src/components/header/style.scss +1 -1
  217. package/src/components/index.js +0 -2
  218. package/src/components/post-actions/actions.js +38 -2
  219. package/src/components/post-actions/index.js +1 -1
  220. package/src/components/post-actions/set-as-homepage.js +183 -0
  221. package/src/components/post-author/constants.js +1 -1
  222. package/src/components/post-author/hook.js +1 -0
  223. package/src/components/post-card-panel/index.js +1 -3
  224. package/src/components/post-card-panel/style.scss +1 -0
  225. package/src/components/post-fields/index.ts +5 -3
  226. package/src/components/post-publish-button/index.js +2 -0
  227. package/src/components/post-publish-button/post-publish-button-or-toggle.js +38 -40
  228. package/src/components/post-publish-button/test/post-publish-button-or-toggle.js +24 -9
  229. package/src/components/post-publish-panel/postpublish.js +114 -124
  230. package/src/components/post-publish-panel/prepublish.js +1 -1
  231. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  232. package/src/components/post-trash/check.js +4 -4
  233. package/src/components/post-url/index.js +2 -1
  234. package/src/components/provider/index.js +17 -3
  235. package/src/components/save-publish-panels/index.js +5 -1
  236. package/src/components/template-part-menu-items/convert-to-template-part.js +1 -1
  237. package/src/components/visual-editor/index.js +1 -0
  238. package/src/components/visual-editor/style.scss +29 -6
  239. package/src/dataviews/store/private-actions.ts +36 -20
  240. package/src/private-apis.js +1 -1
  241. package/src/store/selectors.js +1 -1
  242. package/src/style.scss +0 -2
  243. package/src/utils/pageTypeBadge.js +3 -8
  244. package/tsconfig.tsbuildinfo +1 -1
  245. package/build/components/create-template-part-modal/index.js +0 -170
  246. package/build/components/create-template-part-modal/index.js.map +0 -1
  247. package/build/components/create-template-part-modal/utils.js +0 -64
  248. package/build/components/create-template-part-modal/utils.js.map +0 -1
  249. package/build/components/post-slug/check.js +0 -29
  250. package/build/components/post-slug/check.js.map +0 -1
  251. package/build/components/post-slug/index.js +0 -79
  252. package/build/components/post-slug/index.js.map +0 -1
  253. package/build/components/post-slug/panel.js +0 -30
  254. package/build/components/post-slug/panel.js.map +0 -1
  255. package/build/dataviews/actions/duplicate-template-part.js +0 -67
  256. package/build/dataviews/actions/duplicate-template-part.js.map +0 -1
  257. package/build/dataviews/actions/utils.js +0 -58
  258. package/build/dataviews/actions/utils.js.map +0 -1
  259. package/build/dataviews/types.js +0 -6
  260. package/build/dataviews/types.js.map +0 -1
  261. package/build-module/components/create-template-part-modal/index.js +0 -162
  262. package/build-module/components/create-template-part-modal/index.js.map +0 -1
  263. package/build-module/components/create-template-part-modal/utils.js +0 -54
  264. package/build-module/components/create-template-part-modal/utils.js.map +0 -1
  265. package/build-module/components/post-slug/check.js +0 -23
  266. package/build-module/components/post-slug/check.js.map +0 -1
  267. package/build-module/components/post-slug/index.js +0 -71
  268. package/build-module/components/post-slug/index.js.map +0 -1
  269. package/build-module/components/post-slug/panel.js +0 -21
  270. package/build-module/components/post-slug/panel.js.map +0 -1
  271. package/build-module/dataviews/actions/duplicate-template-part.js +0 -58
  272. package/build-module/dataviews/actions/duplicate-template-part.js.map +0 -1
  273. package/build-module/dataviews/actions/utils.js +0 -47
  274. package/build-module/dataviews/actions/utils.js.map +0 -1
  275. package/build-module/dataviews/types.js +0 -2
  276. package/build-module/dataviews/types.js.map +0 -1
  277. package/build-types/components/create-template-part-modal/index.d.ts +0 -14
  278. package/build-types/components/create-template-part-modal/index.d.ts.map +0 -1
  279. package/build-types/components/create-template-part-modal/utils.d.ts +0 -4
  280. package/build-types/components/create-template-part-modal/utils.d.ts.map +0 -1
  281. package/build-types/components/post-slug/check.d.ts +0 -12
  282. package/build-types/components/post-slug/check.d.ts.map +0 -1
  283. package/build-types/components/post-slug/index.d.ts +0 -7
  284. package/build-types/components/post-slug/index.d.ts.map +0 -1
  285. package/build-types/components/post-slug/panel.d.ts +0 -3
  286. package/build-types/components/post-slug/panel.d.ts.map +0 -1
  287. package/build-types/dataviews/actions/duplicate-template-part.d.ts +0 -5
  288. package/build-types/dataviews/actions/duplicate-template-part.d.ts.map +0 -1
  289. package/build-types/dataviews/actions/utils.d.ts +0 -13
  290. package/build-types/dataviews/actions/utils.d.ts.map +0 -1
  291. package/build-types/dataviews/types.d.ts +0 -92
  292. package/build-types/dataviews/types.d.ts.map +0 -1
  293. package/src/components/create-template-part-modal/index.js +0 -210
  294. package/src/components/create-template-part-modal/style.scss +0 -63
  295. package/src/components/create-template-part-modal/test/utils.js +0 -60
  296. package/src/components/create-template-part-modal/utils.js +0 -67
  297. package/src/components/post-slug/check.js +0 -20
  298. package/src/components/post-slug/index.js +0 -73
  299. package/src/components/post-slug/panel.js +0 -22
  300. package/src/components/post-slug/style.scss +0 -5
  301. package/src/components/post-slug/test/index.js +0 -53
  302. package/src/dataviews/actions/duplicate-template-part.tsx +0 -70
  303. package/src/dataviews/actions/utils.ts +0 -64
  304. package/src/dataviews/types.ts +0 -85
@@ -1 +1 @@
1
- {"version":3,"names":["PanelBody","Button","Spinner","__unstableMotion","motion","__unstableAnimatePresence","AnimatePresence","useSelect","useDispatch","__","store","blockEditorStore","useState","isBlobURL","fetchMedia","jsx","_jsx","jsxs","_jsxs","flattenBlocks","blocks","result","forEach","block","push","innerBlocks","hasExternalMedia","name","attributes","url","id","mediaUrl","mediaId","undefined","getMediaInfo","alt","mediaAlt","Image","clientId","selectBlock","img","tabIndex","role","onClick","onKeyDown","event","key","preventDefault","src","animate","opacity","exit","scale","style","width","height","objectFit","borderRadius","cursor","whileHover","MaybeUploadMediaPanel","isUploading","setIsUploading","isAnimating","setIsAnimating","hadUploadError","setHadUploadError","editorBlocks","mediaUpload","select","getBlocks","getSettings","blocksWithExternalMedia","filter","updateBlockAttributes","length","panelBodyTitle","className","children","updateBlockWithUploadedMedia","media","uploadImages","mediaUrls","Set","map","uploadPromises","Object","fromEntries","entries","filePromise","uploadPromise","then","blob","Promise","resolve","reject","filesList","onFileChange","onError","allSettled","catch","finally","initialOpen","title","display","flexWrap","gap","onExitComplete","size","variant"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-upload-media.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\tSpinner,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState } from '@wordpress/element';\nimport { isBlobURL } from '@wordpress/blob';\n\n/**\n * Internal dependencies\n */\nimport { fetchMedia } from './media-util';\n\nfunction flattenBlocks( blocks ) {\n\tconst result = [];\n\n\tblocks.forEach( ( block ) => {\n\t\tresult.push( block );\n\t\tresult.push( ...flattenBlocks( block.innerBlocks ) );\n\t} );\n\n\treturn result;\n}\n\n/**\n * Determine whether a block has external media.\n *\n * Different blocks use different attribute names (and potentially\n * different logic as well) in determining whether the media is\n * present, and whether it's external.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {boolean?} Whether the block has external media\n */\nfunction hasExternalMedia( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\treturn block.attributes.url && ! block.attributes.id;\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\treturn block.attributes.mediaUrl && ! block.attributes.mediaId;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Retrieve media info from a block.\n *\n * Different blocks use different attribute names, so we need this\n * function to normalize things into a consistent naming scheme.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {{url: ?string, alt: ?string, id: ?number}} The media info for the block.\n */\nfunction getMediaInfo( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\tconst { url, alt, id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\tconst { mediaUrl: url, mediaAlt: alt, mediaId: id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\treturn {};\n}\n\n// Image component to represent a single image in the upload dialog.\nfunction Image( { clientId, alt, url } ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn (\n\t\t<motion.img\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\taria-label={ __( 'Select image block.' ) }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( event.key === 'Enter' || event.key === ' ' ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tkey={ clientId }\n\t\t\talt={ alt }\n\t\t\tsrc={ url }\n\t\t\tanimate={ { opacity: 1 } }\n\t\t\texit={ { opacity: 0, scale: 0 } }\n\t\t\tstyle={ {\n\t\t\t\twidth: '32px',\n\t\t\t\theight: '32px',\n\t\t\t\tobjectFit: 'cover',\n\t\t\t\tborderRadius: '2px',\n\t\t\t\tcursor: 'pointer',\n\t\t\t} }\n\t\t\twhileHover={ { scale: 1.08 } }\n\t\t/>\n\t);\n}\n\nexport default function MaybeUploadMediaPanel() {\n\tconst [ isUploading, setIsUploading ] = useState( false );\n\tconst [ isAnimating, setIsAnimating ] = useState( false );\n\tconst [ hadUploadError, setHadUploadError ] = useState( false );\n\tconst { editorBlocks, mediaUpload } = useSelect(\n\t\t( select ) => ( {\n\t\t\teditorBlocks: select( blockEditorStore ).getBlocks(),\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Get a list of blocks with external media.\n\tconst blocksWithExternalMedia = flattenBlocks( editorBlocks ).filter(\n\t\t( block ) => hasExternalMedia( block )\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tif ( ! mediaUpload || ! blocksWithExternalMedia.length ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'External media' ) }\n\t\t</span>,\n\t];\n\n\t/**\n\t * Update an individual block to point to newly-added library media.\n\t *\n\t * Different blocks use different attribute names, so we need this\n\t * function to ensure we modify the correct attributes for each type.\n\t *\n\t * @param {{name: string, attributes: Object}} block The block.\n\t * @param {{id: number, url: string}} media Media library file info.\n\t */\n\tfunction updateBlockWithUploadedMedia( block, media ) {\n\t\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tid: media.id,\n\t\t\t\turl: media.url,\n\t\t\t} );\n\t\t}\n\n\t\tif ( block.name === 'core/media-text' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tmediaId: media.id,\n\t\t\t\tmediaUrl: media.url,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle fetching and uploading all external media in the post.\n\tfunction uploadImages() {\n\t\tsetIsUploading( true );\n\t\tsetHadUploadError( false );\n\n\t\t// Multiple blocks can be using the same URL, so we\n\t\t// should ensure we only fetch and upload each of them once.\n\t\tconst mediaUrls = new Set(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\t\t\t\treturn url;\n\t\t\t} )\n\t\t);\n\n\t\t// Create an upload promise for each URL, that we can wait for in all\n\t\t// blocks that make use of that media.\n\t\tconst uploadPromises = Object.fromEntries(\n\t\t\tObject.entries( fetchMedia( [ ...mediaUrls ] ) ).map(\n\t\t\t\t( [ url, filePromise ] ) => {\n\t\t\t\t\tconst uploadPromise = filePromise.then(\n\t\t\t\t\t\t( blob ) =>\n\t\t\t\t\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\t\t\t\t\tmediaUpload( {\n\t\t\t\t\t\t\t\t\tfilesList: [ blob ],\n\t\t\t\t\t\t\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\t\t\t\t\t\t\tif ( isBlobURL( media.url ) ) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tresolve( media );\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tonError() {\n\t\t\t\t\t\t\t\t\t\treject();\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);\n\n\t\t\t\t\treturn [ url, uploadPromise ];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\n\t\t// Wait for all blocks to be updated with library media.\n\t\tPromise.allSettled(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\n\t\t\t\treturn uploadPromises[ url ]\n\t\t\t\t\t.then( ( media ) =>\n\t\t\t\t\t\tupdateBlockWithUploadedMedia( block, media )\n\t\t\t\t\t)\n\t\t\t\t\t.then( () => setIsAnimating( true ) )\n\t\t\t\t\t.catch( () => setHadUploadError( true ) );\n\t\t\t} )\n\t\t).finally( () => {\n\t\t\tsetIsUploading( false );\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'inline-flex',\n\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\tgap: '8px',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<AnimatePresence\n\t\t\t\t\tonExitComplete={ () => setIsAnimating( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ blocksWithExternalMedia.map( ( block ) => {\n\t\t\t\t\t\tconst { url, alt } = getMediaInfo( block );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\t\tkey={ block.clientId }\n\t\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\talt={ alt }\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</AnimatePresence>\n\t\t\t\t{ isUploading || isAnimating ? (\n\t\t\t\t\t<Spinner />\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ uploadImages }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ hadUploadError && <p>{ __( 'Upload failed, try again.' ) }</p> }\n\t\t</PanelBody>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,MAAM,EACNC,OAAO,EACPC,gBAAgB,IAAIC,MAAM,EAC1BC,yBAAyB,IAAIC,eAAe,QACtC,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,UAAU,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE1C,SAASC,aAAaA,CAAEC,MAAM,EAAG;EAChC,MAAMC,MAAM,GAAG,EAAE;EAEjBD,MAAM,CAACE,OAAO,CAAIC,KAAK,IAAM;IAC5BF,MAAM,CAACG,IAAI,CAAED,KAAM,CAAC;IACpBF,MAAM,CAACG,IAAI,CAAE,GAAGL,aAAa,CAAEI,KAAK,CAACE,WAAY,CAAE,CAAC;EACrD,CAAE,CAAC;EAEH,OAAOJ,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASK,gBAAgBA,CAAEH,KAAK,EAAG;EAClC,IAAKA,KAAK,CAACI,IAAI,KAAK,YAAY,IAAIJ,KAAK,C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EACJ;EAEA,oBACC5C,KAAA,CAAClB,SAAS;IAACsG,WAAW;IAACC,KAAK,EAAG3B,cAAgB;IAAAE,QAAA,gBAC9C9D,IAAA;MAAA8D,QAAA,EACGrE,EAAE,CACH,8IACD;IAAC,CACC,CAAC,eACJS,KAAA;MACCmC,KAAK,EAAG;QACPmD,OAAO,EAAE,aAAa;QACtBC,QAAQ,EAAE,MAAM;QAChBC,GAAG,EAAE;MACN,CAAG;MAAA5B,QAAA,gBAEH9D,IAAA,CAACV,eAAe;QACfqG,cAAc,EAAGA,CAAA,KAAM3C,cAAc,CAAE,KAAM,CAAG;QAAAc,QAAA,EAE9CN,uBAAuB,CAACY,GAAG,CAAI7D,KAAK,IAAM;UAC3C,MAAM;YAAEM,GAAG;YAAEM;UAAI,CAAC,GAAGD,YAAY,CAAEX,KAAM,CAAC;UAC1C,oBACCP,IAAA,CAACqB,KAAK;YAELC,QAAQ,EAAGf,KAAK,CAACe,QAAU;YAC3BT,GAAG,EAAGA,GAAK;YACXM,GAAG,EAAGA;UAAK,GAHLZ,KAAK,CAACe,QAIZ,CAAC;QAEJ,CAAE;MAAC,CACa,CAAC,EAChBuB,WAAW,IAAIE,WAAW,gBAC3B/C,IAAA,CAACd,OAAO,IAAE,CAAC,gBAEXc,IAAA,CAACf,MAAM;QACN2G,IAAI,EAAC,SAAS;QACdC,OAAO,EAAC,SAAS;QACjBlE,OAAO,EAAGsC,YAAc;QAAAH,QAAA,EAEtBrE,EAAE,CAAE,QAAS;MAAC,CACT,CACR;IAAA,CACG,CAAC,EACJwD,cAAc,iBAAIjD,IAAA;MAAA8D,QAAA,EAAKrE,EAAE,CAAE,2BAA4B;IAAC,CAAK,CAAC;EAAA,CACtD,CAAC;AAEd","ignoreList":[]}
1
+ {"version":3,"names":["PanelBody","Button","Spinner","__unstableMotion","motion","__unstableAnimatePresence","AnimatePresence","useSelect","useDispatch","__","store","blockEditorStore","useState","isBlobURL","fetchMedia","jsx","_jsx","jsxs","_jsxs","flattenBlocks","blocks","result","forEach","block","push","innerBlocks","hasExternalMedia","name","attributes","url","id","mediaUrl","mediaId","undefined","getMediaInfo","alt","mediaAlt","Image","clientId","selectBlock","img","tabIndex","role","onClick","onKeyDown","event","key","preventDefault","src","animate","opacity","exit","scale","style","width","height","objectFit","borderRadius","cursor","whileHover","MaybeUploadMediaPanel","isUploading","setIsUploading","isAnimating","setIsAnimating","hadUploadError","setHadUploadError","editorBlocks","mediaUpload","select","getBlocks","getSettings","blocksWithExternalMedia","filter","updateBlockAttributes","length","panelBodyTitle","className","children","updateBlockWithUploadedMedia","media","uploadImages","mediaUrls","Set","map","uploadPromises","Object","fromEntries","entries","filePromise","uploadPromise","then","blob","Promise","resolve","reject","filesList","onFileChange","onError","allSettled","catch","finally","initialOpen","title","display","flexWrap","gap","onExitComplete","size","variant"],"sources":["@wordpress/editor/src/components/post-publish-panel/maybe-upload-media.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tButton,\n\tSpinner,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState } from '@wordpress/element';\nimport { isBlobURL } from '@wordpress/blob';\n\n/**\n * Internal dependencies\n */\nimport { fetchMedia } from './media-util';\n\nfunction flattenBlocks( blocks ) {\n\tconst result = [];\n\n\tblocks.forEach( ( block ) => {\n\t\tresult.push( block );\n\t\tresult.push( ...flattenBlocks( block.innerBlocks ) );\n\t} );\n\n\treturn result;\n}\n\n/**\n * Determine whether a block has external media.\n *\n * Different blocks use different attribute names (and potentially\n * different logic as well) in determining whether the media is\n * present, and whether it's external.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {boolean?} Whether the block has external media\n */\nfunction hasExternalMedia( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\treturn block.attributes.url && ! block.attributes.id;\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\treturn block.attributes.mediaUrl && ! block.attributes.mediaId;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Retrieve media info from a block.\n *\n * Different blocks use different attribute names, so we need this\n * function to normalize things into a consistent naming scheme.\n *\n * @param {{name: string, attributes: Object}} block The block.\n * @return {{url: ?string, alt: ?string, id: ?number}} The media info for the block.\n */\nfunction getMediaInfo( block ) {\n\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\tconst { url, alt, id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\tif ( block.name === 'core/media-text' ) {\n\t\tconst { mediaUrl: url, mediaAlt: alt, mediaId: id } = block.attributes;\n\t\treturn { url, alt, id };\n\t}\n\n\treturn {};\n}\n\n// Image component to represent a single image in the upload dialog.\nfunction Image( { clientId, alt, url } ) {\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn (\n\t\t<motion.img\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\taria-label={ __( 'Select image block.' ) }\n\t\t\tonClick={ () => {\n\t\t\t\tselectBlock( clientId );\n\t\t\t} }\n\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\tif ( event.key === 'Enter' || event.key === ' ' ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} }\n\t\t\tkey={ clientId }\n\t\t\talt={ alt }\n\t\t\tsrc={ url }\n\t\t\tanimate={ { opacity: 1 } }\n\t\t\texit={ { opacity: 0, scale: 0 } }\n\t\t\tstyle={ {\n\t\t\t\twidth: '32px',\n\t\t\t\theight: '32px',\n\t\t\t\tobjectFit: 'cover',\n\t\t\t\tborderRadius: '2px',\n\t\t\t\tcursor: 'pointer',\n\t\t\t} }\n\t\t\twhileHover={ { scale: 1.08 } }\n\t\t/>\n\t);\n}\n\nexport default function MaybeUploadMediaPanel() {\n\tconst [ isUploading, setIsUploading ] = useState( false );\n\tconst [ isAnimating, setIsAnimating ] = useState( false );\n\tconst [ hadUploadError, setHadUploadError ] = useState( false );\n\tconst { editorBlocks, mediaUpload } = useSelect(\n\t\t( select ) => ( {\n\t\t\teditorBlocks: select( blockEditorStore ).getBlocks(),\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t} ),\n\t\t[]\n\t);\n\n\t// Get a list of blocks with external media.\n\tconst blocksWithExternalMedia = flattenBlocks( editorBlocks ).filter(\n\t\t( block ) => hasExternalMedia( block )\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tif ( ! mediaUpload || ! blocksWithExternalMedia.length ) {\n\t\treturn null;\n\t}\n\n\tconst panelBodyTitle = [\n\t\t__( 'Suggestion:' ),\n\t\t<span className=\"editor-post-publish-panel__link\" key=\"label\">\n\t\t\t{ __( 'External media' ) }\n\t\t</span>,\n\t];\n\n\t/**\n\t * Update an individual block to point to newly-added library media.\n\t *\n\t * Different blocks use different attribute names, so we need this\n\t * function to ensure we modify the correct attributes for each type.\n\t *\n\t * @param {{name: string, attributes: Object}} block The block.\n\t * @param {{id: number, url: string}} media Media library file info.\n\t */\n\tfunction updateBlockWithUploadedMedia( block, media ) {\n\t\tif ( block.name === 'core/image' || block.name === 'core/cover' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tid: media.id,\n\t\t\t\turl: media.url,\n\t\t\t} );\n\t\t}\n\n\t\tif ( block.name === 'core/media-text' ) {\n\t\t\tupdateBlockAttributes( block.clientId, {\n\t\t\t\tmediaId: media.id,\n\t\t\t\tmediaUrl: media.url,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Handle fetching and uploading all external media in the post.\n\tfunction uploadImages() {\n\t\tsetIsUploading( true );\n\t\tsetHadUploadError( false );\n\n\t\t// Multiple blocks can be using the same URL, so we\n\t\t// should ensure we only fetch and upload each of them once.\n\t\tconst mediaUrls = new Set(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\t\t\t\treturn url;\n\t\t\t} )\n\t\t);\n\n\t\t// Create an upload promise for each URL, that we can wait for in all\n\t\t// blocks that make use of that media.\n\t\tconst uploadPromises = Object.fromEntries(\n\t\t\tObject.entries( fetchMedia( [ ...mediaUrls ] ) ).map(\n\t\t\t\t( [ url, filePromise ] ) => {\n\t\t\t\t\tconst uploadPromise = filePromise.then(\n\t\t\t\t\t\t( blob ) =>\n\t\t\t\t\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\t\t\t\t\tmediaUpload( {\n\t\t\t\t\t\t\t\t\tfilesList: [ blob ],\n\t\t\t\t\t\t\t\t\tonFileChange: ( [ media ] ) => {\n\t\t\t\t\t\t\t\t\t\tif ( isBlobURL( media.url ) ) {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\tresolve( media );\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tonError() {\n\t\t\t\t\t\t\t\t\t\treject();\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);\n\n\t\t\t\t\treturn [ url, uploadPromise ];\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\n\t\t// Wait for all blocks to be updated with library media.\n\t\tPromise.allSettled(\n\t\t\tblocksWithExternalMedia.map( ( block ) => {\n\t\t\t\tconst { url } = getMediaInfo( block );\n\n\t\t\t\treturn uploadPromises[ url ]\n\t\t\t\t\t.then( ( media ) =>\n\t\t\t\t\t\tupdateBlockWithUploadedMedia( block, media )\n\t\t\t\t\t)\n\t\t\t\t\t.then( () => setIsAnimating( true ) )\n\t\t\t\t\t.catch( () => setHadUploadError( true ) );\n\t\t\t} )\n\t\t).finally( () => {\n\t\t\tsetIsUploading( false );\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PanelBody initialOpen title={ panelBodyTitle }>\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<div\n\t\t\t\tstyle={ {\n\t\t\t\t\tdisplay: 'inline-flex',\n\t\t\t\t\tflexWrap: 'wrap',\n\t\t\t\t\tgap: '8px',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<AnimatePresence\n\t\t\t\t\tonExitComplete={ () => setIsAnimating( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ blocksWithExternalMedia.map( ( block ) => {\n\t\t\t\t\t\tconst { url, alt } = getMediaInfo( block );\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\t\tkey={ block.clientId }\n\t\t\t\t\t\t\t\tclientId={ block.clientId }\n\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\talt={ alt }\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</AnimatePresence>\n\t\t\t\t{ isUploading || isAnimating ? (\n\t\t\t\t\t<Spinner />\n\t\t\t\t) : (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ uploadImages }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Upload' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ hadUploadError && <p>{ __( 'Upload failed, try again.' ) }</p> }\n\t\t</PanelBody>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,SAAS,EACTC,MAAM,EACNC,OAAO,EACPC,gBAAgB,IAAIC,MAAM,EAC1BC,yBAAyB,IAAIC,eAAe,QACtC,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ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,QAAQ,EAAGf,KAAK,CAACe,QAAU;YAC3BT,GAAG,EAAGA,GAAK;YACXM,GAAG,EAAGA;UAAK,GAHLZ,KAAK,CAACe,QAIZ,CAAC;QAEJ,CAAE;MAAC,CACa,CAAC,EAChBuB,WAAW,IAAIE,WAAW,gBAC3B/C,IAAA,CAACd,OAAO,IAAE,CAAC,gBAEXc,IAAA,CAACf,MAAM;QACN2G,IAAI,EAAC,SAAS;QACdC,OAAO,EAAC,SAAS;QACjBlE,OAAO,EAAGsC,YAAc;QAAAH,QAAA,EAEtBrE,EAAE,CAAE,QAAS;MAAC,CACT,CACR;IAAA,CACG,CAAC,EACJwD,cAAc,iBAAIjD,IAAA;MAAA8D,QAAA,EAAKrE,EAAE,CAAE,2BAA4B;IAAC,CAAK,CAAC;EAAA,CACtD,CAAC;AAEd","ignoreList":[]}
@@ -1,4 +1,3 @@
1
- /* wp:polyfill */
2
1
  /**
3
2
  * External dependencies
4
3
  */
@@ -1 +1 @@
1
- {"version":3,"names":["v4","uuid","getFilename","generateUniqueBasenames","urls","basenames","Set","Object","fromEntries","map","url","filename","basename","parts","split","length","pop","join","has","add","fetchMedia","entries","filePromise","window","fetch","includes","then","response","blob","File","type"],"sources":["@wordpress/editor/src/components/post-publish-panel/media-util.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Generate a list of unique basenames given a list of URLs.\n *\n * We want all basenames to be unique, since sometimes the extension\n * doesn't reflect the mime type, and may end up getting changed by\n * the server, on upload.\n *\n * @param {string[]} urls The list of URLs\n * @return {Record< string, string >} A URL => basename record.\n */\nexport function generateUniqueBasenames( urls ) {\n\tconst basenames = new Set();\n\n\treturn Object.fromEntries(\n\t\turls.map( ( url ) => {\n\t\t\t// We prefer to match the remote filename, if possible.\n\t\t\tconst filename = getFilename( url );\n\t\t\tlet basename = '';\n\n\t\t\tif ( filename ) {\n\t\t\t\tconst parts = filename.split( '.' );\n\t\t\t\tif ( parts.length > 1 ) {\n\t\t\t\t\t// Assume the last part is the extension.\n\t\t\t\t\tparts.pop();\n\t\t\t\t}\n\t\t\t\tbasename = parts.join( '.' );\n\t\t\t}\n\n\t\t\tif ( ! basename ) {\n\t\t\t\t// It looks like we don't have a basename, so let's use a UUID.\n\t\t\t\tbasename = uuid();\n\t\t\t}\n\n\t\t\tif ( basenames.has( basename ) ) {\n\t\t\t\t// Append a UUID to deduplicate the basename.\n\t\t\t\t// The server will try to deduplicate on its own if we don't do this,\n\t\t\t\t// but it may run into a race condition\n\t\t\t\t// (see https://github.com/WordPress/gutenberg/issues/64899).\n\t\t\t\t// Deduplicating the filenames before uploading is safer.\n\t\t\t\tbasename = `${ basename }-${ uuid() }`;\n\t\t\t}\n\n\t\t\tbasenames.add( basename );\n\n\t\t\treturn [ url, basename ];\n\t\t} )\n\t);\n}\n\n/**\n * Fetch a list of URLs, turning those into promises for files with\n * unique filenames.\n *\n * @param {string[]} urls The list of URLs\n * @return {Record< string, Promise< File > >} A URL => File promise record.\n */\nexport function fetchMedia( urls ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( generateUniqueBasenames( urls ) ).map(\n\t\t\t( [ url, basename ] ) => {\n\t\t\t\tconst filePromise = window\n\t\t\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t\t.then( ( blob ) => {\n\t\t\t\t\t\t// The server will reject the upload if it doesn't have an extension,\n\t\t\t\t\t\t// even though it'll rewrite the file name to match the mime type.\n\t\t\t\t\t\t// Here we provide it with a safe extension to get it past that check.\n\t\t\t\t\t\treturn new File( [ blob ], `${ basename }.png`, {\n\t\t\t\t\t\t\ttype: blob.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\n\t\t\t\treturn [ url, filePromise ];\n\t\t\t}\n\t\t)\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,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,CAAE,KAAM;IACxB,MAAMU,WAAW,GAAGC,MAAM,CACxBC,KAAK,CAAEd,GAAG,CAACe,QAAQ,CAAE,GAAI,CAAC,GAAGf,GAAG,GAAGA,GAAG,GAAG,GAAI,CAAC,CAC9CgB,IAAI,CAAIC,QAAQ,IAAMA,QAAQ,CAACC,IAAI,CAAC,CAAE,CAAC,CACvCF,IAAI,CAAIE,IAAI,IAAM;MAClB;MACA;MACA;MACA,OAAO,IAAIC,IAAI,CAAE,CAAED,IAAI,CAAE,EAAE,GAAIhB,QAAQ,MAAO,EAAE;QAC/CkB,IAAI,EAAEF,IAAI,CAACE;MACZ,CAAE,CAAC;IACJ,CAAE,CAAC;IAEJ,OAAO,CAAEpB,GAAG,EAAEY,WAAW,CAAE;EAC5B,CACD,CACD,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["v4","uuid","getFilename","generateUniqueBasenames","urls","basenames","Set","Object","fromEntries","map","url","filename","basename","parts","split","length","pop","join","has","add","fetchMedia","entries","filePromise","window","fetch","includes","then","response","blob","File","type"],"sources":["@wordpress/editor/src/components/post-publish-panel/media-util.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Generate a list of unique basenames given a list of URLs.\n *\n * We want all basenames to be unique, since sometimes the extension\n * doesn't reflect the mime type, and may end up getting changed by\n * the server, on upload.\n *\n * @param {string[]} urls The list of URLs\n * @return {Record< string, string >} A URL => basename record.\n */\nexport function generateUniqueBasenames( urls ) {\n\tconst basenames = new Set();\n\n\treturn Object.fromEntries(\n\t\turls.map( ( url ) => {\n\t\t\t// We prefer to match the remote filename, if possible.\n\t\t\tconst filename = getFilename( url );\n\t\t\tlet basename = '';\n\n\t\t\tif ( filename ) {\n\t\t\t\tconst parts = filename.split( '.' );\n\t\t\t\tif ( parts.length > 1 ) {\n\t\t\t\t\t// Assume the last part is the extension.\n\t\t\t\t\tparts.pop();\n\t\t\t\t}\n\t\t\t\tbasename = parts.join( '.' );\n\t\t\t}\n\n\t\t\tif ( ! basename ) {\n\t\t\t\t// It looks like we don't have a basename, so let's use a UUID.\n\t\t\t\tbasename = uuid();\n\t\t\t}\n\n\t\t\tif ( basenames.has( basename ) ) {\n\t\t\t\t// Append a UUID to deduplicate the basename.\n\t\t\t\t// The server will try to deduplicate on its own if we don't do this,\n\t\t\t\t// but it may run into a race condition\n\t\t\t\t// (see https://github.com/WordPress/gutenberg/issues/64899).\n\t\t\t\t// Deduplicating the filenames before uploading is safer.\n\t\t\t\tbasename = `${ basename }-${ uuid() }`;\n\t\t\t}\n\n\t\t\tbasenames.add( basename );\n\n\t\t\treturn [ url, basename ];\n\t\t} )\n\t);\n}\n\n/**\n * Fetch a list of URLs, turning those into promises for files with\n * unique filenames.\n *\n * @param {string[]} urls The list of URLs\n * @return {Record< string, Promise< File > >} A URL => File promise record.\n */\nexport function fetchMedia( urls ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( generateUniqueBasenames( urls ) ).map(\n\t\t\t( [ url, basename ] ) => {\n\t\t\t\tconst filePromise = window\n\t\t\t\t\t.fetch( url.includes( '?' ) ? url : url + '?' )\n\t\t\t\t\t.then( ( response ) => response.blob() )\n\t\t\t\t\t.then( ( blob ) => {\n\t\t\t\t\t\t// The server will reject the upload if it doesn't have an extension,\n\t\t\t\t\t\t// even though it'll rewrite the file name to match the mime type.\n\t\t\t\t\t\t// Here we provide it with a safe extension to get it past that check.\n\t\t\t\t\t\treturn new File( [ blob ], `${ basename }.png`, {\n\t\t\t\t\t\t\ttype: blob.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\n\t\t\t\treturn [ url, filePromise ];\n\t\t\t}\n\t\t)\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,IAAIC,IAAI,QAAQ,MAAM;;AAEjC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,gBAAgB;;AAE5C;AACA;AACA;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I,CAAC,GAAGf,GAAG,GAAGA,GAAG,GAAG,GAAI,CAAC,CAC9CgB,IAAI,CAAIC,QAAQ,IAAMA,QAAQ,CAACC,IAAI,CAAC,CAAE,CAAC,CACvCF,IAAI,CAAIE,IAAI,IAAM;MAClB;MACA;MACA;MACA,OAAO,IAAIC,IAAI,CAAE,CAAED,IAAI,CAAE,EAAE,GAAIhB,QAAQ,MAAO,EAAE;QAC/CkB,IAAI,EAAEF,IAAI,CAACE;MACZ,CAAE,CAAC;IACJ,CAAE,CAAC;IAEJ,OAAO,CAAEpB,GAAG,EAAEY,WAAW,CAAE;EAC5B,CACD,CACD,CAAC;AACF","ignoreList":[]}
@@ -3,8 +3,8 @@
3
3
  */
4
4
  import { PanelBody, Button, TextControl } from '@wordpress/components';
5
5
  import { __, sprintf } from '@wordpress/i18n';
6
- import { Component, createRef } from '@wordpress/element';
7
- import { withSelect } from '@wordpress/data';
6
+ import { useCallback, useEffect, useState, useRef } from '@wordpress/element';
7
+ import { useSelect } from '@wordpress/data';
8
8
  import { addQueryArgs, safeDecodeURIComponent } from '@wordpress/url';
9
9
  import { decodeEntities } from '@wordpress/html-entities';
10
10
  import { useCopyToClipboard } from '@wordpress/compose';
@@ -40,132 +40,118 @@ const getFuturePostUrl = post => {
40
40
  return post.permalink_template;
41
41
  };
42
42
  function CopyButton({
43
- text,
44
- onCopy,
45
- children
43
+ text
46
44
  }) {
47
- const ref = useCopyToClipboard(text, onCopy);
45
+ const [showCopyConfirmation, setShowCopyConfirmation] = useState(false);
46
+ const timeoutIdRef = useRef();
47
+ const ref = useCopyToClipboard(text, () => {
48
+ setShowCopyConfirmation(true);
49
+ if (timeoutIdRef.current) {
50
+ clearTimeout(timeoutIdRef.current);
51
+ }
52
+ timeoutIdRef.current = setTimeout(() => {
53
+ setShowCopyConfirmation(false);
54
+ }, 4000);
55
+ });
56
+ useEffect(() => {
57
+ return () => {
58
+ if (timeoutIdRef.current) {
59
+ clearTimeout(timeoutIdRef.current);
60
+ }
61
+ };
62
+ }, []);
48
63
  return /*#__PURE__*/_jsx(Button, {
49
64
  __next40pxDefaultSize: true,
50
65
  variant: "secondary",
51
66
  ref: ref,
52
- children: children
67
+ children: showCopyConfirmation ? __('Copied!') : __('Copy')
53
68
  });
54
69
  }
55
- class PostPublishPanelPostpublish extends Component {
56
- constructor() {
57
- super(...arguments);
58
- this.state = {
59
- showCopyConfirmation: false
70
+ export default function PostPublishPanelPostpublish({
71
+ focusOnMount,
72
+ children
73
+ }) {
74
+ const {
75
+ post,
76
+ postType,
77
+ isScheduled
78
+ } = useSelect(select => {
79
+ const {
80
+ getEditedPostAttribute,
81
+ getCurrentPost,
82
+ isCurrentPostScheduled
83
+ } = select(editorStore);
84
+ const {
85
+ getPostType
86
+ } = select(coreStore);
87
+ return {
88
+ post: getCurrentPost(),
89
+ postType: getPostType(getEditedPostAttribute('type')),
90
+ isScheduled: isCurrentPostScheduled()
60
91
  };
61
- this.onCopy = this.onCopy.bind(this);
62
- this.onSelectInput = this.onSelectInput.bind(this);
63
- this.postLink = createRef();
64
- }
65
- componentDidMount() {
66
- if (this.props.focusOnMount) {
67
- this.postLink.current.focus();
92
+ }, []);
93
+ const postLabel = postType?.labels?.singular_name;
94
+ const viewPostLabel = postType?.labels?.view_item;
95
+ const addNewPostLabel = postType?.labels?.add_new_item;
96
+ const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
97
+ const addLink = addQueryArgs('post-new.php', {
98
+ post_type: post.type
99
+ });
100
+ const postLinkRef = useCallback(node => {
101
+ if (focusOnMount && node) {
102
+ node.focus();
68
103
  }
69
- }
70
- componentWillUnmount() {
71
- clearTimeout(this.dismissCopyConfirmation);
72
- }
73
- onCopy() {
74
- this.setState({
75
- showCopyConfirmation: true
76
- });
77
- clearTimeout(this.dismissCopyConfirmation);
78
- this.dismissCopyConfirmation = setTimeout(() => {
79
- this.setState({
80
- showCopyConfirmation: false
81
- });
82
- }, 4000);
83
- }
84
- onSelectInput(event) {
85
- event.target.select();
86
- }
87
- render() {
88
- const {
89
- children,
90
- isScheduled,
91
- post,
92
- postType
93
- } = this.props;
94
- const postLabel = postType?.labels?.singular_name;
95
- const viewPostLabel = postType?.labels?.view_item;
96
- const addNewPostLabel = postType?.labels?.add_new_item;
97
- const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
98
- const addLink = addQueryArgs('post-new.php', {
99
- post_type: post.type
100
- });
101
- const postPublishNonLinkHeader = isScheduled ? /*#__PURE__*/_jsxs(_Fragment, {
102
- children: [__('is now scheduled. It will go live on'), ' ', /*#__PURE__*/_jsx(PostScheduleLabel, {}), "."]
103
- }) : __('is now live.');
104
- return /*#__PURE__*/_jsxs("div", {
105
- className: "post-publish-panel__postpublish",
106
- children: [/*#__PURE__*/_jsxs(PanelBody, {
107
- className: "post-publish-panel__postpublish-header",
108
- children: [/*#__PURE__*/_jsx("a", {
109
- ref: this.postLink,
110
- href: link,
111
- children: decodeEntities(post.title) || __('(no title)')
112
- }), ' ', postPublishNonLinkHeader]
113
- }), /*#__PURE__*/_jsxs(PanelBody, {
114
- children: [/*#__PURE__*/_jsx("p", {
115
- className: "post-publish-panel__postpublish-subheader",
116
- children: /*#__PURE__*/_jsx("strong", {
117
- children: __('What’s next?')
104
+ }, [focusOnMount]);
105
+ const postPublishNonLinkHeader = isScheduled ? /*#__PURE__*/_jsxs(_Fragment, {
106
+ children: [__('is now scheduled. It will go live on'), ' ', /*#__PURE__*/_jsx(PostScheduleLabel, {}), "."]
107
+ }) : __('is now live.');
108
+ return /*#__PURE__*/_jsxs("div", {
109
+ className: "post-publish-panel__postpublish",
110
+ children: [/*#__PURE__*/_jsxs(PanelBody, {
111
+ className: "post-publish-panel__postpublish-header",
112
+ children: [/*#__PURE__*/_jsx("a", {
113
+ ref: postLinkRef,
114
+ href: link,
115
+ children: decodeEntities(post.title) || __('(no title)')
116
+ }), ' ', postPublishNonLinkHeader]
117
+ }), /*#__PURE__*/_jsxs(PanelBody, {
118
+ children: [/*#__PURE__*/_jsx("p", {
119
+ className: "post-publish-panel__postpublish-subheader",
120
+ children: /*#__PURE__*/_jsx("strong", {
121
+ children: __('What’s next?')
122
+ })
123
+ }), /*#__PURE__*/_jsxs("div", {
124
+ className: "post-publish-panel__postpublish-post-address-container",
125
+ children: [/*#__PURE__*/_jsx(TextControl, {
126
+ __next40pxDefaultSize: true,
127
+ __nextHasNoMarginBottom: true,
128
+ className: "post-publish-panel__postpublish-post-address",
129
+ readOnly: true,
130
+ label: sprintf(/* translators: %s: post type singular name */
131
+ __('%s address'), postLabel),
132
+ value: safeDecodeURIComponent(link),
133
+ onFocus: event => event.target.select()
134
+ }), /*#__PURE__*/_jsx("div", {
135
+ className: "post-publish-panel__postpublish-post-address__copy-button-wrap",
136
+ children: /*#__PURE__*/_jsx(CopyButton, {
137
+ text: link
118
138
  })
119
- }), /*#__PURE__*/_jsxs("div", {
120
- className: "post-publish-panel__postpublish-post-address-container",
121
- children: [/*#__PURE__*/_jsx(TextControl, {
122
- __next40pxDefaultSize: true,
123
- __nextHasNoMarginBottom: true,
124
- className: "post-publish-panel__postpublish-post-address",
125
- readOnly: true,
126
- label: sprintf(/* translators: %s: post type singular name */
127
- __('%s address'), postLabel),
128
- value: safeDecodeURIComponent(link),
129
- onFocus: this.onSelectInput
130
- }), /*#__PURE__*/_jsx("div", {
131
- className: "post-publish-panel__postpublish-post-address__copy-button-wrap",
132
- children: /*#__PURE__*/_jsx(CopyButton, {
133
- text: link,
134
- onCopy: this.onCopy,
135
- children: this.state.showCopyConfirmation ? __('Copied!') : __('Copy')
136
- })
137
- })]
138
- }), /*#__PURE__*/_jsxs("div", {
139
- className: "post-publish-panel__postpublish-buttons",
140
- children: [!isScheduled && /*#__PURE__*/_jsx(Button, {
141
- variant: "primary",
142
- href: link,
143
- __next40pxDefaultSize: true,
144
- children: viewPostLabel
145
- }), /*#__PURE__*/_jsx(Button, {
146
- variant: isScheduled ? 'primary' : 'secondary',
147
- __next40pxDefaultSize: true,
148
- href: addLink,
149
- children: addNewPostLabel
150
- })]
151
139
  })]
152
- }), children]
153
- });
154
- }
140
+ }), /*#__PURE__*/_jsxs("div", {
141
+ className: "post-publish-panel__postpublish-buttons",
142
+ children: [!isScheduled && /*#__PURE__*/_jsx(Button, {
143
+ variant: "primary",
144
+ href: link,
145
+ __next40pxDefaultSize: true,
146
+ children: viewPostLabel
147
+ }), /*#__PURE__*/_jsx(Button, {
148
+ variant: isScheduled ? 'primary' : 'secondary',
149
+ __next40pxDefaultSize: true,
150
+ href: addLink,
151
+ children: addNewPostLabel
152
+ })]
153
+ })]
154
+ }), children]
155
+ });
155
156
  }
156
- export default withSelect(select => {
157
- const {
158
- getEditedPostAttribute,
159
- getCurrentPost,
160
- isCurrentPostScheduled
161
- } = select(editorStore);
162
- const {
163
- getPostType
164
- } = select(coreStore);
165
- return {
166
- post: getCurrentPost(),
167
- postType: getPostType(getEditedPostAttribute('type')),
168
- isScheduled: isCurrentPostScheduled()
169
- };
170
- })(PostPublishPanelPostpublish);
171
157
  //# sourceMappingURL=postpublish.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PanelBody","Button","TextControl","__","sprintf","Component","createRef","withSelect","addQueryArgs","safeDecodeURIComponent","decodeEntities","useCopyToClipboard","store","coreStore","PostScheduleLabel","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","POSTNAME","PAGENAME","getFuturePostUrl","post","slug","permalink_template","includes","replace","CopyButton","text","onCopy","children","ref","__next40pxDefaultSize","variant","PostPublishPanelPostpublish","constructor","arguments","state","showCopyConfirmation","bind","onSelectInput","postLink","componentDidMount","props","focusOnMount","current","focus","componentWillUnmount","clearTimeout","dismissCopyConfirmation","setState","setTimeout","event","target","select","render","isScheduled","postType","postLabel","labels","singular_name","viewPostLabel","view_item","addNewPostLabel","add_new_item","link","status","addLink","post_type","type","postPublishNonLinkHeader","className","href","title","__nextHasNoMarginBottom","readOnly","label","value","onFocus","getEditedPostAttribute","getCurrentPost","isCurrentPostScheduled","getPostType"],"sources":["@wordpress/editor/src/components/post-publish-panel/postpublish.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody, Button, TextControl } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { addQueryArgs, safeDecodeURIComponent } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostScheduleLabel from '../post-schedule/label';\nimport { store as editorStore } from '../../store';\n\nconst POSTNAME = '%postname%';\nconst PAGENAME = '%pagename%';\n\n/**\n * Returns URL for a future post.\n *\n * @param {Object} post Post object.\n *\n * @return {string} PostPublish URL.\n */\n\nconst getFuturePostUrl = ( post ) => {\n\tconst { slug } = post;\n\n\tif ( post.permalink_template.includes( POSTNAME ) ) {\n\t\treturn post.permalink_template.replace( POSTNAME, slug );\n\t}\n\n\tif ( post.permalink_template.includes( PAGENAME ) ) {\n\t\treturn post.permalink_template.replace( PAGENAME, slug );\n\t}\n\n\treturn post.permalink_template;\n};\n\nfunction CopyButton( { text, onCopy, children } ) {\n\tconst ref = useCopyToClipboard( text, onCopy );\n\treturn (\n\t\t<Button __next40pxDefaultSize variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nclass PostPublishPanelPostpublish extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.state = {\n\t\t\tshowCopyConfirmation: false,\n\t\t};\n\t\tthis.onCopy = this.onCopy.bind( this );\n\t\tthis.onSelectInput = this.onSelectInput.bind( this );\n\t\tthis.postLink = createRef();\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.focusOnMount ) {\n\t\t\tthis.postLink.current.focus();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.dismissCopyConfirmation );\n\t}\n\n\tonCopy() {\n\t\tthis.setState( {\n\t\t\tshowCopyConfirmation: true,\n\t\t} );\n\n\t\tclearTimeout( this.dismissCopyConfirmation );\n\t\tthis.dismissCopyConfirmation = setTimeout( () => {\n\t\t\tthis.setState( {\n\t\t\t\tshowCopyConfirmation: false,\n\t\t\t} );\n\t\t}, 4000 );\n\t}\n\n\tonSelectInput( event ) {\n\t\tevent.target.select();\n\t}\n\n\trender() {\n\t\tconst { children, isScheduled, post, postType } = this.props;\n\t\tconst postLabel = postType?.labels?.singular_name;\n\t\tconst viewPostLabel = postType?.labels?.view_item;\n\t\tconst addNewPostLabel = postType?.labels?.add_new_item;\n\t\tconst link =\n\t\t\tpost.status === 'future' ? getFuturePostUrl( post ) : post.link;\n\t\tconst addLink = addQueryArgs( 'post-new.php', {\n\t\t\tpost_type: post.type,\n\t\t} );\n\n\t\tconst postPublishNonLinkHeader = isScheduled ? (\n\t\t\t<>\n\t\t\t\t{ __( 'is now scheduled. It will go live on' ) }{ ' ' }\n\t\t\t\t<PostScheduleLabel />.\n\t\t\t</>\n\t\t) : (\n\t\t\t__( 'is now live.' )\n\t\t);\n\n\t\treturn (\n\t\t\t<div className=\"post-publish-panel__postpublish\">\n\t\t\t\t<PanelBody className=\"post-publish-panel__postpublish-header\">\n\t\t\t\t\t<a ref={ this.postLink } href={ link }>\n\t\t\t\t\t\t{ decodeEntities( post.title ) || __( '(no title)' ) }\n\t\t\t\t\t</a>{ ' ' }\n\t\t\t\t\t{ postPublishNonLinkHeader }\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<p className=\"post-publish-panel__postpublish-subheader\">\n\t\t\t\t\t\t<strong>{ __( 'What’s next?' ) }</strong>\n\t\t\t\t\t</p>\n\t\t\t\t\t<div className=\"post-publish-panel__postpublish-post-address-container\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tclassName=\"post-publish-panel__postpublish-post-address\"\n\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: post type singular name */\n\t\t\t\t\t\t\t\t__( '%s address' ),\n\t\t\t\t\t\t\t\tpostLabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ safeDecodeURIComponent( link ) }\n\t\t\t\t\t\t\tonFocus={ this.onSelectInput }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<div className=\"post-publish-panel__postpublish-post-address__copy-button-wrap\">\n\t\t\t\t\t\t\t<CopyButton text={ link } onCopy={ this.onCopy }>\n\t\t\t\t\t\t\t\t{ this.state.showCopyConfirmation\n\t\t\t\t\t\t\t\t\t? __( 'Copied!' )\n\t\t\t\t\t\t\t\t\t: __( 'Copy' ) }\n\t\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"post-publish-panel__postpublish-buttons\">\n\t\t\t\t\t\t{ ! isScheduled && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\thref={ link }\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ viewPostLabel }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant={ isScheduled ? 'primary' : 'secondary' }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\thref={ addLink }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ addNewPostLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</PanelBody>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getEditedPostAttribute, getCurrentPost, isCurrentPostScheduled } =\n\t\tselect( editorStore );\n\tconst { getPostType } = select( coreStore );\n\n\treturn {\n\t\tpost: getCurrentPost(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tisScheduled: isCurrentPostScheduled(),\n\t};\n} )( PostPublishPanelPostpublish );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,QAAQ,uBAAuB;AACtE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,EAAEC,SAAS,QAAQ,oBAAoB;AACzD,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,YAAY,EAAEC,sBAAsB,QAAQ,gBAAgB;AACrE,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASF,KAAK,IAAIG,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEnD,MAAMC,QAAQ,GAAG,YAAY;AAC7B,MAAMC,QAAQ,GAAG,YAAY;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,gBAAgB,GAAKC,IAAI,IAAM;EACpC,MAAM;IAAEC;EAAK,CAAC,GAAGD,IAAI;EAErB,IAAKA,IAAI,CAACE,kBAAkB,CAACC,QAAQ,CAAEN,QAAS,CAAC,EAAG;IACnD,OAAOG,IAAI,CAACE,kBAAkB,CAACE,OAAO,CAAEP,QAAQ,EAAEI,IAAK,CAAC;EACzD;EAEA,IAAKD,IAAI,CAACE,kBAAkB,CAACC,QAAQ,CAAEL,QAAS,CAAC,EAAG;IACnD,OAAOE,IAAI,CAACE,kBAAkB,CAACE,OAAO,CAAEN,QAAQ,EAAEG,IAAK,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ACL,CAAC;MAAA,CACI,CAAC,EACVjC,QAAQ;IAAA,CACN,CAAC;EAER;AACD;AAEA,eAAe1B,UAAU,CAAIkD,MAAM,IAAM;EACxC,MAAM;IAAEyB,sBAAsB;IAAEC,cAAc;IAAEC;EAAuB,CAAC,GACvE3B,MAAM,CAAE1C,WAAY,CAAC;EACtB,MAAM;IAAEsE;EAAY,CAAC,GAAG5B,MAAM,CAAE5C,SAAU,CAAC;EAE3C,OAAO;IACNY,IAAI,EAAE0D,cAAc,CAAC,CAAC;IACtBvB,QAAQ,EAAEyB,WAAW,CAAEH,sBAAsB,CAAE,MAAO,CAAE,CAAC;IACzDvB,WAAW,EAAEyB,sBAAsB,CAAC;EACrC,CAAC;AACF,CAAE,CAAC,CAAE/C,2BAA4B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["PanelBody","Button","TextControl","__","sprintf","useCallback","useEffect","useState","useRef","useSelect","addQueryArgs","safeDecodeURIComponent","decodeEntities","useCopyToClipboard","store","coreStore","PostScheduleLabel","editorStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","POSTNAME","PAGENAME","getFuturePostUrl","post","slug","permalink_template","includes","replace","CopyButton","text","showCopyConfirmation","setShowCopyConfirmation","timeoutIdRef","ref","current","clearTimeout","setTimeout","__next40pxDefaultSize","variant","children","PostPublishPanelPostpublish","focusOnMount","postType","isScheduled","select","getEditedPostAttribute","getCurrentPost","isCurrentPostScheduled","getPostType","postLabel","labels","singular_name","viewPostLabel","view_item","addNewPostLabel","add_new_item","link","status","addLink","post_type","type","postLinkRef","node","focus","postPublishNonLinkHeader","className","href","title","__nextHasNoMarginBottom","readOnly","label","value","onFocus","event","target"],"sources":["@wordpress/editor/src/components/post-publish-panel/postpublish.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody, Button, TextControl } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useEffect, useState, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { addQueryArgs, safeDecodeURIComponent } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostScheduleLabel from '../post-schedule/label';\nimport { store as editorStore } from '../../store';\n\nconst POSTNAME = '%postname%';\nconst PAGENAME = '%pagename%';\n\n/**\n * Returns URL for a future post.\n *\n * @param {Object} post Post object.\n *\n * @return {string} PostPublish URL.\n */\n\nconst getFuturePostUrl = ( post ) => {\n\tconst { slug } = post;\n\n\tif ( post.permalink_template.includes( POSTNAME ) ) {\n\t\treturn post.permalink_template.replace( POSTNAME, slug );\n\t}\n\n\tif ( post.permalink_template.includes( PAGENAME ) ) {\n\t\treturn post.permalink_template.replace( PAGENAME, slug );\n\t}\n\n\treturn post.permalink_template;\n};\n\nfunction CopyButton( { text } ) {\n\tconst [ showCopyConfirmation, setShowCopyConfirmation ] = useState( false );\n\tconst timeoutIdRef = useRef();\n\tconst ref = useCopyToClipboard( text, () => {\n\t\tsetShowCopyConfirmation( true );\n\t\tif ( timeoutIdRef.current ) {\n\t\t\tclearTimeout( timeoutIdRef.current );\n\t\t}\n\t\ttimeoutIdRef.current = setTimeout( () => {\n\t\t\tsetShowCopyConfirmation( false );\n\t\t}, 4000 );\n\t} );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( timeoutIdRef.current ) {\n\t\t\t\tclearTimeout( timeoutIdRef.current );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Button __next40pxDefaultSize variant=\"secondary\" ref={ ref }>\n\t\t\t{ showCopyConfirmation ? __( 'Copied!' ) : __( 'Copy' ) }\n\t\t</Button>\n\t);\n}\n\nexport default function PostPublishPanelPostpublish( {\n\tfocusOnMount,\n\tchildren,\n} ) {\n\tconst { post, postType, isScheduled } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetCurrentPost,\n\t\t\tisCurrentPostScheduled,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\tpost: getCurrentPost(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t};\n\t}, [] );\n\n\tconst postLabel = postType?.labels?.singular_name;\n\tconst viewPostLabel = postType?.labels?.view_item;\n\tconst addNewPostLabel = postType?.labels?.add_new_item;\n\tconst link =\n\t\tpost.status === 'future' ? getFuturePostUrl( post ) : post.link;\n\tconst addLink = addQueryArgs( 'post-new.php', {\n\t\tpost_type: post.type,\n\t} );\n\n\tconst postLinkRef = useCallback(\n\t\t( node ) => {\n\t\t\tif ( focusOnMount && node ) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t},\n\t\t[ focusOnMount ]\n\t);\n\n\tconst postPublishNonLinkHeader = isScheduled ? (\n\t\t<>\n\t\t\t{ __( 'is now scheduled. It will go live on' ) }{ ' ' }\n\t\t\t<PostScheduleLabel />.\n\t\t</>\n\t) : (\n\t\t__( 'is now live.' )\n\t);\n\n\treturn (\n\t\t<div className=\"post-publish-panel__postpublish\">\n\t\t\t<PanelBody className=\"post-publish-panel__postpublish-header\">\n\t\t\t\t<a ref={ postLinkRef } href={ link }>\n\t\t\t\t\t{ decodeEntities( post.title ) || __( '(no title)' ) }\n\t\t\t\t</a>{ ' ' }\n\t\t\t\t{ postPublishNonLinkHeader }\n\t\t\t</PanelBody>\n\t\t\t<PanelBody>\n\t\t\t\t<p className=\"post-publish-panel__postpublish-subheader\">\n\t\t\t\t\t<strong>{ __( 'What’s next?' ) }</strong>\n\t\t\t\t</p>\n\t\t\t\t<div className=\"post-publish-panel__postpublish-post-address-container\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tclassName=\"post-publish-panel__postpublish-post-address\"\n\t\t\t\t\t\treadOnly\n\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: post type singular name */\n\t\t\t\t\t\t\t__( '%s address' ),\n\t\t\t\t\t\t\tpostLabel\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ safeDecodeURIComponent( link ) }\n\t\t\t\t\t\tonFocus={ ( event ) => event.target.select() }\n\t\t\t\t\t/>\n\n\t\t\t\t\t<div className=\"post-publish-panel__postpublish-post-address__copy-button-wrap\">\n\t\t\t\t\t\t<CopyButton text={ link } />\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\n\t\t\t\t<div className=\"post-publish-panel__postpublish-buttons\">\n\t\t\t\t\t{ ! isScheduled && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\thref={ link }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ viewPostLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant={ isScheduled ? 'primary' : 'secondary' }\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\thref={ addLink }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ addNewPostLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t</PanelBody>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,WAAW,QAAQ,uBAAuB;AACtE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AAC7E,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,EAAEC,sBAAsB,QAAQ,gBAAgB;AACrE,SAASC,cAAc,QAAQ,0BAA0B;AACz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B;UACvBH,SAAS,EAAC,8CAA8C;UACxDI,QAAQ;UACRC,KAAK,EAAGtE,OAAO,CACd;UACAD,EAAE,CAAE,YAAa,CAAC,EAClBkD,SACD,CAAG;UACHsB,KAAK,EAAGhE,sBAAsB,CAAEiD,IAAK,CAAG;UACxCgB,OAAO,EAAKC,KAAK,IAAMA,KAAK,CAACC,MAAM,CAAC9B,MAAM,CAAC;QAAG,CAC9C,CAAC,eAEF7B,IAAA;UAAKkD,SAAS,EAAC,gEAAgE;UAAA1B,QAAA,eAC9ExB,IAAA,CAACa,UAAU;YAACC,IAAI,EAAG2B;UAAM,CAAE;QAAC,CACxB,CAAC;MAAA,CACF,CAAC,eAENrC,KAAA;QAAK8C,SAAS,EAAC,yCAAyC;QAAA1B,QAAA,GACrD,CAAEI,WAAW,iBACd5B,IAAA,CAAClB,MAAM;UACNyC,OAAO,EAAC,SAAS;UACjB4B,IAAI,EAAGV,IAAM;UACbnB,qBAAqB;UAAAE,QAAA,EAEnBa;QAAa,CACR,CACR,eACDrC,IAAA,CAAClB,MAAM;UACNyC,OAAO,EAAGK,WAAW,GAAG,SAAS,GAAG,WAAa;UACjDN,qBAAqB;UACrB6B,IAAI,EAAGR,OAAS;UAAAnB,QAAA,EAEde;QAAe,CACV,CAAC;MAAA,CACL,CAAC;IAAA,CACI,CAAC,EACVf,QAAQ;EAAA,CACN,CAAC;AAER","ignoreList":[]}
@@ -70,7 +70,7 @@ function PostPublishPanelPrepublish({
70
70
  let prePublishTitle, prePublishBodyText;
71
71
  if (!hasPublishAction) {
72
72
  prePublishTitle = __('Are you ready to submit for review?');
73
- prePublishBodyText = __('When you’re ready, submit your work for review, and an Editor will be able to approve it for you.');
73
+ prePublishBodyText = __('Your work will be reviewed and then approved.');
74
74
  } else if (isBeingScheduled) {
75
75
  prePublishTitle = __('Are you ready to schedule?');
76
76
  prePublishBodyText = __('Your work will be published at the specified date and time.');
@@ -1 +1 @@
1
- {"version":3,"names":["__","Icon","PanelBody","useSelect","wordpress","filterURLForDisplay","store","coreStore","decodeEntities","PostVisibility","PostVisibilityLabel","PostSchedule","PostScheduleLabel","MaybeTagsPanel","MaybePostFormatPanel","editorStore","MaybeCategoryPanel","MaybeUploadMedia","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","PostPublishPanelPrepublish","children","isBeingScheduled","isRequestingSiteIcon","hasPublishAction","siteIconUrl","siteTitle","siteHome","select","_getCurrentPost$_link","getCurrentPost","isEditedPostBeingScheduled","getEntityRecord","isResolving","siteData","undefined","_links","site_icon_url","name","home","siteIcon","className","size","icon","alt","src","prePublishTitle","prePublishBodyText","initialOpen","title"],"sources":["@wordpress/editor/src/components/post-publish-panel/prepublish.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, PanelBody } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { wordpress } from '@wordpress/icons';\nimport { filterURLForDisplay } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport PostVisibility from '../post-visibility';\nimport PostVisibilityLabel from '../post-visibility/label';\nimport PostSchedule from '../post-schedule';\nimport PostScheduleLabel from '../post-schedule/label';\nimport MaybeTagsPanel from './maybe-tags-panel';\nimport MaybePostFormatPanel from './maybe-post-format-panel';\nimport { store as editorStore } from '../../store';\nimport MaybeCategoryPanel from './maybe-category-panel';\nimport MaybeUploadMedia from './maybe-upload-media';\n\nfunction PostPublishPanelPrepublish( { children } ) {\n\tconst {\n\t\tisBeingScheduled,\n\t\tisRequestingSiteIcon,\n\t\thasPublishAction,\n\t\tsiteIconUrl,\n\t\tsiteTitle,\n\t\tsiteHome,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentPost, isEditedPostBeingScheduled } =\n\t\t\tselect( editorStore );\n\t\tconst { getEntityRecord, isResolving } = select( coreStore );\n\t\tconst siteData =\n\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\treturn {\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tisRequestingSiteIcon: isResolving( 'getEntityRecord', [\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase',\n\t\t\t\tundefined,\n\t\t\t] ),\n\t\t\tsiteIconUrl: siteData.site_icon_url,\n\t\t\tsiteTitle: siteData.name,\n\t\t\tsiteHome: siteData.home && filterURLForDisplay( siteData.home ),\n\t\t};\n\t}, [] );\n\n\tlet siteIcon = (\n\t\t<Icon className=\"components-site-icon\" size=\"36px\" icon={ wordpress } />\n\t);\n\n\tif ( siteIconUrl ) {\n\t\tsiteIcon = (\n\t\t\t<img\n\t\t\t\talt={ __( 'Site Icon' ) }\n\t\t\t\tclassName=\"components-site-icon\"\n\t\t\t\tsrc={ siteIconUrl }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( isRequestingSiteIcon ) {\n\t\tsiteIcon = null;\n\t}\n\n\tlet prePublishTitle, prePublishBodyText;\n\n\tif ( ! hasPublishAction ) {\n\t\tprePublishTitle = __( 'Are you ready to submit for review?' );\n\t\tprePublishBodyText = __(\n\t\t\t'When you’re ready, submit your work for review, and an Editor will be able to approve it for you.'\n\t\t);\n\t} else if ( isBeingScheduled ) {\n\t\tprePublishTitle = __( 'Are you ready to schedule?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Your work will be published at the specified date and time.'\n\t\t);\n\t} else {\n\t\tprePublishTitle = __( 'Are you ready to publish?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Double-check your settings before publishing.'\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"editor-post-publish-panel__prepublish\">\n\t\t\t<div>\n\t\t\t\t<strong>{ prePublishTitle }</strong>\n\t\t\t</div>\n\t\t\t<p>{ prePublishBodyText }</p>\n\t\t\t<div className=\"components-site-card\">\n\t\t\t\t{ siteIcon }\n\t\t\t\t<div className=\"components-site-info\">\n\t\t\t\t\t<span className=\"components-site-name\">\n\t\t\t\t\t\t{ decodeEntities( siteTitle ) || __( '(Untitled)' ) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"components-site-home\">{ siteHome }</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<MaybeUploadMedia />\n\t\t\t{ hasPublishAction && (\n\t\t\t\t<>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t\ttitle={ [\n\t\t\t\t\t\t\t__( 'Visibility:' ),\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"editor-post-publish-panel__link\"\n\t\t\t\t\t\t\t\tkey=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostVisibilityLabel />\n\t\t\t\t\t\t\t</span>,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostVisibility />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t\ttitle={ [\n\t\t\t\t\t\t\t__( 'Publish:' ),\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"editor-post-publish-panel__link\"\n\t\t\t\t\t\t\t\tkey=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostScheduleLabel />\n\t\t\t\t\t\t\t</span>,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostSchedule />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<MaybePostFormatPanel />\n\t\t\t<MaybeTagsPanel />\n\t\t\t<MaybeCategoryPanel />\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default PostPublishPanelPrepublish;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAAS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AAA,CAACL,oBAAoB,IAAE,CAAC,eACxBK,IAAA,CAACN,cAAc,IAAE,CAAC,eAClBM,IAAA,CAACH,kBAAkB,IAAE,CAAC,EACpBS,QAAQ;EAAA,CACN,CAAC;AAER;AAEA,eAAeD,0BAA0B","ignoreList":[]}
1
+ {"version":3,"names":["__","Icon","PanelBody","useSelect","wordpress","filterURLForDisplay","store","coreStore","decodeEntities","PostVisibility","PostVisibilityLabel","PostSchedule","PostScheduleLabel","MaybeTagsPanel","MaybePostFormatPanel","editorStore","MaybeCategoryPanel","MaybeUploadMedia","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","PostPublishPanelPrepublish","children","isBeingScheduled","isRequestingSiteIcon","hasPublishAction","siteIconUrl","siteTitle","siteHome","select","_getCurrentPost$_link","getCurrentPost","isEditedPostBeingScheduled","getEntityRecord","isResolving","siteData","undefined","_links","site_icon_url","name","home","siteIcon","className","size","icon","alt","src","prePublishTitle","prePublishBodyText","initialOpen","title"],"sources":["@wordpress/editor/src/components/post-publish-panel/prepublish.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, PanelBody } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { wordpress } from '@wordpress/icons';\nimport { filterURLForDisplay } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport PostVisibility from '../post-visibility';\nimport PostVisibilityLabel from '../post-visibility/label';\nimport PostSchedule from '../post-schedule';\nimport PostScheduleLabel from '../post-schedule/label';\nimport MaybeTagsPanel from './maybe-tags-panel';\nimport MaybePostFormatPanel from './maybe-post-format-panel';\nimport { store as editorStore } from '../../store';\nimport MaybeCategoryPanel from './maybe-category-panel';\nimport MaybeUploadMedia from './maybe-upload-media';\n\nfunction PostPublishPanelPrepublish( { children } ) {\n\tconst {\n\t\tisBeingScheduled,\n\t\tisRequestingSiteIcon,\n\t\thasPublishAction,\n\t\tsiteIconUrl,\n\t\tsiteTitle,\n\t\tsiteHome,\n\t} = useSelect( ( select ) => {\n\t\tconst { getCurrentPost, isEditedPostBeingScheduled } =\n\t\t\tselect( editorStore );\n\t\tconst { getEntityRecord, isResolving } = select( coreStore );\n\t\tconst siteData =\n\t\t\tgetEntityRecord( 'root', '__unstableBase', undefined ) || {};\n\n\t\treturn {\n\t\t\thasPublishAction:\n\t\t\t\tgetCurrentPost()._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\tisBeingScheduled: isEditedPostBeingScheduled(),\n\t\t\tisRequestingSiteIcon: isResolving( 'getEntityRecord', [\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase',\n\t\t\t\tundefined,\n\t\t\t] ),\n\t\t\tsiteIconUrl: siteData.site_icon_url,\n\t\t\tsiteTitle: siteData.name,\n\t\t\tsiteHome: siteData.home && filterURLForDisplay( siteData.home ),\n\t\t};\n\t}, [] );\n\n\tlet siteIcon = (\n\t\t<Icon className=\"components-site-icon\" size=\"36px\" icon={ wordpress } />\n\t);\n\n\tif ( siteIconUrl ) {\n\t\tsiteIcon = (\n\t\t\t<img\n\t\t\t\talt={ __( 'Site Icon' ) }\n\t\t\t\tclassName=\"components-site-icon\"\n\t\t\t\tsrc={ siteIconUrl }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( isRequestingSiteIcon ) {\n\t\tsiteIcon = null;\n\t}\n\n\tlet prePublishTitle, prePublishBodyText;\n\n\tif ( ! hasPublishAction ) {\n\t\tprePublishTitle = __( 'Are you ready to submit for review?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Your work will be reviewed and then approved.'\n\t\t);\n\t} else if ( isBeingScheduled ) {\n\t\tprePublishTitle = __( 'Are you ready to schedule?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Your work will be published at the specified date and time.'\n\t\t);\n\t} else {\n\t\tprePublishTitle = __( 'Are you ready to publish?' );\n\t\tprePublishBodyText = __(\n\t\t\t'Double-check your settings before publishing.'\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"editor-post-publish-panel__prepublish\">\n\t\t\t<div>\n\t\t\t\t<strong>{ prePublishTitle }</strong>\n\t\t\t</div>\n\t\t\t<p>{ prePublishBodyText }</p>\n\t\t\t<div className=\"components-site-card\">\n\t\t\t\t{ siteIcon }\n\t\t\t\t<div className=\"components-site-info\">\n\t\t\t\t\t<span className=\"components-site-name\">\n\t\t\t\t\t\t{ decodeEntities( siteTitle ) || __( '(Untitled)' ) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<span className=\"components-site-home\">{ siteHome }</span>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<MaybeUploadMedia />\n\t\t\t{ hasPublishAction && (\n\t\t\t\t<>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t\ttitle={ [\n\t\t\t\t\t\t\t__( 'Visibility:' ),\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"editor-post-publish-panel__link\"\n\t\t\t\t\t\t\t\tkey=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostVisibilityLabel />\n\t\t\t\t\t\t\t</span>,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostVisibility />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t\ttitle={ [\n\t\t\t\t\t\t\t__( 'Publish:' ),\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tclassName=\"editor-post-publish-panel__link\"\n\t\t\t\t\t\t\t\tkey=\"label\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostScheduleLabel />\n\t\t\t\t\t\t\t</span>,\n\t\t\t\t\t\t] }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PostSchedule />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</>\n\t\t\t) }\n\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mB,IAAA;UACC0B,SAAS,EAAC,iCAAiC;UAAApB,QAAA,eAG3CN,IAAA,CAACP,iBAAiB,IAAE;QAAC,GAFjB,OAGC,CAAC,CACL;QAAAa,QAAA,eAEHN,IAAA,CAACR,YAAY,IAAE;MAAC,CACN,CAAC;IAAA,CACX,CACF,eACDQ,IAAA,CAACL,oBAAoB,IAAE,CAAC,eACxBK,IAAA,CAACN,cAAc,IAAE,CAAC,eAClBM,IAAA,CAACH,kBAAkB,IAAE,CAAC,EACpBS,QAAQ;EAAA,CACN,CAAC;AAER;AAEA,eAAeD,0BAA0B","ignoreList":[]}
@@ -11,12 +11,12 @@ import { store as editorStore } from '../../store';
11
11
  import { GLOBAL_POST_TYPES } from '../../store/constants';
12
12
 
13
13
  /**
14
- * Wrapper component that renders its children only if the post can trashed.
14
+ * Wrapper component that renders its children only if the post can be trashed.
15
15
  *
16
- * @param {Object} props - The component props.
17
- * @param {React.ReactEl} props.children - The child components to render.
16
+ * @param {Object} props The component props.
17
+ * @param {React.ReactElement} props.children The child components.
18
18
  *
19
- * @return {React.ReactElement} The rendered child components or null if the post can not trashed.
19
+ * @return {React.ReactElement | null} The rendered child components or null if the post can't be trashed.
20
20
  */
21
21
  export default function PostTrashCheck({
22
22
  children
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","editorStore","GLOBAL_POST_TYPES","PostTrashCheck","children","canTrashPost","select","isEditedPostNew","getCurrentPostId","getCurrentPostType","canUser","postType","postId","isNew","canUserDelete","kind","name","id","includes"],"sources":["@wordpress/editor/src/components/post-trash/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { GLOBAL_POST_TYPES } from '../../store/constants';\n\n/**\n * Wrapper component that renders its children only if the post can trashed.\n *\n * @param {Object} props - The component props.\n * @param {React.ReactEl} props.children - The child components to render.\n *\n * @return {React.ReactElement} The rendered child components or null if the post can not trashed.\n */\nexport default function PostTrashCheck( { children } ) {\n\tconst { canTrashPost } = useSelect( ( select ) => {\n\t\tconst { isEditedPostNew, getCurrentPostId, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { canUser } = select( coreStore );\n\t\tconst postType = getCurrentPostType();\n\t\tconst postId = getCurrentPostId();\n\t\tconst isNew = isEditedPostNew();\n\t\tconst canUserDelete = !! postId\n\t\t\t? canUser( 'delete', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t\tid: postId,\n\t\t\t } )\n\t\t\t: false;\n\n\t\treturn {\n\t\t\tcanTrashPost:\n\t\t\t\t( ! isNew || postId ) &&\n\t\t\t\tcanUserDelete &&\n\t\t\t\t! GLOBAL_POST_TYPES.includes( postType ),\n\t\t};\n\t}, [] );\n\tif ( ! canTrashPost ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,SAASC,iBAAiB,QAAQ,uBAAuB;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtD,MAAM;IAAEC;EAAa,CAAC,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IACjD,MAAM;MAAEC,eAAe;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAC9DH,MAAM,CAAEL,WAAY,CAAC;IACtB,MAAM;MAAES;IAAQ,CAAC,GAAGJ,MAAM,CAAEN,SAAU,CAAC;IACvC,MAAMW,QAAQ,GAAGF,kBAAkB,CAAC,CAAC;IACrC,MAAMG,MAAM,GAAGJ,gBAAgB,CAAC,CAAC;IACjC,MAAMK,KAAK,GAAGN,eAAe,CAAC,CAAC;IAC/B,MAAMO,aAAa,GAAG,CAAC,CAAEF,MAAM,GAC5BF,OAAO,CAAE,QAAQ,EAAE;MACnBK,IAAI,EAAE,UAAU;MAChBC,IAAI,EAAEL,QAAQ;MACdM,EAAE,EAAEL;IACJ,CAAE,CAAC,GACH,KAAK;IAER,OAAO;MACNP,YAAY,EACX,CAAE,CAAEQ,KAAK,IAAID,MAAM,KACnBE,aAAa,IACb,CAAEZ,iBAAiB,CAACgB,QAAQ,CAAEP,QAAS;IACzC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,IAAK,CAAEN,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","editorStore","GLOBAL_POST_TYPES","PostTrashCheck","children","canTrashPost","select","isEditedPostNew","getCurrentPostId","getCurrentPostType","canUser","postType","postId","isNew","canUserDelete","kind","name","id","includes"],"sources":["@wordpress/editor/src/components/post-trash/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { GLOBAL_POST_TYPES } from '../../store/constants';\n\n/**\n * Wrapper component that renders its children only if the post can be trashed.\n *\n * @param {Object} props The component props.\n * @param {React.ReactElement} props.children The child components.\n *\n * @return {React.ReactElement | null} The rendered child components or null if the post can't be trashed.\n */\nexport default function PostTrashCheck( { children } ) {\n\tconst { canTrashPost } = useSelect( ( select ) => {\n\t\tconst { isEditedPostNew, getCurrentPostId, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst { canUser } = select( coreStore );\n\t\tconst postType = getCurrentPostType();\n\t\tconst postId = getCurrentPostId();\n\t\tconst isNew = isEditedPostNew();\n\t\tconst canUserDelete = !! postId\n\t\t\t? canUser( 'delete', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: postType,\n\t\t\t\t\tid: postId,\n\t\t\t } )\n\t\t\t: false;\n\n\t\treturn {\n\t\t\tcanTrashPost:\n\t\t\t\t( ! isNew || postId ) &&\n\t\t\t\tcanUserDelete &&\n\t\t\t\t! GLOBAL_POST_TYPES.includes( postType ),\n\t\t};\n\t}, [] );\n\tif ( ! canTrashPost ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,SAASC,iBAAiB,QAAQ,uBAAuB;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACtD,MAAM;IAAEC;EAAa,CAAC,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IACjD,MAAM;MAAEC,eAAe;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAC9DH,MAAM,CAAEL,WAAY,CAAC;IACtB,MAAM;MAAES;IAAQ,CAAC,GAAGJ,MAAM,CAAEN,SAAU,CAAC;IACvC,MAAMW,QAAQ,GAAGF,kBAAkB,CAAC,CAAC;IACrC,MAAMG,MAAM,GAAGJ,gBAAgB,CAAC,CAAC;IACjC,MAAMK,KAAK,GAAGN,eAAe,CAAC,CAAC;IAC/B,MAAMO,aAAa,GAAG,CAAC,CAAEF,MAAM,GAC5BF,OAAO,CAAE,QAAQ,EAAE;MACnBK,IAAI,EAAE,UAAU;MAChBC,IAAI,EAAEL,QAAQ;MACdM,EAAE,EAAEL;IACJ,CAAE,CAAC,GACH,KAAK;IAER,OAAO;MACNP,YAAY,EACX,CAAE,CAAEQ,KAAK,IAAID,MAAM,KACnBE,aAAa,IACb,CAAEZ,iBAAiB,CAACgB,QAAQ,CAAEP,QAAS;IACzC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,IAAK,CAAEN,YAAY,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
@@ -25,7 +25,8 @@ import { store as editorStore } from '../../store';
25
25
  * <PostURL />
26
26
  * ```
27
27
  *
28
- * @param {Function} onClose Callback function to be executed when the popover is closed.
28
+ * @param {{ onClose: () => void }} props The props for the component.
29
+ * @param {() => void} props.onClose Callback function to be executed when the popover is closed.
29
30
  *
30
31
  * @return {React.ReactNode} The rendered PostURL component.
31
32
  */
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","safeDecodeURIComponent","cleanForSlug","useState","createInterpolateElement","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","__","ExternalLink","Button","__experimentalInputControl","InputControl","__experimentalInputControlPrefixWrapper","InputControlPrefixWrapper","__experimentalInputControlSuffixWrapper","InputControlSuffixWrapper","__experimentalVStack","VStack","store","noticesStore","copySmall","coreStore","useCopyToClipboard","useInstanceId","editorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","PostURL","onClose","isEditable","postSlug","postLink","permalinkPrefix","permalinkSuffix","permalink","select","_post$_links$wpActio","post","getCurrentPost","postTypeSlug","getCurrentPostType","postType","getPostType","permalinkParts","getPermalinkParts","hasPublishAction","_links","isPermalinkEditable","getEditedPostSlug","viewPostLabel","labels","view_item","link","prefix","suffix","getPermalink","editPost","createNotice","forceEmptyField","setForceEmptyField","copyButtonRef","isDismissible","type","postUrlSlugDescriptionId","className","children","title","spacing","span","id","a","href","__next40pxDefaultSize","variant","icon","ref","size","label","hideLabelFromVision","value","autoComplete","spellCheck","onChange","newValue","slug","onBlur","event","target"],"sources":["@wordpress/editor/src/components/post-url/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tExternalLink,\n\tButton,\n\t__experimentalInputControl as InputControl,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n\t__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { copySmall } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useCopyToClipboard, useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the `PostURL` component.\n *\n * @example\n * ```jsx\n * <PostURL />\n * ```\n *\n * @param {Function} onClose Callback function to be executed when the popover is closed.\n *\n * @return {React.ReactNode} The rendered PostURL component.\n */\nexport default function PostURL( { onClose } ) {\n\tconst {\n\t\tisEditable,\n\t\tpostSlug,\n\t\tpostLink,\n\t\tpermalinkPrefix,\n\t\tpermalinkSuffix,\n\t\tpermalink,\n\t} = useSelect( ( select ) => {\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tconst permalinkParts = select( editorStore ).getPermalinkParts();\n\t\tconst hasPublishAction = post?._links?.[ 'wp:action-publish' ] ?? false;\n\n\t\treturn {\n\t\t\tisEditable:\n\t\t\t\tselect( editorStore ).isPermalinkEditable() && hasPublishAction,\n\t\t\tpostSlug: safeDecodeURIComponent(\n\t\t\t\tselect( editorStore ).getEditedPostSlug()\n\t\t\t),\n\t\t\tviewPostLabel: postType?.labels.view_item,\n\t\t\tpostLink: post.link,\n\t\t\tpermalinkPrefix: permalinkParts?.prefix,\n\t\t\tpermalinkSuffix: permalinkParts?.suffix,\n\t\t\tpermalink: safeDecodeURIComponent(\n\t\t\t\tselect( editorStore ).getPermalink()\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst [ forceEmptyField, setForceEmptyField ] = useState( false );\n\tconst copyButtonRef = useCopyToClipboard( permalink, () => {\n\t\tcreateNotice( 'info', __( 'Copied Permalink to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\tconst postUrlSlugDescriptionId =\n\t\t'editor-post-url__slug-description-' + useInstanceId( PostURL );\n\n\treturn (\n\t\t<div className=\"editor-post-url\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Slug' ) }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t{ isEditable && (\n\t\t\t\t\t<p className=\"editor-post-url__intro\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'<span>Customize the last part of the Permalink.</span> <a>Learn more.</a>'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span id={ postUrlSlugDescriptionId } />,\n\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t<div>\n\t\t\t\t\t{ isEditable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tprefix={\n\t\t\t\t\t\t\t\t\t<InputControlPrefixWrapper>\n\t\t\t\t\t\t\t\t\t\t/\n\t\t\t\t\t\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsuffix={\n\t\t\t\t\t\t\t\t\t<InputControlSuffixWrapper variant=\"control\">\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\t\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\tlabel=\"Copy\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</InputControlSuffixWrapper>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlabel={ __( 'Slug' ) }\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tvalue={ forceEmptyField ? '' : postSlug }\n\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tclassName=\"editor-post-url__input\"\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\teditPost( { slug: newValue } );\n\t\t\t\t\t\t\t\t\t// When we delete the field the permalink gets\n\t\t\t\t\t\t\t\t\t// reverted to the original value.\n\t\t\t\t\t\t\t\t\t// The forceEmptyField logic allows the user to have\n\t\t\t\t\t\t\t\t\t// the field temporarily empty while typing.\n\t\t\t\t\t\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\t\t\t\t\t\tif ( ! forceEmptyField ) {\n\t\t\t\t\t\t\t\t\t\t\tsetForceEmptyField( true );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\t\t\tsetForceEmptyField( false );\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\tonBlur={ ( event ) => {\n\t\t\t\t\t\t\t\t\teditPost( {\n\t\t\t\t\t\t\t\t\t\tslug: cleanForSlug(\n\t\t\t\t\t\t\t\t\t\t\tevent.target.value\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\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\t\t\tsetForceEmptyField( false );\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\taria-describedby={ postUrlSlugDescriptionId }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p className=\"editor-post-url__permalink\">\n\t\t\t\t\t\t\t\t<span className=\"editor-post-url__permalink-visual-label\">\n\t\t\t\t\t\t\t\t\t{ __( 'Permalink:' ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"editor-post-url__link\"\n\t\t\t\t\t\t\t\t\thref={ postLink }\n\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span className=\"editor-post-url__link-prefix\">\n\t\t\t\t\t\t\t\t\t\t{ permalinkPrefix }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<span className=\"editor-post-url__link-slug\">\n\t\t\t\t\t\t\t\t\t\t{ postSlug }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<span className=\"editor-post-url__link-suffix\">\n\t\t\t\t\t\t\t\t\t\t{ permalinkSuffix }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditable && (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\tclassName=\"editor-post-url__link\"\n\t\t\t\t\t\t\thref={ postLink }\n\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postLink }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,sBAAsB,EAAEC,YAAY,QAAQ,gBAAgB;AACrE,SAASC,QAAQ,EAAEC,wBAAwB,QAAQ,oBAAoB;AACvE,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,YAAY,EACZC,MAAM,EACNC,0BAA0B,IAAIC,YAAY,EAC1CC,uCAAuC,IAAIC,yBAAyB,EACpEC,uCAAuC,IAAIC,yBAAyB,EACpEC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASF,KAAK,IAAIG,SAAS,QAAQ,sBAAsB;AACzD,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,oBAAoB;;AAEtE;AACA;AACA;AACA,SAASL,KAAK,IAAIM,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAYA,eAAe,SAASC,OAAOA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EAC9C,MAAM;IACLC,UAAU;IACVC,QAAQ;IACRC,QAAQ;IACRC,eAAe;IACfC,eAAe;IACfC;EAC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,SAAS,EAAC,4BAA4B;gBAAAC,QAAA,EACzCnC;cAAQ,CACL,CAAC,eACPR,IAAA;gBAAM0C,SAAS,EAAC,8BAA8B;gBAAAC,QAAA,EAC3ChC;cAAe,CACZ,CAAC;YAAA,CACM,CAAC;UAAA,CACb,CAAC;QAAA,CACH,CACF,EACC,CAAEJ,UAAU,iBACbP,IAAA,CAAClB,YAAY;UACZ4D,SAAS,EAAC,uBAAuB;UACjCO,IAAI,EAAGxC,QAAU;UACjBwD,MAAM,EAAC,QAAQ;UAAAtB,QAAA,EAEblC;QAAQ,CACG,CACd;MAAA,CACG,CAAC;IAAA,CACC,CAAC;EAAA,CACL,CAAC;AAER","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","safeDecodeURIComponent","cleanForSlug","useState","createInterpolateElement","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","__","ExternalLink","Button","__experimentalInputControl","InputControl","__experimentalInputControlPrefixWrapper","InputControlPrefixWrapper","__experimentalInputControlSuffixWrapper","InputControlSuffixWrapper","__experimentalVStack","VStack","store","noticesStore","copySmall","coreStore","useCopyToClipboard","useInstanceId","editorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","PostURL","onClose","isEditable","postSlug","postLink","permalinkPrefix","permalinkSuffix","permalink","select","_post$_links$wpActio","post","getCurrentPost","postTypeSlug","getCurrentPostType","postType","getPostType","permalinkParts","getPermalinkParts","hasPublishAction","_links","isPermalinkEditable","getEditedPostSlug","viewPostLabel","labels","view_item","link","prefix","suffix","getPermalink","editPost","createNotice","forceEmptyField","setForceEmptyField","copyButtonRef","isDismissible","type","postUrlSlugDescriptionId","className","children","title","spacing","span","id","a","href","__next40pxDefaultSize","variant","icon","ref","size","label","hideLabelFromVision","value","autoComplete","spellCheck","onChange","newValue","slug","onBlur","event","target"],"sources":["@wordpress/editor/src/components/post-url/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tExternalLink,\n\tButton,\n\t__experimentalInputControl as InputControl,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n\t__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { copySmall } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useCopyToClipboard, useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the `PostURL` component.\n *\n * @example\n * ```jsx\n * <PostURL />\n * ```\n *\n * @param {{ onClose: () => void }} props The props for the component.\n * @param {() => void} props.onClose Callback function to be executed when the popover is closed.\n *\n * @return {React.ReactNode} The rendered PostURL component.\n */\nexport default function PostURL( { onClose } ) {\n\tconst {\n\t\tisEditable,\n\t\tpostSlug,\n\t\tpostLink,\n\t\tpermalinkPrefix,\n\t\tpermalinkSuffix,\n\t\tpermalink,\n\t} = useSelect( ( select ) => {\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tconst permalinkParts = select( editorStore ).getPermalinkParts();\n\t\tconst hasPublishAction = post?._links?.[ 'wp:action-publish' ] ?? false;\n\n\t\treturn {\n\t\t\tisEditable:\n\t\t\t\tselect( editorStore ).isPermalinkEditable() && hasPublishAction,\n\t\t\tpostSlug: safeDecodeURIComponent(\n\t\t\t\tselect( editorStore ).getEditedPostSlug()\n\t\t\t),\n\t\t\tviewPostLabel: postType?.labels.view_item,\n\t\t\tpostLink: post.link,\n\t\t\tpermalinkPrefix: permalinkParts?.prefix,\n\t\t\tpermalinkSuffix: permalinkParts?.suffix,\n\t\t\tpermalink: safeDecodeURIComponent(\n\t\t\t\tselect( editorStore ).getPermalink()\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst [ forceEmptyField, setForceEmptyField ] = useState( false );\n\tconst copyButtonRef = useCopyToClipboard( permalink, () => {\n\t\tcreateNotice( 'info', __( 'Copied Permalink to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\tconst postUrlSlugDescriptionId =\n\t\t'editor-post-url__slug-description-' + useInstanceId( PostURL );\n\n\treturn (\n\t\t<div className=\"editor-post-url\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Slug' ) }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t{ isEditable && (\n\t\t\t\t\t<p className=\"editor-post-url__intro\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'<span>Customize the last part of the Permalink.</span> <a>Learn more.</a>'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: <span id={ postUrlSlugDescriptionId } />,\n\t\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t<div>\n\t\t\t\t\t{ isEditable && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tprefix={\n\t\t\t\t\t\t\t\t\t<InputControlPrefixWrapper>\n\t\t\t\t\t\t\t\t\t\t/\n\t\t\t\t\t\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsuffix={\n\t\t\t\t\t\t\t\t\t<InputControlSuffixWrapper variant=\"control\">\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\t\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\tlabel=\"Copy\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</InputControlSuffixWrapper>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlabel={ __( 'Slug' ) }\n\t\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\t\tvalue={ forceEmptyField ? '' : postSlug }\n\t\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\t\tclassName=\"editor-post-url__input\"\n\t\t\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\t\t\teditPost( { slug: newValue } );\n\t\t\t\t\t\t\t\t\t// When we delete the field the permalink gets\n\t\t\t\t\t\t\t\t\t// reverted to the original value.\n\t\t\t\t\t\t\t\t\t// The forceEmptyField logic allows the user to have\n\t\t\t\t\t\t\t\t\t// the field temporarily empty while typing.\n\t\t\t\t\t\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\t\t\t\t\t\tif ( ! forceEmptyField ) {\n\t\t\t\t\t\t\t\t\t\t\tsetForceEmptyField( true );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\t\t\tsetForceEmptyField( false );\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\tonBlur={ ( event ) => {\n\t\t\t\t\t\t\t\t\teditPost( {\n\t\t\t\t\t\t\t\t\t\tslug: cleanForSlug(\n\t\t\t\t\t\t\t\t\t\t\tevent.target.value\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\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\t\t\tsetForceEmptyField( false );\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\taria-describedby={ postUrlSlugDescriptionId }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p className=\"editor-post-url__permalink\">\n\t\t\t\t\t\t\t\t<span className=\"editor-post-url__permalink-visual-label\">\n\t\t\t\t\t\t\t\t\t{ __( 'Permalink:' ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\tclassName=\"editor-post-url__link\"\n\t\t\t\t\t\t\t\t\thref={ postLink }\n\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span className=\"editor-post-url__link-prefix\">\n\t\t\t\t\t\t\t\t\t\t{ permalinkPrefix }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<span className=\"editor-post-url__link-slug\">\n\t\t\t\t\t\t\t\t\t\t{ postSlug }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<span className=\"editor-post-url__link-suffix\">\n\t\t\t\t\t\t\t\t\t\t{ permalinkSuffix }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isEditable && (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\tclassName=\"editor-post-url__link\"\n\t\t\t\t\t\t\thref={ postLink }\n\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ postLink }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,sBAAsB,EAAEC,YAAY,QAAQ,gBAAgB;AACrE,SAASC,QAAQ,EAAEC,wBAAwB,QAAQ,oBAAoB;AACvE,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,YAAY,EACZC,MAAM,EACNC,0BAA0B,IAAIC,YAAY,EAC1CC,uCAAuC,IAAIC,yBAAyB,EACpEC,uCAAuC,IAAIC,yBAAyB,EACpEC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASF,KAAK,IAAIG,SAAS,QAAQ,sBAAsB;AACzD,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,oBAAoB;;AAEtE;AACA;AACA;AACA,SAASL,KAAK,IAAIM,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAZA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAaA,eAAe,SAASC,OAAOA,CAAE;EAAEC;AAAQ,CAAC,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