@wordpress/editor 14.41.2-next.v.202603161435.0 → 14.43.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 (311) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/components/collaborators-overlay/compute-selection.cjs +10 -10
  3. package/build/components/collaborators-overlay/compute-selection.cjs.map +2 -2
  4. package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
  5. package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
  6. package/build/components/collaborators-overlay/index.cjs +7 -2
  7. package/build/components/collaborators-overlay/index.cjs.map +2 -2
  8. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
  9. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/overlay.cjs +42 -1
  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-render-cursors.cjs +1 -1
  15. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
  16. package/build/components/collaborators-presence/index.cjs +14 -4
  17. package/build/components/collaborators-presence/index.cjs.map +2 -2
  18. package/build/components/collaborators-presence/list.cjs +20 -4
  19. package/build/components/collaborators-presence/list.cjs.map +2 -2
  20. package/build/components/post-card-panel/index.cjs +4 -15
  21. package/build/components/post-card-panel/index.cjs.map +2 -2
  22. package/build/components/post-content-information/index.cjs +10 -13
  23. package/build/components/post-content-information/index.cjs.map +2 -2
  24. package/build/components/post-locked-modal/index.cjs +16 -3
  25. package/build/components/post-locked-modal/index.cjs.map +2 -2
  26. package/build/components/post-revisions-panel/index.cjs +164 -0
  27. package/build/components/post-revisions-panel/index.cjs.map +7 -0
  28. package/build/components/post-revisions-preview/block-diff.cjs +39 -11
  29. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  30. package/build/components/post-revisions-preview/diff-markers.cjs +2 -2
  31. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  32. package/build/components/post-revisions-preview/revisions-canvas.cjs +1 -1
  33. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +2 -2
  34. package/build/components/post-revisions-preview/revisions-slider.cjs +24 -5
  35. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  36. package/build/components/post-template/block-theme.cjs +7 -4
  37. package/build/components/post-template/block-theme.cjs.map +2 -2
  38. package/build/components/post-template/create-new-template-modal.cjs +39 -46
  39. package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
  40. package/build/components/post-template/hooks.cjs +91 -8
  41. package/build/components/post-template/hooks.cjs.map +2 -2
  42. package/build/components/post-template/panel.cjs +5 -42
  43. package/build/components/post-template/panel.cjs.map +3 -3
  44. package/build/components/post-template/swap-template-button.cjs +31 -20
  45. package/build/components/post-template/swap-template-button.cjs.map +2 -2
  46. package/build/components/preferences-modal/index.cjs +35 -27
  47. package/build/components/preferences-modal/index.cjs.map +2 -2
  48. package/build/components/provider/use-block-editor-settings.cjs +2 -0
  49. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  50. package/build/components/revision-block-diff/index.cjs +61 -0
  51. package/build/components/revision-block-diff/index.cjs.map +7 -0
  52. package/build/components/revision-diff-panel/index.cjs +68 -0
  53. package/build/components/revision-diff-panel/index.cjs.map +7 -0
  54. package/build/components/revision-fields-diff/index.cjs +96 -0
  55. package/build/components/revision-fields-diff/index.cjs.map +7 -0
  56. package/build/components/sidebar/dataform-post-summary.cjs +25 -55
  57. package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
  58. package/build/components/sidebar/index.cjs +30 -23
  59. package/build/components/sidebar/index.cjs.map +3 -3
  60. package/build/components/sidebar/post-revision-summary.cjs +74 -0
  61. package/build/components/sidebar/post-revision-summary.cjs.map +7 -0
  62. package/build/components/sidebar/post-summary.cjs +35 -42
  63. package/build/components/sidebar/post-summary.cjs.map +3 -3
  64. package/build/components/style-book/index.cjs +4 -3
  65. package/build/components/style-book/index.cjs.map +2 -2
  66. package/build/components/{sync-connection-modal → sync-connection-error-modal}/index.cjs +89 -80
  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-actions-panel/block-theme-content.cjs +188 -0
  71. package/build/components/template-actions-panel/block-theme-content.cjs.map +7 -0
  72. package/build/components/template-actions-panel/classic-theme-content.cjs +159 -0
  73. package/build/components/template-actions-panel/classic-theme-content.cjs.map +7 -0
  74. package/build/components/template-actions-panel/index.cjs +59 -0
  75. package/build/components/template-actions-panel/index.cjs.map +7 -0
  76. package/build/components/visual-editor/index.cjs +2 -2
  77. package/build/components/visual-editor/index.cjs.map +2 -2
  78. package/build/dataviews/store/private-actions.cjs +2 -0
  79. package/build/dataviews/store/private-actions.cjs.map +2 -2
  80. package/build/store/actions.cjs +1 -3
  81. package/build/store/actions.cjs.map +2 -2
  82. package/build/store/private-actions.cjs +21 -2
  83. package/build/store/private-actions.cjs.map +2 -2
  84. package/build/store/private-selectors.cjs +40 -15
  85. package/build/store/private-selectors.cjs.map +2 -2
  86. package/build/utils/media-finalize/index.cjs +43 -0
  87. package/build/utils/media-finalize/index.cjs.map +7 -0
  88. package/build/utils/sync-error-messages.cjs +29 -16
  89. package/build/utils/sync-error-messages.cjs.map +3 -3
  90. package/build-module/components/collaborators-overlay/compute-selection.mjs +10 -10
  91. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +2 -2
  92. package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
  93. package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
  94. package/build-module/components/collaborators-overlay/index.mjs +7 -2
  95. package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
  96. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
  97. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
  98. package/build-module/components/collaborators-overlay/overlay.mjs +43 -2
  99. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  100. package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
  101. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
  102. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -1
  103. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  104. package/build-module/components/collaborators-presence/index.mjs +14 -4
  105. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  106. package/build-module/components/collaborators-presence/list.mjs +20 -4
  107. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  108. package/build-module/components/post-card-panel/index.mjs +6 -17
  109. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  110. package/build-module/components/post-content-information/index.mjs +6 -13
  111. package/build-module/components/post-content-information/index.mjs.map +2 -2
  112. package/build-module/components/post-locked-modal/index.mjs +16 -3
  113. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  114. package/build-module/components/post-revisions-panel/index.mjs +139 -0
  115. package/build-module/components/post-revisions-panel/index.mjs.map +7 -0
  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 +1 -1
  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 +24 -5
  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/create-new-template-modal.mjs +39 -46
  127. package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
  128. package/build-module/components/post-template/hooks.mjs +90 -8
  129. package/build-module/components/post-template/hooks.mjs.map +2 -2
  130. package/build-module/components/post-template/panel.mjs +5 -42
  131. package/build-module/components/post-template/panel.mjs.map +2 -2
  132. package/build-module/components/post-template/swap-template-button.mjs +27 -20
  133. package/build-module/components/post-template/swap-template-button.mjs.map +2 -2
  134. package/build-module/components/preferences-modal/index.mjs +35 -27
  135. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  136. package/build-module/components/provider/use-block-editor-settings.mjs +2 -0
  137. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  138. package/build-module/components/revision-block-diff/index.mjs +30 -0
  139. package/build-module/components/revision-block-diff/index.mjs.map +7 -0
  140. package/build-module/components/revision-diff-panel/index.mjs +37 -0
  141. package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
  142. package/build-module/components/revision-fields-diff/index.mjs +65 -0
  143. package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
  144. package/build-module/components/sidebar/dataform-post-summary.mjs +25 -55
  145. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  146. package/build-module/components/sidebar/index.mjs +30 -23
  147. package/build-module/components/sidebar/index.mjs.map +2 -2
  148. package/build-module/components/sidebar/post-revision-summary.mjs +43 -0
  149. package/build-module/components/sidebar/post-revision-summary.mjs.map +7 -0
  150. package/build-module/components/sidebar/post-summary.mjs +31 -42
  151. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  152. package/build-module/components/style-book/index.mjs +4 -3
  153. package/build-module/components/style-book/index.mjs.map +2 -2
  154. package/build-module/components/sync-connection-error-modal/index.mjs +177 -0
  155. package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
  156. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +36 -0
  157. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
  158. package/build-module/components/template-actions-panel/block-theme-content.mjs +167 -0
  159. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +7 -0
  160. package/build-module/components/template-actions-panel/classic-theme-content.mjs +138 -0
  161. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +7 -0
  162. package/build-module/components/template-actions-panel/index.mjs +28 -0
  163. package/build-module/components/template-actions-panel/index.mjs.map +7 -0
  164. package/build-module/components/visual-editor/index.mjs +2 -2
  165. package/build-module/components/visual-editor/index.mjs.map +2 -2
  166. package/build-module/dataviews/store/private-actions.mjs +5 -1
  167. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  168. package/build-module/store/actions.mjs +1 -3
  169. package/build-module/store/actions.mjs.map +2 -2
  170. package/build-module/store/private-actions.mjs +21 -2
  171. package/build-module/store/private-actions.mjs.map +2 -2
  172. package/build-module/store/private-selectors.mjs +40 -15
  173. package/build-module/store/private-selectors.mjs.map +2 -2
  174. package/build-module/utils/media-finalize/index.mjs +12 -0
  175. package/build-module/utils/media-finalize/index.mjs.map +7 -0
  176. package/build-module/utils/sync-error-messages.mjs +24 -16
  177. package/build-module/utils/sync-error-messages.mjs.map +3 -3
  178. package/build-style/style-rtl.css +135 -50
  179. package/build-style/style.css +135 -50
  180. package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
  181. package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
  182. package/build-types/components/collaborators-overlay/index.d.ts +7 -4
  183. package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
  184. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
  185. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
  186. package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
  187. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  188. package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
  189. package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
  190. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  191. package/build-types/components/collaborators-presence/list.d.ts +4 -1
  192. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  193. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  194. package/build-types/components/post-content-information/index.d.ts +4 -1
  195. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  196. package/build-types/components/post-locked-modal/index.d.ts +2 -2
  197. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  198. package/build-types/components/post-revisions-panel/index.d.ts +2 -0
  199. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
  200. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  201. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  202. package/build-types/components/post-template/block-theme.d.ts +1 -3
  203. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  204. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  205. package/build-types/components/post-template/hooks.d.ts +2 -1
  206. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  207. package/build-types/components/post-template/panel.d.ts.map +1 -1
  208. package/build-types/components/post-template/swap-template-button.d.ts +4 -0
  209. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  210. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  211. package/build-types/components/revision-block-diff/index.d.ts +6 -0
  212. package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
  213. package/build-types/components/revision-diff-panel/index.d.ts +14 -0
  214. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
  215. package/build-types/components/revision-fields-diff/index.d.ts +6 -0
  216. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
  217. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  218. package/build-types/components/sidebar/index.d.ts.map +1 -1
  219. package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
  220. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
  221. package/build-types/components/sidebar/post-summary.d.ts +3 -0
  222. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  223. package/build-types/components/style-book/index.d.ts +2 -1
  224. package/build-types/components/style-book/index.d.ts.map +1 -1
  225. package/build-types/components/sync-connection-error-modal/index.d.ts +22 -0
  226. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
  227. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
  228. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
  229. package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
  230. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
  231. package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
  232. package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
  233. package/build-types/components/template-actions-panel/index.d.ts +2 -0
  234. package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
  235. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  236. package/build-types/store/actions.d.ts.map +1 -1
  237. package/build-types/store/private-actions.d.ts.map +1 -1
  238. package/build-types/store/private-selectors.d.ts.map +1 -1
  239. package/build-types/utils/media-finalize/index.d.ts +2 -0
  240. package/build-types/utils/media-finalize/index.d.ts.map +1 -0
  241. package/build-types/utils/sync-error-messages.d.ts +17 -3
  242. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  243. package/package.json +45 -44
  244. package/src/components/collaborators-overlay/compute-selection.ts +13 -13
  245. package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
  246. package/src/components/collaborators-overlay/index.tsx +12 -4
  247. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +1 -1
  248. package/src/components/collaborators-overlay/overlay.tsx +64 -1
  249. package/src/components/collaborators-overlay/timing-utils.ts +30 -0
  250. package/src/components/collaborators-overlay/use-render-cursors.ts +1 -1
  251. package/src/components/collaborators-presence/index.tsx +9 -1
  252. package/src/components/collaborators-presence/list.tsx +25 -1
  253. package/src/components/post-card-panel/index.js +7 -21
  254. package/src/components/post-content-information/index.js +5 -16
  255. package/src/components/post-locked-modal/index.js +21 -3
  256. package/src/components/post-revisions-panel/index.js +151 -0
  257. package/src/components/post-revisions-panel/style.scss +16 -0
  258. package/src/components/post-revisions-preview/block-diff.js +59 -20
  259. package/src/components/post-revisions-preview/diff-markers.js +2 -2
  260. package/src/components/post-revisions-preview/revisions-canvas.js +1 -1
  261. package/src/components/post-revisions-preview/revisions-slider.js +29 -7
  262. package/src/components/post-revisions-preview/test/block-diff.js +69 -31
  263. package/src/components/post-template/block-theme.js +4 -1
  264. package/src/components/post-template/create-new-template-modal.js +1 -4
  265. package/src/components/post-template/hooks.js +107 -9
  266. package/src/components/post-template/panel.js +5 -59
  267. package/src/components/post-template/style.scss +0 -6
  268. package/src/components/post-template/swap-template-button.js +30 -21
  269. package/src/components/preferences-modal/index.js +37 -25
  270. package/src/components/provider/use-block-editor-settings.js +2 -0
  271. package/src/components/revision-block-diff/index.js +39 -0
  272. package/src/components/revision-diff-panel/index.js +59 -0
  273. package/src/components/revision-diff-panel/style.scss +13 -0
  274. package/src/components/revision-fields-diff/index.js +91 -0
  275. package/src/components/sidebar/dataform-post-summary.js +45 -68
  276. package/src/components/sidebar/index.js +35 -22
  277. package/src/components/sidebar/post-revision-summary.js +50 -0
  278. package/src/components/sidebar/post-summary.js +22 -40
  279. package/src/components/sidebar/style.scss +7 -0
  280. package/src/components/style-book/index.js +4 -2
  281. package/src/components/sync-connection-error-modal/index.tsx +265 -0
  282. package/src/components/sync-connection-error-modal/style.scss +14 -0
  283. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +57 -0
  284. package/src/components/template-actions-panel/block-theme-content.js +196 -0
  285. package/src/components/template-actions-panel/classic-theme-content.js +170 -0
  286. package/src/components/template-actions-panel/index.js +32 -0
  287. package/src/components/template-actions-panel/style.scss +39 -0
  288. package/src/components/visual-editor/index.js +2 -2
  289. package/src/dataviews/store/private-actions.ts +6 -0
  290. package/src/store/actions.js +1 -4
  291. package/src/store/private-actions.js +24 -3
  292. package/src/store/private-selectors.js +46 -16
  293. package/src/style.scss +4 -1
  294. package/src/utils/media-finalize/index.js +11 -0
  295. package/src/utils/media-finalize/test/index.js +34 -0
  296. package/src/utils/sync-error-messages.ts +72 -0
  297. package/src/utils/test/sync-error-messages.js +9 -32
  298. package/build/components/sync-connection-modal/index.cjs.map +0 -7
  299. package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +0 -7
  300. package/build-module/components/sync-connection-modal/index.mjs +0 -170
  301. package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
  302. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +0 -49
  303. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +0 -7
  304. package/build-types/components/sync-connection-modal/index.d.ts +0 -8
  305. package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
  306. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +0 -9
  307. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +0 -1
  308. package/src/components/sync-connection-modal/index.js +0 -206
  309. package/src/components/sync-connection-modal/style.scss +0 -14
  310. package/src/components/sync-connection-modal/use-retry-countdown.js +0 -70
  311. package/src/utils/sync-error-messages.js +0 -58
package/CHANGELOG.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 14.41.1-next.0 (2026-03-16)
5
+ ## 14.43.0 (2026-04-01)
6
+
7
+ ## 14.42.0 (2026-03-18)
6
8
 
7
9
  ### Bug Fixes
8
10
 
@@ -46,7 +46,7 @@ function computeCursorOnly(start, overlayContext) {
46
46
  );
47
47
  return {
48
48
  coords: (0, import_cursor_dom_utils.getCursorPosition)(
49
- start.textIndex,
49
+ start.richTextOffset,
50
50
  blockElement,
51
51
  overlayContext.editorDocument,
52
52
  overlayContext.overlayRect
@@ -54,7 +54,7 @@ function computeCursorOnly(start, overlayContext) {
54
54
  };
55
55
  }
56
56
  function computeTextSelection(selection, start, end, overlayContext) {
57
- if (!start.localClientId || !end.localClientId || start.textIndex === null || end.textIndex === null) {
57
+ if (!start.localClientId || !end.localClientId || start.richTextOffset === null || end.richTextOffset === null) {
58
58
  return {};
59
59
  }
60
60
  const isReverse = selection.selectionDirection === import_core_data.SelectionDirection.Backward;
@@ -73,7 +73,7 @@ function computeTextSelection(selection, start, end, overlayContext) {
73
73
  if (allRects.length > 0) {
74
74
  return {
75
75
  coords: (0, import_cursor_dom_utils.getCursorPosition)(
76
- activeEnd.textIndex,
76
+ activeEnd.richTextOffset,
77
77
  activeEndBlock,
78
78
  overlayContext.editorDocument,
79
79
  overlayContext.overlayRect
@@ -86,7 +86,7 @@ function computeTextSelection(selection, start, end, overlayContext) {
86
86
  );
87
87
  return {
88
88
  coords: (0, import_cursor_dom_utils.getCursorPosition)(
89
- start.textIndex,
89
+ start.richTextOffset,
90
90
  startBlock,
91
91
  overlayContext.editorDocument,
92
92
  overlayContext.overlayRect
@@ -97,14 +97,14 @@ function computeSingleBlockRects(start, end, overlayContext) {
97
97
  const blockElement = overlayContext.editorDocument.querySelector(
98
98
  `[data-block="${start.localClientId}"]`
99
99
  );
100
- if (!blockElement || start.textIndex === null || end.textIndex === null) {
100
+ if (!blockElement || start.richTextOffset === null || end.richTextOffset === null) {
101
101
  return { rects: [], blockElement: null };
102
102
  }
103
103
  return {
104
104
  rects: (0, import_cursor_dom_utils.getSelectionRects)(
105
105
  blockElement,
106
- start.textIndex,
107
- end.textIndex,
106
+ start.richTextOffset,
107
+ end.richTextOffset,
108
108
  overlayContext.editorDocument,
109
109
  overlayContext.overlayRect
110
110
  ) ?? [],
@@ -125,7 +125,7 @@ function computeMultiBlockRects(start, end, overlayContext) {
125
125
  docLast = start;
126
126
  [firstBlock, lastBlock] = [lastBlock, firstBlock];
127
127
  }
128
- if (!firstBlock || !lastBlock || docFirst.textIndex === null || docLast.textIndex === null || !docFirst.localClientId || !docLast.localClientId) {
128
+ if (!firstBlock || !lastBlock || docFirst.richTextOffset === null || docLast.richTextOffset === null || !docFirst.localClientId || !docLast.localClientId) {
129
129
  return {
130
130
  rects: [],
131
131
  firstBlock: null,
@@ -136,7 +136,7 @@ function computeMultiBlockRects(start, end, overlayContext) {
136
136
  const allRects = [];
137
137
  const startRects = (0, import_cursor_dom_utils.getSelectionRects)(
138
138
  firstBlock,
139
- docFirst.textIndex,
139
+ docFirst.richTextOffset,
140
140
  Number.MAX_SAFE_INTEGER,
141
141
  overlayContext.editorDocument,
142
142
  overlayContext.overlayRect
@@ -160,7 +160,7 @@ function computeMultiBlockRects(start, end, overlayContext) {
160
160
  const endRects = (0, import_cursor_dom_utils.getSelectionRects)(
161
161
  lastBlock,
162
162
  0,
163
- docLast.textIndex,
163
+ docLast.richTextOffset,
164
164
  overlayContext.editorDocument,
165
165
  overlayContext.overlayRect
166
166
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-overlay/compute-selection.ts"],
4
- "sourcesContent": ["import { SelectionDirection, SelectionType } from '@wordpress/core-data';\nimport type { ResolvedSelection } from '@wordpress/core-data';\n\nimport {\n\tgetCursorPosition,\n\tgetSelectionRects,\n\tgetFullBlockSelectionRects,\n\tgetBlocksBetween,\n\tisNodeBefore,\n} from './cursor-dom-utils';\nimport type { CursorCoords, SelectionRect } from './cursor-dom-utils';\n\n/** Common parameters passed to cursor/selection computation helpers. */\ninterface OverlayContext {\n\teditorDocument: Document;\n\toverlayRect: DOMRect;\n}\n\n/** Selection rects and the resolved block element for a single-block selection. */\ninterface SingleBlockResult {\n\trects: SelectionRect[];\n\tblockElement: HTMLElement | null;\n}\n\n/** Selection rects and the resolved block elements for a multi-block selection. */\ninterface MultiBlockResult {\n\trects: SelectionRect[];\n\tfirstBlock: HTMLElement | null;\n\tlastBlock: HTMLElement | null;\n\tfirstBlockClientId: string | null;\n}\n\n/** Result of computing visual cursor/selection state for a single user. */\nexport interface SelectionVisual {\n\tcoords?: CursorCoords | null;\n\tselectionRects?: SelectionRect[];\n}\n\n/**\n * Compute cursor coords and optional selection rects for a single user's selection.\n *\n * @param selection - The selection state from the awareness layer.\n * @param start - Start position (block clientId + text index).\n * @param end - End position (only for range selections).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Cursor coordinates and optional selection rectangles.\n */\nexport function computeSelectionVisual(\n\tselection: any,\n\tstart: ResolvedSelection,\n\tend: ResolvedSelection | undefined,\n\toverlayContext: OverlayContext\n): SelectionVisual {\n\tif (\n\t\tselection.type === SelectionType.None ||\n\t\tselection.type === SelectionType.WholeBlock\n\t) {\n\t\treturn {};\n\t}\n\n\tif ( selection.type === SelectionType.Cursor ) {\n\t\treturn computeCursorOnly( start, overlayContext );\n\t}\n\n\t// SelectionInOneBlock or SelectionInMultipleBlocks.\n\tif ( ! end ) {\n\t\treturn {};\n\t}\n\treturn computeTextSelection( selection, start, end, overlayContext );\n}\n\n/**\n * Compute cursor coordinates for a simple cursor (no highlighted text).\n *\n * @param start - Cursor position (block clientId + text index).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Cursor coordinates.\n */\nfunction computeCursorOnly(\n\tstart: ResolvedSelection,\n\toverlayContext: OverlayContext\n): SelectionVisual {\n\tif ( ! start.localClientId ) {\n\t\treturn {};\n\t}\n\tconst blockElement =\n\t\toverlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t\t`[data-block=\"${ start.localClientId }\"]`\n\t\t);\n\treturn {\n\t\tcoords: getCursorPosition(\n\t\t\tstart.textIndex,\n\t\t\tblockElement,\n\t\t\toverlayContext.editorDocument,\n\t\t\toverlayContext.overlayRect\n\t\t),\n\t};\n}\n\n/**\n * Compute cursor coordinates and selection highlight rects for a text selection\n * (single-block or multi-block).\n *\n * @param selection - The selection state.\n * @param start - Start position (block clientId + text index).\n * @param end - End position (block clientId + text index).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Cursor coordinates and optional selection rectangles.\n */\nfunction computeTextSelection(\n\tselection: any,\n\tstart: ResolvedSelection,\n\tend: ResolvedSelection,\n\toverlayContext: OverlayContext\n): SelectionVisual {\n\tif (\n\t\t! start.localClientId ||\n\t\t! end.localClientId ||\n\t\tstart.textIndex === null ||\n\t\tend.textIndex === null\n\t) {\n\t\treturn {};\n\t}\n\n\tconst isReverse =\n\t\tselection.selectionDirection === SelectionDirection.Backward;\n\tconst activeEnd = isReverse ? start : end;\n\n\tlet allRects: SelectionRect[];\n\tlet activeEndBlock: HTMLElement | null = null;\n\n\tif ( selection.type === SelectionType.SelectionInOneBlock ) {\n\t\tconst result = computeSingleBlockRects( start, end, overlayContext );\n\t\tallRects = result.rects;\n\t\t// Single block: start and end share the same block element.\n\t\tactiveEndBlock = result.blockElement;\n\t} else {\n\t\tconst result = computeMultiBlockRects( start, end, overlayContext );\n\t\tallRects = result.rects;\n\t\t// Pick the block element that matches the active end.\n\t\tactiveEndBlock =\n\t\t\tactiveEnd.localClientId === result.firstBlockClientId\n\t\t\t\t? result.firstBlock\n\t\t\t\t: result.lastBlock;\n\t}\n\n\tif ( allRects.length > 0 ) {\n\t\treturn {\n\t\t\tcoords: getCursorPosition(\n\t\t\t\tactiveEnd.textIndex,\n\t\t\t\tactiveEndBlock,\n\t\t\t\toverlayContext.editorDocument,\n\t\t\t\toverlayContext.overlayRect\n\t\t\t),\n\t\t\tselectionRects: allRects,\n\t\t};\n\t}\n\n\t// Fallback: cursor at start position only.\n\tconst startBlock =\n\t\toverlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t\t`[data-block=\"${ start.localClientId }\"]`\n\t\t);\n\n\treturn {\n\t\tcoords: getCursorPosition(\n\t\t\tstart.textIndex,\n\t\t\tstartBlock,\n\t\t\toverlayContext.editorDocument,\n\t\t\toverlayContext.overlayRect\n\t\t),\n\t};\n}\n\n/**\n * Compute selection rects for a selection within a single block.\n *\n * @param start - Start position (block clientId + text index).\n * @param end - End position (block clientId + text index).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Array of selection rectangles.\n */\nfunction computeSingleBlockRects(\n\tstart: ResolvedSelection,\n\tend: ResolvedSelection,\n\toverlayContext: OverlayContext\n): SingleBlockResult {\n\tconst blockElement =\n\t\toverlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t\t`[data-block=\"${ start.localClientId }\"]`\n\t\t);\n\tif (\n\t\t! blockElement ||\n\t\tstart.textIndex === null ||\n\t\tend.textIndex === null\n\t) {\n\t\treturn { rects: [], blockElement: null };\n\t}\n\treturn {\n\t\trects:\n\t\t\tgetSelectionRects(\n\t\t\t\tblockElement,\n\t\t\t\tstart.textIndex,\n\t\t\t\tend.textIndex,\n\t\t\t\toverlayContext.editorDocument,\n\t\t\t\toverlayContext.overlayRect\n\t\t\t) ?? [],\n\t\tblockElement,\n\t};\n}\n\n/**\n * Compute selection rects for a selection spanning multiple blocks.\n *\n * Normalizes to document order \u2014 for backward selections the block editor\n * reports start after end.\n *\n * @param start - Start position (block clientId + text index).\n * @param end - End position (block clientId + text index).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Array of selection rectangles.\n */\nfunction computeMultiBlockRects(\n\tstart: ResolvedSelection,\n\tend: ResolvedSelection,\n\toverlayContext: OverlayContext\n): MultiBlockResult {\n\tlet docFirst = start;\n\tlet docLast = end;\n\tlet firstBlock = overlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t`[data-block=\"${ docFirst.localClientId }\"]`\n\t);\n\tlet lastBlock = overlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t`[data-block=\"${ docLast.localClientId }\"]`\n\t);\n\n\t// Swap to document order if needed.\n\tif ( firstBlock && lastBlock && isNodeBefore( lastBlock, firstBlock ) ) {\n\t\tdocFirst = end;\n\t\tdocLast = start;\n\t\t[ firstBlock, lastBlock ] = [ lastBlock, firstBlock ];\n\t}\n\n\tif (\n\t\t! firstBlock ||\n\t\t! lastBlock ||\n\t\tdocFirst.textIndex === null ||\n\t\tdocLast.textIndex === null ||\n\t\t! docFirst.localClientId ||\n\t\t! docLast.localClientId\n\t) {\n\t\treturn {\n\t\t\trects: [],\n\t\t\tfirstBlock: null,\n\t\t\tlastBlock: null,\n\t\t\tfirstBlockClientId: null,\n\t\t};\n\t}\n\n\tconst allRects: SelectionRect[] = [];\n\n\t// First block: from start offset to end of block.\n\tconst startRects = getSelectionRects(\n\t\tfirstBlock,\n\t\tdocFirst.textIndex,\n\t\tNumber.MAX_SAFE_INTEGER,\n\t\toverlayContext.editorDocument,\n\t\toverlayContext.overlayRect\n\t);\n\tif ( startRects ) {\n\t\tallRects.push( ...startRects );\n\t}\n\n\t// Intermediate blocks: full content.\n\tconst intermediateBlocks = getBlocksBetween(\n\t\tdocFirst.localClientId,\n\t\tdocLast.localClientId,\n\t\toverlayContext.editorDocument\n\t);\n\tfor ( const intermediateBlock of intermediateBlocks ) {\n\t\tconst rects = getFullBlockSelectionRects(\n\t\t\tintermediateBlock,\n\t\t\toverlayContext.editorDocument,\n\t\t\toverlayContext.overlayRect\n\t\t);\n\t\tallRects.push( ...rects );\n\t}\n\n\t// Last block: from 0 to end offset.\n\tconst endRects = getSelectionRects(\n\t\tlastBlock,\n\t\t0,\n\t\tdocLast.textIndex,\n\t\toverlayContext.editorDocument,\n\t\toverlayContext.overlayRect\n\t);\n\tif ( endRects ) {\n\t\tallRects.push( ...endRects );\n\t}\n\n\treturn {\n\t\trects: allRects,\n\t\tfirstBlock,\n\t\tlastBlock,\n\t\tfirstBlockClientId: docFirst.localClientId,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAkD;AAGlD,8BAMO;AAsCA,SAAS,uBACf,WACA,OACA,KACA,gBACkB;AAClB,MACC,UAAU,SAAS,+BAAc,QACjC,UAAU,SAAS,+BAAc,YAChC;AACD,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,UAAU,SAAS,+BAAc,QAAS;AAC9C,WAAO,kBAAmB,OAAO,cAAe;AAAA,EACjD;AAGA,MAAK,CAAE,KAAM;AACZ,WAAO,CAAC;AAAA,EACT;AACA,SAAO,qBAAsB,WAAW,OAAO,KAAK,cAAe;AACpE;AASA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MACb;AAAA,MACA,eAAe;AAAA,MACf,eAAe;AAAA,IAChB;AACA,aAAS,KAAM,GAAG,KAAM;AAAA,EACzB;AAGA,QAAM,eAAW;AAAA,IAChB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,eAAe;AAAA,EAChB;AACA,MAAK,UAAW;AACf,aAAS,KAAM,GAAG,QAAS;AAAA,EAC5B;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,oBAAoB,SAAS;AAAA,EAC9B;AACD;",
4
+ "sourcesContent": ["import { SelectionDirection, SelectionType } from '@wordpress/core-data';\nimport type { ResolvedSelection } from '@wordpress/core-data';\n\nimport {\n\tgetCursorPosition,\n\tgetSelectionRects,\n\tgetFullBlockSelectionRects,\n\tgetBlocksBetween,\n\tisNodeBefore,\n} from './cursor-dom-utils';\nimport type { CursorCoords, SelectionRect } from './cursor-dom-utils';\n\n/** Common parameters passed to cursor/selection computation helpers. */\ninterface OverlayContext {\n\teditorDocument: Document;\n\toverlayRect: DOMRect;\n}\n\n/** Selection rects and the resolved block element for a single-block selection. */\ninterface SingleBlockResult {\n\trects: SelectionRect[];\n\tblockElement: HTMLElement | null;\n}\n\n/** Selection rects and the resolved block elements for a multi-block selection. */\ninterface MultiBlockResult {\n\trects: SelectionRect[];\n\tfirstBlock: HTMLElement | null;\n\tlastBlock: HTMLElement | null;\n\tfirstBlockClientId: string | null;\n}\n\n/** Result of computing visual cursor/selection state for a single user. */\nexport interface SelectionVisual {\n\tcoords?: CursorCoords | null;\n\tselectionRects?: SelectionRect[];\n}\n\n/**\n * Compute cursor coords and optional selection rects for a single user's selection.\n *\n * @param selection - The selection state from the awareness layer.\n * @param start - Start position (block clientId + text index).\n * @param end - End position (only for range selections).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Cursor coordinates and optional selection rectangles.\n */\nexport function computeSelectionVisual(\n\tselection: any,\n\tstart: ResolvedSelection,\n\tend: ResolvedSelection | undefined,\n\toverlayContext: OverlayContext\n): SelectionVisual {\n\tif (\n\t\tselection.type === SelectionType.None ||\n\t\tselection.type === SelectionType.WholeBlock\n\t) {\n\t\treturn {};\n\t}\n\n\tif ( selection.type === SelectionType.Cursor ) {\n\t\treturn computeCursorOnly( start, overlayContext );\n\t}\n\n\t// SelectionInOneBlock or SelectionInMultipleBlocks.\n\tif ( ! end ) {\n\t\treturn {};\n\t}\n\treturn computeTextSelection( selection, start, end, overlayContext );\n}\n\n/**\n * Compute cursor coordinates for a simple cursor (no highlighted text).\n *\n * @param start - Cursor position (block clientId + text index).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Cursor coordinates.\n */\nfunction computeCursorOnly(\n\tstart: ResolvedSelection,\n\toverlayContext: OverlayContext\n): SelectionVisual {\n\tif ( ! start.localClientId ) {\n\t\treturn {};\n\t}\n\tconst blockElement =\n\t\toverlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t\t`[data-block=\"${ start.localClientId }\"]`\n\t\t);\n\treturn {\n\t\tcoords: getCursorPosition(\n\t\t\tstart.richTextOffset,\n\t\t\tblockElement,\n\t\t\toverlayContext.editorDocument,\n\t\t\toverlayContext.overlayRect\n\t\t),\n\t};\n}\n\n/**\n * Compute cursor coordinates and selection highlight rects for a text selection\n * (single-block or multi-block).\n *\n * @param selection - The selection state.\n * @param start - Start position (block clientId + text index).\n * @param end - End position (block clientId + text index).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Cursor coordinates and optional selection rectangles.\n */\nfunction computeTextSelection(\n\tselection: any,\n\tstart: ResolvedSelection,\n\tend: ResolvedSelection,\n\toverlayContext: OverlayContext\n): SelectionVisual {\n\tif (\n\t\t! start.localClientId ||\n\t\t! end.localClientId ||\n\t\tstart.richTextOffset === null ||\n\t\tend.richTextOffset === null\n\t) {\n\t\treturn {};\n\t}\n\n\tconst isReverse =\n\t\tselection.selectionDirection === SelectionDirection.Backward;\n\tconst activeEnd = isReverse ? start : end;\n\n\tlet allRects: SelectionRect[];\n\tlet activeEndBlock: HTMLElement | null = null;\n\n\tif ( selection.type === SelectionType.SelectionInOneBlock ) {\n\t\tconst result = computeSingleBlockRects( start, end, overlayContext );\n\t\tallRects = result.rects;\n\t\t// Single block: start and end share the same block element.\n\t\tactiveEndBlock = result.blockElement;\n\t} else {\n\t\tconst result = computeMultiBlockRects( start, end, overlayContext );\n\t\tallRects = result.rects;\n\t\t// Pick the block element that matches the active end.\n\t\tactiveEndBlock =\n\t\t\tactiveEnd.localClientId === result.firstBlockClientId\n\t\t\t\t? result.firstBlock\n\t\t\t\t: result.lastBlock;\n\t}\n\n\tif ( allRects.length > 0 ) {\n\t\treturn {\n\t\t\tcoords: getCursorPosition(\n\t\t\t\tactiveEnd.richTextOffset,\n\t\t\t\tactiveEndBlock,\n\t\t\t\toverlayContext.editorDocument,\n\t\t\t\toverlayContext.overlayRect\n\t\t\t),\n\t\t\tselectionRects: allRects,\n\t\t};\n\t}\n\n\t// Fallback: cursor at start position only.\n\tconst startBlock =\n\t\toverlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t\t`[data-block=\"${ start.localClientId }\"]`\n\t\t);\n\n\treturn {\n\t\tcoords: getCursorPosition(\n\t\t\tstart.richTextOffset,\n\t\t\tstartBlock,\n\t\t\toverlayContext.editorDocument,\n\t\t\toverlayContext.overlayRect\n\t\t),\n\t};\n}\n\n/**\n * Compute selection rects for a selection within a single block.\n *\n * @param start - Start position (block clientId + text index).\n * @param end - End position (block clientId + text index).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Array of selection rectangles.\n */\nfunction computeSingleBlockRects(\n\tstart: ResolvedSelection,\n\tend: ResolvedSelection,\n\toverlayContext: OverlayContext\n): SingleBlockResult {\n\tconst blockElement =\n\t\toverlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t\t`[data-block=\"${ start.localClientId }\"]`\n\t\t);\n\tif (\n\t\t! blockElement ||\n\t\tstart.richTextOffset === null ||\n\t\tend.richTextOffset === null\n\t) {\n\t\treturn { rects: [], blockElement: null };\n\t}\n\treturn {\n\t\trects:\n\t\t\tgetSelectionRects(\n\t\t\t\tblockElement,\n\t\t\t\tstart.richTextOffset,\n\t\t\t\tend.richTextOffset,\n\t\t\t\toverlayContext.editorDocument,\n\t\t\t\toverlayContext.overlayRect\n\t\t\t) ?? [],\n\t\tblockElement,\n\t};\n}\n\n/**\n * Compute selection rects for a selection spanning multiple blocks.\n *\n * Normalizes to document order \u2014 for backward selections the block editor\n * reports start after end.\n *\n * @param start - Start position (block clientId + text index).\n * @param end - End position (block clientId + text index).\n * @param overlayContext - Shared editor document / overlay references.\n * @return Array of selection rectangles.\n */\nfunction computeMultiBlockRects(\n\tstart: ResolvedSelection,\n\tend: ResolvedSelection,\n\toverlayContext: OverlayContext\n): MultiBlockResult {\n\tlet docFirst = start;\n\tlet docLast = end;\n\tlet firstBlock = overlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t`[data-block=\"${ docFirst.localClientId }\"]`\n\t);\n\tlet lastBlock = overlayContext.editorDocument.querySelector< HTMLElement >(\n\t\t`[data-block=\"${ docLast.localClientId }\"]`\n\t);\n\n\t// Swap to document order if needed.\n\tif ( firstBlock && lastBlock && isNodeBefore( lastBlock, firstBlock ) ) {\n\t\tdocFirst = end;\n\t\tdocLast = start;\n\t\t[ firstBlock, lastBlock ] = [ lastBlock, firstBlock ];\n\t}\n\n\tif (\n\t\t! firstBlock ||\n\t\t! lastBlock ||\n\t\tdocFirst.richTextOffset === null ||\n\t\tdocLast.richTextOffset === null ||\n\t\t! docFirst.localClientId ||\n\t\t! docLast.localClientId\n\t) {\n\t\treturn {\n\t\t\trects: [],\n\t\t\tfirstBlock: null,\n\t\t\tlastBlock: null,\n\t\t\tfirstBlockClientId: null,\n\t\t};\n\t}\n\n\tconst allRects: SelectionRect[] = [];\n\n\t// First block: from start offset to end of block.\n\tconst startRects = getSelectionRects(\n\t\tfirstBlock,\n\t\tdocFirst.richTextOffset,\n\t\tNumber.MAX_SAFE_INTEGER,\n\t\toverlayContext.editorDocument,\n\t\toverlayContext.overlayRect\n\t);\n\tif ( startRects ) {\n\t\tallRects.push( ...startRects );\n\t}\n\n\t// Intermediate blocks: full content.\n\tconst intermediateBlocks = getBlocksBetween(\n\t\tdocFirst.localClientId,\n\t\tdocLast.localClientId,\n\t\toverlayContext.editorDocument\n\t);\n\tfor ( const intermediateBlock of intermediateBlocks ) {\n\t\tconst rects = getFullBlockSelectionRects(\n\t\t\tintermediateBlock,\n\t\t\toverlayContext.editorDocument,\n\t\t\toverlayContext.overlayRect\n\t\t);\n\t\tallRects.push( ...rects );\n\t}\n\n\t// Last block: from 0 to end offset.\n\tconst endRects = getSelectionRects(\n\t\tlastBlock,\n\t\t0,\n\t\tdocLast.richTextOffset,\n\t\toverlayContext.editorDocument,\n\t\toverlayContext.overlayRect\n\t);\n\tif ( endRects ) {\n\t\tallRects.push( ...endRects );\n\t}\n\n\treturn {\n\t\trects: allRects,\n\t\tfirstBlock,\n\t\tlastBlock,\n\t\tfirstBlockClientId: docFirst.localClientId,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAkD;AAGlD,8BAMO;AAsCA,SAAS,uBACf,WACA,OACA,KACA,gBACkB;AAClB,MACC,UAAU,SAAS,+BAAc,QACjC,UAAU,SAAS,+BAAc,YAChC;AACD,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,UAAU,SAAS,+BAAc,QAAS;AAC9C,WAAO,kBAAmB,OAAO,cAAe;AAAA,EACjD;AAGA,MAAK,CAAE,KAAM;AACZ,WAAO,CAAC;AAAA,EACT;AACA,SAAO,qBAAsB,WAAW,OAAO,KAAK,cAAe;AACpE;AASA,SAAS,kBACR,OACA,gBACkB;AAClB,MAAK,CAAE,MAAM,eAAgB;AAC5B,WAAO,CAAC;AAAA,EACT;AACA,QAAM,eACL,eAAe,eAAe;AAAA,IAC7B,gBAAiB,MAAM,aAAc;AAAA,EACtC;AACD,SAA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AAA,IACR,eAAe;AAAA,IACf,eAAe;AAAA,EAChB;AACA,MAAK,UAAW;AACf,aAAS,KAAM,GAAG,QAAS;AAAA,EAC5B;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA,oBAAoB,SAAS;AAAA,EAC9B;AACD;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/editor/src/components/collaborators-overlay/cursor-registry.ts
21
+ var cursor_registry_exports = {};
22
+ __export(cursor_registry_exports, {
23
+ createCursorRegistry: () => createCursorRegistry
24
+ });
25
+ module.exports = __toCommonJS(cursor_registry_exports);
26
+ function highlightCursor(element, duration) {
27
+ element.classList.add("collaborators-overlay-cursor-highlighted");
28
+ setTimeout(() => {
29
+ element.classList.remove("collaborators-overlay-cursor-highlighted");
30
+ }, duration);
31
+ }
32
+ function createCursorRegistry() {
33
+ const cursorMap = /* @__PURE__ */ new Map();
34
+ return {
35
+ /**
36
+ * Register a cursor element when it's created.
37
+ *
38
+ * @param clientId - The clientId of the cursor to register.
39
+ * @param element - The cursor element to register.
40
+ */
41
+ registerCursor(clientId, element) {
42
+ cursorMap.set(clientId, element);
43
+ },
44
+ /**
45
+ * Unregister a cursor element when it's removed.
46
+ *
47
+ * @param clientId - The clientId of the cursor to unregister.
48
+ */
49
+ unregisterCursor(clientId) {
50
+ cursorMap.delete(clientId);
51
+ },
52
+ /**
53
+ * Scroll to a cursor by clientId.
54
+ *
55
+ * @param clientId - The clientId of the cursor to scroll to.
56
+ * @param options - The options for the scroll.
57
+ * @return true if cursor was found and scrolled to, false otherwise.
58
+ */
59
+ scrollToCursor(clientId, options) {
60
+ const cursorElement = cursorMap.get(clientId);
61
+ if (!cursorElement) {
62
+ return false;
63
+ }
64
+ cursorElement.scrollIntoView({
65
+ behavior: options?.behavior ?? "smooth",
66
+ block: options?.block ?? "center",
67
+ inline: options?.inline ?? "nearest"
68
+ });
69
+ if (options?.highlightDuration) {
70
+ highlightCursor(cursorElement, options.highlightDuration);
71
+ }
72
+ return true;
73
+ },
74
+ /**
75
+ * Clear the registry.
76
+ */
77
+ removeAll() {
78
+ cursorMap.clear();
79
+ }
80
+ };
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ createCursorRegistry
85
+ });
86
+ //# sourceMappingURL=cursor-registry.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/collaborators-overlay/cursor-registry.ts"],
4
+ "sourcesContent": ["interface ScrollToCursorOptions {\n\tbehavior?: ScrollBehavior;\n\tblock?: ScrollLogicalPosition;\n\tinline?: ScrollLogicalPosition;\n\thighlightDuration?: number;\n}\n\n/**\n * Cursor Registry\n * ===\n * This registry stores references to cursor elements so that we can access them\n * in different parts of the component tree. This would more ideally be solved\n * with React context or state in the awareness store, but:\n *\n * 1. EditorPresence and BlockCanvasCover slot/fill break context propagation. We\n * don't currently have a way to provide context to both the slot and fill.\n * 2. Storing pointers to the cursor elements in the awareness store might be a\n * better solution, but would require broader refactoring.\n *\n * For now, we create a single instance of this registry and pass it down to the\n * components that need it. It's important that we create a single instance and\n * not a new instance per component or render; use useState with a lazy\n * initializer to accomplish this.\n */\n\nfunction highlightCursor( element: HTMLElement, duration: number ): void {\n\telement.classList.add( 'collaborators-overlay-cursor-highlighted' );\n\n\tsetTimeout( () => {\n\t\telement.classList.remove( 'collaborators-overlay-cursor-highlighted' );\n\t}, duration );\n}\n\nexport function createCursorRegistry() {\n\tconst cursorMap = new Map< number, HTMLElement >();\n\n\treturn {\n\t\t/**\n\t\t * Register a cursor element when it's created.\n\t\t *\n\t\t * @param clientId - The clientId of the cursor to register.\n\t\t * @param element - The cursor element to register.\n\t\t */\n\t\tregisterCursor( clientId: number, element: HTMLElement ): void {\n\t\t\tcursorMap.set( clientId, element );\n\t\t},\n\n\t\t/**\n\t\t * Unregister a cursor element when it's removed.\n\t\t *\n\t\t * @param clientId - The clientId of the cursor to unregister.\n\t\t */\n\t\tunregisterCursor( clientId: number ): void {\n\t\t\tcursorMap.delete( clientId );\n\t\t},\n\n\t\t/**\n\t\t * Scroll to a cursor by clientId.\n\t\t *\n\t\t * @param clientId - The clientId of the cursor to scroll to.\n\t\t * @param options - The options for the scroll.\n\t\t * @return true if cursor was found and scrolled to, false otherwise.\n\t\t */\n\t\tscrollToCursor(\n\t\t\tclientId: number,\n\t\t\toptions?: ScrollToCursorOptions\n\t\t): boolean {\n\t\t\tconst cursorElement = cursorMap.get( clientId );\n\n\t\t\tif ( ! cursorElement ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tcursorElement.scrollIntoView( {\n\t\t\t\tbehavior: options?.behavior ?? 'smooth',\n\t\t\t\tblock: options?.block ?? 'center',\n\t\t\t\tinline: options?.inline ?? 'nearest',\n\t\t\t} );\n\n\t\t\tif ( options?.highlightDuration ) {\n\t\t\t\thighlightCursor( cursorElement, options.highlightDuration );\n\t\t\t}\n\n\t\t\treturn true;\n\t\t},\n\n\t\t/**\n\t\t * Clear the registry.\n\t\t */\n\t\tremoveAll(): void {\n\t\t\tcursorMap.clear();\n\t\t},\n\t};\n}\n\nexport type CursorRegistry = ReturnType< typeof createCursorRegistry >;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBA,SAAS,gBAAiB,SAAsB,UAAyB;AACxE,UAAQ,UAAU,IAAK,0CAA2C;AAElE,aAAY,MAAM;AACjB,YAAQ,UAAU,OAAQ,0CAA2C;AAAA,EACtE,GAAG,QAAS;AACb;AAEO,SAAS,uBAAuB;AACtC,QAAM,YAAY,oBAAI,IAA2B;AAEjD,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAON,eAAgB,UAAkB,SAA6B;AAC9D,gBAAU,IAAK,UAAU,OAAQ;AAAA,IAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,iBAAkB,UAAyB;AAC1C,gBAAU,OAAQ,QAAS;AAAA,IAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,eACC,UACA,SACU;AACV,YAAM,gBAAgB,UAAU,IAAK,QAAS;AAE9C,UAAK,CAAE,eAAgB;AACtB,eAAO;AAAA,MACR;AAEA,oBAAc,eAAgB;AAAA,QAC7B,UAAU,SAAS,YAAY;AAAA,QAC/B,OAAO,SAAS,SAAS;AAAA,QACzB,QAAQ,SAAS,UAAU;AAAA,MAC5B,CAAE;AAEF,UAAK,SAAS,mBAAoB;AACjC,wBAAiB,eAAe,QAAQ,iBAAkB;AAAA,MAC3D;AAEA,aAAO;AAAA,IACR;AAAA;AAAA;AAAA;AAAA,IAKA,YAAkB;AACjB,gBAAU,MAAM;AAAA,IACjB;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -28,7 +28,11 @@ var import_lock_unlock = require("../../lock-unlock.cjs");
28
28
  var import_overlay = require("./overlay.cjs");
29
29
  var import_jsx_runtime = require("react/jsx-runtime");
30
30
  var { BlockCanvasCover } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
31
- function CollaboratorsOverlay({ postId, postType }) {
31
+ function CollaboratorsOverlay({
32
+ postId,
33
+ postType,
34
+ cursorRegistry
35
+ }) {
32
36
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BlockCanvasCover.Fill, { children: ({
33
37
  containerRef
34
38
  }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -36,7 +40,8 @@ function CollaboratorsOverlay({ postId, postType }) {
36
40
  {
37
41
  blockEditorDocument: containerRef.current?.ownerDocument,
38
42
  postId,
39
- postType
43
+ postType,
44
+ cursorRegistry
40
45
  }
41
46
  ) });
42
47
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-overlay/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\n// @ts-expect-error No exported types\nimport { privateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { Overlay } from './overlay';\n\nconst { BlockCanvasCover } = unlock( privateApis );\n\ninterface Props {\n\tpostId: number | null;\n\tpostType: string | null;\n}\n\n/**\n * Collaborators Overlay component\n * @param props - The props for the CollaboratorsOverlay component\n * @param props.postId - The ID of the post\n * @param props.postType - The type of the post\n * @return The CollaboratorsOverlay component\n */\nexport function CollaboratorsOverlay( { postId, postType }: Props ) {\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t{ ( {\n\t\t\t\tcontainerRef,\n\t\t\t}: {\n\t\t\t\tcontainerRef: React.MutableRefObject< HTMLElement | null >;\n\t\t\t} ) => (\n\t\t\t\t<Overlay\n\t\t\t\t\tblockEditorDocument={ containerRef.current?.ownerDocument }\n\t\t\t\t\tpostId={ postId }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockCanvasCover.Fill>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAA4B;AAK5B,yBAAuB;AACvB,qBAAwB;AAwBpB;AAtBJ,IAAM,EAAE,iBAAiB,QAAI,2BAAQ,+BAAY;AAc1C,SAAS,qBAAsB,EAAE,QAAQ,SAAS,GAAW;AACnE,SACC,4CAAC,iBAAiB,MAAjB,EACE,WAAE;AAAA,IACH;AAAA,EACD,MAGC;AAAA,IAAC;AAAA;AAAA,MACA,qBAAsB,aAAa,SAAS;AAAA,MAC5C;AAAA,MACA;AAAA;AAAA,EACD,GAEF;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\n// @ts-expect-error No exported types\nimport { privateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { Overlay } from './overlay';\nimport { type CursorRegistry } from './cursor-registry';\n\nconst { BlockCanvasCover } = unlock( privateApis );\n\ninterface Props {\n\tpostId: number | null;\n\tpostType: string | null;\n\tcursorRegistry?: CursorRegistry;\n}\n\n/**\n * Collaborators Overlay component\n * @param props - The props for the CollaboratorsOverlay component\n * @param props.postId - The ID of the post\n * @param props.postType - The type of the post\n * @param props.cursorRegistry - The shared cursor registry\n * @return The CollaboratorsOverlay component\n */\nexport function CollaboratorsOverlay( {\n\tpostId,\n\tpostType,\n\tcursorRegistry,\n}: Props ) {\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t{ ( {\n\t\t\t\tcontainerRef,\n\t\t\t}: {\n\t\t\t\tcontainerRef: React.MutableRefObject< HTMLElement | null >;\n\t\t\t} ) => (\n\t\t\t\t<Overlay\n\t\t\t\t\tblockEditorDocument={ containerRef.current?.ownerDocument }\n\t\t\t\t\tpostId={ postId }\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tcursorRegistry={ cursorRegistry }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockCanvasCover.Fill>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAA4B;AAK5B,yBAAuB;AACvB,qBAAwB;AA+BpB;AA5BJ,IAAM,EAAE,iBAAiB,QAAI,2BAAQ,+BAAY;AAgB1C,SAAS,qBAAsB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACD,GAAW;AACV,SACC,4CAAC,iBAAiB,MAAjB,EACE,WAAE;AAAA,IACH;AAAA,EACD,MAGC;AAAA,IAAC;AAAA;AAAA,MACA,qBAAsB,aAAa,SAAS;AAAA,MAC5C;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD,GAEF;AAEF;",
6
6
  "names": []
7
7
  }
@@ -131,7 +131,7 @@ var OVERLAY_IFRAME_STYLES = `
131
131
  outline-style: solid;
132
132
  outline-width: calc(var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));
133
133
  outline-offset: calc(-1 * var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));
134
- box-shadow: inset 0 0 0 calc(var(--wp-admin-border-width-focus, ${import_collaborator_styles.BORDER_WIDTH_FOCUS_FALLBACK}) + ${import_collaborator_styles.BORDER_WIDTH}) ${import_collaborator_styles.WHITE}, 0 0 0 ${import_collaborator_styles.BORDER_WIDTH} ${import_collaborator_styles.WHITE}, ${import_collaborator_styles.ELEVATION_X_SMALL};
134
+ box-shadow: inset 0 0 0 calc((var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1)) + 0.5px) rgba(${import_collaborator_styles.WHITE}, 0.7);
135
135
  z-index: 1;
136
136
  }
137
137
  @media (prefers-reduced-motion: reduce) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-overlay/overlay-iframe-styles.ts"],
4
- "sourcesContent": ["/**\n * CSS for the collaborators overlay \u2014 cursor indicators, block highlights,\n * and positioning of Avatar labels inside the editor canvas iframe.\n */\n\nimport {\n\tBORDER_WIDTH,\n\tBORDER_WIDTH_FOCUS_FALLBACK,\n\tELEVATION_X_SMALL,\n\tGRID_UNIT_05,\n\tGRID_UNIT_10,\n\tWHITE,\n} from './collaborator-styles';\n\nexport const OVERLAY_IFRAME_STYLES = `\n.block-canvas-cover {\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\theight: 100%;\n\tpointer-events: none;\n\tz-index: 20000;\n}\n.block-canvas-cover .collaborators-overlay-full {\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\theight: 100%;\n}\n.block-canvas-cover .collaborators-overlay-fixed {\n\tposition: fixed;\n\twidth: 100%;\n\theight: 100%;\n}\n.collaborators-overlay-user {\n\tposition: absolute;\n}\n/* Cursor lines render below avatar labels across all users. The parent\n .collaborators-overlay-user has no z-index so it does not create a\n stacking context \u2014 children participate in the shared overlay context. */\n.collaborators-overlay-user-cursor {\n\tposition: absolute;\n\tz-index: 0;\n\twidth: ${ BORDER_WIDTH_FOCUS_FALLBACK };\n\tborder-radius: ${ BORDER_WIDTH };\n\toutline: ${ BORDER_WIDTH } solid ${ WHITE };\n\tbox-shadow: ${ ELEVATION_X_SMALL };\n\tanimation: collaborators-overlay-cursor-blink 1s infinite;\n}\n.collaborators-overlay-selection-rect {\n\tposition: absolute;\n\topacity: 0.15;\n\tpointer-events: none;\n\tborder-radius: 2px;\n}\n\n/* Overlay-specific positioning applied to the Avatar cursor label. */\n.collaborators-overlay-user-label.editor-avatar {\n\tposition: absolute;\n\tz-index: 1;\n\ttransform: translate(-11px, -100%);\n\tmargin-top: -${ GRID_UNIT_05 };\n\tpointer-events: auto;\n\toverflow: visible;\n\twidth: max-content;\n}\n/* Avatar positioned above a highlighted block as a label. */\n.collaborators-overlay-block-label.editor-avatar {\n\tposition: absolute;\n\tz-index: 1;\n\ttransform: translateY(calc(-100% - ${ GRID_UNIT_10 }));\n\tpointer-events: auto;\n\toverflow: visible;\n\twidth: max-content;\n}\n\n@keyframes collaborators-overlay-cursor-blink {\n\t0%, 45% { opacity: 1; }\n\t55%, 95% { opacity: 0; }\n\t100% { opacity: 1; }\n}\n.collaborators-overlay-cursor-highlighted .collaborators-overlay-user-cursor {\n\tanimation: collaborators-overlay-cursor-highlight 0.6s ease-in-out 3;\n}\n.collaborators-overlay-cursor-highlighted .collaborators-overlay-user-label {\n\tanimation: collaborators-overlay-label-highlight 0.6s ease-in-out 3;\n}\n@keyframes collaborators-overlay-cursor-highlight {\n\t0%, 100% {\n\t\ttransform: scale(1);\n\t\tfilter: drop-shadow(0 0 0 transparent);\n\t}\n\t50% {\n\t\ttransform: scale(1.2);\n\t\tfilter: drop-shadow(0 0 8px currentColor);\n\t}\n}\n@keyframes collaborators-overlay-label-highlight {\n\t0%, 100% {\n\t\ttransform: translate(-11px, -100%) scale(1);\n\t\tfilter: drop-shadow(0 0 0 transparent);\n\t}\n\t50% {\n\t\ttransform: translate(-11px, -100%) scale(1.1);\n\t\tfilter: drop-shadow(0 0 6px currentColor);\n\t}\n}\n.block-editor-block-list__block.is-collaborator-selected:not(:focus)::after {\n\tcontent: \"\";\n\tposition: absolute;\n\tpointer-events: none;\n\ttop: 0;\n\tright: 0;\n\tbottom: 0;\n\tleft: 0;\n\toutline-color: var(--collaborator-outline-color);\n\toutline-style: solid;\n\toutline-width: calc(var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));\n\toutline-offset: calc(-1 * var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));\n\tbox-shadow: inset 0 0 0 calc(var(--wp-admin-border-width-focus, ${ BORDER_WIDTH_FOCUS_FALLBACK }) + ${ BORDER_WIDTH }) ${ WHITE }, 0 0 0 ${ BORDER_WIDTH } ${ WHITE }, ${ ELEVATION_X_SMALL };\n\tz-index: 1;\n}\n@media (prefers-reduced-motion: reduce) {\n\t.collaborators-overlay-user-label,\n\t.collaborators-overlay-user-cursor {\n\t\tanimation: none;\n\t}\n}\n`;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,iCAOO;AAEA,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UA+B1B,sDAA4B;AAAA,kBACpB,uCAAa;AAAA,YACnB,uCAAa,UAAW,gCAAM;AAAA,eAC3B,4CAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAejB,uCAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCASS,uCAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mEAiDgB,sDAA4B,OAAQ,uCAAa,KAAM,gCAAM,WAAY,uCAAa,IAAK,gCAAM,KAAM,4CAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
4
+ "sourcesContent": ["/**\n * CSS for the collaborators overlay \u2014 cursor indicators, block highlights,\n * and positioning of Avatar labels inside the editor canvas iframe.\n */\n\nimport {\n\tBORDER_WIDTH,\n\tBORDER_WIDTH_FOCUS_FALLBACK,\n\tELEVATION_X_SMALL,\n\tGRID_UNIT_05,\n\tGRID_UNIT_10,\n\tWHITE,\n} from './collaborator-styles';\n\nexport const OVERLAY_IFRAME_STYLES = `\n.block-canvas-cover {\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\theight: 100%;\n\tpointer-events: none;\n\tz-index: 20000;\n}\n.block-canvas-cover .collaborators-overlay-full {\n\tposition: absolute;\n\ttop: 0;\n\tleft: 0;\n\twidth: 100%;\n\theight: 100%;\n}\n.block-canvas-cover .collaborators-overlay-fixed {\n\tposition: fixed;\n\twidth: 100%;\n\theight: 100%;\n}\n.collaborators-overlay-user {\n\tposition: absolute;\n}\n/* Cursor lines render below avatar labels across all users. The parent\n .collaborators-overlay-user has no z-index so it does not create a\n stacking context \u2014 children participate in the shared overlay context. */\n.collaborators-overlay-user-cursor {\n\tposition: absolute;\n\tz-index: 0;\n\twidth: ${ BORDER_WIDTH_FOCUS_FALLBACK };\n\tborder-radius: ${ BORDER_WIDTH };\n\toutline: ${ BORDER_WIDTH } solid ${ WHITE };\n\tbox-shadow: ${ ELEVATION_X_SMALL };\n\tanimation: collaborators-overlay-cursor-blink 1s infinite;\n}\n.collaborators-overlay-selection-rect {\n\tposition: absolute;\n\topacity: 0.15;\n\tpointer-events: none;\n\tborder-radius: 2px;\n}\n\n/* Overlay-specific positioning applied to the Avatar cursor label. */\n.collaborators-overlay-user-label.editor-avatar {\n\tposition: absolute;\n\tz-index: 1;\n\ttransform: translate(-11px, -100%);\n\tmargin-top: -${ GRID_UNIT_05 };\n\tpointer-events: auto;\n\toverflow: visible;\n\twidth: max-content;\n}\n/* Avatar positioned above a highlighted block as a label. */\n.collaborators-overlay-block-label.editor-avatar {\n\tposition: absolute;\n\tz-index: 1;\n\ttransform: translateY(calc(-100% - ${ GRID_UNIT_10 }));\n\tpointer-events: auto;\n\toverflow: visible;\n\twidth: max-content;\n}\n\n@keyframes collaborators-overlay-cursor-blink {\n\t0%, 45% { opacity: 1; }\n\t55%, 95% { opacity: 0; }\n\t100% { opacity: 1; }\n}\n.collaborators-overlay-cursor-highlighted .collaborators-overlay-user-cursor {\n\tanimation: collaborators-overlay-cursor-highlight 0.6s ease-in-out 3;\n}\n.collaborators-overlay-cursor-highlighted .collaborators-overlay-user-label {\n\tanimation: collaborators-overlay-label-highlight 0.6s ease-in-out 3;\n}\n@keyframes collaborators-overlay-cursor-highlight {\n\t0%, 100% {\n\t\ttransform: scale(1);\n\t\tfilter: drop-shadow(0 0 0 transparent);\n\t}\n\t50% {\n\t\ttransform: scale(1.2);\n\t\tfilter: drop-shadow(0 0 8px currentColor);\n\t}\n}\n@keyframes collaborators-overlay-label-highlight {\n\t0%, 100% {\n\t\ttransform: translate(-11px, -100%) scale(1);\n\t\tfilter: drop-shadow(0 0 0 transparent);\n\t}\n\t50% {\n\t\ttransform: translate(-11px, -100%) scale(1.1);\n\t\tfilter: drop-shadow(0 0 6px currentColor);\n\t}\n}\n.block-editor-block-list__block.is-collaborator-selected:not(:focus)::after {\n\tcontent: \"\";\n\tposition: absolute;\n\tpointer-events: none;\n\ttop: 0;\n\tright: 0;\n\tbottom: 0;\n\tleft: 0;\n\toutline-color: var(--collaborator-outline-color);\n\toutline-style: solid;\n\toutline-width: calc(var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));\n\toutline-offset: calc(-1 * var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1));\n\tbox-shadow: inset 0 0 0 calc((var(--wp-admin-border-width-focus) / var(--wp-block-editor-iframe-zoom-out-scale, 1)) + 0.5px) rgba(${ WHITE }, 0.7);\n\tz-index: 1;\n}\n@media (prefers-reduced-motion: reduce) {\n\t.collaborators-overlay-user-label,\n\t.collaborators-overlay-user-cursor {\n\t\tanimation: none;\n\t}\n}\n`;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,iCAOO;AAEA,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UA+B1B,sDAA4B;AAAA,kBACpB,uCAAa;AAAA,YACnB,uCAAa,UAAW,gCAAM;AAAA,eAC3B,4CAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAejB,uCAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCASS,uCAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qIAiDkF,gCAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -39,14 +39,17 @@ var import_i18n = require("@wordpress/i18n");
39
39
  var import_avatar = __toESM(require("../collaborators-presence/avatar/index.cjs"));
40
40
  var import_avatar_iframe_styles = require("./avatar-iframe-styles.cjs");
41
41
  var import_overlay_iframe_styles = require("./overlay-iframe-styles.cjs");
42
+ var import_timing_utils = require("./timing-utils.cjs");
42
43
  var import_use_block_highlighting = require("./use-block-highlighting.cjs");
43
44
  var import_use_render_cursors = require("./use-render-cursors.cjs");
44
45
  var import_jsx_runtime = require("react/jsx-runtime");
45
46
  var RERENDER_DELAY_MS = 500;
47
+ var CURSOR_REDRAW_INTERVAL_MS = 1e4;
46
48
  function Overlay({
47
49
  blockEditorDocument,
48
50
  postId,
49
- postType
51
+ postType,
52
+ cursorRegistry
50
53
  }) {
51
54
  const [overlayElement, setOverlayElement] = (0, import_element.useState)(null);
52
55
  const { cursors, rerenderCursorsAfterDelay } = (0, import_use_render_cursors.useRenderCursors)(
@@ -76,10 +79,47 @@ function Overlay({
76
79
  cleanupHighlights();
77
80
  };
78
81
  }, [rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay]);
82
+ (0, import_element.useEffect)(() => {
83
+ if (cursors.length === 0) {
84
+ return;
85
+ }
86
+ return (0, import_timing_utils.setDelayedInterval)(
87
+ rerenderCursorsAfterDelay,
88
+ CURSOR_REDRAW_INTERVAL_MS
89
+ );
90
+ }, [cursors.length, rerenderCursorsAfterDelay]);
79
91
  const mergedRef = (0, import_compose.useMergeRefs)([
80
92
  setOverlayElement,
81
93
  resizeObserverRef
82
94
  ]);
95
+ const cursorRefsMap = (0, import_element.useRef)(/* @__PURE__ */ new Map());
96
+ (0, import_element.useEffect)(() => {
97
+ if (!cursorRegistry) {
98
+ return;
99
+ }
100
+ const refs = cursorRefsMap.current;
101
+ const currentIds = new Set(cursors.map((c) => c.clientId));
102
+ for (const id of refs.keys()) {
103
+ if (!currentIds.has(id)) {
104
+ cursorRegistry.unregisterCursor(id);
105
+ refs.delete(id);
106
+ }
107
+ }
108
+ for (const [id, el] of refs.entries()) {
109
+ cursorRegistry.registerCursor(id, el);
110
+ }
111
+ return () => cursorRegistry.removeAll();
112
+ }, [cursors, cursorRegistry]);
113
+ const setCursorRef = (0, import_element.useCallback)(
114
+ (clientId) => (el) => {
115
+ if (el) {
116
+ cursorRefsMap.current.set(clientId, el);
117
+ } else {
118
+ cursorRefsMap.current.delete(clientId);
119
+ }
120
+ },
121
+ []
122
+ );
83
123
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "collaborators-overlay-full", ref: mergedRef, children: [
84
124
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: import_avatar_iframe_styles.AVATAR_IFRAME_STYLES + import_overlay_iframe_styles.OVERLAY_IFRAME_STYLES }),
85
125
  cursors.map((cursor) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
@@ -100,6 +140,7 @@ function Overlay({
100
140
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
101
141
  "div",
102
142
  {
143
+ ref: setCursorRef(cursor.clientId),
103
144
  className: "collaborators-overlay-user",
104
145
  style: {
105
146
  left: `${cursor.x}px`,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-overlay/overlay.tsx"],
4
- "sourcesContent": ["import { useResizeObserver, useMergeRefs } from '@wordpress/compose';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nimport Avatar from '../collaborators-presence/avatar';\nimport { AVATAR_IFRAME_STYLES } from './avatar-iframe-styles';\nimport { OVERLAY_IFRAME_STYLES } from './overlay-iframe-styles';\nimport { useBlockHighlighting } from './use-block-highlighting';\nimport { useRenderCursors } from './use-render-cursors';\n\nconst RERENDER_DELAY_MS = 500;\n\ninterface OverlayProps {\n\tblockEditorDocument?: Document;\n\tpostId: number | null;\n\tpostType: string | null;\n}\n\n/**\n * This component is responsible for rendering the overlay components within the editor iframe.\n *\n * @param props - The overlay props.\n * @param props.blockEditorDocument - The block editor document.\n * @param props.postId - The ID of the post.\n * @param props.postType - The type of the post.\n * @return The Overlay component.\n */\nexport function Overlay( {\n\tblockEditorDocument,\n\tpostId,\n\tpostType,\n}: OverlayProps ) {\n\t// Use state for the overlay element so that the hook re-runs once the ref is attached.\n\tconst [ overlayElement, setOverlayElement ] =\n\t\tuseState< HTMLDivElement | null >( null );\n\n\tconst { cursors, rerenderCursorsAfterDelay } = useRenderCursors(\n\t\toverlayElement,\n\t\tblockEditorDocument ?? null,\n\t\tpostId ?? null,\n\t\tpostType ?? null,\n\t\tRERENDER_DELAY_MS\n\t);\n\n\tconst { highlights, rerenderHighlightsAfterDelay } = useBlockHighlighting(\n\t\toverlayElement,\n\t\tblockEditorDocument ?? null,\n\t\tpostId ?? null,\n\t\tpostType ?? null,\n\t\tRERENDER_DELAY_MS\n\t);\n\n\t// Detect layout changes on overlay (e.g. turning on \"Show Template\") and window\n\t// resizes, and re-render the cursors and block highlights.\n\tconst onResize = useCallback( () => {\n\t\trerenderCursorsAfterDelay();\n\t\trerenderHighlightsAfterDelay();\n\t}, [ rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay ] );\n\tconst resizeObserverRef = useResizeObserver( onResize );\n\n\t// Trigger the initial position computation on mount.\n\tuseEffect( () => {\n\t\tconst cleanupCursors = rerenderCursorsAfterDelay();\n\t\tconst cleanupHighlights = rerenderHighlightsAfterDelay();\n\t\treturn () => {\n\t\t\tcleanupCursors();\n\t\t\tcleanupHighlights();\n\t\t};\n\t}, [ rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay ] );\n\n\t// Merge the refs to use the same element for both overlay and resize observation\n\tconst mergedRef = useMergeRefs< HTMLDivElement | null >( [\n\t\tsetOverlayElement,\n\t\tresizeObserverRef,\n\t] );\n\n\t// This is a full overlay that covers the entire iframe document. Good for\n\t// scrollable elements like cursor indicators.\n\treturn (\n\t\t<div className=\"collaborators-overlay-full\" ref={ mergedRef }>\n\t\t\t<style>{ AVATAR_IFRAME_STYLES + OVERLAY_IFRAME_STYLES }</style>\n\t\t\t{ cursors.map( ( cursor ) => (\n\t\t\t\t<div key={ cursor.clientId }>\n\t\t\t\t\t{ ! cursor.isMe &&\n\t\t\t\t\t\tcursor.selectionRects?.map( ( rect, index ) => (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tkey={ `${ cursor.clientId }-sel-${ index }` }\n\t\t\t\t\t\t\t\tclassName=\"collaborators-overlay-selection-rect\"\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tleft: `${ rect.x }px`,\n\t\t\t\t\t\t\t\t\ttop: `${ rect.y }px`,\n\t\t\t\t\t\t\t\t\twidth: `${ rect.width }px`,\n\t\t\t\t\t\t\t\t\theight: `${ rect.height }px`,\n\t\t\t\t\t\t\t\t\tbackgroundColor: cursor.color,\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<div\n\t\t\t\t\t\tclassName=\"collaborators-overlay-user\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\tleft: `${ cursor.x }px`,\n\t\t\t\t\t\t\ttop: `${ cursor.y }px`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! cursor.isMe && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"collaborators-overlay-user-cursor\"\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tbackgroundColor: cursor.color,\n\t\t\t\t\t\t\t\t\theight: `${ cursor.height }px`,\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\t<Avatar\n\t\t\t\t\t\t\tclassName=\"collaborators-overlay-user-label\"\n\t\t\t\t\t\t\tvariant=\"badge\"\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tsrc={ cursor.avatarUrl }\n\t\t\t\t\t\t\tname={ cursor.userName }\n\t\t\t\t\t\t\tlabel={ cursor.isMe ? __( 'You' ) : undefined }\n\t\t\t\t\t\t\tborderColor={ cursor.color }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) ) }\n\t\t\t{ highlights.map( ( highlight ) => (\n\t\t\t\t<Avatar\n\t\t\t\t\tkey={ highlight.blockId }\n\t\t\t\t\tclassName=\"collaborators-overlay-block-label\"\n\t\t\t\t\tvariant=\"badge\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tsrc={ highlight.avatarUrl }\n\t\t\t\t\tname={ highlight.userName }\n\t\t\t\t\tborderColor={ highlight.color }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft: `${ highlight.x }px`,\n\t\t\t\t\t\ttop: `${ highlight.y }px`,\n\t\t\t\t\t} }\n\t\t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B;AAAA;AAAA,MAVM,UAAU;AAAA,IAWjB,CACC;AAAA,KACH;AAEF;",
4
+ "sourcesContent": ["import { useResizeObserver, useMergeRefs } from '@wordpress/compose';\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nimport Avatar from '../collaborators-presence/avatar';\nimport { AVATAR_IFRAME_STYLES } from './avatar-iframe-styles';\nimport { OVERLAY_IFRAME_STYLES } from './overlay-iframe-styles';\nimport { setDelayedInterval } from './timing-utils';\nimport { useBlockHighlighting } from './use-block-highlighting';\nimport { useRenderCursors } from './use-render-cursors';\nimport { type CursorRegistry } from './cursor-registry';\n\n// Milliseconds to wait after a change before recomputing cursor positions.\nconst RERENDER_DELAY_MS = 500;\n\n// Periodically recompute cursor positions to account for DOM layout\n// changes that don't trigger awareness state updates (e.g. a collaborator\n// applying formatting shifts text but the cursor's logical position is\n// unchanged). Only active when remote cursors are visible.\nconst CURSOR_REDRAW_INTERVAL_MS = 10_000;\n\ninterface OverlayProps {\n\tblockEditorDocument?: Document;\n\tpostId: number | null;\n\tpostType: string | null;\n\tcursorRegistry?: CursorRegistry;\n}\n\n/**\n * This component is responsible for rendering the overlay components within the editor iframe.\n *\n * @param props - The overlay props.\n * @param props.blockEditorDocument - The block editor document.\n * @param props.postId - The ID of the post.\n * @param props.postType - The type of the post.\n * @param props.cursorRegistry - The shared cursor registry.\n * @return The Overlay component.\n */\nexport function Overlay( {\n\tblockEditorDocument,\n\tpostId,\n\tpostType,\n\tcursorRegistry,\n}: OverlayProps ) {\n\t// Use state for the overlay element so that the hook re-runs once the ref is attached.\n\tconst [ overlayElement, setOverlayElement ] =\n\t\tuseState< HTMLDivElement | null >( null );\n\n\tconst { cursors, rerenderCursorsAfterDelay } = useRenderCursors(\n\t\toverlayElement,\n\t\tblockEditorDocument ?? null,\n\t\tpostId ?? null,\n\t\tpostType ?? null,\n\t\tRERENDER_DELAY_MS\n\t);\n\n\tconst { highlights, rerenderHighlightsAfterDelay } = useBlockHighlighting(\n\t\toverlayElement,\n\t\tblockEditorDocument ?? null,\n\t\tpostId ?? null,\n\t\tpostType ?? null,\n\t\tRERENDER_DELAY_MS\n\t);\n\n\t// Detect layout changes on overlay (e.g. turning on \"Show Template\") and window\n\t// resizes, and re-render the cursors and block highlights.\n\tconst onResize = useCallback( () => {\n\t\trerenderCursorsAfterDelay();\n\t\trerenderHighlightsAfterDelay();\n\t}, [ rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay ] );\n\tconst resizeObserverRef = useResizeObserver( onResize );\n\n\t// Trigger the initial position computation on mount.\n\tuseEffect( () => {\n\t\tconst cleanupCursors = rerenderCursorsAfterDelay();\n\t\tconst cleanupHighlights = rerenderHighlightsAfterDelay();\n\t\treturn () => {\n\t\t\tcleanupCursors();\n\t\t\tcleanupHighlights();\n\t\t};\n\t}, [ rerenderCursorsAfterDelay, rerenderHighlightsAfterDelay ] );\n\n\tuseEffect( () => {\n\t\tif ( cursors.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn setDelayedInterval(\n\t\t\trerenderCursorsAfterDelay,\n\t\t\tCURSOR_REDRAW_INTERVAL_MS\n\t\t);\n\t}, [ cursors.length, rerenderCursorsAfterDelay ] );\n\n\t// Merge the refs to use the same element for both overlay and resize observation\n\tconst mergedRef = useMergeRefs< HTMLDivElement | null >( [\n\t\tsetOverlayElement,\n\t\tresizeObserverRef,\n\t] );\n\n\t// Track cursor element refs for registry registration.\n\tconst cursorRefsMap = useRef< Map< number, HTMLElement > >( new Map() );\n\n\t// Keep the registry in sync whenever the rendered cursors change.\n\tuseEffect( () => {\n\t\tif ( ! cursorRegistry ) {\n\t\t\treturn;\n\t\t}\n\t\tconst refs = cursorRefsMap.current;\n\t\tconst currentIds = new Set( cursors.map( ( c ) => c.clientId ) );\n\n\t\t// Unregister cursors that are no longer rendered.\n\t\tfor ( const id of refs.keys() ) {\n\t\t\tif ( ! currentIds.has( id ) ) {\n\t\t\t\tcursorRegistry.unregisterCursor( id );\n\t\t\t\trefs.delete( id );\n\t\t\t}\n\t\t}\n\n\t\t// Register or update cursors that are currently rendered.\n\t\tfor ( const [ id, el ] of refs.entries() ) {\n\t\t\tcursorRegistry.registerCursor( id, el );\n\t\t}\n\n\t\treturn () => cursorRegistry.removeAll();\n\t}, [ cursors, cursorRegistry ] );\n\n\t// Callback ref factory to capture each cursor's DOM element.\n\tconst setCursorRef = useCallback(\n\t\t( clientId: number ) => ( el: HTMLDivElement | null ) => {\n\t\t\tif ( el ) {\n\t\t\t\tcursorRefsMap.current.set( clientId, el );\n\t\t\t} else {\n\t\t\t\tcursorRefsMap.current.delete( clientId );\n\t\t\t}\n\t\t},\n\t\t[]\n\t);\n\n\t// This is a full overlay that covers the entire iframe document. Good for\n\t// scrollable elements like cursor indicators.\n\treturn (\n\t\t<div className=\"collaborators-overlay-full\" ref={ mergedRef }>\n\t\t\t<style>{ AVATAR_IFRAME_STYLES + OVERLAY_IFRAME_STYLES }</style>\n\t\t\t{ cursors.map( ( cursor ) => (\n\t\t\t\t<div key={ cursor.clientId }>\n\t\t\t\t\t{ ! cursor.isMe &&\n\t\t\t\t\t\tcursor.selectionRects?.map( ( rect, index ) => (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tkey={ `${ cursor.clientId }-sel-${ index }` }\n\t\t\t\t\t\t\t\tclassName=\"collaborators-overlay-selection-rect\"\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tleft: `${ rect.x }px`,\n\t\t\t\t\t\t\t\t\ttop: `${ rect.y }px`,\n\t\t\t\t\t\t\t\t\twidth: `${ rect.width }px`,\n\t\t\t\t\t\t\t\t\theight: `${ rect.height }px`,\n\t\t\t\t\t\t\t\t\tbackgroundColor: cursor.color,\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<div\n\t\t\t\t\t\tref={ setCursorRef( cursor.clientId ) }\n\t\t\t\t\t\tclassName=\"collaborators-overlay-user\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\tleft: `${ cursor.x }px`,\n\t\t\t\t\t\t\ttop: `${ cursor.y }px`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! cursor.isMe && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName=\"collaborators-overlay-user-cursor\"\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\tbackgroundColor: cursor.color,\n\t\t\t\t\t\t\t\t\theight: `${ cursor.height }px`,\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\t<Avatar\n\t\t\t\t\t\t\tclassName=\"collaborators-overlay-user-label\"\n\t\t\t\t\t\t\tvariant=\"badge\"\n\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\tsrc={ cursor.avatarUrl }\n\t\t\t\t\t\t\tname={ cursor.userName }\n\t\t\t\t\t\t\tlabel={ cursor.isMe ? __( 'You' ) : undefined }\n\t\t\t\t\t\t\tborderColor={ cursor.color }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) ) }\n\t\t\t{ highlights.map( ( highlight ) => (\n\t\t\t\t<Avatar\n\t\t\t\t\tkey={ highlight.blockId }\n\t\t\t\t\tclassName=\"collaborators-overlay-block-label\"\n\t\t\t\t\tvariant=\"badge\"\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tsrc={ highlight.avatarUrl }\n\t\t\t\t\tname={ highlight.userName }\n\t\t\t\t\tborderColor={ highlight.color }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft: `${ highlight.x }px`,\n\t\t\t\t\t\ttop: `${ highlight.y }px`,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;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AAA;AAAA,UACA,KAAM,aAAc,OAAO,QAAS;AAAA,UACpC,WAAU;AAAA,UACV,OAAQ;AAAA,YACP,MAAM,GAAI,OAAO,CAAE;AAAA,YACnB,KAAK,GAAI,OAAO,CAAE;AAAA,UACnB;AAAA,UAEE;AAAA,aAAE,OAAO,QACV;AAAA,cAAC;AAAA;AAAA,gBACA,WAAU;AAAA,gBACV,OAAQ;AAAA,kBACP,iBAAiB,OAAO;AAAA,kBACxB,QAAQ,GAAI,OAAO,MAAO;AAAA,gBAC3B;AAAA;AAAA,YACD;AAAA,YAED;AAAA,cAAC,cAAAA;AAAA,cAAA;AAAA,gBACA,WAAU;AAAA,gBACV,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,KAAM,OAAO;AAAA,gBACb,MAAO,OAAO;AAAA,gBACd,OAAQ,OAAO,WAAO,gBAAI,KAAM,IAAI;AAAA,gBACpC,aAAc,OAAO;AAAA;AAAA,YACtB;AAAA;AAAA;AAAA,MACD;AAAA,SAzCU,OAAO,QA0ClB,CACC;AAAA,IACA,WAAW,IAAK,CAAE,cACnB;AAAA,MAAC,cAAAA;AAAA,MAAA;AAAA,QAEA,WAAU;AAAA,QACV,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,KAAM,UAAU;AAAA,QAChB,MAAO,UAAU;AAAA,QACjB,aAAc,UAAU;AAAA,QACxB,OAAQ;AAAA,UACP,MAAM,GAAI,UAAU,CAAE;AAAA,UACtB,KAAK,GAAI,UAAU,CAAE;AAAA,QACtB;AAAA;AAAA,MAVM,UAAU;AAAA,IAWjB,CACC;AAAA,KACH;AAEF;",
6
6
  "names": ["Avatar"]
7
7
  }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/editor/src/components/collaborators-overlay/timing-utils.ts
21
+ var timing_utils_exports = {};
22
+ __export(timing_utils_exports, {
23
+ setDelayedInterval: () => setDelayedInterval
24
+ });
25
+ module.exports = __toCommonJS(timing_utils_exports);
26
+ function setDelayedInterval(callback, delayMs) {
27
+ let timerHandle = null;
28
+ const runner = () => {
29
+ try {
30
+ callback();
31
+ } catch (error) {
32
+ }
33
+ timerHandle = setTimeout(runner, delayMs);
34
+ };
35
+ timerHandle = setTimeout(runner, delayMs);
36
+ return () => {
37
+ if (timerHandle) {
38
+ clearTimeout(timerHandle);
39
+ }
40
+ };
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ setDelayedInterval
45
+ });
46
+ //# sourceMappingURL=timing-utils.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/collaborators-overlay/timing-utils.ts"],
4
+ "sourcesContent": ["/**\n * Like setInterval but chains setTimeout calls, so the delay is measured from\n * the end of one run to the start of the next. This prevents callbacks from\n * stacking up when the main thread is busy.\n *\n * @param callback The function to call repeatedly.\n * @param delayMs Milliseconds between runs.\n * @return A cleanup function that stops the timer.\n */\nexport function setDelayedInterval( callback: () => void, delayMs: number ) {\n\tlet timerHandle: ReturnType< typeof setTimeout > | null = null;\n\n\tconst runner = () => {\n\t\ttry {\n\t\t\tcallback();\n\t\t} catch ( error ) {\n\t\t\t// Do nothing\n\t\t}\n\n\t\ttimerHandle = setTimeout( runner, delayMs );\n\t};\n\n\ttimerHandle = setTimeout( runner, delayMs );\n\n\treturn () => {\n\t\tif ( timerHandle ) {\n\t\t\tclearTimeout( timerHandle );\n\t\t}\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,mBAAoB,UAAsB,SAAkB;AAC3E,MAAI,cAAsD;AAE1D,QAAM,SAAS,MAAM;AACpB,QAAI;AACH,eAAS;AAAA,IACV,SAAU,OAAQ;AAAA,IAElB;AAEA,kBAAc,WAAY,QAAQ,OAAQ;AAAA,EAC3C;AAEA,gBAAc,WAAY,QAAQ,OAAQ;AAE1C,SAAO,MAAM;AACZ,QAAK,aAAc;AAClB,mBAAc,WAAY;AAAA,IAC3B;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -72,7 +72,7 @@ function useRenderCursors(overlayElement, blockEditorDocument, postId, postType,
72
72
  type: import_core_data.SelectionType.None
73
73
  };
74
74
  let start = {
75
- textIndex: null,
75
+ richTextOffset: null,
76
76
  localClientId: null
77
77
  };
78
78
  let end;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-overlay/use-render-cursors.ts"],
4
- "sourcesContent": ["import {\n\tprivateApis as coreDataPrivateApis,\n\tSelectionType,\n\ttype PostEditorAwarenessState as ActiveCollaborator,\n} from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport type { ResolvedSelection } from '@wordpress/core-data';\n\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarUrl } from './get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\nimport { computeSelectionVisual } from './compute-selection';\nimport { useDebouncedRecompute } from './use-debounced-recompute';\nimport type { SelectionRect } from './cursor-dom-utils';\n\nconst { useActiveCollaborators, useResolvedSelection } =\n\tunlock( coreDataPrivateApis );\n\nexport type { SelectionRect };\n\nexport interface CursorData {\n\tuserName: string;\n\tclientId: number;\n\tcolor: string;\n\tavatarUrl?: string;\n\tx: number;\n\ty: number;\n\theight: number;\n\tisMe?: boolean;\n\tselectionRects?: SelectionRect[];\n}\n\n/**\n * Custom hook that computes cursor positions for each remote user in the editor.\n *\n * @param overlayElement - The overlay element\n * @param blockEditorDocument - The block editor document\n * @param postId - The ID of the post\n * @param postType - The type of the post\n * @param delayMs - Milliseconds to wait before recomputing cursor positions.\n * @return An array of cursor data for rendering, and a function to trigger a delayed recompute.\n */\nexport function useRenderCursors(\n\toverlayElement: HTMLElement | null,\n\tblockEditorDocument: Document | null,\n\tpostId: number | null,\n\tpostType: string | null,\n\tdelayMs: number\n): { cursors: CursorData[]; rerenderCursorsAfterDelay: () => () => void } {\n\tconst sortedUsers = useActiveCollaborators(\n\t\tpostId ?? null,\n\t\tpostType ?? null\n\t);\n\tconst resolveSelection = useResolvedSelection(\n\t\tpostId ?? null,\n\t\tpostType ?? null\n\t);\n\n\tconst showOwnCursor = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showCollaborationCursor' ),\n\t\t[]\n\t);\n\n\tconst [ cursorPositions, setCursorPositions ] = useState< CursorData[] >(\n\t\t[]\n\t);\n\n\t// Bump this counter to force the effect to re-run (e.g. after a layout shift).\n\tconst [ recomputeToken, rerenderCursorsAfterDelay ] =\n\t\tuseDebouncedRecompute( delayMs );\n\n\t// All DOM position computations live inside useEffect.\n\tuseEffect( () => {\n\t\tif ( ! overlayElement || ! blockEditorDocument ) {\n\t\t\tsetCursorPositions( [] );\n\t\t\treturn;\n\t\t}\n\n\t\t// Pre-compute the overlay rect once, same for every user.\n\t\tconst overlayRect = overlayElement.getBoundingClientRect();\n\t\tconst overlayContext = {\n\t\t\teditorDocument: blockEditorDocument,\n\t\t\toverlayRect,\n\t\t};\n\n\t\tconst results: CursorData[] = [];\n\n\t\tconst hasOtherCollaborators = sortedUsers.some(\n\t\t\t( u: ActiveCollaborator ) => ! u.isMe\n\t\t);\n\n\t\tsortedUsers.forEach( ( user: ActiveCollaborator ) => {\n\t\t\tif ( user.isMe && ( ! showOwnCursor || ! hasOtherCollaborators ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = user.editorState?.selection ?? {\n\t\t\t\ttype: SelectionType.None,\n\t\t\t};\n\n\t\t\tlet start: ResolvedSelection = {\n\t\t\t\ttextIndex: null,\n\t\t\t\tlocalClientId: null,\n\t\t\t};\n\t\t\tlet end: ResolvedSelection | undefined;\n\n\t\t\tif ( selection.type === SelectionType.Cursor ) {\n\t\t\t\ttry {\n\t\t\t\t\tstart = resolveSelection( selection );\n\t\t\t\t} catch {\n\t\t\t\t\t// Selection may reference a stale Yjs position.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tselection.type === SelectionType.SelectionInOneBlock ||\n\t\t\t\tselection.type === SelectionType.SelectionInMultipleBlocks\n\t\t\t) {\n\t\t\t\ttry {\n\t\t\t\t\tstart = resolveSelection( {\n\t\t\t\t\t\ttype: SelectionType.Cursor,\n\t\t\t\t\t\tcursorPosition: selection.cursorStartPosition,\n\t\t\t\t\t} );\n\n\t\t\t\t\tend = resolveSelection( {\n\t\t\t\t\t\ttype: SelectionType.Cursor,\n\t\t\t\t\t\tcursorPosition: selection.cursorEndPosition,\n\t\t\t\t\t} );\n\t\t\t\t} catch {\n\t\t\t\t\t// Selection may reference a stale Yjs position.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst userName = user.collaboratorInfo.name;\n\t\t\tconst clientId = user.clientId;\n\t\t\tconst color = user.isMe\n\t\t\t\t? 'var(--wp-admin-theme-color)'\n\t\t\t\t: getAvatarBorderColor( user.collaboratorInfo.id );\n\t\t\tconst avatarUrl = getAvatarUrl( user.collaboratorInfo.avatar_urls );\n\n\t\t\tconst selectionVisual = computeSelectionVisual(\n\t\t\t\tselection,\n\t\t\t\tstart,\n\t\t\t\tend,\n\t\t\t\toverlayContext\n\t\t\t);\n\n\t\t\tif ( selectionVisual.coords ) {\n\t\t\t\tconst cursorData: CursorData = {\n\t\t\t\t\tuserName,\n\t\t\t\t\tclientId,\n\t\t\t\t\tcolor,\n\t\t\t\t\tavatarUrl,\n\t\t\t\t\tisMe: user.isMe,\n\t\t\t\t\t...selectionVisual.coords,\n\t\t\t\t};\n\n\t\t\t\tif ( selectionVisual.selectionRects ) {\n\t\t\t\t\tcursorData.selectionRects = selectionVisual.selectionRects;\n\t\t\t\t}\n\n\t\t\t\tresults.push( cursorData );\n\t\t\t}\n\t\t} );\n\n\t\tsetCursorPositions( results );\n\t}, [\n\t\tblockEditorDocument,\n\t\tresolveSelection,\n\t\toverlayElement,\n\t\tsortedUsers,\n\t\tshowOwnCursor,\n\t\trecomputeToken,\n\t] );\n\n\treturn { cursors: cursorPositions, rerenderCursorsAfterDelay };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAIO;AACP,kBAA0B;AAC1B,qBAAoC;AACpC,yBAA0C;AAG1C,yBAAuB;AACvB,4BAA6B;AAC7B,mBAAqC;AACrC,+BAAuC;AACvC,qCAAsC;AAGtC,IAAM,EAAE,wBAAwB,qBAAqB,QACpD,2BAAQ,iBAAAA,WAAoB;AA0BtB,SAAS,iBACf,gBACA,qBACA,QACA,UACA,SACyE;AACzE,QAAM,cAAc;AAAA,IACnB,UAAU;AAAA,IACV,YAAY;AAAA,EACb;AACA,QAAM,mBAAmB;AAAA,IACxB,UAAU;AAAA,IACV,YAAY;AAAA,EACb;AAEA,QAAM,oBAAgB;AAAA,IACrB,CAAE,WACD,OAAQ,mBAAAC,KAAiB,EAAE,IAAK,QAAQ,yBAA0B;AAAA,IACnE,CAAC;AAAA,EACF;AAEA,QAAM,CAAE,iBAAiB,kBAAmB,QAAI;AAAA,IAC/C,CAAC;A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BAAkB;AAAA,QACvB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAEA,UAAK,gBAAgB,QAAS;AAC7B,cAAM,aAAyB;AAAA,UAC9B;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,MAAM,KAAK;AAAA,UACX,GAAG,gBAAgB;AAAA,QACpB;AAEA,YAAK,gBAAgB,gBAAiB;AACrC,qBAAW,iBAAiB,gBAAgB;AAAA,QAC7C;AAEA,gBAAQ,KAAM,UAAW;AAAA,MAC1B;AAAA,IACD,CAAE;AAEF,uBAAoB,OAAQ;AAAA,EAC7B,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO,EAAE,SAAS,iBAAiB,0BAA0B;AAC9D;",
4
+ "sourcesContent": ["import {\n\tprivateApis as coreDataPrivateApis,\n\tSelectionType,\n\ttype PostEditorAwarenessState as ActiveCollaborator,\n} from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport type { ResolvedSelection } from '@wordpress/core-data';\n\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarUrl } from './get-avatar-url';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\nimport { computeSelectionVisual } from './compute-selection';\nimport { useDebouncedRecompute } from './use-debounced-recompute';\nimport type { SelectionRect } from './cursor-dom-utils';\n\nconst { useActiveCollaborators, useResolvedSelection } =\n\tunlock( coreDataPrivateApis );\n\nexport type { SelectionRect };\n\nexport interface CursorData {\n\tuserName: string;\n\tclientId: number;\n\tcolor: string;\n\tavatarUrl?: string;\n\tx: number;\n\ty: number;\n\theight: number;\n\tisMe?: boolean;\n\tselectionRects?: SelectionRect[];\n}\n\n/**\n * Custom hook that computes cursor positions for each remote user in the editor.\n *\n * @param overlayElement - The overlay element\n * @param blockEditorDocument - The block editor document\n * @param postId - The ID of the post\n * @param postType - The type of the post\n * @param delayMs - Milliseconds to wait before recomputing cursor positions.\n * @return An array of cursor data for rendering, and a function to trigger a delayed recompute.\n */\nexport function useRenderCursors(\n\toverlayElement: HTMLElement | null,\n\tblockEditorDocument: Document | null,\n\tpostId: number | null,\n\tpostType: string | null,\n\tdelayMs: number\n): { cursors: CursorData[]; rerenderCursorsAfterDelay: () => () => void } {\n\tconst sortedUsers = useActiveCollaborators(\n\t\tpostId ?? null,\n\t\tpostType ?? null\n\t);\n\tconst resolveSelection = useResolvedSelection(\n\t\tpostId ?? null,\n\t\tpostType ?? null\n\t);\n\n\tconst showOwnCursor = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', 'showCollaborationCursor' ),\n\t\t[]\n\t);\n\n\tconst [ cursorPositions, setCursorPositions ] = useState< CursorData[] >(\n\t\t[]\n\t);\n\n\t// Bump this counter to force the effect to re-run (e.g. after a layout shift).\n\tconst [ recomputeToken, rerenderCursorsAfterDelay ] =\n\t\tuseDebouncedRecompute( delayMs );\n\n\t// All DOM position computations live inside useEffect.\n\tuseEffect( () => {\n\t\tif ( ! overlayElement || ! blockEditorDocument ) {\n\t\t\tsetCursorPositions( [] );\n\t\t\treturn;\n\t\t}\n\n\t\t// Pre-compute the overlay rect once, same for every user.\n\t\tconst overlayRect = overlayElement.getBoundingClientRect();\n\t\tconst overlayContext = {\n\t\t\teditorDocument: blockEditorDocument,\n\t\t\toverlayRect,\n\t\t};\n\n\t\tconst results: CursorData[] = [];\n\n\t\tconst hasOtherCollaborators = sortedUsers.some(\n\t\t\t( u: ActiveCollaborator ) => ! u.isMe\n\t\t);\n\n\t\tsortedUsers.forEach( ( user: ActiveCollaborator ) => {\n\t\t\tif ( user.isMe && ( ! showOwnCursor || ! hasOtherCollaborators ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selection = user.editorState?.selection ?? {\n\t\t\t\ttype: SelectionType.None,\n\t\t\t};\n\n\t\t\tlet start: ResolvedSelection = {\n\t\t\t\trichTextOffset: null,\n\t\t\t\tlocalClientId: null,\n\t\t\t};\n\t\t\tlet end: ResolvedSelection | undefined;\n\n\t\t\tif ( selection.type === SelectionType.Cursor ) {\n\t\t\t\ttry {\n\t\t\t\t\tstart = resolveSelection( selection );\n\t\t\t\t} catch {\n\t\t\t\t\t// Selection may reference a stale Yjs position.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tselection.type === SelectionType.SelectionInOneBlock ||\n\t\t\t\tselection.type === SelectionType.SelectionInMultipleBlocks\n\t\t\t) {\n\t\t\t\ttry {\n\t\t\t\t\tstart = resolveSelection( {\n\t\t\t\t\t\ttype: SelectionType.Cursor,\n\t\t\t\t\t\tcursorPosition: selection.cursorStartPosition,\n\t\t\t\t\t} );\n\n\t\t\t\t\tend = resolveSelection( {\n\t\t\t\t\t\ttype: SelectionType.Cursor,\n\t\t\t\t\t\tcursorPosition: selection.cursorEndPosition,\n\t\t\t\t\t} );\n\t\t\t\t} catch {\n\t\t\t\t\t// Selection may reference a stale Yjs position.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst userName = user.collaboratorInfo.name;\n\t\t\tconst clientId = user.clientId;\n\t\t\tconst color = user.isMe\n\t\t\t\t? 'var(--wp-admin-theme-color)'\n\t\t\t\t: getAvatarBorderColor( user.collaboratorInfo.id );\n\t\t\tconst avatarUrl = getAvatarUrl( user.collaboratorInfo.avatar_urls );\n\n\t\t\tconst selectionVisual = computeSelectionVisual(\n\t\t\t\tselection,\n\t\t\t\tstart,\n\t\t\t\tend,\n\t\t\t\toverlayContext\n\t\t\t);\n\n\t\t\tif ( selectionVisual.coords ) {\n\t\t\t\tconst cursorData: CursorData = {\n\t\t\t\t\tuserName,\n\t\t\t\t\tclientId,\n\t\t\t\t\tcolor,\n\t\t\t\t\tavatarUrl,\n\t\t\t\t\tisMe: user.isMe,\n\t\t\t\t\t...selectionVisual.coords,\n\t\t\t\t};\n\n\t\t\t\tif ( selectionVisual.selectionRects ) {\n\t\t\t\t\tcursorData.selectionRects = selectionVisual.selectionRects;\n\t\t\t\t}\n\n\t\t\t\tresults.push( cursorData );\n\t\t\t}\n\t\t} );\n\n\t\tsetCursorPositions( results );\n\t}, [\n\t\tblockEditorDocument,\n\t\tresolveSelection,\n\t\toverlayElement,\n\t\tsortedUsers,\n\t\tshowOwnCursor,\n\t\trecomputeToken,\n\t] );\n\n\treturn { cursors: cursorPositions, rerenderCursorsAfterDelay };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAIO;AACP,kBAA0B;AAC1B,qBAAoC;AACpC,yBAA0C;AAG1C,yBAAuB;AACvB,4BAA6B;AAC7B,mBAAqC;AACrC,+BAAuC;AACvC,qCAAsC;AAGtC,IAAM,EAAE,wBAAwB,qBAAqB,QACpD,2BAAQ,iBAAAA,WAAoB;AA0BtB,SAAS,iBACf,gBACA,qBACA,QACA,UACA,SACyE;AACzE,QAAM,cAAc;AAAA,IACnB,UAAU;AAAA,IACV,YAAY;AAAA,EACb;AACA,QAAM,mBAAmB;AAAA,IACxB,UAAU;AAAA,IACV,YAAY;AAAA,EACb;AAEA,QAAM,oBAAgB;AAAA,IACrB,CAAE,WACD,OAAQ,mBAAAC,KAAiB,EAAE,IAAK,QAAQ,yBAA0B;AAAA,IACnE,CAAC;AAAA,EACF;AAEA,QAAM,CAAE,iBAAiB,kBAAmB,QAAI;AAAA,IAC/C,CAAC;AAAA,EACF;AAGA,QAAM,CAAE,gBAAgB,yBAA0B,QACjD,sDAAuB,OAAQ;AAGhC,gCAAW,MAAM;AAChB,QAAK,CAAE,kBAAkB,CAAE,qBAAsB;AAChD,yBAAoB,CAAC,CAAE;AACvB;AAAA,IACD;AAGA,UAAM,cAAc,eAAe,sBAAsB;AACzD,UAAM,iBAAiB;AAAA,MACtB,gBAAgB;AAAA,MAChB;AAAA,IACD;AAEA,UA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B;AAAA,QAC7C;AAEA,gBAAQ,KAAM,UAAW;AAAA,MAC1B;AAAA,IACD,CAAE;AAEF,uBAAoB,OAAQ;AAAA,EAC7B,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SAAO,EAAE,SAAS,iBAAiB,0BAA0B;AAC9D;",
6
6
  "names": ["coreDataPrivateApis", "preferencesStore"]
7
7
  }
@@ -43,11 +43,12 @@ var import_list = require("./list.cjs");
43
43
  var import_lock_unlock = require("../../lock-unlock.cjs");
44
44
  var import_get_avatar_url = require("../collaborators-overlay/get-avatar-url.cjs");
45
45
  var import_utils = require("../collab-sidebar/utils.cjs");
46
+ var import_cursor_registry = require("../collaborators-overlay/cursor-registry.cjs");
46
47
 
47
48
  // packages/editor/src/components/collaborators-presence/styles/collaborators-presence.scss
48
- if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='eee1778bc0']")) {
49
+ if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='5ffe927286']")) {
49
50
  const style = document.createElement("style");
50
- style.setAttribute("data-wp-hash", "eee1778bc0");
51
+ style.setAttribute("data-wp-hash", "5ffe927286");
51
52
  style.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}"));
52
53
  document.head.appendChild(style);
53
54
  }
@@ -78,6 +79,7 @@ function CollaboratorsPresence({
78
79
  return 0;
79
80
  });
80
81
  }, [activeCollaborators]);
82
+ const [cursorRegistry] = (0, import_element.useState)(import_cursor_registry.createCursorRegistry);
81
83
  const [isPopoverVisible, setIsPopoverVisible] = (0, import_element.useState)(false);
82
84
  const [popoverAnchor, setPopoverAnchor] = (0, import_element.useState)(
83
85
  null
@@ -138,11 +140,19 @@ function CollaboratorsPresence({
138
140
  {
139
141
  activeCollaborators: collaboratorsForList,
140
142
  popoverAnchor,
141
- setIsPopoverVisible
143
+ setIsPopoverVisible,
144
+ cursorRegistry
142
145
  }
143
146
  )
144
147
  ] }),
145
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_collaborators_overlay.CollaboratorsOverlay, { postId, postType })
148
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
149
+ import_collaborators_overlay.CollaboratorsOverlay,
150
+ {
151
+ postId,
152
+ postType,
153
+ cursorRegistry
154
+ }
155
+ )
146
156
  ] });
147
157
  }
148
158
  // Annotate the CommonJS export names for ESM import in node: