@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
package/README.md CHANGED
@@ -401,7 +401,7 @@ _Parameters_
401
401
 
402
402
  - _props_ `Object`: The component props.
403
403
  - _props.close_ `Function`: The function to close the dialog.
404
- - _props.renderDialog_ `Function`: The function to render the dialog.
404
+ - _props.renderDialog_ `boolean`: Whether to render the component with modal dialog behavior.
405
405
 
406
406
  _Returns_
407
407
 
@@ -1312,27 +1312,6 @@ _Returns_
1312
1312
 
1313
1313
  - `React.ReactNode`: The rendered component.
1314
1314
 
1315
- ### PostSlug
1316
-
1317
- Renders the PostSlug component. It provide a control for editing the post slug.
1318
-
1319
- _Returns_
1320
-
1321
- - `React.ReactNode`: The rendered component.
1322
-
1323
- ### PostSlugCheck
1324
-
1325
- Wrapper component that renders its children only if the post type supports the slug.
1326
-
1327
- _Parameters_
1328
-
1329
- - _props_ `Object`: Props.
1330
- - _props.children_ `React.ReactNode`: Children to be rendered.
1331
-
1332
- _Returns_
1333
-
1334
- - `React.ReactNode`: The rendered component.
1335
-
1336
1315
  ### PostSticky
1337
1316
 
1338
1317
  Renders the PostSticky component. It provides a checkbox control for the sticky post feature.
@@ -1478,16 +1457,16 @@ _Returns_
1478
1457
 
1479
1458
  ### PostTrashCheck
1480
1459
 
1481
- Wrapper component that renders its children only if the post can trashed.
1460
+ Wrapper component that renders its children only if the post can be trashed.
1482
1461
 
1483
1462
  _Parameters_
1484
1463
 
1485
- - _props_ `Object`: - The component props.
1486
- - _props.children_ `React.ReactEl`: - The child components to render.
1464
+ - _props_ `Object`: The component props.
1465
+ - _props.children_ `React.ReactElement`: The child components.
1487
1466
 
1488
1467
  _Returns_
1489
1468
 
1490
- - `React.ReactElement`: The rendered child components or null if the post can not trashed.
1469
+ - `React.ReactElement | null`: The rendered child components or null if the post can't be trashed.
1491
1470
 
1492
1471
  ### PostTypeSupportCheck
1493
1472
 
@@ -1515,7 +1494,8 @@ _Usage_
1515
1494
 
1516
1495
  _Parameters_
1517
1496
 
1518
- - _onClose_ `Function`: Callback function to be executed when the popover is closed.
1497
+ - _props_ `{ onClose: () => void }`: The props for the component.
1498
+ - _props.onClose_ `() => void`: Callback function to be executed when the popover is closed.
1519
1499
 
1520
1500
  _Returns_
1521
1501
 
@@ -1782,7 +1762,7 @@ A user mentions completer.
1782
1762
 
1783
1763
  _Type_
1784
1764
 
1785
- - `WPCompleter`
1765
+ - `Object`
1786
1766
 
1787
1767
  ### VisualEditorGlobalKeyboardShortcuts
1788
1768
 
@@ -119,10 +119,9 @@ var _default = exports.default = {
119
119
  if (context?.query || context?.queryId) {
120
120
  return false;
121
121
  }
122
- const postType = context?.postType || select(_store.store).getCurrentPostType();
123
122
 
124
- // Check that editing is happening in the post editor and not a template.
125
- if (postType === 'wp_template') {
123
+ // Lock editing when `postType` is not defined.
124
+ if (!context?.postType) {
126
125
  return false;
127
126
  }
128
127
  const fieldValue = getPostMetaFields(select, context)?.[args.key]?.value;
@@ -1 +1 @@
1
- {"version":3,"names":["_coreData","require","_store","_lockUnlock","getPostMetaFields","select","context","getEditedEntityRecord","coreDataStore","getRegisteredPostMeta","unlock","entityMetaValues","postType","postId","meta","registeredFields","metaFields","Object","entries","forEach","key","props","charAt","_entityMetaValues$key","label","title","value","default","undefined","type","keys","length","_default","exports","name","getValues","bindings","newValues","attributeName","source","_ref","fieldKey","args","fieldValue","fieldLabel","setValues","dispatch","newMeta","values","newValue","editEntityRecord","canUserEditValue","query","queryId","editorStore","getCurrentPostType","areCustomFieldsEnabled","getEditorSettings","enableCustomFields","canUserEdit","canUser","kind","id","getFieldsList"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Gets a list of post meta fields with their values and labels\n * to be consumed in the needed callbacks.\n * If the value is not available based on context, like in templates,\n * it falls back to the default value, label, or key.\n *\n * @param {Object} select The select function from the data store.\n * @param {Object} context The context provided.\n * @return {Object} List of post meta fields with their value and label.\n *\n * @example\n * ```js\n * {\n * field_1_key: {\n * label: 'Field 1 Label',\n * value: 'Field 1 Value',\n * },\n * field_2_key: {\n * label: 'Field 2 Label',\n * value: 'Field 2 Value',\n * },\n * ...\n * }\n * ```\n */\nfunction getPostMetaFields( select, context ) {\n\tconst { getEditedEntityRecord } = select( coreDataStore );\n\tconst { getRegisteredPostMeta } = unlock( select( coreDataStore ) );\n\n\tlet entityMetaValues;\n\t// Try to get the current entity meta values.\n\tif ( context?.postType && context?.postId ) {\n\t\tentityMetaValues = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId\n\t\t).meta;\n\t}\n\n\tconst registeredFields = getRegisteredPostMeta( context?.postType );\n\tconst metaFields = {};\n\tObject.entries( registeredFields || {} ).forEach( ( [ key, props ] ) => {\n\t\t// Don't include footnotes or private fields.\n\t\tif ( key !== 'footnotes' && key.charAt( 0 ) !== '_' ) {\n\t\t\tmetaFields[ key ] = {\n\t\t\t\tlabel: props.title || key,\n\t\t\t\tvalue:\n\t\t\t\t\t// When using the entity value, an empty string IS a valid value.\n\t\t\t\t\tentityMetaValues?.[ key ] ??\n\t\t\t\t\t// When using the default, an empty string IS NOT a valid value.\n\t\t\t\t\t( props.default || undefined ),\n\t\t\t\ttype: props.type,\n\t\t\t};\n\t\t}\n\t} );\n\n\tif ( ! Object.keys( metaFields || {} ).length ) {\n\t\treturn null;\n\t}\n\n\treturn metaFields;\n}\n\nexport default {\n\tname: 'core/post-meta',\n\tgetValues( { select, context, bindings } ) {\n\t\tconst metaFields = getPostMetaFields( select, context );\n\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\t// Use the value, the field label, or the field key.\n\t\t\tconst fieldKey = source.args.key;\n\t\t\tconst { value: fieldValue, label: fieldLabel } =\n\t\t\t\tmetaFields?.[ fieldKey ] || {};\n\t\t\tnewValues[ attributeName ] = fieldValue ?? fieldLabel ?? fieldKey;\n\t\t}\n\t\treturn newValues;\n\t},\n\tsetValues( { dispatch, context, bindings } ) {\n\t\tconst newMeta = {};\n\t\tObject.values( bindings ).forEach( ( { args, newValue } ) => {\n\t\t\tnewMeta[ args.key ] = newValue;\n\t\t} );\n\n\t\tdispatch( coreDataStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId,\n\t\t\t{\n\t\t\t\tmeta: newMeta,\n\t\t\t}\n\t\t);\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst postType =\n\t\t\tcontext?.postType || select( editorStore ).getCurrentPostType();\n\n\t\t// Check that editing is happening in the post editor and not a template.\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fieldValue = getPostMetaFields( select, context )?.[ args.key ]\n\t\t\t?.value;\n\t\t// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.\n\t\tif ( fieldValue === undefined ) {\n\t\t\treturn false;\n\t\t}\n\t\t// Check that custom fields metabox is not enabled.\n\t\tconst areCustomFieldsEnabled =\n\t\t\tselect( editorStore ).getEditorSettings().enableCustomFields;\n\t\tif ( areCustomFieldsEnabled ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUser( 'update', {\n\t\t\tkind: 'postType',\n\t\t\tname: context?.postType,\n\t\t\tid: context?.postId,\n\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\tgetFieldsList( { select, context } ) {\n\t\treturn getPostMetaFields( select, context );\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,iBAAiBA,CAAEC,MAAM,EAAEC,OAAO,EAAG;EAC7C,MAAM;IAAEC;EAAsB,CAAC,GAAGF,MAAM,CAAEG,eAAc,CAAC;EACzD,MAAM;IAAEC;EAAsB,CAAC,GAAG,IAAAC,kBAAM,EAAEL,MAAM,CAAEG,eAAc,CAAE,CAAC;EAEnE,IAAIG,gBAAgB;EACpB;EACA,IAAKL,OAAO,EAAEM,QAAQ,IAAIN,OAAO,EAAEO,MAAM,EAAG;IAC3CF,gBAAgB,GAAGJ,qBAAqB,CACvC,UAAU,EACVD,OAAO,EAAEM,QAAQ,EACjBN,OAAO,EAAEO,MACV,CAAC,CAACC,IAAI;EACP;EAEA,MAAMC,gBAAgB,GAAGN,qBAAqB,CAAEH,OAAO,EAAEM,QAAS,CAAC;EACnE,MAAMI,UAAU,GAAG,CAAC,CAAC;EACrBC,MAAM,CAACC,OAAO,CAAEH,gBAAgB,IAAI,CAAC,CAAE,CAAC,CAACI,OAAO,CAAE,CAAE,CAAEC,GAAG,EAAEC,KAAK,CAAE,KAAM;IACvE;IACA,IAAKD,GAAG,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AAK;IACb;;IAEA;IACA,MAAMG,WAAW,GAAGtD,MAAM,CAAEG,eAAc,CAAC,CAACoD,OAAO,CAAE,QAAQ,EAAE;MAC9DC,IAAI,EAAE,UAAU;MAChB3B,IAAI,EAAE5B,OAAO,EAAEM,QAAQ;MACvBkD,EAAE,EAAExD,OAAO,EAAEO;IACd,CAAE,CAAC;IACH,IAAK,CAAE8C,WAAW,EAAG;MACpB,OAAO,KAAK;IACb;IAEA,OAAO,IAAI;EACZ,CAAC;EACDI,aAAaA,CAAE;IAAE1D,MAAM;IAAEC;EAAQ,CAAC,EAAG;IACpC,OAAOF,iBAAiB,CAAEC,MAAM,EAAEC,OAAQ,CAAC;EAC5C;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_coreData","require","_store","_lockUnlock","getPostMetaFields","select","context","getEditedEntityRecord","coreDataStore","getRegisteredPostMeta","unlock","entityMetaValues","postType","postId","meta","registeredFields","metaFields","Object","entries","forEach","key","props","charAt","_entityMetaValues$key","label","title","value","default","undefined","type","keys","length","_default","exports","name","getValues","bindings","newValues","attributeName","source","_ref","fieldKey","args","fieldValue","fieldLabel","setValues","dispatch","newMeta","values","newValue","editEntityRecord","canUserEditValue","query","queryId","areCustomFieldsEnabled","editorStore","getEditorSettings","enableCustomFields","canUserEdit","canUser","kind","id","getFieldsList"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Gets a list of post meta fields with their values and labels\n * to be consumed in the needed callbacks.\n * If the value is not available based on context, like in templates,\n * it falls back to the default value, label, or key.\n *\n * @param {Object} select The select function from the data store.\n * @param {Object} context The context provided.\n * @return {Object} List of post meta fields with their value and label.\n *\n * @example\n * ```js\n * {\n * field_1_key: {\n * label: 'Field 1 Label',\n * value: 'Field 1 Value',\n * },\n * field_2_key: {\n * label: 'Field 2 Label',\n * value: 'Field 2 Value',\n * },\n * ...\n * }\n * ```\n */\nfunction getPostMetaFields( select, context ) {\n\tconst { getEditedEntityRecord } = select( coreDataStore );\n\tconst { getRegisteredPostMeta } = unlock( select( coreDataStore ) );\n\n\tlet entityMetaValues;\n\t// Try to get the current entity meta values.\n\tif ( context?.postType && context?.postId ) {\n\t\tentityMetaValues = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId\n\t\t).meta;\n\t}\n\n\tconst registeredFields = getRegisteredPostMeta( context?.postType );\n\tconst metaFields = {};\n\tObject.entries( registeredFields || {} ).forEach( ( [ key, props ] ) => {\n\t\t// Don't include footnotes or private fields.\n\t\tif ( key !== 'footnotes' && key.charAt( 0 ) !== '_' ) {\n\t\t\tmetaFields[ key ] = {\n\t\t\t\tlabel: props.title || key,\n\t\t\t\tvalue:\n\t\t\t\t\t// When using the entity value, an empty string IS a valid value.\n\t\t\t\t\tentityMetaValues?.[ key ] ??\n\t\t\t\t\t// When using the default, an empty string IS NOT a valid value.\n\t\t\t\t\t( props.default || undefined ),\n\t\t\t\ttype: props.type,\n\t\t\t};\n\t\t}\n\t} );\n\n\tif ( ! Object.keys( metaFields || {} ).length ) {\n\t\treturn null;\n\t}\n\n\treturn metaFields;\n}\n\nexport default {\n\tname: 'core/post-meta',\n\tgetValues( { select, context, bindings } ) {\n\t\tconst metaFields = getPostMetaFields( select, context );\n\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\t// Use the value, the field label, or the field key.\n\t\t\tconst fieldKey = source.args.key;\n\t\t\tconst { value: fieldValue, label: fieldLabel } =\n\t\t\t\tmetaFields?.[ fieldKey ] || {};\n\t\t\tnewValues[ attributeName ] = fieldValue ?? fieldLabel ?? fieldKey;\n\t\t}\n\t\treturn newValues;\n\t},\n\tsetValues( { dispatch, context, bindings } ) {\n\t\tconst newMeta = {};\n\t\tObject.values( bindings ).forEach( ( { args, newValue } ) => {\n\t\t\tnewMeta[ args.key ] = newValue;\n\t\t} );\n\n\t\tdispatch( coreDataStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId,\n\t\t\t{\n\t\t\t\tmeta: newMeta,\n\t\t\t}\n\t\t);\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Lock editing when `postType` is not defined.\n\t\tif ( ! context?.postType ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fieldValue = getPostMetaFields( select, context )?.[ args.key ]\n\t\t\t?.value;\n\t\t// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.\n\t\tif ( fieldValue === undefined ) {\n\t\t\treturn false;\n\t\t}\n\t\t// Check that custom fields metabox is not enabled.\n\t\tconst areCustomFieldsEnabled =\n\t\t\tselect( editorStore ).getEditorSettings().enableCustomFields;\n\t\tif ( areCustomFieldsEnabled ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUser( 'update', {\n\t\t\tkind: 'postType',\n\t\t\tname: context?.postType,\n\t\t\tid: context?.postId,\n\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\tgetFieldsList( { select, context } ) {\n\t\treturn getPostMetaFields( select, context );\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,iBAAiB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E;IAAE9C,MAAM;IAAEC,OAAO;IAAEoC;EAAK,CAAC,EAAG;IAC7C;IACA,IAAKpC,OAAO,EAAE8C,KAAK,IAAI9C,OAAO,EAAE+C,OAAO,EAAG;MACzC,OAAO,KAAK;IACb;;IAEA;IACA,IAAK,CAAE/C,OAAO,EAAEM,QAAQ,EAAG;MAC1B,OAAO,KAAK;IACb;IAEA,MAAM+B,UAAU,GAAGvC,iBAAiB,CAAEC,MAAM,EAAEC,OAAQ,CAAC,GAAIoC,IAAI,CAACtB,GAAG,CAAE,EAClEM,KAAK;IACR;IACA,IAAKiB,UAAU,KAAKf,SAAS,EAAG;MAC/B,OAAO,KAAK;IACb;IACA;IACA,MAAM0B,sBAAsB,GAC3BjD,MAAM,CAAEkD,YAAY,CAAC,CAACC,iBAAiB,CAAC,CAAC,CAACC,kBAAkB;IAC7D,IAAKH,sBAAsB,EAAG;MAC7B,OAAO,KAAK;IACb;;IAEA;IACA,MAAMI,WAAW,GAAGrD,MAAM,CAAEG,eAAc,CAAC,CAACmD,OAAO,CAAE,QAAQ,EAAE;MAC9DC,IAAI,EAAE,UAAU;MAChB1B,IAAI,EAAE5B,OAAO,EAAEM,QAAQ;MACvBiD,EAAE,EAAEvD,OAAO,EAAEO;IACd,CAAE,CAAC;IACH,IAAK,CAAE6C,WAAW,EAAG;MACpB,OAAO,KAAK;IACb;IAEA,OAAO,IAAI;EACZ,CAAC;EACDI,aAAaA,CAAE;IAAEzD,MAAM;IAAEC;EAAQ,CAAC,EAAG;IACpC,OAAOF,iBAAiB,CAAEC,MAAM,EAAEC,OAAQ,CAAC;EAC5C;AACD,CAAC","ignoreList":[]}
@@ -13,8 +13,6 @@ var _jsxRuntime = require("react/jsx-runtime");
13
13
  * WordPress dependencies
14
14
  */
15
15
 
16
- /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
17
-
18
16
  function getUserLabel(user) {
19
17
  const avatar = user.avatar_urls && user.avatar_urls[24] ? /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
20
18
  className: "editor-autocompleters__user-avatar",
@@ -37,7 +35,7 @@ function getUserLabel(user) {
37
35
  /**
38
36
  * A user mentions completer.
39
37
  *
40
- * @type {WPCompleter}
38
+ * @type {Object}
41
39
  */
42
40
  var _default = exports.default = {
43
41
  name: 'users',
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_coreData","_jsxRuntime","getUserLabel","user","avatar","avatar_urls","jsx","className","alt","src","jsxs","Fragment","children","name","slug","_default","exports","default","triggerPrefix","useItems","filterValue","users","useSelect","select","getUsers","coreStore","context","search","encodeURIComponent","options","useMemo","map","key","value","label","getOptionCompletion"],"sources":["@wordpress/editor/src/components/autocompleters/user.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\nexport function getUserLabel( user ) {\n\tconst avatar =\n\t\tuser.avatar_urls && user.avatar_urls[ 24 ] ? (\n\t\t\t<img\n\t\t\t\tclassName=\"editor-autocompleters__user-avatar\"\n\t\t\t\talt=\"\"\n\t\t\t\tsrc={ user.avatar_urls[ 24 ] }\n\t\t\t/>\n\t\t) : (\n\t\t\t<span className=\"editor-autocompleters__no-avatar\"></span>\n\t\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ avatar }\n\t\t\t<span className=\"editor-autocompleters__user-name\">\n\t\t\t\t{ user.name }\n\t\t\t</span>\n\t\t\t<span className=\"editor-autocompleters__user-slug\">\n\t\t\t\t{ user.slug }\n\t\t\t</span>\n\t\t</>\n\t);\n}\n\n/**\n * A user mentions completer.\n *\n * @type {WPCompleter}\n */\nexport default {\n\tname: 'users',\n\tclassName: 'editor-autocompleters__user',\n\ttriggerPrefix: '@',\n\n\tuseItems( filterValue ) {\n\t\tconst users = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getUsers } = select( coreStore );\n\t\t\t\treturn getUsers( {\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t\tsearch: encodeURIComponent( filterValue ),\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[ filterValue ]\n\t\t);\n\n\t\tconst options = useMemo(\n\t\t\t() =>\n\t\t\t\tusers\n\t\t\t\t\t? users.map( ( user ) => ( {\n\t\t\t\t\t\t\tkey: `user-${ user.slug }`,\n\t\t\t\t\t\t\tvalue: user,\n\t\t\t\t\t\t\tlabel: getUserLabel( user ),\n\t\t\t\t\t } ) )\n\t\t\t\t\t: [],\n\t\t\t[ users ]\n\t\t);\n\n\t\treturn [ options ];\n\t},\n\n\tgetOptionCompletion( user ) {\n\t\treturn `@${ user.slug }`;\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAA0D,IAAAG,WAAA,GAAAH,OAAA;AAL1D;AACA;AACA;;AAKA;;AAEO,SAASI,YAAYA,CAAEC,IAAI,EAAG;EACpC,MAAMC,MAAM,GACXD,IAAI,CAACE,WAAW,IAAIF,IAAI,CAACE,WAAW,CAAE,EAAE,CAAE,gBACzC,IAAAJ,WAAA,CAAAK,GAAA;IACCC,SAAS,EAAC,oCAAoC;IAC9CC,GAAG,EAAC,EAAE;IACNC,GAAG,EAAGN,IAAI,CAACE,WAAW,CAAE,EAAE;EAAI,CAC9B,CAAC,gBAEF,IAAAJ,WAAA,CAAAK,GAAA;IAAMC,SAAS,EAAC;EAAkC,CAAO,CACzD;EAEF,oBACC,IAAAN,WAAA,CAAAS,IAAA,EAAAT,WAAA,CAAAU,QAAA;IAAAC,QAAA,GACGR,MAAM,eACR,IAAAH,WAAA,CAAAK,GAAA;MAAMC,SAAS,EAAC,kCAAkC;MAAAK,QAAA,EAC/CT,IAAI,CAACU;IAAI,CACN,CAAC,eACP,IAAAZ,WAAA,CAAAK,GAAA;MAAMC,SAAS,EAAC,kCAAkC;MAAAK,QAAA,EAC/CT,IAAI,CAACW;IAAI,CACN,CAAC;EAAA,CACN,CAAC;AAEL;;AAEA;AACA;AACA;AACA;AACA;AAJA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKe;EACdJ,IAAI,EAAE,OAAO;EACbN,SAAS,EAAE,6BAA6B;EACxCW,aAAa,EAAE,GAAG;EAElBC,QAAQA,CAAEC,WAAW,EAAG;IACvB,MAAMC,KAAK,GAAG,IAAAC,eAAS,EACpBC,MAAM,IAAM;MACb,MAAM;QAAEC;MAAS,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;MACxC,OAAOD,QAAQ,CAAE;QAChBE,OAAO,EAAE,MAAM;QACfC,MAAM,EAAEC,kBAAkB,CAAER,WAAY;MACzC,CAAE,CAAC;IACJ,CAAC,EACD,CAAEA,WAAW,CACd,CAAC;IAED,MAAMS,OAAO,GAAG,IAAAC,gBAAO,EACtB,MACCT,KAAK,GACFA,KAAK,CAACU,GAAG,CAAI5B,IAAI,KAAQ;MACzB6B,GAAG,EAAE,QAAS7B,IAAI,CAACW,IAAI,EAAG;MAC1BmB,KAAK,EAAE9B,IAAI;MACX+B,KAAK,EAAEhC,YAAY,CAAEC,IAAK;IAC1B,CAAC,CAAG,CAAC,GACL,EAAE,EACN,CAAEkB,KAAK,CACR,CAAC;IAED,OAAO,CAAEQ,OAAO,CAAE;EACnB,CAAC;EAEDM,mBAAmBA,CAAEhC,IAAI,EAAG;IAC3B,OAAO,IAAKA,IAAI,CAACW,IAAI,EAAG;EACzB;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_data","_coreData","_jsxRuntime","getUserLabel","user","avatar","avatar_urls","jsx","className","alt","src","jsxs","Fragment","children","name","slug","_default","exports","default","triggerPrefix","useItems","filterValue","users","useSelect","select","getUsers","coreStore","context","search","encodeURIComponent","options","useMemo","map","key","value","label","getOptionCompletion"],"sources":["@wordpress/editor/src/components/autocompleters/user.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\nexport function getUserLabel( user ) {\n\tconst avatar =\n\t\tuser.avatar_urls && user.avatar_urls[ 24 ] ? (\n\t\t\t<img\n\t\t\t\tclassName=\"editor-autocompleters__user-avatar\"\n\t\t\t\talt=\"\"\n\t\t\t\tsrc={ user.avatar_urls[ 24 ] }\n\t\t\t/>\n\t\t) : (\n\t\t\t<span className=\"editor-autocompleters__no-avatar\"></span>\n\t\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ avatar }\n\t\t\t<span className=\"editor-autocompleters__user-name\">\n\t\t\t\t{ user.name }\n\t\t\t</span>\n\t\t\t<span className=\"editor-autocompleters__user-slug\">\n\t\t\t\t{ user.slug }\n\t\t\t</span>\n\t\t</>\n\t);\n}\n\n/**\n * A user mentions completer.\n *\n * @type {Object}\n */\nexport default {\n\tname: 'users',\n\tclassName: 'editor-autocompleters__user',\n\ttriggerPrefix: '@',\n\n\tuseItems( filterValue ) {\n\t\tconst users = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { getUsers } = select( coreStore );\n\t\t\t\treturn getUsers( {\n\t\t\t\t\tcontext: 'view',\n\t\t\t\t\tsearch: encodeURIComponent( filterValue ),\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[ filterValue ]\n\t\t);\n\n\t\tconst options = useMemo(\n\t\t\t() =>\n\t\t\t\tusers\n\t\t\t\t\t? users.map( ( user ) => ( {\n\t\t\t\t\t\t\tkey: `user-${ user.slug }`,\n\t\t\t\t\t\t\tvalue: user,\n\t\t\t\t\t\t\tlabel: getUserLabel( user ),\n\t\t\t\t\t } ) )\n\t\t\t\t\t: [],\n\t\t\t[ users ]\n\t\t);\n\n\t\treturn [ options ];\n\t},\n\n\tgetOptionCompletion( user ) {\n\t\treturn `@${ user.slug }`;\n\t},\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;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,EACD,CAAEA,WAAW,CACd,CAAC;IAED,MAAMS,OAAO,GAAG,IAAAC,gBAAO,EACtB,MACCT,KAAK,GACFA,KAAK,CAACU,GAAG,CAAI5B,IAAI,KAAQ;MACzB6B,GAAG,EAAE,QAAS7B,IAAI,CAACW,IAAI,EAAG;MAC1BmB,KAAK,EAAE9B,IAAI;MACX+B,KAAK,EAAEhC,YAAY,CAAEC,IAAK;IAC1B,CAAC,CAAG,CAAC,GACL,EAAE,EACN,CAAEkB,KAAK,CACR,CAAC;IAED,OAAO,CAAEQ,OAAO,CAAE;EACnB,CAAC;EAEDM,mBAAmBA,CAAEhC,IAAI,EAAG;IAC3B,OAAO,IAAKA,IAAI,CAACW,IAAI,EAAG;EACzB;AACD,CAAC","ignoreList":[]}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.collabSidebarName = void 0;
6
+ exports.collabSidebarName = exports.collabHistorySidebarName = void 0;
7
+ const collabHistorySidebarName = exports.collabHistorySidebarName = 'edit-post/collab-history-sidebar';
7
8
  const collabSidebarName = exports.collabSidebarName = 'edit-post/collab-sidebar';
8
9
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["collabSidebarName","exports"],"sources":["@wordpress/editor/src/components/collab-sidebar/constants.js"],"sourcesContent":["export const collabSidebarName = 'edit-post/collab-sidebar';\n"],"mappings":";;;;;;AAAO,MAAMA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,0BAA0B","ignoreList":[]}
1
+ {"version":3,"names":["collabHistorySidebarName","exports","collabSidebarName"],"sources":["@wordpress/editor/src/components/collab-sidebar/constants.js"],"sourcesContent":["export const collabHistorySidebarName = 'edit-post/collab-history-sidebar';\nexport const collabSidebarName = 'edit-post/collab-sidebar';\n"],"mappings":";;;;;;AAAO,MAAMA,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,kCAAkC;AACnE,MAAME,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAG,0BAA0B","ignoreList":[]}
@@ -21,6 +21,8 @@ var _addComment = require("./add-comment");
21
21
  var _store = require("../../store");
22
22
  var _commentButton = _interopRequireDefault(require("./comment-button"));
23
23
  var _commentButtonToolbar = _interopRequireDefault(require("./comment-button-toolbar"));
24
+ var _globalStylesProvider = require("../global-styles-provider");
25
+ var _utils = require("./utils");
24
26
  var _jsxRuntime = require("react/jsx-runtime");
25
27
  /**
26
28
  * WordPress dependencies
@@ -47,7 +49,9 @@ const modifyBlockCommentAttributes = settings => {
47
49
  (0, _hooks.addFilter)('blocks.registerBlockType', 'block-comment/modify-core-block-attributes', modifyBlockCommentAttributes);
48
50
  function CollabSidebarContent({
49
51
  showCommentBoard,
50
- setShowCommentBoard
52
+ setShowCommentBoard,
53
+ styles,
54
+ comments
51
55
  }) {
52
56
  const {
53
57
  createNotice
@@ -60,22 +64,14 @@ function CollabSidebarContent({
60
64
  getEntityRecord
61
65
  } = (0, _data.resolveSelect)(_coreData.store);
62
66
  const {
63
- postId,
64
- threads
67
+ postId
65
68
  } = (0, _data.useSelect)(select => {
66
69
  const {
67
70
  getCurrentPostId
68
71
  } = select(_store.store);
69
72
  const _postId = getCurrentPostId();
70
- const data = !!_postId ? select(_coreData.store).getEntityRecords('root', 'comment', {
71
- post: _postId,
72
- type: 'block_comment',
73
- status: 'any',
74
- per_page: 100
75
- }) : null;
76
73
  return {
77
- postId: _postId,
78
- threads: data
74
+ postId: _postId
79
75
  };
80
76
  }, []);
81
77
  const {
@@ -85,34 +81,6 @@ function CollabSidebarContent({
85
81
  updateBlockAttributes
86
82
  } = (0, _data.useDispatch)(_blockEditor.store);
87
83
 
88
- // Process comments to build the tree structure
89
- const resultComments = (0, _element.useMemo)(() => {
90
- // Create a compare to store the references to all objects by id
91
- const compare = {};
92
- const result = [];
93
- const filteredComments = (threads !== null && threads !== void 0 ? threads : []).filter(comment => comment.status !== 'trash');
94
-
95
- // Initialize each object with an empty `reply` array
96
- filteredComments.forEach(item => {
97
- compare[item.id] = {
98
- ...item,
99
- reply: []
100
- };
101
- });
102
-
103
- // Iterate over the data to build the tree structure
104
- filteredComments.forEach(item => {
105
- if (item.parent === 0) {
106
- // If parent is 0, it's a root item, push it to the result array
107
- result.push(compare[item.id]);
108
- } else if (compare[item.parent]) {
109
- // Otherwise, find its parent and push it to the parent's `reply` array
110
- compare[item.parent].reply.push(compare[item.id]);
111
- }
112
- });
113
- return result;
114
- }, [threads]);
115
-
116
84
  // Function to save the comment.
117
85
  const addNewComment = async (comment, parentCommentId) => {
118
86
  const args = {
@@ -204,12 +172,13 @@ function CollabSidebarContent({
204
172
  };
205
173
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
206
174
  className: "editor-collab-sidebar-panel",
175
+ style: styles,
207
176
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_addComment.AddComment, {
208
177
  onSubmit: addNewComment,
209
178
  showCommentBoard: showCommentBoard,
210
179
  setShowCommentBoard: setShowCommentBoard
211
180
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_comments.Comments, {
212
- threads: resultComments,
181
+ threads: comments,
213
182
  onEditComment: onEditComment,
214
183
  onAddReply: addNewComment,
215
184
  onCommentDelete: onCommentDelete,
@@ -227,10 +196,30 @@ function CollabSidebar() {
227
196
  enableComplementaryArea
228
197
  } = (0, _data.useDispatch)(_interface.store);
229
198
  const {
230
- postStatus
199
+ getActiveComplementaryArea
200
+ } = (0, _data.useSelect)(_interface.store);
201
+ const {
202
+ postId,
203
+ postType,
204
+ postStatus,
205
+ threads
231
206
  } = (0, _data.useSelect)(select => {
207
+ const {
208
+ getCurrentPostId,
209
+ getCurrentPostType
210
+ } = select(_store.store);
211
+ const _postId = getCurrentPostId();
212
+ const data = !!_postId && typeof _postId === 'number' ? select(_coreData.store).getEntityRecords('root', 'comment', {
213
+ post: _postId,
214
+ type: 'block_comment',
215
+ status: 'any',
216
+ per_page: 100
217
+ }) : null;
232
218
  return {
233
- postStatus: select(_store.store).getEditedPostAttribute('status')
219
+ postId: _postId,
220
+ postType: getCurrentPostType(),
221
+ postStatus: select(_store.store).getEditedPostAttribute('status'),
222
+ threads: data
234
223
  };
235
224
  }, []);
236
225
  const {
@@ -249,6 +238,67 @@ function CollabSidebar() {
249
238
  setShowCommentBoard(true);
250
239
  enableComplementaryArea('core', 'edit-post/collab-sidebar');
251
240
  };
241
+ const [blocks] = (0, _coreData.useEntityBlockEditor)('postType', postType, {
242
+ id: postId
243
+ });
244
+
245
+ // Process comments to build the tree structure
246
+ const {
247
+ resultComments,
248
+ sortedThreads
249
+ } = (0, _element.useMemo)(() => {
250
+ // Create a compare to store the references to all objects by id
251
+ const compare = {};
252
+ const result = [];
253
+ const filteredComments = (threads !== null && threads !== void 0 ? threads : []).filter(comment => comment.status !== 'trash');
254
+
255
+ // Initialize each object with an empty `reply` array
256
+ filteredComments.forEach(item => {
257
+ compare[item.id] = {
258
+ ...item,
259
+ reply: []
260
+ };
261
+ });
262
+
263
+ // Iterate over the data to build the tree structure
264
+ filteredComments.forEach(item => {
265
+ if (item.parent === 0) {
266
+ // If parent is 0, it's a root item, push it to the result array
267
+ result.push(compare[item.id]);
268
+ } else if (compare[item.parent]) {
269
+ // Otherwise, find its parent and push it to the parent's `reply` array
270
+ compare[item.parent].reply.push(compare[item.id]);
271
+ }
272
+ });
273
+ if (0 === result?.length) {
274
+ return {
275
+ resultComments: [],
276
+ sortedThreads: []
277
+ };
278
+ }
279
+ const blockCommentIds = (0, _utils.getCommentIdsFromBlocks)(blocks);
280
+ const threadIdMap = new Map(result.map(thread => [thread.id, thread]));
281
+ const sortedComments = blockCommentIds.map(id => threadIdMap.get(id)).filter(thread => thread !== undefined);
282
+ return {
283
+ resultComments: result,
284
+ sortedThreads: sortedComments
285
+ };
286
+ }, [threads, blocks]);
287
+
288
+ // Get the global styles to set the background color of the sidebar.
289
+ const {
290
+ merged: GlobalStyles
291
+ } = (0, _globalStylesProvider.useGlobalStylesContext)();
292
+ const backgroundColor = GlobalStyles?.styles?.color?.background;
293
+ if (0 < resultComments.length) {
294
+ const unsubscribe = (0, _data.subscribe)(() => {
295
+ const activeSidebar = getActiveComplementaryArea('core');
296
+ if (!activeSidebar) {
297
+ enableComplementaryArea('core', _constants.collabSidebarName);
298
+ unsubscribe();
299
+ }
300
+ });
301
+ }
252
302
 
253
303
  // Check if the experimental flag is enabled.
254
304
  if (!isBlockCommentExperimentEnabled || postStatus === 'publish') {
@@ -259,15 +309,30 @@ function CollabSidebar() {
259
309
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(AddCommentComponent, {
260
310
  onClick: openCollabBoard
261
311
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_pluginSidebar.default, {
262
- identifier: _constants.collabSidebarName
312
+ identifier: _constants.collabHistorySidebarName
263
313
  // translators: Comments sidebar title
264
314
  ,
265
315
  title: (0, _i18n.__)('Comments'),
266
316
  icon: _icons.comment,
267
317
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CollabSidebarContent, {
318
+ comments: resultComments,
268
319
  showCommentBoard: showCommentBoard,
269
320
  setShowCommentBoard: setShowCommentBoard
270
321
  })
322
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_pluginSidebar.default, {
323
+ isPinnable: false,
324
+ header: false,
325
+ identifier: _constants.collabSidebarName,
326
+ className: "editor-collab-sidebar",
327
+ headerClassName: "editor-collab-sidebar__header",
328
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CollabSidebarContent, {
329
+ comments: sortedThreads,
330
+ showCommentBoard: showCommentBoard,
331
+ setShowCommentBoard: setShowCommentBoard,
332
+ styles: {
333
+ backgroundColor
334
+ }
335
+ })
271
336
  })]
272
337
  });
273
338
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_element","_icons","_hooks","_notices","_coreData","_blockEditor","_interface","_pluginSidebar","_interopRequireDefault","_constants","_comments","_addComment","_store","_commentButton","_commentButtonToolbar","_jsxRuntime","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","addFilter","CollabSidebarContent","showCommentBoard","setShowCommentBoard","createNotice","useDispatch","noticesStore","saveEntityRecord","deleteEntityRecord","coreStore","getEntityRecord","resolveSelect","postId","threads","useSelect","select","getCurrentPostId","editorStore","_postId","data","getEntityRecords","post","status","per_page","getSelectedBlockClientId","blockEditorStore","updateBlockAttributes","resultComments","useMemo","compare","result","filteredComments","filter","comment","forEach","item","id","reply","parent","push","addNewComment","parentCommentId","args","content","comment_type","comment_approved","updatedArgs","savedRecord","__","isDismissible","onError","onCommentResolve","commentId","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","children","jsx","AddComment","onSubmit","Comments","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","postStatus","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","AddCommentComponent","AddCommentToolbarButton","AddCommentButton","Fragment","onClick","default","identifier","collabSidebarName","title","icon","commentIcon"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch, resolveSelect } from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\n\nconst isBlockCommentExperimentEnabled =\n\twindow?.__experimentalEnableBlockComment;\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( { showCommentBoard, setShowCommentBoard } ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data = !! _postId\n\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\tpost: _postId,\n\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\tstatus: 'any',\n\t\t\t\t\tper_page: 100,\n\t\t\t } )\n\t\t\t: null;\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Process comments to build the tree structure\n\tconst resultComments = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\treturn result;\n\t}, [ threads ] );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\">\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tthreads={ resultComments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\n\tconst { postStatus } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t};\n\t}, [] );\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\t// Check if the experimental flag is enabled.\n\tif ( ! isBlockCommentExperimentEnabled || postStatus === 'publish' ) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tshowComment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mBAAmB,EAAGA;MAAqB,CAC3C;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_data","_element","_icons","_hooks","_notices","_coreData","_blockEditor","_interface","_pluginSidebar","_interopRequireDefault","_constants","_comments","_addComment","_store","_commentButton","_commentButtonToolbar","_globalStylesProvider","_utils","_jsxRuntime","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","addFilter","CollabSidebarContent","showCommentBoard","setShowCommentBoard","styles","comments","createNotice","useDispatch","noticesStore","saveEntityRecord","deleteEntityRecord","coreStore","getEntityRecord","resolveSelect","postId","useSelect","select","getCurrentPostId","editorStore","_postId","getSelectedBlockClientId","blockEditorStore","updateBlockAttributes","addNewComment","comment","parentCommentId","args","post","content","comment_type","comment_approved","updatedArgs","parent","savedRecord","id","__","isDismissible","onError","onCommentResolve","commentId","status","onEditComment","onCommentDelete","childComment","undefined","jsxs","className","style","children","jsx","AddComment","onSubmit","Comments","threads","onAddReply","CollabSidebar","useState","enableComplementaryArea","interfaceStore","getActiveComplementaryArea","postType","postStatus","getCurrentPostType","data","getEntityRecords","per_page","getEditedPostAttribute","getBlockAttributes","_clientId","openCollabBoard","blocks","useEntityBlockEditor","resultComments","sortedThreads","useMemo","compare","result","filteredComments","filter","forEach","item","reply","push","length","blockCommentIds","getCommentIdsFromBlocks","threadIdMap","Map","map","thread","sortedComments","get","merged","GlobalStyles","useGlobalStylesContext","backgroundColor","color","background","unsubscribe","subscribe","activeSidebar","collabSidebarName","AddCommentComponent","AddCommentToolbarButton","AddCommentButton","Fragment","onClick","default","identifier","collabHistorySidebarName","title","icon","commentIcon","isPinnable","header","headerClassName"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseSelect,\n\tuseDispatch,\n\tresolveSelect,\n\tsubscribe,\n} from '@wordpress/data';\nimport { useState, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabHistorySidebarName, collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { getCommentIdsFromBlocks } from './utils';\n\nconst isBlockCommentExperimentEnabled =\n\twindow?.__experimentalEnableBlockComment;\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\nfunction CollabSidebarContent( {\n\tshowCommentBoard,\n\tsetShowCommentBoard,\n\tstyles,\n\tcomments,\n} ) {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\n\tconst { postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t};\n\t}, [] );\n\n\tconst { getSelectedBlockClientId } = useSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( getSelectedBlockClientId(), {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\treturn (\n\t\t<div className=\"editor-collab-sidebar-panel\" style={ styles }>\n\t\t\t<AddComment\n\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t/>\n\t\t\t<Comments\n\t\t\t\tthreads={ comments }\n\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\n\tconst { postId, postType, postStatus, threads } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst _postId = getCurrentPostId();\n\t\tconst data =\n\t\t\t!! _postId && typeof _postId === 'number'\n\t\t\t\t? select( coreStore ).getEntityRecords( 'root', 'comment', {\n\t\t\t\t\t\tpost: _postId,\n\t\t\t\t\t\ttype: 'block_comment',\n\t\t\t\t\t\tstatus: 'any',\n\t\t\t\t\t\tper_page: 100,\n\t\t\t\t } )\n\t\t\t\t: null;\n\t\treturn {\n\t\t\tpostId: _postId,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostStatus:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'status' ),\n\t\t\tthreads: data,\n\t\t};\n\t}, [] );\n\n\tconst { blockCommentId } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tblockCommentId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.blockCommentId\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\tconst [ blocks ] = useEntityBlockEditor( 'postType', postType, {\n\t\tid: postId,\n\t} );\n\n\t// Process comments to build the tree structure\n\tconst { resultComments, sortedThreads } = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst filteredComments = ( threads ?? [] ).filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 0 === result?.length ) {\n\t\t\treturn { resultComments: [], sortedThreads: [] };\n\t\t}\n\n\t\tconst blockCommentIds = getCommentIdsFromBlocks( blocks );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tresult.map( ( thread ) => [ thread.id, thread ] )\n\t\t);\n\n\t\tconst sortedComments = blockCommentIds\n\t\t\t.map( ( id ) => threadIdMap.get( id ) )\n\t\t\t.filter( ( thread ) => thread !== undefined );\n\n\t\treturn { resultComments: result, sortedThreads: sortedComments };\n\t}, [ threads, blocks ] );\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\tif ( 0 < resultComments.length ) {\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\n\t\t\tif ( ! activeSidebar ) {\n\t\t\t\tenableComplementaryArea( 'core', collabSidebarName );\n\t\t\t\tunsubscribe();\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Check if the experimental flag is enabled.\n\tif ( ! isBlockCommentExperimentEnabled || postStatus === 'publish' ) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\tconst AddCommentComponent = blockCommentId\n\t\t? AddCommentToolbarButton\n\t\t: AddCommentButton;\n\n\treturn (\n\t\t<>\n\t\t\t<AddCommentComponent onClick={ openCollabBoard } />\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabHistorySidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ resultComments }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t\t<PluginSidebar\n\t\t\t\tisPinnable={ false }\n\t\t\t\theader={ false }\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t>\n\t\t\t\t<CollabSidebarContent\n\t\t\t\t\tcomments={ sortedThreads }\n\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\tstyles={ {\n\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AAKA,IAAAS,cAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,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AChB,IAAAZ,WAAA,CAAA0D,GAAA,EAACpE,cAAA,CAAA8H,OAAa;MACbM,UAAU,EAAG,KAAO;MACpBC,MAAM,EAAG,KAAO;MAChBN,UAAU,EAAGP,4BAAmB;MAChCvD,SAAS,EAAC,uBAAuB;MACjCqE,eAAe,EAAC,+BAA+B;MAAAnE,QAAA,eAE/C,IAAAzD,WAAA,CAAA0D,GAAA,EAAChD,oBAAoB;QACpBI,QAAQ,EAAGoE,aAAe;QAC1BvE,gBAAgB,EAAGA,gBAAkB;QACrCC,mBAAmB,EAAGA,mBAAqB;QAC3CC,MAAM,EAAG;UACR2F;QACD;MAAG,CACH;IAAC,CACY,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getCommentIdsFromBlocks = getCommentIdsFromBlocks;
6
7
  exports.sanitizeCommentString = sanitizeCommentString;
7
8
  /**
8
9
  * Sanitizes a comment string by removing non-printable ASCII characters.
@@ -13,4 +14,35 @@ exports.sanitizeCommentString = sanitizeCommentString;
13
14
  function sanitizeCommentString(str) {
14
15
  return str.trim();
15
16
  }
17
+
18
+ /**
19
+ * Extracts comment IDs from an array of blocks.
20
+ *
21
+ * This function recursively traverses the blocks and their inner blocks to
22
+ * collect all comment IDs found in the block attributes.
23
+ *
24
+ * @param {Array} blocks - The array of blocks to extract comment IDs from.
25
+ * @return {Array} An array of comment IDs extracted from the blocks.
26
+ */
27
+ function getCommentIdsFromBlocks(blocks) {
28
+ // Recursive function to extract comment IDs from blocks
29
+ const extractCommentIds = items => {
30
+ return items.reduce((commentIds, block) => {
31
+ // Check for comment IDs in the current block's attributes
32
+ if (block.attributes && block.attributes.blockCommentId && !commentIds.includes(block.attributes.blockCommentId)) {
33
+ commentIds.push(block.attributes.blockCommentId);
34
+ }
35
+
36
+ // Recursively check inner blocks
37
+ if (block.innerBlocks && block.innerBlocks.length > 0) {
38
+ const innerCommentIds = extractCommentIds(block.innerBlocks);
39
+ commentIds.push(...innerCommentIds);
40
+ }
41
+ return commentIds;
42
+ }, []);
43
+ };
44
+
45
+ // Extract all comment IDs recursively
46
+ return extractCommentIds(blocks);
47
+ }
16
48
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["sanitizeCommentString","str","trim"],"sources":["@wordpress/editor/src/components/collab-sidebar/utils.js"],"sourcesContent":["/**\n * Sanitizes a comment string by removing non-printable ASCII characters.\n *\n * @param {string} str - The comment string to sanitize.\n * @return {string} - The sanitized comment string.\n */\nexport function sanitizeCommentString( str ) {\n\treturn str.trim();\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqBA,CAAEC,GAAG,EAAG;EAC5C,OAAOA,GAAG,CAACC,IAAI,CAAC,CAAC;AAClB","ignoreList":[]}
1
+ {"version":3,"names":["sanitizeCommentString","str","trim","getCommentIdsFromBlocks","blocks","extractCommentIds","items","reduce","commentIds","block","attributes","blockCommentId","includes","push","innerBlocks","length","innerCommentIds"],"sources":["@wordpress/editor/src/components/collab-sidebar/utils.js"],"sourcesContent":["/**\n * Sanitizes a comment string by removing non-printable ASCII characters.\n *\n * @param {string} str - The comment string to sanitize.\n * @return {string} - The sanitized comment string.\n */\nexport function sanitizeCommentString( str ) {\n\treturn str.trim();\n}\n\n/**\n * Extracts comment IDs from an array of blocks.\n *\n * This function recursively traverses the blocks and their inner blocks to\n * collect all comment IDs found in the block attributes.\n *\n * @param {Array} blocks - The array of blocks to extract comment IDs from.\n * @return {Array} An array of comment IDs extracted from the blocks.\n */\nexport function getCommentIdsFromBlocks( blocks ) {\n\t// Recursive function to extract comment IDs from blocks\n\tconst extractCommentIds = ( items ) => {\n\t\treturn items.reduce( ( commentIds, block ) => {\n\t\t\t// Check for comment IDs in the current block's attributes\n\t\t\tif (\n\t\t\t\tblock.attributes &&\n\t\t\t\tblock.attributes.blockCommentId &&\n\t\t\t\t! commentIds.includes( block.attributes.blockCommentId )\n\t\t\t) {\n\t\t\t\tcommentIds.push( block.attributes.blockCommentId );\n\t\t\t}\n\n\t\t\t// Recursively check inner blocks\n\t\t\tif ( block.innerBlocks && block.innerBlocks.length > 0 ) {\n\t\t\t\tconst innerCommentIds = extractCommentIds( block.innerBlocks );\n\t\t\t\tcommentIds.push( ...innerCommentIds );\n\t\t\t}\n\n\t\t\treturn commentIds;\n\t\t}, [] );\n\t};\n\n\t// Extract all comment IDs recursively\n\treturn extractCommentIds( blocks );\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAqBA,CAAEC,GAAG,EAAG;EAC5C,OAAOA,GAAG,CAACC,IAAI,CAAC,CAAC;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uBAAuBA,CAAEC,MAAM,EAAG;EACjD;EACA,MAAMC,iBAAiB,GAAKC,KAAK,IAAM;IACtC,OAAOA,KAAK,CAACC,MAAM,CAAE,CAAEC,UAAU,EAAEC,KAAK,KAAM;MAC7C;MACA,IACCA,KAAK,CAACC,UAAU,IAChBD,KAAK,CAACC,UAAU,CAACC,cAAc,IAC/B,CAAEH,UAAU,CAACI,QAAQ,CAAEH,KAAK,CAACC,UAAU,CAACC,cAAe,CAAC,EACvD;QACDH,UAAU,CAACK,IAAI,CAAEJ,KAAK,CAACC,UAAU,CAACC,cAAe,CAAC;MACnD;;MAEA;MACA,IAAKF,KAAK,CAACK,WAAW,IAAIL,KAAK,CAACK,WAAW,CAACC,MAAM,GAAG,CAAC,EAAG;QACxD,MAAMC,eAAe,GAAGX,iBAAiB,CAAEI,KAAK,CAACK,WAAY,CAAC;QAC9DN,UAAU,CAACK,IAAI,CAAE,GAAGG,eAAgB,CAAC;MACtC;MAEA,OAAOR,UAAU;IAClB,CAAC,EAAE,EAAG,CAAC;EACR,CAAC;;EAED;EACA,OAAOH,iBAAiB,CAAED,MAAO,CAAC;AACnC","ignoreList":[]}
@@ -55,6 +55,7 @@ var _jsxRuntime = require("react/jsx-runtime");
55
55
  */
56
56
  function DocumentBar(props) {
57
57
  const {
58
+ postId,
58
59
  postType,
59
60
  postTypeLabel,
60
61
  documentTitle,
@@ -87,6 +88,7 @@ function DocumentBar(props) {
87
88
  });
88
89
  const _postTypeLabel = getPostType(_postType)?.labels?.singular_name;
89
90
  return {
91
+ postId: _postId,
90
92
  postType: _postType,
91
93
  postTypeLabel: _postTypeLabel,
92
94
  documentTitle: _document.title,
@@ -105,7 +107,7 @@ function DocumentBar(props) {
105
107
  const entityTitle = isTemplate ? templateTitle : documentTitle;
106
108
  const title = props.title || entityTitle;
107
109
  const icon = props.icon;
108
- const pageTypeBadge = (0, _pageTypeBadge.default)();
110
+ const pageTypeBadge = (0, _pageTypeBadge.default)(postId);
109
111
  const mountedRef = (0, _element.useRef)(false);
110
112
  (0, _element.useEffect)(() => {
111
113
  mountedRef.current = true;