@wordpress/editor 14.40.2-next.v.202602271551.0 → 14.40.2

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 (481) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/collab-sidebar/add-comment.cjs +0 -3
  3. package/build/components/collab-sidebar/add-comment.cjs.map +2 -2
  4. package/build/components/collab-sidebar/comments.cjs +0 -3
  5. package/build/components/collab-sidebar/comments.cjs.map +2 -2
  6. package/build/components/collab-sidebar/index.cjs +7 -4
  7. package/build/components/collab-sidebar/index.cjs.map +2 -2
  8. package/build/components/collab-sidebar/utils.cjs +13 -15
  9. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs +141 -0
  11. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +7 -0
  12. package/build/components/collaborators-overlay/collaborator-styles.cjs +38 -2
  13. package/build/components/collaborators-overlay/collaborator-styles.cjs.map +2 -2
  14. package/build/components/collaborators-overlay/compute-selection.cjs +185 -0
  15. package/build/components/collaborators-overlay/compute-selection.cjs.map +7 -0
  16. package/build/components/collaborators-overlay/cursor-dom-utils.cjs +243 -0
  17. package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +7 -0
  18. package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
  19. package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
  20. package/build/components/collaborators-overlay/index.cjs +7 -2
  21. package/build/components/collaborators-overlay/index.cjs.map +2 -2
  22. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +148 -0
  23. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +7 -0
  24. package/build/components/collaborators-overlay/overlay.cjs +141 -229
  25. package/build/components/collaborators-overlay/overlay.cjs.map +3 -3
  26. package/build/components/collaborators-overlay/timing-utils.cjs +46 -0
  27. package/build/components/collaborators-overlay/timing-utils.cjs.map +7 -0
  28. package/build/components/collaborators-overlay/use-block-highlighting.cjs +91 -42
  29. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +2 -2
  30. package/build/components/collaborators-overlay/use-debounced-recompute.cjs +49 -0
  31. package/build/components/collaborators-overlay/use-debounced-recompute.cjs.map +7 -0
  32. package/build/components/collaborators-overlay/use-render-cursors.cjs +82 -172
  33. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  34. package/build/components/collaborators-presence/avatar/component.cjs +121 -0
  35. package/build/components/collaborators-presence/avatar/component.cjs.map +7 -0
  36. package/build/components/collaborators-presence/avatar/index.cjs +37 -0
  37. package/build/components/collaborators-presence/avatar/index.cjs.map +7 -0
  38. package/build/components/collaborators-presence/avatar/types.cjs +19 -0
  39. package/build/components/collaborators-presence/avatar/types.cjs.map +7 -0
  40. package/build/components/collaborators-presence/avatar/use-image-loading-status.cjs +44 -0
  41. package/build/components/collaborators-presence/avatar/use-image-loading-status.cjs.map +7 -0
  42. package/build/components/collaborators-presence/avatar-group/component.cjs +78 -0
  43. package/build/components/collaborators-presence/avatar-group/component.cjs.map +7 -0
  44. package/build/components/collaborators-presence/avatar-group/index.cjs +37 -0
  45. package/build/components/collaborators-presence/avatar-group/index.cjs.map +7 -0
  46. package/build/components/collaborators-presence/avatar-group/types.cjs +19 -0
  47. package/build/components/collaborators-presence/avatar-group/types.cjs.map +7 -0
  48. package/build/components/collaborators-presence/index.cjs +66 -19
  49. package/build/components/collaborators-presence/index.cjs.map +3 -3
  50. package/build/components/collaborators-presence/list.cjs +60 -38
  51. package/build/components/collaborators-presence/list.cjs.map +3 -3
  52. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +149 -0
  53. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +7 -0
  54. package/build/components/editor-interface/index.cjs +11 -6
  55. package/build/components/editor-interface/index.cjs.map +2 -2
  56. package/build/components/inserter-sidebar/index.cjs +2 -1
  57. package/build/components/inserter-sidebar/index.cjs.map +2 -2
  58. package/build/components/more-menu/copy-content-menu-item.cjs +19 -2
  59. package/build/components/more-menu/copy-content-menu-item.cjs.map +3 -3
  60. package/build/components/post-last-revision/index.cjs +27 -6
  61. package/build/components/post-last-revision/index.cjs.map +2 -2
  62. package/build/components/post-locked-modal/index.cjs +49 -17
  63. package/build/components/post-locked-modal/index.cjs.map +3 -3
  64. package/build/components/post-revisions-preview/block-diff.cjs +130 -34
  65. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  66. package/build/components/post-revisions-preview/diff-markers.cjs +6 -5
  67. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  68. package/build/components/post-revisions-preview/revisions-canvas.cjs +16 -60
  69. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +3 -3
  70. package/build/components/post-revisions-preview/revisions-slider.cjs +102 -39
  71. package/build/components/post-revisions-preview/revisions-slider.cjs.map +3 -3
  72. package/build/components/post-text-editor/index.cjs +20 -5
  73. package/build/components/post-text-editor/index.cjs.map +3 -3
  74. package/build/components/preferences-modal/index.cjs +36 -4
  75. package/build/components/preferences-modal/index.cjs.map +2 -2
  76. package/build/components/provider/disable-non-page-content-blocks.cjs +31 -28
  77. package/build/components/provider/disable-non-page-content-blocks.cjs.map +3 -3
  78. package/build/components/provider/index.cjs +17 -5
  79. package/build/components/provider/index.cjs.map +2 -2
  80. package/build/components/provider/use-block-editor-settings.cjs +20 -4
  81. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  82. package/build/components/provider/{use-post-content-blocks.cjs → use-post-content-block-types.cjs} +8 -19
  83. package/build/components/provider/use-post-content-block-types.cjs.map +7 -0
  84. package/build/components/provider/use-revision-blocks.cjs +106 -0
  85. package/build/components/provider/use-revision-blocks.cjs.map +7 -0
  86. package/build/components/revision-block-diff/index.cjs +61 -0
  87. package/build/components/revision-block-diff/index.cjs.map +7 -0
  88. package/build/components/revision-diff-panel/index.cjs +68 -0
  89. package/build/components/revision-diff-panel/index.cjs.map +7 -0
  90. package/build/components/revision-fields-diff/index.cjs +96 -0
  91. package/build/components/revision-fields-diff/index.cjs.map +7 -0
  92. package/build/components/sidebar/header.cjs +1 -1
  93. package/build/components/sidebar/header.cjs.map +2 -2
  94. package/build/components/sidebar/index.cjs +7 -1
  95. package/build/components/sidebar/index.cjs.map +3 -3
  96. package/build/components/style-book/index.cjs +4 -3
  97. package/build/components/style-book/index.cjs.map +2 -2
  98. package/build/components/sync-connection-error-modal/index.cjs +187 -0
  99. package/build/components/sync-connection-error-modal/index.cjs.map +7 -0
  100. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs +84 -0
  101. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +7 -0
  102. package/build/components/template-content-panel/index.cjs +35 -31
  103. package/build/components/template-content-panel/index.cjs.map +3 -3
  104. package/build/components/template-part-menu-items/convert-to-regular.cjs +54 -11
  105. package/build/components/template-part-menu-items/convert-to-regular.cjs.map +3 -3
  106. package/build/components/visual-editor/index.cjs +6 -15
  107. package/build/components/visual-editor/index.cjs.map +2 -2
  108. package/build/store/private-actions.cjs +46 -2
  109. package/build/store/private-actions.cjs.map +2 -2
  110. package/build/store/private-selectors.cjs +154 -29
  111. package/build/store/private-selectors.cjs.map +2 -2
  112. package/build/store/reducer.cjs +27 -0
  113. package/build/store/reducer.cjs.map +2 -2
  114. package/build/store/selectors.cjs +0 -14
  115. package/build/store/selectors.cjs.map +2 -2
  116. package/build/utils/media-finalize/index.cjs +43 -0
  117. package/build/utils/media-finalize/index.cjs.map +7 -0
  118. package/build/utils/media-upload/on-success.cjs +46 -0
  119. package/build/utils/media-upload/on-success.cjs.map +7 -0
  120. package/build/utils/sync-error-messages.cjs +32 -15
  121. package/build/utils/sync-error-messages.cjs.map +3 -3
  122. package/build-module/components/collab-sidebar/add-comment.mjs +0 -3
  123. package/build-module/components/collab-sidebar/add-comment.mjs.map +2 -2
  124. package/build-module/components/collab-sidebar/comments.mjs +0 -3
  125. package/build-module/components/collab-sidebar/comments.mjs.map +2 -2
  126. package/build-module/components/collab-sidebar/index.mjs +7 -4
  127. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  128. package/build-module/components/collab-sidebar/utils.mjs +13 -15
  129. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  130. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs +128 -0
  131. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +7 -0
  132. package/build-module/components/collaborators-overlay/collaborator-styles.mjs +25 -1
  133. package/build-module/components/collaborators-overlay/collaborator-styles.mjs.map +2 -2
  134. package/build-module/components/collaborators-overlay/compute-selection.mjs +166 -0
  135. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +7 -0
  136. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +213 -0
  137. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +7 -0
  138. package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
  139. package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
  140. package/build-module/components/collaborators-overlay/index.mjs +7 -2
  141. package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
  142. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +130 -0
  143. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +7 -0
  144. package/build-module/components/collaborators-overlay/overlay.mjs +132 -230
  145. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  146. package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
  147. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
  148. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +93 -45
  149. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  150. package/build-module/components/collaborators-overlay/use-debounced-recompute.mjs +24 -0
  151. package/build-module/components/collaborators-overlay/use-debounced-recompute.mjs.map +7 -0
  152. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +83 -176
  153. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  154. package/build-module/components/collaborators-presence/avatar/component.mjs +90 -0
  155. package/build-module/components/collaborators-presence/avatar/component.mjs.map +7 -0
  156. package/build-module/components/collaborators-presence/avatar/index.mjs +6 -0
  157. package/build-module/components/collaborators-presence/avatar/index.mjs.map +7 -0
  158. package/build-module/components/collaborators-presence/avatar/types.mjs +1 -0
  159. package/build-module/components/collaborators-presence/avatar/types.mjs.map +7 -0
  160. package/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs +19 -0
  161. package/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs.map +7 -0
  162. package/build-module/components/collaborators-presence/avatar-group/component.mjs +47 -0
  163. package/build-module/components/collaborators-presence/avatar-group/component.mjs.map +7 -0
  164. package/build-module/components/collaborators-presence/avatar-group/index.mjs +6 -0
  165. package/build-module/components/collaborators-presence/avatar-group/index.mjs.map +7 -0
  166. package/build-module/components/collaborators-presence/avatar-group/types.mjs +1 -0
  167. package/build-module/components/collaborators-presence/avatar-group/types.mjs.map +7 -0
  168. package/build-module/components/collaborators-presence/index.mjs +57 -23
  169. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  170. package/build-module/components/collaborators-presence/list.mjs +52 -44
  171. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  172. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +126 -0
  173. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +7 -0
  174. package/build-module/components/editor-interface/index.mjs +12 -7
  175. package/build-module/components/editor-interface/index.mjs.map +2 -2
  176. package/build-module/components/inserter-sidebar/index.mjs +2 -1
  177. package/build-module/components/inserter-sidebar/index.mjs.map +2 -2
  178. package/build-module/components/more-menu/copy-content-menu-item.mjs +19 -2
  179. package/build-module/components/more-menu/copy-content-menu-item.mjs.map +2 -2
  180. package/build-module/components/post-last-revision/index.mjs +27 -6
  181. package/build-module/components/post-last-revision/index.mjs.map +2 -2
  182. package/build-module/components/post-locked-modal/index.mjs +49 -17
  183. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  184. package/build-module/components/post-revisions-preview/block-diff.mjs +130 -34
  185. package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
  186. package/build-module/components/post-revisions-preview/diff-markers.mjs +6 -5
  187. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  188. package/build-module/components/post-revisions-preview/revisions-canvas.mjs +18 -65
  189. package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
  190. package/build-module/components/post-revisions-preview/revisions-slider.mjs +110 -42
  191. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  192. package/build-module/components/post-text-editor/index.mjs +20 -5
  193. package/build-module/components/post-text-editor/index.mjs.map +2 -2
  194. package/build-module/components/preferences-modal/index.mjs +36 -4
  195. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  196. package/build-module/components/provider/disable-non-page-content-blocks.mjs +31 -28
  197. package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
  198. package/build-module/components/provider/index.mjs +17 -5
  199. package/build-module/components/provider/index.mjs.map +2 -2
  200. package/build-module/components/provider/use-block-editor-settings.mjs +20 -4
  201. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  202. package/build-module/components/provider/use-post-content-block-types.mjs +23 -0
  203. package/build-module/components/provider/use-post-content-block-types.mjs.map +7 -0
  204. package/build-module/components/provider/use-revision-blocks.mjs +81 -0
  205. package/build-module/components/provider/use-revision-blocks.mjs.map +7 -0
  206. package/build-module/components/revision-block-diff/index.mjs +30 -0
  207. package/build-module/components/revision-block-diff/index.mjs.map +7 -0
  208. package/build-module/components/revision-diff-panel/index.mjs +37 -0
  209. package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
  210. package/build-module/components/revision-fields-diff/index.mjs +65 -0
  211. package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
  212. package/build-module/components/sidebar/header.mjs +1 -1
  213. package/build-module/components/sidebar/header.mjs.map +2 -2
  214. package/build-module/components/sidebar/index.mjs +7 -1
  215. package/build-module/components/sidebar/index.mjs.map +2 -2
  216. package/build-module/components/style-book/index.mjs +4 -3
  217. package/build-module/components/style-book/index.mjs.map +2 -2
  218. package/build-module/components/sync-connection-error-modal/index.mjs +170 -0
  219. package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
  220. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +59 -0
  221. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
  222. package/build-module/components/template-content-panel/index.mjs +25 -31
  223. package/build-module/components/template-content-panel/index.mjs.map +2 -2
  224. package/build-module/components/template-part-menu-items/convert-to-regular.mjs +60 -14
  225. package/build-module/components/template-part-menu-items/convert-to-regular.mjs.map +2 -2
  226. package/build-module/components/visual-editor/index.mjs +6 -15
  227. package/build-module/components/visual-editor/index.mjs.map +2 -2
  228. package/build-module/store/private-actions.mjs +44 -2
  229. package/build-module/store/private-actions.mjs.map +2 -2
  230. package/build-module/store/private-selectors.mjs +153 -29
  231. package/build-module/store/private-selectors.mjs.map +2 -2
  232. package/build-module/store/reducer.mjs +25 -0
  233. package/build-module/store/reducer.mjs.map +2 -2
  234. package/build-module/store/selectors.mjs +0 -13
  235. package/build-module/store/selectors.mjs.map +2 -2
  236. package/build-module/utils/media-finalize/index.mjs +12 -0
  237. package/build-module/utils/media-finalize/index.mjs.map +7 -0
  238. package/build-module/utils/media-upload/on-success.mjs +25 -0
  239. package/build-module/utils/media-upload/on-success.mjs.map +7 -0
  240. package/build-module/utils/sync-error-messages.mjs +27 -15
  241. package/build-module/utils/sync-error-messages.mjs.map +3 -3
  242. package/build-style/style-rtl.css +296 -121
  243. package/build-style/style.css +296 -121
  244. package/build-types/components/autocompleters/link.d.ts +8 -0
  245. package/build-types/components/autocompleters/link.d.ts.map +1 -0
  246. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  247. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts +5 -0
  248. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts.map +1 -0
  249. package/build-types/components/collab-sidebar/add-note.d.ts +6 -0
  250. package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -0
  251. package/build-types/components/collab-sidebar/board-store.d.ts +9 -0
  252. package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -0
  253. package/build-types/components/collab-sidebar/floating-container.d.ts +8 -0
  254. package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -0
  255. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  256. package/build-types/components/collab-sidebar/note-byline.d.ts +10 -0
  257. package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -0
  258. package/build-types/components/collab-sidebar/note-card.d.ts +8 -0
  259. package/build-types/components/collab-sidebar/note-card.d.ts.map +1 -0
  260. package/build-types/components/collab-sidebar/note-form.d.ts +7 -0
  261. package/build-types/components/collab-sidebar/note-form.d.ts.map +1 -0
  262. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts +5 -0
  263. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -0
  264. package/build-types/components/collab-sidebar/note-thread.d.ts +11 -0
  265. package/build-types/components/collab-sidebar/note-thread.d.ts.map +1 -0
  266. package/build-types/components/collab-sidebar/note.d.ts +9 -0
  267. package/build-types/components/collab-sidebar/note.d.ts.map +1 -0
  268. package/build-types/components/collab-sidebar/notes.d.ts +7 -0
  269. package/build-types/components/collab-sidebar/notes.d.ts.map +1 -0
  270. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  271. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts +11 -0
  272. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts.map +1 -0
  273. package/build-types/components/collaborators-overlay/collaborator-styles.d.ts +17 -2
  274. package/build-types/components/collaborators-overlay/collaborator-styles.d.ts.map +1 -1
  275. package/build-types/components/collaborators-overlay/compute-selection.d.ts +24 -0
  276. package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -0
  277. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts +72 -0
  278. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts.map +1 -0
  279. package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
  280. package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
  281. package/build-types/components/collaborators-overlay/index.d.ts +7 -4
  282. package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
  283. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +6 -0
  284. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -0
  285. package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
  286. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  287. package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
  288. package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
  289. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +21 -5
  290. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  291. package/build-types/components/collaborators-overlay/use-debounced-recompute.d.ts +10 -0
  292. package/build-types/components/collaborators-overlay/use-debounced-recompute.d.ts.map +1 -0
  293. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts +6 -1
  294. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  295. package/build-types/components/collaborators-presence/avatar/component.d.ts +7 -0
  296. package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -0
  297. package/build-types/components/collaborators-presence/avatar/index.d.ts +3 -0
  298. package/build-types/components/collaborators-presence/avatar/index.d.ts.map +1 -0
  299. package/build-types/components/collaborators-presence/avatar/types.d.ts +66 -0
  300. package/build-types/components/collaborators-presence/avatar/types.d.ts.map +1 -0
  301. package/build-types/components/collaborators-presence/avatar/use-image-loading-status.d.ts +17 -0
  302. package/build-types/components/collaborators-presence/avatar/use-image-loading-status.d.ts.map +1 -0
  303. package/build-types/components/collaborators-presence/avatar-group/component.d.ts +7 -0
  304. package/build-types/components/collaborators-presence/avatar-group/component.d.ts.map +1 -0
  305. package/build-types/components/collaborators-presence/avatar-group/index.d.ts +3 -0
  306. package/build-types/components/collaborators-presence/avatar-group/index.d.ts.map +1 -0
  307. package/build-types/components/collaborators-presence/avatar-group/types.d.ts +14 -0
  308. package/build-types/components/collaborators-presence/avatar-group/types.d.ts.map +1 -0
  309. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  310. package/build-types/components/collaborators-presence/list.d.ts +6 -2
  311. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  312. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts +9 -0
  313. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -0
  314. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  315. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  316. package/build-types/components/media/media-editor-modal.d.ts +15 -0
  317. package/build-types/components/media/media-editor-modal.d.ts.map +1 -0
  318. package/build-types/components/more-menu/copy-content-menu-item.d.ts.map +1 -1
  319. package/build-types/components/post-last-revision/index.d.ts.map +1 -1
  320. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  321. package/build-types/components/post-revisions-panel/index.d.ts +2 -0
  322. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
  323. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  324. package/build-types/components/post-revisions-preview/diff-markers.d.ts.map +1 -1
  325. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +2 -5
  326. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
  327. package/build-types/components/post-revisions-preview/revisions-slider.d.ts +1 -1
  328. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  329. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  330. package/build-types/components/post-text-editor/utils.d.ts +29 -0
  331. package/build-types/components/post-text-editor/utils.d.ts.map +1 -0
  332. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  333. package/build-types/components/provider/index.d.ts.map +1 -1
  334. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  335. package/build-types/components/provider/use-network-reconnect.d.ts +8 -0
  336. package/build-types/components/provider/use-network-reconnect.d.ts.map +1 -0
  337. package/build-types/components/provider/use-post-content-block-types.d.ts +9 -0
  338. package/build-types/components/provider/use-post-content-block-types.d.ts.map +1 -0
  339. package/build-types/components/provider/use-revision-blocks.d.ts +10 -0
  340. package/build-types/components/provider/use-revision-blocks.d.ts.map +1 -0
  341. package/build-types/components/revision-block-diff/index.d.ts +6 -0
  342. package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
  343. package/build-types/components/revision-diff-panel/index.d.ts +14 -0
  344. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
  345. package/build-types/components/revision-fields-diff/index.d.ts +6 -0
  346. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
  347. package/build-types/components/sidebar/dataform-post-summary.d.ts +4 -0
  348. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -0
  349. package/build-types/components/sidebar/index.d.ts.map +1 -1
  350. package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
  351. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
  352. package/build-types/components/style-book/index.d.ts +2 -1
  353. package/build-types/components/style-book/index.d.ts.map +1 -1
  354. package/build-types/components/sync-connection-error-modal/index.d.ts +8 -0
  355. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
  356. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
  357. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
  358. package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
  359. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
  360. package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
  361. package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
  362. package/build-types/components/template-actions-panel/index.d.ts +2 -0
  363. package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
  364. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  365. package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -1
  366. package/build-types/components/upload-progress-snackbar/index.d.ts +19 -0
  367. package/build-types/components/upload-progress-snackbar/index.d.ts.map +1 -0
  368. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts +28 -0
  369. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts.map +1 -0
  370. package/build-types/components/upload-progress-snackbar/tracker.d.ts +41 -0
  371. package/build-types/components/upload-progress-snackbar/tracker.d.ts.map +1 -0
  372. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  373. package/build-types/store/private-actions.d.ts +12 -0
  374. package/build-types/store/private-actions.d.ts.map +1 -1
  375. package/build-types/store/private-selectors.d.ts +45 -0
  376. package/build-types/store/private-selectors.d.ts.map +1 -1
  377. package/build-types/store/reducer.d.ts +21 -0
  378. package/build-types/store/reducer.d.ts.map +1 -1
  379. package/build-types/store/selectors.d.ts +0 -10
  380. package/build-types/store/selectors.d.ts.map +1 -1
  381. package/build-types/utils/media-delete/index.d.ts +2 -0
  382. package/build-types/utils/media-delete/index.d.ts.map +1 -0
  383. package/build-types/utils/media-finalize/index.d.ts +2 -0
  384. package/build-types/utils/media-finalize/index.d.ts.map +1 -0
  385. package/build-types/utils/media-upload/on-success.d.ts +9 -0
  386. package/build-types/utils/media-upload/on-success.d.ts.map +1 -0
  387. package/build-types/utils/sync-error-messages.d.ts +17 -3
  388. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  389. package/package.json +45 -44
  390. package/src/components/collab-sidebar/add-comment.js +0 -4
  391. package/src/components/collab-sidebar/comments.js +0 -5
  392. package/src/components/collab-sidebar/index.js +7 -4
  393. package/src/components/collab-sidebar/utils.js +9 -10
  394. package/src/components/collaborators-overlay/avatar-iframe-styles.ts +134 -0
  395. package/src/components/collaborators-overlay/collaborator-styles.ts +43 -2
  396. package/src/components/collaborators-overlay/compute-selection.ts +315 -0
  397. package/src/components/collaborators-overlay/cursor-dom-utils.ts +382 -0
  398. package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
  399. package/src/components/collaborators-overlay/index.tsx +12 -4
  400. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +131 -0
  401. package/src/components/collaborators-overlay/overlay.tsx +145 -223
  402. package/src/components/collaborators-overlay/timing-utils.ts +30 -0
  403. package/src/components/collaborators-overlay/use-block-highlighting.ts +152 -64
  404. package/src/components/collaborators-overlay/use-debounced-recompute.ts +32 -0
  405. package/src/components/collaborators-overlay/use-render-cursors.ts +120 -282
  406. package/src/components/collaborators-presence/avatar/component.tsx +123 -0
  407. package/src/components/collaborators-presence/avatar/index.ts +2 -0
  408. package/src/components/collaborators-presence/avatar/styles.scss +184 -0
  409. package/src/components/collaborators-presence/avatar/test/index.tsx +389 -0
  410. package/src/components/collaborators-presence/avatar/types.ts +66 -0
  411. package/src/components/collaborators-presence/avatar/use-image-loading-status.ts +36 -0
  412. package/src/components/collaborators-presence/avatar-group/component.tsx +55 -0
  413. package/src/components/collaborators-presence/avatar-group/index.ts +2 -0
  414. package/src/components/collaborators-presence/avatar-group/styles.scss +33 -0
  415. package/src/components/collaborators-presence/avatar-group/test/index.tsx +139 -0
  416. package/src/components/collaborators-presence/avatar-group/types.ts +13 -0
  417. package/src/components/collaborators-presence/index.tsx +43 -12
  418. package/src/components/collaborators-presence/list.tsx +68 -40
  419. package/src/components/collaborators-presence/styles/collaborators-list.scss +26 -19
  420. package/src/components/collaborators-presence/styles/collaborators-presence.scss +6 -2
  421. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +397 -0
  422. package/src/components/collaborators-presence/use-collaborator-notifications.ts +203 -0
  423. package/src/components/document-bar/style.scss +1 -1
  424. package/src/components/editor-interface/index.js +13 -6
  425. package/src/components/inserter-sidebar/index.js +4 -1
  426. package/src/components/more-menu/copy-content-menu-item.js +20 -2
  427. package/src/components/post-last-revision/index.js +35 -6
  428. package/src/components/post-last-revision/style.scss +0 -3
  429. package/src/components/post-locked-modal/index.js +69 -25
  430. package/src/components/post-panel-row/style.scss +1 -0
  431. package/src/components/post-revisions-preview/block-diff.js +224 -61
  432. package/src/components/post-revisions-preview/diff-markers.js +15 -12
  433. package/src/components/post-revisions-preview/revisions-canvas.js +23 -86
  434. package/src/components/post-revisions-preview/revisions-slider.js +136 -63
  435. package/src/components/post-revisions-preview/style.scss +3 -3
  436. package/src/components/post-revisions-preview/test/block-diff.js +202 -35
  437. package/src/components/post-text-editor/index.js +25 -6
  438. package/src/components/preferences-modal/index.js +37 -7
  439. package/src/components/provider/disable-non-page-content-blocks.js +42 -40
  440. package/src/components/provider/index.js +20 -2
  441. package/src/components/provider/use-block-editor-settings.js +21 -1
  442. package/src/components/provider/use-post-content-block-types.js +30 -0
  443. package/src/components/provider/use-revision-blocks.js +105 -0
  444. package/src/components/revision-block-diff/index.js +39 -0
  445. package/src/components/revision-diff-panel/index.js +59 -0
  446. package/src/components/revision-diff-panel/style.scss +13 -0
  447. package/src/components/revision-fields-diff/index.js +91 -0
  448. package/src/components/sidebar/header.js +1 -1
  449. package/src/components/sidebar/index.js +4 -0
  450. package/src/components/style-book/index.js +4 -2
  451. package/src/components/sync-connection-error-modal/index.tsx +253 -0
  452. package/src/components/sync-connection-error-modal/style.scss +14 -0
  453. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +93 -0
  454. package/src/components/template-content-panel/index.js +30 -38
  455. package/src/components/template-part-menu-items/convert-to-regular.js +74 -12
  456. package/src/components/visual-editor/index.js +6 -23
  457. package/src/store/private-actions.js +70 -1
  458. package/src/store/private-selectors.js +215 -37
  459. package/src/store/reducer.js +41 -0
  460. package/src/store/selectors.js +0 -19
  461. package/src/style.scss +4 -1
  462. package/src/utils/media-finalize/index.js +11 -0
  463. package/src/utils/media-finalize/test/index.js +34 -0
  464. package/src/utils/media-upload/on-success.js +34 -0
  465. package/src/utils/sync-error-messages.ts +72 -0
  466. package/src/utils/test/sync-error-messages.js +34 -0
  467. package/build/components/provider/use-post-content-blocks.cjs.map +0 -7
  468. package/build/components/sync-connection-modal/index.cjs +0 -130
  469. package/build/components/sync-connection-modal/index.cjs.map +0 -7
  470. package/build-module/components/provider/use-post-content-blocks.mjs +0 -34
  471. package/build-module/components/provider/use-post-content-blocks.mjs.map +0 -7
  472. package/build-module/components/sync-connection-modal/index.mjs +0 -114
  473. package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
  474. package/build-types/components/provider/use-post-content-blocks.d.ts +0 -2
  475. package/build-types/components/provider/use-post-content-blocks.d.ts.map +0 -1
  476. package/build-types/components/sync-connection-modal/index.d.ts +0 -8
  477. package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
  478. package/src/components/provider/use-post-content-blocks.js +0 -42
  479. package/src/components/sync-connection-modal/index.js +0 -140
  480. package/src/components/sync-connection-modal/style.scss +0 -11
  481. package/src/utils/sync-error-messages.js +0 -53
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-overlay/overlay.tsx"],
4
- "sourcesContent": ["import { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { useResizeObserver, useMergeRefs } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\n\nimport { unlock } from '../../lock-unlock';\nimport { useBlockHighlighting } from './use-block-highlighting';\nimport { useRenderCursors } from './use-render-cursors';\nimport { ELEVATION_X_SMALL } from './collaborator-styles';\n\nconst { Avatar } = unlock( componentsPrivateApis );\n\n// wp-components styles are excluded from the editor canvas iframe, so the\n// Avatar component's SCSS is not available there. We inject compiled versions\n// of the relevant rules alongside the overlay-specific positioning styles.\nconst COLLABORATORS_OVERLAY_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.collaborators-overlay-user-cursor {\n\tposition: absolute;\n\twidth: 2px;\n\tborder-radius: 1px;\n\toutline: 1px solid #fff;\n\tbox-shadow: ${ ELEVATION_X_SMALL };\n\tanimation: collaborators-overlay-cursor-blink 1s infinite;\n}\n\n/* \u2500\u2500 Avatar component (compiled from packages/components/src/avatar/styles.scss) \u2500\u2500 */\n.components-avatar {\n\tdisplay: inline-flex;\n\talign-items: center;\n\tborder-radius: 9999px;\n\toverflow: clip;\n\tflex-shrink: 0;\n\tbackground-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));\n\tbox-shadow: 0 0 0 var(--wp-admin-border-width-focus, 2px) #fff, ${ ELEVATION_X_SMALL };\n}\n.components-avatar__image {\n\tbox-sizing: border-box;\n\tposition: relative;\n\twidth: 32px;\n\theight: 32px;\n\tborder-radius: 9999px;\n\tborder: 0;\n\tbackground-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));\n\toverflow: clip;\n\tflex-shrink: 0;\n\tfont-size: 0;\n\tcolor: #fff;\n}\n.is-small > .components-avatar__image {\n\twidth: 24px;\n\theight: 24px;\n}\n.has-src > .components-avatar__image {\n\tbackground-image: var(--components-avatar-url);\n\tbackground-size: cover;\n\tbackground-position: center;\n}\n.has-avatar-border-color > .components-avatar__image {\n\tborder: var(--wp-admin-border-width-focus, 2px) solid var(--components-avatar-outline-color);\n\tbox-shadow: inset 0 0 0 var(--wp-admin-border-width-focus, 2px) #fff;\n\tbackground-clip: padding-box;\n}\n.components-avatar:not(.has-src) > .components-avatar__image {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tfont-size: 11px;\n\tfont-weight: 499;\n\tborder: 0;\n\tbox-shadow: none;\n\tbackground-clip: border-box;\n}\n.components-avatar:not(.has-src).has-avatar-border-color > .components-avatar__image {\n\tbackground-color: var(--components-avatar-outline-color);\n}\n.components-avatar__name {\n\tfont-size: 13px;\n\tline-height: 20px;\n\tcolor: #fff;\n\tmin-width: 0;\n\tpadding-bottom: 2px;\n\toverflow: hidden;\n\topacity: 0;\n\twhite-space: nowrap;\n\ttransition: opacity 0.15s cubic-bezier(0.15, 0, 0.15, 1);\n}\n.components-avatar.has-badge {\n\tdisplay: inline-grid;\n\tgrid-template-columns: min-content 0fr;\n\tcolumn-gap: 0;\n\tpadding-inline-end: 0;\n\ttransition:\n\t\tgrid-template-columns 0.3s cubic-bezier(0.15, 0, 0.15, 1),\n\t\tcolumn-gap 0.3s cubic-bezier(0.15, 0, 0.15, 1),\n\t\tpadding-inline-end 0.3s cubic-bezier(0.15, 0, 0.15, 1);\n}\n.components-avatar.has-badge:hover {\n\tgrid-template-columns: min-content 1fr;\n\tcolumn-gap: 4px;\n\tpadding-inline-end: 8px;\n\ttransition-timing-function: cubic-bezier(0.85, 0, 0.85, 1);\n}\n.components-avatar.has-badge:hover .components-avatar__name {\n\topacity: 1;\n\ttransition-timing-function: cubic-bezier(0.85, 0, 0.85, 1);\n}\n.components-avatar.has-badge.has-avatar-border-color {\n\tbackground-color: var(--components-avatar-outline-color);\n}\n/* \u2500\u2500 end Avatar \u2500\u2500 */\n\n/* Overlay-specific positioning applied to the Avatar cursor label. */\n.collaborators-overlay-user-label.components-avatar {\n\tposition: absolute;\n\ttransform: translate(-11px, -100%);\n\tmargin-top: -4px;\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, 2px) + 1px) #fff, 0 0 0 1px #fff, ${ ELEVATION_X_SMALL };\n\tz-index: 1;\n}\n@media (prefers-reduced-motion: reduce) {\n\t.components-avatar.has-badge,\n\t.components-avatar__name,\n\t.collaborators-overlay-user-label,\n\t.collaborators-overlay-user-cursor {\n\t\ttransition: none;\n\t\tanimation: none;\n\t}\n}\n`;\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);\n\n\t// Detect layout changes on overlay (e.g. turning on \"Show Template\") and window\n\t// resizes, and re-render the cursors.\n\tconst resizeObserverRef = useResizeObserver( rerenderCursorsAfterDelay );\n\tuseEffect( rerenderCursorsAfterDelay, [ 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\tuseBlockHighlighting(\n\t\tblockEditorDocument ?? null,\n\t\tpostId ?? null,\n\t\tpostType ?? null\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>{ COLLABORATORS_OVERLAY_STYLES }</style>\n\t\t\t{ cursors.map( ( cursor ) => (\n\t\t\t\t<div\n\t\t\t\t\tkey={ cursor.clientId }\n\t\t\t\t\tclassName=\"collaborators-overlay-user\"\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft: `${ cursor.x }px`,\n\t\t\t\t\t\ttop: `${ cursor.y }px`,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"collaborators-overlay-user-cursor\"\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\tbackgroundColor: cursor.color,\n\t\t\t\t\t\t\theight: `${ cursor.height }px`,\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<Avatar\n\t\t\t\t\t\tclassName=\"collaborators-overlay-user-label\"\n\t\t\t\t\t\tbad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AAA,cAC3B;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,OAAK;AAAA,cACL,MAAK;AAAA,cACL,KAAM,OAAO;AAAA,cACb,MAAO,OAAO;AAAA,cACd,aAAc,OAAO;AAAA;AAAA,UACtB;AAAA;AAAA;AAAA,MArBM,OAAO;AAAA,IAsBd,CACC;AAAA,KACH;AAEF;",
6
- "names": ["componentsPrivateApis"]
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.selectionRects?.map( ( rect, index ) => (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tkey={ `${ cursor.clientId }-sel-${ index }` }\n\t\t\t\t\t\t\tclassName=\"collaborators-overlay-selection-rect\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tleft: `${ rect.x }px`,\n\t\t\t\t\t\t\t\ttop: `${ rect.y }px`,\n\t\t\t\t\t\t\t\twidth: `${ rect.width }px`,\n\t\t\t\t\t\t\t\theight: `${ rect.height }px`,\n\t\t\t\t\t\t\t\tbackgroundColor: cursor.color,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t\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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wnPropDesc = 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
+ }
@@ -27,8 +27,11 @@ var import_core_data = require("@wordpress/core-data");
27
27
  var import_element = require("@wordpress/element");
28
28
  var import_lock_unlock = require("../../lock-unlock.cjs");
29
29
  var import_utils = require("../collab-sidebar/utils.cjs");
30
+ var import_get_avatar_url = require("./get-avatar-url.cjs");
31
+ var import_use_debounced_recompute = require("./use-debounced-recompute.cjs");
30
32
  var { useActiveCollaborators, useResolvedSelection } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
31
- function useBlockHighlighting(blockEditorDocument, postId, postType) {
33
+ var { SelectionType } = (0, import_lock_unlock.unlock)(import_core_data.privateApis);
34
+ function useBlockHighlighting(overlayElement, blockEditorDocument, postId, postType, delayMs) {
32
35
  const highlightedBlockIds = (0, import_element.useRef)(/* @__PURE__ */ new Set());
33
36
  const userStates = useActiveCollaborators(
34
37
  postId ?? null,
@@ -38,12 +41,55 @@ function useBlockHighlighting(blockEditorDocument, postId, postType) {
38
41
  postId ?? null,
39
42
  postType ?? null
40
43
  );
44
+ const [highlights, setHighlights] = (0, import_element.useState)(
45
+ []
46
+ );
47
+ const [recomputeToken, rerenderHighlightsAfterDelay] = (0, import_use_debounced_recompute.useDebouncedRecompute)(delayMs);
41
48
  (0, import_element.useEffect)(() => {
42
- if (blockEditorDocument === null) {
49
+ if (!blockEditorDocument) {
50
+ setHighlights([]);
43
51
  return;
44
52
  }
45
- const unhighlightBlocks = (blockIds) => {
46
- blockIds.forEach((blockId) => {
53
+ const currentHighlightedIds = highlightedBlockIds.current;
54
+ const seen = /* @__PURE__ */ new Set();
55
+ const blocksToHighlight = userStates.filter((userState) => {
56
+ const isWholeBlockSelected = userState.editorState?.selection?.type === SelectionType.WholeBlock;
57
+ return !userState.isMe && isWholeBlockSelected;
58
+ }).map((userState) => {
59
+ let localClientId;
60
+ try {
61
+ ({ localClientId } = resolveSelection(
62
+ userState.editorState?.selection
63
+ ));
64
+ } catch {
65
+ return null;
66
+ }
67
+ if (!localClientId) {
68
+ return null;
69
+ }
70
+ return {
71
+ blockId: localClientId,
72
+ color: userState.isMe ? "var(--wp-admin-theme-color)" : (0, import_utils.getAvatarBorderColor)(userState.collaboratorInfo.id),
73
+ userName: userState.collaboratorInfo.name,
74
+ avatarUrl: (0, import_get_avatar_url.getAvatarUrl)(
75
+ userState.collaboratorInfo.avatar_urls
76
+ )
77
+ };
78
+ }).filter((block) => {
79
+ if (!block) {
80
+ return false;
81
+ }
82
+ if (seen.has(block.blockId)) {
83
+ return false;
84
+ }
85
+ seen.add(block.blockId);
86
+ return true;
87
+ });
88
+ const selectedBlockIds = new Set(
89
+ blocksToHighlight.map((block) => block.blockId)
90
+ );
91
+ for (const blockId of currentHighlightedIds) {
92
+ if (!selectedBlockIds.has(blockId)) {
47
93
  const blockElement = getBlockElementById(
48
94
  blockEditorDocument,
49
95
  blockId
@@ -54,37 +100,13 @@ function useBlockHighlighting(blockEditorDocument, postId, postType) {
54
100
  "--collaborator-outline-color"
55
101
  );
56
102
  }
57
- highlightedBlockIds.current.delete(blockId);
58
- });
59
- };
60
- const blocksToHighlight = userStates.map((userState) => {
61
- const isWholeBlockSelected = userState.editorState?.selection?.type === import_core_data.SelectionType.WholeBlock;
62
- const shouldDrawUser = !userState.isMe;
63
- if (isWholeBlockSelected && shouldDrawUser) {
64
- const { localClientId } = resolveSelection(
65
- userState.editorState?.selection
66
- );
67
- if (!localClientId) {
68
- return null;
69
- }
70
- return {
71
- blockId: localClientId,
72
- color: (0, import_utils.getAvatarBorderColor)(
73
- userState.collaboratorInfo.id
74
- )
75
- };
103
+ currentHighlightedIds.delete(blockId);
76
104
  }
77
- return null;
78
- }).filter((block) => block !== null);
79
- const selectedBlockIds = blocksToHighlight.map(
80
- (block) => block.blockId
81
- );
82
- const blocksIdsToUnhighlight = Array.from(
83
- highlightedBlockIds.current
84
- ).filter((blockId) => !selectedBlockIds.includes(blockId));
85
- unhighlightBlocks(blocksIdsToUnhighlight);
86
- blocksToHighlight.forEach((blockColorPair) => {
87
- const { color, blockId } = blockColorPair;
105
+ }
106
+ const results = [];
107
+ const overlayRect = overlayElement?.getBoundingClientRect() ?? null;
108
+ blocksToHighlight.forEach((block) => {
109
+ const { color, blockId, userName, avatarUrl } = block;
88
110
  const blockElement = getBlockElementById(
89
111
  blockEditorDocument,
90
112
  blockId
@@ -92,16 +114,43 @@ function useBlockHighlighting(blockEditorDocument, postId, postType) {
92
114
  if (!blockElement) {
93
115
  return;
94
116
  }
95
- if (blockElement) {
96
- blockElement.classList.add("is-collaborator-selected");
97
- blockElement.style.setProperty(
98
- "--collaborator-outline-color",
99
- color
100
- );
101
- highlightedBlockIds.current.add(blockId);
117
+ blockElement.classList.add("is-collaborator-selected");
118
+ blockElement.style.setProperty(
119
+ "--collaborator-outline-color",
120
+ color
121
+ );
122
+ currentHighlightedIds.add(blockId);
123
+ if (overlayRect) {
124
+ const blockRect = blockElement.getBoundingClientRect();
125
+ results.push({
126
+ blockId,
127
+ userName,
128
+ avatarUrl,
129
+ color,
130
+ x: blockRect.left - overlayRect.left,
131
+ y: blockRect.top - overlayRect.top
132
+ });
102
133
  }
103
134
  });
104
- }, [userStates, blockEditorDocument, resolveSelection]);
135
+ setHighlights(results);
136
+ return () => {
137
+ for (const blockId of currentHighlightedIds) {
138
+ const el = getBlockElementById(blockEditorDocument, blockId);
139
+ if (el) {
140
+ el.classList.remove("is-collaborator-selected");
141
+ el.style.removeProperty("--collaborator-outline-color");
142
+ }
143
+ }
144
+ currentHighlightedIds.clear();
145
+ };
146
+ }, [
147
+ userStates,
148
+ blockEditorDocument,
149
+ overlayElement,
150
+ recomputeToken,
151
+ resolveSelection
152
+ ]);
153
+ return { highlights, rerenderHighlightsAfterDelay };
105
154
  }
106
155
  var getBlockElementById = (blockEditorDocument, blockId) => {
107
156
  return blockEditorDocument.querySelector(`[data-block="${blockId}"]`);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collaborators-overlay/use-block-highlighting.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as coreDataPrivateApis,\n\tSelectionType,\n} from '@wordpress/core-data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\n\nconst { useActiveCollaborators, useResolvedSelection } =\n\tunlock( coreDataPrivateApis );\n\n/**\n * Custom hook for highlighting selected blocks in the editor\n * @param blockEditorDocument - Ref to the block editor document, used to directly style block elements.\n * @param postId - The ID of the post\n * @param postType - The type of the post\n */\nexport function useBlockHighlighting(\n\tblockEditorDocument: Document | null,\n\tpostId: number | null,\n\tpostType: string | null\n) {\n\tconst highlightedBlockIds = useRef< Set< string > >( new Set() );\n\tconst userStates = 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\t// Draw block highlights\n\tuseEffect( () => {\n\t\t// Don't do anything if editor is not rendered yet.\n\t\tif ( blockEditorDocument === null ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst unhighlightBlocks = ( blockIds: string[] ) => {\n\t\t\tblockIds.forEach( ( blockId ) => {\n\t\t\t\tconst blockElement = getBlockElementById(\n\t\t\t\t\tblockEditorDocument,\n\t\t\t\t\tblockId\n\t\t\t\t);\n\n\t\t\t\tif ( blockElement ) {\n\t\t\t\t\tblockElement.classList.remove( 'is-collaborator-selected' );\n\t\t\t\t\tblockElement.style.removeProperty(\n\t\t\t\t\t\t'--collaborator-outline-color'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\thighlightedBlockIds.current.delete( blockId );\n\t\t\t} );\n\t\t};\n\n\t\tconst blocksToHighlight = userStates\n\t\t\t.map( ( userState: any ) => {\n\t\t\t\tconst isWholeBlockSelected =\n\t\t\t\t\tuserState.editorState?.selection?.type ===\n\t\t\t\t\tSelectionType.WholeBlock;\n\t\t\t\tconst shouldDrawUser = ! userState.isMe;\n\n\t\t\t\tif ( isWholeBlockSelected && shouldDrawUser ) {\n\t\t\t\t\tconst { localClientId } = resolveSelection(\n\t\t\t\t\t\tuserState.editorState?.selection\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( ! localClientId ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tblockId: localClientId,\n\t\t\t\t\t\tcolor: getAvatarBorderColor(\n\t\t\t\t\t\t\tuserState.collaboratorInfo.id\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t} )\n\t\t\t.filter( ( block: any ) => block !== null );\n\n\t\t// Unhighlight blocks that are no longer highlighted.\n\t\tconst selectedBlockIds = blocksToHighlight.map(\n\t\t\t( block: any ) => block.blockId\n\t\t);\n\t\tconst blocksIdsToUnhighlight = Array.from(\n\t\t\thighlightedBlockIds.current\n\t\t).filter( ( blockId ) => ! selectedBlockIds.includes( blockId ) );\n\n\t\tunhighlightBlocks( blocksIdsToUnhighlight );\n\n\t\t// Highlight blocks that are currently highlighted.\n\t\tblocksToHighlight.forEach( ( blockColorPair: any ) => {\n\t\t\tconst { color, blockId } = blockColorPair;\n\t\t\tconst blockElement = getBlockElementById(\n\t\t\t\tblockEditorDocument,\n\t\t\t\tblockId\n\t\t\t);\n\n\t\t\tif ( ! blockElement ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( blockElement ) {\n\t\t\t\tblockElement.classList.add( 'is-collaborator-selected' );\n\t\t\t\tblockElement.style.setProperty(\n\t\t\t\t\t'--collaborator-outline-color',\n\t\t\t\t\tcolor\n\t\t\t\t);\n\t\t\t\thighlightedBlockIds.current.add( blockId );\n\t\t\t}\n\t\t} );\n\t}, [ userStates, blockEditorDocument, resolveSelection ] );\n}\n\nconst getBlockElementById = (\n\tblockEditorDocument: Document,\n\tblockId: string\n): HTMLElement | null => {\n\treturn blockEditorDocument.querySelector( `[data-block=\"${ blockId }\"]` );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAGO;AACP,qBAAkC;AAKlC,yBAAuB;AACvB,mBAAqC;AAErC,IAAM,EAAE,wBAAwB,qBAAqB,QACpD,2BAAQ,iBAAAA,WAAoB;AAQtB,SAAS,qBACf,qBACA,QACA,UACC;AACD,QAAM,0BAAsB,uBAAyB,oBAAI,IAAI,CAAE;AAC/D,QAAM,aAAa;AAAA,IAClB,UAAU;AAAA,IACV,YAAY;AAAA,EACb;AACA,QAAM,mBAAmB;AAAA,IACxB,UAAU;AAAA,IACV,YAAY;AAAA,EACb;AAGA,gCAAW,MAAM;AAEhB,QAAK,wBAAwB,MAAO;AACnC;AAAA,IACD;AAEA,UAAM,oBAAoB,CAAE,aAAwB;AACnD,eAAS,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D,CAAE;AAAA,EACH,GAAG,CAAE,YAAY,qBAAqB,gBAAiB,CAAE;AAC1D;AAEA,IAAM,sBAAsB,CAC3B,qBACA,YACwB;AACxB,SAAO,oBAAoB,cAAe,gBAAiB,OAAQ,IAAK;AACzE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as coreDataPrivateApis,\n\ttype CoreDataPrivateApis,\n\ttype PostEditorAwarenessState as ActiveCollaborator,\n} from '@wordpress/core-data';\nimport { useEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { getAvatarBorderColor } from '../collab-sidebar/utils';\nimport { getAvatarUrl } from './get-avatar-url';\nimport { useDebouncedRecompute } from './use-debounced-recompute';\n\nconst { useActiveCollaborators, useResolvedSelection } =\n\tunlock( coreDataPrivateApis );\nconst { SelectionType } = unlock( coreDataPrivateApis ) as Pick<\n\tCoreDataPrivateApis,\n\t'SelectionType'\n>;\n\nexport interface BlockHighlightData {\n\tblockId: string;\n\tuserName: string;\n\tavatarUrl?: string;\n\tcolor: string;\n\tx: number;\n\ty: number;\n}\n\n/**\n * Custom hook for highlighting selected blocks in the editor and computing\n * their positions for rendering avatar labels in the overlay.\n *\n * @param overlayElement - The overlay element used as position reference.\n * @param blockEditorDocument - Ref to 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 highlight positions.\n * @return Highlight data for rendering and a delayed recompute function.\n */\nexport function useBlockHighlighting(\n\toverlayElement: HTMLElement | null,\n\tblockEditorDocument: Document | null,\n\tpostId: number | null,\n\tpostType: string | null,\n\tdelayMs: number\n): {\n\thighlights: BlockHighlightData[];\n\trerenderHighlightsAfterDelay: () => () => void;\n} {\n\tconst highlightedBlockIds = useRef< Set< string > >( new Set() );\n\tconst userStates: ActiveCollaborator[] = 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 [ highlights, setHighlights ] = useState< BlockHighlightData[] >(\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, rerenderHighlightsAfterDelay ] =\n\t\tuseDebouncedRecompute( delayMs );\n\n\t// All DOM mutations and position computations live inside useEffect.\n\tuseEffect( () => {\n\t\tif ( ! blockEditorDocument ) {\n\t\t\tsetHighlights( [] );\n\t\t\treturn;\n\t\t}\n\n\t\t// Capture the ref value so the cleanup closure sees the same Set\n\t\t// even if a later render replaces it.\n\t\tconst currentHighlightedIds = highlightedBlockIds.current;\n\n\t\t// Deduplicate by blockId \u2014 when multiple collaborators select the\n\t\t// same block, only the first one gets the highlight and avatar label.\n\t\tconst seen = new Set< string >();\n\t\tconst blocksToHighlight = userStates\n\t\t\t.filter( ( userState: ActiveCollaborator ) => {\n\t\t\t\tconst isWholeBlockSelected =\n\t\t\t\t\tuserState.editorState?.selection?.type ===\n\t\t\t\t\tSelectionType.WholeBlock;\n\n\t\t\t\treturn ! userState.isMe && isWholeBlockSelected;\n\t\t\t} )\n\t\t\t.map( ( userState ) => {\n\t\t\t\tlet localClientId;\n\t\t\t\ttry {\n\t\t\t\t\t( { localClientId } = resolveSelection(\n\t\t\t\t\t\tuserState.editorState?.selection\n\t\t\t\t\t) );\n\t\t\t\t} catch {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tif ( ! localClientId ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tblockId: localClientId,\n\t\t\t\t\tcolor: userState.isMe\n\t\t\t\t\t\t? 'var(--wp-admin-theme-color)'\n\t\t\t\t\t\t: getAvatarBorderColor( userState.collaboratorInfo.id ),\n\t\t\t\t\tuserName: userState.collaboratorInfo.name,\n\t\t\t\t\tavatarUrl: getAvatarUrl(\n\t\t\t\t\t\tuserState.collaboratorInfo.avatar_urls\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( ( block ): block is NonNullable< typeof block > => {\n\t\t\t\tif ( ! block ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif ( seen.has( block.blockId ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tseen.add( block.blockId );\n\t\t\t\treturn true;\n\t\t\t} );\n\n\t\t// Unhighlight blocks that are no longer selected.\n\t\tconst selectedBlockIds = new Set(\n\t\t\tblocksToHighlight.map( ( block ) => block.blockId )\n\t\t);\n\n\t\tfor ( const blockId of currentHighlightedIds ) {\n\t\t\tif ( ! selectedBlockIds.has( blockId ) ) {\n\t\t\t\tconst blockElement = getBlockElementById(\n\t\t\t\t\tblockEditorDocument,\n\t\t\t\t\tblockId\n\t\t\t\t);\n\n\t\t\t\tif ( blockElement ) {\n\t\t\t\t\tblockElement.classList.remove( 'is-collaborator-selected' );\n\t\t\t\t\tblockElement.style.removeProperty(\n\t\t\t\t\t\t'--collaborator-outline-color'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tcurrentHighlightedIds.delete( blockId );\n\t\t\t}\n\t\t}\n\n\t\t// Highlight blocks and compute positions for avatar labels.\n\t\tconst results: BlockHighlightData[] = [];\n\t\tconst overlayRect = overlayElement?.getBoundingClientRect() ?? null;\n\n\t\tblocksToHighlight.forEach( ( block ) => {\n\t\t\tconst { color, blockId, userName, avatarUrl } = block;\n\t\t\tconst blockElement = getBlockElementById(\n\t\t\t\tblockEditorDocument,\n\t\t\t\tblockId\n\t\t\t);\n\n\t\t\tif ( ! blockElement ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tblockElement.classList.add( 'is-collaborator-selected' );\n\t\t\tblockElement.style.setProperty(\n\t\t\t\t'--collaborator-outline-color',\n\t\t\t\tcolor\n\t\t\t);\n\t\t\tcurrentHighlightedIds.add( blockId );\n\n\t\t\tif ( overlayRect ) {\n\t\t\t\tconst blockRect = blockElement.getBoundingClientRect();\n\n\t\t\t\tresults.push( {\n\t\t\t\t\tblockId,\n\t\t\t\t\tuserName,\n\t\t\t\t\tavatarUrl,\n\t\t\t\t\tcolor,\n\t\t\t\t\tx: blockRect.left - overlayRect.left,\n\t\t\t\t\ty: blockRect.top - overlayRect.top,\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\n\t\tsetHighlights( results );\n\n\t\t// Clean up all highlights on unmount.\n\t\treturn () => {\n\t\t\tfor ( const blockId of currentHighlightedIds ) {\n\t\t\t\tconst el = getBlockElementById( blockEditorDocument, blockId );\n\t\t\t\tif ( el ) {\n\t\t\t\t\tel.classList.remove( 'is-collaborator-selected' );\n\t\t\t\t\tel.style.removeProperty( '--collaborator-outline-color' );\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrentHighlightedIds.clear();\n\t\t};\n\t}, [\n\t\tuserStates,\n\t\tblockEditorDocument,\n\t\toverlayElement,\n\t\trecomputeToken,\n\t\tresolveSelection,\n\t] );\n\n\treturn { highlights, rerenderHighlightsAfterDelay };\n}\n\nconst getBlockElementById = (\n\tblockEditorDocument: Document,\n\tblockId: string\n): HTMLElement | null => {\n\treturn blockEditorDocument.querySelector( `[data-block=\"${ blockId }\"]` );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAIO;AACP,qBAA4C;AAK5C,yBAAuB;AACvB,mBAAqC;AACrC,4BAA6B;AAC7B,qCAAsC;AAEtC,IAAM,EAAE,wBAAwB,qBAAqB,QACpD,2BAAQ,iBAAAA,WAAoB;AAC7B,IAAM,EAAE,cAAc,QAAI,2BAAQ,iBAAAA,WAAoB;AAyB/C,SAAS,qBACf,gBACA,qBACA,QACA,UACA,SAIC;AACD,QAAM,0BAAsB,uBAAyB,oBAAI,IAAI,CAAE;AAC/D,QAAM,aAAmC;AAAA,IACxC,UAAU;AAAA,IACV,YAAY;AAAA,EACb;AACA,QAAM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B,SAAO,oBAAoB,cAAe,gBAAiB,OAAQ,IAAK;AACzE;",
6
6
  "names": ["coreDataPrivateApis"]
7
7
  }
@@ -0,0 +1,49 @@
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/use-debounced-recompute.ts
21
+ var use_debounced_recompute_exports = {};
22
+ __export(use_debounced_recompute_exports, {
23
+ useDebouncedRecompute: () => useDebouncedRecompute
24
+ });
25
+ module.exports = __toCommonJS(use_debounced_recompute_exports);
26
+ var import_element = require("@wordpress/element");
27
+ function useDebouncedRecompute(delayMs) {
28
+ const [recomputeToken, setRecomputeToken] = (0, import_element.useState)(0);
29
+ const timeoutRef = (0, import_element.useRef)(null);
30
+ const rerenderAfterDelay = (0, import_element.useCallback)(() => {
31
+ if (timeoutRef.current) {
32
+ clearTimeout(timeoutRef.current);
33
+ }
34
+ timeoutRef.current = setTimeout(() => {
35
+ setRecomputeToken((t) => t + 1);
36
+ }, delayMs);
37
+ return () => {
38
+ if (timeoutRef.current) {
39
+ clearTimeout(timeoutRef.current);
40
+ }
41
+ };
42
+ }, [delayMs]);
43
+ return [recomputeToken, rerenderAfterDelay];
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ useDebouncedRecompute
48
+ });
49
+ //# sourceMappingURL=use-debounced-recompute.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/collaborators-overlay/use-debounced-recompute.ts"],
4
+ "sourcesContent": ["import { useCallback, useRef, useState } from '@wordpress/element';\n\n/**\n * Returns a recompute token and a debounced callback that bumps it.\n * Rapid successive calls cancel the previous pending timeout so only one\n * recompute fires, `delayMs` after the last call.\n *\n * @param delayMs - Milliseconds to wait before bumping the recompute token.\n * @return A tuple of [recomputeToken, rerenderAfterDelay].\n */\nexport function useDebouncedRecompute(\n\tdelayMs: number\n): [ number, () => () => void ] {\n\tconst [ recomputeToken, setRecomputeToken ] = useState( 0 );\n\tconst timeoutRef = useRef< ReturnType< typeof setTimeout > | null >( null );\n\n\tconst rerenderAfterDelay = useCallback( () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\tclearTimeout( timeoutRef.current );\n\t\t}\n\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\tsetRecomputeToken( ( t ) => t + 1 );\n\t\t}, delayMs );\n\t\treturn () => {\n\t\t\tif ( timeoutRef.current ) {\n\t\t\t\tclearTimeout( timeoutRef.current );\n\t\t\t}\n\t\t};\n\t}, [ delayMs ] );\n\n\treturn [ recomputeToken, rerenderAfterDelay ];\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8C;AAUvC,SAAS,sBACf,SAC+B;AAC/B,QAAM,CAAE,gBAAgB,iBAAkB,QAAI,yBAAU,CAAE;AAC1D,QAAM,iBAAa,uBAAkD,IAAK;AAE1E,QAAM,yBAAqB,4BAAa,MAAM;AAC7C,QAAK,WAAW,SAAU;AACzB,mBAAc,WAAW,OAAQ;AAAA,IAClC;AACA,eAAW,UAAU,WAAY,MAAM;AACtC,wBAAmB,CAAE,MAAO,IAAI,CAAE;AAAA,IACnC,GAAG,OAAQ;AACX,WAAO,MAAM;AACZ,UAAK,WAAW,SAAU;AACzB,qBAAc,WAAW,OAAQ;AAAA,MAClC;AAAA,IACD;AAAA,EACD,GAAG,CAAE,OAAQ,CAAE;AAEf,SAAO,CAAE,gBAAgB,kBAAmB;AAC7C;",
6
+ "names": []
7
+ }