@wordpress/editor 14.41.1-next.v.202603102151.0 → 14.42.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 (301) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs +12 -4
  3. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +2 -2
  4. package/build/components/collaborators-overlay/compute-selection.cjs +181 -0
  5. package/build/components/collaborators-overlay/compute-selection.cjs.map +7 -0
  6. package/build/components/collaborators-overlay/cursor-dom-utils.cjs +243 -0
  7. package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +7 -0
  8. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +6 -0
  9. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/overlay.cjs +61 -37
  11. package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
  12. package/build/components/collaborators-overlay/timing-utils.cjs +46 -0
  13. package/build/components/collaborators-overlay/timing-utils.cjs.map +7 -0
  14. package/build/components/collaborators-overlay/use-block-highlighting.cjs +5 -6
  15. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +2 -2
  16. package/build/components/collaborators-overlay/use-render-cursors.cjs +50 -140
  17. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  18. package/build/components/collaborators-presence/index.cjs +38 -12
  19. package/build/components/collaborators-presence/index.cjs.map +2 -2
  20. package/build/components/collaborators-presence/list.cjs +27 -24
  21. package/build/components/collaborators-presence/list.cjs.map +2 -2
  22. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +79 -107
  23. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +3 -3
  24. package/build/components/editor-interface/index.cjs +9 -6
  25. package/build/components/editor-interface/index.cjs.map +2 -2
  26. package/build/components/inserter-sidebar/index.cjs +2 -1
  27. package/build/components/inserter-sidebar/index.cjs.map +2 -2
  28. package/build/components/page-attributes/parent.cjs +1 -1
  29. package/build/components/page-attributes/parent.cjs.map +2 -2
  30. package/build/components/post-locked-modal/index.cjs +16 -3
  31. package/build/components/post-locked-modal/index.cjs.map +2 -2
  32. package/build/components/post-revisions-preview/block-diff.cjs +39 -11
  33. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  34. package/build/components/post-revisions-preview/diff-markers.cjs +2 -2
  35. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  36. package/build/components/post-revisions-preview/revisions-canvas.cjs +12 -75
  37. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +3 -3
  38. package/build/components/post-revisions-preview/revisions-slider.cjs +5 -1
  39. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  40. package/build/components/post-template/block-theme.cjs +7 -4
  41. package/build/components/post-template/block-theme.cjs.map +2 -2
  42. package/build/components/post-template/hooks.cjs +39 -2
  43. package/build/components/post-template/hooks.cjs.map +2 -2
  44. package/build/components/post-template/panel.cjs +5 -42
  45. package/build/components/post-template/panel.cjs.map +3 -3
  46. package/build/components/preferences-modal/index.cjs +24 -0
  47. package/build/components/preferences-modal/index.cjs.map +2 -2
  48. package/build/components/provider/disable-non-page-content-blocks.cjs +31 -28
  49. package/build/components/provider/disable-non-page-content-blocks.cjs.map +3 -3
  50. package/build/components/provider/index.cjs +17 -5
  51. package/build/components/provider/index.cjs.map +2 -2
  52. package/build/components/provider/use-block-editor-settings.cjs +19 -5
  53. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  54. package/build/components/provider/{use-post-content-blocks.cjs → use-post-content-block-types.cjs} +8 -19
  55. package/build/components/provider/use-post-content-block-types.cjs.map +7 -0
  56. package/build/components/provider/use-revision-blocks.cjs +106 -0
  57. package/build/components/provider/use-revision-blocks.cjs.map +7 -0
  58. package/build/components/revision-block-diff/index.cjs +84 -0
  59. package/build/components/revision-block-diff/index.cjs.map +7 -0
  60. package/build/components/sidebar/dataform-post-summary.cjs +36 -6
  61. package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
  62. package/build/components/sidebar/header.cjs +1 -1
  63. package/build/components/sidebar/header.cjs.map +2 -2
  64. package/build/components/sidebar/index.cjs +5 -1
  65. package/build/components/sidebar/index.cjs.map +3 -3
  66. package/build/components/{sync-connection-modal → sync-connection-error-modal}/index.cjs +90 -78
  67. package/build/components/sync-connection-error-modal/index.cjs.map +7 -0
  68. package/build/components/{sync-connection-modal → sync-connection-error-modal}/use-retry-countdown.cjs +14 -27
  69. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +7 -0
  70. package/build/components/template-content-panel/index.cjs +35 -31
  71. package/build/components/template-content-panel/index.cjs.map +3 -3
  72. package/build/components/visual-editor/index.cjs +2 -2
  73. package/build/components/visual-editor/index.cjs.map +2 -2
  74. package/build/store/actions.cjs +1 -3
  75. package/build/store/actions.cjs.map +2 -2
  76. package/build/store/private-actions.cjs +11 -2
  77. package/build/store/private-actions.cjs.map +2 -2
  78. package/build/store/private-selectors.cjs +52 -13
  79. package/build/store/private-selectors.cjs.map +2 -2
  80. package/build/store/reducer.cjs +12 -0
  81. package/build/store/reducer.cjs.map +2 -2
  82. package/build/utils/media-finalize/index.cjs +43 -0
  83. package/build/utils/media-finalize/index.cjs.map +7 -0
  84. package/build/utils/sync-error-messages.cjs +29 -16
  85. package/build/utils/sync-error-messages.cjs.map +3 -3
  86. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs +12 -4
  87. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +2 -2
  88. package/build-module/components/collaborators-overlay/compute-selection.mjs +162 -0
  89. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +7 -0
  90. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +213 -0
  91. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +7 -0
  92. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +6 -0
  93. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
  94. package/build-module/components/collaborators-overlay/overlay.mjs +61 -37
  95. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  96. package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
  97. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
  98. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +5 -6
  99. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  100. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +50 -140
  101. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  102. package/build-module/components/collaborators-presence/index.mjs +39 -13
  103. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  104. package/build-module/components/collaborators-presence/list.mjs +27 -24
  105. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  106. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +80 -108
  107. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
  108. package/build-module/components/editor-interface/index.mjs +10 -7
  109. package/build-module/components/editor-interface/index.mjs.map +2 -2
  110. package/build-module/components/inserter-sidebar/index.mjs +2 -1
  111. package/build-module/components/inserter-sidebar/index.mjs.map +2 -2
  112. package/build-module/components/page-attributes/parent.mjs +1 -1
  113. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  114. package/build-module/components/post-locked-modal/index.mjs +16 -3
  115. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  116. package/build-module/components/post-revisions-preview/block-diff.mjs +39 -11
  117. package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
  118. package/build-module/components/post-revisions-preview/diff-markers.mjs +2 -2
  119. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  120. package/build-module/components/post-revisions-preview/revisions-canvas.mjs +14 -80
  121. package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
  122. package/build-module/components/post-revisions-preview/revisions-slider.mjs +5 -1
  123. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  124. package/build-module/components/post-template/block-theme.mjs +7 -4
  125. package/build-module/components/post-template/block-theme.mjs.map +2 -2
  126. package/build-module/components/post-template/hooks.mjs +37 -1
  127. package/build-module/components/post-template/hooks.mjs.map +2 -2
  128. package/build-module/components/post-template/panel.mjs +5 -42
  129. package/build-module/components/post-template/panel.mjs.map +2 -2
  130. package/build-module/components/preferences-modal/index.mjs +24 -0
  131. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  132. package/build-module/components/provider/disable-non-page-content-blocks.mjs +31 -28
  133. package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
  134. package/build-module/components/provider/index.mjs +17 -5
  135. package/build-module/components/provider/index.mjs.map +2 -2
  136. package/build-module/components/provider/use-block-editor-settings.mjs +19 -5
  137. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  138. package/build-module/components/provider/use-post-content-block-types.mjs +23 -0
  139. package/build-module/components/provider/use-post-content-block-types.mjs.map +7 -0
  140. package/build-module/components/provider/use-revision-blocks.mjs +81 -0
  141. package/build-module/components/provider/use-revision-blocks.mjs.map +7 -0
  142. package/build-module/components/revision-block-diff/index.mjs +53 -0
  143. package/build-module/components/revision-block-diff/index.mjs.map +7 -0
  144. package/build-module/components/sidebar/dataform-post-summary.mjs +36 -6
  145. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  146. package/build-module/components/sidebar/header.mjs +1 -1
  147. package/build-module/components/sidebar/header.mjs.map +2 -2
  148. package/build-module/components/sidebar/index.mjs +5 -1
  149. package/build-module/components/sidebar/index.mjs.map +2 -2
  150. package/build-module/components/sync-connection-error-modal/index.mjs +177 -0
  151. package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
  152. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +36 -0
  153. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
  154. package/build-module/components/template-content-panel/index.mjs +25 -31
  155. package/build-module/components/template-content-panel/index.mjs.map +2 -2
  156. package/build-module/components/visual-editor/index.mjs +2 -2
  157. package/build-module/components/visual-editor/index.mjs.map +2 -2
  158. package/build-module/store/actions.mjs +1 -3
  159. package/build-module/store/actions.mjs.map +2 -2
  160. package/build-module/store/private-actions.mjs +10 -2
  161. package/build-module/store/private-actions.mjs.map +2 -2
  162. package/build-module/store/private-selectors.mjs +50 -12
  163. package/build-module/store/private-selectors.mjs.map +2 -2
  164. package/build-module/store/reducer.mjs +11 -0
  165. package/build-module/store/reducer.mjs.map +2 -2
  166. package/build-module/utils/media-finalize/index.mjs +12 -0
  167. package/build-module/utils/media-finalize/index.mjs.map +7 -0
  168. package/build-module/utils/sync-error-messages.mjs +24 -16
  169. package/build-module/utils/sync-error-messages.mjs.map +3 -3
  170. package/build-style/style-rtl.css +95 -16
  171. package/build-style/style.css +95 -16
  172. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts +1 -1
  173. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts.map +1 -1
  174. package/build-types/components/collaborators-overlay/compute-selection.d.ts +24 -0
  175. package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -0
  176. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts +72 -0
  177. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts.map +1 -0
  178. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
  179. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
  180. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  181. package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
  182. package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
  183. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  184. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts +4 -0
  185. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  186. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  187. package/build-types/components/collaborators-presence/list.d.ts +2 -1
  188. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  189. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
  190. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  191. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  192. package/build-types/components/post-locked-modal/index.d.ts +2 -2
  193. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  194. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  195. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +2 -5
  196. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
  197. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  198. package/build-types/components/post-template/block-theme.d.ts +1 -3
  199. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  200. package/build-types/components/post-template/hooks.d.ts +1 -0
  201. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  202. package/build-types/components/post-template/panel.d.ts.map +1 -1
  203. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  204. package/build-types/components/provider/index.d.ts.map +1 -1
  205. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  206. package/build-types/components/provider/use-post-content-block-types.d.ts +9 -0
  207. package/build-types/components/provider/use-post-content-block-types.d.ts.map +1 -0
  208. package/build-types/components/provider/use-revision-blocks.d.ts +10 -0
  209. package/build-types/components/provider/use-revision-blocks.d.ts.map +1 -0
  210. package/build-types/components/revision-block-diff/index.d.ts +6 -0
  211. package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
  212. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  213. package/build-types/components/sidebar/index.d.ts.map +1 -1
  214. package/build-types/components/sync-connection-error-modal/index.d.ts +22 -0
  215. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
  216. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
  217. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
  218. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  219. package/build-types/store/actions.d.ts.map +1 -1
  220. package/build-types/store/private-actions.d.ts +7 -0
  221. package/build-types/store/private-actions.d.ts.map +1 -1
  222. package/build-types/store/private-selectors.d.ts +7 -0
  223. package/build-types/store/private-selectors.d.ts.map +1 -1
  224. package/build-types/store/reducer.d.ts +14 -3
  225. package/build-types/store/reducer.d.ts.map +1 -1
  226. package/build-types/utils/media-finalize/index.d.ts +2 -0
  227. package/build-types/utils/media-finalize/index.d.ts.map +1 -0
  228. package/build-types/utils/sync-error-messages.d.ts +17 -3
  229. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  230. package/package.json +44 -44
  231. package/src/components/collaborators-overlay/avatar-iframe-styles.ts +12 -4
  232. package/src/components/collaborators-overlay/compute-selection.ts +307 -0
  233. package/src/components/collaborators-overlay/cursor-dom-utils.ts +382 -0
  234. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +6 -0
  235. package/src/components/collaborators-overlay/overlay.tsx +59 -27
  236. package/src/components/collaborators-overlay/timing-utils.ts +30 -0
  237. package/src/components/collaborators-overlay/use-block-highlighting.ts +11 -10
  238. package/src/components/collaborators-overlay/use-render-cursors.ts +70 -242
  239. package/src/components/collaborators-presence/avatar/styles.scss +20 -4
  240. package/src/components/collaborators-presence/index.tsx +30 -5
  241. package/src/components/collaborators-presence/list.tsx +38 -24
  242. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +188 -246
  243. package/src/components/collaborators-presence/use-collaborator-notifications.ts +109 -166
  244. package/src/components/document-bar/style.scss +1 -1
  245. package/src/components/editor-interface/index.js +8 -6
  246. package/src/components/inserter-sidebar/index.js +4 -1
  247. package/src/components/page-attributes/parent.js +1 -1
  248. package/src/components/post-locked-modal/index.js +21 -3
  249. package/src/components/post-revisions-preview/block-diff.js +59 -20
  250. package/src/components/post-revisions-preview/diff-markers.js +2 -2
  251. package/src/components/post-revisions-preview/revisions-canvas.js +20 -98
  252. package/src/components/post-revisions-preview/revisions-slider.js +6 -1
  253. package/src/components/post-revisions-preview/test/block-diff.js +69 -31
  254. package/src/components/post-template/block-theme.js +4 -1
  255. package/src/components/post-template/hooks.js +42 -0
  256. package/src/components/post-template/panel.js +5 -59
  257. package/src/components/preferences-modal/index.js +18 -0
  258. package/src/components/provider/disable-non-page-content-blocks.js +42 -40
  259. package/src/components/provider/index.js +20 -2
  260. package/src/components/provider/use-block-editor-settings.js +21 -8
  261. package/src/components/provider/use-post-content-block-types.js +30 -0
  262. package/src/components/provider/use-revision-blocks.js +105 -0
  263. package/src/components/revision-block-diff/index.js +74 -0
  264. package/src/components/revision-block-diff/style.scss +13 -0
  265. package/src/components/sidebar/dataform-post-summary.js +61 -16
  266. package/src/components/sidebar/header.js +1 -1
  267. package/src/components/sidebar/index.js +2 -0
  268. package/src/components/sync-connection-error-modal/index.tsx +265 -0
  269. package/src/components/sync-connection-error-modal/style.scss +14 -0
  270. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +57 -0
  271. package/src/components/template-content-panel/index.js +30 -38
  272. package/src/components/visual-editor/index.js +2 -2
  273. package/src/store/actions.js +1 -4
  274. package/src/store/private-actions.js +21 -2
  275. package/src/store/private-selectors.js +75 -10
  276. package/src/store/reducer.js +19 -0
  277. package/src/style.scss +2 -1
  278. package/src/utils/media-finalize/index.js +11 -0
  279. package/src/utils/media-finalize/test/index.js +34 -0
  280. package/src/utils/sync-error-messages.ts +72 -0
  281. package/src/utils/test/sync-error-messages.js +9 -32
  282. package/build/components/provider/use-post-content-blocks.cjs.map +0 -7
  283. package/build/components/sync-connection-modal/index.cjs.map +0 -7
  284. package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +0 -7
  285. package/build-module/components/provider/use-post-content-blocks.mjs +0 -34
  286. package/build-module/components/provider/use-post-content-blocks.mjs.map +0 -7
  287. package/build-module/components/sync-connection-modal/index.mjs +0 -167
  288. package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
  289. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +0 -49
  290. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +0 -7
  291. package/build-types/components/provider/use-post-content-blocks.d.ts +0 -2
  292. package/build-types/components/provider/use-post-content-blocks.d.ts.map +0 -1
  293. package/build-types/components/sync-connection-modal/index.d.ts +0 -8
  294. package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
  295. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +0 -9
  296. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +0 -1
  297. package/src/components/provider/use-post-content-blocks.js +0 -42
  298. package/src/components/sync-connection-modal/index.js +0 -200
  299. package/src/components/sync-connection-modal/style.scss +0 -9
  300. package/src/components/sync-connection-modal/use-retry-countdown.js +0 -70
  301. package/src/utils/sync-error-messages.js +0 -58
@@ -65,8 +65,19 @@ function CollaboratorsPresence({
65
65
  postType
66
66
  );
67
67
  const otherActiveCollaborators = activeCollaborators.filter(
68
- (collaborator) => !collaborator.isMe
68
+ (c) => !c.isMe
69
69
  );
70
+ const collaboratorsForList = (0, import_element.useMemo)(() => {
71
+ return [...activeCollaborators].sort((a, b) => {
72
+ if (a.isMe && !b.isMe) {
73
+ return -1;
74
+ }
75
+ if (!a.isMe && b.isMe) {
76
+ return 1;
77
+ }
78
+ return 0;
79
+ });
80
+ }, [activeCollaborators]);
70
81
  const [isPopoverVisible, setIsPopoverVisible] = (0, import_element.useState)(false);
71
82
  const [popoverAnchor, setPopoverAnchor] = (0, import_element.useState)(
72
83
  null
@@ -74,6 +85,7 @@ function CollaboratorsPresence({
74
85
  if (otherActiveCollaborators.length === 0) {
75
86
  return null;
76
87
  }
88
+ const me = activeCollaborators.find((c) => c.isMe);
77
89
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
78
90
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "editor-collaborators-presence", children: [
79
91
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -87,30 +99,44 @@ function CollaboratorsPresence({
87
99
  "aria-label": (0, import_i18n.sprintf)(
88
100
  // translators: %d: number of online collaborators.
89
101
  (0, import_i18n.__)("Collaborators list, %d online"),
90
- otherActiveCollaborators.length
102
+ collaboratorsForList.length
91
103
  ),
92
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_avatar_group.default, { max: 4, children: otherActiveCollaborators.map(
93
- (collaboratorState) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
104
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_avatar_group.default, { max: 4, children: [
105
+ me && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
106
  import_avatar.default,
95
107
  {
96
108
  src: (0, import_get_avatar_url.getAvatarUrl)(
97
- collaboratorState.collaboratorInfo.avatar_urls
98
- ),
99
- name: collaboratorState.collaboratorInfo.name,
100
- borderColor: (0, import_utils.getAvatarBorderColor)(
101
- collaboratorState.collaboratorInfo.id
109
+ me.collaboratorInfo.avatar_urls
102
110
  ),
111
+ name: me.collaboratorInfo.name,
112
+ borderColor: "var(--wp-admin-theme-color)",
103
113
  size: "small"
104
114
  },
105
- collaboratorState.clientId
115
+ me.clientId
116
+ ),
117
+ otherActiveCollaborators.map(
118
+ (collaboratorState) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
119
+ import_avatar.default,
120
+ {
121
+ src: (0, import_get_avatar_url.getAvatarUrl)(
122
+ collaboratorState.collaboratorInfo.avatar_urls
123
+ ),
124
+ name: collaboratorState.collaboratorInfo.name,
125
+ borderColor: (0, import_utils.getAvatarBorderColor)(
126
+ collaboratorState.collaboratorInfo.id
127
+ ),
128
+ size: "small"
129
+ },
130
+ collaboratorState.clientId
131
+ )
106
132
  )
107
- ) })
133
+ ] })
108
134
  }
109
135
  ),
110
136
  isPopoverVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
111
137
  import_list.CollaboratorsList,
112
138
  {
113
- activeCollaborators: otherActiveCollaborators,
139
+ activeCollaborators: collaboratorsForList,
114
140
  popoverAnchor,
115
141
  setIsPopoverVisible
116
142
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-presence/index.tsx", "../../../src/components/collaborators-presence/styles/collaborators-presence.scss"],
4
- "sourcesContent": ["import { Button } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n} from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\nimport Avatar from './avatar';\nimport AvatarGroup from './avatar-group';\nimport { CollaboratorsList } from './list';\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nimport './styles/collaborators-presence.scss';\nimport { CollaboratorsOverlay } from '../collaborators-overlay';\n\nconst { useActiveCollaborators } = unlock( privateApis );\n\ninterface CollaboratorsPresenceProps {\n\tpostId: number | null;\n\tpostType: string | null;\n}\n\n/**\n * Renders a list of avatars for the active collaborators, with a maximum of 3 visible avatars.\n * Shows a popover with all collaborators on hover.\n *\n * @param props CollaboratorsPresence component props\n * @param props.postId ID of the post\n * @param props.postType Type of the post\n */\nexport function CollaboratorsPresence( {\n\tpostId,\n\tpostType,\n}: CollaboratorsPresenceProps ) {\n\tconst activeCollaborators = useActiveCollaborators(\n\t\tpostId,\n\t\tpostType\n\t) as PostEditorAwarenessState[];\n\n\t// Filter out current user - we never show ourselves in the list\n\tconst otherActiveCollaborators = activeCollaborators.filter(\n\t\t( collaborator ) => ! collaborator.isMe\n\t);\n\n\tconst [ isPopoverVisible, setIsPopoverVisible ] = useState( false );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\n\t// When there are no other collaborators, this component should not render\n\t// at all. This will always be the case when collaboration is not enabled, but\n\t// also when the current user is the only editor with the post open.\n\tif ( otherActiveCollaborators.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"editor-collaborators-presence\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tclassName=\"editor-collaborators-presence__button\"\n\t\t\t\t\tonClick={ () => setIsPopoverVisible( ! isPopoverVisible ) }\n\t\t\t\t\tisPressed={ isPopoverVisible }\n\t\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %d: number of online collaborators.\n\t\t\t\t\t\t__( 'Collaborators list, %d online' ),\n\t\t\t\t\t\totherActiveCollaborators.length\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<AvatarGroup max={ 4 }>\n\t\t\t\t\t\t{ otherActiveCollaborators.map(\n\t\t\t\t\t\t\t( collaboratorState ) => (\n\t\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\t\tkey={ collaboratorState.clientId }\n\t\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t\t.avatar_urls\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tname={\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.name\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tborderColor={ getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.id\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\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</AvatarGroup>\n\t\t\t\t</Button>\n\t\t\t\t{ isPopoverVisible && (\n\t\t\t\t\t<CollaboratorsList\n\t\t\t\t\t\tactiveCollaborators={ otherActiveCollaborators }\n\t\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\t\tsetIsPopoverVisible={ setIsPopoverVisible }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<CollaboratorsOverlay postId={ postId } postType={ postType } />\n\t\t</>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='eee1778bc0']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"eee1778bc0\");\n\tstyle.appendChild(document.createTextNode(\".editor-collaborators-presence{align-items:center;background:#f0f0f0;border-radius:4px;display:flex;flex-shrink:0;height:32px;margin-right:8px}.editor-collaborators-presence:has(.is-pressed),.editor-collaborators-presence:hover{background-color:#e0e0e0}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button{align-items:center;background:#0000;border-radius:4px;box-sizing:border-box;color:#2f2f2f;cursor:pointer;display:flex;height:100%;padding:4px;position:relative}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed:hover,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:hover{background:#0000;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:focus:not(:active){box-shadow:inset 0 0 0 var(--wp-admin-border-width-focus,2px) var(--wp-admin-theme-color,#007cba);outline:none}\"));\n\tdocument.head.appendChild(style);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAuB;AACvB,qBAAyB;AACzB,uBAGO;AACP,kBAA4B;AAE5B,oBAAmB;AACnB,0BAAwB;AACxB,kBAAkC;AAClC,yBAAuB;AACvB,4BAA6B;AAC7B,mBAAqC;;;ACbrC,IAAI,OAAO,aAAa,eAAe,QAAQ,IAAI,aAAa,UAAU,CAAC,SAAS,KAAK,cAAc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F,GACD;AAAA;AAAA,MACD;AAAA,MACE,oBACD;AAAA,QAAC;AAAA;AAAA,UACA,qBAAsB;AAAA,UACtB;AAAA,UACA;AAAA;AAAA,MACD;AAAA,OAEF;AAAA,IACA,4CAAC,qDAAqB,QAAkB,UAAsB;AAAA,KAC/D;AAEF;",
4
+ "sourcesContent": ["import { Button } from '@wordpress/components';\nimport { useMemo, useState } from '@wordpress/element';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n} from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\nimport Avatar from './avatar';\nimport AvatarGroup from './avatar-group';\nimport { CollaboratorsList } from './list';\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nimport './styles/collaborators-presence.scss';\nimport { CollaboratorsOverlay } from '../collaborators-overlay';\n\nconst { useActiveCollaborators } = unlock( privateApis );\n\ninterface CollaboratorsPresenceProps {\n\tpostId: number | null;\n\tpostType: string | null;\n}\n\n/**\n * Renders a list of avatars for the active collaborators, with a maximum of 3 visible avatars.\n * Shows a popover with all collaborators on hover.\n *\n * @param props CollaboratorsPresence component props\n * @param props.postId ID of the post\n * @param props.postType Type of the post\n */\nexport function CollaboratorsPresence( {\n\tpostId,\n\tpostType,\n}: CollaboratorsPresenceProps ) {\n\tconst activeCollaborators = useActiveCollaborators(\n\t\tpostId,\n\t\tpostType\n\t) as PostEditorAwarenessState[];\n\n\tconst otherActiveCollaborators = activeCollaborators.filter(\n\t\t( c ) => ! c.isMe\n\t);\n\n\t// Always include self in the list sorted first.\n\tconst collaboratorsForList = useMemo( () => {\n\t\treturn [ ...activeCollaborators ].sort( ( a, b ) => {\n\t\t\tif ( a.isMe && ! b.isMe ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif ( ! a.isMe && b.isMe ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t} );\n\t}, [ activeCollaborators ] );\n\n\tconst [ isPopoverVisible, setIsPopoverVisible ] = useState( false );\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(\n\t\tnull\n\t);\n\n\t// When there are no other collaborators, this component should not render\n\t// at all. This will always be the case when collaboration is not enabled, but\n\t// also when the current user is the only editor with the post open.\n\tif ( otherActiveCollaborators.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst me = activeCollaborators.find( ( c ) => c.isMe );\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"editor-collaborators-presence\">\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tclassName=\"editor-collaborators-presence__button\"\n\t\t\t\t\tonClick={ () => setIsPopoverVisible( ! isPopoverVisible ) }\n\t\t\t\t\tisPressed={ isPopoverVisible }\n\t\t\t\t\tref={ setPopoverAnchor }\n\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t// translators: %d: number of online collaborators.\n\t\t\t\t\t\t__( 'Collaborators list, %d online' ),\n\t\t\t\t\t\tcollaboratorsForList.length\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<AvatarGroup max={ 4 }>\n\t\t\t\t\t\t{ me && (\n\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\tkey={ me.clientId }\n\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\tme.collaboratorInfo.avatar_urls\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tname={ me.collaboratorInfo.name }\n\t\t\t\t\t\t\t\tborderColor=\"var(--wp-admin-theme-color)\"\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ otherActiveCollaborators.map(\n\t\t\t\t\t\t\t( collaboratorState ) => (\n\t\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\t\tkey={ collaboratorState.clientId }\n\t\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t\t.avatar_urls\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tname={\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.name\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tborderColor={ getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.id\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\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</AvatarGroup>\n\t\t\t\t</Button>\n\t\t\t\t{ isPopoverVisible && (\n\t\t\t\t\t<CollaboratorsList\n\t\t\t\t\t\tactiveCollaborators={ collaboratorsForList }\n\t\t\t\t\t\tpopoverAnchor={ popoverAnchor }\n\t\t\t\t\t\tsetIsPopoverVisible={ setIsPopoverVisible }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<CollaboratorsOverlay postId={ postId } postType={ postType } />\n\t\t</>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='eee1778bc0']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"eee1778bc0\");\n\tstyle.appendChild(document.createTextNode(\".editor-collaborators-presence{align-items:center;background:#f0f0f0;border-radius:4px;display:flex;flex-shrink:0;height:32px;margin-right:8px}.editor-collaborators-presence:has(.is-pressed),.editor-collaborators-presence:hover{background-color:#e0e0e0}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button{align-items:center;background:#0000;border-radius:4px;box-sizing:border-box;color:#2f2f2f;cursor:pointer;display:flex;height:100%;padding:4px;position:relative}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button.is-pressed:hover,.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:hover{background:#0000;color:#2f2f2f}.editor-collaborators-presence__button.editor-collaborators-presence__button.components-button:focus:not(:active){box-shadow:inset 0 0 0 var(--wp-admin-border-width-focus,2px) var(--wp-admin-theme-color,#007cba);outline:none}\"));\n\tdocument.head.appendChild(style);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAuB;AACvB,qBAAkC;AAClC,uBAGO;AACP,kBAA4B;AAE5B,oBAAmB;AACnB,0BAAwB;AACxB,kBAAkC;AAClC,yBAAuB;AACvB,4BAA6B;AAC7B,mBAAqC;;;ACbrC,IAAI,OAAO,aAAa,eAAe,QAAQ,IAAI,aAAa,UAAU,CAAC,SAAS,KAAK,cAAc,kCAAkC,GAAG;AAC3I,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,aAAa,gBAAgB,YAAY;AAC/C,QAAM,YAAY,SAAS,eAAe,6jCAA6jC,CAAC;AACxmC,WAAS,KAAK,YAAY,KAAK;AAChC;;;ADWA,mCAAqC;AA0DnC;AAxDF,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,4BAAY;AAehD,SAAS,sBAAuB;AAAA,EACtC;AAAA,EACA;AACD,GAAgC;AAC/B,QAAM,sBAAsB;AAAA,IAC3B;AAAA,IACA;AAAA,EACD;AAEA,QAAM,2BAA2B,oBAAoB;AAAA,IACpD,CAAE,MAAO,CAAE,EAAE;AAAA,EACd;AAGA,QAAM,2BAAuB,wBAAS,MAAM;AAC3C,WAAO,CAAE,GAAG,mBAAoB,EAAE,KAAM,CAAE,GAAG,MAAO;AACnD,UAAK,EAAE,QAAQ,CAAE,EAAE,MAAO;AACzB,eAAO;AAAA,MACR;AACA,UAAK,CAAE,EAAE,QAAQ,EAAE,M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AAAA,UACA,qBAAsB;AAAA,UACtB;AAAA,UACA;AAAA;AAAA,MACD;AAAA,OAEF;AAAA,IACA,4CAAC,qDAAqB,QAAkB,UAAsB;AAAA,KAC/D;AAEF;",
6
6
  "names": ["AvatarGroup", "Avatar"]
7
7
  }
@@ -80,30 +80,33 @@ function CollaboratorsList({
80
80
  }
81
81
  ) })
82
82
  ] }),
83
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-items", children: activeCollaborators.map((collaboratorState) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
84
- "button",
85
- {
86
- className: "editor-collaborators-presence__list-item",
87
- disabled: true,
88
- children: [
89
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
- import_avatar.default,
91
- {
92
- src: (0, import_get_avatar_url.getAvatarUrl)(
93
- collaboratorState.collaboratorInfo.avatar_urls
94
- ),
95
- name: collaboratorState.collaboratorInfo.name,
96
- borderColor: (0, import_utils.getAvatarBorderColor)(
97
- collaboratorState.collaboratorInfo.id
98
- ),
99
- dimmed: !collaboratorState.isConnected
100
- }
101
- ),
102
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-item-info", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-item-name", children: collaboratorState.collaboratorInfo.name }) })
103
- ]
104
- },
105
- collaboratorState.clientId
106
- )) })
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-items", children: activeCollaborators.map((collaboratorState) => {
84
+ const isCurrentUser = collaboratorState.isMe;
85
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
86
+ "button",
87
+ {
88
+ className: "editor-collaborators-presence__list-item",
89
+ disabled: true,
90
+ children: [
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ import_avatar.default,
93
+ {
94
+ src: (0, import_get_avatar_url.getAvatarUrl)(
95
+ collaboratorState.collaboratorInfo.avatar_urls
96
+ ),
97
+ name: collaboratorState.collaboratorInfo.name,
98
+ borderColor: isCurrentUser ? "var(--wp-admin-theme-color)" : (0, import_utils.getAvatarBorderColor)(
99
+ collaboratorState.collaboratorInfo.id
100
+ ),
101
+ dimmed: !collaboratorState.isConnected
102
+ }
103
+ ),
104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-item-info", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-collaborators-presence__list-item-name", children: isCurrentUser ? (0, import_i18n.__)("You") : collaboratorState.collaboratorInfo.name }) })
105
+ ]
106
+ },
107
+ collaboratorState.clientId
108
+ );
109
+ }) })
107
110
  ] })
108
111
  }
109
112
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-presence/list.tsx", "../../../src/components/collaborators-presence/styles/collaborators-list.scss"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { Popover, Button } from '@wordpress/components';\nimport { closeSmall } from '@wordpress/icons';\nimport { type PostEditorAwarenessState } from '@wordpress/core-data';\n\nimport Avatar from './avatar';\nimport { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nimport './styles/collaborators-list.scss';\n\ninterface CollaboratorsListProps {\n\tactiveCollaborators: PostEditorAwarenessState[];\n\tpopoverAnchor?: HTMLElement | null;\n\tsetIsPopoverVisible: ( isVisible: boolean ) => void;\n}\n\n/**\n * Renders a list showing all active collaborators with their details.\n * Note: activeUsers should already exclude the current user (filtered by parent component).\n * @param props Component props\n * @param props.activeCollaborators List of active collaborators\n * @param props.popoverAnchor Anchor element for the popover\n * @param props.setIsPopoverVisible Callback to set the visibility of the popover\n */\nexport function CollaboratorsList( {\n\tactiveCollaborators,\n\tpopoverAnchor,\n\tsetIsPopoverVisible,\n}: CollaboratorsListProps ) {\n\treturn (\n\t\t<Popover\n\t\t\tanchor={ popoverAnchor }\n\t\t\tplacement=\"bottom\"\n\t\t\toffset={ 8 }\n\t\t\tclassName=\"editor-collaborators-presence__list\"\n\t\t\tonClose={ () => setIsPopoverVisible( false ) }\n\t\t>\n\t\t\t<div className=\"editor-collaborators-presence__list-content\">\n\t\t\t\t<div className=\"editor-collaborators-presence__list-header\">\n\t\t\t\t\t<div className=\"editor-collaborators-presence__list-header-title\">\n\t\t\t\t\t\t{ __( 'Collaborators' ) }\n\t\t\t\t\t\t<span>{ activeCollaborators.length }</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"editor-collaborators-presence__list-header-action\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t\t\tlabel={ __( 'Close Collaborators List' ) }\n\t\t\t\t\t\t\tonClick={ () => setIsPopoverVisible( false ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-collaborators-presence__list-items\">\n\t\t\t\t\t{ activeCollaborators.map( ( collaboratorState ) => (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tkey={ collaboratorState.clientId }\n\t\t\t\t\t\t\tclassName=\"editor-collaborators-presence__list-item\"\n\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t.avatar_urls\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tname={ collaboratorState.collaboratorInfo.name }\n\t\t\t\t\t\t\t\tborderColor={ getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.id\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tdimmed={ ! collaboratorState.isConnected }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<div className=\"editor-collaborators-presence__list-item-info\">\n\t\t\t\t\t\t\t\t<div className=\"editor-collaborators-presence__list-item-name\">\n\t\t\t\t\t\t\t\t\t{ collaboratorState.collaboratorInfo.name }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='9537a5e604']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"9537a5e604\");\n\tstyle.appendChild(document.createTextNode(\".editor-collaborators-presence__list.components-popover .components-popover__content{background:#fff;border:1px solid #ddd;border-radius:8px;border-width:1px 0 0 1px;box-shadow:0 1px 2px #0000000d,0 2px 3px #0000000a,0 6px 6px #00000008,0 8px 8px #00000005}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-content{min-width:280px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header{align-items:center;display:flex;justify-content:space-between;padding:8px 16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title{display:flex;font-size:13px;font-weight:499;gap:4px;line-height:20px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title span{color:#757575}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action{padding:0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action button{color:#1e1e1e;height:32px;padding:0;width:32px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-items{display:flex;flex-direction:column;padding-bottom:16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item{all:unset;align-items:center;box-sizing:border-box;cursor:pointer;display:flex;gap:8px;padding:12px 16px;transition:background-color .2s ease;width:100%}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:hover:not(:disabled){background-color:rgba(var(--wp-admin-theme-color--rgb),.04)}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:active:not(:disabled){background-color:rgba(var(--wp-admin-theme-color--rgb),.08)}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:focus-visible{outline:2px solid var(--wp-admin-theme-color,#3858e9);outline-offset:-2px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:disabled{cursor:default}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-info{display:flex;flex:1;flex-direction:column;min-width:0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-name{color:#1e1e1e;font-size:13px;font-weight:499;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\"));\n\tdocument.head.appendChild(style);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,wBAAgC;AAChC,mBAA2B;AAG3B,oBAAmB;AACnB,4BAA6B;AAC7B,mBAAqC;;;ACPrC,IAAI,OAAO,aAAa,eAAe,QAAQ,IAAI,aAAa,UAAU,CAAC,SAAS,KAAK,cAAc,kCAAkC,GAAG;AAC3I,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,aAAa,gBAAgB,YAAY;AAC/C,QAAM,YAAY,SAAS,eAAe,yhFAAyhF,CAAC;AACpkF,WAAS,KAAK,YAAY,KAAK;AAChC;;;ADmCK;AAfE,SAAS,kBAAmB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACD,GAA4B;AAC3B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS;AAAA,MACT,WAAU;AAAA,MACV,QAAS;AAAA,MACT,WAAU;AAAA,MACV,SAAU,MAAM,oBAAqB,KAAM;AAAA,MAE3C,uDAAC,SAAI,WAAU,+CACd;AAAA,qDAAC,SAAI,WAAU,8CACd;AAAA,uDAAC,SAAI,WAAU,oDACZ;AAAA,gCAAI,eAAgB;AAAA,YACtB,4CAAC,UAAO,8BAAoB,QAAQ;AAAA,aACrC;AAAA,UACA,4CAAC,SAAI,WAAU,qDACd;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,MAAO;AAAA,cACP,UAAW;AAAA,cACX,WAAQ,gBAAI,0BAA2B;AAAA,cACvC,SAAU,MAAM,oBAAqB,KAAM;AAAA;AAAA,UAC5C,GACD;AAAA,WACD;AAAA,QACA,4CAAC,SAAI,WAAU,6CACZ,8BAAoB,IAAK,CAAE,sBAC5B;AAAA,UAAC;AAAA;AAAA,YAEA,WAAU;AAAA,YACV,UAAQ;AAAA,YAER;AAAA;AAAA,gBAAC,cAAAA;AAAA,gBAAA;AAAA,kBACA,SAAM;AAAA,oBACL,kBAAkB,iBAChB;AAAA,kBACH;AAAA,kBACA,MAAO,kBAAkB,iBAAiB;AAAA,kBAC1C,iBAAc;AAAA,oBACb,kBAAkB,iBAAiB;AAAA,kBACpC;AAAA,kBACA,QAAS,CAAE,kBAAkB;AAAA;AAAA,cAC9B;AAAA,cACA,4CAAC,SAAI,WAAU,iDACd,sDAAC,SAAI,WAAU,iDACZ,4BAAkB,iBAAiB,MACtC,GACD;AAAA;AAAA;AAAA,UAnBM,kBAAkB;AAAA,QAoBzB,CACC,GACH;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { Popover, Button } from '@wordpress/components';\nimport { closeSmall } from '@wordpress/icons';\nimport { type PostEditorAwarenessState } from '@wordpress/core-data';\n\nimport Avatar from './avatar';\nimport { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nimport './styles/collaborators-list.scss';\n\ninterface CollaboratorsListProps {\n\tactiveCollaborators: PostEditorAwarenessState[];\n\tpopoverAnchor?: HTMLElement | null;\n\tsetIsPopoverVisible: ( isVisible: boolean ) => void;\n}\n\n/**\n * Renders a list showing all active collaborators with their details.\n * When the showCollaborationCursor preference is enabled, the current user\n * is included and expected to be first in the list.\n * @param props Component props\n * @param props.activeCollaborators List of active collaborators\n * @param props.popoverAnchor Anchor element for the popover\n * @param props.setIsPopoverVisible Callback to set the visibility of the popover\n */\nexport function CollaboratorsList( {\n\tactiveCollaborators,\n\tpopoverAnchor,\n\tsetIsPopoverVisible,\n}: CollaboratorsListProps ) {\n\treturn (\n\t\t<Popover\n\t\t\tanchor={ popoverAnchor }\n\t\t\tplacement=\"bottom\"\n\t\t\toffset={ 8 }\n\t\t\tclassName=\"editor-collaborators-presence__list\"\n\t\t\tonClose={ () => setIsPopoverVisible( false ) }\n\t\t>\n\t\t\t<div className=\"editor-collaborators-presence__list-content\">\n\t\t\t\t<div className=\"editor-collaborators-presence__list-header\">\n\t\t\t\t\t<div className=\"editor-collaborators-presence__list-header-title\">\n\t\t\t\t\t\t{ __( 'Collaborators' ) }\n\t\t\t\t\t\t<span>{ activeCollaborators.length }</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"editor-collaborators-presence__list-header-action\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\ticonSize={ 24 }\n\t\t\t\t\t\t\tlabel={ __( 'Close Collaborators List' ) }\n\t\t\t\t\t\t\tonClick={ () => setIsPopoverVisible( false ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"editor-collaborators-presence__list-items\">\n\t\t\t\t\t{ activeCollaborators.map( ( collaboratorState ) => {\n\t\t\t\t\t\tconst isCurrentUser = collaboratorState.isMe;\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tkey={ collaboratorState.clientId }\n\t\t\t\t\t\t\t\tclassName=\"editor-collaborators-presence__list-item\"\n\t\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Avatar\n\t\t\t\t\t\t\t\t\tsrc={ getAvatarUrl(\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t\t.avatar_urls\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tname={\n\t\t\t\t\t\t\t\t\t\tcollaboratorState.collaboratorInfo.name\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tborderColor={\n\t\t\t\t\t\t\t\t\t\tisCurrentUser\n\t\t\t\t\t\t\t\t\t\t\t? 'var(--wp-admin-theme-color)'\n\t\t\t\t\t\t\t\t\t\t\t: getAvatarBorderColor(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcollaboratorState\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t.collaboratorInfo.id\n\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdimmed={ ! collaboratorState.isConnected }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<div className=\"editor-collaborators-presence__list-item-info\">\n\t\t\t\t\t\t\t\t\t<div className=\"editor-collaborators-presence__list-item-name\">\n\t\t\t\t\t\t\t\t\t\t{ isCurrentUser\n\t\t\t\t\t\t\t\t\t\t\t? __( 'You' )\n\t\t\t\t\t\t\t\t\t\t\t: collaboratorState.collaboratorInfo\n\t\t\t\t\t\t\t\t\t\t\t\t\t.name }\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</Popover>\n\t);\n}\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='9537a5e604']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"9537a5e604\");\n\tstyle.appendChild(document.createTextNode(\".editor-collaborators-presence__list.components-popover .components-popover__content{background:#fff;border:1px solid #ddd;border-radius:8px;border-width:1px 0 0 1px;box-shadow:0 1px 2px #0000000d,0 2px 3px #0000000a,0 6px 6px #00000008,0 8px 8px #00000005}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-content{min-width:280px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header{align-items:center;display:flex;justify-content:space-between;padding:8px 16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title{display:flex;font-size:13px;font-weight:499;gap:4px;line-height:20px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-title span{color:#757575}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action{padding:0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-header-action button{color:#1e1e1e;height:32px;padding:0;width:32px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-items{display:flex;flex-direction:column;padding-bottom:16px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item{all:unset;align-items:center;box-sizing:border-box;cursor:pointer;display:flex;gap:8px;padding:12px 16px;transition:background-color .2s ease;width:100%}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:hover:not(:disabled){background-color:rgba(var(--wp-admin-theme-color--rgb),.04)}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:active:not(:disabled){background-color:rgba(var(--wp-admin-theme-color--rgb),.08)}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:focus-visible{outline:2px solid var(--wp-admin-theme-color,#3858e9);outline-offset:-2px}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item:disabled{cursor:default}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-info{display:flex;flex:1;flex-direction:column;min-width:0}.editor-collaborators-presence__list.components-popover .editor-collaborators-presence__list-item-name{color:#1e1e1e;font-size:13px;font-weight:499;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\"));\n\tdocument.head.appendChild(style);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,wBAAgC;AAChC,mBAA2B;AAG3B,oBAAmB;AACnB,4BAA6B;AAC7B,mBAAqC;;;ACPrC,IAAI,OAAO,aAAa,eAAe,QAAQ,IAAI,aAAa,UAAU,CAAC,SAAS,KAAK,cAAc,kCAAkC,GAAG;AAC3I,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,aAAa,gBAAgB,YAAY;AAC/C,QAAM,YAAY,SAAS,eAAe,yhFAAyhF,CAAC;AACpkF,WAAS,KAAK,YAAY,KAAK;AAChC;;;ADoCK;AAfE,SAAS,kBAAmB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AACD,GAA4B;AAC3B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,QAAS;AAAA,MACT,WAAU;AAAA,MACV,QAAS;AAAA,MACT,WAAU;AAAA,MACV,SAAU,MAAM,oBAAqB,KAAM;AAAA,MAE3C,uDAAC,SAAI,WAAU,+CACd;AAAA,qDAAC,SAAI,WAAU,8CACd;AAAA,uDAAC,SAAI,WAAU,oDACZ;AAAA,gCAAI,eAAgB;AAAA,YACtB,4CAAC,UAAO,8BAAoB,QAAQ;AAAA,aACrC;AAAA,UACA,4CAAC,SAAI,WAAU,qDACd;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,MAAO;AAAA,cACP,UAAW;AAAA,cACX,WAAQ,gBAAI,0BAA2B;AAAA,cACvC,SAAU,MAAM,oBAAqB,KAAM;AAAA;AAAA,UAC5C,GACD;AAAA,WACD;AAAA,QACA,4CAAC,SAAI,WAAU,6CACZ,8BAAoB,IAAK,CAAE,sBAAuB;AACnD,gBAAM,gBAAgB,kBAAkB;AACxC,iBACC;AAAA,YAAC;AAAA;AAAA,cAEA,WAAU;AAAA,cACV,UAAQ;AAAA,cAER;AAAA;AAAA,kBAAC,cAAAA;AAAA,kBAAA;AAAA,oBACA,SAAM;AAAA,sBACL,kBAAkB,iBAChB;AAAA,oBACH;AAAA,oBACA,MACC,kBAAkB,iBAAiB;AAAA,oBAEpC,aACC,gBACG,oCACA;AAAA,sBACA,kBACE,iBAAiB;AAAA,oBACnB;AAAA,oBAEJ,QAAS,CAAE,kBAAkB;AAAA;AAAA,gBAC9B;AAAA,gBACA,4CAAC,SAAI,WAAU,iDACd,sDAAC,SAAI,WAAU,iDACZ,8BACC,gBAAI,KAAM,IACV,kBAAkB,iBACjB,MACL,GACD;AAAA;AAAA;AAAA,YA7BM,kBAAkB;AAAA,UA8BzB;AAAA,QAEF,CAAE,GACH;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": ["Avatar"]
7
7
  }
@@ -23,25 +23,20 @@ __export(use_collaborator_notifications_exports, {
23
23
  useCollaboratorNotifications: () => useCollaboratorNotifications
24
24
  });
25
25
  module.exports = __toCommonJS(use_collaborator_notifications_exports);
26
- var import_compose = require("@wordpress/compose");
27
26
  var import_data = require("@wordpress/data");
28
27
  var import_element = require("@wordpress/element");
29
28
  var import_i18n = require("@wordpress/i18n");
30
29
  var import_notices = require("@wordpress/notices");
31
30
  var import_core_data = require("@wordpress/core-data");
31
+ var import_preferences = require("@wordpress/preferences");
32
32
  var import_lock_unlock = require("../../lock-unlock.cjs");
33
33
  var import_store = require("../../store/index.cjs");
34
- var { useActiveCollaborators, useLastPostSave } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
34
+ var { useOnCollaboratorJoin, useOnCollaboratorLeave, useOnPostSave } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
35
35
  var NOTIFICATION_TYPE = {
36
36
  COLLAB_POST_UPDATED: "collab-post-updated",
37
37
  COLLAB_USER_ENTERED: "collab-user-entered",
38
38
  COLLAB_USER_EXITED: "collab-user-exited"
39
39
  };
40
- var NOTIFICATIONS_CONFIG = {
41
- userEntered: true,
42
- userExited: true,
43
- postUpdated: true
44
- };
45
40
  var PUBLISHED_STATUSES = ["publish", "private", "future"];
46
41
  function getPostUpdatedMessage(name, status, isFirstPublish) {
47
42
  if (isFirstPublish) {
@@ -53,119 +48,96 @@ function getPostUpdatedMessage(name, status, isFirstPublish) {
53
48
  return (0, import_i18n.sprintf)((0, import_i18n.__)("Draft saved by %s."), name);
54
49
  }
55
50
  function useCollaboratorNotifications(postId, postType) {
56
- const activeCollaborators = useActiveCollaborators(
57
- postId,
58
- postType
51
+ const { postStatus, isCollaborationEnabled, showNotifications } = (0, import_data.useSelect)(
52
+ (select) => {
53
+ const editorSel = select(import_store.store);
54
+ return {
55
+ postStatus: editorSel.getCurrentPostAttribute("status"),
56
+ isCollaborationEnabled: editorSel.isCollaborationEnabledForCurrentPost(),
57
+ showNotifications: select(import_preferences.store).get(
58
+ "core",
59
+ "showCollaborationNotifications"
60
+ ) ?? true
61
+ };
62
+ },
63
+ []
59
64
  );
60
- const lastPostSave = useLastPostSave(postId, postType);
61
- const { postStatus, isCollaborationEnabled } = (0, import_data.useSelect)((select) => {
62
- const editorSel = select(import_store.store);
63
- return {
64
- postStatus: editorSel.getCurrentPostAttribute("status"),
65
- isCollaborationEnabled: editorSel.isCollaborationEnabledForCurrentPost()
66
- };
67
- }, []);
68
65
  const { createNotice } = (0, import_data.useDispatch)(import_notices.store);
69
- const prevCollaborators = (0, import_compose.usePrevious)(activeCollaborators);
70
- const prevPostSave = (0, import_compose.usePrevious)(lastPostSave);
71
- (0, import_element.useEffect)(() => {
72
- if (!isCollaborationEnabled) {
73
- return;
74
- }
75
- if (!prevCollaborators || prevCollaborators.length === 0) {
76
- return;
77
- }
78
- function notify(noticeId, message) {
79
- void createNotice("info", message, {
80
- id: noticeId,
81
- type: "snackbar",
82
- isDismissible: false
83
- });
84
- }
85
- const prevMap = new Map(
86
- prevCollaborators.map((c) => [c.clientId, c])
87
- );
88
- const newMap = new Map(
89
- activeCollaborators.map((c) => [c.clientId, c])
90
- );
91
- if (NOTIFICATIONS_CONFIG.userEntered) {
92
- const me = activeCollaborators.find((c) => c.isMe);
93
- for (const [clientId, collaborator] of newMap) {
94
- if (prevMap.has(clientId) || collaborator.isMe) {
95
- continue;
96
- }
66
+ const shouldSubscribe = isCollaborationEnabled && showNotifications;
67
+ const effectivePostId = shouldSubscribe ? postId : null;
68
+ const effectivePostType = shouldSubscribe ? postType : null;
69
+ useOnCollaboratorJoin(
70
+ effectivePostId,
71
+ effectivePostType,
72
+ (0, import_element.useCallback)(
73
+ (collaborator, me) => {
97
74
  if (me && collaborator.collaboratorInfo.enteredAt < me.collaboratorInfo.enteredAt) {
98
- continue;
75
+ return;
99
76
  }
100
- notify(
101
- `${NOTIFICATION_TYPE.COLLAB_USER_ENTERED}-${collaborator.collaboratorInfo.id}`,
77
+ void createNotice(
78
+ "info",
102
79
  (0, import_i18n.sprintf)(
103
80
  /* translators: %s: collaborator display name */
104
81
  (0, import_i18n.__)("%s has joined the post."),
105
82
  collaborator.collaboratorInfo.name
106
- )
83
+ ),
84
+ {
85
+ id: `${NOTIFICATION_TYPE.COLLAB_USER_ENTERED}-${collaborator.collaboratorInfo.id}`,
86
+ type: "snackbar",
87
+ isDismissible: false
88
+ }
107
89
  );
108
- }
109
- }
110
- if (NOTIFICATIONS_CONFIG.userExited) {
111
- for (const [clientId, prevCollab] of prevMap) {
112
- if (prevCollab.isMe || !prevCollab.isConnected) {
113
- continue;
114
- }
115
- const newCollab = newMap.get(clientId);
116
- if (newCollab?.isConnected) {
117
- continue;
118
- }
119
- notify(
120
- `${NOTIFICATION_TYPE.COLLAB_USER_EXITED}-${prevCollab.collaboratorInfo.id}`,
90
+ },
91
+ [createNotice]
92
+ )
93
+ );
94
+ useOnCollaboratorLeave(
95
+ effectivePostId,
96
+ effectivePostType,
97
+ (0, import_element.useCallback)(
98
+ (collaborator) => {
99
+ void createNotice(
100
+ "info",
121
101
  (0, import_i18n.sprintf)(
122
102
  /* translators: %s: collaborator display name */
123
103
  (0, import_i18n.__)("%s has left the post."),
124
- prevCollab.collaboratorInfo.name
125
- )
104
+ collaborator.collaboratorInfo.name
105
+ ),
106
+ {
107
+ id: `${NOTIFICATION_TYPE.COLLAB_USER_EXITED}-${collaborator.collaboratorInfo.id}`,
108
+ type: "snackbar",
109
+ isDismissible: false
110
+ }
126
111
  );
127
- }
128
- }
129
- }, [
130
- activeCollaborators,
131
- prevCollaborators,
132
- isCollaborationEnabled,
133
- createNotice
134
- ]);
135
- (0, import_element.useEffect)(() => {
136
- if (!isCollaborationEnabled || !NOTIFICATIONS_CONFIG.postUpdated || !lastPostSave || !postStatus) {
137
- return;
138
- }
139
- if (prevPostSave && lastPostSave.savedAt === prevPostSave.savedAt) {
140
- return;
141
- }
142
- const saver = activeCollaborators.find(
143
- (c) => c.clientId === lastPostSave.savedByClientId && !c.isMe
144
- );
145
- if (!saver) {
146
- return;
147
- }
148
- const effectiveStatus = lastPostSave.postStatus ?? postStatus ?? "draft";
149
- const prevStatus = prevPostSave?.postStatus ?? postStatus;
150
- const isFirstPublish = !(prevStatus && PUBLISHED_STATUSES.includes(prevStatus)) && PUBLISHED_STATUSES.includes(effectiveStatus);
151
- const message = getPostUpdatedMessage(
152
- saver.collaboratorInfo.name,
153
- effectiveStatus,
154
- isFirstPublish
155
- );
156
- void createNotice("info", message, {
157
- id: `${NOTIFICATION_TYPE.COLLAB_POST_UPDATED}-${saver.collaboratorInfo.id}`,
158
- type: "snackbar",
159
- isDismissible: false
160
- });
161
- }, [
162
- lastPostSave,
163
- prevPostSave,
164
- activeCollaborators,
165
- isCollaborationEnabled,
166
- postStatus,
167
- createNotice
168
- ]);
112
+ },
113
+ [createNotice]
114
+ )
115
+ );
116
+ useOnPostSave(
117
+ effectivePostId,
118
+ effectivePostType,
119
+ (0, import_element.useCallback)(
120
+ (saveEvent, saver, prevEvent) => {
121
+ if (!postStatus) {
122
+ return;
123
+ }
124
+ const effectiveStatus = saveEvent.postStatus ?? postStatus ?? "draft";
125
+ const prevStatus = prevEvent?.postStatus ?? postStatus;
126
+ const isFirstPublish = !(prevStatus && PUBLISHED_STATUSES.includes(prevStatus)) && PUBLISHED_STATUSES.includes(effectiveStatus);
127
+ const message = getPostUpdatedMessage(
128
+ saver.collaboratorInfo.name,
129
+ effectiveStatus,
130
+ isFirstPublish
131
+ );
132
+ void createNotice("info", message, {
133
+ id: `${NOTIFICATION_TYPE.COLLAB_POST_UPDATED}-${saver.collaboratorInfo.id}`,
134
+ type: "snackbar",
135
+ isDismissible: false
136
+ });
137
+ },
138
+ [createNotice, postStatus]
139
+ )
140
+ );
169
141
  }
170
142
  // Annotate the CommonJS export names for ESM import in node:
171
143
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-presence/use-collaborator-notifications.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n} from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { useActiveCollaborators, useLastPostSave } = unlock( privateApis );\n\n/**\n * Notice IDs for each notification type. Using stable IDs prevents duplicate\n * notices if the same event is processed more than once.\n */\nconst NOTIFICATION_TYPE = {\n\tCOLLAB_POST_UPDATED: 'collab-post-updated',\n\tCOLLAB_USER_ENTERED: 'collab-user-entered',\n\tCOLLAB_USER_EXITED: 'collab-user-exited',\n} as const;\n\nconst NOTIFICATIONS_CONFIG = {\n\tuserEntered: true,\n\tuserExited: true,\n\tpostUpdated: true,\n};\n\nconst PUBLISHED_STATUSES = [ 'publish', 'private', 'future' ];\n\n/**\n * Returns the snackbar message for a post updated notification.\n *\n * @param name Display name of the collaborator who saved.\n * @param status WordPress post status at the time of save.\n * @param isFirstPublish Whether this save transitioned the post to published.\n */\nfunction getPostUpdatedMessage(\n\tname: string,\n\tstatus: string,\n\tisFirstPublish: boolean\n): string {\n\tif ( isFirstPublish ) {\n\t\t/* translators: %s: collaborator display name */\n\t\treturn sprintf( __( 'Post published by %s.' ), name );\n\t}\n\tif ( PUBLISHED_STATUSES.includes( status ) ) {\n\t\t/* translators: %s: collaborator display name */\n\t\treturn sprintf( __( 'Post updated by %s.' ), name );\n\t}\n\t/* translators: %s: collaborator display name */\n\treturn sprintf( __( 'Draft saved by %s.' ), name );\n}\n\n/**\n * Hook that watches for collaborator join/leave events and remote save events,\n * dispatching snackbar notices accordingly.\n *\n * @param postId The ID of the post being edited.\n * @param postType The post type of the post being edited.\n */\nexport function useCollaboratorNotifications(\n\tpostId: number | null,\n\tpostType: string | null\n): void {\n\tconst activeCollaborators = useActiveCollaborators(\n\t\tpostId,\n\t\tpostType\n\t) as PostEditorAwarenessState[];\n\n\tconst lastPostSave = useLastPostSave( postId, postType );\n\n\tconst { postStatus, isCollaborationEnabled } = useSelect( ( select ) => {\n\t\tconst editorSel = select( editorStore );\n\t\treturn {\n\t\t\tpostStatus: editorSel.getCurrentPostAttribute( 'status' ) as\n\t\t\t\t| string\n\t\t\t\t| undefined,\n\t\t\tisCollaborationEnabled:\n\t\t\t\teditorSel.isCollaborationEnabledForCurrentPost(),\n\t\t};\n\t}, [] );\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\n\tconst prevCollaborators = usePrevious( activeCollaborators );\n\tconst prevPostSave = usePrevious( lastPostSave );\n\n\t/*\n\t * Detect collaborator joins and leaves.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isCollaborationEnabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * On first render usePrevious returns undefined. On subsequent renders\n\t\t * the list may still be empty while the store hydrates. In both cases,\n\t\t * skip to avoid spurious \"X joined\" toasts for users already present.\n\t\t */\n\t\tif ( ! prevCollaborators || prevCollaborators.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction notify( noticeId: string, message: string ) {\n\t\t\tvoid createNotice( 'info', message, {\n\t\t\t\tid: noticeId,\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: false,\n\t\t\t} );\n\t\t}\n\n\t\tconst prevMap = new Map< number, PostEditorAwarenessState >(\n\t\t\tprevCollaborators.map( ( c ) => [ c.clientId, c ] )\n\t\t);\n\t\tconst newMap = new Map< number, PostEditorAwarenessState >(\n\t\t\tactiveCollaborators.map( ( c ) => [ c.clientId, c ] )\n\t\t);\n\n\t\t/*\n\t\t * Detect joins: new clientIds that weren't in the previous state.\n\t\t */\n\t\tif ( NOTIFICATIONS_CONFIG.userEntered ) {\n\t\t\tconst me = activeCollaborators.find( ( c ) => c.isMe );\n\n\t\t\tfor ( const [ clientId, collaborator ] of newMap ) {\n\t\t\t\tif ( prevMap.has( clientId ) || collaborator.isMe ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t/*\n\t\t\t\t * Skip collaborators who were present before the current user\n\t\t\t\t * joined. Their enteredAt is earlier than ours, meaning we're\n\t\t\t\t * the newcomer.\n\t\t\t\t */\n\t\t\t\tif (\n\t\t\t\t\tme &&\n\t\t\t\t\tcollaborator.collaboratorInfo.enteredAt <\n\t\t\t\t\t\tme.collaboratorInfo.enteredAt\n\t\t\t\t) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tnotify(\n\t\t\t\t\t`${ NOTIFICATION_TYPE.COLLAB_USER_ENTERED }-${ collaborator.collaboratorInfo.id }`,\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: collaborator display name */\n\t\t\t\t\t\t__( '%s has joined the post.' ),\n\t\t\t\t\t\tcollaborator.collaboratorInfo.name\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t * Detect leaves by iterating the previous collaborator list. A leave\n\t\t * notification fires when a previously-connected collaborator either:\n\t\t * - transitions to isConnected=false (greyed-out in the UI), or\n\t\t * - disappears from the list entirely while still connected.\n\t\t * Already-disconnected collaborators that are later removed from the\n\t\t * list (after the 5 s delay) are silently ignored.\n\t\t */\n\t\tif ( NOTIFICATIONS_CONFIG.userExited ) {\n\t\t\tfor ( const [ clientId, prevCollab ] of prevMap ) {\n\t\t\t\tif ( prevCollab.isMe || ! prevCollab.isConnected ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst newCollab = newMap.get( clientId );\n\t\t\t\tif ( newCollab?.isConnected ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tnotify(\n\t\t\t\t\t`${ NOTIFICATION_TYPE.COLLAB_USER_EXITED }-${ prevCollab.collaboratorInfo.id }`,\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: collaborator display name */\n\t\t\t\t\t\t__( '%s has left the post.' ),\n\t\t\t\t\t\tprevCollab.collaboratorInfo.name\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}, [\n\t\tactiveCollaborators,\n\t\tprevCollaborators,\n\t\tisCollaborationEnabled,\n\t\tcreateNotice,\n\t] );\n\n\t/*\n\t * Detect remote save events via the CRDT state map. The savedByClientId\n\t * is a Y.Doc client ID which maps to a collaborator via clientId.\n\t */\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! isCollaborationEnabled ||\n\t\t\t! NOTIFICATIONS_CONFIG.postUpdated ||\n\t\t\t! lastPostSave ||\n\t\t\t! postStatus\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prevPostSave && lastPostSave.savedAt === prevPostSave.savedAt ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst saver = activeCollaborators.find(\n\t\t\t( c ) => c.clientId === lastPostSave.savedByClientId && ! c.isMe\n\t\t);\n\n\t\tif ( ! saver ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Prefer the remote status from Y.Doc (accurate at save time) over\n\t\t// the local Redux value, which may not have synced yet.\n\t\tconst effectiveStatus =\n\t\t\tlastPostSave.postStatus ?? postStatus ?? 'draft';\n\n\t\t// prevPostSave is null on the first save this session, so fall back\n\t\t// to the Redux status (still pre-save when the notification fires).\n\t\tconst prevStatus = prevPostSave?.postStatus ?? postStatus;\n\t\tconst isFirstPublish =\n\t\t\t! ( prevStatus && PUBLISHED_STATUSES.includes( prevStatus ) ) &&\n\t\t\tPUBLISHED_STATUSES.includes( effectiveStatus );\n\n\t\tconst message = getPostUpdatedMessage(\n\t\t\tsaver.collaboratorInfo.name,\n\t\t\teffectiveStatus,\n\t\t\tisFirstPublish\n\t\t);\n\n\t\tvoid createNotice( 'info', message, {\n\t\t\tid: `${ NOTIFICATION_TYPE.COLLAB_POST_UPDATED }-${ saver.collaboratorInfo.id }`,\n\t\t\ttype: 'snackbar',\n\t\t\tisDismissible: false,\n\t\t} );\n\t}, [\n\t\tlastPostSave,\n\t\tprevPostSave,\n\t\tactiveCollaborators,\n\t\tisCollaborationEnabled,\n\t\tpostStatus,\n\t\tcreateNotice,\n\t] );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,kBAAuC;AACvC,qBAA0B;AAC1B,kBAA4B;AAC5B,qBAAsC;AACtC,uBAGO;AAKP,yBAAuB;AACvB,mBAAqC;AAErC,IAAM,EAAE,wBAAwB,gBAAgB,QAAI,2BAAQ,4BAAY;AAMxE,IAAM,oBAAoB;AAAA,EACzB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,oBAAoB;AACrB;AAEA,IAAM,uBAAuB;AAAA,EAC5B,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,aAAa;AACd;AAEA,IAAM,qBAAqB,CAAE,WAAW,WAAW,QAAS;AAS5D,SAA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AAc;AAI1C,UAAM,aAAa,cAAc,cAAc;AAC/C,UAAM,iBACL,EAAI,cAAc,mBAAmB,SAAU,UAAW,MAC1D,mBAAmB,SAAU,eAAgB;AAE9C,UAAM,UAAU;AAAA,MACf,MAAM,iBAAiB;AAAA,MACvB;AAAA,MACA;AAAA,IACD;AAEA,SAAK,aAAc,QAAQ,SAAS;AAAA,MACnC,IAAI,GAAI,kBAAkB,mBAAoB,IAAK,MAAM,iBAAiB,EAAG;AAAA,MAC7E,MAAM;AAAA,MACN,eAAe;AAAA,IAChB,CAAE;AAAA,EACH,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
- "names": ["editorStore", "noticesStore"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tprivateApis,\n\ttype PostEditorAwarenessState,\n\ttype PostSaveEvent,\n} from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { useOnCollaboratorJoin, useOnCollaboratorLeave, useOnPostSave } =\n\tunlock( privateApis );\n\n/**\n * Notice IDs for each notification type. Using stable IDs prevents duplicate\n * notices if the same event is processed more than once.\n */\nconst NOTIFICATION_TYPE = {\n\tCOLLAB_POST_UPDATED: 'collab-post-updated',\n\tCOLLAB_USER_ENTERED: 'collab-user-entered',\n\tCOLLAB_USER_EXITED: 'collab-user-exited',\n} as const;\n\nconst PUBLISHED_STATUSES = [ 'publish', 'private', 'future' ];\n\n/**\n * Returns the snackbar message for a post updated notification.\n *\n * @param name Display name of the collaborator who saved.\n * @param status WordPress post status at the time of save.\n * @param isFirstPublish Whether this save transitioned the post to published.\n */\nfunction getPostUpdatedMessage(\n\tname: string,\n\tstatus: string,\n\tisFirstPublish: boolean\n): string {\n\tif ( isFirstPublish ) {\n\t\t/* translators: %s: collaborator display name */\n\t\treturn sprintf( __( 'Post published by %s.' ), name );\n\t}\n\tif ( PUBLISHED_STATUSES.includes( status ) ) {\n\t\t/* translators: %s: collaborator display name */\n\t\treturn sprintf( __( 'Post updated by %s.' ), name );\n\t}\n\t/* translators: %s: collaborator display name */\n\treturn sprintf( __( 'Draft saved by %s.' ), name );\n}\n\n/**\n * Hook that watches for collaborator join/leave events and remote save events,\n * dispatching snackbar notices accordingly.\n *\n * @param postId The ID of the post being edited.\n * @param postType The post type of the post being edited.\n */\nexport function useCollaboratorNotifications(\n\tpostId: number | null,\n\tpostType: string | null\n): void {\n\tconst { postStatus, isCollaborationEnabled, showNotifications } = useSelect(\n\t\t( select ) => {\n\t\t\tconst editorSel = select( editorStore );\n\t\t\treturn {\n\t\t\t\tpostStatus: editorSel.getCurrentPostAttribute( 'status' ) as\n\t\t\t\t\t| string\n\t\t\t\t\t| undefined,\n\t\t\t\tisCollaborationEnabled:\n\t\t\t\t\teditorSel.isCollaborationEnabledForCurrentPost(),\n\t\t\t\tshowNotifications:\n\t\t\t\t\tselect( preferencesStore ).get(\n\t\t\t\t\t\t'core',\n\t\t\t\t\t\t'showCollaborationNotifications'\n\t\t\t\t\t) ?? true,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { createNotice } = useDispatch( noticesStore );\n\n\t// Pass null when collaboration is disabled or notifications are\n\t// turned off to prevent the hooks from subscribing to awareness state.\n\tconst shouldSubscribe = isCollaborationEnabled && showNotifications;\n\tconst effectivePostId = shouldSubscribe ? postId : null;\n\tconst effectivePostType = shouldSubscribe ? postType : null;\n\n\tuseOnCollaboratorJoin(\n\t\teffectivePostId,\n\t\teffectivePostType,\n\t\tuseCallback(\n\t\t\t(\n\t\t\t\tcollaborator: PostEditorAwarenessState,\n\t\t\t\tme?: PostEditorAwarenessState\n\t\t\t) => {\n\t\t\t\t/*\n\t\t\t\t * Skip collaborators who were present before the current user\n\t\t\t\t * joined. Their enteredAt is earlier than ours, meaning we're\n\t\t\t\t * the newcomer.\n\t\t\t\t */\n\t\t\t\tif (\n\t\t\t\t\tme &&\n\t\t\t\t\tcollaborator.collaboratorInfo.enteredAt <\n\t\t\t\t\t\tme.collaboratorInfo.enteredAt\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvoid createNotice(\n\t\t\t\t\t'info',\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: collaborator display name */\n\t\t\t\t\t\t__( '%s has joined the post.' ),\n\t\t\t\t\t\tcollaborator.collaboratorInfo.name\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${ NOTIFICATION_TYPE.COLLAB_USER_ENTERED }-${ collaborator.collaboratorInfo.id }`,\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tisDismissible: false,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ createNotice ]\n\t\t)\n\t);\n\n\tuseOnCollaboratorLeave(\n\t\teffectivePostId,\n\t\teffectivePostType,\n\t\tuseCallback(\n\t\t\t( collaborator: PostEditorAwarenessState ) => {\n\t\t\t\tvoid createNotice(\n\t\t\t\t\t'info',\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: collaborator display name */\n\t\t\t\t\t\t__( '%s has left the post.' ),\n\t\t\t\t\t\tcollaborator.collaboratorInfo.name\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${ NOTIFICATION_TYPE.COLLAB_USER_EXITED }-${ collaborator.collaboratorInfo.id }`,\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tisDismissible: false,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ createNotice ]\n\t\t)\n\t);\n\n\tuseOnPostSave(\n\t\teffectivePostId,\n\t\teffectivePostType,\n\t\tuseCallback(\n\t\t\t(\n\t\t\t\tsaveEvent: PostSaveEvent,\n\t\t\t\tsaver: PostEditorAwarenessState,\n\t\t\t\tprevEvent: PostSaveEvent | null\n\t\t\t) => {\n\t\t\t\tif ( ! postStatus ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Prefer the remote status from Y.Doc (accurate at save time)\n\t\t\t\t// over the local Redux value, which may not have synced yet.\n\t\t\t\tconst effectiveStatus =\n\t\t\t\t\tsaveEvent.postStatus ?? postStatus ?? 'draft';\n\n\t\t\t\t// Use the previous save event's status when available for\n\t\t\t\t// accurate first-publish detection across rapid saves.\n\t\t\t\tconst prevStatus = prevEvent?.postStatus ?? postStatus;\n\t\t\t\tconst isFirstPublish =\n\t\t\t\t\t! (\n\t\t\t\t\t\tprevStatus && PUBLISHED_STATUSES.includes( prevStatus )\n\t\t\t\t\t) && PUBLISHED_STATUSES.includes( effectiveStatus );\n\n\t\t\t\tconst message = getPostUpdatedMessage(\n\t\t\t\t\tsaver.collaboratorInfo.name,\n\t\t\t\t\teffectiveStatus,\n\t\t\t\t\tisFirstPublish\n\t\t\t\t);\n\n\t\t\t\tvoid createNotice( 'info', message, {\n\t\t\t\t\tid: `${ NOTIFICATION_TYPE.COLLAB_POST_UPDATED }-${ saver.collaboratorInfo.id }`,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: false,\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[ createNotice, postStatus ]\n\t\t)\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,qBAA4B;AAC5B,kBAA4B;AAC5B,qBAAsC;AACtC,uBAIO;AACP,yBAA0C;AAK1C,yBAAuB;AACvB,mBAAqC;AAErC,IAAM,EAAE,uBAAuB,wBAAwB,cAAc,QACpE,2BAAQ,4BAAY;AAMrB,IAAM,oBA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A,YACN,eAAe;AAAA,UAChB;AAAA,QACD;AAAA,MACD;AAAA,MACA,CAAE,YAAa;AAAA,IAChB;AAAA,EACD;AAEA;AAAA,IACC;AAAA,IACA;AAAA,QACA;AAAA,MACC,CAAE,iBAA4C;AAC7C,aAAK;AAAA,UACJ;AAAA,cACA;AAAA;AAAA,gBAEC,gBAAI,uBAAwB;AAAA,YAC5B,aAAa,iBAAiB;AAAA,UAC/B;AAAA,UACA;AAAA,YACC,IAAI,GAAI,kBAAkB,kBAAmB,IAAK,aAAa,iBAAiB,EAAG;AAAA,YACnF,MAAM;AAAA,YACN,eAAe;AAAA,UAChB;AAAA,QACD;AAAA,MACD;AAAA,MACA,CAAE,YAAa;AAAA,IAChB;AAAA,EACD;AAEA;AAAA,IACC;AAAA,IACA;AAAA,QACA;AAAA,MACC,CACC,WACA,OACA,cACI;AACJ,YAAK,CAAE,YAAa;AACnB;AAAA,QACD;AAIA,cAAM,kBACL,UAAU,cAAc,cAAc;AAIvC,cAAM,aAAa,WAAW,cAAc;AAC5C,cAAM,iBACL,EACC,cAAc,mBAAmB,SAAU,UAAW,MAClD,mBAAmB,SAAU,eAAgB;AAEnD,cAAM,UAAU;AAAA,UACf,MAAM,iBAAiB;AAAA,UACvB;AAAA,UACA;AAAA,QACD;AAEA,aAAK,aAAc,QAAQ,SAAS;AAAA,UACnC,IAAI,GAAI,kBAAkB,mBAAoB,IAAK,MAAM,iBAAiB,EAAG;AAAA,UAC7E,MAAM;AAAA,UACN,eAAe;AAAA,QAChB,CAAE;AAAA,MACH;AAAA,MACA,CAAE,cAAc,UAAW;AAAA,IAC5B;AAAA,EACD;AACD;",
6
+ "names": ["editorStore", "preferencesStore", "noticesStore"]
7
7
  }
@@ -103,7 +103,8 @@ function EditorInterface({
103
103
  postTypeLabel,
104
104
  stylesPath,
105
105
  showStylebook,
106
- isRevisionsMode
106
+ isRevisionsMode,
107
+ showDiff
107
108
  } = (0, import_data.useSelect)((select) => {
108
109
  const { get } = select(import_preferences.store);
109
110
  const {
@@ -115,7 +116,8 @@ function EditorInterface({
115
116
  const {
116
117
  getStylesPath,
117
118
  getShowStylebook,
118
- isRevisionsMode: _isRevisionsMode
119
+ isRevisionsMode: _isRevisionsMode,
120
+ isShowingRevisionDiff
119
121
  } = (0, import_lock_unlock.unlock)(select(import_store.store));
120
122
  const editorSettings = getEditorSettings();
121
123
  let _mode = select(import_store.store).getEditorMode();
@@ -138,9 +140,11 @@ function EditorInterface({
138
140
  stylesPath: getStylesPath(),
139
141
  showStylebook: getShowStylebook(),
140
142
  isAttachment: getCurrentPostType() === "attachment" && window?.__experimentalMediaEditor,
141
- isRevisionsMode: _isRevisionsMode()
143
+ isRevisionsMode: _isRevisionsMode(),
144
+ showDiff: isShowingRevisionDiff()
142
145
  };
143
146
  }, []);
147
+ const { setShowRevisionDiff } = (0, import_lock_unlock.unlock)((0, import_data.useDispatch)(import_store.store));
144
148
  (0, import_use_collaborator_notifications.useCollaboratorNotifications)(postId, postType);
145
149
  const isLargeViewport = (0, import_compose.useViewportMatch)("medium");
146
150
  const secondarySidebarLabel = isListViewOpened ? (0, import_i18n.__)("Document Overview") : (0, import_i18n.__)("Block Library");
@@ -157,7 +161,6 @@ function EditorInterface({
157
161
  },
158
162
  [entitiesSavedStatesCallback]
159
163
  );
160
- const [showDiff, setShowDiff] = (0, import_element.useState)(true);
161
164
  if (isRevisionsMode) {
162
165
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
166
  import_interface.InterfaceSkeleton,
@@ -168,10 +171,10 @@ function EditorInterface({
168
171
  import_post_revisions_preview.RevisionsHeader,
169
172
  {
170
173
  showDiff,
171
- onToggleDiff: () => setShowDiff(!showDiff)
174
+ onToggleDiff: () => setShowRevisionDiff(!showDiff)
172
175
  }
173
176
  ),
174
- content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_post_revisions_preview.RevisionsCanvas, { showDiff }),
177
+ content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_post_revisions_preview.RevisionsCanvas, {}),
175
178
  sidebar: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_interface.ComplementaryArea.Slot, { scope: "core" })
176
179
  }
177
180
  );