@wordpress/editor 14.44.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 (363) 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-note.cjs +100 -0
  5. package/build/components/collab-sidebar/add-note.cjs.map +7 -0
  6. package/build/components/collab-sidebar/board-store.cjs +106 -0
  7. package/build/components/collab-sidebar/board-store.cjs.map +7 -0
  8. package/build/components/collab-sidebar/floating-container.cjs +63 -0
  9. package/build/components/collab-sidebar/floating-container.cjs.map +7 -0
  10. package/build/components/collab-sidebar/hooks.cjs +105 -140
  11. package/build/components/collab-sidebar/hooks.cjs.map +3 -3
  12. package/build/components/collab-sidebar/index.cjs +28 -90
  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} +46 -45
  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 +80 -14
  29. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  30. package/build/components/collaborators-presence/avatar/component.cjs.map +1 -1
  31. package/build/components/collaborators-presence/index.cjs +3 -3
  32. package/build/components/collaborators-presence/index.cjs.map +2 -2
  33. package/build/components/collaborators-presence/list.cjs +3 -3
  34. package/build/components/collaborators-presence/list.cjs.map +2 -2
  35. package/build/components/document-bar/index.cjs.map +3 -3
  36. package/build/components/error-boundary/index.cjs.map +3 -3
  37. package/build/components/list-view-sidebar/list-view-outline.cjs.map +3 -3
  38. package/build/components/media/media-editor-modal.cjs +93 -0
  39. package/build/components/media/media-editor-modal.cjs.map +7 -0
  40. package/build/components/media-categories/index.cjs +1 -1
  41. package/build/components/media-categories/index.cjs.map +1 -1
  42. package/build/components/more-menu/index.cjs +4 -3
  43. package/build/components/more-menu/index.cjs.map +2 -2
  44. package/build/components/post-actions/set-as-homepage.cjs.map +3 -3
  45. package/build/components/post-actions/set-as-posts-page.cjs.map +3 -3
  46. package/build/components/post-card-panel/index.cjs +2 -2
  47. package/build/components/post-card-panel/index.cjs.map +3 -3
  48. package/build/components/post-content-information/index.cjs.map +3 -3
  49. package/build/components/post-excerpt/panel.cjs.map +3 -3
  50. package/build/components/post-last-edited-panel/index.cjs.map +3 -3
  51. package/build/components/post-preview-button/index.cjs +3 -2
  52. package/build/components/post-preview-button/index.cjs.map +2 -2
  53. package/build/components/post-publish-button/index.cjs +2 -2
  54. package/build/components/post-publish-button/index.cjs.map +2 -2
  55. package/build/components/post-publish-button/label.cjs +4 -2
  56. package/build/components/post-publish-button/label.cjs.map +2 -2
  57. package/build/components/post-publish-panel/maybe-upload-media.cjs +1 -1
  58. package/build/components/post-publish-panel/maybe-upload-media.cjs.map +1 -1
  59. package/build/components/post-publish-panel/postpublish.cjs +3 -2
  60. package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
  61. package/build/components/post-revisions-panel/index.cjs +2 -2
  62. package/build/components/post-revisions-panel/index.cjs.map +2 -2
  63. package/build/components/post-revisions-preview/diff-markers.cjs +1 -1
  64. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  65. package/build/components/post-revisions-preview/revisions-slider.cjs +1 -0
  66. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  67. package/build/components/post-saved-state/index.cjs +4 -1
  68. package/build/components/post-saved-state/index.cjs.map +2 -2
  69. package/build/components/post-text-editor/index.cjs +3 -4
  70. package/build/components/post-text-editor/index.cjs.map +2 -2
  71. package/build/components/preview-dropdown/index.cjs +3 -2
  72. package/build/components/preview-dropdown/index.cjs.map +2 -2
  73. package/build/components/provider/index.cjs +3 -1
  74. package/build/components/provider/index.cjs.map +3 -3
  75. package/build/components/provider/use-block-editor-settings.cjs +7 -1
  76. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  77. package/build/components/provider/use-upload-save-lock.cjs +2 -12
  78. package/build/components/provider/use-upload-save-lock.cjs.map +2 -2
  79. package/build/components/resizable-editor/resize-handle.cjs +2 -1
  80. package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
  81. package/build/components/revision-created-panel/index.cjs.map +3 -3
  82. package/build/components/site-discussion/index.cjs.map +2 -2
  83. package/build/components/style-book/constants.cjs +1 -1
  84. package/build/components/style-book/constants.cjs.map +1 -1
  85. package/build/components/style-book/index.cjs +1 -1
  86. package/build/components/style-book/index.cjs.map +1 -1
  87. package/build/components/template-actions-panel/classic-theme-content.cjs.map +2 -2
  88. package/build/components/template-part-menu-items/convert-to-regular.cjs +54 -11
  89. package/build/components/template-part-menu-items/convert-to-regular.cjs.map +3 -3
  90. package/build/components/visual-editor/index.cjs +5 -22
  91. package/build/components/visual-editor/index.cjs.map +2 -2
  92. package/build/store/private-actions.cjs +0 -8
  93. package/build/store/private-actions.cjs.map +2 -2
  94. package/build/store/private-selectors.cjs +0 -5
  95. package/build/store/private-selectors.cjs.map +2 -2
  96. package/build/store/reducer.cjs +0 -10
  97. package/build/store/reducer.cjs.map +2 -2
  98. package/build/utils/media-finalize/index.cjs +3 -2
  99. package/build/utils/media-finalize/index.cjs.map +2 -2
  100. package/build/utils/media-upload/index.cjs +14 -25
  101. package/build/utils/media-upload/index.cjs.map +2 -2
  102. package/build-module/components/collab-sidebar/{comment-menu-item.mjs → add-note-menu-item.mjs} +10 -11
  103. package/build-module/components/collab-sidebar/add-note-menu-item.mjs.map +7 -0
  104. package/build-module/components/collab-sidebar/add-note.mjs +78 -0
  105. package/build-module/components/collab-sidebar/add-note.mjs.map +7 -0
  106. package/build-module/components/collab-sidebar/board-store.mjs +81 -0
  107. package/build-module/components/collab-sidebar/board-store.mjs.map +7 -0
  108. package/build-module/components/collab-sidebar/floating-container.mjs +28 -0
  109. package/build-module/components/collab-sidebar/floating-container.mjs.map +7 -0
  110. package/build-module/components/collab-sidebar/hooks.mjs +105 -144
  111. package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
  112. package/build-module/components/collab-sidebar/index.mjs +29 -95
  113. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  114. package/build-module/components/collab-sidebar/{comment-author-info.mjs → note-byline.mjs} +7 -7
  115. package/build-module/components/collab-sidebar/note-byline.mjs.map +7 -0
  116. package/build-module/components/collab-sidebar/note-card.mjs +33 -0
  117. package/build-module/components/collab-sidebar/note-card.mjs.map +7 -0
  118. package/build-module/components/collab-sidebar/note-form.mjs +84 -0
  119. package/build-module/components/collab-sidebar/note-form.mjs.map +7 -0
  120. package/build-module/components/collab-sidebar/{comment-indicator-toolbar.mjs → note-indicator-toolbar.mjs} +25 -29
  121. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +7 -0
  122. package/build-module/components/collab-sidebar/note-thread.mjs +289 -0
  123. package/build-module/components/collab-sidebar/note-thread.mjs.map +7 -0
  124. package/build-module/components/collab-sidebar/note.mjs +176 -0
  125. package/build-module/components/collab-sidebar/note.mjs.map +7 -0
  126. package/build-module/components/collab-sidebar/notes.mjs +215 -0
  127. package/build-module/components/collab-sidebar/notes.mjs.map +7 -0
  128. package/build-module/components/collab-sidebar/utils.mjs +76 -10
  129. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  130. package/build-module/components/collaborators-presence/avatar/component.mjs.map +1 -1
  131. package/build-module/components/collaborators-presence/index.mjs +3 -3
  132. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  133. package/build-module/components/collaborators-presence/list.mjs +3 -3
  134. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  135. package/build-module/components/document-bar/index.mjs +3 -3
  136. package/build-module/components/document-bar/index.mjs.map +2 -2
  137. package/build-module/components/error-boundary/index.mjs +2 -2
  138. package/build-module/components/error-boundary/index.mjs.map +2 -2
  139. package/build-module/components/list-view-sidebar/list-view-outline.mjs +5 -5
  140. package/build-module/components/list-view-sidebar/list-view-outline.mjs.map +2 -2
  141. package/build-module/components/media/media-editor-modal.mjs +62 -0
  142. package/build-module/components/media/media-editor-modal.mjs.map +7 -0
  143. package/build-module/components/media-categories/index.mjs +1 -1
  144. package/build-module/components/media-categories/index.mjs.map +1 -1
  145. package/build-module/components/more-menu/index.mjs +4 -8
  146. package/build-module/components/more-menu/index.mjs.map +2 -2
  147. package/build-module/components/post-actions/set-as-homepage.mjs +2 -2
  148. package/build-module/components/post-actions/set-as-homepage.mjs.map +2 -2
  149. package/build-module/components/post-actions/set-as-posts-page.mjs +2 -2
  150. package/build-module/components/post-actions/set-as-posts-page.mjs.map +2 -2
  151. package/build-module/components/post-card-panel/index.mjs +5 -5
  152. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  153. package/build-module/components/post-content-information/index.mjs +2 -2
  154. package/build-module/components/post-content-information/index.mjs.map +2 -2
  155. package/build-module/components/post-excerpt/panel.mjs +2 -2
  156. package/build-module/components/post-excerpt/panel.mjs.map +2 -2
  157. package/build-module/components/post-last-edited-panel/index.mjs +2 -2
  158. package/build-module/components/post-last-edited-panel/index.mjs.map +2 -2
  159. package/build-module/components/post-preview-button/index.mjs +3 -2
  160. package/build-module/components/post-preview-button/index.mjs.map +2 -2
  161. package/build-module/components/post-publish-button/index.mjs +2 -2
  162. package/build-module/components/post-publish-button/index.mjs.map +2 -2
  163. package/build-module/components/post-publish-button/label.mjs +4 -2
  164. package/build-module/components/post-publish-button/label.mjs.map +2 -2
  165. package/build-module/components/post-publish-panel/maybe-upload-media.mjs +1 -1
  166. package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +1 -1
  167. package/build-module/components/post-publish-panel/postpublish.mjs +3 -3
  168. package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
  169. package/build-module/components/post-revisions-panel/index.mjs +2 -2
  170. package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
  171. package/build-module/components/post-revisions-preview/diff-markers.mjs +1 -1
  172. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  173. package/build-module/components/post-revisions-preview/revisions-slider.mjs +1 -0
  174. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  175. package/build-module/components/post-saved-state/index.mjs +4 -1
  176. package/build-module/components/post-saved-state/index.mjs.map +2 -2
  177. package/build-module/components/post-text-editor/index.mjs +2 -3
  178. package/build-module/components/post-text-editor/index.mjs.map +2 -2
  179. package/build-module/components/preview-dropdown/index.mjs +2 -2
  180. package/build-module/components/preview-dropdown/index.mjs.map +2 -2
  181. package/build-module/components/provider/index.mjs +3 -1
  182. package/build-module/components/provider/index.mjs.map +2 -2
  183. package/build-module/components/provider/use-block-editor-settings.mjs +7 -1
  184. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  185. package/build-module/components/provider/use-upload-save-lock.mjs +2 -12
  186. package/build-module/components/provider/use-upload-save-lock.mjs.map +2 -2
  187. package/build-module/components/resizable-editor/resize-handle.mjs +2 -5
  188. package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
  189. package/build-module/components/revision-created-panel/index.mjs +2 -2
  190. package/build-module/components/revision-created-panel/index.mjs.map +2 -2
  191. package/build-module/components/site-discussion/index.mjs +2 -2
  192. package/build-module/components/site-discussion/index.mjs.map +2 -2
  193. package/build-module/components/style-book/constants.mjs +1 -1
  194. package/build-module/components/style-book/constants.mjs.map +1 -1
  195. package/build-module/components/style-book/index.mjs +1 -1
  196. package/build-module/components/style-book/index.mjs.map +1 -1
  197. package/build-module/components/template-actions-panel/classic-theme-content.mjs +2 -2
  198. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +2 -2
  199. package/build-module/components/template-part-menu-items/convert-to-regular.mjs +60 -14
  200. package/build-module/components/template-part-menu-items/convert-to-regular.mjs.map +2 -2
  201. package/build-module/components/visual-editor/index.mjs +5 -22
  202. package/build-module/components/visual-editor/index.mjs.map +2 -2
  203. package/build-module/store/private-actions.mjs +0 -7
  204. package/build-module/store/private-actions.mjs.map +2 -2
  205. package/build-module/store/private-selectors.mjs +0 -4
  206. package/build-module/store/private-selectors.mjs.map +2 -2
  207. package/build-module/store/reducer.mjs +0 -9
  208. package/build-module/store/reducer.mjs.map +2 -2
  209. package/build-module/utils/media-finalize/index.mjs +3 -2
  210. package/build-module/utils/media-finalize/index.mjs.map +2 -2
  211. package/build-module/utils/media-upload/index.mjs +14 -25
  212. package/build-module/utils/media-upload/index.mjs.map +2 -2
  213. package/build-style/style-rtl.css +397 -171
  214. package/build-style/style.css +397 -171
  215. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts +5 -0
  216. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts.map +1 -0
  217. package/build-types/components/collab-sidebar/add-note.d.ts +6 -0
  218. package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -0
  219. package/build-types/components/collab-sidebar/board-store.d.ts +9 -0
  220. package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -0
  221. package/build-types/components/collab-sidebar/floating-container.d.ts +8 -0
  222. package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -0
  223. package/build-types/components/collab-sidebar/hooks.d.ts +13 -22
  224. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  225. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  226. package/build-types/components/collab-sidebar/note-byline.d.ts +7 -0
  227. package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -0
  228. package/build-types/components/collab-sidebar/note-card.d.ts +8 -0
  229. package/build-types/components/collab-sidebar/note-card.d.ts.map +1 -0
  230. package/build-types/components/collab-sidebar/note-form.d.ts +7 -0
  231. package/build-types/components/collab-sidebar/note-form.d.ts.map +1 -0
  232. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts +5 -0
  233. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -0
  234. package/build-types/components/collab-sidebar/note-thread.d.ts +11 -0
  235. package/build-types/components/collab-sidebar/note-thread.d.ts.map +1 -0
  236. package/build-types/components/collab-sidebar/note.d.ts +9 -0
  237. package/build-types/components/collab-sidebar/note.d.ts.map +1 -0
  238. package/build-types/components/collab-sidebar/notes.d.ts +7 -0
  239. package/build-types/components/collab-sidebar/notes.d.ts.map +1 -0
  240. package/build-types/components/collab-sidebar/utils.d.ts +41 -17
  241. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  242. package/build-types/components/media/media-editor-modal.d.ts +11 -0
  243. package/build-types/components/media/media-editor-modal.d.ts.map +1 -0
  244. package/build-types/components/more-menu/index.d.ts.map +1 -1
  245. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  246. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  247. package/build-types/components/post-publish-button/label.d.ts.map +1 -1
  248. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  249. package/build-types/components/post-saved-state/index.d.ts.map +1 -1
  250. package/build-types/components/provider/index.d.ts.map +1 -1
  251. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  252. package/build-types/components/provider/use-upload-save-lock.d.ts +0 -2
  253. package/build-types/components/provider/use-upload-save-lock.d.ts.map +1 -1
  254. package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
  255. package/build-types/components/style-book/constants.d.ts +1 -1
  256. package/build-types/components/style-book/constants.d.ts.map +1 -1
  257. package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -1
  258. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  259. package/build-types/store/private-actions.d.ts +0 -7
  260. package/build-types/store/private-actions.d.ts.map +1 -1
  261. package/build-types/store/private-selectors.d.ts +0 -7
  262. package/build-types/store/private-selectors.d.ts.map +1 -1
  263. package/build-types/store/reducer.d.ts +0 -10
  264. package/build-types/store/reducer.d.ts.map +1 -1
  265. package/build-types/utils/media-finalize/index.d.ts +1 -1
  266. package/build-types/utils/media-finalize/index.d.ts.map +1 -1
  267. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  268. package/package.json +46 -46
  269. package/src/components/collab-sidebar/README.md +117 -0
  270. package/src/components/collab-sidebar/{comment-menu-item.js → add-note-menu-item.js} +8 -10
  271. package/src/components/collab-sidebar/{add-comment.js → add-note.js} +26 -49
  272. package/src/components/collab-sidebar/board-store.js +85 -0
  273. package/src/components/collab-sidebar/floating-container.js +30 -0
  274. package/src/components/collab-sidebar/hooks.js +130 -178
  275. package/src/components/collab-sidebar/index.js +35 -106
  276. package/src/components/collab-sidebar/{comment-author-info.js → note-byline.js} +5 -6
  277. package/src/components/collab-sidebar/note-card.js +36 -0
  278. package/src/components/collab-sidebar/{comment-form.js → note-form.js} +29 -40
  279. package/src/components/collab-sidebar/{comment-indicator-toolbar.js → note-indicator-toolbar.js} +29 -32
  280. package/src/components/collab-sidebar/note-thread.js +331 -0
  281. package/src/components/collab-sidebar/note.js +209 -0
  282. package/src/components/collab-sidebar/notes.js +276 -0
  283. package/src/components/collab-sidebar/style.scss +21 -11
  284. package/src/components/collab-sidebar/test/utils.js +155 -0
  285. package/src/components/collab-sidebar/utils.js +125 -19
  286. package/src/components/collaborators-presence/avatar/component.tsx +1 -1
  287. package/src/components/collaborators-presence/styles/collaborators-list.scss +1 -1
  288. package/src/components/collaborators-presence/styles/collaborators-presence.scss +1 -1
  289. package/src/components/document-bar/index.js +4 -4
  290. package/src/components/document-outline/style.scss +1 -1
  291. package/src/components/error-boundary/index.js +3 -3
  292. package/src/components/list-view-sidebar/list-view-outline.js +6 -6
  293. package/src/components/media/media-editor-modal.js +95 -0
  294. package/src/components/media-categories/index.js +1 -1
  295. package/src/components/more-menu/index.js +4 -8
  296. package/src/components/post-actions/set-as-homepage.js +2 -2
  297. package/src/components/post-actions/set-as-posts-page.js +2 -2
  298. package/src/components/post-card-panel/index.js +7 -7
  299. package/src/components/post-content-information/index.js +3 -3
  300. package/src/components/post-excerpt/panel.js +3 -3
  301. package/src/components/post-last-edited-panel/index.js +3 -3
  302. package/src/components/post-preview-button/index.js +3 -2
  303. package/src/components/post-publish-button/index.js +6 -5
  304. package/src/components/post-publish-button/label.js +3 -1
  305. package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
  306. package/src/components/post-publish-panel/postpublish.js +2 -2
  307. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +10 -16
  308. package/src/components/post-revisions-panel/index.js +3 -3
  309. package/src/components/post-revisions-preview/diff-markers.js +1 -1
  310. package/src/components/post-revisions-preview/revisions-slider.js +1 -0
  311. package/src/components/post-revisions-preview/style.scss +1 -1
  312. package/src/components/post-saved-state/index.js +4 -1
  313. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +0 -1
  314. package/src/components/post-text-editor/index.js +3 -3
  315. package/src/components/preview-dropdown/index.js +2 -2
  316. package/src/components/provider/index.js +4 -0
  317. package/src/components/provider/use-block-editor-settings.js +10 -0
  318. package/src/components/provider/use-upload-save-lock.js +2 -17
  319. package/src/components/resizable-editor/resize-handle.js +2 -5
  320. package/src/components/revision-created-panel/index.js +3 -3
  321. package/src/components/site-discussion/index.js +3 -3
  322. package/src/components/style-book/constants.ts +1 -1
  323. package/src/components/style-book/index.js +1 -1
  324. package/src/components/template-actions-panel/classic-theme-content.js +3 -3
  325. package/src/components/template-actions-panel/style.scss +1 -1
  326. package/src/components/template-part-menu-items/convert-to-regular.js +74 -12
  327. package/src/components/visual-editor/index.js +2 -29
  328. package/src/store/private-actions.js +0 -13
  329. package/src/store/private-selectors.js +0 -10
  330. package/src/store/reducer.js +0 -16
  331. package/src/utils/media-finalize/index.js +2 -1
  332. package/src/utils/media-finalize/test/index.js +25 -1
  333. package/src/utils/media-upload/index.js +26 -29
  334. package/build/components/collab-sidebar/add-comment.cjs +0 -129
  335. package/build/components/collab-sidebar/add-comment.cjs.map +0 -7
  336. package/build/components/collab-sidebar/comment-author-info.cjs.map +0 -7
  337. package/build/components/collab-sidebar/comment-form.cjs.map +0 -7
  338. package/build/components/collab-sidebar/comment-indicator-toolbar.cjs.map +0 -7
  339. package/build/components/collab-sidebar/comment-menu-item.cjs.map +0 -7
  340. package/build/components/collab-sidebar/comments.cjs +0 -816
  341. package/build/components/collab-sidebar/comments.cjs.map +0 -7
  342. package/build-module/components/collab-sidebar/add-comment.mjs +0 -100
  343. package/build-module/components/collab-sidebar/add-comment.mjs.map +0 -7
  344. package/build-module/components/collab-sidebar/comment-author-info.mjs.map +0 -7
  345. package/build-module/components/collab-sidebar/comment-form.mjs +0 -90
  346. package/build-module/components/collab-sidebar/comment-form.mjs.map +0 -7
  347. package/build-module/components/collab-sidebar/comment-indicator-toolbar.mjs.map +0 -7
  348. package/build-module/components/collab-sidebar/comment-menu-item.mjs.map +0 -7
  349. package/build-module/components/collab-sidebar/comments.mjs +0 -799
  350. package/build-module/components/collab-sidebar/comments.mjs.map +0 -7
  351. package/build-types/components/collab-sidebar/add-comment.d.ts +0 -10
  352. package/build-types/components/collab-sidebar/add-comment.d.ts.map +0 -1
  353. package/build-types/components/collab-sidebar/comment-author-info.d.ts +0 -8
  354. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +0 -1
  355. package/build-types/components/collab-sidebar/comment-form.d.ts +0 -11
  356. package/build-types/components/collab-sidebar/comment-form.d.ts.map +0 -1
  357. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +0 -6
  358. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +0 -1
  359. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +0 -6
  360. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +0 -1
  361. package/build-types/components/collab-sidebar/comments.d.ts +0 -12
  362. package/build-types/components/collab-sidebar/comments.d.ts.map +0 -1
  363. package/src/components/collab-sidebar/comments.js +0 -985
@@ -1,15 +1,10 @@
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 {
4
+ useState,
9
5
  useEffect,
10
6
  useMemo,
11
- useCallback,
12
- useReducer
7
+ useSyncExternalStore
13
8
  } from "@wordpress/element";
14
9
  import { useEntityRecords, store as coreStore } from "@wordpress/core-data";
15
10
  import { useDispatch, useRegistry, useSelect } from "@wordpress/data";
@@ -18,18 +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
- import { noop } from "./utils.mjs";
27
- var { useBlockElement, cleanEmptyObject } = unlock(blockEditorPrivateApis);
28
- function useBlockComments(postId) {
29
- const [commentLastUpdated, reflowComments] = useReducer(
30
- () => Date.now(),
31
- 0
32
- );
22
+ import { createBoardStore } from "./board-store.mjs";
23
+ import { calculateNotePositions } from "./utils.mjs";
24
+ var { cleanEmptyObject } = unlock(blockEditorPrivateApis);
25
+ function useNoteThreads(postId) {
33
26
  const queryArgs = {
34
27
  post: postId,
35
28
  type: "note",
@@ -49,80 +42,68 @@ function useBlockComments(postId) {
49
42
  clientIds: getClientIdsWithDescendants()
50
43
  };
51
44
  }, []);
52
- const { resultComments, unresolvedSortedThreads } = useMemo(() => {
45
+ const { notes, unresolvedNotes } = useMemo(() => {
53
46
  if (!threads || threads.length === 0) {
54
- return { resultComments: [], unresolvedSortedThreads: [] };
47
+ return { notes: [], unresolvedNotes: [] };
55
48
  }
56
- const blocksWithComments = clientIds.reduce((results, clientId) => {
57
- const commentId = getBlockAttributes(clientId)?.metadata?.noteId;
58
- if (commentId) {
59
- 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);
60
57
  }
61
- return results;
62
- }, {});
63
- const compare = {};
64
- const result = [];
65
- const commentIdToBlockClientId = Object.keys(
66
- blocksWithComments
67
- ).reduce((mapping, clientId) => {
68
- mapping[blocksWithComments[clientId]] = clientId;
69
- return mapping;
70
- }, {});
71
- threads.forEach((item) => {
72
- const itemBlock = commentIdToBlockClientId[item.id];
73
- compare[item.id] = {
58
+ }
59
+ const threadsById = /* @__PURE__ */ new Map();
60
+ const rootThreads = [];
61
+ for (const item of threads) {
62
+ const thread = {
74
63
  ...item,
75
64
  reply: [],
76
- blockClientId: item.parent === 0 ? itemBlock : null
65
+ blockClientId: item.parent === 0 ? clientIdByNoteId.get(String(item.id)) ?? null : null
77
66
  };
78
- });
79
- threads.forEach((item) => {
67
+ threadsById.set(item.id, thread);
80
68
  if (item.parent === 0) {
81
- result.push(compare[item.id]);
82
- } else if (compare[item.parent]) {
83
- compare[item.parent].reply.push(compare[item.id]);
69
+ rootThreads.push(thread);
84
70
  }
85
- });
86
- if (0 === result?.length) {
87
- return { resultComments: [], unresolvedSortedThreads: [] };
88
71
  }
89
- const updatedResult = result.map((item) => ({
90
- ...item,
91
- reply: [...item.reply].reverse()
92
- }));
93
- const threadIdMap = new Map(
94
- updatedResult.map((thread) => [String(thread.id), thread])
95
- );
96
- const mappedIds = new Set(
97
- Object.values(blocksWithComments).map((id) => String(id))
98
- );
99
- const unresolvedSortedComments = Object.values(blocksWithComments).map((commentId) => threadIdMap.get(String(commentId))).filter(
100
- (thread) => thread !== void 0 && thread.status === "hold"
101
- );
102
- const resolvedSortedComments = Object.values(blocksWithComments).map((commentId) => threadIdMap.get(String(commentId))).filter(
103
- (thread) => thread !== void 0 && thread.status === "approved"
104
- );
105
- const orphanedComments = updatedResult.filter(
106
- (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
107
95
  );
108
- const allSortedComments = [
109
- ...unresolvedSortedComments,
110
- ...resolvedSortedComments,
111
- ...orphanedComments
112
- ];
113
96
  return {
114
- resultComments: allSortedComments,
115
- unresolvedSortedThreads: unresolvedSortedComments
97
+ notes: [...unresolved, ...resolved, ...orphans],
98
+ unresolvedNotes: unresolved
116
99
  };
117
100
  }, [clientIds, threads, getBlockAttributes]);
118
101
  return {
119
- resultComments,
120
- unresolvedSortedThreads,
121
- reflowComments,
122
- commentLastUpdated
102
+ notes,
103
+ unresolvedNotes
123
104
  };
124
105
  }
125
- function useBlockCommentsActions(reflowComments = noop) {
106
+ function useNoteActions() {
126
107
  const { createNotice } = useDispatch(noticesStore);
127
108
  const { saveEntityRecord, deleteEntityRecord } = useDispatch(coreStore);
128
109
  const { getCurrentPostId } = useSelect(editorStore);
@@ -167,10 +148,8 @@ function useBlockCommentsActions(reflowComments = noop) {
167
148
  isDismissible: true
168
149
  }
169
150
  );
170
- setTimeout(reflowComments, 300);
171
151
  return savedRecord;
172
152
  } catch (error) {
173
- reflowComments();
174
153
  onError(error);
175
154
  }
176
155
  };
@@ -194,7 +173,7 @@ function useBlockCommentsActions(reflowComments = noop) {
194
173
  throwOnError: true
195
174
  }
196
175
  );
197
- const newCommentData = {
176
+ const newNoteData = {
198
177
  post: getCurrentPostId(),
199
178
  content: content || "",
200
179
  // Empty content for resolve, content for reopen.
@@ -205,7 +184,7 @@ function useBlockCommentsActions(reflowComments = noop) {
205
184
  _wp_note_status: status === "approved" ? "resolved" : "reopen"
206
185
  }
207
186
  };
208
- await saveEntityRecord("root", "comment", newCommentData, {
187
+ await saveEntityRecord("root", "comment", newNoteData, {
209
188
  throwOnError: true
210
189
  });
211
190
  } else {
@@ -226,24 +205,16 @@ function useBlockCommentsActions(reflowComments = noop) {
226
205
  isDismissible: true
227
206
  }
228
207
  );
229
- reflowComments();
230
208
  } catch (error) {
231
- reflowComments();
232
209
  onError(error);
233
210
  }
234
211
  };
235
- const onDelete = async (comment) => {
212
+ const onDelete = async (note) => {
236
213
  try {
237
- await deleteEntityRecord(
238
- "root",
239
- "comment",
240
- comment.id,
241
- void 0,
242
- {
243
- throwOnError: true
244
- }
245
- );
246
- if (!comment.parent) {
214
+ await deleteEntityRecord("root", "comment", note.id, void 0, {
215
+ throwOnError: true
216
+ });
217
+ if (!note.parent) {
247
218
  const clientId = getSelectedBlockClientId();
248
219
  const metadata = getBlockAttributes(clientId)?.metadata;
249
220
  updateBlockAttributes(clientId, {
@@ -257,9 +228,7 @@ function useBlockCommentsActions(reflowComments = noop) {
257
228
  type: "snackbar",
258
229
  isDismissible: true
259
230
  });
260
- reflowComments();
261
231
  } catch (error) {
262
- reflowComments();
263
232
  onError(error);
264
233
  }
265
234
  };
@@ -286,66 +255,58 @@ function useEnableFloatingSidebar(enabled = false) {
286
255
  };
287
256
  }, [enabled, registry]);
288
257
  }
289
- function useFloatingThread({
290
- thread,
291
- calculatedOffset,
292
- setHeights,
293
- selectedThread,
294
- setBlockRef,
295
- commentLastUpdated
258
+ function useFloatingBoard({
259
+ threads,
260
+ selectedNoteId,
261
+ isFloating,
262
+ sidebarRef
296
263
  }) {
297
- const blockElement = useBlockElement(thread.blockClientId);
298
- const updateHeight = useCallback(
299
- (id, newHeight) => {
300
- setHeights((prev) => {
301
- if (prev[id] !== newHeight) {
302
- return { ...prev, [id]: newHeight };
303
- }
304
- return prev;
305
- });
306
- },
307
- [setHeights]
308
- );
309
- const { y, refs } = useFloating({
310
- placement: "right-start",
311
- middleware: [
312
- offsetMiddleware({
313
- crossAxis: calculatedOffset || -16
314
- })
315
- ],
316
- whileElementsMounted: autoUpdate
317
- });
318
- useEffect(() => {
319
- if (blockElement) {
320
- refs.setReference(blockElement);
321
- }
322
- }, [blockElement, refs, commentLastUpdated]);
264
+ const [notePositions, setNotePositions] = useState({});
265
+ const [store] = useState(createBoardStore);
266
+ const heights = useSyncExternalStore(store.subscribe, store.getSnapshot);
323
267
  useEffect(() => {
324
- if (refs.floating?.current) {
325
- setBlockRef(thread.id, blockElement);
326
- }
327
- }, [blockElement, thread.id, refs.floating, setBlockRef]);
328
- useEffect(() => {
329
- if (refs.floating?.current) {
330
- const newHeight = refs.floating.current.scrollHeight;
331
- updateHeight(thread.id, newHeight);
268
+ if (!isFloating || !sidebarRef?.current) {
269
+ return;
332
270
  }
333
- }, [
334
- thread.id,
335
- updateHeight,
336
- refs.floating,
337
- selectedThread,
338
- commentLastUpdated
339
- ]);
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
+ };
281
+ const rafId = window.requestAnimationFrame(() => {
282
+ const result = calculateNotePositions({
283
+ threads,
284
+ selectedNoteId,
285
+ blockRects: store.getBlockRects(),
286
+ heights,
287
+ scrollTop: canvas?.scrollTop ?? 0
288
+ });
289
+ setNotePositions(result.positions);
290
+ applyScroll();
291
+ });
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]);
340
300
  return {
341
- y,
342
- refs
301
+ notePositions,
302
+ registerThread: store.registerThread,
303
+ unregisterThread: store.unregisterThread
343
304
  };
344
305
  }
345
306
  export {
346
- useBlockComments,
347
- useBlockCommentsActions,
348
307
  useEnableFloatingSidebar,
349
- useFloatingThread
308
+ useFloatingBoard,
309
+ useNoteActions,
310
+ useNoteThreads
350
311
  };
351
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\tuseEffect,\n\tuseMemo,\n\tuseCallback,\n\tuseReducer,\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 { noop } from './utils';\n\nconst { useBlockElement, cleanEmptyObject } = unlock( blockEditorPrivateApis );\n\nexport function useBlockComments( postId ) {\n\tconst [ commentLastUpdated, reflowComments ] = useReducer(\n\t\t() => Date.now(),\n\t\t0\n\t);\n\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\treflowComments,\n\t\tcommentLastUpdated,\n\t};\n}\n\nexport function useBlockCommentsActions( reflowComments = noop ) {\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\tsetTimeout( reflowComments, 300 );\n\t\t\treturn savedRecord;\n\t\t} catch ( error ) {\n\t\t\treflowComments();\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\treflowComments();\n\t\t} catch ( error ) {\n\t\t\treflowComments();\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\treflowComments();\n\t\t} catch ( error ) {\n\t\t\treflowComments();\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 useFloatingThread( {\n\tthread,\n\tcalculatedOffset,\n\tsetHeights,\n\tselectedThread,\n\tsetBlockRef,\n\tcommentLastUpdated,\n} ) {\n\tconst blockElement = useBlockElement( thread.blockClientId );\n\tconst updateHeight = useCallback(\n\t\t( id, newHeight ) => {\n\t\t\tsetHeights( ( prev ) => {\n\t\t\t\tif ( prev[ id ] !== newHeight ) {\n\t\t\t\t\treturn { ...prev, [ id ]: newHeight };\n\t\t\t\t}\n\t\t\t\treturn prev;\n\t\t\t} );\n\t\t},\n\t\t[ setHeights ]\n\t);\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// Store the block reference for each thread.\n\tuseEffect( () => {\n\t\tif ( blockElement ) {\n\t\t\trefs.setReference( blockElement );\n\t\t}\n\t}, [ blockElement, refs, commentLastUpdated ] );\n\n\t// Track thread heights.\n\tuseEffect( () => {\n\t\tif ( refs.floating?.current ) {\n\t\t\tsetBlockRef( thread.id, blockElement );\n\t\t}\n\t}, [ blockElement, thread.id, refs.floating, setBlockRef ] );\n\n\t// When the selected thread changes, update heights, triggering offset recalculation.\n\tuseEffect( () => {\n\t\tif ( refs.floating?.current ) {\n\t\t\tconst newHeight = refs.floating.current.scrollHeight;\n\t\t\tupdateHeight( thread.id, newHeight );\n\t\t}\n\t}, [\n\t\tthread.id,\n\t\tupdateHeight,\n\t\trefs.floating,\n\t\tselectedThread,\n\t\tcommentLastUpdated,\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,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,sBAAsB;AAC/B,SAAS,SAAS,sBAAsB;AAKxC,SAAS,SAAS,mBAAmB;AACrC,SAAS,8BAA8B;AACvC,SAAS,cAAc;AACvB,SAAS,YAAY;AAErB,IAAM,EAAE,iBAAiB,iBAAiB,IAAI,OAAQ,sBAAuB;AAEtE,SAAS,iBAAkB,QAAS;AAC1C,QAAM,CAAE,oBAAoB,cAAe,IAAI;AAAA,IAC9C,MAAM,KAAK,IAAI;AAAA,IACf;AAAA,EACD;AAEA,QAAM,YAAY;AAAA,IACjB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,Q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AO,aAAc;AAC3D,QAAM,eAAe;AAAA,IACpB,CAAE,IAAI,cAAe;AACpB,iBAAY,CAAE,SAAU;AACvB,YAAK,KAAM,EAAG,MAAM,WAAY;AAC/B,iBAAO,EAAE,GAAG,MAAM,CAAE,EAAG,GAAG,UAAU;AAAA,QACrC;AACA,eAAO;AAAA,MACR,CAAE;AAAA,IACH;AAAA,IACA,CAAE,UAAW;AAAA,EACd;AAGA,QAAM,EAAE,GAAG,KAAK,IAAI,YAAa;AAAA,IAChC,WAAW;AAAA,IACX,YAAY;AAAA,MACX,iBAAkB;AAAA,QACjB,WAAW,oBAAoB;AAAA,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,MAAM,kBAAmB,CAAE;AAG9C,YAAW,MAAM;AAChB,QAAK,KAAK,UAAU,SAAU;AAC7B,kBAAa,OAAO,IAAI,YAAa;AAAA,IACtC;AAAA,EACD,GAAG,CAAE,cAAc,OAAO,IAAI,KAAK,UAAU,WAAY,CAAE;AAG3D,YAAW,MAAM;AAChB,QAAK,KAAK,UAAU,SAAU;AAC7B,YAAM,YAAY,KAAK,SAAS,QAAQ;AACxC,mBAAc,OAAO,IAAI,SAAU;AAAA,IACpC;AAAA,EACD,GAAG;AAAA,IACF,OAAO;AAAA,IACP;AAAA,IACA,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,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AAEvC,IAAM,EAAE,iBAAiB,IAAI,OAAQ,sBAAuB;AAErD,SAAS,eAAgB,QAAS;AACxC,QAAM,YAAY;AAAA,IACjB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,UAAU;AAAA,EACX;AAEA,QAAM,EAAE,SAAS,QAAQ,IAAI;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,IACA,EAAE,SAAS,CAAC,CAAE,UAAU,OAAO,WAAW,SAAS;AAAA,EACpD;AAEA,QAAM,EAAE,mBAAmB,IAAI,UAAW,gBAAiB;AAC3D,QAAM,EAAE,UAAU,IAAI,UAAW,CAAE,WAAY;AAC9C,UAAM,EAAE,4BAA4B,IAAI,OAAQ,gBAAiB;AACjE,WAAO;AAAA,MACN,WAAW,4BAA4B;AAAA,IACxC;AAAA,EACD,GAAG,CAAC,CAAE;AAGN,QAAM,EAAE,OAAO,gBAAgB,IAAI,QAAS,MAAM;AACjD,QAAK,CAAE,WAAW,QAAQ,WAAW,GAAI;AACxC,aAAO,EAAE,OAAO,CAAC,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AAU,CAAC,CAAE;AACzD,QAAM,CAAE,KAAM,IAAI,SAAU,gBAAiB;AAE7C,QAAM,UAAU,qBAAsB,MAAM,WAAW,MAAM,WAAY;AAIzE,YAAW,MAAM;AAChB,QAAK,CAAE,cAAc,CAAE,YAAY,SAAU;AAC5C;AAAA,IACD;AAEA,UAAM,QAAQ,WAAW;AACzB,UAAM,UAAU,MAAM,qBAAqB;AAG3C,UAAM,SAAS,SAAS,QAAS,oBAAqB,KAAK;AAC3D,UAAM,SAAS,SAAS,mBAAoB,MAAO,IAAI;AAEvD,UAAM,cAAc,MAAM;AACzB,YAAM,MAAM;AAAA,QACX;AAAA,QACA,GAAI,EAAG,QAAQ,aAAa,EAAI;AAAA,MACjC;AAAA,IACD;AAGA,UAAM,QAAQ,OAAO,sBAAuB,MAAM;AACjD,YAAM,SAAS,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,58 +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
- reflowComments,
36
- commentLastUpdated,
37
- isFloating = false
38
- }) {
39
- const { onCreate, onEdit, onDelete } = useBlockCommentsActions(reflowComments);
40
- return /* @__PURE__ */ jsx(
41
- VStack,
42
- {
43
- className: "editor-collab-sidebar-panel",
44
- style: styles,
45
- role: "tree",
46
- spacing: "3",
47
- justify: "flex-start",
48
- ref: (node) => {
49
- if (node) {
50
- commentSidebarRef.current = node;
51
- }
52
- },
53
- "aria-label": isFloating ? __("Unresolved notes") : __("All notes"),
54
- children: /* @__PURE__ */ jsx(
55
- Comments,
56
- {
57
- threads: comments,
58
- onEditComment: onEdit,
59
- onAddReply: onCreate,
60
- onCommentDelete: onDelete,
61
- commentSidebarRef,
62
- reflowComments,
63
- commentLastUpdated,
64
- isFloating
65
- }
66
- )
67
- }
68
- );
69
- }
70
26
  function NotesSidebar({ postId }) {
71
27
  const { getActiveComplementaryArea } = useSelect(interfaceStore);
72
28
  const { enableComplementaryArea } = useDispatch(interfaceStore);
@@ -75,23 +31,16 @@ function NotesSidebar({ postId }) {
75
31
  );
76
32
  const { selectNote } = unlock(useDispatch(editorStore));
77
33
  const isLargeViewport = useViewportMatch("medium");
78
- const commentSidebarRef = useRef(null);
79
- const { clientId, blockCommentId, isClassicBlock } = useSelect(
80
- (select) => {
81
- const {
82
- getBlockAttributes,
83
- getSelectedBlockClientId,
84
- getBlockName
85
- } = select(blockEditorStore);
86
- const _clientId = getSelectedBlockClientId();
87
- return {
88
- clientId: _clientId,
89
- blockCommentId: _clientId ? getBlockAttributes(_clientId)?.metadata?.noteId : null,
90
- isClassicBlock: _clientId ? getBlockName(_clientId) === "core/freeform" : false
91
- };
92
- },
93
- []
94
- );
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
+ }, []);
95
44
  const { isDistractionFree } = useSelect((select) => {
96
45
  const { get } = select(preferencesStore);
97
46
  return {
@@ -102,16 +51,11 @@ function NotesSidebar({ postId }) {
102
51
  (select) => unlock(select(editorStore)).getSelectedNote(),
103
52
  []
104
53
  );
105
- const {
106
- resultComments,
107
- unresolvedSortedThreads,
108
- reflowComments,
109
- commentLastUpdated
110
- } = useBlockComments(postId);
54
+ const { notes, unresolvedNotes } = useNoteThreads(postId);
111
55
  const showFloatingSidebar = isLargeViewport;
112
- const showAllNotesSidebar = resultComments.length > 0 || !showFloatingSidebar;
56
+ const showAllNotesSidebar = notes.length > 0 || !showFloatingSidebar;
113
57
  useEnableFloatingSidebar(
114
- showFloatingSidebar && (unresolvedSortedThreads.length > 0 || selectedNote !== void 0)
58
+ showFloatingSidebar && (unresolvedNotes.length > 0 || selectedNote !== void 0)
115
59
  );
116
60
  useShortcut(
117
61
  "core/editor/new-note",
@@ -122,17 +66,17 @@ function NotesSidebar({ postId }) {
122
66
  {
123
67
  // When multiple notes per block are supported. Remove note ID check.
124
68
  // See: https://github.com/WordPress/gutenberg/pull/75147.
125
- isDisabled: isDistractionFree || isClassicBlock || !clientId || !!blockCommentId
69
+ isDisabled: isDistractionFree || isClassicBlock || !clientId || !!noteId
126
70
  }
127
71
  );
128
72
  const { merged: GlobalStyles } = useGlobalStylesContext();
129
73
  const backgroundColor = GlobalStyles?.styles?.color?.background;
130
- const currentThread = blockCommentId ? resultComments.find((thread) => thread.id === blockCommentId) : null;
74
+ const currentThread = noteId ? notes.find((thread) => thread.id === noteId) : null;
131
75
  async function openTheSidebar(selectedClientId) {
132
76
  const prevArea = await getActiveComplementaryArea("core");
133
77
  const activeNotesArea = SIDEBARS.find((name) => name === prevArea);
134
78
  const targetClientId = selectedClientId && selectedClientId !== clientId ? selectedClientId : clientId;
135
- const targetNote = resultComments.find(
79
+ const targetNote = notes.find(
136
80
  (note) => note.blockClientId === targetClientId
137
81
  );
138
82
  if (targetNote?.status === "approved") {
@@ -152,17 +96,17 @@ function NotesSidebar({ postId }) {
152
96
  selectNote(targetNote ? targetNote.id : "new", { focus: true });
153
97
  }
154
98
  if (isDistractionFree) {
155
- return /* @__PURE__ */ jsx(AddCommentMenuItem, { isDistractionFree: true });
99
+ return /* @__PURE__ */ jsx(AddNoteMenuItem, { isDistractionFree: true });
156
100
  }
157
101
  return /* @__PURE__ */ jsxs(Fragment, { children: [
158
102
  !!currentThread && /* @__PURE__ */ jsx(
159
- CommentAvatarIndicator,
103
+ NoteAvatarIndicator,
160
104
  {
161
- thread: currentThread,
105
+ note: currentThread,
162
106
  onClick: openTheSidebar
163
107
  }
164
108
  ),
165
- /* @__PURE__ */ jsx(AddCommentMenuItem, { onClick: openTheSidebar }),
109
+ /* @__PURE__ */ jsx(AddNoteMenuItem, { onClick: openTheSidebar }),
166
110
  showAllNotesSidebar && /* @__PURE__ */ jsx(
167
111
  PluginSidebar,
168
112
  {
@@ -172,13 +116,7 @@ function NotesSidebar({ postId }) {
172
116
  header: /* @__PURE__ */ jsx("h2", { className: "interface-complementary-area-header__title", children: __("All notes") }),
173
117
  icon: commentIcon,
174
118
  closeLabel: __("Close Notes"),
175
- children: /* @__PURE__ */ jsx(
176
- NotesSidebarContent,
177
- {
178
- comments: resultComments,
179
- commentSidebarRef
180
- }
181
- )
119
+ children: /* @__PURE__ */ jsx(Notes, { notes, sidebarRef })
182
120
  }
183
121
  ),
184
122
  isLargeViewport && /* @__PURE__ */ jsx(
@@ -191,15 +129,11 @@ function NotesSidebar({ postId }) {
191
129
  headerClassName: "editor-collab-sidebar__header",
192
130
  backgroundColor,
193
131
  children: /* @__PURE__ */ jsx(
194
- NotesSidebarContent,
132
+ Notes,
195
133
  {
196
- comments: unresolvedSortedThreads,
197
- commentSidebarRef,
198
- reflowComments,
199
- commentLastUpdated,
200
- styles: {
201
- backgroundColor
202
- },
134
+ notes: unresolvedNotes,
135
+ sidebarRef,
136
+ styles: { backgroundColor },
203
137
  isFloating: true
204
138
  }
205
139
  )