@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
@@ -261,6 +261,11 @@ var getCurrentRevision = (0, import_data.createRegistrySelector)(
261
261
  return void 0;
262
262
  }
263
263
  const { type: postType, id: postId } = (0, import_selectors.getCurrentPost)(state);
264
+ const entityConfig = select(import_core_data.store).getEntityConfig(
265
+ "postType",
266
+ postType
267
+ );
268
+ const revisionKey = entityConfig?.revisionKey || "id";
264
269
  const revisions = select(import_core_data.store).getRevisions(
265
270
  "postType",
266
271
  postType,
@@ -268,18 +273,25 @@ var getCurrentRevision = (0, import_data.createRegistrySelector)(
268
273
  {
269
274
  per_page: -1,
270
275
  context: "edit",
271
- _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
276
+ _fields: [
277
+ .../* @__PURE__ */ new Set([
278
+ "id",
279
+ "date",
280
+ "modified",
281
+ "author",
282
+ "meta",
283
+ "title.raw",
284
+ "excerpt.raw",
285
+ "content.raw",
286
+ revisionKey
287
+ ])
288
+ ].join()
272
289
  }
273
290
  );
274
291
  if (!revisions) {
275
292
  return null;
276
293
  }
277
- const entityConfig = select(import_core_data.store).getEntityConfig(
278
- "postType",
279
- postType
280
- );
281
- const revKey = entityConfig?.revisionKey || "id";
282
- return revisions.find((r) => r[revKey] === revisionId) ?? null;
294
+ return revisions.find((r) => r[revisionKey] === revisionId) ?? null;
283
295
  }
284
296
  );
285
297
  function getSelectedNote(state) {
@@ -295,6 +307,11 @@ var getPreviousRevision = (0, import_data.createRegistrySelector)(
295
307
  return void 0;
296
308
  }
297
309
  const { type: postType, id: postId } = (0, import_selectors.getCurrentPost)(state);
310
+ const entityConfig = select(import_core_data.store).getEntityConfig(
311
+ "postType",
312
+ postType
313
+ );
314
+ const revisionKey = entityConfig?.revisionKey || "id";
298
315
  const revisions = select(import_core_data.store).getRevisions(
299
316
  "postType",
300
317
  postType,
@@ -302,22 +319,30 @@ var getPreviousRevision = (0, import_data.createRegistrySelector)(
302
319
  {
303
320
  per_page: -1,
304
321
  context: "edit",
305
- _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
322
+ _fields: [
323
+ .../* @__PURE__ */ new Set([
324
+ "id",
325
+ "date",
326
+ "modified",
327
+ "author",
328
+ "meta",
329
+ "title.raw",
330
+ "excerpt.raw",
331
+ "content.raw",
332
+ revisionKey
333
+ ])
334
+ ].join()
306
335
  }
307
336
  );
308
337
  if (!revisions) {
309
338
  return null;
310
339
  }
340
+ const revisionDateField = revisionKey === "wp_id" ? "modified" : "date";
311
341
  const sortedRevisions = [...revisions].sort(
312
- (a, b) => new Date(a.date) - new Date(b.date)
313
- );
314
- const entityConfig = select(import_core_data.store).getEntityConfig(
315
- "postType",
316
- postType
342
+ (a, b) => new Date(a[revisionDateField]) - new Date(b[revisionDateField])
317
343
  );
318
- const revKey = entityConfig?.revisionKey || "id";
319
344
  const currentIndex = sortedRevisions.findIndex(
320
- (r) => r[revKey] === currentRevisionId
345
+ (r) => r[revisionKey] === currentRevisionId
321
346
  );
322
347
  if (currentIndex > 0) {
323
348
  return sortedRevisions[currentIndex - 1];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/private-selectors.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\tlayout,\n\tsymbol,\n\tnavigation,\n\tpage as pageIcon,\n\tverse,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { getRenderingMode, getCurrentPost } from './selectors';\nimport {\n\tgetEntityActions as _getEntityActions,\n\tgetEntityFields as _getEntityFields,\n\tisEntityReady as _isEntityReady,\n} from '../dataviews/store/private-selectors';\nimport { getTemplatePartIcon } from '../utils';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * These are rendering modes that the editor supports.\n */\nconst RENDERING_MODES = [ 'post-only', 'template-locked' ];\n\n/**\n * Get the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const getInserter = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\t\treturn state.blockInserterPanel;\n\t\t\t}\n\n\t\t\tif ( getRenderingMode( state ) === 'template-locked' ) {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlocksByName,\n\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\tgetBlockParents,\n\t\t\t\t\tgetBlockOrder,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst [ postContentClientId ] =\n\t\t\t\t\tgetBlocksByName( 'core/post-content' );\n\t\t\t\tif ( postContentClientId ) {\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\t\t\t// If a block inside Post Content is selected,\n\t\t\t\t\t// let the inserter use its default logic for determining the\n\t\t\t\t\t// insertion position by returning an empty insertion point.\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectedBlockClientId &&\n\t\t\t\t\t\tselectedBlockClientId !== postContentClientId &&\n\t\t\t\t\t\tgetBlockParents( selectedBlockClientId ).includes(\n\t\t\t\t\t\t\tpostContentClientId\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise (no selection, or Post Content itself\n\t\t\t\t\t// is selected), insert at the end of Post Content.\n\t\t\t\t\treturn {\n\t\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\t\tinsertionIndex:\n\t\t\t\t\t\t\tgetBlockOrder( postContentClientId ).length,\n\t\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t},\n\t\t( state ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocksByName,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tgetBlocksByName( 'core/post-content' );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\treturn [\n\t\t\t\tstate.blockInserterPanel,\n\t\t\t\tgetRenderingMode( state ),\n\t\t\t\tpostContentClientId,\n\t\t\t\tselectedBlockClientId,\n\t\t\t\tselectedBlockClientId\n\t\t\t\t\t? getBlockParents( selectedBlockClientId )\n\t\t\t\t\t: undefined,\n\t\t\t\tpostContentClientId\n\t\t\t\t\t? getBlockOrder( postContentClientId ).length\n\t\t\t\t\t: undefined,\n\t\t\t];\n\t\t}\n\t)\n);\n\nexport function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\nconst CARD_ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigation,\n\tpage: pageIcon,\n\tpost: verse,\n};\n\nexport const getPostIcon = createRegistrySelector(\n\t( select ) => ( state, postType, options ) => {\n\t\t{\n\t\t\tif (\n\t\t\t\tpostType === 'wp_template_part' ||\n\t\t\t\tpostType === 'wp_template'\n\t\t\t) {\n\t\t\t\tconst templateAreas =\n\t\t\t\t\tselect( coreStore ).getCurrentTheme()\n\t\t\t\t\t\t?.default_template_part_areas || [];\n\n\t\t\t\tconst areaData = templateAreas.find(\n\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t);\n\n\t\t\t\tif ( areaData?.icon ) {\n\t\t\t\t\treturn getTemplatePartIcon( areaData.icon );\n\t\t\t\t}\n\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\tif ( CARD_ICONS[ postType ] ) {\n\t\t\t\treturn CARD_ICONS[ postType ];\n\t\t\t}\n\t\t\tconst postTypeEntity = select( coreStore ).getPostType( postType );\n\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t// also supports urls and svg as values.\n\t\t\tif (\n\t\t\t\ttypeof postTypeEntity?.icon === 'string' &&\n\t\t\t\tpostTypeEntity.icon.startsWith( 'dashicons-' )\n\t\t\t) {\n\t\t\t\treturn postTypeEntity.icon.slice( 10 );\n\t\t\t}\n\t\t\treturn pageIcon;\n\t\t}\n\t}\n);\n\n/**\n * Returns true if there are unsaved changes to the\n * post's meta fields, and false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type of the post.\n * @param {number} postId The ID of the post.\n *\n * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.\n */\nexport const hasPostMetaChanges = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst { type: currentPostType, id: currentPostId } =\n\t\t\tgetCurrentPost( state );\n\t\t// If no postType or postId is passed, use the current post.\n\t\tconst edits = select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t);\n\n\t\tif ( ! edits?.meta ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Compare if anything apart from `footnotes` has changed.\n\t\tconst originalPostMeta = select( coreStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t)?.meta;\n\n\t\treturn ! fastDeepEqual(\n\t\t\t{ ...originalPostMeta, footnotes: undefined },\n\t\t\t{ ...edits.meta, footnotes: undefined }\n\t\t);\n\t}\n);\n\nexport function getEntityActions( state, ...args ) {\n\treturn _getEntityActions( state.dataviews, ...args );\n}\n\nexport function isEntityReady( state, ...args ) {\n\treturn _isEntityReady( state.dataviews, ...args );\n}\n\nexport function getEntityFields( state, ...args ) {\n\treturn _getEntityFields( state.dataviews, ...args );\n}\n\n/**\n * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most\n * blocks that aren't descendants of the query block.\n *\n * @param {Object} state Global application state.\n * @param {Array|string} blockNames Block names of the blocks to retrieve.\n *\n * @return {Array} Block client IDs.\n */\nexport const getPostBlocksByName = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn getBlocksByName( blockNames ).filter( ( clientId ) =>\n\t\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// Ignore descendents of the query block.\n\t\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t\t// Enable only the top-most block.\n\t\t\t\t\t\t! blockNames.includes( parentBlockName )\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst clientIds = getBlocksByName( blockNames );\n\t\t\tconst parentsOfClientIds = clientIds.map( ( id ) =>\n\t\t\t\tgetBlockParents( id )\n\t\t\t);\n\t\t\treturn [ clientIds, ...parentsOfClientIds ];\n\t\t}\n\t)\n);\n\n/**\n * Returns the default rendering mode for a post type by user preference or post type configuration.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type.\n *\n * @return {string} The default rendering mode. Returns `undefined` while resolving value.\n */\nexport const getDefaultRenderingMode = createRegistrySelector(\n\t( select ) => ( state, postType ) => {\n\t\tconst { getPostType, getCurrentTheme, hasFinishedResolution } =\n\t\t\tselect( coreStore );\n\n\t\t// This needs to be called before `hasFinishedResolution`.\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst currentTheme = getCurrentTheme();\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst postTypeEntity = getPostType( postType );\n\n\t\t// Wait for the post type and theme resolution.\n\t\tif (\n\t\t\t! hasFinishedResolution( 'getPostType', [ postType ] ) ||\n\t\t\t! hasFinishedResolution( 'getCurrentTheme' )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst theme = currentTheme?.stylesheet;\n\t\tconst defaultModePreference = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'renderingModes'\n\t\t)?.[ theme ]?.[ postType ];\n\t\tconst postTypeDefaultMode = Array.isArray(\n\t\t\tpostTypeEntity?.supports?.editor\n\t\t)\n\t\t\t? postTypeEntity.supports.editor.find(\n\t\t\t\t\t( features ) => 'default-mode' in features\n\t\t\t )?.[ 'default-mode' ]\n\t\t\t: undefined;\n\n\t\tconst defaultMode = defaultModePreference || postTypeDefaultMode;\n\n\t\t// Fallback gracefully to 'post-only' when rendering mode is not supported.\n\t\tif ( ! RENDERING_MODES.includes( defaultMode ) ) {\n\t\t\treturn 'post-only';\n\t\t}\n\n\t\treturn defaultMode;\n\t}\n);\n\n/**\n * Get the current global styles navigation path.\n *\n * @param {Object} state Global application state.\n * @return {string} The current styles path.\n */\nexport function getStylesPath( state ) {\n\treturn state.stylesPath ?? '/';\n}\n\n/**\n * Get whether the stylebook is currently visible.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether the stylebook is visible.\n */\nexport function getShowStylebook( state ) {\n\treturn state.showStylebook ?? false;\n}\n\n/**\n * Get the canvas minimum height.\n *\n * @param {Object} state Global application state.\n * @return {number} The canvas minimum height.\n */\nexport function getCanvasMinHeight( state ) {\n\treturn state.canvasMinHeight;\n}\n\n/**\n * Returns whether the editor is in revisions preview mode.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether revisions mode is active.\n */\nexport function isRevisionsMode( state ) {\n\treturn state.revisionId !== null;\n}\n\n/**\n * Returns whether the revision diff highlighting is shown.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether revision diff is being shown.\n */\nexport function isShowingRevisionDiff( state ) {\n\treturn state.showRevisionDiff;\n}\n\n/**\n * Returns the current revision ID in revisions mode.\n *\n * @param {Object} state Global application state.\n * @return {number|null} The revision ID, or null if not in revisions mode.\n */\nexport function getCurrentRevisionId( state ) {\n\treturn state.revisionId;\n}\n\n/**\n * Returns the current revision object in revisions mode.\n *\n * @param {Object} state Global application state.\n * @return {Object|null|undefined} The revision object, null if loading, or undefined if not in revisions mode.\n */\nexport const getCurrentRevision = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst revisionId = getCurrentRevisionId( state );\n\t\tif ( ! revisionId ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { type: postType, id: postId } = getCurrentPost( state );\n\t\t// - Use getRevisions (plural) instead of getRevision (singular) to\n\t\t// avoid a race condition where both API calls complete around the\n\t\t// same time and the single revision fetch overwrites the list in the\n\t\t// store.\n\t\t// - getRevision also needs to be updated to check if there's any\n\t\t// received revisions from the collection API call to avoid unnecessary\n\t\t// API calls.\n\t\tconst revisions = select( coreStore ).getRevisions(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields:\n\t\t\t\t\t'id,date,author,meta,title.raw,excerpt.raw,content.raw',\n\t\t\t}\n\t\t);\n\t\tif ( ! revisions ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst revKey = entityConfig?.revisionKey || 'id';\n\t\treturn revisions.find( ( r ) => r[ revKey ] === revisionId ) ?? null;\n\t}\n);\n\n/**\n * Returns the currently selected note ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {undefined|number|'new'} The selected note ID, 'new' for the new note form, or undefined if none.\n */\nexport function getSelectedNote( state ) {\n\treturn state.selectedNote?.noteId;\n}\n\n/**\n * Returns whether the selected note should be focused.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the selected note should be focused.\n */\nexport function isNoteFocused( state ) {\n\treturn !! state.selectedNote?.options?.focus;\n}\n\n/**\n * Returns the previous revision (the one before the current revision).\n * Used for diffing between revisions.\n *\n * @param {Object} state Global application state.\n * @return {Object|null|undefined} The previous revision object, null if loading or no previous revision, or undefined if not in revisions mode.\n */\nexport const getPreviousRevision = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst currentRevisionId = getCurrentRevisionId( state );\n\t\tif ( ! currentRevisionId ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { type: postType, id: postId } = getCurrentPost( state );\n\t\tconst revisions = select( coreStore ).getRevisions(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields:\n\t\t\t\t\t'id,date,author,meta,title.raw,excerpt.raw,content.raw',\n\t\t\t}\n\t\t);\n\t\tif ( ! revisions ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Sort by date ascending (oldest first).\n\t\tconst sortedRevisions = [ ...revisions ].sort(\n\t\t\t( a, b ) => new Date( a.date ) - new Date( b.date )\n\t\t);\n\n\t\t// Find current revision index.\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst revKey = entityConfig?.revisionKey || 'id';\n\t\tconst currentIndex = sortedRevisions.findIndex(\n\t\t\t( r ) => r[ revKey ] === currentRevisionId\n\t\t);\n\n\t\t// Return the previous revision (older one) if it exists.\n\t\tif ( currentIndex > 0 ) {\n\t\t\treturn sortedRevisions[ currentIndex - 1 ];\n\t\t}\n\n\t\treturn null;\n\t}\n);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,6BAA0B;AAK1B,0BAA0C;AAC1C,kBAAuD;AACvD,mBAMO;AACP,uBAAmC;AACnC,yBAA0C;AAK1C,uBAAiD;AACjD,+BAIO;AACP,mBAAoC;AAEpC,IAAM,wBAAwB;AAAA,EAC7B,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,aAAa;AACd;AAKA,IAAM,kBAAkB,CAAE,aAAa,iBAAkB;AASlD,IAAM,kBAAc;AAAA,EAAwB,CAAE,eACpD;AAAA,IAC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AA,MACA;AAAA,IACD;AACA,UAAM,SAAS,cAAc,eAAe;AAC5C,WAAO,UAAU,KAAM,CAAE,MAAO,EAAG,MAAO,MAAM,UAAW,KAAK;AAAA,EACjE;AACD;AASO,SAAS,gBAAiB,OAAQ;AACxC,SAAO,MAAM,cAAc;AAC5B;AASO,SAAS,cAAe,OAAQ;AACtC,SAAO,CAAC,CAAE,MAAM,cAAc,SAAS;AACxC;AASO,IAAM,0BAAsB;AAAA,EAClC,CAAE,WAAY,CAAE,UAAW;AAC1B,UAAM,oBAAoB,qBAAsB,KAAM;AACtD,QAAK,CAAE,mBAAoB;AAC1B,aAAO;AAAA,IACR;AAEA,UAAM,EAAE,MAAM,UAAU,IAAI,OAAO,QAAI,iCAAgB,KAAM;AAC7D,UAAM,YAAY,OAAQ,iBAAAA,KAAU,EAAE;AAAA,MACrC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,SAAS;AAAA,QACT,SACC;AAAA,MACF;AAAA,IACD;AACA,QAAK,CAAE,WAAY;AAClB,aAAO;AAAA,IACR;AAGA,UAAM,kBAAkB,CAAE,GAAG,SAAU,EAAE;AAAA,MACxC,CAAE,GAAG,MAAO,IAAI,KAAM,EAAE,IAAK,IAAI,IAAI,KAAM,EAAE,IAAK;AAAA,IACnD;AAGA,UAAM,eAAe,OAAQ,iBAAAA,KAAU,EAAE;AAAA,MACxC;AAAA,MACA;AAAA,IACD;AACA,UAAM,SAAS,cAAc,eAAe;AAC5C,UAAM,eAAe,gBAAgB;AAAA,MACpC,CAAE,MAAO,EAAG,MAAO,MAAM;AAAA,IAC1B;AAGA,QAAK,eAAe,GAAI;AACvB,aAAO,gBAAiB,eAAe,CAAE;AAAA,IAC1C;AAEA,WAAO;AAAA,EACR;AACD;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\tlayout,\n\tsymbol,\n\tnavigation,\n\tpage as pageIcon,\n\tverse,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { getRenderingMode, getCurrentPost } from './selectors';\nimport {\n\tgetEntityActions as _getEntityActions,\n\tgetEntityFields as _getEntityFields,\n\tisEntityReady as _isEntityReady,\n} from '../dataviews/store/private-selectors';\nimport { getTemplatePartIcon } from '../utils';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * These are rendering modes that the editor supports.\n */\nconst RENDERING_MODES = [ 'post-only', 'template-locked' ];\n\n/**\n * Get the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const getInserter = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\t\treturn state.blockInserterPanel;\n\t\t\t}\n\n\t\t\tif ( getRenderingMode( state ) === 'template-locked' ) {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlocksByName,\n\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\tgetBlockParents,\n\t\t\t\t\tgetBlockOrder,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst [ postContentClientId ] =\n\t\t\t\t\tgetBlocksByName( 'core/post-content' );\n\t\t\t\tif ( postContentClientId ) {\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\t\t\t// If a block inside Post Content is selected,\n\t\t\t\t\t// let the inserter use its default logic for determining the\n\t\t\t\t\t// insertion position by returning an empty insertion point.\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectedBlockClientId &&\n\t\t\t\t\t\tselectedBlockClientId !== postContentClientId &&\n\t\t\t\t\t\tgetBlockParents( selectedBlockClientId ).includes(\n\t\t\t\t\t\t\tpostContentClientId\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise (no selection, or Post Content itself\n\t\t\t\t\t// is selected), insert at the end of Post Content.\n\t\t\t\t\treturn {\n\t\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\t\tinsertionIndex:\n\t\t\t\t\t\t\tgetBlockOrder( postContentClientId ).length,\n\t\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t},\n\t\t( state ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocksByName,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tgetBlocksByName( 'core/post-content' );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\treturn [\n\t\t\t\tstate.blockInserterPanel,\n\t\t\t\tgetRenderingMode( state ),\n\t\t\t\tpostContentClientId,\n\t\t\t\tselectedBlockClientId,\n\t\t\t\tselectedBlockClientId\n\t\t\t\t\t? getBlockParents( selectedBlockClientId )\n\t\t\t\t\t: undefined,\n\t\t\t\tpostContentClientId\n\t\t\t\t\t? getBlockOrder( postContentClientId ).length\n\t\t\t\t\t: undefined,\n\t\t\t];\n\t\t}\n\t)\n);\n\nexport function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\nconst CARD_ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigation,\n\tpage: pageIcon,\n\tpost: verse,\n};\n\nexport const getPostIcon = createRegistrySelector(\n\t( select ) => ( state, postType, options ) => {\n\t\t{\n\t\t\tif (\n\t\t\t\tpostType === 'wp_template_part' ||\n\t\t\t\tpostType === 'wp_template'\n\t\t\t) {\n\t\t\t\tconst templateAreas =\n\t\t\t\t\tselect( coreStore ).getCurrentTheme()\n\t\t\t\t\t\t?.default_template_part_areas || [];\n\n\t\t\t\tconst areaData = templateAreas.find(\n\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t);\n\n\t\t\t\tif ( areaData?.icon ) {\n\t\t\t\t\treturn getTemplatePartIcon( areaData.icon );\n\t\t\t\t}\n\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\tif ( CARD_ICONS[ postType ] ) {\n\t\t\t\treturn CARD_ICONS[ postType ];\n\t\t\t}\n\t\t\tconst postTypeEntity = select( coreStore ).getPostType( postType );\n\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t// also supports urls and svg as values.\n\t\t\tif (\n\t\t\t\ttypeof postTypeEntity?.icon === 'string' &&\n\t\t\t\tpostTypeEntity.icon.startsWith( 'dashicons-' )\n\t\t\t) {\n\t\t\t\treturn postTypeEntity.icon.slice( 10 );\n\t\t\t}\n\t\t\treturn pageIcon;\n\t\t}\n\t}\n);\n\n/**\n * Returns true if there are unsaved changes to the\n * post's meta fields, and false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type of the post.\n * @param {number} postId The ID of the post.\n *\n * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.\n */\nexport const hasPostMetaChanges = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst { type: currentPostType, id: currentPostId } =\n\t\t\tgetCurrentPost( state );\n\t\t// If no postType or postId is passed, use the current post.\n\t\tconst edits = select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t);\n\n\t\tif ( ! edits?.meta ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Compare if anything apart from `footnotes` has changed.\n\t\tconst originalPostMeta = select( coreStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t)?.meta;\n\n\t\treturn ! fastDeepEqual(\n\t\t\t{ ...originalPostMeta, footnotes: undefined },\n\t\t\t{ ...edits.meta, footnotes: undefined }\n\t\t);\n\t}\n);\n\nexport function getEntityActions( state, ...args ) {\n\treturn _getEntityActions( state.dataviews, ...args );\n}\n\nexport function isEntityReady( state, ...args ) {\n\treturn _isEntityReady( state.dataviews, ...args );\n}\n\nexport function getEntityFields( state, ...args ) {\n\treturn _getEntityFields( state.dataviews, ...args );\n}\n\n/**\n * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most\n * blocks that aren't descendants of the query block.\n *\n * @param {Object} state Global application state.\n * @param {Array|string} blockNames Block names of the blocks to retrieve.\n *\n * @return {Array} Block client IDs.\n */\nexport const getPostBlocksByName = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn getBlocksByName( blockNames ).filter( ( clientId ) =>\n\t\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// Ignore descendents of the query block.\n\t\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t\t// Enable only the top-most block.\n\t\t\t\t\t\t! blockNames.includes( parentBlockName )\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst clientIds = getBlocksByName( blockNames );\n\t\t\tconst parentsOfClientIds = clientIds.map( ( id ) =>\n\t\t\t\tgetBlockParents( id )\n\t\t\t);\n\t\t\treturn [ clientIds, ...parentsOfClientIds ];\n\t\t}\n\t)\n);\n\n/**\n * Returns the default rendering mode for a post type by user preference or post type configuration.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type.\n *\n * @return {string} The default rendering mode. Returns `undefined` while resolving value.\n */\nexport const getDefaultRenderingMode = createRegistrySelector(\n\t( select ) => ( state, postType ) => {\n\t\tconst { getPostType, getCurrentTheme, hasFinishedResolution } =\n\t\t\tselect( coreStore );\n\n\t\t// This needs to be called before `hasFinishedResolution`.\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst currentTheme = getCurrentTheme();\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst postTypeEntity = getPostType( postType );\n\n\t\t// Wait for the post type and theme resolution.\n\t\tif (\n\t\t\t! hasFinishedResolution( 'getPostType', [ postType ] ) ||\n\t\t\t! hasFinishedResolution( 'getCurrentTheme' )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst theme = currentTheme?.stylesheet;\n\t\tconst defaultModePreference = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'renderingModes'\n\t\t)?.[ theme ]?.[ postType ];\n\t\tconst postTypeDefaultMode = Array.isArray(\n\t\t\tpostTypeEntity?.supports?.editor\n\t\t)\n\t\t\t? postTypeEntity.supports.editor.find(\n\t\t\t\t\t( features ) => 'default-mode' in features\n\t\t\t )?.[ 'default-mode' ]\n\t\t\t: undefined;\n\n\t\tconst defaultMode = defaultModePreference || postTypeDefaultMode;\n\n\t\t// Fallback gracefully to 'post-only' when rendering mode is not supported.\n\t\tif ( ! RENDERING_MODES.includes( defaultMode ) ) {\n\t\t\treturn 'post-only';\n\t\t}\n\n\t\treturn defaultMode;\n\t}\n);\n\n/**\n * Get the current global styles navigation path.\n *\n * @param {Object} state Global application state.\n * @return {string} The current styles path.\n */\nexport function getStylesPath( state ) {\n\treturn state.stylesPath ?? '/';\n}\n\n/**\n * Get whether the stylebook is currently visible.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether the stylebook is visible.\n */\nexport function getShowStylebook( state ) {\n\treturn state.showStylebook ?? false;\n}\n\n/**\n * Get the canvas minimum height.\n *\n * @param {Object} state Global application state.\n * @return {number} The canvas minimum height.\n */\nexport function getCanvasMinHeight( state ) {\n\treturn state.canvasMinHeight;\n}\n\n/**\n * Returns whether the editor is in revisions preview mode.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether revisions mode is active.\n */\nexport function isRevisionsMode( state ) {\n\treturn state.revisionId !== null;\n}\n\n/**\n * Returns whether the revision diff highlighting is shown.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether revision diff is being shown.\n */\nexport function isShowingRevisionDiff( state ) {\n\treturn state.showRevisionDiff;\n}\n\n/**\n * Returns the current revision ID in revisions mode.\n *\n * @param {Object} state Global application state.\n * @return {number|null} The revision ID, or null if not in revisions mode.\n */\nexport function getCurrentRevisionId( state ) {\n\treturn state.revisionId;\n}\n\n/**\n * Returns the current revision object in revisions mode.\n *\n * @param {Object} state Global application state.\n * @return {Object|null|undefined} The revision object, null if loading, or undefined if not in revisions mode.\n */\nexport const getCurrentRevision = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst revisionId = getCurrentRevisionId( state );\n\t\tif ( ! revisionId ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { type: postType, id: postId } = getCurrentPost( state );\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst revisionKey = entityConfig?.revisionKey || 'id';\n\t\t// - Use getRevisions (plural) instead of getRevision (singular) to\n\t\t// avoid a race condition where both API calls complete around the\n\t\t// same time and the single revision fetch overwrites the list in the\n\t\t// store.\n\t\t// - getRevision also needs to be updated to check if there's any\n\t\t// received revisions from the collection API call to avoid unnecessary\n\t\t// API calls.\n\t\tconst revisions = select( coreStore ).getRevisions(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t'id',\n\t\t\t\t\t\t'date',\n\t\t\t\t\t\t'modified',\n\t\t\t\t\t\t'author',\n\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t'title.raw',\n\t\t\t\t\t\t'excerpt.raw',\n\t\t\t\t\t\t'content.raw',\n\t\t\t\t\t\trevisionKey,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t}\n\t\t);\n\t\tif ( ! revisions ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn (\n\t\t\trevisions.find( ( r ) => r[ revisionKey ] === revisionId ) ?? null\n\t\t);\n\t}\n);\n\n/**\n * Returns the currently selected note ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {undefined|number|'new'} The selected note ID, 'new' for the new note form, or undefined if none.\n */\nexport function getSelectedNote( state ) {\n\treturn state.selectedNote?.noteId;\n}\n\n/**\n * Returns whether the selected note should be focused.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the selected note should be focused.\n */\nexport function isNoteFocused( state ) {\n\treturn !! state.selectedNote?.options?.focus;\n}\n\n/**\n * Returns the previous revision (the one before the current revision).\n * Used for diffing between revisions.\n *\n * @param {Object} state Global application state.\n * @return {Object|null|undefined} The previous revision object, null if loading or no previous revision, or undefined if not in revisions mode.\n */\nexport const getPreviousRevision = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst currentRevisionId = getCurrentRevisionId( state );\n\t\tif ( ! currentRevisionId ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { type: postType, id: postId } = getCurrentPost( state );\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst revisionKey = entityConfig?.revisionKey || 'id';\n\t\tconst revisions = select( coreStore ).getRevisions(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t'id',\n\t\t\t\t\t\t'date',\n\t\t\t\t\t\t'modified',\n\t\t\t\t\t\t'author',\n\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t'title.raw',\n\t\t\t\t\t\t'excerpt.raw',\n\t\t\t\t\t\t'content.raw',\n\t\t\t\t\t\trevisionKey,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t}\n\t\t);\n\t\tif ( ! revisions ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Template revisions use the template REST API format, which exposes\n\t\t// 'modified' instead of 'date'. Regular post revisions use 'date'.\n\t\tconst revisionDateField = revisionKey === 'wp_id' ? 'modified' : 'date';\n\n\t\t// Sort by date ascending (oldest first).\n\t\tconst sortedRevisions = [ ...revisions ].sort(\n\t\t\t( a, b ) =>\n\t\t\t\tnew Date( a[ revisionDateField ] ) -\n\t\t\t\tnew Date( b[ revisionDateField ] )\n\t\t);\n\n\t\t// Find current revision index.\n\t\tconst currentIndex = sortedRevisions.findIndex(\n\t\t\t( r ) => r[ revisionKey ] === currentRevisionId\n\t\t);\n\n\t\t// Return the previous revision (older one) if it exists.\n\t\tif ( currentIndex > 0 ) {\n\t\t\treturn sortedRevisions[ currentIndex - 1 ];\n\t\t}\n\n\t\treturn null;\n\t}\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AK;AAAA,YACX;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACD,CAAE;AAAA,QACH,EAAE,KAAK;AAAA,MACR;AAAA,IACD;AACA,QAAK,CAAE,WAAY;AAClB,aAAO;AAAA,IACR;AAIA,UAAM,oBAAoB,gBAAgB,UAAU,aAAa;AAGjE,UAAM,kBAAkB,CAAE,GAAG,SAAU,EAAE;AAAA,MACxC,CAAE,GAAG,MACJ,IAAI,KAAM,EAAG,iBAAkB,CAAE,IACjC,IAAI,KAAM,EAAG,iBAAkB,CAAE;AAAA,IACnC;AAGA,UAAM,eAAe,gBAAgB;AAAA,MACpC,CAAE,MAAO,EAAG,WAAY,MAAM;AAAA,IAC/B;AAGA,QAAK,eAAe,GAAI;AACvB,aAAO,gBAAiB,eAAe,CAAE;AAAA,IAC1C;AAEA,WAAO;AAAA,EACR;AACD;",
6
6
  "names": ["blockEditorStore", "pageIcon", "coreStore", "fastDeepEqual", "_getEntityActions", "_isEntityReady", "_getEntityFields", "preferencesStore"]
7
7
  }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/editor/src/utils/media-finalize/index.js
31
+ var media_finalize_exports = {};
32
+ __export(media_finalize_exports, {
33
+ default: () => mediaFinalize
34
+ });
35
+ module.exports = __toCommonJS(media_finalize_exports);
36
+ var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
37
+ async function mediaFinalize(id) {
38
+ await (0, import_api_fetch.default)({
39
+ path: `/wp/v2/media/${id}/finalize`,
40
+ method: "POST"
41
+ });
42
+ }
43
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/media-finalize/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\nexport default async function mediaFinalize( id ) {\n\tawait apiFetch( {\n\t\tpath: `/wp/v2/media/${ id }/finalize`,\n\t\tmethod: 'POST',\n\t} );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAqB;AAErB,eAAO,cAAsC,IAAK;AACjD,YAAM,iBAAAA,SAAU;AAAA,IACf,MAAM,gBAAiB,EAAG;AAAA,IAC1B,QAAQ;AAAA,EACT,CAAE;AACH;",
6
+ "names": ["apiFetch"]
7
+ }
@@ -17,51 +17,64 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // packages/editor/src/utils/sync-error-messages.js
20
+ // packages/editor/src/utils/sync-error-messages.ts
21
21
  var sync_error_messages_exports = {};
22
22
  __export(sync_error_messages_exports, {
23
+ AUTHENTICATION_FAILED: () => AUTHENTICATION_FAILED,
24
+ CONNECTION_EXPIRED: () => CONNECTION_EXPIRED,
25
+ CONNECTION_LIMIT_EXCEEDED: () => CONNECTION_LIMIT_EXCEEDED,
26
+ DOCUMENT_SIZE_LIMIT_EXCEEDED: () => DOCUMENT_SIZE_LIMIT_EXCEEDED,
27
+ UNKNOWN_ERROR: () => UNKNOWN_ERROR,
23
28
  getSyncErrorMessages: () => getSyncErrorMessages
24
29
  });
25
30
  module.exports = __toCommonJS(sync_error_messages_exports);
26
31
  var import_i18n = require("@wordpress/i18n");
32
+ var AUTHENTICATION_FAILED = "authentication-failed";
33
+ var CONNECTION_EXPIRED = "connection-expired";
34
+ var CONNECTION_LIMIT_EXCEEDED = "connection-limit-exceeded";
35
+ var DOCUMENT_SIZE_LIMIT_EXCEEDED = "document-size-limit-exceeded";
36
+ var UNKNOWN_ERROR = "unknown-error";
27
37
  var ERROR_MESSAGES = {
28
- "authentication-failed": {
38
+ [AUTHENTICATION_FAILED]: {
29
39
  title: (0, import_i18n.__)("Unable to connect"),
30
40
  description: (0, import_i18n.__)(
31
- "Real-time collaboration couldn't verify your permissions. Check that you have access to edit this post, or contact your site administrator."
32
- ),
33
- canRetry: false
41
+ "Real-time collaboration couldn't verify your permissions. Check that you have access to edit this post or contact your site administrator."
42
+ )
34
43
  },
35
- "connection-expired": {
44
+ [CONNECTION_EXPIRED]: {
36
45
  title: (0, import_i18n.__)("Connection expired"),
37
46
  description: (0, import_i18n.__)(
38
47
  "Your connection to real-time collaboration has timed out. Editing is paused to prevent conflicts with other editors."
39
- ),
40
- canRetry: true
48
+ )
41
49
  },
42
- "connection-limit-exceeded": {
50
+ [CONNECTION_LIMIT_EXCEEDED]: {
43
51
  title: (0, import_i18n.__)("Too many editors connected"),
44
52
  description: (0, import_i18n.__)(
45
53
  "Real-time collaboration has reached its connection limit. Try again later or contact your site administrator."
46
- ),
47
- canRetry: true
54
+ )
48
55
  },
49
- "unknown-error": {
56
+ // DOCUMENT_SIZE_LIMIT_EXCEEDED is not included here because it results in
57
+ // collaboration being disabled entirely.
58
+ [UNKNOWN_ERROR]: {
50
59
  title: (0, import_i18n.__)("Connection lost"),
51
60
  description: (0, import_i18n.__)(
52
61
  "The connection to real-time collaboration was interrupted. Editing is paused to prevent conflicts with other editors."
53
- ),
54
- canRetry: true
62
+ )
55
63
  }
56
64
  };
57
65
  function getSyncErrorMessages(error) {
58
- if (ERROR_MESSAGES[error?.code]) {
66
+ if (error?.code && ERROR_MESSAGES[error?.code]) {
59
67
  return ERROR_MESSAGES[error.code];
60
68
  }
61
- return ERROR_MESSAGES["unknown-error"];
69
+ return ERROR_MESSAGES[UNKNOWN_ERROR];
62
70
  }
63
71
  // Annotate the CommonJS export names for ESM import in node:
64
72
  0 && (module.exports = {
73
+ AUTHENTICATION_FAILED,
74
+ CONNECTION_EXPIRED,
75
+ CONNECTION_LIMIT_EXCEEDED,
76
+ DOCUMENT_SIZE_LIMIT_EXCEEDED,
77
+ UNKNOWN_ERROR,
65
78
  getSyncErrorMessages
66
79
  });
67
80
  //# sourceMappingURL=sync-error-messages.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/utils/sync-error-messages.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Default error messages for known error codes.\n */\nconst ERROR_MESSAGES = {\n\t'authentication-failed': {\n\t\ttitle: __( 'Unable to connect' ),\n\t\tdescription: __(\n\t\t\t\"Real-time collaboration couldn't verify your permissions. \" +\n\t\t\t\t'Check that you have access to edit this post, or contact your site administrator.'\n\t\t),\n\t\tcanRetry: false,\n\t},\n\t'connection-expired': {\n\t\ttitle: __( 'Connection expired' ),\n\t\tdescription: __(\n\t\t\t'Your connection to real-time collaboration has timed out. ' +\n\t\t\t\t'Editing is paused to prevent conflicts with other editors.'\n\t\t),\n\t\tcanRetry: true,\n\t},\n\t'connection-limit-exceeded': {\n\t\ttitle: __( 'Too many editors connected' ),\n\t\tdescription: __(\n\t\t\t'Real-time collaboration has reached its connection limit. ' +\n\t\t\t\t'Try again later or contact your site administrator.'\n\t\t),\n\t\tcanRetry: true,\n\t},\n\t'unknown-error': {\n\t\ttitle: __( 'Connection lost' ),\n\t\tdescription: __(\n\t\t\t'The connection to real-time collaboration was interrupted. ' +\n\t\t\t\t'Editing is paused to prevent conflicts with other editors.'\n\t\t),\n\t\tcanRetry: true,\n\t},\n};\n\n/**\n * Get user-facing title and description from a sync connection error.\n *\n * Provides default messages based on error.code.\n *\n * @param {Object} error - Connection error object.\n * @return {Object} Object with title, description, and canRetry flag.\n */\nexport function getSyncErrorMessages( error ) {\n\tif ( ERROR_MESSAGES[ error?.code ] ) {\n\t\treturn ERROR_MESSAGES[ error.code ];\n\t}\n\n\treturn ERROR_MESSAGES[ 'unknown-error' ];\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,IAAM,iBAAiB;AAAA,EACtB,yBAAyB;AAAA,IACxB,WAAO,gBAAI,mBAAoB;AAAA,IAC/B,iBAAa;AAAA,MACZ;AAAA,IAED;AAAA,IACA,UAAU;AAAA,EACX;AAAA,EACA,sBAAsB;AAAA,IACrB,WAAO,gBAAI,oBAAqB;AAAA,IAChC,iBAAa;AAAA,MACZ;AAAA,IAED;AAAA,IACA,UAAU;AAAA,EACX;AAAA,EACA,6BAA6B;AAAA,IAC5B,WAAO,gBAAI,4BAA6B;AAAA,IACxC,iBAAa;AAAA,MACZ;AAAA,IAED;AAAA,IACA,UAAU;AAAA,EACX;AAAA,EACA,iBAAiB;AAAA,IAChB,WAAO,gBAAI,iBAAkB;AAAA,IAC7B,iBAAa;AAAA,MACZ;AAAA,IAED;AAAA,IACA,UAAU;AAAA,EACX;AACD;AAUO,SAAS,qBAAsB,OAAQ;AAC7C,MAAK,eAAgB,OAAO,IAAK,GAAI;AACpC,WAAO,eAAgB,MAAM,IAAK;AAAA,EACnC;AAEA,SAAO,eAAgB,eAAgB;AACxC;",
3
+ "sources": ["../../src/utils/sync-error-messages.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { type ConnectionError } from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n// These error codes are defined in the sync package:\n// packages/sync/src/errors.ts\nexport const AUTHENTICATION_FAILED = 'authentication-failed';\nexport const CONNECTION_EXPIRED = 'connection-expired';\nexport const CONNECTION_LIMIT_EXCEEDED = 'connection-limit-exceeded';\nexport const DOCUMENT_SIZE_LIMIT_EXCEEDED = 'document-size-limit-exceeded';\nexport const UNKNOWN_ERROR = 'unknown-error';\n\ninterface ConnectionErrorMessages {\n\tdescription: string;\n\ttitle: string;\n}\n\n/**\n * Default error messages for known error codes.\n */\nconst ERROR_MESSAGES: Record< string, ConnectionErrorMessages > = {\n\t[ AUTHENTICATION_FAILED ]: {\n\t\ttitle: __( 'Unable to connect' ),\n\t\tdescription: __(\n\t\t\t\"Real-time collaboration couldn't verify your permissions. \" +\n\t\t\t\t'Check that you have access to edit this post or contact your site administrator.'\n\t\t),\n\t},\n\t[ CONNECTION_EXPIRED ]: {\n\t\ttitle: __( 'Connection expired' ),\n\t\tdescription: __(\n\t\t\t'Your connection to real-time collaboration has timed out. ' +\n\t\t\t\t'Editing is paused to prevent conflicts with other editors.'\n\t\t),\n\t},\n\t[ CONNECTION_LIMIT_EXCEEDED ]: {\n\t\ttitle: __( 'Too many editors connected' ),\n\t\tdescription: __(\n\t\t\t'Real-time collaboration has reached its connection limit. ' +\n\t\t\t\t'Try again later or contact your site administrator.'\n\t\t),\n\t},\n\t// DOCUMENT_SIZE_LIMIT_EXCEEDED is not included here because it results in\n\t// collaboration being disabled entirely.\n\t[ UNKNOWN_ERROR ]: {\n\t\ttitle: __( 'Connection lost' ),\n\t\tdescription: __(\n\t\t\t'The connection to real-time collaboration was interrupted. ' +\n\t\t\t\t'Editing is paused to prevent conflicts with other editors.'\n\t\t),\n\t},\n};\n\n/**\n * Get user-facing title and description from a sync connection error.\n *\n * Provides default messages based on error.code.\n *\n * @param error - Connection error.\n * @return Object with title, description, and canRetry flag.\n */\nexport function getSyncErrorMessages(\n\terror?: ConnectionError\n): ConnectionErrorMessages {\n\tif ( error?.code && ERROR_MESSAGES[ error?.code ] ) {\n\t\treturn ERROR_MESSAGES[ error.code ];\n\t}\n\n\treturn ERROR_MESSAGES[ UNKNOWN_ERROR ];\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AAIZ,IAAM,wBAAwB;AAC9B,IAAM,qBAAqB;AAC3B,IAAM,4BAA4B;AAClC,IAAM,+BAA+B;AACrC,IAAM,gBAAgB;AAU7B,IAAM,iBAA4D;AAAA,EACjE,CAAE,qBAAsB,GAAG;AAAA,IAC1B,WAAO,gBAAI,mBAAoB;AAAA,IAC/B,iBAAa;AAAA,MACZ;AAAA,IAED;AAAA,EACD;AAAA,EACA,CAAE,kBAAmB,GAAG;AAAA,IACvB,WAAO,gBAAI,oBAAqB;AAAA,IAChC,iBAAa;AAAA,MACZ;AAAA,IAED;AAAA,EACD;AAAA,EACA,CAAE,yBAA0B,GAAG;AAAA,IAC9B,WAAO,gBAAI,4BAA6B;AAAA,IACxC,iBAAa;AAAA,MACZ;AAAA,IAED;AAAA,EACD;AAAA;AAAA;AAAA,EAGA,CAAE,aAAc,GAAG;AAAA,IAClB,WAAO,gBAAI,iBAAkB;AAAA,IAC7B,iBAAa;AAAA,MACZ;AAAA,IAED;AAAA,EACD;AACD;AAUO,SAAS,qBACf,OAC0B;AAC1B,MAAK,OAAO,QAAQ,eAAgB,OAAO,IAAK,GAAI;AACnD,WAAO,eAAgB,MAAM,IAAK;AAAA,EACnC;AAEA,SAAO,eAAgB,aAAc;AACtC;",
6
6
  "names": []
7
7
  }
@@ -28,7 +28,7 @@ function computeCursorOnly(start, overlayContext) {
28
28
  );
29
29
  return {
30
30
  coords: getCursorPosition(
31
- start.textIndex,
31
+ start.richTextOffset,
32
32
  blockElement,
33
33
  overlayContext.editorDocument,
34
34
  overlayContext.overlayRect
@@ -36,7 +36,7 @@ function computeCursorOnly(start, overlayContext) {
36
36
  };
37
37
  }
38
38
  function computeTextSelection(selection, start, end, overlayContext) {
39
- if (!start.localClientId || !end.localClientId || start.textIndex === null || end.textIndex === null) {
39
+ if (!start.localClientId || !end.localClientId || start.richTextOffset === null || end.richTextOffset === null) {
40
40
  return {};
41
41
  }
42
42
  const isReverse = selection.selectionDirection === SelectionDirection.Backward;
@@ -55,7 +55,7 @@ function computeTextSelection(selection, start, end, overlayContext) {
55
55
  if (allRects.length > 0) {
56
56
  return {
57
57
  coords: getCursorPosition(
58
- activeEnd.textIndex,
58
+ activeEnd.richTextOffset,
59
59
  activeEndBlock,
60
60
  overlayContext.editorDocument,
61
61
  overlayContext.overlayRect
@@ -68,7 +68,7 @@ function computeTextSelection(selection, start, end, overlayContext) {
68
68
  );
69
69
  return {
70
70
  coords: getCursorPosition(
71
- start.textIndex,
71
+ start.richTextOffset,
72
72
  startBlock,
73
73
  overlayContext.editorDocument,
74
74
  overlayContext.overlayRect
@@ -79,14 +79,14 @@ function computeSingleBlockRects(start, end, overlayContext) {
79
79
  const blockElement = overlayContext.editorDocument.querySelector(
80
80
  `[data-block="${start.localClientId}"]`
81
81
  );
82
- if (!blockElement || start.textIndex === null || end.textIndex === null) {
82
+ if (!blockElement || start.richTextOffset === null || end.richTextOffset === null) {
83
83
  return { rects: [], blockElement: null };
84
84
  }
85
85
  return {
86
86
  rects: getSelectionRects(
87
87
  blockElement,
88
- start.textIndex,
89
- end.textIndex,
88
+ start.richTextOffset,
89
+ end.richTextOffset,
90
90
  overlayContext.editorDocument,
91
91
  overlayContext.overlayRect
92
92
  ) ?? [],
@@ -107,7 +107,7 @@ function computeMultiBlockRects(start, end, overlayContext) {
107
107
  docLast = start;
108
108
  [firstBlock, lastBlock] = [lastBlock, firstBlock];
109
109
  }
110
- if (!firstBlock || !lastBlock || docFirst.textIndex === null || docLast.textIndex === null || !docFirst.localClientId || !docLast.localClientId) {
110
+ if (!firstBlock || !lastBlock || docFirst.richTextOffset === null || docLast.richTextOffset === null || !docFirst.localClientId || !docLast.localClientId) {
111
111
  return {
112
112
  rects: [],
113
113
  firstBlock: null,
@@ -118,7 +118,7 @@ function computeMultiBlockRects(start, end, overlayContext) {
118
118
  const allRects = [];
119
119
  const startRects = getSelectionRects(
120
120
  firstBlock,
121
- docFirst.textIndex,
121
+ docFirst.richTextOffset,
122
122
  Number.MAX_SAFE_INTEGER,
123
123
  overlayContext.editorDocument,
124
124
  overlayContext.overlayRect
@@ -142,7 +142,7 @@ function computeMultiBlockRects(start, end, overlayContext) {
142
142
  const endRects = getSelectionRects(
143
143
  lastBlock,
144
144
  0,
145
- docLast.textIndex,
145
+ docLast.richTextOffset,
146
146
  overlayContext.editorDocument,
147
147
  overlayContext.overlayRect
148
148
  );
@@ -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,SAAS,oBAAoB,qBAAqB;AAGlD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAsCA,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QAAM,aAAa;AAAA,IAClB;AAAA,IACA,SAAS;AAAA,IACT,OAAO;AAAA,IACP,eAAe;AAAA,IACf,eAAe;AAAA,EAChB;AACA,MAAK,YAAa;AACjB,aAAS,KAAM,GAAG,UAAW;AAAA,EAC9B;AAGA,QAAM,qBAAqB;AAAA,IAC1B,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,eAAe;AAAA,EAChB;AACA,aAAY,qBAAqB,oBAAqB;AACrD,UAAM,QAAQ;AAAA,MACb;AAAA,MACA,eAAe;AAAA,MACf,eAAe;AAAA,IAChB;AACA,aAAS,KAAM,GAAG,KAAM;AAAA,EACzB;AAGA,QAAM,WAAW;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,SAAS,oBAAoB,qBAAqB;AAGlD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAsCA,SAAS,uBACf,WACA,OACA,KACA,gBACkB;AAClB,MACC,UAAU,SAAS,cAAc,QACjC,UAAU,SAAS,cAAc,YAChC;AACD,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,UAAU,SAAS,cAAc,QAAS;A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AG,UAAW;AAAA,EAC9B;AAGA,QAAM,qBAAqB;AAAA,IAC1B,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,eAAe;AAAA,EAChB;AACA,aAAY,qBAAqB,oBAAqB;AACrD,UAAM,QAAQ;AAAA,MACb;AAAA,MACA,eAAe;AAAA,MACf,eAAe;AAAA,IAChB;AACA,aAAS,KAAM,GAAG,KAAM;AAAA,EACzB;AAGA,QAAM,WAAW;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;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,61 @@
1
+ // packages/editor/src/components/collaborators-overlay/cursor-registry.ts
2
+ function highlightCursor(element, duration) {
3
+ element.classList.add("collaborators-overlay-cursor-highlighted");
4
+ setTimeout(() => {
5
+ element.classList.remove("collaborators-overlay-cursor-highlighted");
6
+ }, duration);
7
+ }
8
+ function createCursorRegistry() {
9
+ const cursorMap = /* @__PURE__ */ new Map();
10
+ return {
11
+ /**
12
+ * Register a cursor element when it's created.
13
+ *
14
+ * @param clientId - The clientId of the cursor to register.
15
+ * @param element - The cursor element to register.
16
+ */
17
+ registerCursor(clientId, element) {
18
+ cursorMap.set(clientId, element);
19
+ },
20
+ /**
21
+ * Unregister a cursor element when it's removed.
22
+ *
23
+ * @param clientId - The clientId of the cursor to unregister.
24
+ */
25
+ unregisterCursor(clientId) {
26
+ cursorMap.delete(clientId);
27
+ },
28
+ /**
29
+ * Scroll to a cursor by clientId.
30
+ *
31
+ * @param clientId - The clientId of the cursor to scroll to.
32
+ * @param options - The options for the scroll.
33
+ * @return true if cursor was found and scrolled to, false otherwise.
34
+ */
35
+ scrollToCursor(clientId, options) {
36
+ const cursorElement = cursorMap.get(clientId);
37
+ if (!cursorElement) {
38
+ return false;
39
+ }
40
+ cursorElement.scrollIntoView({
41
+ behavior: options?.behavior ?? "smooth",
42
+ block: options?.block ?? "center",
43
+ inline: options?.inline ?? "nearest"
44
+ });
45
+ if (options?.highlightDuration) {
46
+ highlightCursor(cursorElement, options.highlightDuration);
47
+ }
48
+ return true;
49
+ },
50
+ /**
51
+ * Clear the registry.
52
+ */
53
+ removeAll() {
54
+ cursorMap.clear();
55
+ }
56
+ };
57
+ }
58
+ export {
59
+ createCursorRegistry
60
+ };
61
+ //# sourceMappingURL=cursor-registry.mjs.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": ";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
+ }
@@ -4,7 +4,11 @@ import { unlock } from "../../lock-unlock.mjs";
4
4
  import { Overlay } from "./overlay.mjs";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  var { BlockCanvasCover } = unlock(privateApis);
7
- function CollaboratorsOverlay({ postId, postType }) {
7
+ function CollaboratorsOverlay({
8
+ postId,
9
+ postType,
10
+ cursorRegistry
11
+ }) {
8
12
  return /* @__PURE__ */ jsx(BlockCanvasCover.Fill, { children: ({
9
13
  containerRef
10
14
  }) => /* @__PURE__ */ jsx(
@@ -12,7 +16,8 @@ function CollaboratorsOverlay({ postId, postType }) {
12
16
  {
13
17
  blockEditorDocument: containerRef.current?.ownerDocument,
14
18
  postId,
15
- postType
19
+ postType,
20
+ cursorRegistry
16
21
  }
17
22
  ) });
18
23
  }
@@ -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": ";AAIA,SAAS,mBAAmB;AAK5B,SAAS,cAAc;AACvB,SAAS,eAAe;AAwBpB;AAtBJ,IAAM,EAAE,iBAAiB,IAAI,OAAQ,WAAY;AAc1C,SAAS,qBAAsB,EAAE,QAAQ,SAAS,GAAW;AACnE,SACC,oBAAC,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": ";AAIA,SAAS,mBAAmB;AAK5B,SAAS,cAAc;AACvB,SAAS,eAAe;AA+BpB;AA5BJ,IAAM,EAAE,iBAAiB,IAAI,OAAQ,WAAY;AAgB1C,SAAS,qBAAsB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACD,GAAW;AACV,SACC,oBAAC,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
  }