@wordpress/editor 14.44.1-next.v.202604201441.0 → 14.45.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 (322) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/collab-sidebar/{comment-menu-item.cjs → add-note-menu-item.cjs} +17 -14
  3. package/build/components/collab-sidebar/add-note-menu-item.cjs.map +7 -0
  4. package/build/components/collab-sidebar/{add-comment.cjs → add-note.cjs} +28 -41
  5. package/build/components/collab-sidebar/add-note.cjs.map +7 -0
  6. package/build/components/collab-sidebar/board-store.cjs +3 -0
  7. package/build/components/collab-sidebar/board-store.cjs.map +2 -2
  8. package/build/components/collab-sidebar/floating-container.cjs +4 -3
  9. package/build/components/collab-sidebar/floating-container.cjs.map +3 -3
  10. package/build/components/collab-sidebar/hooks.cjs +92 -135
  11. package/build/components/collab-sidebar/hooks.cjs.map +3 -3
  12. package/build/components/collab-sidebar/index.cjs +28 -79
  13. package/build/components/collab-sidebar/index.cjs.map +3 -3
  14. package/build/components/collab-sidebar/{comment-author-info.cjs → note-byline.cjs} +13 -9
  15. package/build/components/collab-sidebar/note-byline.cjs.map +7 -0
  16. package/build/components/collab-sidebar/note-card.cjs +58 -0
  17. package/build/components/collab-sidebar/note-card.cjs.map +7 -0
  18. package/build/components/collab-sidebar/{comment-form.cjs → note-form.cjs} +45 -36
  19. package/build/components/collab-sidebar/note-form.cjs.map +7 -0
  20. package/build/components/collab-sidebar/{comment-indicator-toolbar.cjs → note-indicator-toolbar.cjs} +31 -27
  21. package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +7 -0
  22. package/build/components/collab-sidebar/note-thread.cjs +321 -0
  23. package/build/components/collab-sidebar/note-thread.cjs.map +7 -0
  24. package/build/components/collab-sidebar/note.cjs +207 -0
  25. package/build/components/collab-sidebar/note.cjs.map +7 -0
  26. package/build/components/collab-sidebar/notes.cjs +237 -0
  27. package/build/components/collab-sidebar/notes.cjs.map +7 -0
  28. package/build/components/collab-sidebar/utils.cjs +23 -25
  29. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  30. package/build/components/document-bar/index.cjs.map +3 -3
  31. package/build/components/error-boundary/index.cjs.map +3 -3
  32. package/build/components/list-view-sidebar/list-view-outline.cjs.map +3 -3
  33. package/build/components/media/media-editor-modal.cjs +93 -0
  34. package/build/components/media/media-editor-modal.cjs.map +7 -0
  35. package/build/components/more-menu/index.cjs +3 -2
  36. package/build/components/more-menu/index.cjs.map +2 -2
  37. package/build/components/post-actions/set-as-homepage.cjs.map +3 -3
  38. package/build/components/post-actions/set-as-posts-page.cjs.map +3 -3
  39. package/build/components/post-card-panel/index.cjs +2 -2
  40. package/build/components/post-card-panel/index.cjs.map +3 -3
  41. package/build/components/post-content-information/index.cjs.map +3 -3
  42. package/build/components/post-excerpt/panel.cjs.map +3 -3
  43. package/build/components/post-last-edited-panel/index.cjs.map +3 -3
  44. package/build/components/post-preview-button/index.cjs +3 -2
  45. package/build/components/post-preview-button/index.cjs.map +2 -2
  46. package/build/components/post-publish-button/index.cjs +2 -2
  47. package/build/components/post-publish-button/index.cjs.map +2 -2
  48. package/build/components/post-publish-button/label.cjs +4 -2
  49. package/build/components/post-publish-button/label.cjs.map +2 -2
  50. package/build/components/post-publish-panel/postpublish.cjs +3 -2
  51. package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
  52. package/build/components/post-revisions-panel/index.cjs +2 -2
  53. package/build/components/post-revisions-panel/index.cjs.map +2 -2
  54. package/build/components/post-revisions-preview/diff-markers.cjs +1 -1
  55. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  56. package/build/components/post-revisions-preview/revisions-slider.cjs +1 -0
  57. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  58. package/build/components/post-saved-state/index.cjs +4 -1
  59. package/build/components/post-saved-state/index.cjs.map +2 -2
  60. package/build/components/post-text-editor/index.cjs +3 -4
  61. package/build/components/post-text-editor/index.cjs.map +2 -2
  62. package/build/components/preview-dropdown/index.cjs +3 -2
  63. package/build/components/preview-dropdown/index.cjs.map +2 -2
  64. package/build/components/provider/index.cjs +3 -1
  65. package/build/components/provider/index.cjs.map +3 -3
  66. package/build/components/provider/use-block-editor-settings.cjs +7 -1
  67. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  68. package/build/components/provider/use-upload-save-lock.cjs +2 -12
  69. package/build/components/provider/use-upload-save-lock.cjs.map +2 -2
  70. package/build/components/resizable-editor/resize-handle.cjs +2 -1
  71. package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
  72. package/build/components/revision-created-panel/index.cjs.map +3 -3
  73. package/build/components/site-discussion/index.cjs.map +2 -2
  74. package/build/components/template-actions-panel/classic-theme-content.cjs.map +2 -2
  75. package/build/components/template-part-menu-items/convert-to-regular.cjs +54 -11
  76. package/build/components/template-part-menu-items/convert-to-regular.cjs.map +3 -3
  77. package/build/components/visual-editor/index.cjs +5 -22
  78. package/build/components/visual-editor/index.cjs.map +2 -2
  79. package/build/store/private-actions.cjs +0 -8
  80. package/build/store/private-actions.cjs.map +2 -2
  81. package/build/store/private-selectors.cjs +0 -5
  82. package/build/store/private-selectors.cjs.map +2 -2
  83. package/build/store/reducer.cjs +0 -10
  84. package/build/store/reducer.cjs.map +2 -2
  85. package/build/utils/media-finalize/index.cjs +3 -2
  86. package/build/utils/media-finalize/index.cjs.map +2 -2
  87. package/build/utils/media-upload/index.cjs +14 -25
  88. package/build/utils/media-upload/index.cjs.map +2 -2
  89. package/build-module/components/collab-sidebar/{comment-menu-item.mjs → add-note-menu-item.mjs} +10 -11
  90. package/build-module/components/collab-sidebar/add-note-menu-item.mjs.map +7 -0
  91. package/build-module/components/collab-sidebar/{add-comment.mjs → add-note.mjs} +26 -29
  92. package/build-module/components/collab-sidebar/add-note.mjs.map +7 -0
  93. package/build-module/components/collab-sidebar/board-store.mjs +3 -0
  94. package/build-module/components/collab-sidebar/board-store.mjs.map +2 -2
  95. package/build-module/components/collab-sidebar/floating-container.mjs +4 -3
  96. package/build-module/components/collab-sidebar/floating-container.mjs.map +2 -2
  97. package/build-module/components/collab-sidebar/hooks.mjs +91 -137
  98. package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
  99. package/build-module/components/collab-sidebar/index.mjs +29 -84
  100. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  101. package/build-module/components/collab-sidebar/{comment-author-info.mjs → note-byline.mjs} +7 -7
  102. package/build-module/components/collab-sidebar/note-byline.mjs.map +7 -0
  103. package/build-module/components/collab-sidebar/note-card.mjs +33 -0
  104. package/build-module/components/collab-sidebar/note-card.mjs.map +7 -0
  105. package/build-module/components/collab-sidebar/note-form.mjs +84 -0
  106. package/build-module/components/collab-sidebar/note-form.mjs.map +7 -0
  107. package/build-module/components/collab-sidebar/{comment-indicator-toolbar.mjs → note-indicator-toolbar.mjs} +25 -29
  108. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +7 -0
  109. package/build-module/components/collab-sidebar/note-thread.mjs +289 -0
  110. package/build-module/components/collab-sidebar/note-thread.mjs.map +7 -0
  111. package/build-module/components/collab-sidebar/note.mjs +176 -0
  112. package/build-module/components/collab-sidebar/note.mjs.map +7 -0
  113. package/build-module/components/collab-sidebar/notes.mjs +215 -0
  114. package/build-module/components/collab-sidebar/notes.mjs.map +7 -0
  115. package/build-module/components/collab-sidebar/utils.mjs +19 -21
  116. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  117. package/build-module/components/document-bar/index.mjs +3 -3
  118. package/build-module/components/document-bar/index.mjs.map +2 -2
  119. package/build-module/components/error-boundary/index.mjs +2 -2
  120. package/build-module/components/error-boundary/index.mjs.map +2 -2
  121. package/build-module/components/list-view-sidebar/list-view-outline.mjs +5 -5
  122. package/build-module/components/list-view-sidebar/list-view-outline.mjs.map +2 -2
  123. package/build-module/components/media/media-editor-modal.mjs +62 -0
  124. package/build-module/components/media/media-editor-modal.mjs.map +7 -0
  125. package/build-module/components/more-menu/index.mjs +3 -7
  126. package/build-module/components/more-menu/index.mjs.map +2 -2
  127. package/build-module/components/post-actions/set-as-homepage.mjs +2 -2
  128. package/build-module/components/post-actions/set-as-homepage.mjs.map +2 -2
  129. package/build-module/components/post-actions/set-as-posts-page.mjs +2 -2
  130. package/build-module/components/post-actions/set-as-posts-page.mjs.map +2 -2
  131. package/build-module/components/post-card-panel/index.mjs +5 -5
  132. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  133. package/build-module/components/post-content-information/index.mjs +2 -2
  134. package/build-module/components/post-content-information/index.mjs.map +2 -2
  135. package/build-module/components/post-excerpt/panel.mjs +2 -2
  136. package/build-module/components/post-excerpt/panel.mjs.map +2 -2
  137. package/build-module/components/post-last-edited-panel/index.mjs +2 -2
  138. package/build-module/components/post-last-edited-panel/index.mjs.map +2 -2
  139. package/build-module/components/post-preview-button/index.mjs +3 -2
  140. package/build-module/components/post-preview-button/index.mjs.map +2 -2
  141. package/build-module/components/post-publish-button/index.mjs +2 -2
  142. package/build-module/components/post-publish-button/index.mjs.map +2 -2
  143. package/build-module/components/post-publish-button/label.mjs +4 -2
  144. package/build-module/components/post-publish-button/label.mjs.map +2 -2
  145. package/build-module/components/post-publish-panel/postpublish.mjs +3 -3
  146. package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
  147. package/build-module/components/post-revisions-panel/index.mjs +2 -2
  148. package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
  149. package/build-module/components/post-revisions-preview/diff-markers.mjs +1 -1
  150. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  151. package/build-module/components/post-revisions-preview/revisions-slider.mjs +1 -0
  152. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  153. package/build-module/components/post-saved-state/index.mjs +4 -1
  154. package/build-module/components/post-saved-state/index.mjs.map +2 -2
  155. package/build-module/components/post-text-editor/index.mjs +2 -3
  156. package/build-module/components/post-text-editor/index.mjs.map +2 -2
  157. package/build-module/components/preview-dropdown/index.mjs +2 -2
  158. package/build-module/components/preview-dropdown/index.mjs.map +2 -2
  159. package/build-module/components/provider/index.mjs +3 -1
  160. package/build-module/components/provider/index.mjs.map +2 -2
  161. package/build-module/components/provider/use-block-editor-settings.mjs +7 -1
  162. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  163. package/build-module/components/provider/use-upload-save-lock.mjs +2 -12
  164. package/build-module/components/provider/use-upload-save-lock.mjs.map +2 -2
  165. package/build-module/components/resizable-editor/resize-handle.mjs +2 -5
  166. package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
  167. package/build-module/components/revision-created-panel/index.mjs +2 -2
  168. package/build-module/components/revision-created-panel/index.mjs.map +2 -2
  169. package/build-module/components/site-discussion/index.mjs +2 -2
  170. package/build-module/components/site-discussion/index.mjs.map +2 -2
  171. package/build-module/components/template-actions-panel/classic-theme-content.mjs +2 -2
  172. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +2 -2
  173. package/build-module/components/template-part-menu-items/convert-to-regular.mjs +60 -14
  174. package/build-module/components/template-part-menu-items/convert-to-regular.mjs.map +2 -2
  175. package/build-module/components/visual-editor/index.mjs +5 -22
  176. package/build-module/components/visual-editor/index.mjs.map +2 -2
  177. package/build-module/store/private-actions.mjs +0 -7
  178. package/build-module/store/private-actions.mjs.map +2 -2
  179. package/build-module/store/private-selectors.mjs +0 -4
  180. package/build-module/store/private-selectors.mjs.map +2 -2
  181. package/build-module/store/reducer.mjs +0 -9
  182. package/build-module/store/reducer.mjs.map +2 -2
  183. package/build-module/utils/media-finalize/index.mjs +3 -2
  184. package/build-module/utils/media-finalize/index.mjs.map +2 -2
  185. package/build-module/utils/media-upload/index.mjs +14 -25
  186. package/build-module/utils/media-upload/index.mjs.map +2 -2
  187. package/build-style/style-rtl.css +386 -142
  188. package/build-style/style.css +386 -142
  189. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts +5 -0
  190. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts.map +1 -0
  191. package/build-types/components/collab-sidebar/add-note.d.ts +6 -0
  192. package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -0
  193. package/build-types/components/collab-sidebar/board-store.d.ts +1 -0
  194. package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -1
  195. package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -1
  196. package/build-types/components/collab-sidebar/hooks.d.ts +8 -21
  197. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  198. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  199. package/build-types/components/collab-sidebar/note-byline.d.ts +7 -0
  200. package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -0
  201. package/build-types/components/collab-sidebar/note-card.d.ts +8 -0
  202. package/build-types/components/collab-sidebar/note-card.d.ts.map +1 -0
  203. package/build-types/components/collab-sidebar/note-form.d.ts +7 -0
  204. package/build-types/components/collab-sidebar/note-form.d.ts.map +1 -0
  205. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts +5 -0
  206. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -0
  207. package/build-types/components/collab-sidebar/note-thread.d.ts +11 -0
  208. package/build-types/components/collab-sidebar/note-thread.d.ts.map +1 -0
  209. package/build-types/components/collab-sidebar/note.d.ts +9 -0
  210. package/build-types/components/collab-sidebar/note.d.ts.map +1 -0
  211. package/build-types/components/collab-sidebar/notes.d.ts +7 -0
  212. package/build-types/components/collab-sidebar/notes.d.ts.map +1 -0
  213. package/build-types/components/collab-sidebar/utils.d.ts +21 -20
  214. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  215. package/build-types/components/media/media-editor-modal.d.ts +11 -0
  216. package/build-types/components/media/media-editor-modal.d.ts.map +1 -0
  217. package/build-types/components/more-menu/index.d.ts.map +1 -1
  218. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  219. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  220. package/build-types/components/post-publish-button/label.d.ts.map +1 -1
  221. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  222. package/build-types/components/post-saved-state/index.d.ts.map +1 -1
  223. package/build-types/components/provider/index.d.ts.map +1 -1
  224. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  225. package/build-types/components/provider/use-upload-save-lock.d.ts +0 -2
  226. package/build-types/components/provider/use-upload-save-lock.d.ts.map +1 -1
  227. package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
  228. package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -1
  229. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  230. package/build-types/store/private-actions.d.ts +0 -7
  231. package/build-types/store/private-actions.d.ts.map +1 -1
  232. package/build-types/store/private-selectors.d.ts +0 -7
  233. package/build-types/store/private-selectors.d.ts.map +1 -1
  234. package/build-types/store/reducer.d.ts +0 -10
  235. package/build-types/store/reducer.d.ts.map +1 -1
  236. package/build-types/utils/media-finalize/index.d.ts +1 -1
  237. package/build-types/utils/media-finalize/index.d.ts.map +1 -1
  238. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  239. package/package.json +46 -46
  240. package/src/components/collab-sidebar/README.md +117 -0
  241. package/src/components/collab-sidebar/{comment-menu-item.js → add-note-menu-item.js} +8 -10
  242. package/src/components/collab-sidebar/{add-comment.js → add-note.js} +20 -21
  243. package/src/components/collab-sidebar/board-store.js +4 -2
  244. package/src/components/collab-sidebar/floating-container.js +5 -4
  245. package/src/components/collab-sidebar/hooks.js +115 -175
  246. package/src/components/collab-sidebar/index.js +35 -95
  247. package/src/components/collab-sidebar/{comment-author-info.js → note-byline.js} +5 -6
  248. package/src/components/collab-sidebar/note-card.js +36 -0
  249. package/src/components/collab-sidebar/{comment-form.js → note-form.js} +25 -27
  250. package/src/components/collab-sidebar/{comment-indicator-toolbar.js → note-indicator-toolbar.js} +29 -32
  251. package/src/components/collab-sidebar/note-thread.js +331 -0
  252. package/src/components/collab-sidebar/note.js +209 -0
  253. package/src/components/collab-sidebar/notes.js +276 -0
  254. package/src/components/collab-sidebar/style.scss +21 -11
  255. package/src/components/collab-sidebar/test/utils.js +65 -63
  256. package/src/components/collab-sidebar/utils.js +33 -35
  257. package/src/components/document-bar/index.js +4 -4
  258. package/src/components/error-boundary/index.js +3 -3
  259. package/src/components/list-view-sidebar/list-view-outline.js +6 -6
  260. package/src/components/media/media-editor-modal.js +95 -0
  261. package/src/components/more-menu/index.js +3 -7
  262. package/src/components/post-actions/set-as-homepage.js +2 -2
  263. package/src/components/post-actions/set-as-posts-page.js +2 -2
  264. package/src/components/post-card-panel/index.js +7 -7
  265. package/src/components/post-content-information/index.js +3 -3
  266. package/src/components/post-excerpt/panel.js +3 -3
  267. package/src/components/post-last-edited-panel/index.js +3 -3
  268. package/src/components/post-preview-button/index.js +3 -2
  269. package/src/components/post-publish-button/index.js +6 -5
  270. package/src/components/post-publish-button/label.js +3 -1
  271. package/src/components/post-publish-panel/postpublish.js +2 -2
  272. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +8 -14
  273. package/src/components/post-revisions-panel/index.js +3 -3
  274. package/src/components/post-revisions-preview/diff-markers.js +1 -1
  275. package/src/components/post-revisions-preview/revisions-slider.js +1 -0
  276. package/src/components/post-saved-state/index.js +4 -1
  277. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +0 -1
  278. package/src/components/post-text-editor/index.js +3 -3
  279. package/src/components/preview-dropdown/index.js +2 -2
  280. package/src/components/provider/index.js +4 -0
  281. package/src/components/provider/use-block-editor-settings.js +10 -0
  282. package/src/components/provider/use-upload-save-lock.js +2 -17
  283. package/src/components/resizable-editor/resize-handle.js +2 -5
  284. package/src/components/revision-created-panel/index.js +3 -3
  285. package/src/components/site-discussion/index.js +3 -3
  286. package/src/components/template-actions-panel/classic-theme-content.js +3 -3
  287. package/src/components/template-part-menu-items/convert-to-regular.js +74 -12
  288. package/src/components/visual-editor/index.js +2 -29
  289. package/src/store/private-actions.js +0 -13
  290. package/src/store/private-selectors.js +0 -10
  291. package/src/store/reducer.js +0 -16
  292. package/src/utils/media-finalize/index.js +2 -1
  293. package/src/utils/media-finalize/test/index.js +25 -1
  294. package/src/utils/media-upload/index.js +26 -29
  295. package/build/components/collab-sidebar/add-comment.cjs.map +0 -7
  296. package/build/components/collab-sidebar/comment-author-info.cjs.map +0 -7
  297. package/build/components/collab-sidebar/comment-form.cjs.map +0 -7
  298. package/build/components/collab-sidebar/comment-indicator-toolbar.cjs.map +0 -7
  299. package/build/components/collab-sidebar/comment-menu-item.cjs.map +0 -7
  300. package/build/components/collab-sidebar/comments.cjs +0 -696
  301. package/build/components/collab-sidebar/comments.cjs.map +0 -7
  302. package/build-module/components/collab-sidebar/add-comment.mjs.map +0 -7
  303. package/build-module/components/collab-sidebar/comment-author-info.mjs.map +0 -7
  304. package/build-module/components/collab-sidebar/comment-form.mjs +0 -82
  305. package/build-module/components/collab-sidebar/comment-form.mjs.map +0 -7
  306. package/build-module/components/collab-sidebar/comment-indicator-toolbar.mjs.map +0 -7
  307. package/build-module/components/collab-sidebar/comment-menu-item.mjs.map +0 -7
  308. package/build-module/components/collab-sidebar/comments.mjs +0 -678
  309. package/build-module/components/collab-sidebar/comments.mjs.map +0 -7
  310. package/build-types/components/collab-sidebar/add-comment.d.ts +0 -6
  311. package/build-types/components/collab-sidebar/add-comment.d.ts.map +0 -1
  312. package/build-types/components/collab-sidebar/comment-author-info.d.ts +0 -8
  313. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +0 -1
  314. package/build-types/components/collab-sidebar/comment-form.d.ts +0 -9
  315. package/build-types/components/collab-sidebar/comment-form.d.ts.map +0 -1
  316. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +0 -6
  317. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +0 -1
  318. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +0 -6
  319. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +0 -1
  320. package/build-types/components/collab-sidebar/comments.d.ts +0 -10
  321. package/build-types/components/collab-sidebar/comments.d.ts.map +0 -1
  322. package/src/components/collab-sidebar/comments.js +0 -812
@@ -1,6 +1,6 @@
1
1
  // packages/editor/src/components/collab-sidebar/floating-container.js
2
2
  import clsx from "clsx";
3
- import { __experimentalVStack as VStack } from "@wordpress/components";
3
+ import { Stack } from "@wordpress/ui";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  function FloatingContainer({
6
6
  floating,
@@ -11,10 +11,11 @@ function FloatingContainer({
11
11
  }) {
12
12
  const isFloating = !!floating;
13
13
  return /* @__PURE__ */ jsx(
14
- VStack,
14
+ Stack,
15
15
  {
16
+ direction: "column",
16
17
  className: clsx(className, { "is-floating": isFloating }),
17
- ref: isFloating ? floating.refs.setFloating : void 0,
18
+ ref: isFloating ? floating.ref : void 0,
18
19
  style: isFloating ? { top: floating.y, ...style } : style,
19
20
  ...props,
20
21
  children
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/floating-container.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalVStack as VStack } from '@wordpress/components';\n\nexport function FloatingContainer( {\n\tfloating,\n\tclassName,\n\tstyle,\n\tchildren,\n\t...props\n} ) {\n\tconst isFloating = !! floating;\n\treturn (\n\t\t<VStack\n\t\t\tclassName={ clsx( className, { 'is-floating': isFloating } ) }\n\t\t\tref={ isFloating ? floating.refs.setFloating : undefined }\n\t\t\tstyle={ isFloating ? { top: floating.y, ...style } : style }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</VStack>\n\t);\n}\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,wBAAwB,cAAc;AAW7C;AATK,SAAS,kBAAmB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,aAAa,CAAC,CAAE;AACtB,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,KAAM,WAAW,EAAE,eAAe,WAAW,CAAE;AAAA,MAC3D,KAAM,aAAa,SAAS,KAAK,cAAc;AAAA,MAC/C,OAAQ,aAAa,EAAE,KAAK,SAAS,GAAG,GAAG,MAAM,IAAI;AAAA,MACnD,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Stack } from '@wordpress/ui';\n\nexport function FloatingContainer( {\n\tfloating,\n\tclassName,\n\tstyle,\n\tchildren,\n\t...props\n} ) {\n\tconst isFloating = !! floating;\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tclassName={ clsx( className, { 'is-floating': isFloating } ) }\n\t\t\tref={ isFloating ? floating.ref : undefined }\n\t\t\tstyle={ isFloating ? { top: floating.y, ...style } : style }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ children }\n\t\t</Stack>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,aAAa;AAWpB;AATK,SAAS,kBAAmB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAAI;AACH,QAAM,aAAa,CAAC,CAAE;AACtB,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,WAAY,KAAM,WAAW,EAAE,eAAe,WAAW,CAAE;AAAA,MAC3D,KAAM,aAAa,SAAS,MAAM;AAAA,MAClC,OAAQ,aAAa,EAAE,KAAK,SAAS,GAAG,GAAG,MAAM,IAAI;AAAA,MACnD,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,4 @@
1
1
  // packages/editor/src/components/collab-sidebar/hooks.js
2
- import {
3
- useFloating,
4
- offset as offsetMiddleware,
5
- autoUpdate
6
- } from "@floating-ui/react-dom";
7
2
  import { __ } from "@wordpress/i18n";
8
3
  import {
9
4
  useState,
@@ -18,15 +13,16 @@ import {
18
13
  privateApis as blockEditorPrivateApis
19
14
  } from "@wordpress/block-editor";
20
15
  import { store as noticesStore } from "@wordpress/notices";
16
+ import { getScrollContainer } from "@wordpress/dom";
21
17
  import { decodeEntities } from "@wordpress/html-entities";
22
18
  import { store as interfaceStore } from "@wordpress/interface";
23
19
  import { store as editorStore } from "../../store/index.mjs";
24
20
  import { FLOATING_NOTES_SIDEBAR } from "./constants.mjs";
25
21
  import { unlock } from "../../lock-unlock.mjs";
26
22
  import { createBoardStore } from "./board-store.mjs";
27
- import { calculateAllOffsets } from "./utils.mjs";
28
- var { useBlockElement, cleanEmptyObject } = unlock(blockEditorPrivateApis);
29
- function useBlockComments(postId) {
23
+ import { calculateNotePositions } from "./utils.mjs";
24
+ var { cleanEmptyObject } = unlock(blockEditorPrivateApis);
25
+ function useNoteThreads(postId) {
30
26
  const queryArgs = {
31
27
  post: postId,
32
28
  type: "note",
@@ -46,78 +42,68 @@ function useBlockComments(postId) {
46
42
  clientIds: getClientIdsWithDescendants()
47
43
  };
48
44
  }, []);
49
- const { resultComments, unresolvedSortedThreads } = useMemo(() => {
45
+ const { notes, unresolvedNotes } = useMemo(() => {
50
46
  if (!threads || threads.length === 0) {
51
- return { resultComments: [], unresolvedSortedThreads: [] };
47
+ return { notes: [], unresolvedNotes: [] };
52
48
  }
53
- const blocksWithComments = clientIds.reduce((results, clientId) => {
54
- const commentId = getBlockAttributes(clientId)?.metadata?.noteId;
55
- if (commentId) {
56
- results[clientId] = commentId;
49
+ const blocksWithNotes = {};
50
+ const clientIdByNoteId = /* @__PURE__ */ new Map();
51
+ for (const clientId of clientIds) {
52
+ const noteId = getBlockAttributes(clientId)?.metadata?.noteId;
53
+ if (noteId) {
54
+ const key = String(noteId);
55
+ blocksWithNotes[clientId] = key;
56
+ clientIdByNoteId.set(key, clientId);
57
57
  }
58
- return results;
59
- }, {});
60
- const compare = {};
61
- const result = [];
62
- const commentIdToBlockClientId = Object.keys(
63
- blocksWithComments
64
- ).reduce((mapping, clientId) => {
65
- mapping[blocksWithComments[clientId]] = clientId;
66
- return mapping;
67
- }, {});
68
- threads.forEach((item) => {
69
- const itemBlock = commentIdToBlockClientId[item.id];
70
- compare[item.id] = {
58
+ }
59
+ const threadsById = /* @__PURE__ */ new Map();
60
+ const rootThreads = [];
61
+ for (const item of threads) {
62
+ const thread = {
71
63
  ...item,
72
64
  reply: [],
73
- blockClientId: item.parent === 0 ? itemBlock : null
65
+ blockClientId: item.parent === 0 ? clientIdByNoteId.get(String(item.id)) ?? null : null
74
66
  };
75
- });
76
- threads.forEach((item) => {
67
+ threadsById.set(item.id, thread);
77
68
  if (item.parent === 0) {
78
- result.push(compare[item.id]);
79
- } else if (compare[item.parent]) {
80
- compare[item.parent].reply.push(compare[item.id]);
69
+ rootThreads.push(thread);
81
70
  }
82
- });
83
- if (0 === result?.length) {
84
- return { resultComments: [], unresolvedSortedThreads: [] };
85
71
  }
86
- const updatedResult = result.map((item) => ({
87
- ...item,
88
- reply: [...item.reply].reverse()
89
- }));
90
- const threadIdMap = new Map(
91
- updatedResult.map((thread) => [String(thread.id), thread])
92
- );
93
- const mappedIds = new Set(
94
- Object.values(blocksWithComments).map((id) => String(id))
95
- );
96
- const unresolvedSortedComments = Object.values(blocksWithComments).map((commentId) => threadIdMap.get(String(commentId))).filter(
97
- (thread) => thread !== void 0 && thread.status === "hold"
98
- );
99
- const resolvedSortedComments = Object.values(blocksWithComments).map((commentId) => threadIdMap.get(String(commentId))).filter(
100
- (thread) => thread !== void 0 && thread.status === "approved"
101
- );
102
- const orphanedComments = updatedResult.filter(
103
- (thread) => !mappedIds.has(String(thread.id))
72
+ for (const item of threads) {
73
+ if (item.parent !== 0) {
74
+ threadsById.get(item.parent)?.reply.unshift(threadsById.get(item.id));
75
+ }
76
+ }
77
+ if (rootThreads.length === 0) {
78
+ return { notes: [], unresolvedNotes: [] };
79
+ }
80
+ const unresolved = [];
81
+ const resolved = [];
82
+ for (const noteId of Object.values(blocksWithNotes)) {
83
+ const thread = threadsById.get(Number(noteId)) ?? threadsById.get(noteId);
84
+ if (!thread) {
85
+ continue;
86
+ }
87
+ if (thread.status === "hold") {
88
+ unresolved.push(thread);
89
+ } else if (thread.status === "approved") {
90
+ resolved.push(thread);
91
+ }
92
+ }
93
+ const orphans = rootThreads.filter(
94
+ (thread) => !thread.blockClientId
104
95
  );
105
- const allSortedComments = [
106
- ...unresolvedSortedComments,
107
- ...resolvedSortedComments,
108
- ...orphanedComments
109
- ];
110
96
  return {
111
- resultComments: allSortedComments,
112
- unresolvedSortedThreads: unresolvedSortedComments
97
+ notes: [...unresolved, ...resolved, ...orphans],
98
+ unresolvedNotes: unresolved
113
99
  };
114
100
  }, [clientIds, threads, getBlockAttributes]);
115
101
  return {
116
- resultComments,
117
- unresolvedSortedThreads
102
+ notes,
103
+ unresolvedNotes
118
104
  };
119
105
  }
120
- function useBlockCommentsActions() {
106
+ function useNoteActions() {
121
107
  const { createNotice } = useDispatch(noticesStore);
122
108
  const { saveEntityRecord, deleteEntityRecord } = useDispatch(coreStore);
123
109
  const { getCurrentPostId } = useSelect(editorStore);
@@ -187,7 +173,7 @@ function useBlockCommentsActions() {
187
173
  throwOnError: true
188
174
  }
189
175
  );
190
- const newCommentData = {
176
+ const newNoteData = {
191
177
  post: getCurrentPostId(),
192
178
  content: content || "",
193
179
  // Empty content for resolve, content for reopen.
@@ -198,7 +184,7 @@ function useBlockCommentsActions() {
198
184
  _wp_note_status: status === "approved" ? "resolved" : "reopen"
199
185
  }
200
186
  };
201
- await saveEntityRecord("root", "comment", newCommentData, {
187
+ await saveEntityRecord("root", "comment", newNoteData, {
202
188
  throwOnError: true
203
189
  });
204
190
  } else {
@@ -223,18 +209,12 @@ function useBlockCommentsActions() {
223
209
  onError(error);
224
210
  }
225
211
  };
226
- const onDelete = async (comment) => {
212
+ const onDelete = async (note) => {
227
213
  try {
228
- await deleteEntityRecord(
229
- "root",
230
- "comment",
231
- comment.id,
232
- void 0,
233
- {
234
- throwOnError: true
235
- }
236
- );
237
- if (!comment.parent) {
214
+ await deleteEntityRecord("root", "comment", note.id, void 0, {
215
+ throwOnError: true
216
+ });
217
+ if (!note.parent) {
238
218
  const clientId = getSelectedBlockClientId();
239
219
  const metadata = getBlockAttributes(clientId)?.metadata;
240
220
  updateBlockAttributes(clientId, {
@@ -275,84 +255,58 @@ function useEnableFloatingSidebar(enabled = false) {
275
255
  };
276
256
  }, [enabled, registry]);
277
257
  }
278
- function useFloatingBoard({ threads, selectedNoteId, isFloating }) {
279
- const [boardOffsets, setBoardOffsets] = useState({});
258
+ function useFloatingBoard({
259
+ threads,
260
+ selectedNoteId,
261
+ isFloating,
262
+ sidebarRef
263
+ }) {
264
+ const [notePositions, setNotePositions] = useState({});
280
265
  const [store] = useState(createBoardStore);
281
- const { setCanvasMinHeight } = unlock(useDispatch(editorStore));
282
266
  const heights = useSyncExternalStore(store.subscribe, store.getSnapshot);
283
267
  useEffect(() => {
284
- if (!isFloating) {
268
+ if (!isFloating || !sidebarRef?.current) {
285
269
  return;
286
270
  }
271
+ const panel = sidebarRef.current;
272
+ const blockEl = store.getFirstBlockElement();
273
+ const rootEl = blockEl?.closest(".is-root-container") ?? blockEl;
274
+ const canvas = rootEl ? getScrollContainer(rootEl) : null;
275
+ const applyScroll = () => {
276
+ panel.style.setProperty(
277
+ "--canvas-scroll",
278
+ `${-(canvas?.scrollTop ?? 0)}px`
279
+ );
280
+ };
287
281
  const rafId = window.requestAnimationFrame(() => {
288
- const { offsets, minHeight } = calculateAllOffsets({
282
+ const result = calculateNotePositions({
289
283
  threads,
290
284
  selectedNoteId,
291
285
  blockRects: store.getBlockRects(),
292
- heights
286
+ heights,
287
+ scrollTop: canvas?.scrollTop ?? 0
293
288
  });
294
- setBoardOffsets(offsets);
295
- setCanvasMinHeight(minHeight);
289
+ setNotePositions(result.positions);
290
+ applyScroll();
296
291
  });
297
- return () => window.cancelAnimationFrame(rafId);
298
- }, [
299
- heights,
300
- isFloating,
301
- selectedNoteId,
302
- setCanvasMinHeight,
303
- store,
304
- threads
305
- ]);
292
+ const view = canvas?.ownerDocument?.defaultView;
293
+ const listenerOptions = { passive: true, capture: true };
294
+ view?.addEventListener("scroll", applyScroll, listenerOptions);
295
+ return () => {
296
+ window.cancelAnimationFrame(rafId);
297
+ view?.removeEventListener("scroll", applyScroll, listenerOptions);
298
+ };
299
+ }, [sidebarRef, heights, isFloating, selectedNoteId, store, threads]);
306
300
  return {
307
- boardOffsets,
301
+ notePositions,
308
302
  registerThread: store.registerThread,
309
303
  unregisterThread: store.unregisterThread
310
304
  };
311
305
  }
312
- function useFloatingThread({
313
- thread,
314
- calculatedOffset,
315
- registerThread,
316
- unregisterThread
317
- }) {
318
- const blockElement = useBlockElement(thread.blockClientId);
319
- const { y, refs } = useFloating({
320
- placement: "right-start",
321
- middleware: [
322
- offsetMiddleware({
323
- crossAxis: calculatedOffset || -16
324
- })
325
- ],
326
- whileElementsMounted: autoUpdate
327
- });
328
- useEffect(() => {
329
- if (blockElement) {
330
- refs.setReference(blockElement);
331
- }
332
- }, [blockElement, refs]);
333
- useEffect(() => {
334
- const floatingEl = refs.floating?.current;
335
- if (floatingEl && registerThread) {
336
- registerThread(thread.id, blockElement, floatingEl);
337
- }
338
- return () => unregisterThread?.(thread.id);
339
- }, [
340
- blockElement,
341
- thread.id,
342
- refs.floating,
343
- registerThread,
344
- unregisterThread
345
- ]);
346
- return {
347
- y,
348
- refs
349
- };
350
- }
351
306
  export {
352
- useBlockComments,
353
- useBlockCommentsActions,
354
307
  useEnableFloatingSidebar,
355
308
  useFloatingBoard,
356
- useFloatingThread
309
+ useNoteActions,
310
+ useNoteThreads
357
311
  };
358
312
  //# sourceMappingURL=hooks.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/hooks.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tuseFloating,\n\toffset as offsetMiddleware,\n\tautoUpdate,\n} from '@floating-ui/react-dom';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseMemo,\n\tuseSyncExternalStore,\n} from '@wordpress/element';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { FLOATING_NOTES_SIDEBAR } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { createBoardStore } from './board-store';\nimport { calculateAllOffsets } from './utils';\n\nconst { useBlockElement, cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\nexport function useBlockComments( postId ) {\n\tconst queryArgs = {\n\t\tpost: postId,\n\t\ttype: 'note',\n\t\tstatus: 'all',\n\t\tper_page: -1,\n\t};\n\n\tconst { records: threads } = useEntityRecords(\n\t\t'root',\n\t\t'comment',\n\t\tqueryArgs,\n\t\t{ enabled: !! postId && typeof postId === 'number' }\n\t);\n\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst { clientIds } = useSelect( ( select ) => {\n\t\tconst { getClientIdsWithDescendants } = select( blockEditorStore );\n\t\treturn {\n\t\t\tclientIds: getClientIdsWithDescendants(),\n\t\t};\n\t}, [] );\n\n\t// Process comments to build the tree structure.\n\tconst { resultComments, unresolvedSortedThreads } = useMemo( () => {\n\t\tif ( ! threads || threads.length === 0 ) {\n\t\t\treturn { resultComments: [], unresolvedSortedThreads: [] };\n\t\t}\n\n\t\tconst blocksWithComments = clientIds.reduce( ( results, clientId ) => {\n\t\t\tconst commentId = getBlockAttributes( clientId )?.metadata?.noteId;\n\t\t\tif ( commentId ) {\n\t\t\t\tresults[ clientId ] = commentId;\n\t\t\t}\n\t\t\treturn results;\n\t\t}, {} );\n\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\t// Create a reverse map for faster lookup.\n\t\tconst commentIdToBlockClientId = Object.keys(\n\t\t\tblocksWithComments\n\t\t).reduce( ( mapping, clientId ) => {\n\t\t\tmapping[ blocksWithComments[ clientId ] ] = clientId;\n\t\t\treturn mapping;\n\t\t}, {} );\n\n\t\t// Initialize each object with an empty `reply` array and map blockClientId.\n\t\tthreads.forEach( ( item ) => {\n\t\t\tconst itemBlock = commentIdToBlockClientId[ item.id ];\n\n\t\t\tcompare[ item.id ] = {\n\t\t\t\t...item,\n\t\t\t\treply: [],\n\t\t\t\tblockClientId: item.parent === 0 ? itemBlock : null,\n\t\t\t};\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure.\n\t\tthreads.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: [], unresolvedSortedThreads: [] };\n\t\t}\n\n\t\tconst updatedResult = result.map( ( item ) => ( {\n\t\t\t...item,\n\t\t\treply: [ ...item.reply ].reverse(),\n\t\t} ) );\n\n\t\tconst threadIdMap = new Map(\n\t\t\tupdatedResult.map( ( thread ) => [ String( thread.id ), thread ] )\n\t\t);\n\n\t\t// Prepare sets to determine which threads are linked to existing blocks.\n\t\tconst mappedIds = new Set(\n\t\t\tObject.values( blocksWithComments ).map( ( id ) => String( id ) )\n\t\t);\n\n\t\t// Get comments by block order, first unresolved, then resolved.\n\t\tconst unresolvedSortedComments = Object.values( blocksWithComments )\n\t\t\t.map( ( commentId ) => threadIdMap.get( String( commentId ) ) )\n\t\t\t.filter(\n\t\t\t\t( thread ) => thread !== undefined && thread.status === 'hold'\n\t\t\t);\n\n\t\tconst resolvedSortedComments = Object.values( blocksWithComments )\n\t\t\t.map( ( commentId ) => threadIdMap.get( String( commentId ) ) )\n\t\t\t.filter(\n\t\t\t\t( thread ) =>\n\t\t\t\t\tthread !== undefined && thread.status === 'approved'\n\t\t\t);\n\n\t\t// Append orphaned notes (whose related block was deleted or missing).\n\t\tconst orphanedComments = updatedResult.filter(\n\t\t\t( thread ) => ! mappedIds.has( String( thread.id ) )\n\t\t);\n\n\t\tconst allSortedComments = [\n\t\t\t...unresolvedSortedComments,\n\t\t\t...resolvedSortedComments,\n\t\t\t...orphanedComments,\n\t\t];\n\n\t\treturn {\n\t\t\tresultComments: allSortedComments,\n\t\t\tunresolvedSortedThreads: unresolvedSortedComments,\n\t\t};\n\t}, [ clientIds, threads, getBlockAttributes ] );\n\n\treturn {\n\t\tresultComments,\n\t\tunresolvedSortedThreads,\n\t};\n}\n\nexport function useBlockCommentsActions() {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onError = ( error ) => {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? decodeEntities( error.message )\n\t\t\t\t: __( 'An error occurred while performing an update.' );\n\t\tcreateNotice( 'error', errorMessage, {\n\t\t\ttype: 'snackbar',\n\t\t\tisDismissible: true,\n\t\t} );\n\t};\n\n\tconst onCreate = async ( { content, parent } ) => {\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tpost: getCurrentPostId(),\n\t\t\t\t\tcontent,\n\t\t\t\t\tstatus: 'hold',\n\t\t\t\t\ttype: 'note',\n\t\t\t\t\tparent: parent || 0,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parent && savedRecord?.id ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t\tnoteId: savedRecord.id,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparent ? __( 'Reply added.' ) : __( 'Note added.' ),\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\treturn savedRecord;\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onEdit = async ( { id, content, status } ) => {\n\t\tconst messageType = status ? status : 'updated';\n\t\tconst messages = {\n\t\t\tapproved: __( 'Note marked as resolved.' ),\n\t\t\thold: __( 'Note reopened.' ),\n\t\t\tupdated: __( 'Note updated.' ),\n\t\t};\n\n\t\ttry {\n\t\t\t// For resolution or reopen actions, create a new note with metadata.\n\t\t\tif ( status === 'approved' || status === 'hold' ) {\n\t\t\t\t// First, update the thread status.\n\t\t\t\tawait saveEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'comment',\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Then create a new comment with the metadata.\n\t\t\t\tconst newCommentData = {\n\t\t\t\t\tpost: getCurrentPostId(),\n\t\t\t\t\tcontent: content || '', // Empty content for resolve, content for reopen.\n\t\t\t\t\ttype: 'note',\n\t\t\t\t\tstatus,\n\t\t\t\t\tparent: id,\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\t_wp_note_status:\n\t\t\t\t\t\t\tstatus === 'approved' ? 'resolved' : 'reopen',\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tawait saveEntityRecord( 'root', 'comment', newCommentData, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst updateData = {\n\t\t\t\t\tid,\n\t\t\t\t\tcontent,\n\t\t\t\t\tstatus,\n\t\t\t\t};\n\n\t\t\t\tawait saveEntityRecord( 'root', 'comment', updateData, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tmessages[ messageType ] ?? __( 'Note updated.' ),\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} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onDelete = async ( comment ) => {\n\t\ttry {\n\t\t\tawait deleteEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\tcomment.id,\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! comment.parent ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t\tnoteId: undefined,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice( 'snackbar', __( 'Note deleted.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\treturn { onCreate, onEdit, onDelete };\n}\n\nexport function useEnableFloatingSidebar( enabled = false ) {\n\tconst registry = useRegistry();\n\tuseEffect( () => {\n\t\tif ( ! enabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { getActiveComplementaryArea } =\n\t\t\tregistry.select( interfaceStore );\n\t\tconst { disableComplementaryArea, enableComplementaryArea } =\n\t\t\tregistry.dispatch( interfaceStore );\n\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Return `null` to indicate the user hid the complementary area.\n\t\t\tif ( getActiveComplementaryArea( 'core' ) === null ) {\n\t\t\t\tenableComplementaryArea( 'core', FLOATING_NOTES_SIDEBAR );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tif (\n\t\t\t\tgetActiveComplementaryArea( 'core' ) === FLOATING_NOTES_SIDEBAR\n\t\t\t) {\n\t\t\t\tdisableComplementaryArea( 'core', FLOATING_NOTES_SIDEBAR );\n\t\t\t}\n\t\t};\n\t}, [ enabled, registry ] );\n}\n\nexport function useFloatingBoard( { threads, selectedNoteId, isFloating } ) {\n\tconst [ boardOffsets, setBoardOffsets ] = useState( {} );\n\tconst [ store ] = useState( createBoardStore );\n\tconst { setCanvasMinHeight } = unlock( useDispatch( editorStore ) );\n\n\tconst heights = useSyncExternalStore( store.subscribe, store.getSnapshot );\n\n\t// Recalc is deferred to a rAF; the cleanup cancels the pending frame\n\t// when deps change, so back-to-back updates collapse into one paint.\n\tuseEffect( () => {\n\t\tif ( ! isFloating ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst rafId = window.requestAnimationFrame( () => {\n\t\t\tconst { offsets, minHeight } = calculateAllOffsets( {\n\t\t\t\tthreads,\n\t\t\t\tselectedNoteId,\n\t\t\t\tblockRects: store.getBlockRects(),\n\t\t\t\theights,\n\t\t\t} );\n\t\t\tsetBoardOffsets( offsets );\n\t\t\tsetCanvasMinHeight( minHeight );\n\t\t} );\n\n\t\treturn () => window.cancelAnimationFrame( rafId );\n\t}, [\n\t\theights,\n\t\tisFloating,\n\t\tselectedNoteId,\n\t\tsetCanvasMinHeight,\n\t\tstore,\n\t\tthreads,\n\t] );\n\n\treturn {\n\t\tboardOffsets,\n\t\tregisterThread: store.registerThread,\n\t\tunregisterThread: store.unregisterThread,\n\t};\n}\n\nexport function useFloatingThread( {\n\tthread,\n\tcalculatedOffset,\n\tregisterThread,\n\tunregisterThread,\n} ) {\n\tconst blockElement = useBlockElement( thread.blockClientId );\n\n\t// Use floating-ui to track the block element's position with the calculated offset.\n\tconst { y, refs } = useFloating( {\n\t\tplacement: 'right-start',\n\t\tmiddleware: [\n\t\t\toffsetMiddleware( {\n\t\t\t\tcrossAxis: calculatedOffset || -16,\n\t\t\t} ),\n\t\t],\n\t\twhileElementsMounted: autoUpdate,\n\t} );\n\n\t// Set the floating-ui reference element.\n\tuseEffect( () => {\n\t\tif ( blockElement ) {\n\t\t\trefs.setReference( blockElement );\n\t\t}\n\t}, [ blockElement, refs ] );\n\n\t// Register block + floating elements with the board.\n\t// The board's ResizeObserver tracks height changes automatically.\n\tuseEffect( () => {\n\t\tconst floatingEl = refs.floating?.current;\n\t\tif ( floatingEl && registerThread ) {\n\t\t\tregisterThread( thread.id, blockElement, floatingEl );\n\t\t}\n\t\treturn () => unregisterThread?.( thread.id );\n\t}, [\n\t\tblockElement,\n\t\tthread.id,\n\t\trefs.floating,\n\t\tregisterThread,\n\t\tunregisterThread,\n\t] );\n\n\treturn {\n\t\ty,\n\t\trefs,\n\t};\n}\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA,UAAU;AAAA,EACV;AAAA,OACM;AAKP,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA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AA,MAChC,CAAE;AAAA,IACH;AAAA,IACA,sBAAsB;AAAA,EACvB,CAAE;AAGF,YAAW,MAAM;AAChB,QAAK,cAAe;AACnB,WAAK,aAAc,YAAa;AAAA,IACjC;AAAA,EACD,GAAG,CAAE,cAAc,IAAK,CAAE;AAI1B,YAAW,MAAM;AAChB,UAAM,aAAa,KAAK,UAAU;AAClC,QAAK,cAAc,gBAAiB;AACnC,qBAAgB,OAAO,IAAI,cAAc,UAAW;AAAA,IACrD;AACA,WAAO,MAAM,mBAAoB,OAAO,EAAG;AAAA,EAC5C,GAAG;AAAA,IACF;AAAA,IACA,OAAO;AAAA,IACP,KAAK;AAAA,IACL;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseMemo,\n\tuseSyncExternalStore,\n} from '@wordpress/element';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { FLOATING_NOTES_SIDEBAR } from './constants';\nimport { unlock } from '../../lock-unlock';\nimport { createBoardStore } from './board-store';\nimport { calculateNotePositions } from './utils';\n\nconst { cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\nexport function useNoteThreads( postId ) {\n\tconst queryArgs = {\n\t\tpost: postId,\n\t\ttype: 'note',\n\t\tstatus: 'all',\n\t\tper_page: -1,\n\t};\n\n\tconst { records: threads } = useEntityRecords(\n\t\t'root',\n\t\t'comment',\n\t\tqueryArgs,\n\t\t{ enabled: !! postId && typeof postId === 'number' }\n\t);\n\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst { clientIds } = useSelect( ( select ) => {\n\t\tconst { getClientIdsWithDescendants } = select( blockEditorStore );\n\t\treturn {\n\t\t\tclientIds: getClientIdsWithDescendants(),\n\t\t};\n\t}, [] );\n\n\t// Process notes to build the tree structure.\n\tconst { notes, unresolvedNotes } = useMemo( () => {\n\t\tif ( ! threads || threads.length === 0 ) {\n\t\t\treturn { notes: [], unresolvedNotes: [] };\n\t\t}\n\n\t\t// Single pass over clientIds: build clientId->noteId map AND reverse lookup.\n\t\tconst blocksWithNotes = {};\n\t\tconst clientIdByNoteId = new Map();\n\t\tfor ( const clientId of clientIds ) {\n\t\t\tconst noteId = getBlockAttributes( clientId )?.metadata?.noteId;\n\t\t\tif ( noteId ) {\n\t\t\t\tconst key = String( noteId );\n\t\t\t\tblocksWithNotes[ clientId ] = key;\n\t\t\t\tclientIdByNoteId.set( key, clientId );\n\t\t\t}\n\t\t}\n\n\t\t// Materialize threads; collect roots; replies linked in a second pass\n\t\t// via unshift to invert order (matches prior reverse semantics).\n\t\tconst threadsById = new Map();\n\t\tconst rootThreads = [];\n\t\tfor ( const item of threads ) {\n\t\t\tconst thread = {\n\t\t\t\t...item,\n\t\t\t\treply: [],\n\t\t\t\tblockClientId:\n\t\t\t\t\titem.parent === 0\n\t\t\t\t\t\t? clientIdByNoteId.get( String( item.id ) ) ?? null\n\t\t\t\t\t\t: null,\n\t\t\t};\n\t\t\tthreadsById.set( item.id, thread );\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\trootThreads.push( thread );\n\t\t\t}\n\t\t}\n\t\tfor ( const item of threads ) {\n\t\t\tif ( item.parent !== 0 ) {\n\t\t\t\tthreadsById\n\t\t\t\t\t.get( item.parent )\n\t\t\t\t\t?.reply.unshift( threadsById.get( item.id ) );\n\t\t\t}\n\t\t}\n\n\t\tif ( rootThreads.length === 0 ) {\n\t\t\treturn { notes: [], unresolvedNotes: [] };\n\t\t}\n\n\t\t// Single partition over notes-in-block-order.\n\t\tconst unresolved = [];\n\t\tconst resolved = [];\n\t\tfor ( const noteId of Object.values( blocksWithNotes ) ) {\n\t\t\tconst thread =\n\t\t\t\tthreadsById.get( Number( noteId ) ) ??\n\t\t\t\tthreadsById.get( noteId );\n\t\t\tif ( ! thread ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( thread.status === 'hold' ) {\n\t\t\t\tunresolved.push( thread );\n\t\t\t} else if ( thread.status === 'approved' ) {\n\t\t\t\tresolved.push( thread );\n\t\t\t}\n\t\t}\n\n\t\t// Orphans: root threads without a linked block. They only need to come last.\n\t\tconst orphans = rootThreads.filter(\n\t\t\t( thread ) => ! thread.blockClientId\n\t\t);\n\n\t\treturn {\n\t\t\tnotes: [ ...unresolved, ...resolved, ...orphans ],\n\t\t\tunresolvedNotes: unresolved,\n\t\t};\n\t}, [ clientIds, threads, getBlockAttributes ] );\n\n\treturn {\n\t\tnotes,\n\t\tunresolvedNotes,\n\t};\n}\n\nexport function useNoteActions() {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\tconst { getBlockAttributes, getSelectedBlockClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst onError = ( error ) => {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? decodeEntities( error.message )\n\t\t\t\t: __( 'An error occurred while performing an update.' );\n\t\tcreateNotice( 'error', errorMessage, {\n\t\t\ttype: 'snackbar',\n\t\t\tisDismissible: true,\n\t\t} );\n\t};\n\n\tconst onCreate = async ( { content, parent } ) => {\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'comment',\n\t\t\t\t{\n\t\t\t\t\tpost: getCurrentPostId(),\n\t\t\t\t\tcontent,\n\t\t\t\t\tstatus: 'hold',\n\t\t\t\t\ttype: 'note',\n\t\t\t\t\tparent: parent || 0,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// If it's a top-level note, update the block attributes with the note id.\n\t\t\tif ( ! parent && savedRecord?.id ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t\tnoteId: savedRecord.id,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparent ? __( 'Reply added.' ) : __( 'Note added.' ),\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\treturn savedRecord;\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onEdit = async ( { id, content, status } ) => {\n\t\tconst messageType = status ? status : 'updated';\n\t\tconst messages = {\n\t\t\tapproved: __( 'Note marked as resolved.' ),\n\t\t\thold: __( 'Note reopened.' ),\n\t\t\tupdated: __( 'Note updated.' ),\n\t\t};\n\n\t\ttry {\n\t\t\t// For resolution or reopen actions, create a new note with metadata.\n\t\t\tif ( status === 'approved' || status === 'hold' ) {\n\t\t\t\t// First, update the thread status.\n\t\t\t\tawait saveEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'comment',\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Then create a new note with the metadata.\n\t\t\t\tconst newNoteData = {\n\t\t\t\t\tpost: getCurrentPostId(),\n\t\t\t\t\tcontent: content || '', // Empty content for resolve, content for reopen.\n\t\t\t\t\ttype: 'note',\n\t\t\t\t\tstatus,\n\t\t\t\t\tparent: id,\n\t\t\t\t\tmeta: {\n\t\t\t\t\t\t_wp_note_status:\n\t\t\t\t\t\t\tstatus === 'approved' ? 'resolved' : 'reopen',\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\tawait saveEntityRecord( 'root', 'comment', newNoteData, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst updateData = {\n\t\t\t\t\tid,\n\t\t\t\t\tcontent,\n\t\t\t\t\tstatus,\n\t\t\t\t};\n\n\t\t\t\tawait saveEntityRecord( 'root', 'comment', updateData, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tmessages[ messageType ] ?? __( 'Note updated.' ),\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} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\tconst onDelete = async ( note ) => {\n\t\ttry {\n\t\t\tawait deleteEntityRecord( 'root', 'comment', note.id, undefined, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\n\t\t\tif ( ! note.parent ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t\tnoteId: undefined,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice( 'snackbar', __( 'Note deleted.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tonError( error );\n\t\t}\n\t};\n\n\treturn { onCreate, onEdit, onDelete };\n}\n\nexport function useEnableFloatingSidebar( enabled = false ) {\n\tconst registry = useRegistry();\n\tuseEffect( () => {\n\t\tif ( ! enabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { getActiveComplementaryArea } =\n\t\t\tregistry.select( interfaceStore );\n\t\tconst { disableComplementaryArea, enableComplementaryArea } =\n\t\t\tregistry.dispatch( interfaceStore );\n\n\t\tconst unsubscribe = registry.subscribe( () => {\n\t\t\t// Return `null` to indicate the user hid the complementary area.\n\t\t\tif ( getActiveComplementaryArea( 'core' ) === null ) {\n\t\t\t\tenableComplementaryArea( 'core', FLOATING_NOTES_SIDEBAR );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribe();\n\t\t\tif (\n\t\t\t\tgetActiveComplementaryArea( 'core' ) === FLOATING_NOTES_SIDEBAR\n\t\t\t) {\n\t\t\t\tdisableComplementaryArea( 'core', FLOATING_NOTES_SIDEBAR );\n\t\t\t}\n\t\t};\n\t}, [ enabled, registry ] );\n}\n\nexport function useFloatingBoard( {\n\tthreads,\n\tselectedNoteId,\n\tisFloating,\n\tsidebarRef,\n} ) {\n\tconst [ notePositions, setNotePositions ] = useState( {} );\n\tconst [ store ] = useState( createBoardStore );\n\n\tconst heights = useSyncExternalStore( store.subscribe, store.getSnapshot );\n\n\t// Notes are positioned in canvas content-space; CSS inherits\n\t// `--canvas-scroll` to translate each thread in sync with the canvas.\n\tuseEffect( () => {\n\t\tif ( ! isFloating || ! sidebarRef?.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst panel = sidebarRef.current;\n\t\tconst blockEl = store.getFirstBlockElement();\n\t\t// Climb to the block-list root so nested scroll containers\n\t\t// (e.g. a Group with overflow:auto) don't shadow the canvas.\n\t\tconst rootEl = blockEl?.closest( '.is-root-container' ) ?? blockEl;\n\t\tconst canvas = rootEl ? getScrollContainer( rootEl ) : null;\n\n\t\tconst applyScroll = () => {\n\t\t\tpanel.style.setProperty(\n\t\t\t\t'--canvas-scroll',\n\t\t\t\t`${ -( canvas?.scrollTop ?? 0 ) }px`\n\t\t\t);\n\t\t};\n\n\t\t// Recalc is deferred to a rAF; back-to-back updates collapse into one paint.\n\t\tconst rafId = window.requestAnimationFrame( () => {\n\t\t\tconst result = calculateNotePositions( {\n\t\t\t\tthreads,\n\t\t\t\tselectedNoteId,\n\t\t\t\tblockRects: store.getBlockRects(),\n\t\t\t\theights,\n\t\t\t\tscrollTop: canvas?.scrollTop ?? 0,\n\t\t\t} );\n\n\t\t\tsetNotePositions( result.positions );\n\t\t\tapplyScroll();\n\t\t} );\n\n\t\t// Root scrolling elements (documentElement/body) don't fire scroll\n\t\t// on themselves; capture on the window catches them in either canvas.\n\t\tconst view = canvas?.ownerDocument?.defaultView;\n\t\tconst listenerOptions = { passive: true, capture: true };\n\t\tview?.addEventListener( 'scroll', applyScroll, listenerOptions );\n\n\t\treturn () => {\n\t\t\twindow.cancelAnimationFrame( rafId );\n\t\t\tview?.removeEventListener( 'scroll', applyScroll, listenerOptions );\n\t\t};\n\t}, [ sidebarRef, heights, isFloating, selectedNoteId, store, threads ] );\n\n\treturn {\n\t\tnotePositions,\n\t\tregisterThread: store.registerThread,\n\t\tunregisterThread: store.unregisterThread,\n\t};\n}\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB,SAAS,iBAAiB;AACrD,SAAS,aAAa,aAAa,iBAAiB;AACpD;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AACP,SAAS,SAAS,oBAAoB;AACtC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,SAAS,sBAAsB;AAKxC,SAAS,SAAS,mBAAmB;AACrC,SAAS,8BAA8B;AACvC,SAA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uBAAwB;AAAA,QACtC;AAAA,QACA;AAAA,QACA,YAAY,MAAM,cAAc;AAAA,QAChC;AAAA,QACA,WAAW,QAAQ,aAAa;AAAA,MACjC,CAAE;AAEF,uBAAkB,OAAO,SAAU;AACnC,kBAAY;AAAA,IACb,CAAE;AAIF,UAAM,OAAO,QAAQ,eAAe;AACpC,UAAM,kBAAkB,EAAE,SAAS,MAAM,SAAS,KAAK;AACvD,UAAM,iBAAkB,UAAU,aAAa,eAAgB;AAE/D,WAAO,MAAM;AACZ,aAAO,qBAAsB,KAAM;AACnC,YAAM,oBAAqB,UAAU,aAAa,eAAgB;AAAA,IACnE;AAAA,EACD,GAAG,CAAE,YAAY,SAAS,YAAY,gBAAgB,OAAO,OAAQ,CAAE;AAEvE,SAAO;AAAA,IACN;AAAA,IACA,gBAAgB,MAAM;AAAA,IACtB,kBAAkB,MAAM;AAAA,EACzB;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,6 @@
1
1
  // packages/editor/src/components/collab-sidebar/index.js
2
2
  import { __ } from "@wordpress/i18n";
3
3
  import { useSelect, useDispatch } from "@wordpress/data";
4
- import { __experimentalVStack as VStack } from "@wordpress/components";
5
4
  import { useRef } from "@wordpress/element";
6
5
  import { useViewportMatch } from "@wordpress/compose";
7
6
  import { useShortcut } from "@wordpress/keyboard-shortcuts";
@@ -15,54 +14,15 @@ import {
15
14
  FLOATING_NOTES_SIDEBAR,
16
15
  SIDEBARS
17
16
  } from "./constants.mjs";
18
- import { Comments } from "./comments.mjs";
17
+ import { Notes } from "./notes.mjs";
19
18
  import { store as editorStore } from "../../store/index.mjs";
20
- import AddCommentMenuItem from "./comment-menu-item.mjs";
21
- import CommentAvatarIndicator from "./comment-indicator-toolbar.mjs";
19
+ import { AddNoteMenuItem } from "./add-note-menu-item.mjs";
20
+ import { NoteAvatarIndicator } from "./note-indicator-toolbar.mjs";
22
21
  import { useGlobalStylesContext } from "../global-styles-provider/index.mjs";
23
- import {
24
- useBlockComments,
25
- useBlockCommentsActions,
26
- useEnableFloatingSidebar
27
- } from "./hooks.mjs";
22
+ import { useNoteThreads, useEnableFloatingSidebar } from "./hooks.mjs";
28
23
  import PostTypeSupportCheck from "../post-type-support-check/index.mjs";
29
24
  import { unlock } from "../../lock-unlock.mjs";
30
25
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
31
- function NotesSidebarContent({
32
- styles,
33
- comments,
34
- commentSidebarRef,
35
- isFloating = false
36
- }) {
37
- const { onCreate, onEdit, onDelete } = useBlockCommentsActions();
38
- return /* @__PURE__ */ jsx(
39
- VStack,
40
- {
41
- className: "editor-collab-sidebar-panel",
42
- style: styles,
43
- role: "tree",
44
- spacing: "3",
45
- justify: "flex-start",
46
- ref: (node) => {
47
- if (node) {
48
- commentSidebarRef.current = node;
49
- }
50
- },
51
- "aria-label": isFloating ? __("Unresolved notes") : __("All notes"),
52
- children: /* @__PURE__ */ jsx(
53
- Comments,
54
- {
55
- threads: comments,
56
- onEditComment: onEdit,
57
- onAddReply: onCreate,
58
- onCommentDelete: onDelete,
59
- commentSidebarRef,
60
- isFloating
61
- }
62
- )
63
- }
64
- );
65
- }
66
26
  function NotesSidebar({ postId }) {
67
27
  const { getActiveComplementaryArea } = useSelect(interfaceStore);
68
28
  const { enableComplementaryArea } = useDispatch(interfaceStore);
@@ -71,23 +31,16 @@ function NotesSidebar({ postId }) {
71
31
  );
72
32
  const { selectNote } = unlock(useDispatch(editorStore));
73
33
  const isLargeViewport = useViewportMatch("medium");
74
- const commentSidebarRef = useRef(null);
75
- const { clientId, blockCommentId, isClassicBlock } = useSelect(
76
- (select) => {
77
- const {
78
- getBlockAttributes,
79
- getSelectedBlockClientId,
80
- getBlockName
81
- } = select(blockEditorStore);
82
- const _clientId = getSelectedBlockClientId();
83
- return {
84
- clientId: _clientId,
85
- blockCommentId: _clientId ? getBlockAttributes(_clientId)?.metadata?.noteId : null,
86
- isClassicBlock: _clientId ? getBlockName(_clientId) === "core/freeform" : false
87
- };
88
- },
89
- []
90
- );
34
+ const sidebarRef = useRef(null);
35
+ const { clientId, noteId, isClassicBlock } = useSelect((select) => {
36
+ const { getBlockAttributes, getSelectedBlockClientId, getBlockName } = select(blockEditorStore);
37
+ const _clientId = getSelectedBlockClientId();
38
+ return {
39
+ clientId: _clientId,
40
+ noteId: _clientId ? getBlockAttributes(_clientId)?.metadata?.noteId : null,
41
+ isClassicBlock: _clientId ? getBlockName(_clientId) === "core/freeform" : false
42
+ };
43
+ }, []);
91
44
  const { isDistractionFree } = useSelect((select) => {
92
45
  const { get } = select(preferencesStore);
93
46
  return {
@@ -98,11 +51,11 @@ function NotesSidebar({ postId }) {
98
51
  (select) => unlock(select(editorStore)).getSelectedNote(),
99
52
  []
100
53
  );
101
- const { resultComments, unresolvedSortedThreads } = useBlockComments(postId);
54
+ const { notes, unresolvedNotes } = useNoteThreads(postId);
102
55
  const showFloatingSidebar = isLargeViewport;
103
- const showAllNotesSidebar = resultComments.length > 0 || !showFloatingSidebar;
56
+ const showAllNotesSidebar = notes.length > 0 || !showFloatingSidebar;
104
57
  useEnableFloatingSidebar(
105
- showFloatingSidebar && (unresolvedSortedThreads.length > 0 || selectedNote !== void 0)
58
+ showFloatingSidebar && (unresolvedNotes.length > 0 || selectedNote !== void 0)
106
59
  );
107
60
  useShortcut(
108
61
  "core/editor/new-note",
@@ -113,17 +66,17 @@ function NotesSidebar({ postId }) {
113
66
  {
114
67
  // When multiple notes per block are supported. Remove note ID check.
115
68
  // See: https://github.com/WordPress/gutenberg/pull/75147.
116
- isDisabled: isDistractionFree || isClassicBlock || !clientId || !!blockCommentId
69
+ isDisabled: isDistractionFree || isClassicBlock || !clientId || !!noteId
117
70
  }
118
71
  );
119
72
  const { merged: GlobalStyles } = useGlobalStylesContext();
120
73
  const backgroundColor = GlobalStyles?.styles?.color?.background;
121
- const currentThread = blockCommentId ? resultComments.find((thread) => thread.id === blockCommentId) : null;
74
+ const currentThread = noteId ? notes.find((thread) => thread.id === noteId) : null;
122
75
  async function openTheSidebar(selectedClientId) {
123
76
  const prevArea = await getActiveComplementaryArea("core");
124
77
  const activeNotesArea = SIDEBARS.find((name) => name === prevArea);
125
78
  const targetClientId = selectedClientId && selectedClientId !== clientId ? selectedClientId : clientId;
126
- const targetNote = resultComments.find(
79
+ const targetNote = notes.find(
127
80
  (note) => note.blockClientId === targetClientId
128
81
  );
129
82
  if (targetNote?.status === "approved") {
@@ -143,17 +96,17 @@ function NotesSidebar({ postId }) {
143
96
  selectNote(targetNote ? targetNote.id : "new", { focus: true });
144
97
  }
145
98
  if (isDistractionFree) {
146
- return /* @__PURE__ */ jsx(AddCommentMenuItem, { isDistractionFree: true });
99
+ return /* @__PURE__ */ jsx(AddNoteMenuItem, { isDistractionFree: true });
147
100
  }
148
101
  return /* @__PURE__ */ jsxs(Fragment, { children: [
149
102
  !!currentThread && /* @__PURE__ */ jsx(
150
- CommentAvatarIndicator,
103
+ NoteAvatarIndicator,
151
104
  {
152
- thread: currentThread,
105
+ note: currentThread,
153
106
  onClick: openTheSidebar
154
107
  }
155
108
  ),
156
- /* @__PURE__ */ jsx(AddCommentMenuItem, { onClick: openTheSidebar }),
109
+ /* @__PURE__ */ jsx(AddNoteMenuItem, { onClick: openTheSidebar }),
157
110
  showAllNotesSidebar && /* @__PURE__ */ jsx(
158
111
  PluginSidebar,
159
112
  {
@@ -163,13 +116,7 @@ function NotesSidebar({ postId }) {
163
116
  header: /* @__PURE__ */ jsx("h2", { className: "interface-complementary-area-header__title", children: __("All notes") }),
164
117
  icon: commentIcon,
165
118
  closeLabel: __("Close Notes"),
166
- children: /* @__PURE__ */ jsx(
167
- NotesSidebarContent,
168
- {
169
- comments: resultComments,
170
- commentSidebarRef
171
- }
172
- )
119
+ children: /* @__PURE__ */ jsx(Notes, { notes, sidebarRef })
173
120
  }
174
121
  ),
175
122
  isLargeViewport && /* @__PURE__ */ jsx(
@@ -182,13 +129,11 @@ function NotesSidebar({ postId }) {
182
129
  headerClassName: "editor-collab-sidebar__header",
183
130
  backgroundColor,
184
131
  children: /* @__PURE__ */ jsx(
185
- NotesSidebarContent,
132
+ Notes,
186
133
  {
187
- comments: unresolvedSortedThreads,
188
- commentSidebarRef,
189
- styles: {
190
- backgroundColor
191
- },
134
+ notes: unresolvedNotes,
135
+ sidebarRef,
136
+ styles: { backgroundColor },
192
137
  isFloating: true
193
138
  }
194
139
  )