@open-mercato/documents 0.6.8-develop.7016.1.4ed7b1e49d

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 (602) hide show
  1. package/README.md +88 -0
  2. package/build.mjs +23 -0
  3. package/dist/index.js +5 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/modules/documents/acl.js +15 -0
  6. package/dist/modules/documents/acl.js.map +7 -0
  7. package/dist/modules/documents/api/[id]/archive/route.js +116 -0
  8. package/dist/modules/documents/api/[id]/archive/route.js.map +7 -0
  9. package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js +155 -0
  10. package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js.map +7 -0
  11. package/dist/modules/documents/api/[id]/attachments/route.js +153 -0
  12. package/dist/modules/documents/api/[id]/attachments/route.js.map +7 -0
  13. package/dist/modules/documents/api/[id]/collab-token/route.js +180 -0
  14. package/dist/modules/documents/api/[id]/collab-token/route.js.map +7 -0
  15. package/dist/modules/documents/api/[id]/comments/access-check/route.js +86 -0
  16. package/dist/modules/documents/api/[id]/comments/access-check/route.js.map +7 -0
  17. package/dist/modules/documents/api/[id]/comments/route.js +387 -0
  18. package/dist/modules/documents/api/[id]/comments/route.js.map +7 -0
  19. package/dist/modules/documents/api/[id]/content/route.js +143 -0
  20. package/dist/modules/documents/api/[id]/content/route.js.map +7 -0
  21. package/dist/modules/documents/api/[id]/duplicate/route.js +200 -0
  22. package/dist/modules/documents/api/[id]/duplicate/route.js.map +7 -0
  23. package/dist/modules/documents/api/[id]/export/route.js +421 -0
  24. package/dist/modules/documents/api/[id]/export/route.js.map +7 -0
  25. package/dist/modules/documents/api/[id]/favorite/route.js +96 -0
  26. package/dist/modules/documents/api/[id]/favorite/route.js.map +7 -0
  27. package/dist/modules/documents/api/[id]/links/[linkId]/route.js +85 -0
  28. package/dist/modules/documents/api/[id]/links/[linkId]/route.js.map +7 -0
  29. package/dist/modules/documents/api/[id]/links/route.js +257 -0
  30. package/dist/modules/documents/api/[id]/links/route.js.map +7 -0
  31. package/dist/modules/documents/api/[id]/principals/route.js +299 -0
  32. package/dist/modules/documents/api/[id]/principals/route.js.map +7 -0
  33. package/dist/modules/documents/api/[id]/route.js +246 -0
  34. package/dist/modules/documents/api/[id]/route.js.map +7 -0
  35. package/dist/modules/documents/api/[id]/shares/route.js +335 -0
  36. package/dist/modules/documents/api/[id]/shares/route.js.map +7 -0
  37. package/dist/modules/documents/api/[id]/unarchive/route.js +39 -0
  38. package/dist/modules/documents/api/[id]/unarchive/route.js.map +7 -0
  39. package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js +133 -0
  40. package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js.map +7 -0
  41. package/dist/modules/documents/api/[id]/versions/[versionId]/route.js +93 -0
  42. package/dist/modules/documents/api/[id]/versions/[versionId]/route.js.map +7 -0
  43. package/dist/modules/documents/api/[id]/versions/route.js +193 -0
  44. package/dist/modules/documents/api/[id]/versions/route.js.map +7 -0
  45. package/dist/modules/documents/api/[id]/watch/route.js +97 -0
  46. package/dist/modules/documents/api/[id]/watch/route.js.map +7 -0
  47. package/dist/modules/documents/api/_commands.js +34 -0
  48. package/dist/modules/documents/api/_commands.js.map +7 -0
  49. package/dist/modules/documents/api/_shared.js +490 -0
  50. package/dist/modules/documents/api/_shared.js.map +7 -0
  51. package/dist/modules/documents/api/folders/route.js +256 -0
  52. package/dist/modules/documents/api/folders/route.js.map +7 -0
  53. package/dist/modules/documents/api/instantiate/route.js +108 -0
  54. package/dist/modules/documents/api/instantiate/route.js.map +7 -0
  55. package/dist/modules/documents/api/route.js +322 -0
  56. package/dist/modules/documents/api/route.js.map +7 -0
  57. package/dist/modules/documents/api/templates/[templateId]/preview/route.js +94 -0
  58. package/dist/modules/documents/api/templates/[templateId]/preview/route.js.map +7 -0
  59. package/dist/modules/documents/api/templates/[templateId]/route.js +82 -0
  60. package/dist/modules/documents/api/templates/[templateId]/route.js.map +7 -0
  61. package/dist/modules/documents/api/templates/route.js +344 -0
  62. package/dist/modules/documents/api/templates/route.js.map +7 -0
  63. package/dist/modules/documents/backend/documents/DocumentsPageClient.js +160 -0
  64. package/dist/modules/documents/backend/documents/DocumentsPageClient.js.map +7 -0
  65. package/dist/modules/documents/backend/documents/DocumentsTable.js +143 -0
  66. package/dist/modules/documents/backend/documents/DocumentsTable.js.map +7 -0
  67. package/dist/modules/documents/backend/documents/FolderDialog.js +55 -0
  68. package/dist/modules/documents/backend/documents/FolderDialog.js.map +7 -0
  69. package/dist/modules/documents/backend/documents/FolderTree.js +40 -0
  70. package/dist/modules/documents/backend/documents/FolderTree.js.map +7 -0
  71. package/dist/modules/documents/backend/documents/MoveDocumentDialog.js +64 -0
  72. package/dist/modules/documents/backend/documents/MoveDocumentDialog.js.map +7 -0
  73. package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js +77 -0
  74. package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js.map +7 -0
  75. package/dist/modules/documents/backend/documents/[id]/CommentComposer.js +126 -0
  76. package/dist/modules/documents/backend/documents/[id]/CommentComposer.js.map +7 -0
  77. package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js +88 -0
  78. package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js.map +7 -0
  79. package/dist/modules/documents/backend/documents/[id]/CommentsRail.js +123 -0
  80. package/dist/modules/documents/backend/documents/[id]/CommentsRail.js.map +7 -0
  81. package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js +91 -0
  82. package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js.map +7 -0
  83. package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js +27 -0
  84. package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js.map +7 -0
  85. package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js +50 -0
  86. package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js.map +7 -0
  87. package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js +168 -0
  88. package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js.map +7 -0
  89. package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js +129 -0
  90. package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js.map +7 -0
  91. package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js +429 -0
  92. package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js.map +7 -0
  93. package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js +68 -0
  94. package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js.map +7 -0
  95. package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js +69 -0
  96. package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js.map +7 -0
  97. package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js +151 -0
  98. package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js.map +7 -0
  99. package/dist/modules/documents/backend/documents/[id]/ExportMenu.js +121 -0
  100. package/dist/modules/documents/backend/documents/[id]/ExportMenu.js.map +7 -0
  101. package/dist/modules/documents/backend/documents/[id]/MentionPicker.js +114 -0
  102. package/dist/modules/documents/backend/documents/[id]/MentionPicker.js.map +7 -0
  103. package/dist/modules/documents/backend/documents/[id]/OutlinePane.js +70 -0
  104. package/dist/modules/documents/backend/documents/[id]/OutlinePane.js.map +7 -0
  105. package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js +157 -0
  106. package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js.map +7 -0
  107. package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js +266 -0
  108. package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js.map +7 -0
  109. package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js +227 -0
  110. package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js.map +7 -0
  111. package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js +157 -0
  112. package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js.map +7 -0
  113. package/dist/modules/documents/backend/documents/[id]/commentTypes.js +150 -0
  114. package/dist/modules/documents/backend/documents/[id]/commentTypes.js.map +7 -0
  115. package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js +13 -0
  116. package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js.map +7 -0
  117. package/dist/modules/documents/backend/documents/[id]/documentPagination.js +295 -0
  118. package/dist/modules/documents/backend/documents/[id]/documentPagination.js.map +7 -0
  119. package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js +81 -0
  120. package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js.map +7 -0
  121. package/dist/modules/documents/backend/documents/[id]/editorTypes.js +52 -0
  122. package/dist/modules/documents/backend/documents/[id]/editorTypes.js.map +7 -0
  123. package/dist/modules/documents/backend/documents/[id]/page.js +10 -0
  124. package/dist/modules/documents/backend/documents/[id]/page.js.map +7 -0
  125. package/dist/modules/documents/backend/documents/[id]/page.meta.js +16 -0
  126. package/dist/modules/documents/backend/documents/[id]/page.meta.js.map +7 -0
  127. package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js +38 -0
  128. package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js.map +7 -0
  129. package/dist/modules/documents/backend/documents/[id]/restoreVersion.js +33 -0
  130. package/dist/modules/documents/backend/documents/[id]/restoreVersion.js.map +7 -0
  131. package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js +392 -0
  132. package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js.map +7 -0
  133. package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js +253 -0
  134. package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js.map +7 -0
  135. package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js +149 -0
  136. package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js.map +7 -0
  137. package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js +82 -0
  138. package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js.map +7 -0
  139. package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js +144 -0
  140. package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js.map +7 -0
  141. package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js +237 -0
  142. package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js.map +7 -0
  143. package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js +216 -0
  144. package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js.map +7 -0
  145. package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js +25 -0
  146. package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js.map +7 -0
  147. package/dist/modules/documents/backend/documents/components/EntityPicker.js +156 -0
  148. package/dist/modules/documents/backend/documents/components/EntityPicker.js.map +7 -0
  149. package/dist/modules/documents/backend/documents/components/EntityPickerResults.js +46 -0
  150. package/dist/modules/documents/backend/documents/components/EntityPickerResults.js.map +7 -0
  151. package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js +127 -0
  152. package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js.map +7 -0
  153. package/dist/modules/documents/backend/documents/components/PrincipalPicker.js +84 -0
  154. package/dist/modules/documents/backend/documents/components/PrincipalPicker.js.map +7 -0
  155. package/dist/modules/documents/backend/documents/components/ShareDialog.js +77 -0
  156. package/dist/modules/documents/backend/documents/components/ShareDialog.js.map +7 -0
  157. package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js +93 -0
  158. package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js.map +7 -0
  159. package/dist/modules/documents/backend/documents/components/ShareDialogList.js +82 -0
  160. package/dist/modules/documents/backend/documents/components/ShareDialogList.js.map +7 -0
  161. package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js +96 -0
  162. package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js.map +7 -0
  163. package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js +169 -0
  164. package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js.map +7 -0
  165. package/dist/modules/documents/backend/documents/components/TemplatePreview.js +38 -0
  166. package/dist/modules/documents/backend/documents/components/TemplatePreview.js.map +7 -0
  167. package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js +69 -0
  168. package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js.map +7 -0
  169. package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js +71 -0
  170. package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js.map +7 -0
  171. package/dist/modules/documents/backend/documents/components/principalPickerModel.js +63 -0
  172. package/dist/modules/documents/backend/documents/components/principalPickerModel.js.map +7 -0
  173. package/dist/modules/documents/backend/documents/components/shareDialogModel.js +68 -0
  174. package/dist/modules/documents/backend/documents/components/shareDialogModel.js.map +7 -0
  175. package/dist/modules/documents/backend/documents/components/templateUi.js +89 -0
  176. package/dist/modules/documents/backend/documents/components/templateUi.js.map +7 -0
  177. package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js +30 -0
  178. package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js.map +7 -0
  179. package/dist/modules/documents/backend/documents/components/useEntitySearch.js +191 -0
  180. package/dist/modules/documents/backend/documents/components/useEntitySearch.js.map +7 -0
  181. package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js +221 -0
  182. package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js.map +7 -0
  183. package/dist/modules/documents/backend/documents/components/useShareDialog.js +236 -0
  184. package/dist/modules/documents/backend/documents/components/useShareDialog.js.map +7 -0
  185. package/dist/modules/documents/backend/documents/components/useTemplateDetail.js +49 -0
  186. package/dist/modules/documents/backend/documents/components/useTemplateDetail.js.map +7 -0
  187. package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js +234 -0
  188. package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js.map +7 -0
  189. package/dist/modules/documents/backend/documents/documentUi.js +106 -0
  190. package/dist/modules/documents/backend/documents/documentUi.js.map +7 -0
  191. package/dist/modules/documents/backend/documents/documentsListTypes.js +132 -0
  192. package/dist/modules/documents/backend/documents/documentsListTypes.js.map +7 -0
  193. package/dist/modules/documents/backend/documents/page.js +9 -0
  194. package/dist/modules/documents/backend/documents/page.js.map +7 -0
  195. package/dist/modules/documents/backend/documents/page.meta.js +26 -0
  196. package/dist/modules/documents/backend/documents/page.meta.js.map +7 -0
  197. package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js +91 -0
  198. package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js.map +7 -0
  199. package/dist/modules/documents/backend/documents/templates/TemplatesTable.js +58 -0
  200. package/dist/modules/documents/backend/documents/templates/TemplatesTable.js.map +7 -0
  201. package/dist/modules/documents/backend/documents/templates/page.js +9 -0
  202. package/dist/modules/documents/backend/documents/templates/page.js.map +7 -0
  203. package/dist/modules/documents/backend/documents/templates/page.meta.js +34 -0
  204. package/dist/modules/documents/backend/documents/templates/page.meta.js.map +7 -0
  205. package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js +139 -0
  206. package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js.map +7 -0
  207. package/dist/modules/documents/backend/documents/useDocumentsList.js +314 -0
  208. package/dist/modules/documents/backend/documents/useDocumentsList.js.map +7 -0
  209. package/dist/modules/documents/ce.js +8 -0
  210. package/dist/modules/documents/ce.js.map +7 -0
  211. package/dist/modules/documents/commands/aggregate.js +99 -0
  212. package/dist/modules/documents/commands/aggregate.js.map +7 -0
  213. package/dist/modules/documents/commands/attachments.js +252 -0
  214. package/dist/modules/documents/commands/attachments.js.map +7 -0
  215. package/dist/modules/documents/commands/comments.js +782 -0
  216. package/dist/modules/documents/commands/comments.js.map +7 -0
  217. package/dist/modules/documents/commands/content.js +238 -0
  218. package/dist/modules/documents/commands/content.js.map +7 -0
  219. package/dist/modules/documents/commands/document-crud.js +505 -0
  220. package/dist/modules/documents/commands/document-crud.js.map +7 -0
  221. package/dist/modules/documents/commands/documents.js +473 -0
  222. package/dist/modules/documents/commands/documents.js.map +7 -0
  223. package/dist/modules/documents/commands/duplicate.js +640 -0
  224. package/dist/modules/documents/commands/duplicate.js.map +7 -0
  225. package/dist/modules/documents/commands/favorites.js +150 -0
  226. package/dist/modules/documents/commands/favorites.js.map +7 -0
  227. package/dist/modules/documents/commands/folders.js +420 -0
  228. package/dist/modules/documents/commands/folders.js.map +7 -0
  229. package/dist/modules/documents/commands/index.js +64 -0
  230. package/dist/modules/documents/commands/index.js.map +7 -0
  231. package/dist/modules/documents/commands/interceptors.js +300 -0
  232. package/dist/modules/documents/commands/interceptors.js.map +7 -0
  233. package/dist/modules/documents/commands/lifecycle.js +249 -0
  234. package/dist/modules/documents/commands/lifecycle.js.map +7 -0
  235. package/dist/modules/documents/commands/links.js +410 -0
  236. package/dist/modules/documents/commands/links.js.map +7 -0
  237. package/dist/modules/documents/commands/mutation-helpers.js +42 -0
  238. package/dist/modules/documents/commands/mutation-helpers.js.map +7 -0
  239. package/dist/modules/documents/commands/projection-types.js +1 -0
  240. package/dist/modules/documents/commands/projection-types.js.map +7 -0
  241. package/dist/modules/documents/commands/shared.js +143 -0
  242. package/dist/modules/documents/commands/shared.js.map +7 -0
  243. package/dist/modules/documents/commands/shares.js +527 -0
  244. package/dist/modules/documents/commands/shares.js.map +7 -0
  245. package/dist/modules/documents/commands/side-effects.js +103 -0
  246. package/dist/modules/documents/commands/side-effects.js.map +7 -0
  247. package/dist/modules/documents/commands/templates.js +461 -0
  248. package/dist/modules/documents/commands/templates.js.map +7 -0
  249. package/dist/modules/documents/commands/versions.js +432 -0
  250. package/dist/modules/documents/commands/versions.js.map +7 -0
  251. package/dist/modules/documents/commands/watchers.js +164 -0
  252. package/dist/modules/documents/commands/watchers.js.map +7 -0
  253. package/dist/modules/documents/data/entities.js +653 -0
  254. package/dist/modules/documents/data/entities.js.map +7 -0
  255. package/dist/modules/documents/data/extensions.js +44 -0
  256. package/dist/modules/documents/data/extensions.js.map +7 -0
  257. package/dist/modules/documents/data/validators.js +219 -0
  258. package/dist/modules/documents/data/validators.js.map +7 -0
  259. package/dist/modules/documents/di.js +35 -0
  260. package/dist/modules/documents/di.js.map +7 -0
  261. package/dist/modules/documents/encryption.js +12 -0
  262. package/dist/modules/documents/encryption.js.map +7 -0
  263. package/dist/modules/documents/events.js +27 -0
  264. package/dist/modules/documents/events.js.map +7 -0
  265. package/dist/modules/documents/index.js +19 -0
  266. package/dist/modules/documents/index.js.map +7 -0
  267. package/dist/modules/documents/lib/attachmentServicePort.js +30 -0
  268. package/dist/modules/documents/lib/attachmentServicePort.js.map +7 -0
  269. package/dist/modules/documents/lib/capabilities.js +32 -0
  270. package/dist/modules/documents/lib/capabilities.js.map +7 -0
  271. package/dist/modules/documents/lib/collabCloseEvents.js +17 -0
  272. package/dist/modules/documents/lib/collabCloseEvents.js.map +7 -0
  273. package/dist/modules/documents/lib/collabEndpoint.js +22 -0
  274. package/dist/modules/documents/lib/collabEndpoint.js.map +7 -0
  275. package/dist/modules/documents/lib/collabMaterializer.js +107 -0
  276. package/dist/modules/documents/lib/collabMaterializer.js.map +7 -0
  277. package/dist/modules/documents/lib/collabToken.js +120 -0
  278. package/dist/modules/documents/lib/collabToken.js.map +7 -0
  279. package/dist/modules/documents/lib/collaborationAwareness.js +68 -0
  280. package/dist/modules/documents/lib/collaborationAwareness.js.map +7 -0
  281. package/dist/modules/documents/lib/commentAnchors.js +15 -0
  282. package/dist/modules/documents/lib/commentAnchors.js.map +7 -0
  283. package/dist/modules/documents/lib/constants.js +25 -0
  284. package/dist/modules/documents/lib/constants.js.map +7 -0
  285. package/dist/modules/documents/lib/contentService.js +248 -0
  286. package/dist/modules/documents/lib/contentService.js.map +7 -0
  287. package/dist/modules/documents/lib/displayLabels.js +23 -0
  288. package/dist/modules/documents/lib/displayLabels.js.map +7 -0
  289. package/dist/modules/documents/lib/docxRenderer.js +601 -0
  290. package/dist/modules/documents/lib/docxRenderer.js.map +7 -0
  291. package/dist/modules/documents/lib/duplicateContent.js +22 -0
  292. package/dist/modules/documents/lib/duplicateContent.js.map +7 -0
  293. package/dist/modules/documents/lib/editorConfig.js +287 -0
  294. package/dist/modules/documents/lib/editorConfig.js.map +7 -0
  295. package/dist/modules/documents/lib/entityLinks.js +148 -0
  296. package/dist/modules/documents/lib/entityLinks.js.map +7 -0
  297. package/dist/modules/documents/lib/entityRegistry.js +258 -0
  298. package/dist/modules/documents/lib/entityRegistry.js.map +7 -0
  299. package/dist/modules/documents/lib/entityRegistry.server.js +189 -0
  300. package/dist/modules/documents/lib/entityRegistry.server.js.map +7 -0
  301. package/dist/modules/documents/lib/entityRegistryAvailability.server.js +9 -0
  302. package/dist/modules/documents/lib/entityRegistryAvailability.server.js.map +7 -0
  303. package/dist/modules/documents/lib/entitySuggestion.js +50 -0
  304. package/dist/modules/documents/lib/entitySuggestion.js.map +7 -0
  305. package/dist/modules/documents/lib/favorites.js +22 -0
  306. package/dist/modules/documents/lib/favorites.js.map +7 -0
  307. package/dist/modules/documents/lib/folderHierarchySerialization.js +19 -0
  308. package/dist/modules/documents/lib/folderHierarchySerialization.js.map +7 -0
  309. package/dist/modules/documents/lib/historyLimits.js +100 -0
  310. package/dist/modules/documents/lib/historyLimits.js.map +7 -0
  311. package/dist/modules/documents/lib/historyPolicy.js +14 -0
  312. package/dist/modules/documents/lib/historyPolicy.js.map +7 -0
  313. package/dist/modules/documents/lib/organizationAccess.js +17 -0
  314. package/dist/modules/documents/lib/organizationAccess.js.map +7 -0
  315. package/dist/modules/documents/lib/pdfHtml.js +62 -0
  316. package/dist/modules/documents/lib/pdfHtml.js.map +7 -0
  317. package/dist/modules/documents/lib/pdfRenderer.js +284 -0
  318. package/dist/modules/documents/lib/pdfRenderer.js.map +7 -0
  319. package/dist/modules/documents/lib/permissions.js +222 -0
  320. package/dist/modules/documents/lib/permissions.js.map +7 -0
  321. package/dist/modules/documents/lib/platformServices.js +35 -0
  322. package/dist/modules/documents/lib/platformServices.js.map +7 -0
  323. package/dist/modules/documents/lib/recordFieldInsertion.js +58 -0
  324. package/dist/modules/documents/lib/recordFieldInsertion.js.map +7 -0
  325. package/dist/modules/documents/lib/requestBody.js +80 -0
  326. package/dist/modules/documents/lib/requestBody.js.map +7 -0
  327. package/dist/modules/documents/lib/resourceLimits.js +62 -0
  328. package/dist/modules/documents/lib/resourceLimits.js.map +7 -0
  329. package/dist/modules/documents/lib/shareCounts.js +25 -0
  330. package/dist/modules/documents/lib/shareCounts.js.map +7 -0
  331. package/dist/modules/documents/lib/templateFill.js +84 -0
  332. package/dist/modules/documents/lib/templateFill.js.map +7 -0
  333. package/dist/modules/documents/lib/templateInstantiation.js +147 -0
  334. package/dist/modules/documents/lib/templateInstantiation.js.map +7 -0
  335. package/dist/modules/documents/lib/templatePreviewDigest.js +82 -0
  336. package/dist/modules/documents/lib/templatePreviewDigest.js.map +7 -0
  337. package/dist/modules/documents/lib/templateSeeds.js +201 -0
  338. package/dist/modules/documents/lib/templateSeeds.js.map +7 -0
  339. package/dist/modules/documents/lib/userLabels.js +37 -0
  340. package/dist/modules/documents/lib/userLabels.js.map +7 -0
  341. package/dist/modules/documents/lib/versionContent.js +131 -0
  342. package/dist/modules/documents/lib/versionContent.js.map +7 -0
  343. package/dist/modules/documents/lib/versionLabels.js +12 -0
  344. package/dist/modules/documents/lib/versionLabels.js.map +7 -0
  345. package/dist/modules/documents/lib/versioning.js +14 -0
  346. package/dist/modules/documents/lib/versioning.js.map +7 -0
  347. package/dist/modules/documents/lib/visibility.js +422 -0
  348. package/dist/modules/documents/lib/visibility.js.map +7 -0
  349. package/dist/modules/documents/lib/watchers.js +106 -0
  350. package/dist/modules/documents/lib/watchers.js.map +7 -0
  351. package/dist/modules/documents/migrations/Migration20260708163836_documents.js +44 -0
  352. package/dist/modules/documents/migrations/Migration20260708163836_documents.js.map +7 -0
  353. package/dist/modules/documents/migrations/Migration20260709164720_documents.js +17 -0
  354. package/dist/modules/documents/migrations/Migration20260709164720_documents.js.map +7 -0
  355. package/dist/modules/documents/migrations/Migration20260710002318_documents.js +32 -0
  356. package/dist/modules/documents/migrations/Migration20260710002318_documents.js.map +7 -0
  357. package/dist/modules/documents/migrations/Migration20260710071003_documents.js +13 -0
  358. package/dist/modules/documents/migrations/Migration20260710071003_documents.js.map +7 -0
  359. package/dist/modules/documents/migrations/Migration20260712120000_documents.js +13 -0
  360. package/dist/modules/documents/migrations/Migration20260712120000_documents.js.map +7 -0
  361. package/dist/modules/documents/migrations/Migration20260712183000_documents.js +14 -0
  362. package/dist/modules/documents/migrations/Migration20260712183000_documents.js.map +7 -0
  363. package/dist/modules/documents/migrations/Migration20260713092156_documents.js +29 -0
  364. package/dist/modules/documents/migrations/Migration20260713092156_documents.js.map +7 -0
  365. package/dist/modules/documents/migrations/Migration20260717000000_documents.js +37 -0
  366. package/dist/modules/documents/migrations/Migration20260717000000_documents.js.map +7 -0
  367. package/dist/modules/documents/notifications.js +47 -0
  368. package/dist/modules/documents/notifications.js.map +7 -0
  369. package/dist/modules/documents/search.js +101 -0
  370. package/dist/modules/documents/search.js.map +7 -0
  371. package/dist/modules/documents/setup.js +19 -0
  372. package/dist/modules/documents/setup.js.map +7 -0
  373. package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js +214 -0
  374. package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js.map +7 -0
  375. package/dist/modules/documents/widgets/injection/related-documents/context.js +84 -0
  376. package/dist/modules/documents/widgets/injection/related-documents/context.js.map +7 -0
  377. package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js +98 -0
  378. package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js.map +7 -0
  379. package/dist/modules/documents/widgets/injection/related-documents/widget.client.js +83 -0
  380. package/dist/modules/documents/widgets/injection/related-documents/widget.client.js.map +7 -0
  381. package/dist/modules/documents/widgets/injection/related-documents/widget.js +19 -0
  382. package/dist/modules/documents/widgets/injection/related-documents/widget.js.map +7 -0
  383. package/dist/modules/documents/widgets/injection-table.js +21 -0
  384. package/dist/modules/documents/widgets/injection-table.js.map +7 -0
  385. package/dist/server/documents-collab-server.js +2260 -0
  386. package/dist/server/documents-collab-server.js.map +7 -0
  387. package/generated/entities/document/index.ts +12 -0
  388. package/generated/entities/document_attachment/index.ts +9 -0
  389. package/generated/entities/document_comment/index.ts +14 -0
  390. package/generated/entities/document_content/index.ts +11 -0
  391. package/generated/entities/document_entity_link/index.ts +19 -0
  392. package/generated/entities/document_favorite/index.ts +7 -0
  393. package/generated/entities/document_folder/index.ts +9 -0
  394. package/generated/entities/document_share/index.ts +11 -0
  395. package/generated/entities/document_template/index.ts +13 -0
  396. package/generated/entities/document_version/index.ts +9 -0
  397. package/generated/entities/document_watcher/index.ts +7 -0
  398. package/generated/entities.ids.generated.ts +21 -0
  399. package/generated/entity-fields-registry.ts +151 -0
  400. package/jest.config.cjs +34 -0
  401. package/package.json +149 -0
  402. package/server/documents-collab-server.ts +3416 -0
  403. package/src/index.ts +1 -0
  404. package/src/modules/documents/acl.ts +11 -0
  405. package/src/modules/documents/api/[id]/archive/route.ts +132 -0
  406. package/src/modules/documents/api/[id]/attachments/[attachmentId]/route.ts +166 -0
  407. package/src/modules/documents/api/[id]/attachments/route.ts +173 -0
  408. package/src/modules/documents/api/[id]/collab-token/route.ts +203 -0
  409. package/src/modules/documents/api/[id]/comments/access-check/route.ts +96 -0
  410. package/src/modules/documents/api/[id]/comments/route.ts +442 -0
  411. package/src/modules/documents/api/[id]/content/route.ts +156 -0
  412. package/src/modules/documents/api/[id]/duplicate/route.ts +231 -0
  413. package/src/modules/documents/api/[id]/export/route.ts +535 -0
  414. package/src/modules/documents/api/[id]/favorite/route.ts +110 -0
  415. package/src/modules/documents/api/[id]/links/[linkId]/route.ts +92 -0
  416. package/src/modules/documents/api/[id]/links/route.ts +301 -0
  417. package/src/modules/documents/api/[id]/principals/route.ts +375 -0
  418. package/src/modules/documents/api/[id]/route.ts +267 -0
  419. package/src/modules/documents/api/[id]/shares/route.ts +372 -0
  420. package/src/modules/documents/api/[id]/unarchive/route.ts +42 -0
  421. package/src/modules/documents/api/[id]/versions/[versionId]/restore/route.ts +152 -0
  422. package/src/modules/documents/api/[id]/versions/[versionId]/route.ts +100 -0
  423. package/src/modules/documents/api/[id]/versions/route.ts +207 -0
  424. package/src/modules/documents/api/[id]/watch/route.ts +111 -0
  425. package/src/modules/documents/api/_commands.ts +53 -0
  426. package/src/modules/documents/api/_shared.ts +676 -0
  427. package/src/modules/documents/api/folders/route.ts +287 -0
  428. package/src/modules/documents/api/instantiate/route.ts +114 -0
  429. package/src/modules/documents/api/route.ts +362 -0
  430. package/src/modules/documents/api/templates/[templateId]/preview/route.ts +97 -0
  431. package/src/modules/documents/api/templates/[templateId]/route.ts +92 -0
  432. package/src/modules/documents/api/templates/route.ts +370 -0
  433. package/src/modules/documents/backend/documents/DocumentsPageClient.tsx +150 -0
  434. package/src/modules/documents/backend/documents/DocumentsTable.tsx +168 -0
  435. package/src/modules/documents/backend/documents/FolderDialog.tsx +62 -0
  436. package/src/modules/documents/backend/documents/FolderTree.tsx +72 -0
  437. package/src/modules/documents/backend/documents/MoveDocumentDialog.tsx +70 -0
  438. package/src/modules/documents/backend/documents/[id]/CommentAnchorNavigation.ts +88 -0
  439. package/src/modules/documents/backend/documents/[id]/CommentComposer.tsx +136 -0
  440. package/src/modules/documents/backend/documents/[id]/CommentThreadList.tsx +131 -0
  441. package/src/modules/documents/backend/documents/[id]/CommentsRail.tsx +138 -0
  442. package/src/modules/documents/backend/documents/[id]/DocumentCanvas.tsx +111 -0
  443. package/src/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.tsx +39 -0
  444. package/src/modules/documents/backend/documents/[id]/DocumentEditorIsland.tsx +50 -0
  445. package/src/modules/documents/backend/documents/[id]/DocumentEditorSurface.tsx +162 -0
  446. package/src/modules/documents/backend/documents/[id]/DocumentNavigator.tsx +129 -0
  447. package/src/modules/documents/backend/documents/[id]/DocumentPageClient.tsx +463 -0
  448. package/src/modules/documents/backend/documents/[id]/EditorColorTools.tsx +71 -0
  449. package/src/modules/documents/backend/documents/[id]/EditorStatusPresence.tsx +78 -0
  450. package/src/modules/documents/backend/documents/[id]/EditorToolbar.tsx +108 -0
  451. package/src/modules/documents/backend/documents/[id]/ExportMenu.tsx +144 -0
  452. package/src/modules/documents/backend/documents/[id]/MentionPicker.tsx +137 -0
  453. package/src/modules/documents/backend/documents/[id]/OutlinePane.tsx +98 -0
  454. package/src/modules/documents/backend/documents/[id]/RecordFieldsDialog.tsx +185 -0
  455. package/src/modules/documents/backend/documents/[id]/RelatedRecordsPanel.tsx +320 -0
  456. package/src/modules/documents/backend/documents/[id]/VersionHistoryPanel.tsx +244 -0
  457. package/src/modules/documents/backend/documents/[id]/VersionPreviewDialog.tsx +197 -0
  458. package/src/modules/documents/backend/documents/[id]/commentTypes.ts +192 -0
  459. package/src/modules/documents/backend/documents/[id]/componentCapabilities.ts +17 -0
  460. package/src/modules/documents/backend/documents/[id]/documentPagination.ts +352 -0
  461. package/src/modules/documents/backend/documents/[id]/editorPresenceStyles.ts +77 -0
  462. package/src/modules/documents/backend/documents/[id]/editorTypes.ts +84 -0
  463. package/src/modules/documents/backend/documents/[id]/page.meta.ts +12 -0
  464. package/src/modules/documents/backend/documents/[id]/page.tsx +6 -0
  465. package/src/modules/documents/backend/documents/[id]/relatedRecordModel.ts +49 -0
  466. package/src/modules/documents/backend/documents/[id]/restoreVersion.ts +49 -0
  467. package/src/modules/documents/backend/documents/[id]/useDocumentCollaboration.ts +458 -0
  468. package/src/modules/documents/backend/documents/[id]/useDocumentComments.ts +286 -0
  469. package/src/modules/documents/backend/documents/[id]/useDocumentEditor.ts +157 -0
  470. package/src/modules/documents/backend/documents/[id]/useDocumentTitle.ts +77 -0
  471. package/src/modules/documents/backend/documents/[id]/useEditorInsertions.ts +147 -0
  472. package/src/modules/documents/backend/documents/[id]/useFallbackContentPersistence.ts +277 -0
  473. package/src/modules/documents/backend/documents/[id]/useMentionPicker.ts +259 -0
  474. package/src/modules/documents/backend/documents/[id]/versionHistoryModel.ts +29 -0
  475. package/src/modules/documents/backend/documents/components/EntityPicker.tsx +171 -0
  476. package/src/modules/documents/backend/documents/components/EntityPickerResults.tsx +64 -0
  477. package/src/modules/documents/backend/documents/components/NewFromTemplateDialog.tsx +136 -0
  478. package/src/modules/documents/backend/documents/components/PrincipalPicker.tsx +90 -0
  479. package/src/modules/documents/backend/documents/components/ShareDialog.tsx +88 -0
  480. package/src/modules/documents/backend/documents/components/ShareDialogAddForm.tsx +113 -0
  481. package/src/modules/documents/backend/documents/components/ShareDialogList.tsx +117 -0
  482. package/src/modules/documents/backend/documents/components/TemplateBodyEditor.tsx +96 -0
  483. package/src/modules/documents/backend/documents/components/TemplateEditorDialog.tsx +171 -0
  484. package/src/modules/documents/backend/documents/components/TemplatePreview.tsx +43 -0
  485. package/src/modules/documents/backend/documents/components/TemplateSlotFields.tsx +72 -0
  486. package/src/modules/documents/backend/documents/components/TemplateSlotsEditor.tsx +72 -0
  487. package/src/modules/documents/backend/documents/components/principalPickerModel.ts +86 -0
  488. package/src/modules/documents/backend/documents/components/shareDialogModel.ts +94 -0
  489. package/src/modules/documents/backend/documents/components/templateUi.ts +128 -0
  490. package/src/modules/documents/backend/documents/components/useAvailableEntityRegistry.ts +43 -0
  491. package/src/modules/documents/backend/documents/components/useEntitySearch.ts +197 -0
  492. package/src/modules/documents/backend/documents/components/usePrincipalPicker.ts +165 -0
  493. package/src/modules/documents/backend/documents/components/useShareDialog.ts +267 -0
  494. package/src/modules/documents/backend/documents/components/useTemplateDetail.ts +54 -0
  495. package/src/modules/documents/backend/documents/components/useTemplateInstantiation.ts +252 -0
  496. package/src/modules/documents/backend/documents/documentUi.ts +134 -0
  497. package/src/modules/documents/backend/documents/documentsListTypes.ts +163 -0
  498. package/src/modules/documents/backend/documents/page.meta.ts +24 -0
  499. package/src/modules/documents/backend/documents/page.tsx +5 -0
  500. package/src/modules/documents/backend/documents/templates/TemplatesPageClient.tsx +93 -0
  501. package/src/modules/documents/backend/documents/templates/TemplatesTable.tsx +71 -0
  502. package/src/modules/documents/backend/documents/templates/page.meta.ts +32 -0
  503. package/src/modules/documents/backend/documents/templates/page.tsx +5 -0
  504. package/src/modules/documents/backend/documents/templates/useTemplatesPage.tsx +148 -0
  505. package/src/modules/documents/backend/documents/useDocumentsList.tsx +305 -0
  506. package/src/modules/documents/ce.ts +6 -0
  507. package/src/modules/documents/commands/aggregate.ts +128 -0
  508. package/src/modules/documents/commands/attachments.ts +309 -0
  509. package/src/modules/documents/commands/comments.ts +966 -0
  510. package/src/modules/documents/commands/content.ts +294 -0
  511. package/src/modules/documents/commands/document-crud.ts +609 -0
  512. package/src/modules/documents/commands/documents.ts +581 -0
  513. package/src/modules/documents/commands/duplicate.ts +772 -0
  514. package/src/modules/documents/commands/favorites.ts +171 -0
  515. package/src/modules/documents/commands/folders.ts +506 -0
  516. package/src/modules/documents/commands/index.ts +33 -0
  517. package/src/modules/documents/commands/interceptors.ts +402 -0
  518. package/src/modules/documents/commands/lifecycle.ts +333 -0
  519. package/src/modules/documents/commands/links.ts +486 -0
  520. package/src/modules/documents/commands/mutation-helpers.ts +48 -0
  521. package/src/modules/documents/commands/projection-types.ts +77 -0
  522. package/src/modules/documents/commands/shared.ts +219 -0
  523. package/src/modules/documents/commands/shares.ts +612 -0
  524. package/src/modules/documents/commands/side-effects.ts +130 -0
  525. package/src/modules/documents/commands/templates.ts +522 -0
  526. package/src/modules/documents/commands/versions.ts +537 -0
  527. package/src/modules/documents/commands/watchers.ts +181 -0
  528. package/src/modules/documents/data/entities.ts +631 -0
  529. package/src/modules/documents/data/extensions.ts +42 -0
  530. package/src/modules/documents/data/validators.ts +248 -0
  531. package/src/modules/documents/di.ts +33 -0
  532. package/src/modules/documents/encryption.ts +14 -0
  533. package/src/modules/documents/events.ts +23 -0
  534. package/src/modules/documents/i18n/.hardcoded-allowlist.json +9 -0
  535. package/src/modules/documents/i18n/de.json +522 -0
  536. package/src/modules/documents/i18n/en.json +522 -0
  537. package/src/modules/documents/i18n/es.json +522 -0
  538. package/src/modules/documents/i18n/ko.json +522 -0
  539. package/src/modules/documents/i18n/pl.json +522 -0
  540. package/src/modules/documents/index.ts +17 -0
  541. package/src/modules/documents/lib/attachmentServicePort.ts +94 -0
  542. package/src/modules/documents/lib/capabilities.ts +57 -0
  543. package/src/modules/documents/lib/collabCloseEvents.ts +26 -0
  544. package/src/modules/documents/lib/collabEndpoint.ts +43 -0
  545. package/src/modules/documents/lib/collabMaterializer.ts +140 -0
  546. package/src/modules/documents/lib/collabToken.ts +170 -0
  547. package/src/modules/documents/lib/collaborationAwareness.ts +102 -0
  548. package/src/modules/documents/lib/commentAnchors.ts +19 -0
  549. package/src/modules/documents/lib/constants.ts +39 -0
  550. package/src/modules/documents/lib/contentService.ts +340 -0
  551. package/src/modules/documents/lib/displayLabels.ts +31 -0
  552. package/src/modules/documents/lib/docxRenderer.ts +685 -0
  553. package/src/modules/documents/lib/duplicateContent.ts +32 -0
  554. package/src/modules/documents/lib/editorConfig.ts +371 -0
  555. package/src/modules/documents/lib/entityLinks.ts +250 -0
  556. package/src/modules/documents/lib/entityRegistry.server.ts +267 -0
  557. package/src/modules/documents/lib/entityRegistry.ts +345 -0
  558. package/src/modules/documents/lib/entityRegistryAvailability.server.ts +19 -0
  559. package/src/modules/documents/lib/entitySuggestion.ts +61 -0
  560. package/src/modules/documents/lib/favorites.ts +35 -0
  561. package/src/modules/documents/lib/folderHierarchySerialization.ts +34 -0
  562. package/src/modules/documents/lib/historyLimits.ts +154 -0
  563. package/src/modules/documents/lib/historyPolicy.ts +7 -0
  564. package/src/modules/documents/lib/organizationAccess.ts +44 -0
  565. package/src/modules/documents/lib/pdfHtml.ts +65 -0
  566. package/src/modules/documents/lib/pdfRenderer.ts +367 -0
  567. package/src/modules/documents/lib/permissions.ts +299 -0
  568. package/src/modules/documents/lib/platformServices.ts +70 -0
  569. package/src/modules/documents/lib/recordFieldInsertion.ts +72 -0
  570. package/src/modules/documents/lib/requestBody.ts +97 -0
  571. package/src/modules/documents/lib/resourceLimits.ts +94 -0
  572. package/src/modules/documents/lib/shareCounts.ts +44 -0
  573. package/src/modules/documents/lib/templateFill.ts +138 -0
  574. package/src/modules/documents/lib/templateInstantiation.ts +206 -0
  575. package/src/modules/documents/lib/templatePreviewDigest.ts +122 -0
  576. package/src/modules/documents/lib/templateSeeds.ts +248 -0
  577. package/src/modules/documents/lib/userLabels.ts +58 -0
  578. package/src/modules/documents/lib/versionContent.ts +163 -0
  579. package/src/modules/documents/lib/versionLabels.ts +9 -0
  580. package/src/modules/documents/lib/versioning.ts +29 -0
  581. package/src/modules/documents/lib/visibility.ts +610 -0
  582. package/src/modules/documents/lib/watchers.ts +129 -0
  583. package/src/modules/documents/migrations/.snapshot-open-mercato.json +2892 -0
  584. package/src/modules/documents/migrations/Migration20260708163836_documents.ts +50 -0
  585. package/src/modules/documents/migrations/Migration20260709164720_documents.ts +19 -0
  586. package/src/modules/documents/migrations/Migration20260710002318_documents.ts +35 -0
  587. package/src/modules/documents/migrations/Migration20260710071003_documents.ts +13 -0
  588. package/src/modules/documents/migrations/Migration20260712120000_documents.ts +13 -0
  589. package/src/modules/documents/migrations/Migration20260712183000_documents.ts +12 -0
  590. package/src/modules/documents/migrations/Migration20260713092156_documents.ts +43 -0
  591. package/src/modules/documents/migrations/Migration20260717000000_documents.ts +40 -0
  592. package/src/modules/documents/notifications.ts +45 -0
  593. package/src/modules/documents/search.ts +118 -0
  594. package/src/modules/documents/setup.ts +19 -0
  595. package/src/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.tsx +224 -0
  596. package/src/modules/documents/widgets/injection/related-documents/context.ts +101 -0
  597. package/src/modules/documents/widgets/injection/related-documents/useRelatedDocuments.ts +112 -0
  598. package/src/modules/documents/widgets/injection/related-documents/widget.client.tsx +76 -0
  599. package/src/modules/documents/widgets/injection/related-documents/widget.ts +19 -0
  600. package/src/modules/documents/widgets/injection-table.ts +20 -0
  601. package/tsconfig.json +9 -0
  602. package/watch.mjs +6 -0
@@ -0,0 +1,138 @@
1
+ "use client"
2
+
3
+ import * as React from 'react'
4
+ import type { Editor } from '@tiptap/core'
5
+ import { MessageSquare } from 'lucide-react'
6
+ import { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'
7
+ import { flash } from '@open-mercato/ui/backend/FlashMessages'
8
+ import { Button } from '@open-mercato/ui/primitives/button'
9
+ import { EmptyState } from '@open-mercato/ui/primitives/empty-state'
10
+ import {
11
+ Dialog,
12
+ DialogContent,
13
+ DialogDescription,
14
+ DialogFooter,
15
+ DialogHeader,
16
+ DialogTitle,
17
+ } from '@open-mercato/ui/primitives/dialog'
18
+ import { useDialogKeyHandler } from '@open-mercato/ui/hooks/useDialogKeyHandler'
19
+ import { useT } from '@open-mercato/shared/lib/i18n/context'
20
+ import type { CommentAnchor } from './CommentAnchorNavigation'
21
+ import { CommentComposer } from './CommentComposer'
22
+ import { CommentThreadList } from './CommentThreadList'
23
+ import { resolveCommentsCapability, type DocumentTier } from './componentCapabilities'
24
+ import { useDocumentComments } from './useDocumentComments'
25
+
26
+ type CommentFocusRequest = { anchor: CommentAnchor; requestId: number }
27
+ export type { DocumentTier } from './componentCapabilities'
28
+ export { resolveCommentsCapability } from './componentCapabilities'
29
+
30
+ type CommentsRailProps = {
31
+ documentId: string
32
+ editor: Editor | null
33
+ commentFocusRequest?: CommentFocusRequest | null
34
+ /** Legacy compatibility; an explicit capability projection takes precedence. */
35
+ tier?: DocumentTier
36
+ canComment?: boolean
37
+ canShare?: boolean
38
+ }
39
+
40
+ export function CommentsRail({
41
+ documentId,
42
+ editor,
43
+ commentFocusRequest,
44
+ tier,
45
+ canComment,
46
+ canShare = false,
47
+ }: CommentsRailProps) {
48
+ const t = useT()
49
+ const mayComment = resolveCommentsCapability(canComment, tier)
50
+ const composerRef = React.useRef<HTMLFormElement | null>(null)
51
+ const comments = useDocumentComments({ documentId, editor, canComment: mayComment, canShare })
52
+
53
+ React.useEffect(() => {
54
+ if (!commentFocusRequest || !mayComment) return
55
+ comments.setPendingAnchor(commentFocusRequest.anchor)
56
+ window.setTimeout(() => composerRef.current?.scrollIntoView({ block: 'nearest', behavior: 'smooth' }), 0)
57
+ }, [commentFocusRequest, comments.setPendingAnchor, mayComment])
58
+
59
+ const grantPromptKeyDown = useDialogKeyHandler({
60
+ onConfirm: () => comments.chooseGrantAccess(true),
61
+ onCancel: () => comments.chooseGrantAccess(false),
62
+ })
63
+
64
+ return (
65
+ <>
66
+ <section className="rounded-lg border border-border bg-card p-3 sm:p-4">
67
+ <div className="mb-4 flex items-center gap-2">
68
+ <MessageSquare className="size-4 text-muted-foreground" aria-hidden="true" />
69
+ <h2 className="text-sm font-semibold">{t('documents.comments.title')}</h2>
70
+ </div>
71
+ <div className="space-y-4">
72
+ {comments.state.status === 'loading' ? <LoadingMessage label={t('documents.comments.loading')} /> : null}
73
+ {comments.state.status === 'error' ? (
74
+ <ErrorMessage
75
+ label={comments.state.message}
76
+ action={<Button type="button" size="sm" variant="outline" onClick={() => void comments.reload()}>{t('documents.actions.retry')}</Button>}
77
+ />
78
+ ) : null}
79
+ {comments.state.status === 'ready' && comments.comments.length === 0 ? (
80
+ <EmptyState size="sm" variant="subtle" title={t('documents.comments.empty')} icon={<MessageSquare className="size-5" />} />
81
+ ) : null}
82
+ {comments.state.status === 'ready' && comments.comments.length > 0 ? (
83
+ <CommentThreadList
84
+ comments={comments.comments}
85
+ canComment={mayComment}
86
+ resolvingCommentId={comments.resolvingCommentId}
87
+ labelFor={comments.labelFor}
88
+ onJump={(comment) => {
89
+ void (async () => {
90
+ if (!editor || comment.anchor === null || comment.anchor === 'changed') {
91
+ flash(t('documents.comments.anchor.changed'), 'info')
92
+ return
93
+ }
94
+ const { jumpToCommentAnchor } = await import('./CommentAnchorNavigation')
95
+ if (!jumpToCommentAnchor(editor, comment.anchor)) {
96
+ flash(t('documents.comments.anchor.changed'), 'info')
97
+ }
98
+ })()
99
+ }}
100
+ onReply={comments.startReply}
101
+ onResolve={(comment) => void comments.resolveComment(comment)}
102
+ t={t}
103
+ />
104
+ ) : null}
105
+ {mayComment ? (
106
+ <CommentComposer
107
+ ref={composerRef}
108
+ documentId={documentId}
109
+ body={comments.body}
110
+ pendingMentions={comments.pendingMentions}
111
+ replyToName={comments.replyToName}
112
+ isSubmitting={comments.isSubmitting}
113
+ onBodyChange={comments.setBody}
114
+ onMentionsChange={comments.setPendingMentions}
115
+ onSubmit={() => void comments.submit()}
116
+ onCancel={comments.resetComposer}
117
+ focusSignal={commentFocusRequest?.requestId ?? comments.parentCommentId ?? undefined}
118
+ />
119
+ ) : null}
120
+ </div>
121
+ </section>
122
+ <Dialog open={comments.grantAccessNames !== null} onOpenChange={(open) => { if (!open) comments.chooseGrantAccess(false) }}>
123
+ <DialogContent onKeyDown={grantPromptKeyDown}>
124
+ <DialogHeader>
125
+ <DialogTitle>{t('documents.comments.grant.title')}</DialogTitle>
126
+ <DialogDescription>{t('documents.comments.grant.body', { names: comments.grantAccessNames?.join(', ') ?? '' })}</DialogDescription>
127
+ </DialogHeader>
128
+ <DialogFooter>
129
+ <Button type="button" variant="outline" onClick={() => comments.chooseGrantAccess(false)}>{t('documents.comments.grant.skip')}</Button>
130
+ <Button type="button" onClick={() => comments.chooseGrantAccess(true)}>{t('documents.comments.grant.share')}</Button>
131
+ </DialogFooter>
132
+ </DialogContent>
133
+ </Dialog>
134
+ </>
135
+ )
136
+ }
137
+
138
+ export default CommentsRail
@@ -0,0 +1,111 @@
1
+ "use client"
2
+
3
+ import * as React from 'react'
4
+ import type { Editor } from '@tiptap/core'
5
+ import { EditorContent, useEditorState } from '@tiptap/react'
6
+ import { BubbleMenu } from '@tiptap/react/menus'
7
+ import { Bold, Italic, Link2, MessageSquare, Underline } from 'lucide-react'
8
+ import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
9
+ import { Button } from '@open-mercato/ui/primitives/button'
10
+ import { IconButton } from '@open-mercato/ui/primitives/icon-button'
11
+ import { Input } from '@open-mercato/ui/primitives/input'
12
+ import { useT } from '@open-mercato/shared/lib/i18n/context'
13
+ import { cn } from '@open-mercato/shared/lib/utils'
14
+ import { OutlinePane } from './OutlinePane'
15
+ import { captureCommentAnchor, type CommentAnchor } from './CommentAnchorNavigation'
16
+ import { DOCUMENT_EDITOR_CONTENT_CLASS } from './editorTypes'
17
+ import { DOCUMENT_PAGINATION_STYLES } from './documentPagination'
18
+
19
+ type TitleModel = {
20
+ value: string
21
+ setValue: (value: string) => void
22
+ saving: boolean
23
+ commit: () => Promise<void>
24
+ onKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void
25
+ }
26
+
27
+ const EMPTY_BUBBLE_MENU_STATE = {
28
+ bold: false,
29
+ italic: false,
30
+ underline: false,
31
+ link: false,
32
+ }
33
+
34
+ export function DocumentCanvas({
35
+ editor,
36
+ title,
37
+ readOnly,
38
+ outlineOpen,
39
+ notice,
40
+ onOpenLink,
41
+ onComment,
42
+ }: {
43
+ editor: Editor | null
44
+ title: TitleModel
45
+ readOnly: boolean
46
+ outlineOpen: boolean
47
+ notice: string | null
48
+ onOpenLink: () => void
49
+ onComment?: (anchor: CommentAnchor) => void
50
+ }) {
51
+ const t = useT()
52
+ const editorState = useEditorState({
53
+ editor,
54
+ selector: ({ editor: current }) => current ? {
55
+ bold: current.isActive('bold'),
56
+ italic: current.isActive('italic'),
57
+ underline: current.isActive('underline'),
58
+ link: current.isActive('link'),
59
+ } : EMPTY_BUBBLE_MENU_STATE,
60
+ }) ?? EMPTY_BUBBLE_MENU_STATE
61
+ const keepSelection = React.useCallback((event: React.MouseEvent<HTMLButtonElement>) => event.preventDefault(), [])
62
+ const comment = React.useCallback(() => {
63
+ if (!editor || !onComment) return
64
+ const anchor = captureCommentAnchor(editor)
65
+ if (anchor) onComment(anchor)
66
+ }, [editor, onComment])
67
+ const shouldShow = React.useCallback(
68
+ ({ from, to }: { from: number; to: number }) => from !== to && (!readOnly || Boolean(onComment)),
69
+ [onComment, readOnly],
70
+ )
71
+
72
+ return (
73
+ <div className="om-doc-canvas max-h-[calc(100dvh-var(--topbar-height,0px)-12rem)] min-h-96 overflow-auto bg-muted p-0 sm:px-4 sm:py-8 md:px-8 md:py-10">
74
+ <style>{DOCUMENT_PAGINATION_STYLES}</style>
75
+ {notice ? <Alert status="information" style="lighter" className="mx-auto mb-4 max-w-3xl"><AlertDescription>{notice}</AlertDescription></Alert> : null}
76
+ <div className="mx-auto flex w-fit min-w-full flex-col gap-4 lg:flex-row lg:items-start">
77
+ {outlineOpen ? <OutlinePane editor={editor} /> : null}
78
+ <article className="om-doc-paper mx-auto flex-none bg-card sm:rounded-sm sm:shadow-lg">
79
+ {readOnly ? (
80
+ <h1 className="mb-6 text-xl font-semibold leading-tight text-foreground sm:mb-8 sm:text-3xl">{title.value}</h1>
81
+ ) : (
82
+ <Input
83
+ value={title.value}
84
+ onChange={(event) => title.setValue(event.target.value)}
85
+ onBlur={() => void title.commit()}
86
+ onKeyDown={title.onKeyDown}
87
+ maxLength={512}
88
+ disabled={title.saving}
89
+ aria-label={t('documents.editor.title.ariaLabel')}
90
+ className="mb-6 h-auto border-0 bg-transparent px-0 py-0 text-xl font-semibold leading-tight text-foreground shadow-none focus-visible:shadow-focus sm:mb-8 sm:text-3xl"
91
+ />
92
+ )}
93
+ {editor ? (
94
+ <BubbleMenu editor={editor} shouldShow={shouldShow} className="z-popover flex items-center gap-1 rounded-md border border-border bg-card p-1 shadow-md">
95
+ {!readOnly ? (
96
+ <>
97
+ <IconButton type="button" size="sm" variant={editorState.bold ? 'outline' : 'ghost'} aria-label={t('documents.editor.toolbar.bold')} aria-pressed={editorState.bold} onMouseDown={keepSelection} onClick={() => editor.chain().focus().toggleBold().run()}><Bold /></IconButton>
98
+ <IconButton type="button" size="sm" variant={editorState.italic ? 'outline' : 'ghost'} aria-label={t('documents.editor.toolbar.italic')} aria-pressed={editorState.italic} onMouseDown={keepSelection} onClick={() => editor.chain().focus().toggleItalic().run()}><Italic /></IconButton>
99
+ <IconButton type="button" size="sm" variant={editorState.underline ? 'outline' : 'ghost'} aria-label={t('documents.editor.toolbar.underline')} aria-pressed={editorState.underline} onMouseDown={keepSelection} onClick={() => editor.chain().focus().toggleMark('underline').run()}><Underline /></IconButton>
100
+ <IconButton type="button" size="sm" variant={editorState.link ? 'outline' : 'ghost'} aria-label={t('documents.editor.toolbar.link')} aria-pressed={editorState.link} onMouseDown={keepSelection} onClick={onOpenLink}><Link2 /></IconButton>
101
+ </>
102
+ ) : null}
103
+ {onComment ? <Button type="button" size="sm" variant="ghost" onMouseDown={keepSelection} onClick={comment}><MessageSquare />{t('documents.editor.toolbar.comment')}</Button> : null}
104
+ </BubbleMenu>
105
+ ) : null}
106
+ <EditorContent className={cn(DOCUMENT_EDITOR_CONTENT_CLASS, readOnly && 'select-text')} editor={editor} />
107
+ </article>
108
+ </div>
109
+ </div>
110
+ )
111
+ }
@@ -0,0 +1,39 @@
1
+ "use client"
2
+
3
+ import * as React from 'react'
4
+
5
+ type DocumentEditorErrorBoundaryProps = {
6
+ children: React.ReactNode
7
+ fallback: (retry: () => void) => React.ReactNode
8
+ onRetry: () => void
9
+ resetKey: string
10
+ }
11
+ type DocumentEditorErrorBoundaryState = {
12
+ failed: boolean
13
+ }
14
+
15
+ export class DocumentEditorErrorBoundary extends React.Component<
16
+ DocumentEditorErrorBoundaryProps,
17
+ DocumentEditorErrorBoundaryState
18
+ > {
19
+ state: DocumentEditorErrorBoundaryState = { failed: false }
20
+
21
+ static getDerivedStateFromError(): DocumentEditorErrorBoundaryState {
22
+ return { failed: true }
23
+ }
24
+
25
+ componentDidUpdate(previous: DocumentEditorErrorBoundaryProps) {
26
+ if (this.state.failed && previous.resetKey !== this.props.resetKey) {
27
+ this.setState({ failed: false })
28
+ }
29
+ }
30
+
31
+ private retry = () => {
32
+ this.setState({ failed: false })
33
+ this.props.onRetry()
34
+ }
35
+
36
+ render() {
37
+ return this.state.failed ? this.props.fallback(this.retry) : this.props.children
38
+ }
39
+ }
@@ -0,0 +1,50 @@
1
+ "use client"
2
+
3
+ import * as React from 'react'
4
+ import { useRouter, useSearchParams } from 'next/navigation'
5
+ import { LoadingMessage } from '@open-mercato/ui/backend/detail'
6
+ import { useT } from '@open-mercato/shared/lib/i18n/context'
7
+ import { DocumentEditorSurface } from './DocumentEditorSurface'
8
+ import { resolveEditorMode, type DocumentEditorIslandProps, type EditorMode } from './editorTypes'
9
+ import { useDocumentCollaboration } from './useDocumentCollaboration'
10
+
11
+ export default function DocumentEditorIsland(props: DocumentEditorIslandProps) {
12
+ const t = useT()
13
+ const router = useRouter()
14
+ const searchParams = useSearchParams()
15
+ const collaboration = useDocumentCollaboration(props.documentId)
16
+ const requestedMode: EditorMode = searchParams.get('mode') === 'preview' ? 'preview' : 'edit'
17
+ const serverReadOnly = collaboration.mode === 'collab'
18
+ ? collaboration.serverReadOnly
19
+ : collaboration.mode === 'fallback'
20
+ ? collaboration.readOnly
21
+ : false
22
+ const forcedReadOnly = props.readOnly || serverReadOnly
23
+ const mode = resolveEditorMode(props.readOnly, serverReadOnly, requestedMode)
24
+ const changeMode = React.useCallback((nextMode: EditorMode) => {
25
+ if (forcedReadOnly) return
26
+ const next = new URLSearchParams(searchParams.toString())
27
+ if (nextMode === 'preview') next.set('mode', 'preview')
28
+ else next.delete('mode')
29
+ const query = next.toString()
30
+ router.replace(query ? `?${query}` : '?', { scroll: false })
31
+ }, [forcedReadOnly, router, searchParams])
32
+
33
+ if (collaboration.mode === 'connecting') return <LoadingMessage label={t('documents.editor.loading')} />
34
+ if (collaboration.mode === 'fallback') {
35
+ return <DocumentEditorSurface {...props} readOnly={forcedReadOnly} key={`fallback:${props.documentId}`} transport="fallback" connectionStatus="offline" presenceUsers={[]} mode={mode} onModeChange={changeMode} />
36
+ }
37
+ return (
38
+ <DocumentEditorSurface
39
+ {...props}
40
+ readOnly={forcedReadOnly}
41
+ key={`collab:${props.documentId}`}
42
+ transport="collab"
43
+ collabResources={collaboration.resources}
44
+ connectionStatus={collaboration.connectionStatus}
45
+ presenceUsers={collaboration.presenceUsers}
46
+ mode={mode}
47
+ onModeChange={changeMode}
48
+ />
49
+ )
50
+ }
@@ -0,0 +1,162 @@
1
+ "use client"
2
+
3
+ import * as React from 'react'
4
+ import { Link2, Unlink } from 'lucide-react'
5
+ import { Button } from '@open-mercato/ui/primitives/button'
6
+ import { Input } from '@open-mercato/ui/primitives/input'
7
+ import { Label } from '@open-mercato/ui/primitives/label'
8
+ import { useT } from '@open-mercato/shared/lib/i18n/context'
9
+ import { cn } from '@open-mercato/shared/lib/utils'
10
+ import { EntityPicker } from '../components/EntityPicker'
11
+ import { DocumentCanvas } from './DocumentCanvas'
12
+ import { EditorStatusPresence } from './EditorStatusPresence'
13
+ import { EditorToolbar } from './EditorToolbar'
14
+ import { RecordFieldsDialog } from './RecordFieldsDialog'
15
+ import { EDITOR_PRESENCE_STYLES } from './editorPresenceStyles'
16
+ import { canCreateSelectionComment, type CollabResources, type ConnectionStatus, type DocumentEditorIslandProps, type EditorMode, type PresenceUser } from './editorTypes'
17
+ import { useDocumentEditor } from './useDocumentEditor'
18
+ import { useFallbackContentPersistence } from './useFallbackContentPersistence'
19
+ import { useDocumentTitle } from './useDocumentTitle'
20
+ import { useEditorInsertions } from './useEditorInsertions'
21
+
22
+ type Props = DocumentEditorIslandProps & {
23
+ transport: 'collab' | 'fallback'
24
+ collabResources?: CollabResources
25
+ connectionStatus: ConnectionStatus
26
+ presenceUsers: PresenceUser[]
27
+ mode: EditorMode
28
+ onModeChange: (mode: EditorMode) => void
29
+ }
30
+
31
+ export function DocumentEditorSurface(input: Props) {
32
+ const t = useT()
33
+ const [outlineOpen, setOutlineOpen] = React.useState(false)
34
+ const [suggestionRange, setSuggestionRange] = React.useState<{ from: number; to: number } | null>(null)
35
+ const modeChangeInFlightRef = React.useRef(false)
36
+ const effectiveReadOnly = input.readOnly || input.mode === 'preview'
37
+ const openSuggestion = React.useCallback((range: { from: number; to: number }) => setSuggestionRange(range), [])
38
+ const closeSuggestion = React.useCallback(() => setSuggestionRange(null), [])
39
+ const fallbackPersistence = useFallbackContentPersistence({
40
+ documentId: input.documentId,
41
+ initialUpdatedAt: input.contentUpdatedAt ?? null,
42
+ enabled: input.transport === 'fallback' && !input.readOnly,
43
+ onConflictRefresh: input.onContentConflict,
44
+ })
45
+ const editorModel = useDocumentEditor({
46
+ documentId: input.documentId,
47
+ initialContentHtml: input.initialContentHtml,
48
+ editorMode: input.transport,
49
+ collabResources: input.collabResources,
50
+ readOnly: effectiveReadOnly,
51
+ onEditorReady: input.onEditorReady,
52
+ onUpdate: fallbackPersistence.onEditorUpdate,
53
+ onEntitySuggestion: openSuggestion,
54
+ onSuggestionClose: closeSuggestion,
55
+ })
56
+ const title = useDocumentTitle({
57
+ documentId: input.documentId,
58
+ title: input.title,
59
+ updatedAt: input.documentUpdatedAt ?? null,
60
+ readOnly: effectiveReadOnly,
61
+ onTitleChange: input.onTitleChange,
62
+ })
63
+ const insertions = useEditorInsertions({
64
+ documentId: input.documentId,
65
+ editorRef: editorModel.editorRef,
66
+ disabled: effectiveReadOnly,
67
+ suggestionRange,
68
+ setSuggestionRange,
69
+ })
70
+ React.useEffect(() => {
71
+ if (suggestionRange && !effectiveReadOnly) insertions.setPickerOpen(true)
72
+ }, [effectiveReadOnly, insertions.setPickerOpen, suggestionRange])
73
+
74
+ const status = input.transport === 'fallback' ? 'offline' : input.connectionStatus
75
+ const notice = input.transport === 'fallback'
76
+ ? t(input.readOnly ? 'documents.editor.realtime.readOnlyFallback' : 'documents.editor.realtime.singleUserFallback')
77
+ : input.readOnly
78
+ ? t('documents.editor.readOnly')
79
+ : input.mode === 'preview'
80
+ ? t('documents.editor.mode.previewNotice')
81
+ : null
82
+ const selectionCommentHandler = canCreateSelectionComment({
83
+ permissionReadOnly: input.readOnly,
84
+ mode: input.mode,
85
+ transport: input.transport,
86
+ hasCommentHandler: Boolean(input.onComment),
87
+ }) ? input.onComment : undefined
88
+ const handleModeChange = React.useCallback(async (nextMode: EditorMode) => {
89
+ if (nextMode === input.mode || modeChangeInFlightRef.current) return
90
+ if (input.transport !== 'fallback' || nextMode !== 'preview') {
91
+ input.onModeChange(nextMode)
92
+ return
93
+ }
94
+
95
+ modeChangeInFlightRef.current = true
96
+ try {
97
+ if (await fallbackPersistence.saveNow()) input.onModeChange(nextMode)
98
+ } finally {
99
+ modeChangeInFlightRef.current = false
100
+ }
101
+ }, [fallbackPersistence.saveNow, input.mode, input.onModeChange, input.transport])
102
+
103
+ return (
104
+ <div className={cn('space-y-3', input.transport === 'collab' && 'om-doc-collab', input.mode === 'preview' && 'om-doc-preview')}>
105
+ <style>{EDITOR_PRESENCE_STYLES}</style>
106
+ <div className="overflow-hidden rounded-lg border border-border bg-muted shadow-sm">
107
+ <div className="sticky top-0 z-sticky border-b border-border bg-card/95">
108
+ <div className="flex flex-wrap items-center justify-between gap-2 px-3 py-2">
109
+ <EditorStatusPresence
110
+ status={status}
111
+ users={input.presenceUsers}
112
+ counts={editorModel.counts}
113
+ mode={input.mode}
114
+ canEdit={!input.readOnly}
115
+ onModeChange={(nextMode) => { void handleModeChange(nextMode) }}
116
+ fallbackSave={input.transport === 'fallback' && !input.readOnly ? {
117
+ status: fallbackPersistence.status,
118
+ onSave: fallbackPersistence.saveNow,
119
+ } : undefined}
120
+ />
121
+ </div>
122
+ {input.mode === 'edit' ? (
123
+ <EditorToolbar
124
+ editor={editorModel.editor}
125
+ disabled={effectiveReadOnly || !editorModel.editor}
126
+ outlineOpen={outlineOpen}
127
+ uploading={insertions.uploading}
128
+ onToggleOutline={() => setOutlineOpen((value) => !value)}
129
+ onOpenEntityPicker={insertions.openEntityPicker}
130
+ onOpenLink={insertions.openLink}
131
+ onImage={() => insertions.fileInputRef.current?.click()}
132
+ />
133
+ ) : null}
134
+ {insertions.linkOpen && !effectiveReadOnly ? (
135
+ <div className="flex flex-col gap-3 border-t border-border bg-muted/30 p-3 md:flex-row md:items-end" onKeyDown={(event) => {
136
+ if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') { event.preventDefault(); insertions.applyLink() }
137
+ if (event.key === 'Escape') { event.preventDefault(); insertions.setLinkOpen(false) }
138
+ }}>
139
+ <div className="min-w-0 flex-1 space-y-2">
140
+ <Label htmlFor={`document-link-${input.documentId}`}>{t('documents.editor.link.url')}</Label>
141
+ <Input id={`document-link-${input.documentId}`} type="url" value={insertions.linkHref} onChange={(event) => insertions.setLinkHref(event.target.value)} placeholder={t('documents.editor.link.placeholder')} />
142
+ </div>
143
+ <Button type="button" onClick={insertions.applyLink}><Link2 />{t('documents.editor.link.apply')}</Button>
144
+ <Button type="button" variant="outline" onClick={insertions.removeLink}><Unlink />{t('documents.editor.link.remove')}</Button>
145
+ <Button type="button" variant="ghost" onClick={() => insertions.setLinkOpen(false)}>{t('documents.actions.cancel')}</Button>
146
+ </div>
147
+ ) : null}
148
+ </div>
149
+ <DocumentCanvas editor={editorModel.editor} title={title} readOnly={effectiveReadOnly} outlineOpen={outlineOpen} notice={notice} onOpenLink={insertions.openLink} onComment={selectionCommentHandler} />
150
+ </div>
151
+ <EntityPicker open={insertions.entityPickerOpen} onOpenChange={insertions.setPickerOpen} onPick={(pick) => { void insertions.handleEntityPick(pick) }} />
152
+ <RecordFieldsDialog
153
+ documentId={input.documentId}
154
+ linkId={insertions.recordFieldsLinkId}
155
+ editor={editorModel.editor}
156
+ canInsert={!effectiveReadOnly && Boolean(editorModel.editor)}
157
+ onOpenChange={(open) => { if (!open) insertions.closeRecordFields() }}
158
+ />
159
+ <input ref={insertions.fileInputRef} type="file" accept="image/*" className="hidden" aria-label={t('documents.editor.imageInput')} onChange={(event) => { void insertions.handleFiles(event.target.files) }} />
160
+ </div>
161
+ )
162
+ }
@@ -0,0 +1,129 @@
1
+ "use client"
2
+
3
+ import * as React from 'react'
4
+ import type { Editor } from '@tiptap/core'
5
+ import { Button } from '@open-mercato/ui/primitives/button'
6
+ import { Input } from '@open-mercato/ui/primitives/input'
7
+ import { Label } from '@open-mercato/ui/primitives/label'
8
+ import { Progress } from '@open-mercato/ui/primitives/progress'
9
+ import { useT } from '@open-mercato/shared/lib/i18n/context'
10
+
11
+ type PagePosition = { currentPage: number; totalPages: number }
12
+
13
+ export function pageAtOffset(pageTops: number[], offset: number): PagePosition {
14
+ if (pageTops.length === 0) return { currentPage: 1, totalPages: 1 }
15
+ let low = 0
16
+ let high = pageTops.length
17
+ while (low < high) {
18
+ const middle = Math.floor((low + high) / 2)
19
+ if ((pageTops[middle] ?? Number.POSITIVE_INFINITY) <= offset) low = middle + 1
20
+ else high = middle
21
+ }
22
+ return { currentPage: Math.max(1, low), totalPages: pageTops.length }
23
+ }
24
+
25
+ function documentScroller(editor: Editor): HTMLElement | null {
26
+ return editor.view.dom.closest<HTMLElement>('.om-doc-canvas')
27
+ }
28
+
29
+ function collectPageTops(editor: Editor, scroller: HTMLElement): number[] {
30
+ const paper = editor.view.dom.closest<HTMLElement>('.om-doc-paper')
31
+ if (!paper) return []
32
+ const scrollerTop = scroller.getBoundingClientRect().top
33
+ const tops = [paper.getBoundingClientRect().top - scrollerTop + scroller.scrollTop]
34
+ paper.querySelectorAll<HTMLElement>('[data-document-page-start]').forEach((pageStart) => {
35
+ tops.push(pageStart.getBoundingClientRect().top - scrollerTop + scroller.scrollTop)
36
+ })
37
+ return tops
38
+ }
39
+
40
+ export function DocumentNavigator({ editor }: { editor: Editor | null }) {
41
+ const t = useT()
42
+ const pageTopsRef = React.useRef<number[]>([])
43
+ const pageStartsRef = React.useRef<HTMLElement[]>([])
44
+ const frameRef = React.useRef<number | null>(null)
45
+ const [position, setPosition] = React.useState<PagePosition>({ currentPage: 1, totalPages: 1 })
46
+ const [targetPage, setTargetPage] = React.useState('')
47
+
48
+ React.useEffect(() => {
49
+ if (!editor || editor.isDestroyed) return
50
+ const scroller = documentScroller(editor)
51
+ if (!scroller) return
52
+ const readCurrentPage = () => {
53
+ frameRef.current = null
54
+ const anchor = scroller.scrollTop + Math.min(160, scroller.clientHeight * 0.25)
55
+ const next = pageAtOffset(pageTopsRef.current, anchor)
56
+ setPosition((current) => current.currentPage === next.currentPage && current.totalPages === next.totalPages ? current : next)
57
+ }
58
+ const scheduleCurrentPage = () => {
59
+ if (frameRef.current === null) frameRef.current = window.requestAnimationFrame(readCurrentPage)
60
+ }
61
+ const refreshPageTops = () => {
62
+ pageTopsRef.current = collectPageTops(editor, scroller)
63
+ pageStartsRef.current = Array.from(editor.view.dom.closest<HTMLElement>('.om-doc-paper')?.querySelectorAll<HTMLElement>('[data-document-page-start]') ?? [])
64
+ scheduleCurrentPage()
65
+ }
66
+ const mutationObserver = new MutationObserver(refreshPageTops)
67
+ mutationObserver.observe(editor.view.dom, { childList: true, subtree: true })
68
+ const paper = editor.view.dom.closest<HTMLElement>('.om-doc-paper')
69
+ const resizeObserver = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(refreshPageTops)
70
+ if (paper) resizeObserver?.observe(paper)
71
+ scroller.addEventListener('scroll', scheduleCurrentPage, { passive: true })
72
+ window.addEventListener('resize', refreshPageTops)
73
+ refreshPageTops()
74
+ return () => {
75
+ if (frameRef.current !== null) window.cancelAnimationFrame(frameRef.current)
76
+ mutationObserver.disconnect()
77
+ resizeObserver?.disconnect()
78
+ scroller.removeEventListener('scroll', scheduleCurrentPage)
79
+ window.removeEventListener('resize', refreshPageTops)
80
+ }
81
+ }, [editor])
82
+
83
+ const jumpToPage = React.useCallback(() => {
84
+ const requested = Number.parseInt(targetPage, 10)
85
+ if (!Number.isFinite(requested)) return
86
+ const page = Math.min(position.totalPages, Math.max(1, requested))
87
+ const scroller = editor && !editor.isDestroyed ? documentScroller(editor) : null
88
+ const top = pageTopsRef.current[page - 1]
89
+ if (!scroller || top === undefined || (page > 1 && !pageStartsRef.current[page - 2])) return
90
+ scroller.scrollTo({ top: Math.max(0, top - 24), behavior: 'auto' })
91
+ setTargetPage('')
92
+ }, [editor, position.totalPages, targetPage])
93
+ const progress = Math.round((position.currentPage / position.totalPages) * 100)
94
+
95
+ return (
96
+ <section className="space-y-4 rounded-lg border border-border bg-card p-4" aria-label={t('documents.editor.navigation.title')}>
97
+ <div>
98
+ <h2 className="text-sm font-semibold">{t('documents.editor.navigation.title')}</h2>
99
+ <p className="mt-1 text-sm text-muted-foreground">{t('documents.editor.navigation.pageStatus', position)}</p>
100
+ </div>
101
+ <Progress
102
+ value={progress}
103
+ label={t('documents.editor.navigation.progress')}
104
+ showValue
105
+ aria-label={t('documents.editor.navigation.progress')}
106
+ />
107
+ <form className="space-y-2" onSubmit={(event) => { event.preventDefault(); jumpToPage() }}>
108
+ <Label htmlFor="documents-page-target">{t('documents.editor.navigation.goToPage')}</Label>
109
+ <div className="flex items-center gap-2">
110
+ <Input
111
+ id="documents-page-target"
112
+ type="number"
113
+ inputMode="numeric"
114
+ min={1}
115
+ max={position.totalPages}
116
+ value={targetPage}
117
+ onChange={(event) => setTargetPage(event.target.value)}
118
+ placeholder={String(position.currentPage)}
119
+ aria-describedby="documents-page-range"
120
+ />
121
+ <Button type="submit" disabled={!targetPage.trim()}>{t('documents.editor.navigation.go')}</Button>
122
+ </div>
123
+ <p id="documents-page-range" className="text-xs text-muted-foreground">
124
+ {t('documents.editor.navigation.pageRange', { totalPages: position.totalPages })}
125
+ </p>
126
+ </form>
127
+ </section>
128
+ )
129
+ }