@arbidocs/blocks 0.5.134 → 0.5.136

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 (231) hide show
  1. package/dist/{ConnectedNativeDocxComparison-H72RQJKH.cjs → ConnectedNativeDocxComparison-W4KIGO54.cjs} +8 -8
  2. package/dist/{ConnectedNativeDocxComparison-H72RQJKH.cjs.map → ConnectedNativeDocxComparison-W4KIGO54.cjs.map} +1 -1
  3. package/dist/{ConnectedStreamedWordArtifact-T7PZIRBY.cjs → ConnectedStreamedWordArtifact-764NSXPQ.cjs} +8 -8
  4. package/dist/{ConnectedStreamedWordArtifact-T7PZIRBY.cjs.map → ConnectedStreamedWordArtifact-764NSXPQ.cjs.map} +1 -1
  5. package/dist/{DocumentReviewCard-EM2AJUF3.cjs → DocumentReviewCard-UV3DLFCB.cjs} +3 -3
  6. package/dist/{DocumentReviewCard-EM2AJUF3.cjs.map → DocumentReviewCard-UV3DLFCB.cjs.map} +1 -1
  7. package/dist/{FilesViewerDialog-PA2B7O7I.cjs → FilesViewerDialog-IFF2JR2A.cjs} +6 -6
  8. package/dist/{FilesViewerDialog-PA2B7O7I.cjs.map → FilesViewerDialog-IFF2JR2A.cjs.map} +1 -1
  9. package/dist/{NativeDocxEditor-XZAEU5QU.cjs → NativeDocxEditor-KM6U4ZLA.cjs} +6 -6
  10. package/dist/{NativeDocxEditor-XZAEU5QU.cjs.map → NativeDocxEditor-KM6U4ZLA.cjs.map} +1 -1
  11. package/dist/{chunk-T2DUNNYY.cjs → chunk-C6DF6WB2.cjs} +745 -21
  12. package/dist/chunk-C6DF6WB2.cjs.map +1 -0
  13. package/dist/{chunk-64247UHS.cjs → chunk-DBGBAD4J.cjs} +4 -4
  14. package/dist/{chunk-64247UHS.cjs.map → chunk-DBGBAD4J.cjs.map} +1 -1
  15. package/dist/{chunk-UOZ237OW.cjs → chunk-FABKMTAI.cjs} +42 -5
  16. package/dist/chunk-FABKMTAI.cjs.map +1 -0
  17. package/dist/{chunk-L4Y6UMRC.cjs → chunk-FDRZJFNV.cjs} +5 -5
  18. package/dist/{chunk-L4Y6UMRC.cjs.map → chunk-FDRZJFNV.cjs.map} +1 -1
  19. package/dist/{chunk-O5WVYUFT.cjs → chunk-IEAZX7L6.cjs} +4 -4
  20. package/dist/{chunk-O5WVYUFT.cjs.map → chunk-IEAZX7L6.cjs.map} +1 -1
  21. package/dist/{chunk-2SWS7ESM.cjs → chunk-L62EU3TQ.cjs} +3 -3
  22. package/dist/{chunk-2SWS7ESM.cjs.map → chunk-L62EU3TQ.cjs.map} +1 -1
  23. package/dist/{chunk-IN3KXI3K.cjs → chunk-LG36LSVZ.cjs} +6 -6
  24. package/dist/{chunk-IN3KXI3K.cjs.map → chunk-LG36LSVZ.cjs.map} +1 -1
  25. package/dist/{chunk-RZSBHRQL.cjs → chunk-MMKMQZ2B.cjs} +5 -5
  26. package/dist/{chunk-RZSBHRQL.cjs.map → chunk-MMKMQZ2B.cjs.map} +1 -1
  27. package/dist/chunk-MMMGOZYH.cjs +18 -0
  28. package/dist/{chunk-KWD5Q4XH.cjs.map → chunk-MMMGOZYH.cjs.map} +1 -1
  29. package/dist/{chunk-V6SFJ44C.cjs → chunk-ZN2JXV65.cjs} +50 -13
  30. package/dist/chunk-ZN2JXV65.cjs.map +1 -0
  31. package/dist/connect/docx.cjs +12 -12
  32. package/dist/connect/index.cjs +86 -86
  33. package/dist/connect/viewer.cjs +4 -4
  34. package/dist/connection/docx/ConnectedNativeDocxEditor.js +39 -2
  35. package/dist/connection/docx/ConnectedNativeDocxEditor.js.map +2 -2
  36. package/dist/connection/viewer/ConnectedDocumentViewer.js +43 -6
  37. package/dist/connection/viewer/ConnectedDocumentViewer.js.map +2 -2
  38. package/dist/docx/NativeDocxEditor.d.ts +12 -1
  39. package/dist/docx/NativeDocxEditor.js +513 -20
  40. package/dist/docx/NativeDocxEditor.js.map +3 -3
  41. package/dist/docx/index.cjs +38 -38
  42. package/dist/docx/recoveryStore.d.ts +8 -0
  43. package/dist/docx/recoveryStore.js +208 -0
  44. package/dist/docx/recoveryStore.js.map +7 -0
  45. package/dist/docx/temporaryRecovery.d.ts +8 -0
  46. package/dist/docx/temporaryRecovery.js +37 -0
  47. package/dist/docx/temporaryRecovery.js.map +7 -0
  48. package/dist/index.cjs +72 -72
  49. package/dist/styles.css +1 -1
  50. package/dist/vite/index.cjs +11 -1
  51. package/dist/vite/index.cjs.map +1 -1
  52. package/dist/vite/index.d.ts +13 -0
  53. package/dist/vite/index.js +11 -1
  54. package/dist/vite/index.js.map +1 -1
  55. package/dist/workflow-canvas/index.cjs +10 -10
  56. package/node_modules/@arbidocs/coedit/dist/commands.cjs +18 -1
  57. package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -1
  58. package/node_modules/@arbidocs/coedit/dist/commands.d.cts +2 -2
  59. package/node_modules/@arbidocs/coedit/dist/commands.d.ts +2 -2
  60. package/node_modules/@arbidocs/coedit/dist/commands.js +18 -1
  61. package/node_modules/@arbidocs/coedit/dist/commands.js.map +1 -1
  62. package/node_modules/@arbidocs/coedit/dist/{port-BbN5OZHx.d.cts → port-DXBNxZYw.d.cts} +2 -0
  63. package/node_modules/@arbidocs/coedit/dist/{port-BbN5OZHx.d.ts → port-DXBNxZYw.d.ts} +2 -0
  64. package/node_modules/@arbidocs/coedit/dist/server.cjs +16 -0
  65. package/node_modules/@arbidocs/coedit/dist/server.cjs.map +1 -1
  66. package/node_modules/@arbidocs/coedit/dist/server.d.cts +1 -1
  67. package/node_modules/@arbidocs/coedit/dist/server.d.ts +1 -1
  68. package/node_modules/@arbidocs/coedit/dist/server.js +16 -0
  69. package/node_modules/@arbidocs/coedit/dist/server.js.map +1 -1
  70. package/node_modules/@arbidocs/coedit/package.json +2 -2
  71. package/node_modules/@docx-editor.dev/core/README.md +25 -1
  72. package/node_modules/@docx-editor.dev/core/THIRD_PARTY_NOTICES.md +1 -0
  73. package/node_modules/@docx-editor.dev/core/dist/automation.cjs +1 -1
  74. package/node_modules/@docx-editor.dev/core/dist/automation.d.ts +21 -63
  75. package/node_modules/@docx-editor.dev/core/dist/automation.js +1 -1
  76. package/node_modules/@docx-editor.dev/core/dist/binding.cjs +1 -1
  77. package/node_modules/@docx-editor.dev/core/dist/binding.d.ts +49 -40
  78. package/node_modules/@docx-editor.dev/core/dist/binding.js +1 -1
  79. package/node_modules/@docx-editor.dev/core/dist/{chrome-print-CAs51cpq.d.ts → chrome-print-CrPI9ZQc.d.ts} +714 -290
  80. package/node_modules/@docx-editor.dev/core/dist/chunk-23MKR33J.js +4 -0
  81. package/node_modules/@docx-editor.dev/core/dist/chunk-2CWQY27B.cjs +1 -0
  82. package/node_modules/@docx-editor.dev/core/dist/chunk-2DEY5NUC.cjs +32 -0
  83. package/node_modules/@docx-editor.dev/core/dist/chunk-2DR4TH6B.js +1 -0
  84. package/node_modules/@docx-editor.dev/core/dist/chunk-2F2UEAE2.js +2 -0
  85. package/node_modules/@docx-editor.dev/core/dist/chunk-2GPGAFOJ.cjs +5 -0
  86. package/node_modules/@docx-editor.dev/core/dist/chunk-ALD626VU.cjs +2 -0
  87. package/node_modules/@docx-editor.dev/core/dist/chunk-AU33YWEJ.js +236 -0
  88. package/node_modules/@docx-editor.dev/core/dist/chunk-AXU63LYW.cjs +1 -0
  89. package/node_modules/@docx-editor.dev/core/dist/chunk-CM5VZRBV.js +32 -0
  90. package/node_modules/@docx-editor.dev/core/dist/chunk-D7FAFFTN.js +1 -0
  91. package/node_modules/@docx-editor.dev/core/dist/chunk-DYUVJNDD.cjs +1 -0
  92. package/node_modules/@docx-editor.dev/core/dist/chunk-ESYUKD5D.js +2 -0
  93. package/node_modules/@docx-editor.dev/core/dist/chunk-F7TGQMVR.js +5 -0
  94. package/node_modules/@docx-editor.dev/core/dist/chunk-FLW7KIQX.js +30 -0
  95. package/node_modules/@docx-editor.dev/core/dist/chunk-JG4A6W6I.js +7 -0
  96. package/node_modules/@docx-editor.dev/core/dist/chunk-JNGLSBPH.js +2 -0
  97. package/node_modules/@docx-editor.dev/core/dist/chunk-KE6ZWRIY.cjs +236 -0
  98. package/node_modules/@docx-editor.dev/core/dist/chunk-L3YXJDPX.js +1 -0
  99. package/node_modules/@docx-editor.dev/core/dist/chunk-LI42N7OW.cjs +4 -0
  100. package/node_modules/@docx-editor.dev/core/dist/chunk-PLKDS4JT.js +1 -0
  101. package/node_modules/@docx-editor.dev/core/dist/chunk-PXMTQ73F.cjs +2 -0
  102. package/node_modules/@docx-editor.dev/core/dist/chunk-R4R3AAE4.js +1 -0
  103. package/node_modules/@docx-editor.dev/core/dist/chunk-RFUNFTGV.cjs +1 -0
  104. package/node_modules/@docx-editor.dev/core/dist/chunk-SVM6PGMS.js +3 -0
  105. package/node_modules/@docx-editor.dev/core/dist/chunk-SZURLHR3.cjs +3 -0
  106. package/node_modules/@docx-editor.dev/core/dist/chunk-UYCGCVZ2.cjs +1 -0
  107. package/node_modules/@docx-editor.dev/core/dist/chunk-WN7ICTA5.js +1 -0
  108. package/node_modules/@docx-editor.dev/core/dist/chunk-X34QRAUU.cjs +1 -0
  109. package/node_modules/@docx-editor.dev/core/dist/chunk-XNBYG4XJ.cjs +30 -0
  110. package/node_modules/@docx-editor.dev/core/dist/chunk-ZDFJW5XS.cjs +2 -0
  111. package/node_modules/@docx-editor.dev/core/dist/chunk-ZWO4JHNN.cjs +7 -0
  112. package/node_modules/@docx-editor.dev/core/dist/collaboration/replication.cjs +1 -1
  113. package/node_modules/@docx-editor.dev/core/dist/collaboration/replication.d.ts +29 -5
  114. package/node_modules/@docx-editor.dev/core/dist/collaboration/replication.js +1 -1
  115. package/node_modules/@docx-editor.dev/core/dist/collaboration.cjs +1 -1
  116. package/node_modules/@docx-editor.dev/core/dist/collaboration.d.ts +5 -6
  117. package/node_modules/@docx-editor.dev/core/dist/collaboration.js +1 -1
  118. package/node_modules/@docx-editor.dev/core/dist/contracts/document.d.ts +3 -3
  119. package/node_modules/@docx-editor.dev/core/dist/contracts/editor.d.ts +13 -10
  120. package/node_modules/@docx-editor.dev/core/dist/contracts/interaction.d.ts +2 -2
  121. package/node_modules/@docx-editor.dev/core/dist/contracts/modules.d.ts +15 -13
  122. package/node_modules/@docx-editor.dev/core/dist/contracts/types.d.ts +135 -2
  123. package/node_modules/@docx-editor.dev/core/dist/{custom-node-writes-Bn6uciLb.d.ts → custom-node-writes-AqY5KpVx.d.ts} +7 -2
  124. package/node_modules/@docx-editor.dev/core/dist/diagnostic-context-CuzhOX0g.d.ts +98 -0
  125. package/node_modules/@docx-editor.dev/core/dist/{diagnostic-hints-BeVjfNOv.d.ts → diagnostic-hints-BtCaCqQC.d.ts} +14 -7
  126. package/node_modules/@docx-editor.dev/core/dist/{document-protection-CUb55pl_.d.ts → document-protection-BvbpSXbQ.d.ts} +1 -1
  127. package/node_modules/@docx-editor.dev/core/dist/drawing-graphic-kind-CXYGYbB3.d.ts +324 -0
  128. package/node_modules/@docx-editor.dev/core/dist/drawing-preview-package-B9lSLRg4.d.ts +115 -0
  129. package/node_modules/@docx-editor.dev/core/dist/{editor-CZQZmTIU.d.ts → editor-B7OOAAie.d.ts} +536 -283
  130. package/node_modules/@docx-editor.dev/core/dist/editor-fonts-D_-vjuJi.d.ts +53 -0
  131. package/node_modules/@docx-editor.dev/core/dist/editor-scope-CA6egMaK.d.ts +141 -0
  132. package/node_modules/@docx-editor.dev/core/dist/editor.cjs +1 -1
  133. package/node_modules/@docx-editor.dev/core/dist/editor.css +6 -4
  134. package/node_modules/@docx-editor.dev/core/dist/editor.d.ts +834 -34
  135. package/node_modules/@docx-editor.dev/core/dist/editor.js +1 -1
  136. package/node_modules/@docx-editor.dev/core/dist/export.cjs +2 -2
  137. package/node_modules/@docx-editor.dev/core/dist/export.d.ts +52 -21
  138. package/node_modules/@docx-editor.dev/core/dist/export.js +2 -2
  139. package/node_modules/@docx-editor.dev/core/dist/{failure-NS2lsya4.d.ts → failure-6KGFrDO9.d.ts} +1 -1
  140. package/node_modules/@docx-editor.dev/core/dist/{font-resolver-lSBLirLR.d.ts → font-resolver-Bm9XqTNO.d.ts} +15 -1
  141. package/node_modules/@docx-editor.dev/core/dist/font-shaping-policy-BvpkrfxM.d.ts +7 -0
  142. package/node_modules/@docx-editor.dev/core/dist/index.cjs +1 -1
  143. package/node_modules/@docx-editor.dev/core/dist/index.d.ts +44 -27
  144. package/node_modules/@docx-editor.dev/core/dist/index.js +1 -1
  145. package/node_modules/@docx-editor.dev/core/dist/{layout-shaping-BD-dF_rn.d.ts → layout-shaping-Ci_BTnSU.d.ts} +3 -2
  146. package/node_modules/@docx-editor.dev/core/dist/layout.cjs +1 -1
  147. package/node_modules/@docx-editor.dev/core/dist/layout.d.ts +276 -126
  148. package/node_modules/@docx-editor.dev/core/dist/layout.js +1 -1
  149. package/node_modules/@docx-editor.dev/core/dist/metafile-drawing-DtMFyMKq.d.ts +107 -0
  150. package/node_modules/@docx-editor.dev/core/dist/{note-properties-qQUjO1GQ.d.ts → note-properties-DCIJUKIy.d.ts} +1 -1
  151. package/node_modules/@docx-editor.dev/core/dist/output.cjs +1 -1
  152. package/node_modules/@docx-editor.dev/core/dist/output.d.ts +24 -10
  153. package/node_modules/@docx-editor.dev/core/dist/output.js +1 -1
  154. package/node_modules/@docx-editor.dev/core/dist/{protocol-DYzzz2ej.d.ts → protocol-Cp_QzVxS.d.ts} +167 -5
  155. package/node_modules/@docx-editor.dev/core/dist/{review-paragraph-order-CN_0l2Cb.d.ts → review-paragraph-order-BJQ43_r0.d.ts} +1 -1
  156. package/node_modules/@docx-editor.dev/core/dist/revision-projection-OVusTS77.d.ts +258 -0
  157. package/node_modules/@docx-editor.dev/core/dist/{semantic-cell-selection-eYag3P47.d.ts → semantic-cell-selection-CoI5hHBm.d.ts} +2 -2
  158. package/node_modules/@docx-editor.dev/core/dist/{semantic-interaction-kR_QB845.d.ts → semantic-interaction-BbA4dgEo.d.ts} +1 -1
  159. package/node_modules/@docx-editor.dev/core/dist/{semantic-paint-ZayFF3tD.d.ts → semantic-paint-B5JcIv9c.d.ts} +19 -9
  160. package/node_modules/@docx-editor.dev/core/dist/{semantic-record-queries-Bsgth6lv.d.ts → semantic-record-queries-DnO8J5_j.d.ts} +1 -1
  161. package/node_modules/@docx-editor.dev/core/dist/{semantic-records-DQmumPgL.d.ts → semantic-records-DoK0lNjS.d.ts} +697 -608
  162. package/node_modules/@docx-editor.dev/core/dist/store.cjs +1 -1
  163. package/node_modules/@docx-editor.dev/core/dist/store.d.ts +527 -123
  164. package/node_modules/@docx-editor.dev/core/dist/store.js +1 -1
  165. package/node_modules/@docx-editor.dev/core/dist/{types-barrel-DuC5QBNC.d.ts → tree-op-types-Df4oY2u4.d.ts} +1723 -765
  166. package/node_modules/@docx-editor.dev/core/dist/{tree-package-store-CovjNARF.d.ts → tree-package-store-DXhX1PE-.d.ts} +617 -428
  167. package/node_modules/@docx-editor.dev/core/dist/{tree-session-contract-CZVAGl51.d.ts → tree-session-contract-CF2625mv.d.ts} +28 -13
  168. package/node_modules/@docx-editor.dev/core/dist/unsupported-elements-CUojsaCr.d.ts +23 -0
  169. package/node_modules/@docx-editor.dev/core/docs/accept-reject-without-scrolling.md +95 -0
  170. package/node_modules/@docx-editor.dev/core/docs/comment-on-found-text.md +72 -0
  171. package/node_modules/@docx-editor.dev/core/docs/custom-review-cards.md +178 -0
  172. package/node_modules/@docx-editor.dev/core/docs/highlight-ranges.md +48 -0
  173. package/node_modules/@docx-editor.dev/core/docs/index.md +36 -0
  174. package/node_modules/@docx-editor.dev/core/docs/propose-rewrite.md +247 -0
  175. package/node_modules/@docx-editor.dev/core/docs/tracked-replacement.md +68 -0
  176. package/node_modules/@docx-editor.dev/core/licenses/ECMA-376.md +29 -0
  177. package/node_modules/@docx-editor.dev/core/package.json +3 -2
  178. package/node_modules/@docx-editor.dev/react/README.md +71 -0
  179. package/node_modules/@docx-editor.dev/react/dist/index.d.mts +936 -86
  180. package/node_modules/@docx-editor.dev/react/dist/index.d.ts +936 -86
  181. package/node_modules/@docx-editor.dev/react/dist/index.js +3 -3
  182. package/node_modules/@docx-editor.dev/react/dist/index.mjs +3 -3
  183. package/node_modules/@docx-editor.dev/react/docs/accept-reject-without-scrolling.md +72 -0
  184. package/node_modules/@docx-editor.dev/react/docs/comment-on-found-text.md +47 -0
  185. package/node_modules/@docx-editor.dev/react/docs/custom-review-cards.md +105 -0
  186. package/node_modules/@docx-editor.dev/react/docs/highlight-ranges.md +25 -0
  187. package/node_modules/@docx-editor.dev/react/docs/index.md +36 -0
  188. package/node_modules/@docx-editor.dev/react/docs/propose-rewrite.md +247 -0
  189. package/node_modules/@docx-editor.dev/react/docs/tracked-replacement.md +45 -0
  190. package/node_modules/@docx-editor.dev/react/package.json +4 -3
  191. package/package.json +8 -8
  192. package/src/docx/styles.css +37 -7
  193. package/dist/chunk-KWD5Q4XH.cjs +0 -18
  194. package/dist/chunk-T2DUNNYY.cjs.map +0 -1
  195. package/dist/chunk-UOZ237OW.cjs.map +0 -1
  196. package/dist/chunk-V6SFJ44C.cjs.map +0 -1
  197. package/node_modules/@docx-editor.dev/core/dist/chunk-236O4YQW.js +0 -2
  198. package/node_modules/@docx-editor.dev/core/dist/chunk-6JIJOZDW.js +0 -1
  199. package/node_modules/@docx-editor.dev/core/dist/chunk-6JPL6ZAS.cjs +0 -5
  200. package/node_modules/@docx-editor.dev/core/dist/chunk-6ZQP4HQ7.js +0 -3
  201. package/node_modules/@docx-editor.dev/core/dist/chunk-7WQ7AAHW.cjs +0 -2
  202. package/node_modules/@docx-editor.dev/core/dist/chunk-BCXH4BXB.js +0 -5
  203. package/node_modules/@docx-editor.dev/core/dist/chunk-BTQKU64Q.cjs +0 -1
  204. package/node_modules/@docx-editor.dev/core/dist/chunk-BY2ACZZ6.cjs +0 -1
  205. package/node_modules/@docx-editor.dev/core/dist/chunk-CAJEXXVG.cjs +0 -4
  206. package/node_modules/@docx-editor.dev/core/dist/chunk-CPWLFPWC.js +0 -30
  207. package/node_modules/@docx-editor.dev/core/dist/chunk-D7ZMDMPX.cjs +0 -3
  208. package/node_modules/@docx-editor.dev/core/dist/chunk-DOHF6FA7.cjs +0 -30
  209. package/node_modules/@docx-editor.dev/core/dist/chunk-DVX32P2P.js +0 -27
  210. package/node_modules/@docx-editor.dev/core/dist/chunk-E4LOMDNL.js +0 -1
  211. package/node_modules/@docx-editor.dev/core/dist/chunk-EKLM7NWB.cjs +0 -7
  212. package/node_modules/@docx-editor.dev/core/dist/chunk-G3K63G7P.cjs +0 -27
  213. package/node_modules/@docx-editor.dev/core/dist/chunk-G4HOFIKJ.js +0 -1
  214. package/node_modules/@docx-editor.dev/core/dist/chunk-JLVBDYVQ.cjs +0 -2
  215. package/node_modules/@docx-editor.dev/core/dist/chunk-LQX36Z5P.js +0 -7
  216. package/node_modules/@docx-editor.dev/core/dist/chunk-LSZ6KPKK.js +0 -1
  217. package/node_modules/@docx-editor.dev/core/dist/chunk-MM5QBMTE.cjs +0 -1
  218. package/node_modules/@docx-editor.dev/core/dist/chunk-OMCG63ZF.js +0 -1
  219. package/node_modules/@docx-editor.dev/core/dist/chunk-OSFOJTHU.cjs +0 -18
  220. package/node_modules/@docx-editor.dev/core/dist/chunk-RCLZXP3B.js +0 -2
  221. package/node_modules/@docx-editor.dev/core/dist/chunk-T6K2QYNZ.cjs +0 -2
  222. package/node_modules/@docx-editor.dev/core/dist/chunk-TRGAVV2Y.js +0 -4
  223. package/node_modules/@docx-editor.dev/core/dist/chunk-U4JZVSOE.js +0 -2
  224. package/node_modules/@docx-editor.dev/core/dist/chunk-UHHYFIDT.cjs +0 -1
  225. package/node_modules/@docx-editor.dev/core/dist/chunk-W35WTWAO.cjs +0 -1
  226. package/node_modules/@docx-editor.dev/core/dist/chunk-YQ5G6LC7.js +0 -18
  227. package/node_modules/@docx-editor.dev/core/dist/diagnostic-context-B8M79cfK.d.ts +0 -30
  228. package/node_modules/@docx-editor.dev/core/dist/editor-scope-7o9xweiJ.d.ts +0 -84
  229. package/node_modules/@docx-editor.dev/core/dist/headless-document-view-pp3q7wIh.d.ts +0 -143
  230. package/node_modules/@docx-editor.dev/core/dist/image-resources-tXLQShoC.d.ts +0 -211
  231. package/node_modules/@docx-editor.dev/core/dist/omml-equation-BUbU0utM.d.ts +0 -85
@@ -8,13 +8,20 @@ import {
8
8
  DocxCommentActivity
9
9
  } from "./DocxMentions.js";
10
10
  import * as Y from "yjs";
11
+ import { materializeBytes } from "@arbidocs/coedit/encoding";
12
+ import { createRecoveryStore } from "./recoveryStore.js";
13
+ import { createTemporaryRecoveryStore } from "./temporaryRecovery.js";
11
14
  import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
12
15
  import {
13
16
  DocxEditor,
14
17
  useChromeTranslate,
15
18
  useDocxEditor
16
19
  } from "@docx-editor.dev/react";
17
- import { collaborationModule, DOCUMENT_COLLABORATION_VERSIONS } from "@arbidocs/coedit";
20
+ import {
21
+ collaborationModule,
22
+ DOCUMENT_COLLABORATION_VERSIONS,
23
+ formatRefusal
24
+ } from "@arbidocs/coedit";
18
25
  import { awaitMatchingEditor } from "./coedit-update.js";
19
26
  import {
20
27
  createHocuspocusCollaboration
@@ -69,6 +76,20 @@ import { HouseTemplatePanel } from "./template/HouseTemplatePanel.js";
69
76
  import { DocxAuthorContext } from "./structural/useTrackedOrNoted.js";
70
77
  import { contentPath } from "./content-path.js";
71
78
  const drafts = /* @__PURE__ */ new Map();
79
+ const pendingRecoveryWrites = /* @__PURE__ */ new Map();
80
+ const failedRecoveryWrites = /* @__PURE__ */ new Set();
81
+ const unretainedRecoveryFailures = /* @__PURE__ */ new Set();
82
+ const MEMORY_RECOVERY_LIMIT = 32 * 1024 * 1024;
83
+ const memoryRecovery = createTemporaryRecoveryStore(MEMORY_RECOVERY_LIMIT);
84
+ const warnMemoryRecovery = (event) => event.preventDefault();
85
+ const recoveryKey = (workspace, doc, key) => `${workspace}\0${doc}\0${Array.from(key, (b) => b.toString(16).padStart(2, "0")).join("")}`;
86
+ const memoryKey = (scope, workspace, doc, key) => scope ? `scope\0${scope}\0${doc}` : recoveryKey(workspace, doc, key);
87
+ function retainMemoryRecovery(key, bytes) {
88
+ const empty = memoryRecovery.size === 0;
89
+ if (!memoryRecovery.add(key, bytes)) return false;
90
+ if (empty) window.addEventListener("beforeunload", warnMemoryRecovery);
91
+ return true;
92
+ }
72
93
  const stateBytes = (room) => Y.encodeStateAsUpdate(room.ydoc);
73
94
  const encodeState = (room) => {
74
95
  let binary = "";
@@ -264,7 +285,8 @@ function NativeDocxEditor({
264
285
  adapter,
265
286
  compact = false,
266
287
  stateRef,
267
- saveRef
288
+ saveRef,
289
+ leaveRef
268
290
  }) {
269
291
  const [ready, setReady] = useState(), [error, setError] = useState(""), [retry, setRetry] = useState(0);
270
292
  const [status, setStatus] = useState("Connecting\u2026"), [dirty, setDirty] = useState(false), [saving, setSaving] = useState(false), [offline, setOffline] = useState(false);
@@ -275,6 +297,30 @@ function NativeDocxEditor({
275
297
  const fitting = useRef(true), fitted = useRef(void 0);
276
298
  const [fitWidth, setFitWidth] = useState(true), [zoomPercent, setZoomPercent] = useState(100);
277
299
  const ref = useRef(null), dirtyRef = useRef(false), draftTimer = useRef(void 0);
300
+ const acknowledgedStateRef = useRef(void 0);
301
+ const [recoveryCopies, setRecoveryCopies] = useState([]);
302
+ const [memoryCopies, setMemoryCopies] = useState([]);
303
+ const [recoveryWarning, setRecoveryWarning] = useState("");
304
+ const recoveryRef = useRef(null);
305
+ const unmountRecoveryRef = useRef(void 0);
306
+ const checkpointedStateRef = useRef(void 0);
307
+ const proactiveTimerRef = useRef(void 0);
308
+ const proactiveCopyRef = useRef(void 0);
309
+ const proactiveGenerationRef = useRef(0);
310
+ const currentRecovery = async () => {
311
+ if (adapter.recoveryIsCurrent && !adapter.recoveryIsCurrent())
312
+ throw new Error("The signed-in recovery identity changed.");
313
+ const saved = recoveryRef.current, identity = await adapter.recoveryIdentity?.();
314
+ if (!identity) throw new Error("Recovery identity is unavailable.");
315
+ if (!saved) {
316
+ identity.keypair.secretKey.fill(0);
317
+ throw new Error("Recovery identity is unavailable.");
318
+ }
319
+ const same = identity.workspaceId === saved.workspaceId && identity.keypair.publicKey.length === saved.publicKey.length && identity.keypair.publicKey.every((byte, index) => byte === saved.publicKey[index]);
320
+ identity.keypair.secretKey.fill(0);
321
+ if (!same) throw new Error("The signed-in recovery identity changed.");
322
+ return saved;
323
+ };
278
324
  const isDraft = draftContent !== void 0;
279
325
  const streamRef = useRef(stream);
280
326
  streamRef.current = stream;
@@ -313,6 +359,7 @@ function NativeDocxEditor({
313
359
  useEffect(() => () => clearTimeout(streamTimer.current), []);
314
360
  useEffect(() => {
315
361
  let cancelled = false;
362
+ let recoveryInvalidated = false;
316
363
  let room;
317
364
  const cleanups = [];
318
365
  setReady(void 0);
@@ -320,6 +367,92 @@ function NativeDocxEditor({
320
367
  setStatus("Connecting\u2026");
321
368
  setDirty(false);
322
369
  dirtyRef.current = false;
370
+ setRecoveryCopies([]);
371
+ setMemoryCopies([]);
372
+ setRecoveryWarning("");
373
+ acknowledgedStateRef.current = void 0;
374
+ checkpointedStateRef.current = void 0;
375
+ proactiveCopyRef.current = void 0;
376
+ proactiveGenerationRef.current += 1;
377
+ if (adapter.onRecoveryInvalidated)
378
+ cleanups.push(
379
+ adapter.onRecoveryInvalidated(() => {
380
+ if (recoveryInvalidated) return;
381
+ recoveryInvalidated = true;
382
+ const recovery = recoveryRef.current;
383
+ if (recovery) {
384
+ try {
385
+ if (!room || !flushInputRef.current) throw new Error("Editor input is unavailable");
386
+ flushInputRef.current();
387
+ runBeforeSave(ref.current);
388
+ room.session.flushPendingJournals();
389
+ const bytes = stateBytes(room), confirmed = acknowledgedStateRef.current, checkpointed = checkpointedStateRef.current;
390
+ const same = (other) => !!other && other.length === bytes.length && other.every((byte, index) => byte === bytes[index]);
391
+ if (!same(confirmed) && !same(checkpointed)) {
392
+ const key = memoryKey(
393
+ adapter.recoveryScope,
394
+ recovery.workspaceId,
395
+ documentId,
396
+ recovery.publicKey
397
+ );
398
+ failedRecoveryWrites.add(
399
+ recoveryKey(recovery.workspaceId, documentId, recovery.publicKey)
400
+ );
401
+ if (retainMemoryRecovery(key, bytes)) {
402
+ checkpointedStateRef.current = bytes;
403
+ adapter.notify?.(
404
+ "A recovery copy is held only in this tab for the previous account or workspace.",
405
+ "error"
406
+ );
407
+ } else {
408
+ unretainedRecoveryFailures.add(
409
+ recoveryKey(recovery.workspaceId, documentId, recovery.publicKey)
410
+ );
411
+ adapter.notify?.(
412
+ "The temporary recovery buffer is full. Local changes could not be retained.",
413
+ "error"
414
+ );
415
+ }
416
+ }
417
+ } catch {
418
+ adapter.notify?.(
419
+ "Local changes could not be prepared for account or workspace switching.",
420
+ "error"
421
+ );
422
+ }
423
+ recoveryRef.current = null;
424
+ void recovery.store.close();
425
+ } else if (room && flushInputRef.current && adapter.recoveryScope) {
426
+ try {
427
+ flushInputRef.current();
428
+ runBeforeSave(ref.current);
429
+ room.session.flushPendingJournals();
430
+ const bytes = stateBytes(room), confirmed = acknowledgedStateRef.current;
431
+ if (!confirmed || confirmed.length !== bytes.length || confirmed.some((byte, index) => byte !== bytes[index])) {
432
+ const key = memoryKey(adapter.recoveryScope, "", documentId, new Uint8Array());
433
+ if (retainMemoryRecovery(key, bytes)) {
434
+ checkpointedStateRef.current = bytes;
435
+ adapter.notify?.(
436
+ "A recovery copy is held only in this tab for the previous account or workspace.",
437
+ "error"
438
+ );
439
+ } else
440
+ adapter.notify?.(
441
+ "The temporary recovery buffer is full. Local changes could not be retained.",
442
+ "error"
443
+ );
444
+ }
445
+ } catch {
446
+ adapter.notify?.(
447
+ "Local changes could not be prepared for account or workspace switching.",
448
+ "error"
449
+ );
450
+ }
451
+ }
452
+ setRecoveryCopies([]);
453
+ setMemoryCopies([]);
454
+ })
455
+ );
323
456
  const updating = (reason) => {
324
457
  const cancel = awaitMatchingEditor(reason, () => setRetry((x) => x + 1));
325
458
  if (!cancel) return false;
@@ -379,11 +512,58 @@ function NativeDocxEditor({
379
512
  return;
380
513
  }
381
514
  const current = room;
515
+ if (adapter.recoveryIdentity) {
516
+ void adapter.recoveryIdentity().then(async (identity) => {
517
+ if (!identity) return;
518
+ const publicKey = identity.keypair.publicKey.slice(), store = createRecoveryStore(identity.keypair);
519
+ identity.keypair.secretKey.fill(0);
520
+ if (cancelled || recoveryInvalidated || adapter.recoveryIsCurrent && !adapter.recoveryIsCurrent()) {
521
+ await store.close();
522
+ return;
523
+ }
524
+ recoveryRef.current = { store, workspaceId: identity.workspaceId, publicKey };
525
+ try {
526
+ const key = recoveryKey(identity.workspaceId, documentId, publicKey);
527
+ while (pendingRecoveryWrites.get(key)?.size)
528
+ await Promise.all([...pendingRecoveryWrites.get(key)]);
529
+ if (!cancelled)
530
+ setMemoryCopies(
531
+ memoryRecovery.list(
532
+ memoryKey(adapter.recoveryScope, identity.workspaceId, documentId, publicKey)
533
+ )
534
+ );
535
+ if (!cancelled && failedRecoveryWrites.has(key))
536
+ setError(
537
+ "A local recovery copy could not be saved. The prior editor was closed before storage succeeded."
538
+ );
539
+ const copies = await store.list(identity.workspaceId, documentId);
540
+ if (!cancelled) setRecoveryCopies(copies);
541
+ } catch {
542
+ if (!cancelled)
543
+ setRecoveryWarning(
544
+ "Local recovery storage is unavailable. Download your DOCX before leaving if it has unsaved changes."
545
+ );
546
+ }
547
+ }).catch(() => {
548
+ if (!cancelled)
549
+ setRecoveryWarning(
550
+ "Local recovery storage is unavailable. Download your DOCX before leaving if it has unsaved changes."
551
+ );
552
+ });
553
+ }
554
+ acknowledgedStateRef.current = stateBytes(current);
382
555
  cleanups.push(
383
556
  current.session.subscribeStatus((s, _reason, detail) => {
384
- const disconnected = s === "disconnected";
557
+ const disconnected = s === "disconnected" || s === "error";
385
558
  setOffline(disconnected);
386
559
  if (s === "error") {
560
+ if (formatRefusal(detail)) {
561
+ setError(
562
+ "The editor and collaboration server need matching versions. Download your DOCX before reloading to preserve any local edits."
563
+ );
564
+ setStatus("Update required");
565
+ return;
566
+ }
387
567
  if (updating(detail)) return;
388
568
  setError(
389
569
  detail || "The collaboration session failed. Export your local document before reconnecting."
@@ -401,6 +581,7 @@ function NativeDocxEditor({
401
581
  const message = JSON.parse(payload);
402
582
  if (message.type === "persisted") {
403
583
  if (!cancelled && message.vector && message.receipt && covered(current, message.vector, message.receipt)) {
584
+ acknowledgedStateRef.current = stateBytes(current);
404
585
  dirtyRef.current = false;
405
586
  setDirty(false);
406
587
  setStatus("All changes saved");
@@ -445,10 +626,115 @@ function NativeDocxEditor({
445
626
  cancelled = true;
446
627
  cleanups.forEach((f) => f());
447
628
  clearTimeout(draftTimer.current);
629
+ clearTimeout(proactiveTimerRef.current);
448
630
  fitCleanup.current?.();
631
+ const recovery = recoveryRef.current;
632
+ recoveryRef.current = null;
633
+ if (recovery) {
634
+ const pending = unmountRecoveryRef.current;
635
+ unmountRecoveryRef.current = void 0;
636
+ if (pending)
637
+ void pending.then(
638
+ () => recovery.store.close(),
639
+ () => recovery.store.close()
640
+ );
641
+ else void recovery.store.close();
642
+ }
449
643
  room?.destroy();
450
644
  };
451
- }, [documentId, isDraft, snapshot, retry]);
645
+ }, [documentId, isDraft, snapshot, retry, adapter.recoveryScope]);
646
+ useLayoutEffect(() => {
647
+ const room = ready?.room;
648
+ return () => {
649
+ const recovery = recoveryRef.current;
650
+ if (!room) return;
651
+ try {
652
+ if (!flushInputRef.current) throw new Error("Editor input is unavailable");
653
+ flushInputRef.current();
654
+ runBeforeSave(ref.current);
655
+ room.session.flushPendingJournals();
656
+ const bytes = stateBytes(room), confirmed = acknowledgedStateRef.current;
657
+ if (confirmed && confirmed.length === bytes.length && confirmed.every((byte, index) => byte === bytes[index]))
658
+ return;
659
+ const checkpointed = checkpointedStateRef.current;
660
+ if (checkpointed && checkpointed.length === bytes.length && checkpointed.every((byte, index) => byte === bytes[index]))
661
+ return;
662
+ if (!recovery) {
663
+ if (!adapter.recoveryScope) throw new Error("Recovery identity is unavailable");
664
+ const retained = retainMemoryRecovery(
665
+ memoryKey(adapter.recoveryScope, "", documentId, new Uint8Array()),
666
+ bytes
667
+ );
668
+ adapter.notify?.(
669
+ retained ? "A recovery copy is held only in this tab. Reopen the document and download it." : "The temporary recovery buffer is full. Local changes could not be retained.",
670
+ "error"
671
+ );
672
+ return;
673
+ }
674
+ const key = recoveryKey(recovery.workspaceId, documentId, recovery.publicKey);
675
+ if (adapter.recoveryIsCurrent && !adapter.recoveryIsCurrent()) {
676
+ failedRecoveryWrites.add(key);
677
+ adapter.notify?.(
678
+ retainMemoryRecovery(
679
+ memoryKey(
680
+ adapter.recoveryScope,
681
+ recovery.workspaceId,
682
+ documentId,
683
+ recovery.publicKey
684
+ ),
685
+ bytes
686
+ ) ? "A recovery copy is held only in this tab. Reopen the document and download it." : "The temporary recovery buffer is full. Local changes could not be retained.",
687
+ "error"
688
+ );
689
+ return;
690
+ }
691
+ const writes = pendingRecoveryWrites.get(key) ?? /* @__PURE__ */ new Set();
692
+ const pending = recovery.store.checkpoint(recovery.workspaceId, documentId, bytes).then(
693
+ () => {
694
+ },
695
+ () => {
696
+ failedRecoveryWrites.add(key);
697
+ if (retainMemoryRecovery(
698
+ memoryKey(
699
+ adapter.recoveryScope,
700
+ recovery.workspaceId,
701
+ documentId,
702
+ recovery.publicKey
703
+ ),
704
+ bytes
705
+ )) {
706
+ adapter.notify?.(
707
+ "A recovery copy is held only in this tab. Reopen the document and download it.",
708
+ "error"
709
+ );
710
+ } else {
711
+ unretainedRecoveryFailures.add(key);
712
+ adapter.notify?.(
713
+ "Recovery storage and the temporary recovery buffer are full. Local changes could not be retained.",
714
+ "error"
715
+ );
716
+ }
717
+ }
718
+ ).finally(() => {
719
+ writes.delete(pending);
720
+ if (!writes.size) pendingRecoveryWrites.delete(key);
721
+ });
722
+ writes.add(pending);
723
+ pendingRecoveryWrites.set(key, writes);
724
+ unmountRecoveryRef.current = pending;
725
+ } catch {
726
+ if (recovery) {
727
+ const key = recoveryKey(recovery.workspaceId, documentId, recovery.publicKey);
728
+ failedRecoveryWrites.add(key);
729
+ unretainedRecoveryFailures.add(key);
730
+ }
731
+ adapter.notify?.(
732
+ "A local recovery copy could not be prepared before the editor closed.",
733
+ "error"
734
+ );
735
+ }
736
+ };
737
+ }, [ready?.room, documentId, adapter.recoveryScope]);
452
738
  useEffect(() => {
453
739
  if (!stateRef) return;
454
740
  const room = ready?.room;
@@ -457,6 +743,43 @@ function NativeDocxEditor({
457
743
  stateRef.current = null;
458
744
  };
459
745
  }, [stateRef, ready?.room]);
746
+ useEffect(() => {
747
+ if (!leaveRef) return;
748
+ leaveRef.current = async () => {
749
+ const room = ready?.room;
750
+ if (!room) return "unchanged";
751
+ try {
752
+ if (!flushInputRef.current) throw new Error("Editor input is not ready.");
753
+ flushInputRef.current();
754
+ runBeforeSave(ref.current);
755
+ room.session.flushPendingJournals();
756
+ const bytes = stateBytes(room), confirmed = acknowledgedStateRef.current;
757
+ if (confirmed && confirmed.length === bytes.length && confirmed.every((byte, index) => byte === bytes[index]))
758
+ return "unchanged";
759
+ const checkpointed = checkpointedStateRef.current;
760
+ if (checkpointed && checkpointed.length === bytes.length && checkpointed.every((byte, index) => byte === bytes[index]))
761
+ return "unchanged";
762
+ const recovery = await currentRecovery();
763
+ await recovery.store.checkpoint(recovery.workspaceId, documentId, bytes);
764
+ await currentRecovery();
765
+ flushInputRef.current();
766
+ room.session.flushPendingJournals();
767
+ const after = stateBytes(room);
768
+ if (bytes.length !== after.length || bytes.some((byte, index) => byte !== after[index]))
769
+ throw new Error("The document changed while preserving it; try again.");
770
+ checkpointedStateRef.current = bytes;
771
+ return "saved";
772
+ } catch (error2) {
773
+ setError(
774
+ error2 instanceof Error ? `${error2.message} Keep this editor open or download your DOCX.` : "Recovery failed. Keep this editor open or download your DOCX."
775
+ );
776
+ return false;
777
+ }
778
+ };
779
+ return () => {
780
+ leaveRef.current = null;
781
+ };
782
+ }, [leaveRef, ready?.room, documentId, adapter]);
460
783
  useEffect(() => {
461
784
  adapter.onDirtyChange?.(dirty);
462
785
  const beforeUnload = (e) => {
@@ -483,6 +806,89 @@ function NativeDocxEditor({
483
806
  a.click();
484
807
  setTimeout(() => URL.revokeObjectURL(url), 5e3);
485
808
  }
809
+ async function downloadRecovery(id) {
810
+ try {
811
+ const recovery = await currentRecovery();
812
+ const state = await recovery.store.load(recovery.workspaceId, documentId, id);
813
+ if (!state) throw new Error("The recovery copy is unavailable.");
814
+ await currentRecovery();
815
+ const doc = new Y.Doc();
816
+ try {
817
+ Y.applyUpdate(doc, state);
818
+ const url = URL.createObjectURL(
819
+ new Blob([materializeBytes(doc)], {
820
+ type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
821
+ })
822
+ );
823
+ const a = document.createElement("a");
824
+ a.href = url;
825
+ a.download = title.replace(/\.[^.]+$/, "") + "-recovery.docx";
826
+ a.click();
827
+ setTimeout(() => URL.revokeObjectURL(url), 5e3);
828
+ } finally {
829
+ doc.destroy();
830
+ }
831
+ } catch (error2) {
832
+ setError(error2 instanceof Error ? error2.message : "Could not open the recovery copy.");
833
+ }
834
+ }
835
+ async function downloadMemoryRecovery(id) {
836
+ try {
837
+ const recovery = await currentRecovery(), key = memoryKey(adapter.recoveryScope, recovery.workspaceId, documentId, recovery.publicKey);
838
+ const state = memoryRecovery.get(key, id);
839
+ if (!state) throw new Error("The temporary recovery copy is unavailable.");
840
+ const doc = new Y.Doc();
841
+ try {
842
+ Y.applyUpdate(doc, state);
843
+ await currentRecovery();
844
+ const url = URL.createObjectURL(
845
+ new Blob([materializeBytes(doc)], {
846
+ type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
847
+ })
848
+ );
849
+ const a = document.createElement("a");
850
+ a.href = url;
851
+ a.download = title.replace(/\.[^.]+$/, "") + "-recovery.docx";
852
+ a.click();
853
+ setTimeout(() => URL.revokeObjectURL(url), 5e3);
854
+ } finally {
855
+ doc.destroy();
856
+ }
857
+ } catch (error2) {
858
+ setError(
859
+ error2 instanceof Error ? error2.message : "Could not open the temporary recovery copy."
860
+ );
861
+ }
862
+ }
863
+ async function removeMemoryRecovery(id) {
864
+ if (!window.confirm("Delete this temporary recovery copy?")) return;
865
+ try {
866
+ const recovery = await currentRecovery(), key = memoryKey(adapter.recoveryScope, recovery.workspaceId, documentId, recovery.publicKey);
867
+ if (!memoryRecovery.remove(key, id))
868
+ throw new Error("The temporary recovery copy is unavailable.");
869
+ const copies = memoryRecovery.list(key);
870
+ const failureKey = recoveryKey(recovery.workspaceId, documentId, recovery.publicKey);
871
+ if (!copies.length && !unretainedRecoveryFailures.has(failureKey))
872
+ failedRecoveryWrites.delete(failureKey);
873
+ if (memoryRecovery.size === 0) window.removeEventListener("beforeunload", warnMemoryRecovery);
874
+ setMemoryCopies(copies);
875
+ } catch (error2) {
876
+ setError(
877
+ error2 instanceof Error ? error2.message : "Could not remove the temporary recovery copy."
878
+ );
879
+ }
880
+ }
881
+ async function removeRecovery(id) {
882
+ if (!window.confirm("Delete this local recovery copy?")) return;
883
+ try {
884
+ const recovery = await currentRecovery();
885
+ await recovery.store.remove(recovery.workspaceId, documentId, id);
886
+ await currentRecovery();
887
+ setRecoveryCopies((copies) => copies.filter((copy) => copy !== id));
888
+ } catch (error2) {
889
+ setError(error2 instanceof Error ? error2.message : "Could not remove the recovery copy.");
890
+ }
891
+ }
486
892
  useLayoutEffect(() => {
487
893
  const editor = ref.current;
488
894
  return () => {
@@ -641,6 +1047,32 @@ function NativeDocxEditor({
641
1047
  setStatus(
642
1048
  isDraft ? "Unsaved note" : offline ? "Offline \xB7 edits buffered locally" : "Saving changes\u2026"
643
1049
  );
1050
+ if (offline && ready?.room && adapter.recoveryIdentity) {
1051
+ clearTimeout(proactiveTimerRef.current);
1052
+ const room = ready.room;
1053
+ const generation = ++proactiveGenerationRef.current;
1054
+ proactiveTimerRef.current = setTimeout(() => {
1055
+ void (async () => {
1056
+ try {
1057
+ if (!flushInputRef.current) throw new Error("Editor input is unavailable.");
1058
+ flushInputRef.current();
1059
+ room.session.flushPendingJournals();
1060
+ const bytes = stateBytes(room), recovery = await currentRecovery();
1061
+ const id = await recovery.store.checkpoint(recovery.workspaceId, documentId, bytes);
1062
+ await currentRecovery();
1063
+ if (generation !== proactiveGenerationRef.current) return;
1064
+ const previous = proactiveCopyRef.current;
1065
+ proactiveCopyRef.current = id;
1066
+ checkpointedStateRef.current = bytes;
1067
+ if (previous) await recovery.store.remove(recovery.workspaceId, documentId, previous);
1068
+ } catch {
1069
+ setError(
1070
+ "A local recovery copy could not be saved. Keep this editor open or download your DOCX."
1071
+ );
1072
+ }
1073
+ })();
1074
+ }, 750);
1075
+ }
644
1076
  if (isDraft) {
645
1077
  clearTimeout(draftTimer.current);
646
1078
  draftTimer.current = setTimeout(() => {
@@ -658,22 +1090,83 @@ function NativeDocxEditor({
658
1090
  "aria-busy": !!stream?.busy,
659
1091
  "data-generation-state": stream ? stream.busy ? "generating" : stream.error ? "stopped" : "generated" : "ready",
660
1092
  children: [
661
- offline && /* @__PURE__ */ jsx("div", { className: "native-docx-notice", children: "Changes are buffered in this browser. Keep this tab open until the connection returns, or download your DOCX." }),
662
- error && /* @__PURE__ */ jsxs("div", { className: "native-docx-notice", "data-error": "true", role: "alert", children: [
663
- error,
664
- " ",
665
- /* @__PURE__ */ jsxs(
666
- "button",
667
- {
668
- disabled: !stream && dirty,
669
- title: dirty ? "Download your unsaved DOCX before reopening the editor" : void 0,
670
- onClick: () => stream ? (setError(""), setStreamAttempt((x) => x + 1)) : setRetry((x) => x + 1),
671
- children: [
672
- /* @__PURE__ */ jsx(RefreshCw, { size: 12 }),
673
- "Retry"
674
- ]
675
- }
676
- )
1093
+ /* @__PURE__ */ jsxs("div", { className: "native-docx-notice-stack", children: [
1094
+ recoveryWarning && /* @__PURE__ */ jsx("div", { className: "native-docx-notice", role: "status", children: recoveryWarning }),
1095
+ recoveryCopies.length > 0 && /* @__PURE__ */ jsxs("div", { className: "native-docx-notice", role: "status", children: [
1096
+ "Local recovery ",
1097
+ recoveryCopies.length === 1 ? "copy" : "copies",
1098
+ " available.",
1099
+ " ",
1100
+ recoveryCopies.map((id, index) => /* @__PURE__ */ jsxs("span", { children: [
1101
+ /* @__PURE__ */ jsxs("button", { onClick: () => void downloadRecovery(id), children: [
1102
+ "Download recovery copy ",
1103
+ index + 1
1104
+ ] }),
1105
+ " ",
1106
+ /* @__PURE__ */ jsxs("button", { onClick: () => void removeRecovery(id), children: [
1107
+ "Delete recovery copy ",
1108
+ index + 1
1109
+ ] }),
1110
+ " "
1111
+ ] }, id))
1112
+ ] }),
1113
+ memoryCopies.length > 0 && /* @__PURE__ */ jsxs("div", { className: "native-docx-notice", role: "status", children: [
1114
+ "Recovery copies held only in this tab will be lost when it closes.",
1115
+ " ",
1116
+ memoryCopies.map((id, index) => /* @__PURE__ */ jsxs("span", { children: [
1117
+ /* @__PURE__ */ jsxs("button", { onClick: () => void downloadMemoryRecovery(id), children: [
1118
+ "Download temporary recovery copy ",
1119
+ index + 1
1120
+ ] }),
1121
+ " ",
1122
+ /* @__PURE__ */ jsxs("button", { onClick: () => void removeMemoryRecovery(id), children: [
1123
+ "Delete temporary recovery copy ",
1124
+ index + 1
1125
+ ] }),
1126
+ " "
1127
+ ] }, id))
1128
+ ] }),
1129
+ offline && /* @__PURE__ */ jsx("div", { className: "native-docx-notice", children: "Changes are buffered in this browser. Keep this tab open until the connection returns, or download your DOCX." }),
1130
+ error && /* @__PURE__ */ jsxs("div", { className: "native-docx-notice", "data-error": "true", role: "alert", children: [
1131
+ error,
1132
+ " ",
1133
+ compact && ready && /* @__PURE__ */ jsx("button", { onClick: () => void exportDocument(), children: "Download DOCX" }),
1134
+ " ",
1135
+ /* @__PURE__ */ jsxs(
1136
+ "button",
1137
+ {
1138
+ disabled: !stream && dirty,
1139
+ title: dirty ? "Download this document before reopening the editor" : void 0,
1140
+ onClick: () => {
1141
+ if (stream) {
1142
+ setError("");
1143
+ setStreamAttempt((x) => x + 1);
1144
+ return;
1145
+ }
1146
+ if (ready?.room) {
1147
+ try {
1148
+ if (!flushInputRef.current) throw new Error("Editor input is not available");
1149
+ flushInputRef.current();
1150
+ ready.room.session.flushPendingJournals();
1151
+ const previous = acknowledgedStateRef.current, current = stateBytes(ready.room);
1152
+ if (!previous || previous.length !== current.length || previous.some((byte, index) => byte !== current[index]))
1153
+ throw new Error("Room has unconfirmed changes");
1154
+ } catch {
1155
+ setError(
1156
+ "This document has changes that are not confirmed saved. Download your DOCX before reloading."
1157
+ );
1158
+ return;
1159
+ }
1160
+ }
1161
+ setRetry((x) => x + 1);
1162
+ },
1163
+ children: [
1164
+ /* @__PURE__ */ jsx(RefreshCw, { size: 12 }),
1165
+ "Retry"
1166
+ ]
1167
+ }
1168
+ )
1169
+ ] })
677
1170
  ] }),
678
1171
  !ready && !error && /* @__PURE__ */ jsx("div", { className: "native-docx-error", role: "status", children: "Opening Word document\u2026" }),
679
1172
  ready && /* @__PURE__ */ jsx("div", { className: "native-docx-body docx-editor", children: /* @__PURE__ */ jsx(EditorBoundary, { children: /* @__PURE__ */ jsx(