@wordpress/editor 14.45.2-next.v.202605131032.0 → 14.47.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 (326) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/build/components/collab-sidebar/add-note.cjs +6 -0
  3. package/build/components/collab-sidebar/add-note.cjs.map +2 -2
  4. package/build/components/collab-sidebar/hooks.cjs +36 -24
  5. package/build/components/collab-sidebar/hooks.cjs.map +2 -2
  6. package/build/components/collab-sidebar/index.cjs +19 -10
  7. package/build/components/collab-sidebar/index.cjs.map +2 -2
  8. package/build/components/collab-sidebar/note-byline.cjs +16 -9
  9. package/build/components/collab-sidebar/note-byline.cjs.map +2 -2
  10. package/build/components/collab-sidebar/notes.cjs +20 -11
  11. package/build/components/collab-sidebar/notes.cjs.map +2 -2
  12. package/build/components/collab-sidebar/utils.cjs +42 -2
  13. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  14. package/build/components/collaborators-overlay/compute-selection.cjs +39 -15
  15. package/build/components/collaborators-overlay/compute-selection.cjs.map +3 -3
  16. package/build/components/collaborators-overlay/use-block-highlighting.cjs +10 -2
  17. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
  18. package/build/components/collaborators-overlay/use-render-cursors.cjs +15 -7
  19. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  20. package/build/components/collaborators-presence/avatar/component.cjs +5 -1
  21. package/build/components/collaborators-presence/avatar/component.cjs.map +3 -3
  22. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +6 -3
  23. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
  24. package/build/components/editor-interface/index.cjs +17 -16
  25. package/build/components/editor-interface/index.cjs.map +3 -3
  26. package/build/components/editor-notices/index.cjs +6 -1
  27. package/build/components/editor-notices/index.cjs.map +3 -3
  28. package/build/components/global-styles/hooks.cjs +12 -1
  29. package/build/components/global-styles/hooks.cjs.map +2 -2
  30. package/build/components/header/index.cjs +11 -6
  31. package/build/components/header/index.cjs.map +2 -2
  32. package/build/components/media/media-editor-modal.cjs +14 -1
  33. package/build/components/media/media-editor-modal.cjs.map +2 -2
  34. package/build/components/post-card-panel/index.cjs +7 -1
  35. package/build/components/post-card-panel/index.cjs.map +3 -3
  36. package/build/components/post-last-revision/index.cjs +28 -8
  37. package/build/components/post-last-revision/index.cjs.map +2 -2
  38. package/build/components/post-locked-modal/index.cjs +9 -6
  39. package/build/components/post-locked-modal/index.cjs.map +2 -2
  40. package/build/components/post-publish-button/label.cjs +0 -7
  41. package/build/components/post-publish-button/label.cjs.map +2 -2
  42. package/build/components/post-publish-panel/prepublish.cjs +8 -1
  43. package/build/components/post-publish-panel/prepublish.cjs.map +3 -3
  44. package/build/components/post-revisions-panel/index.cjs +7 -0
  45. package/build/components/post-revisions-panel/index.cjs.map +2 -2
  46. package/build/components/post-revisions-preview/diff-markers.cjs +21 -13
  47. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  48. package/build/components/post-revisions-preview/revisions-canvas.cjs +7 -1
  49. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +2 -2
  50. package/build/components/post-taxonomies/check.cjs +1 -2
  51. package/build/components/post-taxonomies/check.cjs.map +2 -2
  52. package/build/components/post-taxonomies/index.cjs +1 -2
  53. package/build/components/post-taxonomies/index.cjs.map +2 -2
  54. package/build/components/preferences-modal/index.cjs +1 -1
  55. package/build/components/preferences-modal/index.cjs.map +2 -2
  56. package/build/components/preview-dropdown/index.cjs.map +3 -3
  57. package/build/components/provider/index.cjs +5 -21
  58. package/build/components/provider/index.cjs.map +3 -3
  59. package/build/components/provider/use-block-editor-settings.cjs +16 -9
  60. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  61. package/build/components/resizable-editor/resize-handle.cjs +24 -16
  62. package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
  63. package/build/components/sidebar/header.cjs +16 -21
  64. package/build/components/sidebar/header.cjs.map +3 -3
  65. package/build/components/sidebar/index.cjs +2 -6
  66. package/build/components/sidebar/index.cjs.map +2 -2
  67. package/build/components/start-page-options/index.cjs +14 -4
  68. package/build/components/start-page-options/index.cjs.map +2 -2
  69. package/build/components/start-template-options/index.cjs +8 -6
  70. package/build/components/start-template-options/index.cjs.map +2 -2
  71. package/build/components/styles-canvas/style-book.cjs +59 -2
  72. package/build/components/styles-canvas/style-book.cjs.map +2 -2
  73. package/build/components/sync-connection-error-modal/index.cjs +10 -7
  74. package/build/components/sync-connection-error-modal/index.cjs.map +3 -3
  75. package/build/components/template-actions-panel/block-theme-content.cjs +21 -12
  76. package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
  77. package/build/dataviews/store/private-actions.cjs.map +2 -2
  78. package/build/store/private-actions.cjs +17 -1
  79. package/build/store/private-actions.cjs.map +3 -3
  80. package/build/store/private-selectors.cjs +18 -0
  81. package/build/store/private-selectors.cjs.map +2 -2
  82. package/build/store/selectors.cjs +0 -17
  83. package/build/store/selectors.cjs.map +2 -2
  84. package/build/{components/media → utils/media-delete}/index.cjs +12 -13
  85. package/build/utils/media-delete/index.cjs.map +7 -0
  86. package/build/utils/media-finalize/index.cjs +3 -1
  87. package/build/utils/media-finalize/index.cjs.map +2 -2
  88. package/build/utils/sync-error-messages.cjs +9 -0
  89. package/build/utils/sync-error-messages.cjs.map +2 -2
  90. package/build-module/components/collab-sidebar/add-note.mjs +6 -0
  91. package/build-module/components/collab-sidebar/add-note.mjs.map +2 -2
  92. package/build-module/components/collab-sidebar/hooks.mjs +42 -25
  93. package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
  94. package/build-module/components/collab-sidebar/index.mjs +19 -10
  95. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  96. package/build-module/components/collab-sidebar/note-byline.mjs +17 -10
  97. package/build-module/components/collab-sidebar/note-byline.mjs.map +2 -2
  98. package/build-module/components/collab-sidebar/notes.mjs +26 -13
  99. package/build-module/components/collab-sidebar/notes.mjs.map +2 -2
  100. package/build-module/components/collab-sidebar/utils.mjs +38 -2
  101. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  102. package/build-module/components/collaborators-overlay/compute-selection.mjs +36 -12
  103. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +2 -2
  104. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +10 -3
  105. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  106. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +11 -6
  107. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  108. package/build-module/components/collaborators-presence/avatar/component.mjs +7 -3
  109. package/build-module/components/collaborators-presence/avatar/component.mjs.map +2 -2
  110. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +6 -3
  111. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
  112. package/build-module/components/editor-interface/index.mjs +22 -17
  113. package/build-module/components/editor-interface/index.mjs.map +2 -2
  114. package/build-module/components/editor-notices/index.mjs +6 -1
  115. package/build-module/components/editor-notices/index.mjs.map +2 -2
  116. package/build-module/components/global-styles/hooks.mjs +12 -1
  117. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  118. package/build-module/components/header/index.mjs +11 -6
  119. package/build-module/components/header/index.mjs.map +2 -2
  120. package/build-module/components/media/media-editor-modal.mjs +14 -1
  121. package/build-module/components/media/media-editor-modal.mjs.map +2 -2
  122. package/build-module/components/post-card-panel/index.mjs +8 -2
  123. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  124. package/build-module/components/post-last-revision/index.mjs +29 -9
  125. package/build-module/components/post-last-revision/index.mjs.map +2 -2
  126. package/build-module/components/post-locked-modal/index.mjs +9 -6
  127. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  128. package/build-module/components/post-publish-button/label.mjs +0 -7
  129. package/build-module/components/post-publish-button/label.mjs.map +2 -2
  130. package/build-module/components/post-publish-panel/prepublish.mjs +9 -2
  131. package/build-module/components/post-publish-panel/prepublish.mjs.map +2 -2
  132. package/build-module/components/post-revisions-panel/index.mjs +7 -0
  133. package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
  134. package/build-module/components/post-revisions-preview/diff-markers.mjs +22 -14
  135. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  136. package/build-module/components/post-revisions-preview/revisions-canvas.mjs +7 -1
  137. package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
  138. package/build-module/components/post-taxonomies/check.mjs +1 -2
  139. package/build-module/components/post-taxonomies/check.mjs.map +2 -2
  140. package/build-module/components/post-taxonomies/index.mjs +1 -2
  141. package/build-module/components/post-taxonomies/index.mjs.map +2 -2
  142. package/build-module/components/preferences-modal/index.mjs +1 -1
  143. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  144. package/build-module/components/preview-dropdown/index.mjs +2 -2
  145. package/build-module/components/preview-dropdown/index.mjs.map +2 -2
  146. package/build-module/components/provider/index.mjs +6 -22
  147. package/build-module/components/provider/index.mjs.map +2 -2
  148. package/build-module/components/provider/use-block-editor-settings.mjs +16 -9
  149. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  150. package/build-module/components/resizable-editor/resize-handle.mjs +26 -18
  151. package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
  152. package/build-module/components/sidebar/header.mjs +11 -16
  153. package/build-module/components/sidebar/header.mjs.map +2 -2
  154. package/build-module/components/sidebar/index.mjs +2 -7
  155. package/build-module/components/sidebar/index.mjs.map +2 -2
  156. package/build-module/components/start-page-options/index.mjs +14 -4
  157. package/build-module/components/start-page-options/index.mjs.map +2 -2
  158. package/build-module/components/start-template-options/index.mjs +8 -6
  159. package/build-module/components/start-template-options/index.mjs.map +2 -2
  160. package/build-module/components/styles-canvas/style-book.mjs +60 -3
  161. package/build-module/components/styles-canvas/style-book.mjs.map +2 -2
  162. package/build-module/components/sync-connection-error-modal/index.mjs +14 -8
  163. package/build-module/components/sync-connection-error-modal/index.mjs.map +2 -2
  164. package/build-module/components/template-actions-panel/block-theme-content.mjs +21 -13
  165. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
  166. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  167. package/build-module/store/private-actions.mjs +16 -1
  168. package/build-module/store/private-actions.mjs.map +2 -2
  169. package/build-module/store/private-selectors.mjs +18 -0
  170. package/build-module/store/private-selectors.mjs.map +2 -2
  171. package/build-module/store/selectors.mjs +0 -16
  172. package/build-module/store/selectors.mjs.map +2 -2
  173. package/build-module/utils/media-delete/index.mjs +12 -0
  174. package/build-module/utils/media-delete/index.mjs.map +7 -0
  175. package/build-module/utils/media-finalize/index.mjs +3 -1
  176. package/build-module/utils/media-finalize/index.mjs.map +2 -2
  177. package/build-module/utils/sync-error-messages.mjs +8 -0
  178. package/build-module/utils/sync-error-messages.mjs.map +2 -2
  179. package/build-style/style-rtl.css +462 -408
  180. package/build-style/style.css +462 -408
  181. package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -1
  182. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  183. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  184. package/build-types/components/collab-sidebar/note-byline.d.ts +3 -0
  185. package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -1
  186. package/build-types/components/collab-sidebar/notes.d.ts.map +1 -1
  187. package/build-types/components/collab-sidebar/utils.d.ts +33 -0
  188. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  189. package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -1
  190. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +3 -0
  191. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  192. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  193. package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -1
  194. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
  195. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  196. package/build-types/components/editor-notices/index.d.ts.map +1 -1
  197. package/build-types/components/global-styles/hooks.d.ts.map +1 -1
  198. package/build-types/components/media/media-editor-modal.d.ts +6 -2
  199. package/build-types/components/media/media-editor-modal.d.ts.map +1 -1
  200. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  201. package/build-types/components/post-last-revision/index.d.ts.map +1 -1
  202. package/build-types/components/post-locked-modal/index.d.ts +1 -6
  203. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  204. package/build-types/components/post-publish-button/label.d.ts.map +1 -1
  205. package/build-types/components/post-publish-panel/prepublish.d.ts.map +1 -1
  206. package/build-types/components/post-revisions-panel/index.d.ts +1 -1
  207. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -1
  208. package/build-types/components/post-revisions-preview/diff-markers.d.ts.map +1 -1
  209. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
  210. package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
  211. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +1 -6
  212. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -6
  213. package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
  214. package/build-types/components/provider/index.d.ts.map +1 -1
  215. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  216. package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
  217. package/build-types/components/sidebar/index.d.ts.map +1 -1
  218. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  219. package/build-types/components/start-template-options/index.d.ts.map +1 -1
  220. package/build-types/components/styles-canvas/style-book.d.ts.map +1 -1
  221. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -1
  222. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
  223. package/build-types/dataviews/store/private-actions.d.ts +0 -1
  224. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  225. package/build-types/store/private-actions.d.ts +15 -0
  226. package/build-types/store/private-actions.d.ts.map +1 -1
  227. package/build-types/store/private-selectors.d.ts +10 -0
  228. package/build-types/store/private-selectors.d.ts.map +1 -1
  229. package/build-types/store/selectors.d.ts +0 -10
  230. package/build-types/store/selectors.d.ts.map +1 -1
  231. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  232. package/build-types/utils/media-delete/index.d.ts +2 -0
  233. package/build-types/utils/media-delete/index.d.ts.map +1 -0
  234. package/build-types/utils/media-finalize/index.d.ts +1 -1
  235. package/build-types/utils/media-finalize/index.d.ts.map +1 -1
  236. package/build-types/utils/sync-error-messages.d.ts +1 -0
  237. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  238. package/package.json +48 -48
  239. package/src/components/collab-sidebar/add-note.js +9 -0
  240. package/src/components/collab-sidebar/hooks.js +53 -29
  241. package/src/components/collab-sidebar/index.js +28 -14
  242. package/src/components/collab-sidebar/note-byline.js +15 -10
  243. package/src/components/collab-sidebar/notes.js +36 -14
  244. package/src/components/collab-sidebar/test/utils.js +375 -1
  245. package/src/components/collab-sidebar/utils.js +70 -1
  246. package/src/components/collaborators-overlay/compute-selection.ts +67 -19
  247. package/src/components/collaborators-overlay/use-block-highlighting.ts +14 -1
  248. package/src/components/collaborators-overlay/use-render-cursors.ts +15 -4
  249. package/src/components/collaborators-presence/avatar/component.tsx +10 -3
  250. package/src/components/collaborators-presence/avatar/test/index.tsx +50 -18
  251. package/src/components/collaborators-presence/styles/collaborators-presence.scss +4 -1
  252. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +2 -1
  253. package/src/components/collaborators-presence/use-collaborator-notifications.ts +6 -4
  254. package/src/components/editor-help/help-topic-row.native.js +2 -2
  255. package/src/components/editor-interface/index.js +22 -23
  256. package/src/components/editor-interface/style.scss +4 -0
  257. package/src/components/editor-notices/index.js +7 -1
  258. package/src/components/error-boundary/index.native.js +2 -2
  259. package/src/components/global-styles/hooks.js +26 -0
  260. package/src/components/global-styles-sidebar/style.scss +0 -9
  261. package/src/components/header/index.js +12 -12
  262. package/src/components/media/media-editor-modal.js +20 -2
  263. package/src/components/offline-status/index.native.js +2 -2
  264. package/src/components/post-card-panel/index.js +5 -2
  265. package/src/components/post-last-revision/index.js +37 -9
  266. package/src/components/post-last-revision/style.scss +0 -3
  267. package/src/components/post-locked-modal/index.js +8 -5
  268. package/src/components/post-panel-row/style.scss +1 -0
  269. package/src/components/post-publish-button/label.js +0 -11
  270. package/src/components/post-publish-panel/prepublish.js +6 -2
  271. package/src/components/post-revisions-panel/index.js +8 -0
  272. package/src/components/post-revisions-preview/diff-markers.js +17 -11
  273. package/src/components/post-revisions-preview/revisions-canvas.js +7 -1
  274. package/src/components/post-revisions-preview/style.scss +4 -4
  275. package/src/components/post-taxonomies/check.js +1 -2
  276. package/src/components/post-taxonomies/index.js +1 -2
  277. package/src/components/preferences-modal/index.js +1 -1
  278. package/src/components/preview-dropdown/index.js +2 -2
  279. package/src/components/provider/index.js +10 -31
  280. package/src/components/provider/use-block-editor-settings.js +19 -12
  281. package/src/components/resizable-editor/resize-handle.js +22 -16
  282. package/src/components/sidebar/header.js +18 -28
  283. package/src/components/sidebar/index.js +5 -14
  284. package/src/components/start-page-options/index.js +19 -4
  285. package/src/components/start-template-options/index.js +13 -6
  286. package/src/components/styles-canvas/style-book.js +75 -13
  287. package/src/components/sync-connection-error-modal/index.tsx +25 -11
  288. package/src/components/template-actions-panel/block-theme-content.js +19 -13
  289. package/src/components/text-editor/style.scss +2 -2
  290. package/src/dataviews/store/private-actions.ts +0 -1
  291. package/src/store/private-actions.js +27 -0
  292. package/src/store/private-selectors.js +26 -0
  293. package/src/store/selectors.js +0 -24
  294. package/src/store/test/actions.js +34 -0
  295. package/src/utils/media-delete/index.js +11 -0
  296. package/src/utils/media-finalize/index.js +6 -1
  297. package/src/utils/media-finalize/test/index.js +32 -2
  298. package/src/utils/sync-error-messages.ts +8 -0
  299. package/src/utils/test/sync-error-messages.js +1 -0
  300. package/build/components/global-styles-provider/index.cjs +0 -181
  301. package/build/components/global-styles-provider/index.cjs.map +0 -7
  302. package/build/components/media/index.cjs.map +0 -7
  303. package/build/components/media/metadata-panel.cjs +0 -96
  304. package/build/components/media/metadata-panel.cjs.map +0 -7
  305. package/build/components/media/preview.cjs +0 -39
  306. package/build/components/media/preview.cjs.map +0 -7
  307. package/build-module/components/global-styles-provider/index.mjs +0 -156
  308. package/build-module/components/global-styles-provider/index.mjs.map +0 -7
  309. package/build-module/components/media/index.mjs +0 -8
  310. package/build-module/components/media/index.mjs.map +0 -7
  311. package/build-module/components/media/metadata-panel.mjs +0 -65
  312. package/build-module/components/media/metadata-panel.mjs.map +0 -7
  313. package/build-module/components/media/preview.mjs +0 -21
  314. package/build-module/components/media/preview.mjs.map +0 -7
  315. package/build-types/components/global-styles-provider/index.d.ts +0 -16
  316. package/build-types/components/global-styles-provider/index.d.ts.map +0 -1
  317. package/build-types/components/media/index.d.ts +0 -3
  318. package/build-types/components/media/index.d.ts.map +0 -1
  319. package/build-types/components/media/metadata-panel.d.ts +0 -12
  320. package/build-types/components/media/metadata-panel.d.ts.map +0 -1
  321. package/build-types/components/media/preview.d.ts +0 -9
  322. package/build-types/components/media/preview.d.ts.map +0 -1
  323. package/src/components/global-styles-provider/index.js +0 -207
  324. package/src/components/media/index.js +0 -2
  325. package/src/components/media/metadata-panel.js +0 -77
  326. package/src/components/media/preview.js +0 -35
@@ -20,7 +20,12 @@ import { store as editorStore } from "../../store/index.mjs";
20
20
  import { FLOATING_NOTES_SIDEBAR } from "./constants.mjs";
21
21
  import { unlock } from "../../lock-unlock.mjs";
22
22
  import { createBoardStore } from "./board-store.mjs";
23
- import { calculateNotePositions } from "./utils.mjs";
23
+ import {
24
+ calculateNotePositions,
25
+ getNoteIdsFromMetadata,
26
+ addNoteIdToMetadata,
27
+ removeNoteIdFromMetadata
28
+ } from "./utils.mjs";
24
29
  var { cleanEmptyObject } = unlock(blockEditorPrivateApis);
25
30
  function useNoteThreads(postId) {
26
31
  const queryArgs = {
@@ -49,11 +54,13 @@ function useNoteThreads(postId) {
49
54
  const blocksWithNotes = {};
50
55
  const clientIdByNoteId = /* @__PURE__ */ new Map();
51
56
  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
+ const metadata = getBlockAttributes(clientId)?.metadata;
58
+ const noteIds = getNoteIdsFromMetadata(metadata);
59
+ if (noteIds.length > 0) {
60
+ blocksWithNotes[clientId] = noteIds;
61
+ for (const noteId of noteIds) {
62
+ clientIdByNoteId.set(noteId, clientId);
63
+ }
57
64
  }
58
65
  }
59
66
  const threadsById = /* @__PURE__ */ new Map();
@@ -62,7 +69,7 @@ function useNoteThreads(postId) {
62
69
  const thread = {
63
70
  ...item,
64
71
  reply: [],
65
- blockClientId: item.parent === 0 ? clientIdByNoteId.get(String(item.id)) ?? null : null
72
+ blockClientId: item.parent === 0 ? clientIdByNoteId.get(item.id) ?? null : null
66
73
  };
67
74
  threadsById.set(item.id, thread);
68
75
  if (item.parent === 0) {
@@ -79,15 +86,17 @@ function useNoteThreads(postId) {
79
86
  }
80
87
  const unresolved = [];
81
88
  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);
89
+ for (const noteIds of Object.values(blocksWithNotes)) {
90
+ for (const noteId of noteIds) {
91
+ const thread = threadsById.get(noteId);
92
+ if (!thread) {
93
+ continue;
94
+ }
95
+ if (thread.status === "hold") {
96
+ unresolved.push(thread);
97
+ } else if (thread.status === "approved") {
98
+ resolved.push(thread);
99
+ }
91
100
  }
92
101
  }
93
102
  const orphans = rootThreads.filter(
@@ -132,12 +141,16 @@ function useNoteActions() {
132
141
  );
133
142
  if (!parent && savedRecord?.id) {
134
143
  const clientId = getSelectedBlockClientId();
144
+ if (!clientId) {
145
+ return savedRecord;
146
+ }
135
147
  const metadata = getBlockAttributes(clientId)?.metadata;
148
+ const updatedMetadata = addNoteIdToMetadata(
149
+ metadata,
150
+ savedRecord.id
151
+ );
136
152
  updateBlockAttributes(clientId, {
137
- metadata: {
138
- ...metadata,
139
- noteId: savedRecord.id
140
- }
153
+ metadata: cleanEmptyObject(updatedMetadata)
141
154
  });
142
155
  }
143
156
  createNotice(
@@ -215,13 +228,17 @@ function useNoteActions() {
215
228
  throwOnError: true
216
229
  });
217
230
  if (!note.parent) {
218
- const clientId = getSelectedBlockClientId();
231
+ const clientId = note.blockClientId || getSelectedBlockClientId();
232
+ if (!clientId) {
233
+ return;
234
+ }
219
235
  const metadata = getBlockAttributes(clientId)?.metadata;
236
+ const updatedMetadata = removeNoteIdFromMetadata(
237
+ metadata,
238
+ note.id
239
+ );
220
240
  updateBlockAttributes(clientId, {
221
- metadata: cleanEmptyObject({
222
- ...metadata,
223
- noteId: void 0
224
- })
241
+ metadata: cleanEmptyObject(updatedMetadata)
225
242
  });
226
243
  }
227
244
  createNotice("snackbar", __("Note deleted."), {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/hooks.js"],
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;AAA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AU,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;",
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 {\n\tcalculateNotePositions,\n\tgetNoteIdsFromMetadata,\n\taddNoteIdToMetadata,\n\tremoveNoteIdFromMetadata,\n} 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 builds the forward map and reverse lookup\n\t\t// together. getNoteIdsFromMetadata returns numeric ids, matching the\n\t\t// types returned by the comments REST endpoint.\n\t\tconst blocksWithNotes = {};\n\t\tconst clientIdByNoteId = new Map();\n\t\tfor ( const clientId of clientIds ) {\n\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\tconst noteIds = getNoteIdsFromMetadata( metadata );\n\t\t\tif ( noteIds.length > 0 ) {\n\t\t\t\tblocksWithNotes[ clientId ] = noteIds;\n\t\t\t\tfor ( const noteId of noteIds ) {\n\t\t\t\t\tclientIdByNoteId.set( noteId, clientId );\n\t\t\t\t}\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( 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. Each block can have\n\t\t// multiple note IDs, so iterate the flattened list.\n\t\tconst unresolved = [];\n\t\tconst resolved = [];\n\t\tfor ( const noteIds of Object.values( blocksWithNotes ) ) {\n\t\t\tfor ( const noteId of noteIds ) {\n\t\t\t\tconst thread = threadsById.get( noteId );\n\t\t\t\tif ( ! thread ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif ( thread.status === 'hold' ) {\n\t\t\t\t\tunresolved.push( thread );\n\t\t\t\t} else if ( thread.status === 'approved' ) {\n\t\t\t\t\tresolved.push( thread );\n\t\t\t\t}\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\t// Read-modify-write on metadata is racy under concurrent edits:\n\t\t\t// two near-simultaneous adds against the same base will each write\n\t\t\t// a 2-element array and the later write wins, dropping the other\n\t\t\t// id. Tracking issue: https://github.com/WordPress/gutenberg/issues/74751.\n\t\t\tif ( ! parent && savedRecord?.id ) {\n\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\treturn savedRecord;\n\t\t\t\t}\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tconst updatedMetadata = addNoteIdToMetadata(\n\t\t\t\t\tmetadata,\n\t\t\t\t\tsavedRecord.id\n\t\t\t\t);\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: cleanEmptyObject( updatedMetadata ),\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\t// Use blockClientId if available, otherwise fall back to selected block.\n\t\t\t\tconst clientId =\n\t\t\t\t\tnote.blockClientId || getSelectedBlockClientId();\n\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst metadata = getBlockAttributes( clientId )?.metadata;\n\t\t\t\tconst updatedMetadata = removeNoteIdFromMetadata(\n\t\t\t\t\tmetadata,\n\t\t\t\t\tnote.id\n\t\t\t\t);\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tmetadata: cleanEmptyObject( updatedMetadata ),\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;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,IAAM,EAAE,iBAAiB,IAAI,OAAQ,sBAAuB;AAErD,SAAS,eAAgB,QAAS;AACxC,QAAM,YAAY;AAAA,IACjB,MAAM;AAAA,IACN,MAAM;A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B;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
  }
@@ -18,8 +18,9 @@ import { Notes } from "./notes.mjs";
18
18
  import { store as editorStore } from "../../store/index.mjs";
19
19
  import { AddNoteMenuItem } from "./add-note-menu-item.mjs";
20
20
  import { NoteAvatarIndicator } from "./note-indicator-toolbar.mjs";
21
- import { useGlobalStylesContext } from "../global-styles-provider/index.mjs";
21
+ import { useGlobalStyles } from "../global-styles/index.mjs";
22
22
  import { useNoteThreads, useEnableFloatingSidebar } from "./hooks.mjs";
23
+ import { getNoteIdsFromMetadata, pickPrimaryNote } from "./utils.mjs";
23
24
  import PostTypeSupportCheck from "../post-type-support-check/index.mjs";
24
25
  import { unlock } from "../../lock-unlock.mjs";
25
26
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -41,6 +42,7 @@ function NotesSidebar({ postId }) {
41
42
  isClassicBlock: _clientId ? getBlockName(_clientId) === "core/freeform" : false
42
43
  };
43
44
  }, []);
45
+ const blockNoteIds = getNoteIdsFromMetadata({ noteId });
44
46
  const { isDistractionFree } = useSelect((select) => {
45
47
  const { get } = select(preferencesStore);
46
48
  return {
@@ -83,30 +85,37 @@ function NotesSidebar({ postId }) {
83
85
  selectNote(targetNoteId, { focus: true });
84
86
  }
85
87
  function openNoteForBlock(targetClientId) {
86
- const target = notes.find(
87
- (note) => note.blockClientId === targetClientId
88
+ const blockThreads = notes.filter(
89
+ (thread) => thread.blockClientId === targetClientId
88
90
  );
91
+ const target = pickPrimaryNote(blockThreads);
89
92
  return focusNote({
90
93
  targetClientId,
91
94
  noteId: target?.id ?? "new",
92
95
  isApproved: target?.status === "approved"
93
96
  });
94
97
  }
98
+ function addNewNoteForBlock(targetClientId) {
99
+ return focusNote({
100
+ targetClientId,
101
+ noteId: "new",
102
+ isApproved: false
103
+ });
104
+ }
95
105
  useShortcut(
96
106
  "core/editor/new-note",
97
107
  (event) => {
98
108
  event.preventDefault();
99
- openNoteForBlock(clientId);
109
+ addNewNoteForBlock(clientId);
100
110
  },
101
111
  {
102
- // When multiple notes per block are supported. Remove note ID check.
103
- // See: https://github.com/WordPress/gutenberg/pull/75147.
104
- isDisabled: isDistractionFree || isClassicBlock || !clientId || !!noteId
112
+ isDisabled: isDistractionFree || isClassicBlock || !clientId
105
113
  }
106
114
  );
107
- const { merged: GlobalStyles } = useGlobalStylesContext();
115
+ const { merged: GlobalStyles } = useGlobalStyles();
108
116
  const backgroundColor = GlobalStyles?.styles?.color?.background;
109
- const currentThread = noteId ? notes.find((thread) => thread.id === noteId) : null;
117
+ const currentThreads = blockNoteIds.length > 0 ? notes.filter((thread) => blockNoteIds.includes(thread.id)) : [];
118
+ const currentThread = pickPrimaryNote(currentThreads);
110
119
  if (isDistractionFree) {
111
120
  return /* @__PURE__ */ jsx(AddNoteMenuItem, { isDistractionFree: true });
112
121
  }
@@ -121,7 +130,7 @@ function NotesSidebar({ postId }) {
121
130
  /* @__PURE__ */ jsx(
122
131
  AddNoteMenuItem,
123
132
  {
124
- onClick: (menuClientId) => openNoteForBlock(menuClientId)
133
+ onClick: (menuClientId) => addNewNoteForBlock(menuClientId)
125
134
  }
126
135
  ),
127
136
  showAllNotesSidebar && /* @__PURE__ */ jsx(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport {\n\tALL_NOTES_SIDEBAR,\n\tFLOATING_NOTES_SIDEBAR,\n\tSIDEBARS,\n} from './constants';\nimport { Notes } from './notes';\nimport { store as editorStore } from '../../store';\nimport { AddNoteMenuItem } from './add-note-menu-item';\nimport { NoteAvatarIndicator } from './note-indicator-toolbar';\nimport { useGlobalStylesContext } from '../global-styles-provider';\nimport { useNoteThreads, useEnableFloatingSidebar } from './hooks';\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { unlock } from '../../lock-unlock';\n\nfunction NotesSidebar( { postId } ) {\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { toggleBlockSpotlight, selectBlock } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst { selectNote } = unlock( useDispatch( editorStore ) );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst sidebarRef = useRef( null );\n\n\tconst { clientId, noteId, isClassicBlock } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId, getBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tclientId: _clientId,\n\t\t\tnoteId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.metadata?.noteId\n\t\t\t\t: null,\n\t\t\tisClassicBlock: _clientId\n\t\t\t\t? getBlockName( _clientId ) === 'core/freeform'\n\t\t\t\t: false,\n\t\t};\n\t}, [] );\n\tconst { isDistractionFree } = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\treturn {\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t};\n\t}, [] );\n\tconst selectedNote = useSelect(\n\t\t( select ) => unlock( select( editorStore ) ).getSelectedNote(),\n\t\t[]\n\t);\n\n\tconst { notes, unresolvedNotes } = useNoteThreads( postId );\n\n\t// Only enable the floating sidebar for large viewports.\n\tconst showFloatingSidebar = isLargeViewport;\n\t// Fallback to \"All notes\" sidebar on smaller viewports.\n\tconst showAllNotesSidebar = notes.length > 0 || ! showFloatingSidebar;\n\tuseEnableFloatingSidebar(\n\t\tshowFloatingSidebar &&\n\t\t\t( unresolvedNotes.length > 0 || selectedNote !== undefined )\n\t);\n\n\tasync function focusNote( {\n\t\ttargetClientId,\n\t\tnoteId: targetNoteId,\n\t\tisApproved,\n\t} ) {\n\t\tif ( ! targetClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevArea = await getActiveComplementaryArea( 'core' );\n\t\tif ( isApproved ) {\n\t\t\tenableComplementaryArea( 'core', ALL_NOTES_SIDEBAR );\n\t\t} else if ( ! SIDEBARS.includes( prevArea ) || ! showAllNotesSidebar ) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core',\n\t\t\t\tshowFloatingSidebar ? FLOATING_NOTES_SIDEBAR : ALL_NOTES_SIDEBAR\n\t\t\t);\n\t\t}\n\n\t\tconst currentArea = await getActiveComplementaryArea( 'core' );\n\t\t// Bail out if the current active area is not one of note sidebars.\n\t\tif ( ! SIDEBARS.includes( currentArea ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// A special case for the List View, where block selection isn't required to trigger an action.\n\t\t// The action won't do anything if the block is already selected.\n\t\tselectBlock( targetClientId, null );\n\t\ttoggleBlockSpotlight( targetClientId, true );\n\t\tselectNote( targetNoteId, { focus: true } );\n\t}\n\n\tfunction openNoteForBlock( targetClientId ) {\n\t\tconst target = notes.find(\n\t\t\t( note ) => note.blockClientId === targetClientId\n\t\t);\n\t\treturn focusNote( {\n\t\t\ttargetClientId,\n\t\t\tnoteId: target?.id ?? 'new',\n\t\t\tisApproved: target?.status === 'approved',\n\t\t} );\n\t}\n\n\tuseShortcut(\n\t\t'core/editor/new-note',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\topenNoteForBlock( clientId );\n\t\t},\n\t\t{\n\t\t\t// When multiple notes per block are supported. Remove note ID check.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/75147.\n\t\t\tisDisabled:\n\t\t\t\tisDistractionFree || isClassicBlock || ! clientId || !! noteId,\n\t\t}\n\t);\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStylesContext();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\t// Find the current thread for the selected block.\n\tconst currentThread = noteId\n\t\t? notes.find( ( thread ) => thread.id === noteId )\n\t\t: null;\n\n\tif ( isDistractionFree ) {\n\t\treturn <AddNoteMenuItem isDistractionFree />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ !! currentThread && (\n\t\t\t\t<NoteAvatarIndicator\n\t\t\t\t\tnote={ currentThread }\n\t\t\t\t\tonClick={ () => openNoteForBlock( clientId ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<AddNoteMenuItem\n\t\t\t\tonClick={ ( menuClientId ) => openNoteForBlock( menuClientId ) }\n\t\t\t/>\n\t\t\t{ showAllNotesSidebar && (\n\t\t\t\t<PluginSidebar\n\t\t\t\t\tidentifier={ ALL_NOTES_SIDEBAR }\n\t\t\t\t\tname={ ALL_NOTES_SIDEBAR }\n\t\t\t\t\ttitle={ __( 'All notes' ) }\n\t\t\t\t\theader={\n\t\t\t\t\t\t<h2 className=\"interface-complementary-area-header__title\">\n\t\t\t\t\t\t\t{ __( 'All notes' ) }\n\t\t\t\t\t\t</h2>\n\t\t\t\t\t}\n\t\t\t\t\ticon={ commentIcon }\n\t\t\t\t\tcloseLabel={ __( 'Close Notes' ) }\n\t\t\t\t>\n\t\t\t\t\t<Notes notes={ notes } sidebarRef={ sidebarRef } />\n\t\t\t\t</PluginSidebar>\n\t\t\t) }\n\t\t\t{ isLargeViewport && (\n\t\t\t\t<PluginSidebar\n\t\t\t\t\tisPinnable={ false }\n\t\t\t\t\theader={ false }\n\t\t\t\t\tidentifier={ FLOATING_NOTES_SIDEBAR }\n\t\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t\t\tbackgroundColor={ backgroundColor }\n\t\t\t\t>\n\t\t\t\t\t<Notes\n\t\t\t\t\t\tnotes={ unresolvedNotes }\n\t\t\t\t\t\tsidebarRef={ sidebarRef }\n\t\t\t\t\t\tstyles={ { backgroundColor } }\n\t\t\t\t\t\tisFloating\n\t\t\t\t\t/>\n\t\t\t\t</PluginSidebar>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default function NotesSidebarContainer() {\n\tconst { postId, editorMode, revisionsMode } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getEditorMode, isRevisionsMode } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\teditorMode: getEditorMode(),\n\t\t\trevisionsMode: isRevisionsMode(),\n\t\t};\n\t}, [] );\n\n\tif ( ! postId || typeof postId !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Hide Notes sidebar for Code Editor and in-editor revision mode.\n\tif ( editorMode === 'text' || revisionsMode ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"editor.notes\">\n\t\t\t<NotesSidebar post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BAAyC;AAC/C,QAAM,EAAE,QAAQ,YAAY,cAAc,IAAI,UAAW,CAAE,WAAY;AACtE,UAAM,EAAE,kBAAkB,eAAe,gBAAgB,IAAI;AAAA,MAC5D,OAAQ,WAAY;AAAA,IACrB;AACA,WAAO;AAAA,MACN,QAAQ,iBAAiB;AAAA,MACzB,YAAY,cAAc;AAAA,MAC1B,eAAe,gBAAgB;AAAA,IAChC;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,MAAK,CAAE,UAAU,OAAO,WAAW,UAAW;AAC7C,WAAO;AAAA,EACR;AAGA,MAAK,eAAe,UAAU,eAAgB;AAC7C,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,wBAAqB,aAAY,gBACjC,8BAAC,gBAAa,QAAkB,GACjC;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport {\n\tALL_NOTES_SIDEBAR,\n\tFLOATING_NOTES_SIDEBAR,\n\tSIDEBARS,\n} from './constants';\nimport { Notes } from './notes';\nimport { store as editorStore } from '../../store';\nimport { AddNoteMenuItem } from './add-note-menu-item';\nimport { NoteAvatarIndicator } from './note-indicator-toolbar';\nimport { useGlobalStyles } from '../global-styles';\nimport { useNoteThreads, useEnableFloatingSidebar } from './hooks';\nimport { getNoteIdsFromMetadata, pickPrimaryNote } from './utils';\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { unlock } from '../../lock-unlock';\n\nfunction NotesSidebar( { postId } ) {\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst { toggleBlockSpotlight, selectBlock } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst { selectNote } = unlock( useDispatch( editorStore ) );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst sidebarRef = useRef( null );\n\n\tconst { clientId, noteId, isClassicBlock } = useSelect( ( select ) => {\n\t\tconst { getBlockAttributes, getSelectedBlockClientId, getBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\tconst _clientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tclientId: _clientId,\n\t\t\tnoteId: _clientId\n\t\t\t\t? getBlockAttributes( _clientId )?.metadata?.noteId\n\t\t\t\t: null,\n\t\t\tisClassicBlock: _clientId\n\t\t\t\t? getBlockName( _clientId ) === 'core/freeform'\n\t\t\t\t: false,\n\t\t};\n\t}, [] );\n\n\tconst blockNoteIds = getNoteIdsFromMetadata( { noteId } );\n\tconst { isDistractionFree } = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\treturn {\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t};\n\t}, [] );\n\tconst selectedNote = useSelect(\n\t\t( select ) => unlock( select( editorStore ) ).getSelectedNote(),\n\t\t[]\n\t);\n\n\tconst { notes, unresolvedNotes } = useNoteThreads( postId );\n\n\t// Only enable the floating sidebar for large viewports.\n\tconst showFloatingSidebar = isLargeViewport;\n\t// Fallback to \"All notes\" sidebar on smaller viewports.\n\tconst showAllNotesSidebar = notes.length > 0 || ! showFloatingSidebar;\n\tuseEnableFloatingSidebar(\n\t\tshowFloatingSidebar &&\n\t\t\t( unresolvedNotes.length > 0 || selectedNote !== undefined )\n\t);\n\n\tasync function focusNote( {\n\t\ttargetClientId,\n\t\tnoteId: targetNoteId,\n\t\tisApproved,\n\t} ) {\n\t\tif ( ! targetClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevArea = await getActiveComplementaryArea( 'core' );\n\t\tif ( isApproved ) {\n\t\t\tenableComplementaryArea( 'core', ALL_NOTES_SIDEBAR );\n\t\t} else if ( ! SIDEBARS.includes( prevArea ) || ! showAllNotesSidebar ) {\n\t\t\tenableComplementaryArea(\n\t\t\t\t'core',\n\t\t\t\tshowFloatingSidebar ? FLOATING_NOTES_SIDEBAR : ALL_NOTES_SIDEBAR\n\t\t\t);\n\t\t}\n\n\t\tconst currentArea = await getActiveComplementaryArea( 'core' );\n\t\t// Bail out if the current active area is not one of note sidebars.\n\t\tif ( ! SIDEBARS.includes( currentArea ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// A special case for the List View, where block selection isn't required to trigger an action.\n\t\t// The action won't do anything if the block is already selected.\n\t\tselectBlock( targetClientId, null );\n\t\ttoggleBlockSpotlight( targetClientId, true );\n\t\tselectNote( targetNoteId, { focus: true } );\n\t}\n\n\tfunction openNoteForBlock( targetClientId ) {\n\t\t// A block can carry multiple threads; surface the most relevant.\n\t\tconst blockThreads = notes.filter(\n\t\t\t( thread ) => thread.blockClientId === targetClientId\n\t\t);\n\t\tconst target = pickPrimaryNote( blockThreads );\n\t\treturn focusNote( {\n\t\t\ttargetClientId,\n\t\t\tnoteId: target?.id ?? 'new',\n\t\t\tisApproved: target?.status === 'approved',\n\t\t} );\n\t}\n\n\tfunction addNewNoteForBlock( targetClientId ) {\n\t\treturn focusNote( {\n\t\t\ttargetClientId,\n\t\t\tnoteId: 'new',\n\t\t\tisApproved: false,\n\t\t} );\n\t}\n\n\tuseShortcut(\n\t\t'core/editor/new-note',\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\taddNewNoteForBlock( clientId );\n\t\t},\n\t\t{\n\t\t\tisDisabled: isDistractionFree || isClassicBlock || ! clientId,\n\t\t}\n\t);\n\n\t// Get the global styles to set the background color of the sidebar.\n\tconst { merged: GlobalStyles } = useGlobalStyles();\n\tconst backgroundColor = GlobalStyles?.styles?.color?.background;\n\n\t// Surface one thread for the avatar indicator.\n\tconst currentThreads =\n\t\tblockNoteIds.length > 0\n\t\t\t? notes.filter( ( thread ) => blockNoteIds.includes( thread.id ) )\n\t\t\t: [];\n\tconst currentThread = pickPrimaryNote( currentThreads );\n\n\tif ( isDistractionFree ) {\n\t\treturn <AddNoteMenuItem isDistractionFree />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ !! currentThread && (\n\t\t\t\t<NoteAvatarIndicator\n\t\t\t\t\tnote={ currentThread }\n\t\t\t\t\tonClick={ () => openNoteForBlock( clientId ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<AddNoteMenuItem\n\t\t\t\tonClick={ ( menuClientId ) =>\n\t\t\t\t\taddNewNoteForBlock( menuClientId )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ showAllNotesSidebar && (\n\t\t\t\t<PluginSidebar\n\t\t\t\t\tidentifier={ ALL_NOTES_SIDEBAR }\n\t\t\t\t\tname={ ALL_NOTES_SIDEBAR }\n\t\t\t\t\ttitle={ __( 'All notes' ) }\n\t\t\t\t\theader={\n\t\t\t\t\t\t<h2 className=\"interface-complementary-area-header__title\">\n\t\t\t\t\t\t\t{ __( 'All notes' ) }\n\t\t\t\t\t\t</h2>\n\t\t\t\t\t}\n\t\t\t\t\ticon={ commentIcon }\n\t\t\t\t\tcloseLabel={ __( 'Close Notes' ) }\n\t\t\t\t>\n\t\t\t\t\t<Notes notes={ notes } sidebarRef={ sidebarRef } />\n\t\t\t\t</PluginSidebar>\n\t\t\t) }\n\t\t\t{ isLargeViewport && (\n\t\t\t\t<PluginSidebar\n\t\t\t\t\tisPinnable={ false }\n\t\t\t\t\theader={ false }\n\t\t\t\t\tidentifier={ FLOATING_NOTES_SIDEBAR }\n\t\t\t\t\tclassName=\"editor-collab-sidebar\"\n\t\t\t\t\theaderClassName=\"editor-collab-sidebar__header\"\n\t\t\t\t\tbackgroundColor={ backgroundColor }\n\t\t\t\t>\n\t\t\t\t\t<Notes\n\t\t\t\t\t\tnotes={ unresolvedNotes }\n\t\t\t\t\t\tsidebarRef={ sidebarRef }\n\t\t\t\t\t\tstyles={ { backgroundColor } }\n\t\t\t\t\t\tisFloating\n\t\t\t\t\t/>\n\t\t\t\t</PluginSidebar>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default function NotesSidebarContainer() {\n\tconst { postId, editorMode, revisionsMode } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getEditorMode, isRevisionsMode } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\teditorMode: getEditorMode(),\n\t\t\trevisionsMode: isRevisionsMode(),\n\t\t};\n\t}, [] );\n\n\tif ( ! postId || typeof postId !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Hide Notes sidebar for Code Editor and in-editor revision mode.\n\tif ( editorMode === 'text' || revisionsMode ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"editor.notes\">\n\t\t\t<NotesSidebar postId={ postId } />\n\t\t</PostTypeSupportCheck>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,WAAW,mBAAmB;AACvC,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,sBAAsB;AACxC,SAAS,SAAS,wBAAwB;AAK1C,OAAO,mBAAmB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,aAAa;AACtB,SAAS,SAAS,mBAAmB;AACrC,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,gCAAgC;AACzD,SAAS,wBAAwB,uBAAuB;AACxD,OAAO,0BAA0B;AACjC,SAAS,cAAc;AA8Hd,SAIP,UAJO,KAIP,YAJO;AA5HT,SAAS,aAAc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7C,WAAO;AAAA,EACR;AAGA,MAAK,eAAe,UAAU,eAAgB;AAC7C,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,wBAAqB,aAAY,gBACjC,8BAAC,gBAAa,QAAkB,GACjC;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,5 @@
1
1
  // packages/editor/src/components/collab-sidebar/note-byline.js
2
- import { Tooltip } from "@wordpress/components";
3
- import { Stack } from "@wordpress/ui";
2
+ import { Stack, Tooltip } from "@wordpress/ui";
4
3
  import { __, _x } from "@wordpress/i18n";
5
4
  import {
6
5
  dateI18n,
@@ -73,14 +72,22 @@ function NoteByline({ avatar, name, date, userId }) {
73
72
  ),
74
73
  /* @__PURE__ */ jsxs(Stack, { direction: "column", children: [
75
74
  /* @__PURE__ */ jsx("span", { className: "editor-collab-sidebar-panel__user-name", children: name ?? currentUserName }),
76
- date && /* @__PURE__ */ jsx(Tooltip, { text: tooltipText, children: /* @__PURE__ */ jsx(
77
- "time",
78
- {
79
- dateTime: commentDateTime,
80
- className: "editor-collab-sidebar-panel__user-time",
81
- children: commentDateText
82
- }
83
- ) })
75
+ date && /* @__PURE__ */ jsxs(Tooltip.Root, { children: [
76
+ /* @__PURE__ */ jsx(
77
+ Tooltip.Trigger,
78
+ {
79
+ render: /* @__PURE__ */ jsx(
80
+ "time",
81
+ {
82
+ dateTime: commentDateTime,
83
+ className: "editor-collab-sidebar-panel__user-time",
84
+ children: commentDateText
85
+ }
86
+ )
87
+ }
88
+ ),
89
+ /* @__PURE__ */ jsx(Tooltip.Popup, { children: tooltipText })
90
+ ] })
84
91
  ] })
85
92
  ] });
86
93
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/note-byline.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Tooltip } from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tdateI18n,\n\tgetSettings as getDateSettings,\n\thumanTimeDiff,\n\tgetDate,\n} from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getAvatarBorderColor } from './utils';\n\nexport function NoteByline( { avatar, name, date, userId } ) {\n\tconst hasAvatar = !! avatar;\n\tconst dateSettings = getDateSettings();\n\tconst {\n\t\tcurrentUserAvatar,\n\t\tcurrentUserName,\n\t\tcurrentUserId,\n\t\tdateFormat = dateSettings.formats.date,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getCurrentUser, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tif ( hasAvatar ) {\n\t\t\t\treturn {\n\t\t\t\t\tdateFormat: siteSettings?.date_format,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\t\tconst defaultAvatar = __experimentalDiscussionSettings?.avatarURL;\n\t\t\tconst userData = getCurrentUser();\n\t\t\treturn {\n\t\t\t\tcurrentUserAvatar:\n\t\t\t\t\tuserData?.avatar_urls?.[ 48 ] ?? defaultAvatar,\n\t\t\t\tcurrentUserName: userData?.name,\n\t\t\t\tcurrentUserId: userData?.id,\n\t\t\t\tdateFormat: siteSettings?.date_format,\n\t\t\t};\n\t\t},\n\t\t[ hasAvatar ]\n\t);\n\n\tconst commentDate = getDate( date );\n\tconst commentDateTime = dateI18n( 'c', commentDate );\n\tconst shouldShowHumanTimeDiff =\n\t\tMath.floor( ( new Date() - commentDate ) / ( 1000 * 60 * 60 * 24 ) ) <\n\t\t30;\n\n\tconst commentDateText = shouldShowHumanTimeDiff\n\t\t? humanTimeDiff( commentDate )\n\t\t: dateI18n( dateFormat, commentDate );\n\n\tconst tooltipText = dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'Note date full date format' ),\n\t\tdate\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ avatar || currentUserAvatar }\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-avatar\"\n\t\t\t\t// translators: alt text for user avatar image\n\t\t\t\talt={ __( 'User avatar' ) }\n\t\t\t\twidth={ 32 }\n\t\t\t\theight={ 32 }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborderColor: getAvatarBorderColor(\n\t\t\t\t\t\tuserId ?? currentUserId\n\t\t\t\t\t),\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<Stack direction=\"column\">\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__user-name\">\n\t\t\t\t\t{ name ?? currentUserName }\n\t\t\t\t</span>\n\t\t\t\t{ date && (\n\t\t\t\t\t<Tooltip text={ tooltipText }>\n\t\t\t\t\t\t<time\n\t\t\t\t\t\t\tdateTime={ commentDateTime }\n\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-time\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ commentDateText }\n\t\t\t\t\t\t</time>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,IAAI,UAAU;AACvB;AAAA,EACC;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAK1C,SAAS,4BAA4B;AA2DnC,mBACC,KAaA,YAdD;AAzDK,SAAS,WAAY,EAAE,QAAQ,MAAM,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Q;AAAA,UACP,aAAa;AAAA,YACZ,UAAU;AAAA,UACX;AAAA,QACD;AAAA;AAAA,IACD;AAAA,IACA,qBAAC,SAAM,WAAU,UAChB;AAAA,0BAAC,UAAK,WAAU,0CACb,kBAAQ,iBACX;AAAA,MACE,QACD,oBAAC,WAAQ,MAAO,aACf;AAAA,QAAC;AAAA;AAAA,UACA,UAAW;AAAA,UACX,WAAU;AAAA,UAER;AAAA;AAAA,MACH,GACD;AAAA,OAEF;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\n// eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.\nimport { Stack, Tooltip } from '@wordpress/ui';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tdateI18n,\n\tgetSettings as getDateSettings,\n\thumanTimeDiff,\n\tgetDate,\n} from '@wordpress/date';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getAvatarBorderColor } from './utils';\n\nexport function NoteByline( { avatar, name, date, userId } ) {\n\tconst hasAvatar = !! avatar;\n\tconst dateSettings = getDateSettings();\n\tconst {\n\t\tcurrentUserAvatar,\n\t\tcurrentUserName,\n\t\tcurrentUserId,\n\t\tdateFormat = dateSettings.formats.date,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser, getCurrentUser, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst siteSettings = canUser( 'read', {\n\t\t\t\tkind: 'root',\n\t\t\t\tname: 'site',\n\t\t\t} )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\tif ( hasAvatar ) {\n\t\t\t\treturn {\n\t\t\t\t\tdateFormat: siteSettings?.date_format,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\t\tconst defaultAvatar = __experimentalDiscussionSettings?.avatarURL;\n\t\t\tconst userData = getCurrentUser();\n\t\t\treturn {\n\t\t\t\tcurrentUserAvatar:\n\t\t\t\t\tuserData?.avatar_urls?.[ 48 ] ?? defaultAvatar,\n\t\t\t\tcurrentUserName: userData?.name,\n\t\t\t\tcurrentUserId: userData?.id,\n\t\t\t\tdateFormat: siteSettings?.date_format,\n\t\t\t};\n\t\t},\n\t\t[ hasAvatar ]\n\t);\n\n\tconst commentDate = getDate( date );\n\tconst commentDateTime = dateI18n( 'c', commentDate );\n\tconst shouldShowHumanTimeDiff =\n\t\tMath.floor( ( new Date() - commentDate ) / ( 1000 * 60 * 60 * 24 ) ) <\n\t\t30;\n\n\tconst commentDateText = shouldShowHumanTimeDiff\n\t\t? humanTimeDiff( commentDate )\n\t\t: dateI18n( dateFormat, commentDate );\n\n\tconst tooltipText = dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'Note date full date format' ),\n\t\tdate\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<img\n\t\t\t\tsrc={ avatar || currentUserAvatar }\n\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-avatar\"\n\t\t\t\t// translators: alt text for user avatar image\n\t\t\t\talt={ __( 'User avatar' ) }\n\t\t\t\twidth={ 32 }\n\t\t\t\theight={ 32 }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborderColor: getAvatarBorderColor(\n\t\t\t\t\t\tuserId ?? currentUserId\n\t\t\t\t\t),\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<Stack direction=\"column\">\n\t\t\t\t<span className=\"editor-collab-sidebar-panel__user-name\">\n\t\t\t\t\t{ name ?? currentUserName }\n\t\t\t\t</span>\n\t\t\t\t{ date && (\n\t\t\t\t\t<Tooltip.Root>\n\t\t\t\t\t\t<Tooltip.Trigger\n\t\t\t\t\t\t\trender={\n\t\t\t\t\t\t\t\t<time\n\t\t\t\t\t\t\t\t\tdateTime={ commentDateTime }\n\t\t\t\t\t\t\t\t\tclassName=\"editor-collab-sidebar-panel__user-time\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ commentDateText }\n\t\t\t\t\t\t\t\t</time>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Tooltip.Popup>{ tooltipText }</Tooltip.Popup>\n\t\t\t\t\t</Tooltip.Root>\n\t\t\t\t) }\n\t\t\t</Stack>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";AAIA,SAAS,OAAO,eAAe;AAC/B,SAAS,IAAI,UAAU;AACvB;AAAA,EACC;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS,iBAAiB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAK1C,SAAS,4BAA4B;AA2DnC,mBACC,KAkBE,YAnBH;AAzDK,SAAS,WAAY,EAAE,QAAQ,MAAM,MAAM,OAAO,GAAI;AAC5D,QAAM,YAAY,CAAC,CAAE;AACrB,QAAM,eAAe,gBAAgB;AACrC,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,aAAa,QAAQ;AAAA,EACnC,IAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM,EAAE,SAAS,gBAAgB,gBAAgB,IAChD,OAAQ,SAAU;AACnB,YAAM,eAAe,QAAS,QAAQ;AAAA,QACrC,MAAM;AAAA,QACN,MAAM;AAAA,MACP,CAAE,IACC,gBAAiB,QAAQ,MAAO,IAChC;AAEH,UAAK,WAAY;AAChB,eAAO;AAAA,UACN,YAAY,cAAc;AAAA,QAC3B;AAAA,MACD;AAEA,YAAM,EAAE,YAAY,IAAI,OAAQ,gBAAiB;AACjD,YAAM,EAAE,iCAAiC,IAAI,YAAY;AACzD,YAAM,gBAAgB,kCAAkC;AACxD,YAAM,WAAW,eAAe;AAChC,aAAO;AAAA,QACN,mBACC,UAAU,cAAe,EAAG,KAAK;AAAA,QAClC,iBAAiB,UAAU;AAAA,QAC3B,eAAe,UAAU;AAAA,QACzB,YAAY,cAAc;AAAA,MAC3B;AAAA,IACD;AAAA,IACA,CAAE,SAAU;AAAA,EACb;AAEA,QAAM,cAAc,QAAS,IAAK;AAClC,QAAM,kBAAkB,SAAU,KAAK,WAAY;AACnD,QAAM,0BACL,KAAK,OAAS,oBAAI,KAAK,IAAI,gBAAkB,MAAO,KAAK,KAAK,GAAK,IACnE;AAED,QAAM,kBAAkB,0BACrB,cAAe,WAAY,IAC3B,SAAU,YAAY,WAAY;AAErC,QAAM,cAAc;AAAA;AAAA,IAEnB,GAAI,mBAAmB,4BAA6B;AAAA,IACpD;AAAA,EACD;AAEA,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,KAAM,UAAU;AAAA,QAChB,WAAU;AAAA,QAEV,KAAM,GAAI,aAAc;AAAA,QACxB,OAAQ;AAAA,QACR,QAAS;AAAA,QACT,OAAQ;AAAA,UACP,aAAa;AAAA,YACZ,UAAU;AAAA,UACX;AAAA,QACD;AAAA;AAAA,IACD;AAAA,IACA,qBAAC,SAAM,WAAU,UAChB;AAAA,0BAAC,UAAK,WAAU,0CACb,kBAAQ,iBACX;AAAA,MACE,QACD,qBAAC,QAAQ,MAAR,EACA;AAAA;AAAA,UAAC,QAAQ;AAAA,UAAR;AAAA,YACA,QACC;AAAA,cAAC;AAAA;AAAA,gBACA,UAAW;AAAA,gBACX,WAAU;AAAA,gBAER;AAAA;AAAA,YACH;AAAA;AAAA,QAEF;AAAA,QACA,oBAAC,QAAQ,OAAR,EAAgB,uBAAa;AAAA,SAC/B;AAAA,OAEF;AAAA,KACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  // packages/editor/src/components/collab-sidebar/notes.js
2
- import { useEffect, useMemo } from "@wordpress/element";
2
+ import { useEffect, useMemo, useRef } from "@wordpress/element";
3
3
  import { __ } from "@wordpress/i18n";
4
4
  import { useSelect, useDispatch } from "@wordpress/data";
5
5
  import { Stack } from "@wordpress/ui";
@@ -9,7 +9,11 @@ import {
9
9
  } from "@wordpress/block-editor";
10
10
  import { unlock } from "../../lock-unlock.mjs";
11
11
  import { NoteThread } from "./note-thread.mjs";
12
- import { focusNoteThread } from "./utils.mjs";
12
+ import {
13
+ focusNoteThread,
14
+ getNoteIdsFromMetadata,
15
+ pickPrimaryNote
16
+ } from "./utils.mjs";
13
17
  import { useFloatingBoard, useNoteActions } from "./hooks.mjs";
14
18
  import { AddNote } from "./add-note.mjs";
15
19
  import { store as editorStore } from "../../store/index.mjs";
@@ -25,7 +29,7 @@ function Notes({ notes, sidebarRef, isFloating = false, styles }) {
25
29
  const { selectBlock, toggleBlockSpotlight } = unlock(
26
30
  useDispatch(blockEditorStore)
27
31
  );
28
- const { blockNoteId, selectedBlockClientId, orderedBlockIds } = useSelect(
32
+ const { noteId, selectedBlockClientId, orderedBlockIds } = useSelect(
29
33
  (select) => {
30
34
  const {
31
35
  getBlockAttributes,
@@ -34,7 +38,7 @@ function Notes({ notes, sidebarRef, isFloating = false, styles }) {
34
38
  } = select(blockEditorStore);
35
39
  const clientId = getSelectedBlockClientId();
36
40
  return {
37
- blockNoteId: clientId ? getBlockAttributes(clientId)?.metadata?.noteId : null,
41
+ noteId: clientId ? getBlockAttributes(clientId)?.metadata?.noteId : null,
38
42
  selectedBlockClientId: clientId,
39
43
  orderedBlockIds: getClientIdsWithDescendants()
40
44
  };
@@ -62,15 +66,12 @@ function Notes({ notes, sidebarRef, isFloating = false, styles }) {
62
66
  };
63
67
  const out = [];
64
68
  orderedBlockIds.forEach((blockId) => {
69
+ const threadsForBlock = notes.filter(
70
+ (t) => t.blockClientId === blockId
71
+ );
72
+ out.push(...threadsForBlock);
65
73
  if (blockId === selectedBlockClientId) {
66
74
  out.push(newNoteThread);
67
- } else {
68
- const threadForBlock = notes.find(
69
- (t) => t.blockClientId === blockId
70
- );
71
- if (threadForBlock) {
72
- out.push(threadForBlock);
73
- }
74
75
  }
75
76
  });
76
77
  return out;
@@ -105,9 +106,21 @@ function Notes({ notes, sidebarRef, isFloating = false, styles }) {
105
106
  relatedBlockElement?.focus();
106
107
  }
107
108
  };
109
+ const targetNoteId = useMemo(() => {
110
+ const blockNoteIds = getNoteIdsFromMetadata({ noteId });
111
+ const blockThreads = notes.filter(
112
+ (t) => blockNoteIds.includes(t.id)
113
+ );
114
+ return pickPrimaryNote(blockThreads)?.id;
115
+ }, [noteId, notes]);
116
+ const prevBlockIdRef = useRef(selectedBlockClientId);
108
117
  useEffect(() => {
109
- selectNote(blockNoteId ?? void 0);
110
- }, [blockNoteId, selectNote]);
118
+ if (prevBlockIdRef.current === selectedBlockClientId) {
119
+ return;
120
+ }
121
+ prevBlockIdRef.current = selectedBlockClientId;
122
+ selectNote(targetNoteId);
123
+ }, [selectedBlockClientId, targetNoteId, selectNote]);
111
124
  useEffect(() => {
112
125
  if (noteFocused && selectedNote) {
113
126
  focusNoteThread(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab-sidebar/notes.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Stack } from '@wordpress/ui';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { NoteThread } from './note-thread';\nimport { focusNoteThread } from './utils';\nimport { useFloatingBoard, useNoteActions } from './hooks';\nimport { AddNote } from './add-note';\nimport { store as editorStore } from '../../store';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\nexport function Notes( { notes, sidebarRef, isFloating = false, styles } ) {\n\tconst {\n\t\tonCreate: onAddReply,\n\t\tonEdit: onEditNote,\n\t\tonDelete,\n\t} = useNoteActions();\n\tconst { selectNote } = unlock( useDispatch( editorStore ) );\n\tconst { selectBlock, toggleBlockSpotlight } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tconst { blockNoteId, selectedBlockClientId, orderedBlockIds } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetClientIdsWithDescendants,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\treturn {\n\t\t\t\tblockNoteId: clientId\n\t\t\t\t\t? getBlockAttributes( clientId )?.metadata?.noteId\n\t\t\t\t\t: null,\n\t\t\t\tselectedBlockClientId: clientId,\n\t\t\t\torderedBlockIds: getClientIdsWithDescendants(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { selectedNote, noteFocused } = useSelect( ( select ) => {\n\t\tconst { getSelectedNote, isNoteFocused } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\treturn {\n\t\t\tselectedNote: getSelectedNote(),\n\t\t\tnoteFocused: isNoteFocused(),\n\t\t};\n\t}, [] );\n\n\tconst relatedBlockElement = useBlockElement( selectedBlockClientId );\n\n\tconst threads = useMemo( () => {\n\t\t// In floating mode with a pending new note, splice a placeholder\n\t\t// entry at the selected block's position so the board can float it\n\t\t// alongside regular threads.\n\t\tif ( ! isFloating || selectedNote !== 'new' ) {\n\t\t\treturn notes;\n\t\t}\n\t\tconst newNoteThread = {\n\t\t\tid: 'new',\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tcontent: { rendered: '' },\n\t\t};\n\t\tconst out = [];\n\t\torderedBlockIds.forEach( ( blockId ) => {\n\t\t\tif ( blockId === selectedBlockClientId ) {\n\t\t\t\tout.push( newNoteThread );\n\t\t\t} else {\n\t\t\t\tconst threadForBlock = notes.find(\n\t\t\t\t\t( t ) => t.blockClientId === blockId\n\t\t\t\t);\n\t\t\t\tif ( threadForBlock ) {\n\t\t\t\t\tout.push( threadForBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t\treturn out;\n\t}, [\n\t\tnotes,\n\t\tisFloating,\n\t\tselectedNote,\n\t\tselectedBlockClientId,\n\t\torderedBlockIds,\n\t] );\n\n\tconst handleDelete = async ( note ) => {\n\t\tconst currentIndex = threads.findIndex( ( t ) => t.id === note.id );\n\t\tconst nextThread = threads[ currentIndex + 1 ];\n\t\tconst prevThread = threads[ currentIndex - 1 ];\n\n\t\tawait onDelete( note );\n\n\t\tif ( note.parent !== 0 ) {\n\t\t\t// Move focus to the parent thread when a reply was deleted.\n\t\t\tselectNote( note.parent );\n\t\t\tfocusNoteThread( note.parent, sidebarRef.current );\n\t\t\treturn;\n\t\t}\n\n\t\tconst adjacentThread = nextThread ?? prevThread;\n\t\tif ( adjacentThread ) {\n\t\t\tselectNote( adjacentThread.id );\n\t\t\tfocusNoteThread( adjacentThread.id, sidebarRef.current );\n\t\t\tif ( adjacentThread.blockClientId ) {\n\t\t\t\ttoggleBlockSpotlight( adjacentThread.blockClientId, true );\n\t\t\t\t// Pass `null` as the second parameter to prevent focusing the block.\n\t\t\t\tselectBlock( adjacentThread.blockClientId, null );\n\t\t\t}\n\t\t} else {\n\t\t\tselectNote( undefined );\n\t\t\ttoggleBlockSpotlight( note.blockClientId, false );\n\t\t\t// Move focus to the related block.\n\t\t\trelatedBlockElement?.focus();\n\t\t}\n\t};\n\n\t// Auto-select the related note thread when a block is selected.\n\tuseEffect( () => {\n\t\tselectNote( blockNoteId ?? undefined );\n\t}, [ blockNoteId, selectNote ] );\n\n\t// Focus the selected note when requested.\n\tuseEffect( () => {\n\t\tif ( noteFocused && selectedNote ) {\n\t\t\tfocusNoteThread(\n\t\t\t\tselectedNote,\n\t\t\t\tsidebarRef.current,\n\t\t\t\tselectedNote === 'new' ? 'textarea' : undefined\n\t\t\t);\n\t\t\t// Clear focus flag to avoid re-triggering.\n\t\t\tselectNote( selectedNote );\n\t\t}\n\t}, [ noteFocused, selectedNote, selectNote, sidebarRef ] );\n\n\tconst { notePositions, registerThread, unregisterThread } =\n\t\tuseFloatingBoard( {\n\t\t\tthreads,\n\t\t\tselectedNoteId: selectedNote,\n\t\t\tisFloating,\n\t\t\tsidebarRef,\n\t\t} );\n\n\tconst hasThreads = Array.isArray( threads ) && threads.length > 0;\n\n\tconst navigate = ( event, thread, isSelected ) => {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentIndex = threads.findIndex( ( t ) => t.id === thread.id );\n\t\tconst isSelfTarget = event.currentTarget === event.target;\n\n\t\tif (\n\t\t\t( event.key === 'Enter' || event.key === 'ArrowRight' ) &&\n\t\t\tisSelfTarget &&\n\t\t\t! isSelected\n\t\t) {\n\t\t\t// Expand thread.\n\t\t\tselectNote( thread.id );\n\t\t\tif ( !! thread.blockClientId ) {\n\t\t\t\t// Pass `null` as the second parameter to prevent focusing the block.\n\t\t\t\tselectBlock( thread.blockClientId, null );\n\t\t\t\ttoggleBlockSpotlight( thread.blockClientId, true );\n\t\t\t}\n\t\t} else if (\n\t\t\t( ( event.key === 'Enter' || event.key === 'ArrowLeft' ) &&\n\t\t\t\tisSelfTarget &&\n\t\t\t\tisSelected ) ||\n\t\t\tevent.key === 'Escape'\n\t\t) {\n\t\t\t// Collapse thread.\n\t\t\tselectNote( undefined );\n\t\t\tif ( thread.blockClientId ) {\n\t\t\t\ttoggleBlockSpotlight( thread.blockClientId, false );\n\t\t\t}\n\t\t\tfocusNoteThread( thread.id, sidebarRef.current );\n\t\t} else if (\n\t\t\tevent.key === 'ArrowDown' &&\n\t\t\tcurrentIndex < threads.length - 1 &&\n\t\t\tisSelfTarget\n\t\t) {\n\t\t\tfocusNoteThread(\n\t\t\t\tthreads[ currentIndex + 1 ].id,\n\t\t\t\tsidebarRef.current\n\t\t\t);\n\t\t} else if (\n\t\t\tevent.key === 'ArrowUp' &&\n\t\t\tcurrentIndex > 0 &&\n\t\t\tisSelfTarget\n\t\t) {\n\t\t\tfocusNoteThread(\n\t\t\t\tthreads[ currentIndex - 1 ].id,\n\t\t\t\tsidebarRef.current\n\t\t\t);\n\t\t} else if ( event.key === 'Home' && isSelfTarget ) {\n\t\t\tfocusNoteThread( threads[ 0 ].id, sidebarRef.current );\n\t\t} else if ( event.key === 'End' && isSelfTarget ) {\n\t\t\tfocusNoteThread(\n\t\t\t\tthreads[ threads.length - 1 ].id,\n\t\t\t\tsidebarRef.current\n\t\t\t);\n\t\t}\n\t};\n\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"editor-collab-sidebar-panel\"\n\t\t\tstyle={ styles }\n\t\t\trole=\"tree\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t\tjustify=\"flex-start\"\n\t\t\tref={ ( node ) => {\n\t\t\t\t// Sometimes previous sidebar unmounts after the new one mounts.\n\t\t\t\t// This ensures we always have the latest reference.\n\t\t\t\tif ( node ) {\n\t\t\t\t\tsidebarRef.current = node;\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={\n\t\t\t\tisFloating ? __( 'Unresolved notes' ) : __( 'All notes' )\n\t\t\t}\n\t\t>\n\t\t\t{ ! hasThreads && ! isFloating ? (\n\t\t\t\t<AddNote onSubmit={ onAddReply } sidebarRef={ sidebarRef } />\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{ ! isFloating && selectedNote === 'new' && (\n\t\t\t\t\t\t<AddNote\n\t\t\t\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\t\t\t\tsidebarRef={ sidebarRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ threads.map( ( thread ) => (\n\t\t\t\t\t\t<NoteThread\n\t\t\t\t\t\t\tkey={ thread.id }\n\t\t\t\t\t\t\tnote={ thread }\n\t\t\t\t\t\t\tonAddReply={ onAddReply }\n\t\t\t\t\t\t\tonDeleteNote={ handleDelete }\n\t\t\t\t\t\t\tonEditNote={ onEditNote }\n\t\t\t\t\t\t\tisSelected={ selectedNote === thread.id }\n\t\t\t\t\t\t\tsidebarRef={ sidebarRef }\n\t\t\t\t\t\t\tfloating={\n\t\t\t\t\t\t\t\tisFloating\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\ty: notePositions[ thread.id ],\n\t\t\t\t\t\t\t\t\t\t\tregisterThread,\n\t\t\t\t\t\t\t\t\t\t\tunregisterThread,\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonKeyDown={ ( event ) =>\n\t\t\t\t\t\t\t\tnavigate(\n\t\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\t\tthread,\n\t\t\t\t\t\t\t\t\tselectedNote === thread.id\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,WAAW,eAAe;AACnC,SAAS,UAAU;AACnB,SAAS,WAAW,mBAAmB;AACvC,SAAS,aAAa;AACtB;AAAA,EACC,SAAS;AAAA,EACT,eAAe;AAAA,OACT;AAKP,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,eAAe;AACxB,SAAS,SAAS,mBAAmB;AA0NjC,SAEA,UAFA,KAEA,YAFA;AAxNJ,IAAM,EAAE,gBAAgB,IAAI,OAAQ,sBAAuB;AAEpD,SAAS,MAAO,EAAE,OAAO,YAAY,aAAa,OAAO,OAAO,GAAI;AAC1E,QAAM;AAAA,IACL,UAAU;AAAA,IACV,QAAQ;AAAA,IACR;AAAA,EACD,IAAI,eAAe;AACnB,QAAM,EAAE,WAAW,I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AAGjB,YAAK,MAAO;AACX,qBAAW,UAAU;AAAA,QACtB;AAAA,MACD;AAAA,MACA,cACC,aAAa,GAAI,kBAAmB,IAAI,GAAI,WAAY;AAAA,MAGvD,WAAE,cAAc,CAAE,aACnB,oBAAC,WAAQ,UAAW,YAAa,YAA0B,IAE3D,iCACG;AAAA,SAAE,cAAc,iBAAiB,SAClC;AAAA,UAAC;AAAA;AAAA,YACA,UAAW;AAAA,YACX;AAAA;AAAA,QACD;AAAA,QAEC,QAAQ,IAAK,CAAE,WAChB;AAAA,UAAC;AAAA;AAAA,YAEA,MAAO;AAAA,YACP;AAAA,YACA,cAAe;AAAA,YACf;AAAA,YACA,YAAa,iBAAiB,OAAO;AAAA,YACrC;AAAA,YACA,UACC,aACG;AAAA,cACA,GAAG,cAAe,OAAO,EAAG;AAAA,cAC5B;AAAA,cACA;AAAA,YACA,IACA;AAAA,YAEJ,WAAY,CAAE,UACb;AAAA,cACC;AAAA,cACA;AAAA,cACA,iBAAiB,OAAO;AAAA,YACzB;AAAA;AAAA,UArBK,OAAO;AAAA,QAuBd,CACC;AAAA,SACH;AAAA;AAAA,EAEF;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Stack } from '@wordpress/ui';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { NoteThread } from './note-thread';\nimport {\n\tfocusNoteThread,\n\tgetNoteIdsFromMetadata,\n\tpickPrimaryNote,\n} from './utils';\nimport { useFloatingBoard, useNoteActions } from './hooks';\nimport { AddNote } from './add-note';\nimport { store as editorStore } from '../../store';\n\nconst { useBlockElement } = unlock( blockEditorPrivateApis );\n\nexport function Notes( { notes, sidebarRef, isFloating = false, styles } ) {\n\tconst {\n\t\tonCreate: onAddReply,\n\t\tonEdit: onEditNote,\n\t\tonDelete,\n\t} = useNoteActions();\n\tconst { selectNote } = unlock( useDispatch( editorStore ) );\n\tconst { selectBlock, toggleBlockSpotlight } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tconst { noteId, selectedBlockClientId, orderedBlockIds } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetClientIdsWithDescendants,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\treturn {\n\t\t\t\tnoteId: clientId\n\t\t\t\t\t? getBlockAttributes( clientId )?.metadata?.noteId\n\t\t\t\t\t: null,\n\t\t\t\tselectedBlockClientId: clientId,\n\t\t\t\torderedBlockIds: getClientIdsWithDescendants(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { selectedNote, noteFocused } = useSelect( ( select ) => {\n\t\tconst { getSelectedNote, isNoteFocused } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\treturn {\n\t\t\tselectedNote: getSelectedNote(),\n\t\t\tnoteFocused: isNoteFocused(),\n\t\t};\n\t}, [] );\n\n\tconst relatedBlockElement = useBlockElement( selectedBlockClientId );\n\n\tconst threads = useMemo( () => {\n\t\t// In floating mode with a pending new note, splice a placeholder\n\t\t// entry at the selected block's position so the board can float it\n\t\t// alongside regular threads.\n\t\tif ( ! isFloating || selectedNote !== 'new' ) {\n\t\t\treturn notes;\n\t\t}\n\t\tconst newNoteThread = {\n\t\t\tid: 'new',\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tcontent: { rendered: '' },\n\t\t};\n\t\tconst out = [];\n\t\torderedBlockIds.forEach( ( blockId ) => {\n\t\t\t// Blocks can carry multiple notes \u2014 surface them all.\n\t\t\tconst threadsForBlock = notes.filter(\n\t\t\t\t( t ) => t.blockClientId === blockId\n\t\t\t);\n\t\t\tout.push( ...threadsForBlock );\n\t\t\tif ( blockId === selectedBlockClientId ) {\n\t\t\t\t// Place the new note placeholder after the block's existing\n\t\t\t\t// threads so the form appears alongside them.\n\t\t\t\tout.push( newNoteThread );\n\t\t\t}\n\t\t} );\n\t\treturn out;\n\t}, [\n\t\tnotes,\n\t\tisFloating,\n\t\tselectedNote,\n\t\tselectedBlockClientId,\n\t\torderedBlockIds,\n\t] );\n\n\tconst handleDelete = async ( note ) => {\n\t\tconst currentIndex = threads.findIndex( ( t ) => t.id === note.id );\n\t\tconst nextThread = threads[ currentIndex + 1 ];\n\t\tconst prevThread = threads[ currentIndex - 1 ];\n\n\t\tawait onDelete( note );\n\n\t\tif ( note.parent !== 0 ) {\n\t\t\t// Move focus to the parent thread when a reply was deleted.\n\t\t\tselectNote( note.parent );\n\t\t\tfocusNoteThread( note.parent, sidebarRef.current );\n\t\t\treturn;\n\t\t}\n\n\t\tconst adjacentThread = nextThread ?? prevThread;\n\t\tif ( adjacentThread ) {\n\t\t\tselectNote( adjacentThread.id );\n\t\t\tfocusNoteThread( adjacentThread.id, sidebarRef.current );\n\t\t\tif ( adjacentThread.blockClientId ) {\n\t\t\t\ttoggleBlockSpotlight( adjacentThread.blockClientId, true );\n\t\t\t\t// Pass `null` as the second parameter to prevent focusing the block.\n\t\t\t\tselectBlock( adjacentThread.blockClientId, null );\n\t\t\t}\n\t\t} else {\n\t\t\tselectNote( undefined );\n\t\t\ttoggleBlockSpotlight( note.blockClientId, false );\n\t\t\t// Move focus to the related block.\n\t\t\trelatedBlockElement?.focus();\n\t\t}\n\t};\n\n\t// Pick the most relevant thread for the selected block. Derived outside\n\t// the effect so the effect body stays minimal.\n\tconst targetNoteId = useMemo( () => {\n\t\tconst blockNoteIds = getNoteIdsFromMetadata( { noteId } );\n\t\tconst blockThreads = notes.filter( ( t ) =>\n\t\t\tblockNoteIds.includes( t.id )\n\t\t);\n\t\treturn pickPrimaryNote( blockThreads )?.id;\n\t}, [ noteId, notes ] );\n\n\t// Sync the selected note to the new block's primary thread when the\n\t// block context changes. The ref tracks the previous block id so the\n\t// effect only fires on block transitions, leaving in-block note changes\n\t// (Escape, Cancel, \"new\" form) alone.\n\tconst prevBlockIdRef = useRef( selectedBlockClientId );\n\tuseEffect( () => {\n\t\tif ( prevBlockIdRef.current === selectedBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\t\tprevBlockIdRef.current = selectedBlockClientId;\n\t\tselectNote( targetNoteId );\n\t}, [ selectedBlockClientId, targetNoteId, selectNote ] );\n\n\t// Focus the selected note when requested.\n\tuseEffect( () => {\n\t\tif ( noteFocused && selectedNote ) {\n\t\t\tfocusNoteThread(\n\t\t\t\tselectedNote,\n\t\t\t\tsidebarRef.current,\n\t\t\t\tselectedNote === 'new' ? 'textarea' : undefined\n\t\t\t);\n\t\t\t// Clear focus flag to avoid re-triggering.\n\t\t\tselectNote( selectedNote );\n\t\t}\n\t}, [ noteFocused, selectedNote, selectNote, sidebarRef ] );\n\n\tconst { notePositions, registerThread, unregisterThread } =\n\t\tuseFloatingBoard( {\n\t\t\tthreads,\n\t\t\tselectedNoteId: selectedNote,\n\t\t\tisFloating,\n\t\t\tsidebarRef,\n\t\t} );\n\n\tconst hasThreads = Array.isArray( threads ) && threads.length > 0;\n\n\tconst navigate = ( event, thread, isSelected ) => {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentIndex = threads.findIndex( ( t ) => t.id === thread.id );\n\t\tconst isSelfTarget = event.currentTarget === event.target;\n\n\t\tif (\n\t\t\t( event.key === 'Enter' || event.key === 'ArrowRight' ) &&\n\t\t\tisSelfTarget &&\n\t\t\t! isSelected\n\t\t) {\n\t\t\t// Expand thread.\n\t\t\tselectNote( thread.id );\n\t\t\tif ( !! thread.blockClientId ) {\n\t\t\t\t// Pass `null` as the second parameter to prevent focusing the block.\n\t\t\t\tselectBlock( thread.blockClientId, null );\n\t\t\t\ttoggleBlockSpotlight( thread.blockClientId, true );\n\t\t\t}\n\t\t} else if (\n\t\t\t( ( event.key === 'Enter' || event.key === 'ArrowLeft' ) &&\n\t\t\t\tisSelfTarget &&\n\t\t\t\tisSelected ) ||\n\t\t\tevent.key === 'Escape'\n\t\t) {\n\t\t\t// Collapse thread.\n\t\t\tselectNote( undefined );\n\t\t\tif ( thread.blockClientId ) {\n\t\t\t\ttoggleBlockSpotlight( thread.blockClientId, false );\n\t\t\t}\n\t\t\tfocusNoteThread( thread.id, sidebarRef.current );\n\t\t} else if (\n\t\t\tevent.key === 'ArrowDown' &&\n\t\t\tcurrentIndex < threads.length - 1 &&\n\t\t\tisSelfTarget\n\t\t) {\n\t\t\tfocusNoteThread(\n\t\t\t\tthreads[ currentIndex + 1 ].id,\n\t\t\t\tsidebarRef.current\n\t\t\t);\n\t\t} else if (\n\t\t\tevent.key === 'ArrowUp' &&\n\t\t\tcurrentIndex > 0 &&\n\t\t\tisSelfTarget\n\t\t) {\n\t\t\tfocusNoteThread(\n\t\t\t\tthreads[ currentIndex - 1 ].id,\n\t\t\t\tsidebarRef.current\n\t\t\t);\n\t\t} else if ( event.key === 'Home' && isSelfTarget ) {\n\t\t\tfocusNoteThread( threads[ 0 ].id, sidebarRef.current );\n\t\t} else if ( event.key === 'End' && isSelfTarget ) {\n\t\t\tfocusNoteThread(\n\t\t\t\tthreads[ threads.length - 1 ].id,\n\t\t\t\tsidebarRef.current\n\t\t\t);\n\t\t}\n\t};\n\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"editor-collab-sidebar-panel\"\n\t\t\tstyle={ styles }\n\t\t\trole=\"tree\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t\tjustify=\"flex-start\"\n\t\t\tref={ ( node ) => {\n\t\t\t\t// Sometimes previous sidebar unmounts after the new one mounts.\n\t\t\t\t// This ensures we always have the latest reference.\n\t\t\t\tif ( node ) {\n\t\t\t\t\tsidebarRef.current = node;\n\t\t\t\t}\n\t\t\t} }\n\t\t\taria-label={\n\t\t\t\tisFloating ? __( 'Unresolved notes' ) : __( 'All notes' )\n\t\t\t}\n\t\t>\n\t\t\t{ ! hasThreads && ! isFloating ? (\n\t\t\t\t<AddNote onSubmit={ onAddReply } sidebarRef={ sidebarRef } />\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t{ ! isFloating && selectedNote === 'new' && (\n\t\t\t\t\t\t<AddNote\n\t\t\t\t\t\t\tonSubmit={ onAddReply }\n\t\t\t\t\t\t\tsidebarRef={ sidebarRef }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ threads.map( ( thread ) => (\n\t\t\t\t\t\t<NoteThread\n\t\t\t\t\t\t\tkey={ thread.id }\n\t\t\t\t\t\t\tnote={ thread }\n\t\t\t\t\t\t\tonAddReply={ onAddReply }\n\t\t\t\t\t\t\tonDeleteNote={ handleDelete }\n\t\t\t\t\t\t\tonEditNote={ onEditNote }\n\t\t\t\t\t\t\tisSelected={ selectedNote === thread.id }\n\t\t\t\t\t\t\tsidebarRef={ sidebarRef }\n\t\t\t\t\t\t\tfloating={\n\t\t\t\t\t\t\t\tisFloating\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\ty: notePositions[ thread.id ],\n\t\t\t\t\t\t\t\t\t\t\tregisterThread,\n\t\t\t\t\t\t\t\t\t\t\tunregisterThread,\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonKeyDown={ ( event ) =>\n\t\t\t\t\t\t\t\tnavigate(\n\t\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\t\tthread,\n\t\t\t\t\t\t\t\t\tselectedNote === thread.id\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,WAAW,SA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