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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (481) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/collab-sidebar/add-comment.cjs +0 -3
  3. package/build/components/collab-sidebar/add-comment.cjs.map +2 -2
  4. package/build/components/collab-sidebar/comments.cjs +0 -3
  5. package/build/components/collab-sidebar/comments.cjs.map +2 -2
  6. package/build/components/collab-sidebar/index.cjs +7 -4
  7. package/build/components/collab-sidebar/index.cjs.map +2 -2
  8. package/build/components/collab-sidebar/utils.cjs +13 -15
  9. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs +141 -0
  11. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +7 -0
  12. package/build/components/collaborators-overlay/collaborator-styles.cjs +38 -2
  13. package/build/components/collaborators-overlay/collaborator-styles.cjs.map +2 -2
  14. package/build/components/collaborators-overlay/compute-selection.cjs +185 -0
  15. package/build/components/collaborators-overlay/compute-selection.cjs.map +7 -0
  16. package/build/components/collaborators-overlay/cursor-dom-utils.cjs +243 -0
  17. package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +7 -0
  18. package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
  19. package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
  20. package/build/components/collaborators-overlay/index.cjs +7 -2
  21. package/build/components/collaborators-overlay/index.cjs.map +2 -2
  22. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +148 -0
  23. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +7 -0
  24. package/build/components/collaborators-overlay/overlay.cjs +141 -229
  25. package/build/components/collaborators-overlay/overlay.cjs.map +3 -3
  26. package/build/components/collaborators-overlay/timing-utils.cjs +46 -0
  27. package/build/components/collaborators-overlay/timing-utils.cjs.map +7 -0
  28. package/build/components/collaborators-overlay/use-block-highlighting.cjs +91 -42
  29. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +2 -2
  30. package/build/components/collaborators-overlay/use-debounced-recompute.cjs +49 -0
  31. package/build/components/collaborators-overlay/use-debounced-recompute.cjs.map +7 -0
  32. package/build/components/collaborators-overlay/use-render-cursors.cjs +82 -172
  33. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  34. package/build/components/collaborators-presence/avatar/component.cjs +121 -0
  35. package/build/components/collaborators-presence/avatar/component.cjs.map +7 -0
  36. package/build/components/collaborators-presence/avatar/index.cjs +37 -0
  37. package/build/components/collaborators-presence/avatar/index.cjs.map +7 -0
  38. package/build/components/collaborators-presence/avatar/types.cjs +19 -0
  39. package/build/components/collaborators-presence/avatar/types.cjs.map +7 -0
  40. package/build/components/collaborators-presence/avatar/use-image-loading-status.cjs +44 -0
  41. package/build/components/collaborators-presence/avatar/use-image-loading-status.cjs.map +7 -0
  42. package/build/components/collaborators-presence/avatar-group/component.cjs +78 -0
  43. package/build/components/collaborators-presence/avatar-group/component.cjs.map +7 -0
  44. package/build/components/collaborators-presence/avatar-group/index.cjs +37 -0
  45. package/build/components/collaborators-presence/avatar-group/index.cjs.map +7 -0
  46. package/build/components/collaborators-presence/avatar-group/types.cjs +19 -0
  47. package/build/components/collaborators-presence/avatar-group/types.cjs.map +7 -0
  48. package/build/components/collaborators-presence/index.cjs +66 -19
  49. package/build/components/collaborators-presence/index.cjs.map +3 -3
  50. package/build/components/collaborators-presence/list.cjs +60 -38
  51. package/build/components/collaborators-presence/list.cjs.map +3 -3
  52. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +149 -0
  53. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +7 -0
  54. package/build/components/editor-interface/index.cjs +11 -6
  55. package/build/components/editor-interface/index.cjs.map +2 -2
  56. package/build/components/inserter-sidebar/index.cjs +2 -1
  57. package/build/components/inserter-sidebar/index.cjs.map +2 -2
  58. package/build/components/more-menu/copy-content-menu-item.cjs +19 -2
  59. package/build/components/more-menu/copy-content-menu-item.cjs.map +3 -3
  60. package/build/components/post-last-revision/index.cjs +27 -6
  61. package/build/components/post-last-revision/index.cjs.map +2 -2
  62. package/build/components/post-locked-modal/index.cjs +49 -17
  63. package/build/components/post-locked-modal/index.cjs.map +3 -3
  64. package/build/components/post-revisions-preview/block-diff.cjs +130 -34
  65. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  66. package/build/components/post-revisions-preview/diff-markers.cjs +6 -5
  67. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  68. package/build/components/post-revisions-preview/revisions-canvas.cjs +16 -60
  69. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +3 -3
  70. package/build/components/post-revisions-preview/revisions-slider.cjs +102 -39
  71. package/build/components/post-revisions-preview/revisions-slider.cjs.map +3 -3
  72. package/build/components/post-text-editor/index.cjs +20 -5
  73. package/build/components/post-text-editor/index.cjs.map +3 -3
  74. package/build/components/preferences-modal/index.cjs +36 -4
  75. package/build/components/preferences-modal/index.cjs.map +2 -2
  76. package/build/components/provider/disable-non-page-content-blocks.cjs +31 -28
  77. package/build/components/provider/disable-non-page-content-blocks.cjs.map +3 -3
  78. package/build/components/provider/index.cjs +17 -5
  79. package/build/components/provider/index.cjs.map +2 -2
  80. package/build/components/provider/use-block-editor-settings.cjs +20 -4
  81. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  82. package/build/components/provider/{use-post-content-blocks.cjs → use-post-content-block-types.cjs} +8 -19
  83. package/build/components/provider/use-post-content-block-types.cjs.map +7 -0
  84. package/build/components/provider/use-revision-blocks.cjs +106 -0
  85. package/build/components/provider/use-revision-blocks.cjs.map +7 -0
  86. package/build/components/revision-block-diff/index.cjs +61 -0
  87. package/build/components/revision-block-diff/index.cjs.map +7 -0
  88. package/build/components/revision-diff-panel/index.cjs +68 -0
  89. package/build/components/revision-diff-panel/index.cjs.map +7 -0
  90. package/build/components/revision-fields-diff/index.cjs +96 -0
  91. package/build/components/revision-fields-diff/index.cjs.map +7 -0
  92. package/build/components/sidebar/header.cjs +1 -1
  93. package/build/components/sidebar/header.cjs.map +2 -2
  94. package/build/components/sidebar/index.cjs +7 -1
  95. package/build/components/sidebar/index.cjs.map +3 -3
  96. package/build/components/style-book/index.cjs +4 -3
  97. package/build/components/style-book/index.cjs.map +2 -2
  98. package/build/components/sync-connection-error-modal/index.cjs +187 -0
  99. package/build/components/sync-connection-error-modal/index.cjs.map +7 -0
  100. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs +84 -0
  101. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +7 -0
  102. package/build/components/template-content-panel/index.cjs +35 -31
  103. package/build/components/template-content-panel/index.cjs.map +3 -3
  104. package/build/components/template-part-menu-items/convert-to-regular.cjs +54 -11
  105. package/build/components/template-part-menu-items/convert-to-regular.cjs.map +3 -3
  106. package/build/components/visual-editor/index.cjs +6 -15
  107. package/build/components/visual-editor/index.cjs.map +2 -2
  108. package/build/store/private-actions.cjs +46 -2
  109. package/build/store/private-actions.cjs.map +2 -2
  110. package/build/store/private-selectors.cjs +154 -29
  111. package/build/store/private-selectors.cjs.map +2 -2
  112. package/build/store/reducer.cjs +27 -0
  113. package/build/store/reducer.cjs.map +2 -2
  114. package/build/store/selectors.cjs +0 -14
  115. package/build/store/selectors.cjs.map +2 -2
  116. package/build/utils/media-finalize/index.cjs +43 -0
  117. package/build/utils/media-finalize/index.cjs.map +7 -0
  118. package/build/utils/media-upload/on-success.cjs +46 -0
  119. package/build/utils/media-upload/on-success.cjs.map +7 -0
  120. package/build/utils/sync-error-messages.cjs +32 -15
  121. package/build/utils/sync-error-messages.cjs.map +3 -3
  122. package/build-module/components/collab-sidebar/add-comment.mjs +0 -3
  123. package/build-module/components/collab-sidebar/add-comment.mjs.map +2 -2
  124. package/build-module/components/collab-sidebar/comments.mjs +0 -3
  125. package/build-module/components/collab-sidebar/comments.mjs.map +2 -2
  126. package/build-module/components/collab-sidebar/index.mjs +7 -4
  127. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  128. package/build-module/components/collab-sidebar/utils.mjs +13 -15
  129. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  130. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs +128 -0
  131. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +7 -0
  132. package/build-module/components/collaborators-overlay/collaborator-styles.mjs +25 -1
  133. package/build-module/components/collaborators-overlay/collaborator-styles.mjs.map +2 -2
  134. package/build-module/components/collaborators-overlay/compute-selection.mjs +166 -0
  135. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +7 -0
  136. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +213 -0
  137. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +7 -0
  138. package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
  139. package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
  140. package/build-module/components/collaborators-overlay/index.mjs +7 -2
  141. package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
  142. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +130 -0
  143. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +7 -0
  144. package/build-module/components/collaborators-overlay/overlay.mjs +132 -230
  145. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  146. package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
  147. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
  148. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +93 -45
  149. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  150. package/build-module/components/collaborators-overlay/use-debounced-recompute.mjs +24 -0
  151. package/build-module/components/collaborators-overlay/use-debounced-recompute.mjs.map +7 -0
  152. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +83 -176
  153. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  154. package/build-module/components/collaborators-presence/avatar/component.mjs +90 -0
  155. package/build-module/components/collaborators-presence/avatar/component.mjs.map +7 -0
  156. package/build-module/components/collaborators-presence/avatar/index.mjs +6 -0
  157. package/build-module/components/collaborators-presence/avatar/index.mjs.map +7 -0
  158. package/build-module/components/collaborators-presence/avatar/types.mjs +1 -0
  159. package/build-module/components/collaborators-presence/avatar/types.mjs.map +7 -0
  160. package/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs +19 -0
  161. package/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs.map +7 -0
  162. package/build-module/components/collaborators-presence/avatar-group/component.mjs +47 -0
  163. package/build-module/components/collaborators-presence/avatar-group/component.mjs.map +7 -0
  164. package/build-module/components/collaborators-presence/avatar-group/index.mjs +6 -0
  165. package/build-module/components/collaborators-presence/avatar-group/index.mjs.map +7 -0
  166. package/build-module/components/collaborators-presence/avatar-group/types.mjs +1 -0
  167. package/build-module/components/collaborators-presence/avatar-group/types.mjs.map +7 -0
  168. package/build-module/components/collaborators-presence/index.mjs +57 -23
  169. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  170. package/build-module/components/collaborators-presence/list.mjs +52 -44
  171. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  172. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +126 -0
  173. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +7 -0
  174. package/build-module/components/editor-interface/index.mjs +12 -7
  175. package/build-module/components/editor-interface/index.mjs.map +2 -2
  176. package/build-module/components/inserter-sidebar/index.mjs +2 -1
  177. package/build-module/components/inserter-sidebar/index.mjs.map +2 -2
  178. package/build-module/components/more-menu/copy-content-menu-item.mjs +19 -2
  179. package/build-module/components/more-menu/copy-content-menu-item.mjs.map +2 -2
  180. package/build-module/components/post-last-revision/index.mjs +27 -6
  181. package/build-module/components/post-last-revision/index.mjs.map +2 -2
  182. package/build-module/components/post-locked-modal/index.mjs +49 -17
  183. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  184. package/build-module/components/post-revisions-preview/block-diff.mjs +130 -34
  185. package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
  186. package/build-module/components/post-revisions-preview/diff-markers.mjs +6 -5
  187. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  188. package/build-module/components/post-revisions-preview/revisions-canvas.mjs +18 -65
  189. package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
  190. package/build-module/components/post-revisions-preview/revisions-slider.mjs +110 -42
  191. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  192. package/build-module/components/post-text-editor/index.mjs +20 -5
  193. package/build-module/components/post-text-editor/index.mjs.map +2 -2
  194. package/build-module/components/preferences-modal/index.mjs +36 -4
  195. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  196. package/build-module/components/provider/disable-non-page-content-blocks.mjs +31 -28
  197. package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
  198. package/build-module/components/provider/index.mjs +17 -5
  199. package/build-module/components/provider/index.mjs.map +2 -2
  200. package/build-module/components/provider/use-block-editor-settings.mjs +20 -4
  201. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  202. package/build-module/components/provider/use-post-content-block-types.mjs +23 -0
  203. package/build-module/components/provider/use-post-content-block-types.mjs.map +7 -0
  204. package/build-module/components/provider/use-revision-blocks.mjs +81 -0
  205. package/build-module/components/provider/use-revision-blocks.mjs.map +7 -0
  206. package/build-module/components/revision-block-diff/index.mjs +30 -0
  207. package/build-module/components/revision-block-diff/index.mjs.map +7 -0
  208. package/build-module/components/revision-diff-panel/index.mjs +37 -0
  209. package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
  210. package/build-module/components/revision-fields-diff/index.mjs +65 -0
  211. package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
  212. package/build-module/components/sidebar/header.mjs +1 -1
  213. package/build-module/components/sidebar/header.mjs.map +2 -2
  214. package/build-module/components/sidebar/index.mjs +7 -1
  215. package/build-module/components/sidebar/index.mjs.map +2 -2
  216. package/build-module/components/style-book/index.mjs +4 -3
  217. package/build-module/components/style-book/index.mjs.map +2 -2
  218. package/build-module/components/sync-connection-error-modal/index.mjs +170 -0
  219. package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
  220. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +59 -0
  221. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
  222. package/build-module/components/template-content-panel/index.mjs +25 -31
  223. package/build-module/components/template-content-panel/index.mjs.map +2 -2
  224. package/build-module/components/template-part-menu-items/convert-to-regular.mjs +60 -14
  225. package/build-module/components/template-part-menu-items/convert-to-regular.mjs.map +2 -2
  226. package/build-module/components/visual-editor/index.mjs +6 -15
  227. package/build-module/components/visual-editor/index.mjs.map +2 -2
  228. package/build-module/store/private-actions.mjs +44 -2
  229. package/build-module/store/private-actions.mjs.map +2 -2
  230. package/build-module/store/private-selectors.mjs +153 -29
  231. package/build-module/store/private-selectors.mjs.map +2 -2
  232. package/build-module/store/reducer.mjs +25 -0
  233. package/build-module/store/reducer.mjs.map +2 -2
  234. package/build-module/store/selectors.mjs +0 -13
  235. package/build-module/store/selectors.mjs.map +2 -2
  236. package/build-module/utils/media-finalize/index.mjs +12 -0
  237. package/build-module/utils/media-finalize/index.mjs.map +7 -0
  238. package/build-module/utils/media-upload/on-success.mjs +25 -0
  239. package/build-module/utils/media-upload/on-success.mjs.map +7 -0
  240. package/build-module/utils/sync-error-messages.mjs +27 -15
  241. package/build-module/utils/sync-error-messages.mjs.map +3 -3
  242. package/build-style/style-rtl.css +296 -121
  243. package/build-style/style.css +296 -121
  244. package/build-types/components/autocompleters/link.d.ts +8 -0
  245. package/build-types/components/autocompleters/link.d.ts.map +1 -0
  246. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -1
  247. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts +5 -0
  248. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts.map +1 -0
  249. package/build-types/components/collab-sidebar/add-note.d.ts +6 -0
  250. package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -0
  251. package/build-types/components/collab-sidebar/board-store.d.ts +9 -0
  252. package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -0
  253. package/build-types/components/collab-sidebar/floating-container.d.ts +8 -0
  254. package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -0
  255. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  256. package/build-types/components/collab-sidebar/note-byline.d.ts +10 -0
  257. package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -0
  258. package/build-types/components/collab-sidebar/note-card.d.ts +8 -0
  259. package/build-types/components/collab-sidebar/note-card.d.ts.map +1 -0
  260. package/build-types/components/collab-sidebar/note-form.d.ts +7 -0
  261. package/build-types/components/collab-sidebar/note-form.d.ts.map +1 -0
  262. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts +5 -0
  263. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -0
  264. package/build-types/components/collab-sidebar/note-thread.d.ts +11 -0
  265. package/build-types/components/collab-sidebar/note-thread.d.ts.map +1 -0
  266. package/build-types/components/collab-sidebar/note.d.ts +9 -0
  267. package/build-types/components/collab-sidebar/note.d.ts.map +1 -0
  268. package/build-types/components/collab-sidebar/notes.d.ts +7 -0
  269. package/build-types/components/collab-sidebar/notes.d.ts.map +1 -0
  270. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  271. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts +11 -0
  272. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts.map +1 -0
  273. package/build-types/components/collaborators-overlay/collaborator-styles.d.ts +17 -2
  274. package/build-types/components/collaborators-overlay/collaborator-styles.d.ts.map +1 -1
  275. package/build-types/components/collaborators-overlay/compute-selection.d.ts +24 -0
  276. package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -0
  277. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts +72 -0
  278. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts.map +1 -0
  279. package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
  280. package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
  281. package/build-types/components/collaborators-overlay/index.d.ts +7 -4
  282. package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
  283. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +6 -0
  284. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -0
  285. package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
  286. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  287. package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
  288. package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
  289. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +21 -5
  290. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  291. package/build-types/components/collaborators-overlay/use-debounced-recompute.d.ts +10 -0
  292. package/build-types/components/collaborators-overlay/use-debounced-recompute.d.ts.map +1 -0
  293. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts +6 -1
  294. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  295. package/build-types/components/collaborators-presence/avatar/component.d.ts +7 -0
  296. package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -0
  297. package/build-types/components/collaborators-presence/avatar/index.d.ts +3 -0
  298. package/build-types/components/collaborators-presence/avatar/index.d.ts.map +1 -0
  299. package/build-types/components/collaborators-presence/avatar/types.d.ts +66 -0
  300. package/build-types/components/collaborators-presence/avatar/types.d.ts.map +1 -0
  301. package/build-types/components/collaborators-presence/avatar/use-image-loading-status.d.ts +17 -0
  302. package/build-types/components/collaborators-presence/avatar/use-image-loading-status.d.ts.map +1 -0
  303. package/build-types/components/collaborators-presence/avatar-group/component.d.ts +7 -0
  304. package/build-types/components/collaborators-presence/avatar-group/component.d.ts.map +1 -0
  305. package/build-types/components/collaborators-presence/avatar-group/index.d.ts +3 -0
  306. package/build-types/components/collaborators-presence/avatar-group/index.d.ts.map +1 -0
  307. package/build-types/components/collaborators-presence/avatar-group/types.d.ts +14 -0
  308. package/build-types/components/collaborators-presence/avatar-group/types.d.ts.map +1 -0
  309. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  310. package/build-types/components/collaborators-presence/list.d.ts +6 -2
  311. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  312. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts +9 -0
  313. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -0
  314. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  315. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  316. package/build-types/components/media/media-editor-modal.d.ts +15 -0
  317. package/build-types/components/media/media-editor-modal.d.ts.map +1 -0
  318. package/build-types/components/more-menu/copy-content-menu-item.d.ts.map +1 -1
  319. package/build-types/components/post-last-revision/index.d.ts.map +1 -1
  320. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  321. package/build-types/components/post-revisions-panel/index.d.ts +2 -0
  322. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
  323. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  324. package/build-types/components/post-revisions-preview/diff-markers.d.ts.map +1 -1
  325. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +2 -5
  326. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
  327. package/build-types/components/post-revisions-preview/revisions-slider.d.ts +1 -1
  328. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  329. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  330. package/build-types/components/post-text-editor/utils.d.ts +29 -0
  331. package/build-types/components/post-text-editor/utils.d.ts.map +1 -0
  332. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  333. package/build-types/components/provider/index.d.ts.map +1 -1
  334. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  335. package/build-types/components/provider/use-network-reconnect.d.ts +8 -0
  336. package/build-types/components/provider/use-network-reconnect.d.ts.map +1 -0
  337. package/build-types/components/provider/use-post-content-block-types.d.ts +9 -0
  338. package/build-types/components/provider/use-post-content-block-types.d.ts.map +1 -0
  339. package/build-types/components/provider/use-revision-blocks.d.ts +10 -0
  340. package/build-types/components/provider/use-revision-blocks.d.ts.map +1 -0
  341. package/build-types/components/revision-block-diff/index.d.ts +6 -0
  342. package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
  343. package/build-types/components/revision-diff-panel/index.d.ts +14 -0
  344. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
  345. package/build-types/components/revision-fields-diff/index.d.ts +6 -0
  346. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
  347. package/build-types/components/sidebar/dataform-post-summary.d.ts +4 -0
  348. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -0
  349. package/build-types/components/sidebar/index.d.ts.map +1 -1
  350. package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
  351. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
  352. package/build-types/components/style-book/index.d.ts +2 -1
  353. package/build-types/components/style-book/index.d.ts.map +1 -1
  354. package/build-types/components/sync-connection-error-modal/index.d.ts +8 -0
  355. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
  356. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
  357. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
  358. package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
  359. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
  360. package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
  361. package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
  362. package/build-types/components/template-actions-panel/index.d.ts +2 -0
  363. package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
  364. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  365. package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -1
  366. package/build-types/components/upload-progress-snackbar/index.d.ts +19 -0
  367. package/build-types/components/upload-progress-snackbar/index.d.ts.map +1 -0
  368. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts +28 -0
  369. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts.map +1 -0
  370. package/build-types/components/upload-progress-snackbar/tracker.d.ts +41 -0
  371. package/build-types/components/upload-progress-snackbar/tracker.d.ts.map +1 -0
  372. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  373. package/build-types/store/private-actions.d.ts +12 -0
  374. package/build-types/store/private-actions.d.ts.map +1 -1
  375. package/build-types/store/private-selectors.d.ts +45 -0
  376. package/build-types/store/private-selectors.d.ts.map +1 -1
  377. package/build-types/store/reducer.d.ts +21 -0
  378. package/build-types/store/reducer.d.ts.map +1 -1
  379. package/build-types/store/selectors.d.ts +0 -10
  380. package/build-types/store/selectors.d.ts.map +1 -1
  381. package/build-types/utils/media-delete/index.d.ts +2 -0
  382. package/build-types/utils/media-delete/index.d.ts.map +1 -0
  383. package/build-types/utils/media-finalize/index.d.ts +2 -0
  384. package/build-types/utils/media-finalize/index.d.ts.map +1 -0
  385. package/build-types/utils/media-upload/on-success.d.ts +9 -0
  386. package/build-types/utils/media-upload/on-success.d.ts.map +1 -0
  387. package/build-types/utils/sync-error-messages.d.ts +17 -3
  388. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  389. package/package.json +45 -44
  390. package/src/components/collab-sidebar/add-comment.js +0 -4
  391. package/src/components/collab-sidebar/comments.js +0 -5
  392. package/src/components/collab-sidebar/index.js +7 -4
  393. package/src/components/collab-sidebar/utils.js +9 -10
  394. package/src/components/collaborators-overlay/avatar-iframe-styles.ts +134 -0
  395. package/src/components/collaborators-overlay/collaborator-styles.ts +43 -2
  396. package/src/components/collaborators-overlay/compute-selection.ts +315 -0
  397. package/src/components/collaborators-overlay/cursor-dom-utils.ts +382 -0
  398. package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
  399. package/src/components/collaborators-overlay/index.tsx +12 -4
  400. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +131 -0
  401. package/src/components/collaborators-overlay/overlay.tsx +145 -223
  402. package/src/components/collaborators-overlay/timing-utils.ts +30 -0
  403. package/src/components/collaborators-overlay/use-block-highlighting.ts +152 -64
  404. package/src/components/collaborators-overlay/use-debounced-recompute.ts +32 -0
  405. package/src/components/collaborators-overlay/use-render-cursors.ts +120 -282
  406. package/src/components/collaborators-presence/avatar/component.tsx +123 -0
  407. package/src/components/collaborators-presence/avatar/index.ts +2 -0
  408. package/src/components/collaborators-presence/avatar/styles.scss +184 -0
  409. package/src/components/collaborators-presence/avatar/test/index.tsx +389 -0
  410. package/src/components/collaborators-presence/avatar/types.ts +66 -0
  411. package/src/components/collaborators-presence/avatar/use-image-loading-status.ts +36 -0
  412. package/src/components/collaborators-presence/avatar-group/component.tsx +55 -0
  413. package/src/components/collaborators-presence/avatar-group/index.ts +2 -0
  414. package/src/components/collaborators-presence/avatar-group/styles.scss +33 -0
  415. package/src/components/collaborators-presence/avatar-group/test/index.tsx +139 -0
  416. package/src/components/collaborators-presence/avatar-group/types.ts +13 -0
  417. package/src/components/collaborators-presence/index.tsx +43 -12
  418. package/src/components/collaborators-presence/list.tsx +68 -40
  419. package/src/components/collaborators-presence/styles/collaborators-list.scss +26 -19
  420. package/src/components/collaborators-presence/styles/collaborators-presence.scss +6 -2
  421. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +397 -0
  422. package/src/components/collaborators-presence/use-collaborator-notifications.ts +203 -0
  423. package/src/components/document-bar/style.scss +1 -1
  424. package/src/components/editor-interface/index.js +13 -6
  425. package/src/components/inserter-sidebar/index.js +4 -1
  426. package/src/components/more-menu/copy-content-menu-item.js +20 -2
  427. package/src/components/post-last-revision/index.js +35 -6
  428. package/src/components/post-last-revision/style.scss +0 -3
  429. package/src/components/post-locked-modal/index.js +69 -25
  430. package/src/components/post-panel-row/style.scss +1 -0
  431. package/src/components/post-revisions-preview/block-diff.js +224 -61
  432. package/src/components/post-revisions-preview/diff-markers.js +15 -12
  433. package/src/components/post-revisions-preview/revisions-canvas.js +23 -86
  434. package/src/components/post-revisions-preview/revisions-slider.js +136 -63
  435. package/src/components/post-revisions-preview/style.scss +3 -3
  436. package/src/components/post-revisions-preview/test/block-diff.js +202 -35
  437. package/src/components/post-text-editor/index.js +25 -6
  438. package/src/components/preferences-modal/index.js +37 -7
  439. package/src/components/provider/disable-non-page-content-blocks.js +42 -40
  440. package/src/components/provider/index.js +20 -2
  441. package/src/components/provider/use-block-editor-settings.js +21 -1
  442. package/src/components/provider/use-post-content-block-types.js +30 -0
  443. package/src/components/provider/use-revision-blocks.js +105 -0
  444. package/src/components/revision-block-diff/index.js +39 -0
  445. package/src/components/revision-diff-panel/index.js +59 -0
  446. package/src/components/revision-diff-panel/style.scss +13 -0
  447. package/src/components/revision-fields-diff/index.js +91 -0
  448. package/src/components/sidebar/header.js +1 -1
  449. package/src/components/sidebar/index.js +4 -0
  450. package/src/components/style-book/index.js +4 -2
  451. package/src/components/sync-connection-error-modal/index.tsx +253 -0
  452. package/src/components/sync-connection-error-modal/style.scss +14 -0
  453. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +93 -0
  454. package/src/components/template-content-panel/index.js +30 -38
  455. package/src/components/template-part-menu-items/convert-to-regular.js +74 -12
  456. package/src/components/visual-editor/index.js +6 -23
  457. package/src/store/private-actions.js +70 -1
  458. package/src/store/private-selectors.js +215 -37
  459. package/src/store/reducer.js +41 -0
  460. package/src/store/selectors.js +0 -19
  461. package/src/style.scss +4 -1
  462. package/src/utils/media-finalize/index.js +11 -0
  463. package/src/utils/media-finalize/test/index.js +34 -0
  464. package/src/utils/media-upload/on-success.js +34 -0
  465. package/src/utils/sync-error-messages.ts +72 -0
  466. package/src/utils/test/sync-error-messages.js +34 -0
  467. package/build/components/provider/use-post-content-blocks.cjs.map +0 -7
  468. package/build/components/sync-connection-modal/index.cjs +0 -130
  469. package/build/components/sync-connection-modal/index.cjs.map +0 -7
  470. package/build-module/components/provider/use-post-content-blocks.mjs +0 -34
  471. package/build-module/components/provider/use-post-content-blocks.mjs.map +0 -7
  472. package/build-module/components/sync-connection-modal/index.mjs +0 -114
  473. package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
  474. package/build-types/components/provider/use-post-content-blocks.d.ts +0 -2
  475. package/build-types/components/provider/use-post-content-blocks.d.ts.map +0 -1
  476. package/build-types/components/sync-connection-modal/index.d.ts +0 -8
  477. package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
  478. package/src/components/provider/use-post-content-blocks.js +0 -42
  479. package/src/components/sync-connection-modal/index.js +0 -140
  480. package/src/components/sync-connection-modal/style.scss +0 -11
  481. package/src/utils/sync-error-messages.js +0 -53
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-locked-modal/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\tExternalLink,\n\t__experimentalHStack as HStack,\n\twithFilters,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect, createInterpolateElement } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction PostLockedModal() {\n\tconst instanceId = useInstanceId( PostLockedModal );\n\tconst hookName = 'core/editor/post-locked-modal-' + instanceId;\n\tconst { autosave, updatePostLock } = useDispatch( editorStore );\n\tconst {\n\t\tisCollaborationEnabled,\n\t\tisLocked,\n\t\tisTakeover,\n\t\tuser,\n\t\tpostId,\n\t\tpostLockUtils,\n\t\tactivePostLock,\n\t\tpostType,\n\t\tpreviewLink,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisCollaborationEnabledForCurrentPost,\n\t\t\tisPostLocked,\n\t\t\tisPostLockTakeover,\n\t\t\tgetPostLockUser,\n\t\t\tgetCurrentPostId,\n\t\t\tgetActivePostLock,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisCollaborationEnabled: isCollaborationEnabledForCurrentPost(),\n\t\t\tisLocked: isPostLocked(),\n\t\t\tisTakeover: isPostLockTakeover(),\n\t\t\tuser: getPostLockUser(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostLockUtils: getEditorSettings().postLockUtils,\n\t\t\tactivePostLock: getActivePostLock(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tpreviewLink: getEditedPostPreviewLink(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Keep the lock refreshed.\n\t\t *\n\t\t * When the user does not send a heartbeat in a heartbeat-tick\n\t\t * the user is no longer editing and another user can start editing.\n\t\t *\n\t\t * @param {Object} data Data to send in the heartbeat request.\n\t\t */\n\t\tfunction sendPostLock( data ) {\n\t\t\tif ( isLocked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdata[ 'wp-refresh-post-lock' ] = {\n\t\t\t\tlock: activePostLock,\n\t\t\t\tpost_id: postId,\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.\n\t\t *\n\t\t * @param {Object} data Data received in the heartbeat request\n\t\t */\n\t\tfunction receivePostLock( data ) {\n\t\t\tif ( ! data[ 'wp-refresh-post-lock' ] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst received = data[ 'wp-refresh-post-lock' ];\n\t\t\tif ( received.lock_error ) {\n\t\t\t\t// Auto save and display the takeover modal.\n\t\t\t\tautosave();\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: true,\n\t\t\t\t\tisTakeover: true,\n\t\t\t\t\tuser: {\n\t\t\t\t\t\tname: received.lock_error.name,\n\t\t\t\t\t\tavatar: received.lock_error.avatar_src_2x,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else if ( received.new_lock ) {\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tactivePostLock: received.new_lock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Unlock the post before the window is exited.\n\t\t */\n\t\tfunction releasePostLock() {\n\t\t\tif ( isLocked || ! activePostLock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst data = new window.FormData();\n\t\t\tdata.append( 'action', 'wp-remove-post-lock' );\n\t\t\tdata.append( '_wpnonce', postLockUtils.unlockNonce );\n\t\t\tdata.append( 'post_ID', postId );\n\t\t\tdata.append( 'active_post_lock', activePostLock );\n\n\t\t\tif ( window.navigator.sendBeacon ) {\n\t\t\t\twindow.navigator.sendBeacon( postLockUtils.ajaxUrl, data );\n\t\t\t} else {\n\t\t\t\tconst xhr = new window.XMLHttpRequest();\n\t\t\t\txhr.open( 'POST', postLockUtils.ajaxUrl, false );\n\t\t\t\txhr.send( data );\n\t\t\t}\n\t\t}\n\n\t\t// Details on these events on the Heartbeat API docs\n\t\t// https://developer.wordpress.org/plugins/javascript/heartbeat-api/\n\t\taddAction( 'heartbeat.send', hookName, sendPostLock );\n\t\taddAction( 'heartbeat.tick', hookName, receivePostLock );\n\t\twindow.addEventListener( 'beforeunload', releasePostLock );\n\n\t\treturn () => {\n\t\t\tremoveAction( 'heartbeat.send', hookName );\n\t\t\tremoveAction( 'heartbeat.tick', hookName );\n\t\t\twindow.removeEventListener( 'beforeunload', releasePostLock );\n\t\t};\n\t}, [] );\n\n\tif ( ! isLocked ) {\n\t\treturn null;\n\t}\n\n\t// Avoid sending the modal if sync is supported, but retain functionality around locks etc.\n\tif ( isCollaborationEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst userDisplayName = user.name;\n\tconst userAvatar = user.avatar;\n\n\tconst unlockUrl = addQueryArgs( 'post.php', {\n\t\t'get-post-lock': '1',\n\t\tlockKey: true,\n\t\tpost: postId,\n\t\taction: 'edit',\n\t\t_wpnonce: postLockUtils.nonce,\n\t} );\n\tconst allPostsUrl = addQueryArgs( 'edit.php', {\n\t\tpost_type: postType?.slug,\n\t} );\n\tconst allPostsLabel = __( 'Exit editor' );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tisTakeover\n\t\t\t\t\t? __( 'Someone else has taken over this post' )\n\t\t\t\t\t: __( 'This post is already being edited' )\n\t\t\t}\n\t\t\tfocusOnMount\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tisDismissible={ false }\n\t\t\t// Do not remove this class, as this class is used by third party plugins.\n\t\t\tclassName=\"editor-post-locked-modal\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<HStack alignment=\"top\" spacing={ 6 }>\n\t\t\t\t{ !! userAvatar && (\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\t\talt={ __( 'Avatar' ) }\n\t\t\t\t\t\tclassName=\"editor-post-locked-modal__avatar\"\n\t\t\t\t\t\twidth={ 64 }\n\t\t\t\t\t\theight={ 64 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<div>\n\t\t\t\t\t{ !! isTakeover && (\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'If you take over, the other user will lose editing control to the post, but their changes will be saved.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tclassName=\"editor-post-locked-modal__buttons\"\n\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\thref={ unlockUrl }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Take over' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\thref={ allPostsUrl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</div>\n\t\t\t</HStack>\n\t\t</Modal>\n\t);\n}\n\n/**\n * A modal component that is displayed when a post is locked for editing by another user.\n * The modal provides information about the lock status and options to take over or exit the editor.\n *\n * @return {React.ReactNode} The rendered PostLockedModal component.\n */\nexport default globalThis.IS_GUTENBERG_PLUGIN\n\t? withFilters( 'editor.PostLockedModal' )( PostLockedModal )\n\t: PostLockedModal;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,wBAMO;AACP,kBAAuC;AACvC,iBAA6B;AAC7B,qBAAoD;AACpD,mBAAwC;AACxC,qBAA8B;AAC9B,uBAAmC;AAKnC,mBAAqC;AAwKhC;AAtKL,SAAS,kBAAkB;AAC1B,QAAM,iBAAa,8BAAe,eAAgB;AAClD,QAAM,WAAW,mCAAmC;AACpD,QAAM,EAAE,UAAU,eAAe,QAAI,yBAAa,aAAAA,KAAY;AAC9D,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,uBAAW,CAAE,WAAY;AAC5B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,IAAI,OAAQ,aAAAA,KAAY;AACxB,UAAM,EAAE,YAAY,IAAI,OAAQ,iBAAAC,KAAU;AAC1C,WAAO;AAAA,MACN,wBAAwB,qCAAqC;AAAA,MAC7D,UAAU,aAAa;AAAA,MACvB,YAAY,mBAAmB;AAAA,MAC/B,MAAM,gBAAgB;AAAA,MACtB,QAAQ,iBAAiB;AAAA,MACzB,eAAe,kBAAkB,EAAE;AAAA,MACnC,gBAAgB,kBAAkB;AAAA,MAClC,UAAU,YAAa,uBAAwB,MAAO,CAAE;AAAA,MACxD,aAAa,yBAAyB;AAAA,IACvC;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,gCAAW,MAAM;AAShB,aAAS,aAAc,MAAO;AAC7B,UAAK,UAAW;AACf;AAAA,MACD;AAEA,WAAM,sBAAuB,IAAI;AAA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,cACA,QACA;AAAA,gBACA;AAAA,cACA;AAAA,cACH;AAAA,gBACC,QAAQ,4CAAC,YAAO;AAAA,gBAChB,aACC,4CAAC,kCAAa,MAAO,aAClB,8BAAI,SAAU,GACjB;AAAA,cAEF;AAAA,YACD,GACD;AAAA,YACA,4CAAC,OACE;AAAA,cACD;AAAA,YACD,GACD;AAAA,aACD;AAAA,UAGD;AAAA,YAAC,kBAAAA;AAAA,YAAA;AAAA,cACA,WAAU;AAAA,cACV,SAAQ;AAAA,cAEN;AAAA,iBAAE,cACH;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,MAAO;AAAA,oBAEL,8BAAI,WAAY;AAAA;AAAA,gBACnB;AAAA,gBAED;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,MAAO;AAAA,oBAEL;AAAA;AAAA,gBACH;AAAA;AAAA;AAAA,UACD;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;AAQA,IAAO,4BAAQ,WAAW,0BACvB,+BAAa,wBAAyB,EAAG,eAAgB,IACzD;",
6
- "names": ["editorStore", "coreStore", "HStack"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tModal,\n\tButton,\n\tExternalLink,\n\t__experimentalHStack as HStack,\n\twithFilters,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useEffect, createInterpolateElement } from '@wordpress/element';\nimport { addAction, removeAction } from '@wordpress/hooks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { unlock } from '../../lock-unlock';\nimport { DOCUMENT_SIZE_LIMIT_EXCEEDED } from '../../utils/sync-error-messages';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction CollaborationContext() {\n\tconst { isCollaborationSupported, syncConnectionStatus } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisCollaborationSupported: isSupported,\n\t\t\t\tgetSyncConnectionStatus,\n\t\t\t} = unlock( select( coreStore ) );\n\t\t\treturn {\n\t\t\t\tisCollaborationSupported: isSupported(),\n\t\t\t\tsyncConnectionStatus: getSyncConnectionStatus(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tif ( isCollaborationSupported ) {\n\t\treturn null;\n\t}\n\n\tif ( DOCUMENT_SIZE_LIMIT_EXCEEDED === syncConnectionStatus?.error?.code ) {\n\t\treturn (\n\t\t\t<p>\n\t\t\t\t{ __(\n\t\t\t\t\t'Because this post is too large for real-time collaboration, only one person can edit at a time.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t);\n\t}\n\n\treturn (\n\t\t<p>\n\t\t\t{ __(\n\t\t\t\t'Because this post uses plugins that aren\u2019t compatible with real-time collaboration, only one person can edit at a time.'\n\t\t\t) }\n\t\t</p>\n\t);\n}\n\nfunction PostLockedModal() {\n\tconst instanceId = useInstanceId( PostLockedModal );\n\tconst hookName = 'core/editor/post-locked-modal-' + instanceId;\n\tconst { autosave, updatePostLock } = useDispatch( editorStore );\n\tconst {\n\t\tisCollaborationEnabled,\n\t\tisLocked,\n\t\tisTakeover,\n\t\tuser,\n\t\tpostId,\n\t\tpostLockUtils,\n\t\tactivePostLock,\n\t\tpostType,\n\t\tpreviewLink,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPostLocked,\n\t\t\tisPostLockTakeover,\n\t\t\tgetPostLockUser,\n\t\t\tgetCurrentPostId,\n\t\t\tgetActivePostLock,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostPreviewLink,\n\t\t\tgetEditorSettings,\n\t\t\tisCollaborationEnabledForCurrentPost,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisCollaborationEnabled: isCollaborationEnabledForCurrentPost(),\n\t\t\tisLocked: isPostLocked(),\n\t\t\tisTakeover: isPostLockTakeover(),\n\t\t\tuser: getPostLockUser(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tpostLockUtils: getEditorSettings().postLockUtils,\n\t\t\tactivePostLock: getActivePostLock(),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tpreviewLink: getEditedPostPreviewLink(),\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * Keep the lock refreshed.\n\t\t *\n\t\t * When the user does not send a heartbeat in a heartbeat-tick\n\t\t * the user is no longer editing and another user can start editing.\n\t\t *\n\t\t * @param {Object} data Data to send in the heartbeat request.\n\t\t */\n\t\tfunction sendPostLock( data ) {\n\t\t\tif ( isLocked ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdata[ 'wp-refresh-post-lock' ] = {\n\t\t\t\tlock: activePostLock,\n\t\t\t\tpost_id: postId,\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.\n\t\t *\n\t\t * @param {Object} data Data received in the heartbeat request\n\t\t */\n\t\tfunction receivePostLock( data ) {\n\t\t\tif ( ! data[ 'wp-refresh-post-lock' ] ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst received = data[ 'wp-refresh-post-lock' ];\n\t\t\tif ( received.lock_error ) {\n\t\t\t\t// Auto save and display the takeover modal.\n\t\t\t\tautosave();\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: true,\n\t\t\t\t\tisTakeover: true,\n\t\t\t\t\tuser: {\n\t\t\t\t\t\tname: received.lock_error.name,\n\t\t\t\t\t\tavatar: received.lock_error.avatar_src_2x,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t} else if ( received.new_lock ) {\n\t\t\t\tupdatePostLock( {\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tactivePostLock: received.new_lock,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Unlock the post before the window is exited.\n\t\t */\n\t\tfunction releasePostLock() {\n\t\t\tif ( isLocked || ! activePostLock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst data = new window.FormData();\n\t\t\tdata.append( 'action', 'wp-remove-post-lock' );\n\t\t\tdata.append( '_wpnonce', postLockUtils.unlockNonce );\n\t\t\tdata.append( 'post_ID', postId );\n\t\t\tdata.append( 'active_post_lock', activePostLock );\n\n\t\t\tif ( window.navigator.sendBeacon ) {\n\t\t\t\twindow.navigator.sendBeacon( postLockUtils.ajaxUrl, data );\n\t\t\t} else {\n\t\t\t\tconst xhr = new window.XMLHttpRequest();\n\t\t\t\txhr.open( 'POST', postLockUtils.ajaxUrl, false );\n\t\t\t\txhr.send( data );\n\t\t\t}\n\t\t}\n\n\t\t// Details on these events on the Heartbeat API docs\n\t\t// https://developer.wordpress.org/plugins/javascript/heartbeat-api/\n\t\taddAction( 'heartbeat.send', hookName, sendPostLock );\n\t\taddAction( 'heartbeat.tick', hookName, receivePostLock );\n\t\twindow.addEventListener( 'beforeunload', releasePostLock );\n\n\t\treturn () => {\n\t\t\tremoveAction( 'heartbeat.send', hookName );\n\t\t\tremoveAction( 'heartbeat.tick', hookName );\n\t\t\twindow.removeEventListener( 'beforeunload', releasePostLock );\n\t\t};\n\t}, [] );\n\n\tif ( ! isLocked ) {\n\t\treturn null;\n\t}\n\n\t// Avoid sending the modal if sync is supported, but retain functionality around locks etc.\n\tif ( isCollaborationEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst userDisplayName = user.name;\n\tconst userAvatar = user.avatar;\n\n\tconst unlockUrl = addQueryArgs( 'post.php', {\n\t\t'get-post-lock': '1',\n\t\tlockKey: true,\n\t\tpost: postId,\n\t\taction: 'edit',\n\t\t_wpnonce: postLockUtils.nonce,\n\t} );\n\tconst allPostsUrl = addQueryArgs( 'edit.php', {\n\t\tpost_type: postType?.slug,\n\t} );\n\tconst allPostsLabel = __( 'Exit editor' );\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tisTakeover\n\t\t\t\t\t? __( 'Someone else has taken over this post' )\n\t\t\t\t\t: __( 'This post is already being edited' )\n\t\t\t}\n\t\t\tfocusOnMount\n\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\tshouldCloseOnEsc={ false }\n\t\t\tisDismissible={ false }\n\t\t\t// Do not remove this class, as this class is used by third party plugins.\n\t\t\tclassName=\"editor-post-locked-modal\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<HStack alignment=\"top\" spacing={ 6 }>\n\t\t\t\t{ !! userAvatar && (\n\t\t\t\t\t<img\n\t\t\t\t\t\tsrc={ userAvatar }\n\t\t\t\t\t\talt={ __( 'Avatar' ) }\n\t\t\t\t\t\tclassName=\"editor-post-locked-modal__avatar\"\n\t\t\t\t\t\twidth={ 64 }\n\t\t\t\t\t\theight={ 64 }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<div>\n\t\t\t\t\t{ !! isTakeover && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Another user now has editing control of this post (<PreviewLink />). Don\u2019t worry, your changes up to this moment have been saved.'\n\t\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<CollaborationContext />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: user's display name */\n\t\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t\t'<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\t\tuserDisplayName\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'\n\t\t\t\t\t\t\t\t\t\t ),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tstrong: <strong />,\n\t\t\t\t\t\t\t\t\t\tPreviewLink: (\n\t\t\t\t\t\t\t\t\t\t\t<ExternalLink href={ previewLink }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'preview' ) }\n\t\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t<CollaborationContext />\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'If you take over, the other user will lose editing control to the post, but their changes will be saved.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tclassName=\"editor-post-locked-modal__buttons\"\n\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! isTakeover && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\thref={ unlockUrl }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Take over' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\thref={ allPostsUrl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ allPostsLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</HStack>\n\t\t\t\t</div>\n\t\t\t</HStack>\n\t\t</Modal>\n\t);\n}\n\n/**\n * A modal component that is displayed when a post is locked for editing by another user.\n * The modal provides information about the lock status and options to take over or exit the editor.\n *\n * @return {React.ReactNode} The rendered PostLockedModal component.\n */\nexport default globalThis.IS_GUTENBERG_PLUGIN\n\t? withFilters( 'editor.PostLockedModal' )( PostLockedModal )\n\t: PostLockedModal;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,wBAMO;AACP,kBAA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AA;AAAA,oBAEA;AAAA,kBACC;AAAA,gBACD;AAAA,gBACA;AAAA,cACA,QACA;AAAA,gBACA;AAAA,cACA;AAAA,cACH;AAAA,gBACC,QAAQ,4CAAC,YAAO;AAAA,gBAChB,aACC,4CAAC,kCAAa,MAAO,aAClB,8BAAI,SAAU,GACjB;AAAA,cAEF;AAAA,YACD,GACD;AAAA,YACA,4CAAC,wBAAqB;AAAA,aACvB;AAAA,UAEC,CAAE,cACH,4EACC;AAAA,wDAAC,OACE;AAAA,cACD,sBACG;AAAA;AAAA,oBAEA;AAAA,kBACC;AAAA,gBACD;AAAA,gBACA;AAAA,cACA,QACA;AAAA,gBACA;AAAA,cACA;AAAA,cACH;AAAA,gBACC,QAAQ,4CAAC,YAAO;AAAA,gBAChB,aACC,4CAAC,kCAAa,MAAO,aAClB,8BAAI,SAAU,GACjB;AAAA,cAEF;AAAA,YACD,GACD;AAAA,YACA,4CAAC,wBAAqB;AAAA,YACtB,4CAAC,OACE;AAAA,cACD;AAAA,YACD,GACD;AAAA,aACD;AAAA,UAGD;AAAA,YAAC,kBAAAA;AAAA,YAAA;AAAA,cACA,WAAU;AAAA,cACV,SAAQ;AAAA,cAEN;AAAA,iBAAE,cACH;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,MAAO;AAAA,oBAEL,8BAAI,WAAY;AAAA;AAAA,gBACnB;AAAA,gBAED;AAAA,kBAAC;AAAA;AAAA,oBACA,uBAAqB;AAAA,oBACrB,SAAQ;AAAA,oBACR,MAAO;AAAA,oBAEL;AAAA;AAAA,gBACH;AAAA;AAAA;AAAA,UACD;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;AAQA,IAAO,4BAAQ,WAAW,0BACvB,+BAAa,wBAAyB,EAAG,eAAgB,IACzD;",
6
+ "names": ["coreStore", "editorStore", "HStack"]
7
7
  }
@@ -31,6 +31,15 @@ var import_rich_text = require("@wordpress/rich-text");
31
31
  var import_i18n = require("@wordpress/i18n");
32
32
  var import_lock_unlock = require("../../lock-unlock.cjs");
33
33
  var { parseRawBlock } = (0, import_lock_unlock.unlock)(import_blocks.privateApis);
34
+ function stringifyValue(value) {
35
+ if (value === null || value === void 0) {
36
+ return "";
37
+ }
38
+ if (typeof value === "object") {
39
+ return JSON.stringify(value, null, 2);
40
+ }
41
+ return String(value);
42
+ }
34
43
  function textSimilarity(text1, text2) {
35
44
  if (!text1 && !text2) {
36
45
  return 1;
@@ -38,16 +47,39 @@ function textSimilarity(text1, text2) {
38
47
  if (!text1 || !text2) {
39
48
  return 0;
40
49
  }
41
- const changes = (0, import_word.diffWords)(text1, text2);
42
- const unchanged = changes.filter((c) => !c.added && !c.removed).reduce((sum, c) => sum + c.value.length, 0);
43
- const total = Math.max(text1.length, text2.length);
44
- return total > 0 ? unchanged / total : 0;
50
+ const segmenter = new Intl.Segmenter(void 0, {
51
+ granularity: "word"
52
+ });
53
+ const wordLikeRegex = /[\p{L}\p{N}]/u;
54
+ const getWords = (text) => {
55
+ const words = [];
56
+ for (const { segment, isWordLike } of segmenter.segment(text)) {
57
+ if (isWordLike || wordLikeRegex.test(segment)) {
58
+ words.push(segment);
59
+ }
60
+ }
61
+ return words;
62
+ };
63
+ const words1 = getWords(text1);
64
+ const words2 = getWords(text2);
65
+ if (words1.length === 0 && words2.length === 0) {
66
+ return 1;
67
+ }
68
+ const set1 = new Set(words1);
69
+ let intersection = 0;
70
+ for (const word of words2) {
71
+ if (set1.has(word)) {
72
+ intersection++;
73
+ }
74
+ }
75
+ const total = Math.max(words1.length, words2.length);
76
+ return total > 0 ? intersection / total : 0;
45
77
  }
46
78
  function pairSimilarBlocks(blocks) {
47
79
  const removed = [];
48
80
  const added = [];
49
81
  blocks.forEach((block, index) => {
50
- const status = block.__revisionDiffStatus;
82
+ const status = block.__revisionDiffStatus?.status;
51
83
  if (status === "removed") {
52
84
  removed.push({ block, index });
53
85
  } else if (status === "added") {
@@ -58,39 +90,84 @@ function pairSimilarBlocks(blocks) {
58
90
  return blocks;
59
91
  }
60
92
  const pairedRemoved = /* @__PURE__ */ new Set();
93
+ const pairedAdded = /* @__PURE__ */ new Set();
61
94
  const modifications = /* @__PURE__ */ new Map();
62
- const SIMILARITY_THRESHOLD = 0.3;
95
+ const SIMILARITY_THRESHOLD = 0.5;
96
+ const addedByName = /* @__PURE__ */ new Map();
97
+ for (const add of added) {
98
+ const name = add.block.blockName;
99
+ if (!addedByName.has(name)) {
100
+ addedByName.set(name, []);
101
+ }
102
+ addedByName.get(name).push(add);
103
+ }
104
+ const removedByName = /* @__PURE__ */ new Map();
63
105
  for (const rem of removed) {
106
+ const name = rem.block.blockName;
107
+ if (!removedByName.has(name)) {
108
+ removedByName.set(name, []);
109
+ }
110
+ removedByName.get(name).push(rem);
111
+ }
112
+ let maxPairedAddedIndex = -1;
113
+ for (const rem of removed) {
114
+ const candidates = addedByName.get(rem.block.blockName) || [];
115
+ const sameNameRemoved = removedByName.get(rem.block.blockName) || [];
116
+ const unpaired = candidates.filter(
117
+ (add) => !modifications.has(add.index) && add.index > maxPairedAddedIndex
118
+ );
119
+ if (unpaired.length === 0) {
120
+ continue;
121
+ }
64
122
  let bestMatch = null;
65
- let bestScore = 0;
66
- for (const add of added) {
67
- if (modifications.has(add.index)) {
68
- continue;
69
- }
70
- if (add.block.blockName !== rem.block.blockName) {
71
- continue;
72
- }
73
- const score = textSimilarity(
74
- rem.block.innerHTML || "",
75
- add.block.innerHTML || ""
76
- );
123
+ if (sameNameRemoved.length === 1 && unpaired.length === 1) {
124
+ const add = unpaired[0];
77
125
  const attrsMatch = JSON.stringify(rem.block.attrs) === JSON.stringify(add.block.attrs);
78
- if (score > bestScore && score > SIMILARITY_THRESHOLD && (score < 1 || !attrsMatch)) {
79
- bestScore = score;
126
+ const contentMatch = (rem.block.innerHTML || "") === (add.block.innerHTML || "");
127
+ if (!contentMatch || !attrsMatch) {
80
128
  bestMatch = add;
81
129
  }
130
+ } else {
131
+ let bestScore = 0;
132
+ for (const add of unpaired) {
133
+ const score = textSimilarity(
134
+ rem.block.innerHTML || "",
135
+ add.block.innerHTML || ""
136
+ );
137
+ const attrsMatch = JSON.stringify(rem.block.attrs) === JSON.stringify(add.block.attrs);
138
+ if (score > bestScore && score > SIMILARITY_THRESHOLD && (score < 1 || !attrsMatch)) {
139
+ bestScore = score;
140
+ bestMatch = add;
141
+ }
142
+ }
82
143
  }
83
144
  if (bestMatch) {
84
- pairedRemoved.add(rem.index);
85
- modifications.set(bestMatch.index, {
145
+ maxPairedAddedIndex = bestMatch.index;
146
+ const modifiedBlock = {
86
147
  ...bestMatch.block,
87
- __revisionDiffStatus: "modified",
148
+ __revisionDiffStatus: { status: "modified" },
88
149
  __previousRawBlock: rem.block
89
- });
150
+ };
151
+ const lo = Math.min(rem.index, bestMatch.index);
152
+ const hi = Math.max(rem.index, bestMatch.index);
153
+ let hasAddedBetween = false;
154
+ for (let i = lo + 1; i < hi; i++) {
155
+ if (blocks[i].__revisionDiffStatus?.status === "added" && !pairedAdded.has(i)) {
156
+ hasAddedBetween = true;
157
+ break;
158
+ }
159
+ }
160
+ if (hasAddedBetween) {
161
+ modifications.set(bestMatch.index, modifiedBlock);
162
+ pairedRemoved.add(rem.index);
163
+ } else {
164
+ modifications.set(rem.index, modifiedBlock);
165
+ pairedAdded.add(bestMatch.index);
166
+ }
90
167
  }
91
168
  }
92
169
  return blocks.map((block, index) => {
93
- if (pairedRemoved.has(index)) {
170
+ if (pairedRemoved.has(index) || pairedAdded.has(index)) {
94
171
  return null;
95
172
  }
96
173
  if (modifications.has(index)) {
@@ -120,14 +197,14 @@ function diffRawBlocks(currentRaw, previousRaw) {
120
197
  for (let i = 0; i < part.count; i++) {
121
198
  result.push({
122
199
  ...currentRaw[currIdx++],
123
- __revisionDiffStatus: "added"
200
+ __revisionDiffStatus: { status: "added" }
124
201
  });
125
202
  }
126
203
  } else if (part.removed) {
127
204
  for (let i = 0; i < part.count; i++) {
128
205
  result.push({
129
206
  ...previousRaw[prevIdx++],
130
- __revisionDiffStatus: "removed"
207
+ __revisionDiffStatus: { status: "removed" }
131
208
  });
132
209
  }
133
210
  } else {
@@ -333,11 +410,12 @@ function applyRichTextDiff(currentRichText, previousRichText) {
333
410
  }
334
411
  return new import_rich_text.RichTextData(result);
335
412
  }
336
- function applyRichTextDiffToBlock(currentBlock, previousBlock) {
413
+ function applyDiffToBlock(currentBlock, previousBlock, diffStatus) {
337
414
  const blockType = (0, import_blocks.getBlockType)(currentBlock.name);
338
415
  if (!blockType) {
339
416
  return;
340
417
  }
418
+ const changedAttributes = {};
341
419
  for (const [attrName, attrDef] of Object.entries(
342
420
  blockType.attributes
343
421
  )) {
@@ -350,18 +428,36 @@ function applyRichTextDiffToBlock(currentBlock, previousBlock) {
350
428
  previousRichText
351
429
  );
352
430
  }
431
+ } else {
432
+ const currStr = stringifyValue(
433
+ currentBlock.attributes[attrName]
434
+ );
435
+ const prevStr = stringifyValue(
436
+ previousBlock.attributes[attrName]
437
+ );
438
+ if (currStr !== prevStr) {
439
+ changedAttributes[attrName] = (0, import_word.diffWords)(prevStr, currStr);
440
+ }
353
441
  }
354
442
  }
443
+ if (Object.keys(changedAttributes).length > 0) {
444
+ diffStatus.changedAttributes = changedAttributes;
445
+ }
355
446
  }
356
447
  function applyDiffRecursively(parsedBlock, rawBlock) {
357
448
  if (rawBlock.__revisionDiffStatus) {
358
- parsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;
359
- }
360
- if (rawBlock.__revisionDiffStatus === "modified" && rawBlock.__previousRawBlock) {
361
- const previousParsed = parseRawBlock(rawBlock.__previousRawBlock);
362
- if (previousParsed) {
363
- applyRichTextDiffToBlock(parsedBlock, previousParsed);
449
+ if (rawBlock.__revisionDiffStatus.status === "modified" && rawBlock.__previousRawBlock) {
450
+ const previousParsed = parseRawBlock(rawBlock.__previousRawBlock);
451
+ if (previousParsed) {
452
+ applyDiffToBlock(
453
+ parsedBlock,
454
+ previousParsed,
455
+ rawBlock.__revisionDiffStatus
456
+ );
457
+ }
364
458
  }
459
+ parsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;
460
+ parsedBlock.attributes.__revisionDiffStatus = rawBlock.__revisionDiffStatus;
365
461
  }
366
462
  if (parsedBlock.innerBlocks && rawBlock.innerBlocks) {
367
463
  for (let i = 0; i < parsedBlock.innerBlocks.length; i++) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-revisions-preview/block-diff.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { diffArrays } from 'diff/lib/diff/array';\nimport { diffWords } from 'diff/lib/diff/word';\n\n/**\n * WordPress dependencies\n */\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\nimport {\n\tprivateApis as blocksPrivateApis,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport {\n\tRichTextData,\n\tcreate,\n\tslice,\n\tconcat,\n\tapplyFormat,\n} from '@wordpress/rich-text';\nimport { __, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { parseRawBlock } = unlock( blocksPrivateApis );\n\n/**\n * Calculate text similarity using word diff (semantically meaningful).\n * Returns ratio of unchanged words to total words.\n *\n * @param {string} text1 First text to compare.\n * @param {string} text2 Second text to compare.\n * @return {number} Similarity score between 0 and 1.\n */\nfunction textSimilarity( text1, text2 ) {\n\tif ( ! text1 && ! text2 ) {\n\t\treturn 1;\n\t}\n\tif ( ! text1 || ! text2 ) {\n\t\treturn 0;\n\t}\n\n\tconst changes = diffWords( text1, text2 );\n\tconst unchanged = changes\n\t\t.filter( ( c ) => ! c.added && ! c.removed )\n\t\t.reduce( ( sum, c ) => sum + c.value.length, 0 );\n\tconst total = Math.max( text1.length, text2.length );\n\treturn total > 0 ? unchanged / total : 0;\n}\n\n/**\n * Post-process diff result to pair similar removed/added blocks as modifications.\n * This catches modifications that LCS missed due to content changes.\n *\n * @param {Array} blocks Raw blocks with diff status.\n * @return {Array} Blocks with similar pairs converted to modifications.\n */\nfunction pairSimilarBlocks( blocks ) {\n\tconst removed = [];\n\tconst added = [];\n\n\t// Separate blocks by status, tracking original indices.\n\tblocks.forEach( ( block, index ) => {\n\t\tconst status = block.__revisionDiffStatus;\n\t\tif ( status === 'removed' ) {\n\t\t\tremoved.push( { block, index } );\n\t\t} else if ( status === 'added' ) {\n\t\t\tadded.push( { block, index } );\n\t\t}\n\t} );\n\n\t// If no removed or no added, nothing to pair.\n\tif ( removed.length === 0 || added.length === 0 ) {\n\t\treturn blocks;\n\t}\n\n\tconst pairedRemoved = new Set(); // Indices of removed blocks that were paired.\n\tconst modifications = new Map(); // Map from added block index to modified block.\n\tconst SIMILARITY_THRESHOLD = 0.3;\n\n\t// For each removed block, find best matching added block.\n\tfor ( const rem of removed ) {\n\t\tlet bestMatch = null;\n\t\tlet bestScore = 0;\n\n\t\tfor ( const add of added ) {\n\t\t\tif ( modifications.has( add.index ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ( add.block.blockName !== rem.block.blockName ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst score = textSimilarity(\n\t\t\t\trem.block.innerHTML || '',\n\t\t\t\tadd.block.innerHTML || ''\n\t\t\t);\n\t\t\t// If content is identical (score=1), only pair if attrs differ.\n\t\t\t// Otherwise identical blocks are just position swaps, not modifications.\n\t\t\tconst attrsMatch =\n\t\t\t\tJSON.stringify( rem.block.attrs ) ===\n\t\t\t\tJSON.stringify( add.block.attrs );\n\t\t\tif (\n\t\t\t\tscore > bestScore &&\n\t\t\t\tscore > SIMILARITY_THRESHOLD &&\n\t\t\t\t( score < 1 || ! attrsMatch )\n\t\t\t) {\n\t\t\t\tbestScore = score;\n\t\t\t\tbestMatch = add;\n\t\t\t}\n\t\t}\n\n\t\tif ( bestMatch ) {\n\t\t\tpairedRemoved.add( rem.index );\n\n\t\t\t// Create modified block with previous content stored.\n\t\t\tmodifications.set( bestMatch.index, {\n\t\t\t\t...bestMatch.block,\n\t\t\t\t__revisionDiffStatus: 'modified',\n\t\t\t\t__previousRawBlock: rem.block,\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Rebuild result: filter out paired removed, replace paired added with modified.\n\treturn blocks\n\t\t.map( ( block, index ) => {\n\t\t\t// Skip paired removed blocks.\n\t\t\tif ( pairedRemoved.has( index ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Replace paired added blocks with modified version.\n\t\t\tif ( modifications.has( index ) ) {\n\t\t\t\treturn modifications.get( index );\n\t\t\t}\n\t\t\treturn block;\n\t\t} )\n\t\t.filter( Boolean );\n}\n\n/**\n * Diff raw block arrays using LCS, recursively handling innerBlocks.\n * Detects modifications when exactly 1 block is removed and 1 is added\n * with the same blockName (1:1 replacement = modification).\n *\n * @param {Array} currentRaw Current revision's raw blocks.\n * @param {Array} previousRaw Previous revision's raw blocks.\n * @return {Array} Merged raw blocks with diff status injected.\n */\nfunction diffRawBlocks( currentRaw, previousRaw ) {\n\tconst createBlockSignature = ( rawBlock ) =>\n\t\tJSON.stringify( {\n\t\t\tname: rawBlock.blockName,\n\t\t\tattrs: rawBlock.attrs,\n\t\t\t// Use innerContent filtered to non-null and non-whitespace-only strings.\n\t\t\t// This excludes whitespace between inner blocks which changes based on count.\n\t\t\thtml: ( rawBlock.innerContent || [] ).filter(\n\t\t\t\t( c ) => c !== null && c.trim() !== ''\n\t\t\t),\n\t\t} );\n\tconst currentSigs = currentRaw.map( createBlockSignature );\n\tconst previousSigs = previousRaw.map( createBlockSignature );\n\n\tconst diff = diffArrays( previousSigs, currentSigs );\n\n\tconst result = [];\n\tlet currIdx = 0;\n\tlet prevIdx = 0;\n\n\tfor ( const part of diff ) {\n\t\tif ( part.added ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currentRaw[ currIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: 'added',\n\t\t\t\t} );\n\t\t\t}\n\t\t} else if ( part.removed ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...previousRaw[ prevIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: 'removed',\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Matched blocks - recursively diff their innerBlocks.\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tconst currBlock = currentRaw[ currIdx++ ];\n\t\t\t\tconst prevBlock = previousRaw[ prevIdx++ ];\n\n\t\t\t\t// Recursively diff inner blocks.\n\t\t\t\tconst diffedInnerBlocks = diffRawBlocks(\n\t\t\t\t\tcurrBlock.innerBlocks || [],\n\t\t\t\t\tprevBlock.innerBlocks || []\n\t\t\t\t);\n\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currBlock,\n\t\t\t\t\tinnerBlocks: diffedInnerBlocks,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Post-process to pair similar removed/added blocks as modifications.\n\treturn pairSimilarBlocks( result );\n}\n\n/**\n * Check if formatting has changed at specific character indices.\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currentIndex Character index in current.\n * @param {number} previousIndex Character index in previous.\n * @return {boolean} True if formatting changed at these indices.\n */\nfunction hasFormatChangedAtIndex(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrentIndex,\n\tpreviousIndex\n) {\n\tconst currFmts = currentFormats[ currentIndex ] || [];\n\tconst prevFmts = previousFormats[ previousIndex ] || [];\n\n\tif ( currFmts.length !== prevFmts.length ) {\n\t\treturn true;\n\t}\n\n\t// Check if each format in current exists in previous\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find(\n\t\t\t( pf ) =>\n\t\t\t\tpf.type === fmt.type &&\n\t\t\t\tJSON.stringify( pf.attributes ) ===\n\t\t\t\t\tJSON.stringify( fmt.attributes )\n\t\t);\n\t\tif ( ! match ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Analyze what formatting changed between two character positions.\n * Returns both the change type (for styling) and a description (for tooltip).\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currIdx Character index in current.\n * @param {number} prevIdx Character index in previous.\n * @return {{ type: 'added'|'removed'|'changed', description: string }} Change info.\n */\nfunction describeFormatChange(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrIdx,\n\tprevIdx\n) {\n\tconst currFmts = currentFormats[ currIdx ] || [];\n\tconst prevFmts = previousFormats[ prevIdx ] || [];\n\n\tlet addedCount = 0;\n\tlet removedCount = 0;\n\tlet changedCount = 0;\n\n\t// Find added formats and attribute changes\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find( ( pf ) => pf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\taddedCount++;\n\t\t} else if (\n\t\t\tJSON.stringify( fmt.attributes ) !==\n\t\t\tJSON.stringify( match.attributes )\n\t\t) {\n\t\t\tchangedCount++;\n\t\t}\n\t}\n\n\t// Find removed formats\n\tfor ( const fmt of prevFmts ) {\n\t\tconst match = currFmts.find( ( cf ) => cf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\tremovedCount++;\n\t\t}\n\t}\n\n\t// Determine primary change type for styling\n\tif ( addedCount > 0 && removedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'added',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t),\n\t\t};\n\t}\n\tif ( removedCount > 0 && addedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'removed',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t),\n\t\t};\n\t}\n\n\t// Mixed or attribute-only changes\n\tconst parts = [];\n\tif ( addedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( removedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( changedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats changed */\n\t\t\t\t_n( '%d format changed', '%d formats changed', changedCount ),\n\t\t\t\tchangedCount\n\t\t\t)\n\t\t);\n\t}\n\treturn {\n\t\ttype: 'changed',\n\t\tdescription: parts.join( ', ' ) || __( 'Formatting changed' ),\n\t};\n}\n\n/**\n * Apply inline diff formatting comparing two RichTextData values.\n * - Text changes: apply revision/diff-removed and revision/diff-added formats\n * - Format-only changes (text unchanged): apply revision/diff-format-changed format\n *\n * @param {RichTextData} currentRichText Current revision's rich text.\n * @param {RichTextData} previousRichText Previous revision's rich text.\n * @return {RichTextData} New rich text with diff formatting applied.\n */\nfunction applyRichTextDiff( currentRichText, previousRichText ) {\n\tconst currentText = currentRichText.toPlainText();\n\tconst previousText = previousRichText.toPlainText();\n\n\t// Diff the plain text (words for cleaner output)\n\tconst textDiff = diffWords( previousText, currentText );\n\n\tlet result = create( { text: '' } );\n\tlet currentIdx = 0;\n\tlet previousIdx = 0;\n\n\tfor ( const part of textDiff ) {\n\t\tif ( part.removed ) {\n\t\t\t// Text deleted - slice from PREVIOUS, apply <del>\n\t\t\tconst removedSlice = slice(\n\t\t\t\tpreviousRichText,\n\t\t\t\tpreviousIdx,\n\t\t\t\tpreviousIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\tremovedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-removed',\n\t\t\t\t\tattributes: { title: __( 'Removed' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tpreviousIdx += part.value.length;\n\t\t} else if ( part.added ) {\n\t\t\t// Text added - slice from CURRENT, apply <ins>\n\t\t\tconst addedSlice = slice(\n\t\t\t\tcurrentRichText,\n\t\t\t\tcurrentIdx,\n\t\t\t\tcurrentIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\taddedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-added',\n\t\t\t\t\tattributes: { title: __( 'Added' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tcurrentIdx += part.value.length;\n\t\t} else {\n\t\t\t// Text unchanged - check formatting at each character position.\n\t\t\t// Only apply <mark> to specific ranges where formatting differs.\n\t\t\tconst currentFormats = currentRichText.formats || [];\n\t\t\tconst previousFormats = previousRichText.formats || [];\n\t\t\tconst len = part.value.length;\n\n\t\t\t// Helper to check format change at offset within this unchanged part.\n\t\t\tconst checkFormatChanged = ( offset ) =>\n\t\t\t\thasFormatChangedAtIndex(\n\t\t\t\t\tcurrentFormats,\n\t\t\t\t\tpreviousFormats,\n\t\t\t\t\tcurrentIdx + offset,\n\t\t\t\t\tpreviousIdx + offset\n\t\t\t\t);\n\n\t\t\t// Find ranges of characters grouped by whether format changed.\n\t\t\tlet rangeStart = 0;\n\t\t\tlet rangeFormatChanged = checkFormatChanged( 0 );\n\n\t\t\tfor ( let i = 1; i <= len; i++ ) {\n\t\t\t\tconst formatChanged = i < len && checkFormatChanged( i );\n\n\t\t\t\t// When format-changed status changes or we reach the end, emit range.\n\t\t\t\tif ( i === len || formatChanged !== rangeFormatChanged ) {\n\t\t\t\t\tconst rangeSlice = slice(\n\t\t\t\t\t\tcurrentRichText,\n\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\tcurrentIdx + i\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( rangeFormatChanged ) {\n\t\t\t\t\t\t// Get type and description of what changed\n\t\t\t\t\t\tconst { type, description } = describeFormatChange(\n\t\t\t\t\t\t\tcurrentFormats,\n\t\t\t\t\t\t\tpreviousFormats,\n\t\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\t\tpreviousIdx + rangeStart\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Map change type to format type for styling\n\t\t\t\t\t\tconst formatType = {\n\t\t\t\t\t\t\tadded: 'revision/diff-format-added',\n\t\t\t\t\t\t\tremoved: 'revision/diff-format-removed',\n\t\t\t\t\t\t\tchanged: 'revision/diff-format-changed',\n\t\t\t\t\t\t}[ type ];\n\n\t\t\t\t\t\tconst marked = applyFormat(\n\t\t\t\t\t\t\trangeSlice,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: formatType,\n\t\t\t\t\t\t\t\tattributes: { title: description },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\ti - rangeStart\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult = concat( result, marked );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = concat( result, rangeSlice );\n\t\t\t\t\t}\n\n\t\t\t\t\trangeStart = i;\n\t\t\t\t\trangeFormatChanged = formatChanged;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcurrentIdx += part.value.length;\n\t\t\tpreviousIdx += part.value.length;\n\t\t}\n\t}\n\n\treturn new RichTextData( result );\n}\n\n/**\n * Apply rich text diff to all rich-text attributes of a block.\n * Compares each rich-text attribute between current and previous parsed blocks.\n *\n * @param {Object} currentBlock Current parsed block.\n * @param {Object} previousBlock Previous parsed block.\n */\nfunction applyRichTextDiffToBlock( currentBlock, previousBlock ) {\n\tconst blockType = getBlockType( currentBlock.name );\n\tif ( ! blockType ) {\n\t\treturn;\n\t}\n\n\t// Find rich-text attributes and compare\n\tfor ( const [ attrName, attrDef ] of Object.entries(\n\t\tblockType.attributes\n\t) ) {\n\t\tif ( attrDef.source === 'rich-text' ) {\n\t\t\tconst currentRichText = currentBlock.attributes[ attrName ];\n\t\t\tconst previousRichText = previousBlock.attributes[ attrName ];\n\n\t\t\tif (\n\t\t\t\tcurrentRichText instanceof RichTextData &&\n\t\t\t\tpreviousRichText instanceof RichTextData\n\t\t\t) {\n\t\t\t\tcurrentBlock.attributes[ attrName ] = applyRichTextDiff(\n\t\t\t\t\tcurrentRichText,\n\t\t\t\t\tpreviousRichText\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Recursively apply diff status and rich text diff to blocks in the tree.\n * Copies __revisionDiffStatus from raw blocks to parsed blocks and applies\n * rich text diffs to modified blocks.\n *\n * @param {Object} parsedBlock Parsed block (with inner blocks).\n * @param {Object} rawBlock Raw block (with __revisionDiffStatus and __previousRawBlock).\n */\nfunction applyDiffRecursively( parsedBlock, rawBlock ) {\n\t// Copy diff status from raw block to parsed block.\n\tif ( rawBlock.__revisionDiffStatus ) {\n\t\tparsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;\n\t}\n\n\t// Apply rich text diff if this block is modified and has a previous raw block.\n\tif (\n\t\trawBlock.__revisionDiffStatus === 'modified' &&\n\t\trawBlock.__previousRawBlock\n\t) {\n\t\tconst previousParsed = parseRawBlock( rawBlock.__previousRawBlock );\n\t\tif ( previousParsed ) {\n\t\t\tapplyRichTextDiffToBlock( parsedBlock, previousParsed );\n\t\t}\n\t}\n\n\t// Recursively process inner blocks.\n\tif ( parsedBlock.innerBlocks && rawBlock.innerBlocks ) {\n\t\tfor ( let i = 0; i < parsedBlock.innerBlocks.length; i++ ) {\n\t\t\tconst parsedInner = parsedBlock.innerBlocks[ i ];\n\t\t\tconst rawInner = rawBlock.innerBlocks[ i ];\n\t\t\tif ( parsedInner && rawInner ) {\n\t\t\t\tapplyDiffRecursively( parsedInner, rawInner );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Diff two revision contents at the grammar level.\n *\n * @param {string} currentContent Current revision's raw content.\n * @param {string} previousContent Previous revision's raw content.\n * @return {Array} Array of parsed blocks with diff status attributes.\n */\nexport function diffRevisionContent( currentContent, previousContent ) {\n\t// Grammar parse both contents.\n\tconst currentRaw = grammarParse( currentContent || '' );\n\tconst previousRaw = grammarParse( previousContent || '' );\n\n\t// Diff the raw block arrays.\n\tconst mergedRaw = diffRawBlocks( currentRaw, previousRaw );\n\n\t// Parse each raw block and apply diff status.\n\treturn mergedRaw\n\t\t.map( ( rawBlock ) => {\n\t\t\tconst parsed = parseRawBlock( rawBlock );\n\t\t\tif ( parsed ) {\n\t\t\t\tapplyDiffRecursively( parsed, rawBlock );\n\t\t\t}\n\t\t\treturn parsed;\n\t\t} )\n\t\t.filter( Boolean );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA2B;AAC3B,kBAA0B;AAK1B,gDAAsC;AACtC,oBAGO;AACP,uBAMO;AACP,kBAAgC;AAKhC,yBAAuB;AAEvB,IAAM,EAAE,cAAc,QAAI,2BAAQ,cAAAA,WAAkB;AAUpD,SAAS,eAAgB,OAAO,OAAQ;AACvC,MAAK,CAAE,SAAS,CAAE,OAAQ;AACzB,WAAO;AAAA,EACR;AACA,MAAK,CAAE,SAAS,CAAE,OAAQ;AACzB,WAAO;AAAA,EACR;AAEA,QAAM,cAAU,uBAAW,OAAO,KAAM;AACxC,QAAM,YAAY,QAChB,OAAQ,CAAE,MAAO,CAAE,EAAE,SAAS,CAAE,EAAE,OAAQ,EAC1C,OAAQ,CAAE,KAAK,MAAO,MAAM,EAAE,MAAM,QAAQ,CAAE;AAChD,QAAM,QAAQ,KAAK,IAAK,MAAM,QA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YAAY,YAAa,CAAE;AAC/C,YAAM,WAAW,SAAS,YAAa,CAAE;AACzC,UAAK,eAAe,UAAW;AAC9B,6BAAsB,aAAa,QAAS;AAAA,MAC7C;AAAA,IACD;AAAA,EACD;AACD;AASO,SAAS,oBAAqB,gBAAgB,iBAAkB;AAEtE,QAAM,iBAAa,0CAAAC,OAAc,kBAAkB,EAAG;AACtD,QAAM,kBAAc,0CAAAA,OAAc,mBAAmB,EAAG;AAGxD,QAAM,YAAY,cAAe,YAAY,WAAY;AAGzD,SAAO,UACL,IAAK,CAAE,aAAc;AACrB,UAAM,SAAS,cAAe,QAAS;AACvC,QAAK,QAAS;AACb,2BAAsB,QAAQ,QAAS;AAAA,IACxC;AACA,WAAO;AAAA,EACR,CAAE,EACD,OAAQ,OAAQ;AACnB;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { diffArrays } from 'diff/lib/diff/array';\nimport { diffWords } from 'diff/lib/diff/word';\n\n/**\n * WordPress dependencies\n */\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\nimport {\n\tprivateApis as blocksPrivateApis,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport {\n\tRichTextData,\n\tcreate,\n\tslice,\n\tconcat,\n\tapplyFormat,\n} from '@wordpress/rich-text';\nimport { __, _n, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { parseRawBlock } = unlock( blocksPrivateApis );\n\n/**\n * Safely stringifies a value for display and comparison.\n *\n * @param {*} value The value to stringify.\n * @return {string} The stringified value.\n */\nfunction stringifyValue( value ) {\n\tif ( value === null || value === undefined ) {\n\t\treturn '';\n\t}\n\tif ( typeof value === 'object' ) {\n\t\treturn JSON.stringify( value, null, 2 );\n\t}\n\treturn String( value );\n}\n\n/**\n * Calculate text similarity using word-set overlap.\n *\n * Uses a variant of the Jaccard index (https://en.wikipedia.org/wiki/Jaccard_index)\n * called the overlap coefficient (https://en.wikipedia.org/wiki/Overlap_coefficient)\n * where we divide by the larger set size rather than the union. This ensures that\n * a small edit to a long paragraph scores high \u2014 the few changed words don't\n * dilute the score.\n *\n * This replaces the previous diffWords-based similarity which was O(n*m) per pair.\n * The word-set approach is O(n) where n is the number of words.\n *\n * Words are extracted using Intl.Segmenter for proper multilingual support\n * (CJK, Thai, etc.) rather than splitting on whitespace.\n *\n * @param {string} text1 First text to compare.\n * @param {string} text2 Second text to compare.\n * @return {number} Similarity score between 0 and 1.\n */\nfunction textSimilarity( text1, text2 ) {\n\tif ( ! text1 && ! text2 ) {\n\t\treturn 1;\n\t}\n\tif ( ! text1 || ! text2 ) {\n\t\treturn 0;\n\t}\n\n\tconst segmenter = new Intl.Segmenter( undefined, {\n\t\tgranularity: 'word',\n\t} );\n\t// Safari's Intl.Segmenter returns isWordLike: false for numeric segments,\n\t// so fall back to a Unicode-aware regex for letters and numbers.\n\tconst wordLikeRegex = /[\\p{L}\\p{N}]/u;\n\tconst getWords = ( text ) => {\n\t\tconst words = [];\n\t\tfor ( const { segment, isWordLike } of segmenter.segment( text ) ) {\n\t\t\tif ( isWordLike || wordLikeRegex.test( segment ) ) {\n\t\t\t\twords.push( segment );\n\t\t\t}\n\t\t}\n\t\treturn words;\n\t};\n\tconst words1 = getWords( text1 );\n\tconst words2 = getWords( text2 );\n\n\tif ( words1.length === 0 && words2.length === 0 ) {\n\t\treturn 1;\n\t}\n\n\tconst set1 = new Set( words1 );\n\tlet intersection = 0;\n\tfor ( const word of words2 ) {\n\t\tif ( set1.has( word ) ) {\n\t\t\tintersection++;\n\t\t}\n\t}\n\n\tconst total = Math.max( words1.length, words2.length );\n\treturn total > 0 ? intersection / total : 0;\n}\n\n/**\n * Post-process diff result to pair similar removed/added blocks as modifications.\n *\n * After LCS diffing, a block whose content changed appears as a separate \"removed\"\n * and \"added\" entry (since the full block signature differs). This function detects\n * such pairs and merges them into a single \"modified\" block with inline diff.\n *\n * Two pairing strategies are used:\n * 1. When exactly one block of a given type was removed and one was added,\n * they are paired directly \u2014 no ambiguity, no similarity check needed.\n * 2. When multiple candidates exist, textSimilarity (overlap coefficient) is\n * used to find the best match. Blocks must share at least 50% of their\n * words to be paired, preventing unrelated paragraphs from being merged.\n *\n * @param {Array} blocks Raw blocks with diff status.\n * @return {Array} Blocks with similar pairs converted to modifications.\n */\nfunction pairSimilarBlocks( blocks ) {\n\tconst removed = [];\n\tconst added = [];\n\n\t// Separate blocks by status, tracking original indices.\n\tblocks.forEach( ( block, index ) => {\n\t\tconst status = block.__revisionDiffStatus?.status;\n\t\tif ( status === 'removed' ) {\n\t\t\tremoved.push( { block, index } );\n\t\t} else if ( status === 'added' ) {\n\t\t\tadded.push( { block, index } );\n\t\t}\n\t} );\n\n\t// If no removed or no added, nothing to pair.\n\tif ( removed.length === 0 || added.length === 0 ) {\n\t\treturn blocks;\n\t}\n\n\tconst pairedRemoved = new Set(); // Indices of removed blocks filtered out.\n\tconst pairedAdded = new Set(); // Indices of added blocks filtered out.\n\tconst modifications = new Map(); // Index \u2192 modified block.\n\tconst SIMILARITY_THRESHOLD = 0.5;\n\n\t// Group candidates by block name for efficient lookup.\n\tconst addedByName = new Map();\n\tfor ( const add of added ) {\n\t\tconst name = add.block.blockName;\n\t\tif ( ! addedByName.has( name ) ) {\n\t\t\taddedByName.set( name, [] );\n\t\t}\n\t\taddedByName.get( name ).push( add );\n\t}\n\tconst removedByName = new Map();\n\tfor ( const rem of removed ) {\n\t\tconst name = rem.block.blockName;\n\t\tif ( ! removedByName.has( name ) ) {\n\t\t\tremovedByName.set( name, [] );\n\t\t}\n\t\tremovedByName.get( name ).push( rem );\n\t}\n\n\t// For each removed block, find best matching added block.\n\t// Track the highest added index paired so far \u2014 new pairings must\n\t// not go backwards, or the removed/added text order would break.\n\tlet maxPairedAddedIndex = -1;\n\n\tfor ( const rem of removed ) {\n\t\tconst candidates = addedByName.get( rem.block.blockName ) || [];\n\t\tconst sameNameRemoved = removedByName.get( rem.block.blockName ) || [];\n\t\tconst unpaired = candidates.filter(\n\t\t\t( add ) =>\n\t\t\t\t! modifications.has( add.index ) &&\n\t\t\t\tadd.index > maxPairedAddedIndex\n\t\t);\n\n\t\tif ( unpaired.length === 0 ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet bestMatch = null;\n\n\t\t// If there's exactly one removed and one added of this type,\n\t\t// pair them directly \u2014 no ambiguity, no similarity check needed.\n\t\tif ( sameNameRemoved.length === 1 && unpaired.length === 1 ) {\n\t\t\tconst add = unpaired[ 0 ];\n\t\t\tconst attrsMatch =\n\t\t\t\tJSON.stringify( rem.block.attrs ) ===\n\t\t\t\tJSON.stringify( add.block.attrs );\n\t\t\t// Only skip pairing if both content and attrs are identical\n\t\t\t// (position swap, not a modification).\n\t\t\tconst contentMatch =\n\t\t\t\t( rem.block.innerHTML || '' ) === ( add.block.innerHTML || '' );\n\t\t\tif ( ! contentMatch || ! attrsMatch ) {\n\t\t\t\tbestMatch = add;\n\t\t\t}\n\t\t} else {\n\t\t\t// Multiple candidates \u2014 use similarity to find best match.\n\t\t\tlet bestScore = 0;\n\t\t\tfor ( const add of unpaired ) {\n\t\t\t\tconst score = textSimilarity(\n\t\t\t\t\trem.block.innerHTML || '',\n\t\t\t\t\tadd.block.innerHTML || ''\n\t\t\t\t);\n\t\t\t\t// Skip identical blocks (score=1 with same attrs) \u2014 those\n\t\t\t\t// are position swaps, not modifications. They should show\n\t\t\t\t// as separate removed + added, not as a no-op \"modified\".\n\t\t\t\tconst attrsMatch =\n\t\t\t\t\tJSON.stringify( rem.block.attrs ) ===\n\t\t\t\t\tJSON.stringify( add.block.attrs );\n\t\t\t\tif (\n\t\t\t\t\tscore > bestScore &&\n\t\t\t\t\tscore > SIMILARITY_THRESHOLD &&\n\t\t\t\t\t( score < 1 || ! attrsMatch )\n\t\t\t\t) {\n\t\t\t\t\tbestScore = score;\n\t\t\t\t\tbestMatch = add;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( bestMatch ) {\n\t\t\tmaxPairedAddedIndex = bestMatch.index;\n\n\t\t\tconst modifiedBlock = {\n\t\t\t\t...bestMatch.block,\n\t\t\t\t__revisionDiffStatus: { status: 'modified' },\n\t\t\t\t__previousRawBlock: rem.block,\n\t\t\t};\n\n\t\t\t// Decide where to place the modified block by checking\n\t\t\t// what's between the removed and added positions.\n\t\t\t// If there are unpaired added blocks between them,\n\t\t\t// placing at the removed position would put the modified\n\t\t\t// block before content that comes before it in the\n\t\t\t// current revision \u2014 so use the added position.\n\t\t\t// Otherwise, use the removed position to keep the\n\t\t\t// previous revision's order intact.\n\t\t\tconst lo = Math.min( rem.index, bestMatch.index );\n\t\t\tconst hi = Math.max( rem.index, bestMatch.index );\n\t\t\tlet hasAddedBetween = false;\n\t\t\tfor ( let i = lo + 1; i < hi; i++ ) {\n\t\t\t\tif (\n\t\t\t\t\tblocks[ i ].__revisionDiffStatus?.status === 'added' &&\n\t\t\t\t\t! pairedAdded.has( i )\n\t\t\t\t) {\n\t\t\t\t\thasAddedBetween = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( hasAddedBetween ) {\n\t\t\t\t// Use the added position \u2014 don't jump before\n\t\t\t\t// current-revision content.\n\t\t\t\tmodifications.set( bestMatch.index, modifiedBlock );\n\t\t\t\tpairedRemoved.add( rem.index );\n\t\t\t} else {\n\t\t\t\t// Use the removed position \u2014 keep the previous\n\t\t\t\t// revision's reading order.\n\t\t\t\tmodifications.set( rem.index, modifiedBlock );\n\t\t\t\tpairedAdded.add( bestMatch.index );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Rebuild result: replace modification targets, filter out\n\t// their paired counterparts.\n\treturn blocks\n\t\t.map( ( block, index ) => {\n\t\t\tif ( pairedRemoved.has( index ) || pairedAdded.has( index ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif ( modifications.has( index ) ) {\n\t\t\t\treturn modifications.get( index );\n\t\t\t}\n\t\t\treturn block;\n\t\t} )\n\t\t.filter( Boolean );\n}\n\n/**\n * Diff raw block arrays using LCS, recursively handling innerBlocks.\n * Detects modifications when exactly 1 block is removed and 1 is added\n * with the same blockName (1:1 replacement = modification).\n *\n * @param {Array} currentRaw Current revision's raw blocks.\n * @param {Array} previousRaw Previous revision's raw blocks.\n * @return {Array} Merged raw blocks with diff status injected.\n */\nfunction diffRawBlocks( currentRaw, previousRaw ) {\n\tconst createBlockSignature = ( rawBlock ) =>\n\t\tJSON.stringify( {\n\t\t\tname: rawBlock.blockName,\n\t\t\tattrs: rawBlock.attrs,\n\t\t\t// Use innerContent filtered to non-null and non-whitespace-only strings.\n\t\t\t// This excludes whitespace between inner blocks which changes based on count.\n\t\t\thtml: ( rawBlock.innerContent || [] ).filter(\n\t\t\t\t( c ) => c !== null && c.trim() !== ''\n\t\t\t),\n\t\t} );\n\tconst currentSigs = currentRaw.map( createBlockSignature );\n\tconst previousSigs = previousRaw.map( createBlockSignature );\n\n\tconst diff = diffArrays( previousSigs, currentSigs );\n\n\tconst result = [];\n\tlet currIdx = 0;\n\tlet prevIdx = 0;\n\n\tfor ( const part of diff ) {\n\t\tif ( part.added ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currentRaw[ currIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: { status: 'added' },\n\t\t\t\t} );\n\t\t\t}\n\t\t} else if ( part.removed ) {\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tresult.push( {\n\t\t\t\t\t...previousRaw[ prevIdx++ ],\n\t\t\t\t\t__revisionDiffStatus: { status: 'removed' },\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\t// Matched blocks - recursively diff their innerBlocks.\n\t\t\tfor ( let i = 0; i < part.count; i++ ) {\n\t\t\t\tconst currBlock = currentRaw[ currIdx++ ];\n\t\t\t\tconst prevBlock = previousRaw[ prevIdx++ ];\n\n\t\t\t\t// Recursively diff inner blocks.\n\t\t\t\tconst diffedInnerBlocks = diffRawBlocks(\n\t\t\t\t\tcurrBlock.innerBlocks || [],\n\t\t\t\t\tprevBlock.innerBlocks || []\n\t\t\t\t);\n\n\t\t\t\tresult.push( {\n\t\t\t\t\t...currBlock,\n\t\t\t\t\tinnerBlocks: diffedInnerBlocks,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\t// Post-process to pair similar removed/added blocks as modifications.\n\treturn pairSimilarBlocks( result );\n}\n\n/**\n * Check if formatting has changed at specific character indices.\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currentIndex Character index in current.\n * @param {number} previousIndex Character index in previous.\n * @return {boolean} True if formatting changed at these indices.\n */\nfunction hasFormatChangedAtIndex(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrentIndex,\n\tpreviousIndex\n) {\n\tconst currFmts = currentFormats[ currentIndex ] || [];\n\tconst prevFmts = previousFormats[ previousIndex ] || [];\n\n\tif ( currFmts.length !== prevFmts.length ) {\n\t\treturn true;\n\t}\n\n\t// Check if each format in current exists in previous\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find(\n\t\t\t( pf ) =>\n\t\t\t\tpf.type === fmt.type &&\n\t\t\t\tJSON.stringify( pf.attributes ) ===\n\t\t\t\t\tJSON.stringify( fmt.attributes )\n\t\t);\n\t\tif ( ! match ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Analyze what formatting changed between two character positions.\n * Returns both the change type (for styling) and a description (for tooltip).\n *\n * @param {Array} currentFormats Current formats array.\n * @param {Array} previousFormats Previous formats array.\n * @param {number} currIdx Character index in current.\n * @param {number} prevIdx Character index in previous.\n * @return {{ type: 'added'|'removed'|'changed', description: string }} Change info.\n */\nfunction describeFormatChange(\n\tcurrentFormats,\n\tpreviousFormats,\n\tcurrIdx,\n\tprevIdx\n) {\n\tconst currFmts = currentFormats[ currIdx ] || [];\n\tconst prevFmts = previousFormats[ prevIdx ] || [];\n\n\tlet addedCount = 0;\n\tlet removedCount = 0;\n\tlet changedCount = 0;\n\n\t// Find added formats and attribute changes\n\tfor ( const fmt of currFmts ) {\n\t\tconst match = prevFmts.find( ( pf ) => pf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\taddedCount++;\n\t\t} else if (\n\t\t\tJSON.stringify( fmt.attributes ) !==\n\t\t\tJSON.stringify( match.attributes )\n\t\t) {\n\t\t\tchangedCount++;\n\t\t}\n\t}\n\n\t// Find removed formats\n\tfor ( const fmt of prevFmts ) {\n\t\tconst match = currFmts.find( ( cf ) => cf.type === fmt.type );\n\t\tif ( ! match ) {\n\t\t\tremovedCount++;\n\t\t}\n\t}\n\n\t// Determine primary change type for styling\n\tif ( addedCount > 0 && removedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'added',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t),\n\t\t};\n\t}\n\tif ( removedCount > 0 && addedCount === 0 && changedCount === 0 ) {\n\t\treturn {\n\t\t\ttype: 'removed',\n\t\t\tdescription: sprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t),\n\t\t};\n\t}\n\n\t// Mixed or attribute-only changes\n\tconst parts = [];\n\tif ( addedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats added */\n\t\t\t\t_n( '%d format added', '%d formats added', addedCount ),\n\t\t\t\taddedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( removedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats removed */\n\t\t\t\t_n( '%d format removed', '%d formats removed', removedCount ),\n\t\t\t\tremovedCount\n\t\t\t)\n\t\t);\n\t}\n\tif ( changedCount > 0 ) {\n\t\tparts.push(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of formats changed */\n\t\t\t\t_n( '%d format changed', '%d formats changed', changedCount ),\n\t\t\t\tchangedCount\n\t\t\t)\n\t\t);\n\t}\n\treturn {\n\t\ttype: 'changed',\n\t\tdescription: parts.join( ', ' ) || __( 'Formatting changed' ),\n\t};\n}\n\n/**\n * Apply inline diff formatting comparing two RichTextData values.\n * - Text changes: apply revision/diff-removed and revision/diff-added formats\n * - Format-only changes (text unchanged): apply revision/diff-format-changed format\n *\n * @param {RichTextData} currentRichText Current revision's rich text.\n * @param {RichTextData} previousRichText Previous revision's rich text.\n * @return {RichTextData} New rich text with diff formatting applied.\n */\nfunction applyRichTextDiff( currentRichText, previousRichText ) {\n\tconst currentText = currentRichText.toPlainText();\n\tconst previousText = previousRichText.toPlainText();\n\n\t// Diff the plain text (words for cleaner output)\n\tconst textDiff = diffWords( previousText, currentText );\n\n\tlet result = create( { text: '' } );\n\tlet currentIdx = 0;\n\tlet previousIdx = 0;\n\n\tfor ( const part of textDiff ) {\n\t\tif ( part.removed ) {\n\t\t\t// Text deleted - slice from PREVIOUS, apply <del>\n\t\t\tconst removedSlice = slice(\n\t\t\t\tpreviousRichText,\n\t\t\t\tpreviousIdx,\n\t\t\t\tpreviousIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\tremovedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-removed',\n\t\t\t\t\tattributes: { title: __( 'Removed' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tpreviousIdx += part.value.length;\n\t\t} else if ( part.added ) {\n\t\t\t// Text added - slice from CURRENT, apply <ins>\n\t\t\tconst addedSlice = slice(\n\t\t\t\tcurrentRichText,\n\t\t\t\tcurrentIdx,\n\t\t\t\tcurrentIdx + part.value.length\n\t\t\t);\n\t\t\tconst formatted = applyFormat(\n\t\t\t\taddedSlice,\n\t\t\t\t{\n\t\t\t\t\ttype: 'revision/diff-added',\n\t\t\t\t\tattributes: { title: __( 'Added' ) },\n\t\t\t\t},\n\t\t\t\t0,\n\t\t\t\tpart.value.length\n\t\t\t);\n\t\t\tresult = concat( result, formatted );\n\t\t\tcurrentIdx += part.value.length;\n\t\t} else {\n\t\t\t// Text unchanged - check formatting at each character position.\n\t\t\t// Only apply <mark> to specific ranges where formatting differs.\n\t\t\tconst currentFormats = currentRichText.formats || [];\n\t\t\tconst previousFormats = previousRichText.formats || [];\n\t\t\tconst len = part.value.length;\n\n\t\t\t// Helper to check format change at offset within this unchanged part.\n\t\t\tconst checkFormatChanged = ( offset ) =>\n\t\t\t\thasFormatChangedAtIndex(\n\t\t\t\t\tcurrentFormats,\n\t\t\t\t\tpreviousFormats,\n\t\t\t\t\tcurrentIdx + offset,\n\t\t\t\t\tpreviousIdx + offset\n\t\t\t\t);\n\n\t\t\t// Find ranges of characters grouped by whether format changed.\n\t\t\tlet rangeStart = 0;\n\t\t\tlet rangeFormatChanged = checkFormatChanged( 0 );\n\n\t\t\tfor ( let i = 1; i <= len; i++ ) {\n\t\t\t\tconst formatChanged = i < len && checkFormatChanged( i );\n\n\t\t\t\t// When format-changed status changes or we reach the end, emit range.\n\t\t\t\tif ( i === len || formatChanged !== rangeFormatChanged ) {\n\t\t\t\t\tconst rangeSlice = slice(\n\t\t\t\t\t\tcurrentRichText,\n\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\tcurrentIdx + i\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( rangeFormatChanged ) {\n\t\t\t\t\t\t// Get type and description of what changed\n\t\t\t\t\t\tconst { type, description } = describeFormatChange(\n\t\t\t\t\t\t\tcurrentFormats,\n\t\t\t\t\t\t\tpreviousFormats,\n\t\t\t\t\t\t\tcurrentIdx + rangeStart,\n\t\t\t\t\t\t\tpreviousIdx + rangeStart\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Map change type to format type for styling\n\t\t\t\t\t\tconst formatType = {\n\t\t\t\t\t\t\tadded: 'revision/diff-format-added',\n\t\t\t\t\t\t\tremoved: 'revision/diff-format-removed',\n\t\t\t\t\t\t\tchanged: 'revision/diff-format-changed',\n\t\t\t\t\t\t}[ type ];\n\n\t\t\t\t\t\tconst marked = applyFormat(\n\t\t\t\t\t\t\trangeSlice,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: formatType,\n\t\t\t\t\t\t\t\tattributes: { title: description },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\ti - rangeStart\n\t\t\t\t\t\t);\n\t\t\t\t\t\tresult = concat( result, marked );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = concat( result, rangeSlice );\n\t\t\t\t\t}\n\n\t\t\t\t\trangeStart = i;\n\t\t\t\t\trangeFormatChanged = formatChanged;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcurrentIdx += part.value.length;\n\t\t\tpreviousIdx += part.value.length;\n\t\t}\n\t}\n\n\treturn new RichTextData( result );\n}\n\n/**\n * Apply diffs to a modified block's attributes.\n * - Rich-text attributes: applies inline diff formatting (ins/del marks).\n * - Other attributes: computes word-level diffs for the sidebar panel.\n *\n * @param {Object} currentBlock Current parsed block.\n * @param {Object} previousBlock Previous parsed block.\n * @param {Object} diffStatus The __revisionDiffStatus object to attach changedAttributes to.\n */\nfunction applyDiffToBlock( currentBlock, previousBlock, diffStatus ) {\n\tconst blockType = getBlockType( currentBlock.name );\n\tif ( ! blockType ) {\n\t\treturn;\n\t}\n\n\tconst changedAttributes = {};\n\n\tfor ( const [ attrName, attrDef ] of Object.entries(\n\t\tblockType.attributes\n\t) ) {\n\t\tif ( attrDef.source === 'rich-text' ) {\n\t\t\tconst currentRichText = currentBlock.attributes[ attrName ];\n\t\t\tconst previousRichText = previousBlock.attributes[ attrName ];\n\t\t\tif (\n\t\t\t\tcurrentRichText instanceof RichTextData &&\n\t\t\t\tpreviousRichText instanceof RichTextData\n\t\t\t) {\n\t\t\t\tcurrentBlock.attributes[ attrName ] = applyRichTextDiff(\n\t\t\t\t\tcurrentRichText,\n\t\t\t\t\tpreviousRichText\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tconst currStr = stringifyValue(\n\t\t\t\tcurrentBlock.attributes[ attrName ]\n\t\t\t);\n\t\t\tconst prevStr = stringifyValue(\n\t\t\t\tpreviousBlock.attributes[ attrName ]\n\t\t\t);\n\t\t\tif ( currStr !== prevStr ) {\n\t\t\t\tchangedAttributes[ attrName ] = diffWords( prevStr, currStr );\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( Object.keys( changedAttributes ).length > 0 ) {\n\t\tdiffStatus.changedAttributes = changedAttributes;\n\t}\n}\n\n/**\n * Recursively apply diff status and rich text diff to blocks in the tree.\n * Copies __revisionDiffStatus from raw blocks to parsed blocks and applies\n * rich text diffs to modified blocks.\n *\n * @param {Object} parsedBlock Parsed block (with inner blocks).\n * @param {Object} rawBlock Raw block (with __revisionDiffStatus and __previousRawBlock).\n */\nfunction applyDiffRecursively( parsedBlock, rawBlock ) {\n\t// Copy diff status from raw block to parsed block.\n\tif ( rawBlock.__revisionDiffStatus ) {\n\t\t// Apply diffs if this block is modified and has a previous raw block.\n\t\tif (\n\t\t\trawBlock.__revisionDiffStatus.status === 'modified' &&\n\t\t\trawBlock.__previousRawBlock\n\t\t) {\n\t\t\tconst previousParsed = parseRawBlock( rawBlock.__previousRawBlock );\n\t\t\tif ( previousParsed ) {\n\t\t\t\tapplyDiffToBlock(\n\t\t\t\t\tparsedBlock,\n\t\t\t\t\tpreviousParsed,\n\t\t\t\t\trawBlock.__revisionDiffStatus\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tparsedBlock.__revisionDiffStatus = rawBlock.__revisionDiffStatus;\n\t\t// Also store in attributes so it survives block-editor store normalization.\n\t\tparsedBlock.attributes.__revisionDiffStatus =\n\t\t\trawBlock.__revisionDiffStatus;\n\t}\n\n\t// Recursively process inner blocks.\n\tif ( parsedBlock.innerBlocks && rawBlock.innerBlocks ) {\n\t\tfor ( let i = 0; i < parsedBlock.innerBlocks.length; i++ ) {\n\t\t\tconst parsedInner = parsedBlock.innerBlocks[ i ];\n\t\t\tconst rawInner = rawBlock.innerBlocks[ i ];\n\t\t\tif ( parsedInner && rawInner ) {\n\t\t\t\tapplyDiffRecursively( parsedInner, rawInner );\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Diff two revision contents at the grammar level.\n *\n * @param {string} currentContent Current revision's raw content.\n * @param {string} previousContent Previous revision's raw content.\n * @return {Array} Array of parsed blocks with diff status attributes.\n */\nexport function diffRevisionContent( currentContent, previousContent ) {\n\t// Grammar parse both contents.\n\tconst currentRaw = grammarParse( currentContent || '' );\n\tconst previousRaw = grammarParse( previousContent || '' );\n\n\t// Diff the raw block arrays.\n\tconst mergedRaw = diffRawBlocks( currentRaw, previousRaw );\n\n\t// Parse each raw block and apply diff status.\n\treturn mergedRaw\n\t\t.map( ( rawBlock ) => {\n\t\t\tconst parsed = parseRawBlock( rawBlock );\n\t\t\tif ( parsed ) {\n\t\t\t\tapplyDiffRecursively( parsed, rawBlock );\n\t\t\t}\n\t\t\treturn parsed;\n\t\t} )\n\t\t.filter( Boolean );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA2B;AAC3B,kBAA0B;AAK1B,gDAAsC;AACtC,oBAGO;AACP,uBAMO;AACP,kBAAgC;AAKhC,yBAAuB;AAEvB,IAAM,EAAE,cAAc,QAAI,2BAAQ,cAAAA,WAAkB;AAQpD,SAAS,eAAgB,OAAQ;AAChC,MAAK,UAAU,QAAQ,UAAU,QAAY;AAC5C,WAAO;AAAA,EACR;AACA,MAAK,OAAO,UAAU,UAAW;AAChC,WAAO,KAAK,UAAW,OAAO,MAAM,CAAE;AAAA,EACvC;AACA,SAAO,OAAQ,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AAiB,cAAe,SAAS,kBAAmB;AAClE,UAAK,gBAAiB;AACrB;AAAA,UACC;AAAA,UACA;AAAA,UACA,SAAS;AAAA,QACV;AAAA,MACD;AAAA,IACD;AAEA,gBAAY,uBAAuB,SAAS;AAE5C,gBAAY,WAAW,uBACtB,SAAS;AAAA,EACX;AAGA,MAAK,YAAY,eAAe,SAAS,aAAc;AACtD,aAAU,IAAI,GAAG,IAAI,YAAY,YAAY,QAAQ,KAAM;AAC1D,YAAM,cAAc,YAAY,YAAa,CAAE;AAC/C,YAAM,WAAW,SAAS,YAAa,CAAE;AACzC,UAAK,eAAe,UAAW;AAC9B,6BAAsB,aAAa,QAAS;AAAA,MAC7C;AAAA,IACD;AAAA,EACD;AACD;AASO,SAAS,oBAAqB,gBAAgB,iBAAkB;AAEtE,QAAM,iBAAa,0CAAAC,OAAc,kBAAkB,EAAG;AACtD,QAAM,kBAAc,0CAAAA,OAAc,mBAAmB,EAAG;AAGxD,QAAM,YAAY,cAAe,YAAY,WAAY;AAGzD,SAAO,UACL,IAAK,CAAE,aAAc;AACrB,UAAM,SAAS,cAAe,QAAS;AACvC,QAAK,QAAS;AACb,2BAAsB,QAAQ,QAAS;AAAA,IACxC;AACA,WAAO;AAAA,EACR,CAAE,EACD,OAAQ,OAAQ;AACnB;",
6
6
  "names": ["blocksPrivateApis", "grammarParse"]
7
7
  }
@@ -28,16 +28,17 @@ var import_compose = require("@wordpress/compose");
28
28
  var import_data = require("@wordpress/data");
29
29
  var import_block_editor = require("@wordpress/block-editor");
30
30
  var import_i18n = require("@wordpress/i18n");
31
+ var import_components = require("@wordpress/components");
31
32
  var import_lock_unlock = require("../../lock-unlock.cjs");
32
33
  var import_jsx_runtime = require("react/jsx-runtime");
33
34
  var { useBlockElementRef } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
34
35
  function collectDiffBlocks(blocks) {
35
36
  const result = [];
36
37
  for (const block of blocks) {
37
- if (block.__revisionDiffStatus) {
38
+ if (block.__revisionDiffStatus?.status) {
38
39
  result.push({
39
40
  clientId: block.clientId,
40
- status: block.__revisionDiffStatus
41
+ status: block.__revisionDiffStatus.status
41
42
  });
42
43
  }
43
44
  if (block.innerBlocks?.length) {
@@ -82,7 +83,7 @@ function DiffMarkerButton({ clientId, status, subscribe }) {
82
83
  if (!position) {
83
84
  return null;
84
85
  }
85
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Tooltip, { text: STATUS_LABELS[status], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
87
  "button",
87
88
  {
88
89
  className: `revision-diff-marker is-${status}`,
@@ -93,7 +94,7 @@ function DiffMarkerButton({ clientId, status, subscribe }) {
93
94
  onClick: () => blockRef.current?.focus(),
94
95
  "aria-label": STATUS_LABELS[status]
95
96
  }
96
- );
97
+ ) });
97
98
  }
98
99
  function useDiffMarkers() {
99
100
  const [isMounted, setIsMounted] = (0, import_element.useState)(false);
@@ -125,7 +126,7 @@ function useDiffMarkers() {
125
126
  {
126
127
  className: "revision-diff-markers",
127
128
  role: "navigation",
128
- "aria-label": (0, import_i18n.__)("Diff markers"),
129
+ "aria-label": (0, import_i18n.__)("Document changes"),
129
130
  children: isMounted && diffBlocks.map(({ clientId, status }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
130
131
  DiffMarkerButton,
131
132
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-revisions-preview/diff-markers.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useBlockElementRef } = unlock( blockEditorPrivateApis );\n\n/**\n * Recursively collect blocks with diff status.\n *\n * @param {Array} blocks The blocks to search.\n * @return {Array} Blocks with __revisionDiffStatus.\n */\nfunction collectDiffBlocks( blocks ) {\n\tconst result = [];\n\tfor ( const block of blocks ) {\n\t\tif ( block.__revisionDiffStatus ) {\n\t\t\tresult.push( {\n\t\t\t\tclientId: block.clientId,\n\t\t\t\tstatus: block.__revisionDiffStatus,\n\t\t\t} );\n\t\t}\n\t\tif ( block.innerBlocks?.length ) {\n\t\t\tresult.push( ...collectDiffBlocks( block.innerBlocks ) );\n\t\t}\n\t}\n\treturn result;\n}\n\nconst STATUS_LABELS = {\n\tadded: __( 'Go to added block' ),\n\tremoved: __( 'Go to removed block' ),\n\tmodified: __( 'Go to modified block' ),\n};\n\nfunction calculatePosition( el ) {\n\tif ( ! el ) {\n\t\treturn null;\n\t}\n\tconst doc = el.ownerDocument;\n\tconst scrollHeight = doc.documentElement.scrollHeight;\n\tconst rect = el.getBoundingClientRect();\n\tconst scrollTop = doc.documentElement.scrollTop;\n\tconst top = rect.top + scrollTop;\n\treturn {\n\t\ttop: ( top / scrollHeight ) * 100,\n\t\theight: ( rect.height / scrollHeight ) * 100,\n\t};\n}\n\n/**\n * Button component for a single diff marker.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId The block client ID.\n * @param {string} props.status The diff status (added/removed/modified).\n * @param {Function} props.subscribe Function to subscribe to position updates.\n * @return {React.JSX.Element} The diff marker button or null if position not calculated.\n */\nfunction DiffMarkerButton( { clientId, status, subscribe } ) {\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\tconst [ position, setPosition ] = useState( () =>\n\t\tcalculatePosition( blockRef.current )\n\t);\n\n\tuseEffect( () => {\n\t\treturn subscribe( () => {\n\t\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t\t} );\n\t}, [ subscribe ] );\n\n\tuseEffect( () => {\n\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t}, [ status ] );\n\n\tif ( ! position ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<button\n\t\t\tclassName={ `revision-diff-marker is-${ status }` }\n\t\t\tstyle={ {\n\t\t\t\ttop: `${ position.top }%`,\n\t\t\t\theight: `${ Math.max( position.height, 0.5 ) }%`,\n\t\t\t} }\n\t\t\tonClick={ () => blockRef.current?.focus() }\n\t\t\taria-label={ STATUS_LABELS[ status ] }\n\t\t/>\n\t);\n}\n\n/**\n * Hook that provides diff markers functionality.\n * Returns a ref callback for the content element and a DiffMarkers component.\n * Must be used inside a BlockEditorProvider context.\n *\n * @return {Array} Tuple of [contentRef, DiffMarkersComponent].\n */\nexport function useDiffMarkers() {\n\tconst [ isMounted, setIsMounted ] = useState( false );\n\tconst subscribersRef = useRef( new Set() );\n\tconst blocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks(),\n\t\t[]\n\t);\n\tconst diffBlocks = useMemo( () => collectDiffBlocks( blocks ), [ blocks ] );\n\tconst subscribe = useCallback( ( callback ) => {\n\t\tsubscribersRef.current.add( callback );\n\t\treturn () => subscribersRef.current.delete( callback );\n\t}, [] );\n\tconst contentRef = useRefEffect( ( element ) => {\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst resizeObserver = new defaultView.ResizeObserver( () => {\n\t\t\tsubscribersRef.current.forEach( ( cb ) => cb() );\n\t\t} );\n\t\tresizeObserver.observe( ownerDocument.body );\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [] );\n\treturn [\n\t\tuseMergeRefs( [ contentRef, setIsMounted ] ),\n\t\t<div\n\t\t\tkey=\"diff-markers\"\n\t\t\tclassName=\"revision-diff-markers\"\n\t\t\trole=\"navigation\"\n\t\t\taria-label={ __( 'Diff markers' ) }\n\t\t>\n\t\t\t{ isMounted &&\n\t\t\t\tdiffBlocks.map( ( { clientId, status } ) => (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EAAE,YAAY,IAAI;AACxB,UAAM,iBAAiB,IAAI,YAAY,eAAgB,MAAM;AAC5D,qBAAe,QAAQ,QAAS,CAAE,OAAQ,GAAG,CAAE;AAAA,IAChD,CAAE;AACF,mBAAe,QAAS,cAAc,IAAK;AAC3C,WAAO,MAAM;AACZ,qBAAe,WAAW;AAAA,IAC3B;AAAA,EACD,GAAG,CAAC,CAAE;AACN,SAAO;AAAA,QACN,6BAAc,CAAE,YAAY,YAAa,CAAE;AAAA,IAC3C;AAAA,MAAC;AAAA;AAAA,QAEA,WAAU;AAAA,QACV,MAAK;AAAA,QACL,kBAAa,gBAAI,cAAe;AAAA,QAE9B,uBACD,WAAW,IAAK,CAAE,EAAE,UAAU,OAAO,MACpC;AAAA,UAAC;AAAA;AAAA,YAEA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,UAHM;AAAA,QAIP,CACC;AAAA;AAAA,MAbC;AAAA,IAcL;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { Tooltip } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useBlockElementRef } = unlock( blockEditorPrivateApis );\n\n/**\n * Recursively collect blocks with diff status.\n *\n * @param {Array} blocks The blocks to search.\n * @return {Array} Blocks with __revisionDiffStatus.\n */\nfunction collectDiffBlocks( blocks ) {\n\tconst result = [];\n\tfor ( const block of blocks ) {\n\t\tif ( block.__revisionDiffStatus?.status ) {\n\t\t\tresult.push( {\n\t\t\t\tclientId: block.clientId,\n\t\t\t\tstatus: block.__revisionDiffStatus.status,\n\t\t\t} );\n\t\t}\n\t\tif ( block.innerBlocks?.length ) {\n\t\t\tresult.push( ...collectDiffBlocks( block.innerBlocks ) );\n\t\t}\n\t}\n\treturn result;\n}\n\nconst STATUS_LABELS = {\n\tadded: __( 'Go to added block' ),\n\tremoved: __( 'Go to removed block' ),\n\tmodified: __( 'Go to modified block' ),\n};\n\nfunction calculatePosition( el ) {\n\tif ( ! el ) {\n\t\treturn null;\n\t}\n\tconst doc = el.ownerDocument;\n\tconst scrollHeight = doc.documentElement.scrollHeight;\n\tconst rect = el.getBoundingClientRect();\n\tconst scrollTop = doc.documentElement.scrollTop;\n\tconst top = rect.top + scrollTop;\n\treturn {\n\t\ttop: ( top / scrollHeight ) * 100,\n\t\theight: ( rect.height / scrollHeight ) * 100,\n\t};\n}\n\n/**\n * Button component for a single diff marker.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId The block client ID.\n * @param {string} props.status The diff status (added/removed/modified).\n * @param {Function} props.subscribe Function to subscribe to position updates.\n * @return {React.JSX.Element} The diff marker button or null if position not calculated.\n */\nfunction DiffMarkerButton( { clientId, status, subscribe } ) {\n\tconst blockRef = useRef();\n\tuseBlockElementRef( clientId, blockRef );\n\tconst [ position, setPosition ] = useState( () =>\n\t\tcalculatePosition( blockRef.current )\n\t);\n\n\tuseEffect( () => {\n\t\treturn subscribe( () => {\n\t\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t\t} );\n\t}, [ subscribe ] );\n\n\tuseEffect( () => {\n\t\tsetPosition( calculatePosition( blockRef.current ) );\n\t}, [ status ] );\n\n\tif ( ! position ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Tooltip text={ STATUS_LABELS[ status ] }>\n\t\t\t<button\n\t\t\t\tclassName={ `revision-diff-marker is-${ status }` }\n\t\t\t\tstyle={ {\n\t\t\t\t\ttop: `${ position.top }%`,\n\t\t\t\t\theight: `${ Math.max( position.height, 0.5 ) }%`,\n\t\t\t\t} }\n\t\t\t\tonClick={ () => blockRef.current?.focus() }\n\t\t\t\taria-label={ STATUS_LABELS[ status ] }\n\t\t\t/>\n\t\t</Tooltip>\n\t);\n}\n\n/**\n * Hook that provides diff markers functionality.\n * Returns a ref callback for the content element and a DiffMarkers component.\n * Must be used inside a BlockEditorProvider context.\n *\n * @return {Array} Tuple of [contentRef, DiffMarkersComponent].\n */\nexport function useDiffMarkers() {\n\tconst [ isMounted, setIsMounted ] = useState( false );\n\tconst subscribersRef = useRef( new Set() );\n\tconst blocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks(),\n\t\t[]\n\t);\n\tconst diffBlocks = useMemo( () => collectDiffBlocks( blocks ), [ blocks ] );\n\tconst subscribe = useCallback( ( callback ) => {\n\t\tsubscribersRef.current.add( callback );\n\t\treturn () => subscribersRef.current.delete( callback );\n\t}, [] );\n\tconst contentRef = useRefEffect( ( element ) => {\n\t\tconst { ownerDocument } = element;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst resizeObserver = new defaultView.ResizeObserver( () => {\n\t\t\tsubscribersRef.current.forEach( ( cb ) => cb() );\n\t\t} );\n\t\tresizeObserver.observe( ownerDocument.body );\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [] );\n\treturn [\n\t\tuseMergeRefs( [ contentRef, setIsMounted ] ),\n\t\t<div\n\t\t\tkey=\"diff-markers\"\n\t\t\tclassName=\"revision-diff-markers\"\n\t\t\trole=\"navigation\"\n\t\t\taria-label={ __( 'Document changes' ) }\n\t\t>\n\t\t\t{ isMounted &&\n\t\t\t\tdiffBlocks.map( ( { clientId, status } ) => (\n\t\t\t\t\t<DiffMarkerButton\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tstatus={ status }\n\t\t\t\t\t\tsubscribe={ subscribe }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t</div>,\n\t];\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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