@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.
- package/README.md +88 -0
- package/build.mjs +23 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/dist/modules/documents/acl.js +15 -0
- package/dist/modules/documents/acl.js.map +7 -0
- package/dist/modules/documents/api/[id]/archive/route.js +116 -0
- package/dist/modules/documents/api/[id]/archive/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js +155 -0
- package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/attachments/route.js +153 -0
- package/dist/modules/documents/api/[id]/attachments/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/collab-token/route.js +180 -0
- package/dist/modules/documents/api/[id]/collab-token/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/comments/access-check/route.js +86 -0
- package/dist/modules/documents/api/[id]/comments/access-check/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/comments/route.js +387 -0
- package/dist/modules/documents/api/[id]/comments/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/content/route.js +143 -0
- package/dist/modules/documents/api/[id]/content/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/duplicate/route.js +200 -0
- package/dist/modules/documents/api/[id]/duplicate/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/export/route.js +421 -0
- package/dist/modules/documents/api/[id]/export/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/favorite/route.js +96 -0
- package/dist/modules/documents/api/[id]/favorite/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/links/[linkId]/route.js +85 -0
- package/dist/modules/documents/api/[id]/links/[linkId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/links/route.js +257 -0
- package/dist/modules/documents/api/[id]/links/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/principals/route.js +299 -0
- package/dist/modules/documents/api/[id]/principals/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/route.js +246 -0
- package/dist/modules/documents/api/[id]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/shares/route.js +335 -0
- package/dist/modules/documents/api/[id]/shares/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/unarchive/route.js +39 -0
- package/dist/modules/documents/api/[id]/unarchive/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js +133 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/route.js +93 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/route.js +193 -0
- package/dist/modules/documents/api/[id]/versions/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/watch/route.js +97 -0
- package/dist/modules/documents/api/[id]/watch/route.js.map +7 -0
- package/dist/modules/documents/api/_commands.js +34 -0
- package/dist/modules/documents/api/_commands.js.map +7 -0
- package/dist/modules/documents/api/_shared.js +490 -0
- package/dist/modules/documents/api/_shared.js.map +7 -0
- package/dist/modules/documents/api/folders/route.js +256 -0
- package/dist/modules/documents/api/folders/route.js.map +7 -0
- package/dist/modules/documents/api/instantiate/route.js +108 -0
- package/dist/modules/documents/api/instantiate/route.js.map +7 -0
- package/dist/modules/documents/api/route.js +322 -0
- package/dist/modules/documents/api/route.js.map +7 -0
- package/dist/modules/documents/api/templates/[templateId]/preview/route.js +94 -0
- package/dist/modules/documents/api/templates/[templateId]/preview/route.js.map +7 -0
- package/dist/modules/documents/api/templates/[templateId]/route.js +82 -0
- package/dist/modules/documents/api/templates/[templateId]/route.js.map +7 -0
- package/dist/modules/documents/api/templates/route.js +344 -0
- package/dist/modules/documents/api/templates/route.js.map +7 -0
- package/dist/modules/documents/backend/documents/DocumentsPageClient.js +160 -0
- package/dist/modules/documents/backend/documents/DocumentsPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/DocumentsTable.js +143 -0
- package/dist/modules/documents/backend/documents/DocumentsTable.js.map +7 -0
- package/dist/modules/documents/backend/documents/FolderDialog.js +55 -0
- package/dist/modules/documents/backend/documents/FolderDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/FolderTree.js +40 -0
- package/dist/modules/documents/backend/documents/FolderTree.js.map +7 -0
- package/dist/modules/documents/backend/documents/MoveDocumentDialog.js +64 -0
- package/dist/modules/documents/backend/documents/MoveDocumentDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js +77 -0
- package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentComposer.js +126 -0
- package/dist/modules/documents/backend/documents/[id]/CommentComposer.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js +88 -0
- package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentsRail.js +123 -0
- package/dist/modules/documents/backend/documents/[id]/CommentsRail.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js +91 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js +27 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js +50 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js +168 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js +129 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js +429 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js +68 -0
- package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js +69 -0
- package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js +151 -0
- package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/ExportMenu.js +121 -0
- package/dist/modules/documents/backend/documents/[id]/ExportMenu.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/MentionPicker.js +114 -0
- package/dist/modules/documents/backend/documents/[id]/MentionPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/OutlinePane.js +70 -0
- package/dist/modules/documents/backend/documents/[id]/OutlinePane.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js +157 -0
- package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js +266 -0
- package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js +227 -0
- package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js +157 -0
- package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/commentTypes.js +150 -0
- package/dist/modules/documents/backend/documents/[id]/commentTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js +13 -0
- package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/documentPagination.js +295 -0
- package/dist/modules/documents/backend/documents/[id]/documentPagination.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js +81 -0
- package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/editorTypes.js +52 -0
- package/dist/modules/documents/backend/documents/[id]/editorTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/page.js +10 -0
- package/dist/modules/documents/backend/documents/[id]/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/page.meta.js +16 -0
- package/dist/modules/documents/backend/documents/[id]/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js +38 -0
- package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/restoreVersion.js +33 -0
- package/dist/modules/documents/backend/documents/[id]/restoreVersion.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js +392 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js +253 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js +149 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js +82 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js +144 -0
- package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js +237 -0
- package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js +216 -0
- package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js +25 -0
- package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/EntityPicker.js +156 -0
- package/dist/modules/documents/backend/documents/components/EntityPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/EntityPickerResults.js +46 -0
- package/dist/modules/documents/backend/documents/components/EntityPickerResults.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js +127 -0
- package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/PrincipalPicker.js +84 -0
- package/dist/modules/documents/backend/documents/components/PrincipalPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialog.js +77 -0
- package/dist/modules/documents/backend/documents/components/ShareDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js +93 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogList.js +82 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogList.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js +96 -0
- package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js +169 -0
- package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplatePreview.js +38 -0
- package/dist/modules/documents/backend/documents/components/TemplatePreview.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js +69 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js +71 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/principalPickerModel.js +63 -0
- package/dist/modules/documents/backend/documents/components/principalPickerModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/shareDialogModel.js +68 -0
- package/dist/modules/documents/backend/documents/components/shareDialogModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/templateUi.js +89 -0
- package/dist/modules/documents/backend/documents/components/templateUi.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js +30 -0
- package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useEntitySearch.js +191 -0
- package/dist/modules/documents/backend/documents/components/useEntitySearch.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js +221 -0
- package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useShareDialog.js +236 -0
- package/dist/modules/documents/backend/documents/components/useShareDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useTemplateDetail.js +49 -0
- package/dist/modules/documents/backend/documents/components/useTemplateDetail.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js +234 -0
- package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js.map +7 -0
- package/dist/modules/documents/backend/documents/documentUi.js +106 -0
- package/dist/modules/documents/backend/documents/documentUi.js.map +7 -0
- package/dist/modules/documents/backend/documents/documentsListTypes.js +132 -0
- package/dist/modules/documents/backend/documents/documentsListTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/page.js +9 -0
- package/dist/modules/documents/backend/documents/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/page.meta.js +26 -0
- package/dist/modules/documents/backend/documents/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js +91 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesTable.js +58 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesTable.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/page.js +9 -0
- package/dist/modules/documents/backend/documents/templates/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/page.meta.js +34 -0
- package/dist/modules/documents/backend/documents/templates/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js +139 -0
- package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js.map +7 -0
- package/dist/modules/documents/backend/documents/useDocumentsList.js +314 -0
- package/dist/modules/documents/backend/documents/useDocumentsList.js.map +7 -0
- package/dist/modules/documents/ce.js +8 -0
- package/dist/modules/documents/ce.js.map +7 -0
- package/dist/modules/documents/commands/aggregate.js +99 -0
- package/dist/modules/documents/commands/aggregate.js.map +7 -0
- package/dist/modules/documents/commands/attachments.js +252 -0
- package/dist/modules/documents/commands/attachments.js.map +7 -0
- package/dist/modules/documents/commands/comments.js +782 -0
- package/dist/modules/documents/commands/comments.js.map +7 -0
- package/dist/modules/documents/commands/content.js +238 -0
- package/dist/modules/documents/commands/content.js.map +7 -0
- package/dist/modules/documents/commands/document-crud.js +505 -0
- package/dist/modules/documents/commands/document-crud.js.map +7 -0
- package/dist/modules/documents/commands/documents.js +473 -0
- package/dist/modules/documents/commands/documents.js.map +7 -0
- package/dist/modules/documents/commands/duplicate.js +640 -0
- package/dist/modules/documents/commands/duplicate.js.map +7 -0
- package/dist/modules/documents/commands/favorites.js +150 -0
- package/dist/modules/documents/commands/favorites.js.map +7 -0
- package/dist/modules/documents/commands/folders.js +420 -0
- package/dist/modules/documents/commands/folders.js.map +7 -0
- package/dist/modules/documents/commands/index.js +64 -0
- package/dist/modules/documents/commands/index.js.map +7 -0
- package/dist/modules/documents/commands/interceptors.js +300 -0
- package/dist/modules/documents/commands/interceptors.js.map +7 -0
- package/dist/modules/documents/commands/lifecycle.js +249 -0
- package/dist/modules/documents/commands/lifecycle.js.map +7 -0
- package/dist/modules/documents/commands/links.js +410 -0
- package/dist/modules/documents/commands/links.js.map +7 -0
- package/dist/modules/documents/commands/mutation-helpers.js +42 -0
- package/dist/modules/documents/commands/mutation-helpers.js.map +7 -0
- package/dist/modules/documents/commands/projection-types.js +1 -0
- package/dist/modules/documents/commands/projection-types.js.map +7 -0
- package/dist/modules/documents/commands/shared.js +143 -0
- package/dist/modules/documents/commands/shared.js.map +7 -0
- package/dist/modules/documents/commands/shares.js +527 -0
- package/dist/modules/documents/commands/shares.js.map +7 -0
- package/dist/modules/documents/commands/side-effects.js +103 -0
- package/dist/modules/documents/commands/side-effects.js.map +7 -0
- package/dist/modules/documents/commands/templates.js +461 -0
- package/dist/modules/documents/commands/templates.js.map +7 -0
- package/dist/modules/documents/commands/versions.js +432 -0
- package/dist/modules/documents/commands/versions.js.map +7 -0
- package/dist/modules/documents/commands/watchers.js +164 -0
- package/dist/modules/documents/commands/watchers.js.map +7 -0
- package/dist/modules/documents/data/entities.js +653 -0
- package/dist/modules/documents/data/entities.js.map +7 -0
- package/dist/modules/documents/data/extensions.js +44 -0
- package/dist/modules/documents/data/extensions.js.map +7 -0
- package/dist/modules/documents/data/validators.js +219 -0
- package/dist/modules/documents/data/validators.js.map +7 -0
- package/dist/modules/documents/di.js +35 -0
- package/dist/modules/documents/di.js.map +7 -0
- package/dist/modules/documents/encryption.js +12 -0
- package/dist/modules/documents/encryption.js.map +7 -0
- package/dist/modules/documents/events.js +27 -0
- package/dist/modules/documents/events.js.map +7 -0
- package/dist/modules/documents/index.js +19 -0
- package/dist/modules/documents/index.js.map +7 -0
- package/dist/modules/documents/lib/attachmentServicePort.js +30 -0
- package/dist/modules/documents/lib/attachmentServicePort.js.map +7 -0
- package/dist/modules/documents/lib/capabilities.js +32 -0
- package/dist/modules/documents/lib/capabilities.js.map +7 -0
- package/dist/modules/documents/lib/collabCloseEvents.js +17 -0
- package/dist/modules/documents/lib/collabCloseEvents.js.map +7 -0
- package/dist/modules/documents/lib/collabEndpoint.js +22 -0
- package/dist/modules/documents/lib/collabEndpoint.js.map +7 -0
- package/dist/modules/documents/lib/collabMaterializer.js +107 -0
- package/dist/modules/documents/lib/collabMaterializer.js.map +7 -0
- package/dist/modules/documents/lib/collabToken.js +120 -0
- package/dist/modules/documents/lib/collabToken.js.map +7 -0
- package/dist/modules/documents/lib/collaborationAwareness.js +68 -0
- package/dist/modules/documents/lib/collaborationAwareness.js.map +7 -0
- package/dist/modules/documents/lib/commentAnchors.js +15 -0
- package/dist/modules/documents/lib/commentAnchors.js.map +7 -0
- package/dist/modules/documents/lib/constants.js +25 -0
- package/dist/modules/documents/lib/constants.js.map +7 -0
- package/dist/modules/documents/lib/contentService.js +248 -0
- package/dist/modules/documents/lib/contentService.js.map +7 -0
- package/dist/modules/documents/lib/displayLabels.js +23 -0
- package/dist/modules/documents/lib/displayLabels.js.map +7 -0
- package/dist/modules/documents/lib/docxRenderer.js +601 -0
- package/dist/modules/documents/lib/docxRenderer.js.map +7 -0
- package/dist/modules/documents/lib/duplicateContent.js +22 -0
- package/dist/modules/documents/lib/duplicateContent.js.map +7 -0
- package/dist/modules/documents/lib/editorConfig.js +287 -0
- package/dist/modules/documents/lib/editorConfig.js.map +7 -0
- package/dist/modules/documents/lib/entityLinks.js +148 -0
- package/dist/modules/documents/lib/entityLinks.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistry.js +258 -0
- package/dist/modules/documents/lib/entityRegistry.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistry.server.js +189 -0
- package/dist/modules/documents/lib/entityRegistry.server.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistryAvailability.server.js +9 -0
- package/dist/modules/documents/lib/entityRegistryAvailability.server.js.map +7 -0
- package/dist/modules/documents/lib/entitySuggestion.js +50 -0
- package/dist/modules/documents/lib/entitySuggestion.js.map +7 -0
- package/dist/modules/documents/lib/favorites.js +22 -0
- package/dist/modules/documents/lib/favorites.js.map +7 -0
- package/dist/modules/documents/lib/folderHierarchySerialization.js +19 -0
- package/dist/modules/documents/lib/folderHierarchySerialization.js.map +7 -0
- package/dist/modules/documents/lib/historyLimits.js +100 -0
- package/dist/modules/documents/lib/historyLimits.js.map +7 -0
- package/dist/modules/documents/lib/historyPolicy.js +14 -0
- package/dist/modules/documents/lib/historyPolicy.js.map +7 -0
- package/dist/modules/documents/lib/organizationAccess.js +17 -0
- package/dist/modules/documents/lib/organizationAccess.js.map +7 -0
- package/dist/modules/documents/lib/pdfHtml.js +62 -0
- package/dist/modules/documents/lib/pdfHtml.js.map +7 -0
- package/dist/modules/documents/lib/pdfRenderer.js +284 -0
- package/dist/modules/documents/lib/pdfRenderer.js.map +7 -0
- package/dist/modules/documents/lib/permissions.js +222 -0
- package/dist/modules/documents/lib/permissions.js.map +7 -0
- package/dist/modules/documents/lib/platformServices.js +35 -0
- package/dist/modules/documents/lib/platformServices.js.map +7 -0
- package/dist/modules/documents/lib/recordFieldInsertion.js +58 -0
- package/dist/modules/documents/lib/recordFieldInsertion.js.map +7 -0
- package/dist/modules/documents/lib/requestBody.js +80 -0
- package/dist/modules/documents/lib/requestBody.js.map +7 -0
- package/dist/modules/documents/lib/resourceLimits.js +62 -0
- package/dist/modules/documents/lib/resourceLimits.js.map +7 -0
- package/dist/modules/documents/lib/shareCounts.js +25 -0
- package/dist/modules/documents/lib/shareCounts.js.map +7 -0
- package/dist/modules/documents/lib/templateFill.js +84 -0
- package/dist/modules/documents/lib/templateFill.js.map +7 -0
- package/dist/modules/documents/lib/templateInstantiation.js +147 -0
- package/dist/modules/documents/lib/templateInstantiation.js.map +7 -0
- package/dist/modules/documents/lib/templatePreviewDigest.js +82 -0
- package/dist/modules/documents/lib/templatePreviewDigest.js.map +7 -0
- package/dist/modules/documents/lib/templateSeeds.js +201 -0
- package/dist/modules/documents/lib/templateSeeds.js.map +7 -0
- package/dist/modules/documents/lib/userLabels.js +37 -0
- package/dist/modules/documents/lib/userLabels.js.map +7 -0
- package/dist/modules/documents/lib/versionContent.js +131 -0
- package/dist/modules/documents/lib/versionContent.js.map +7 -0
- package/dist/modules/documents/lib/versionLabels.js +12 -0
- package/dist/modules/documents/lib/versionLabels.js.map +7 -0
- package/dist/modules/documents/lib/versioning.js +14 -0
- package/dist/modules/documents/lib/versioning.js.map +7 -0
- package/dist/modules/documents/lib/visibility.js +422 -0
- package/dist/modules/documents/lib/visibility.js.map +7 -0
- package/dist/modules/documents/lib/watchers.js +106 -0
- package/dist/modules/documents/lib/watchers.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260708163836_documents.js +44 -0
- package/dist/modules/documents/migrations/Migration20260708163836_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260709164720_documents.js +17 -0
- package/dist/modules/documents/migrations/Migration20260709164720_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260710002318_documents.js +32 -0
- package/dist/modules/documents/migrations/Migration20260710002318_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260710071003_documents.js +13 -0
- package/dist/modules/documents/migrations/Migration20260710071003_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260712120000_documents.js +13 -0
- package/dist/modules/documents/migrations/Migration20260712120000_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260712183000_documents.js +14 -0
- package/dist/modules/documents/migrations/Migration20260712183000_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260713092156_documents.js +29 -0
- package/dist/modules/documents/migrations/Migration20260713092156_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260717000000_documents.js +37 -0
- package/dist/modules/documents/migrations/Migration20260717000000_documents.js.map +7 -0
- package/dist/modules/documents/notifications.js +47 -0
- package/dist/modules/documents/notifications.js.map +7 -0
- package/dist/modules/documents/search.js +101 -0
- package/dist/modules/documents/search.js.map +7 -0
- package/dist/modules/documents/setup.js +19 -0
- package/dist/modules/documents/setup.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js +214 -0
- package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/context.js +84 -0
- package/dist/modules/documents/widgets/injection/related-documents/context.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js +98 -0
- package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.client.js +83 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.client.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.js +19 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.js.map +7 -0
- package/dist/modules/documents/widgets/injection-table.js +21 -0
- package/dist/modules/documents/widgets/injection-table.js.map +7 -0
- package/dist/server/documents-collab-server.js +2260 -0
- package/dist/server/documents-collab-server.js.map +7 -0
- package/generated/entities/document/index.ts +12 -0
- package/generated/entities/document_attachment/index.ts +9 -0
- package/generated/entities/document_comment/index.ts +14 -0
- package/generated/entities/document_content/index.ts +11 -0
- package/generated/entities/document_entity_link/index.ts +19 -0
- package/generated/entities/document_favorite/index.ts +7 -0
- package/generated/entities/document_folder/index.ts +9 -0
- package/generated/entities/document_share/index.ts +11 -0
- package/generated/entities/document_template/index.ts +13 -0
- package/generated/entities/document_version/index.ts +9 -0
- package/generated/entities/document_watcher/index.ts +7 -0
- package/generated/entities.ids.generated.ts +21 -0
- package/generated/entity-fields-registry.ts +151 -0
- package/jest.config.cjs +34 -0
- package/package.json +149 -0
- package/server/documents-collab-server.ts +3416 -0
- package/src/index.ts +1 -0
- package/src/modules/documents/acl.ts +11 -0
- package/src/modules/documents/api/[id]/archive/route.ts +132 -0
- package/src/modules/documents/api/[id]/attachments/[attachmentId]/route.ts +166 -0
- package/src/modules/documents/api/[id]/attachments/route.ts +173 -0
- package/src/modules/documents/api/[id]/collab-token/route.ts +203 -0
- package/src/modules/documents/api/[id]/comments/access-check/route.ts +96 -0
- package/src/modules/documents/api/[id]/comments/route.ts +442 -0
- package/src/modules/documents/api/[id]/content/route.ts +156 -0
- package/src/modules/documents/api/[id]/duplicate/route.ts +231 -0
- package/src/modules/documents/api/[id]/export/route.ts +535 -0
- package/src/modules/documents/api/[id]/favorite/route.ts +110 -0
- package/src/modules/documents/api/[id]/links/[linkId]/route.ts +92 -0
- package/src/modules/documents/api/[id]/links/route.ts +301 -0
- package/src/modules/documents/api/[id]/principals/route.ts +375 -0
- package/src/modules/documents/api/[id]/route.ts +267 -0
- package/src/modules/documents/api/[id]/shares/route.ts +372 -0
- package/src/modules/documents/api/[id]/unarchive/route.ts +42 -0
- package/src/modules/documents/api/[id]/versions/[versionId]/restore/route.ts +152 -0
- package/src/modules/documents/api/[id]/versions/[versionId]/route.ts +100 -0
- package/src/modules/documents/api/[id]/versions/route.ts +207 -0
- package/src/modules/documents/api/[id]/watch/route.ts +111 -0
- package/src/modules/documents/api/_commands.ts +53 -0
- package/src/modules/documents/api/_shared.ts +676 -0
- package/src/modules/documents/api/folders/route.ts +287 -0
- package/src/modules/documents/api/instantiate/route.ts +114 -0
- package/src/modules/documents/api/route.ts +362 -0
- package/src/modules/documents/api/templates/[templateId]/preview/route.ts +97 -0
- package/src/modules/documents/api/templates/[templateId]/route.ts +92 -0
- package/src/modules/documents/api/templates/route.ts +370 -0
- package/src/modules/documents/backend/documents/DocumentsPageClient.tsx +150 -0
- package/src/modules/documents/backend/documents/DocumentsTable.tsx +168 -0
- package/src/modules/documents/backend/documents/FolderDialog.tsx +62 -0
- package/src/modules/documents/backend/documents/FolderTree.tsx +72 -0
- package/src/modules/documents/backend/documents/MoveDocumentDialog.tsx +70 -0
- package/src/modules/documents/backend/documents/[id]/CommentAnchorNavigation.ts +88 -0
- package/src/modules/documents/backend/documents/[id]/CommentComposer.tsx +136 -0
- package/src/modules/documents/backend/documents/[id]/CommentThreadList.tsx +131 -0
- package/src/modules/documents/backend/documents/[id]/CommentsRail.tsx +138 -0
- package/src/modules/documents/backend/documents/[id]/DocumentCanvas.tsx +111 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.tsx +39 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorIsland.tsx +50 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorSurface.tsx +162 -0
- package/src/modules/documents/backend/documents/[id]/DocumentNavigator.tsx +129 -0
- package/src/modules/documents/backend/documents/[id]/DocumentPageClient.tsx +463 -0
- package/src/modules/documents/backend/documents/[id]/EditorColorTools.tsx +71 -0
- package/src/modules/documents/backend/documents/[id]/EditorStatusPresence.tsx +78 -0
- package/src/modules/documents/backend/documents/[id]/EditorToolbar.tsx +108 -0
- package/src/modules/documents/backend/documents/[id]/ExportMenu.tsx +144 -0
- package/src/modules/documents/backend/documents/[id]/MentionPicker.tsx +137 -0
- package/src/modules/documents/backend/documents/[id]/OutlinePane.tsx +98 -0
- package/src/modules/documents/backend/documents/[id]/RecordFieldsDialog.tsx +185 -0
- package/src/modules/documents/backend/documents/[id]/RelatedRecordsPanel.tsx +320 -0
- package/src/modules/documents/backend/documents/[id]/VersionHistoryPanel.tsx +244 -0
- package/src/modules/documents/backend/documents/[id]/VersionPreviewDialog.tsx +197 -0
- package/src/modules/documents/backend/documents/[id]/commentTypes.ts +192 -0
- package/src/modules/documents/backend/documents/[id]/componentCapabilities.ts +17 -0
- package/src/modules/documents/backend/documents/[id]/documentPagination.ts +352 -0
- package/src/modules/documents/backend/documents/[id]/editorPresenceStyles.ts +77 -0
- package/src/modules/documents/backend/documents/[id]/editorTypes.ts +84 -0
- package/src/modules/documents/backend/documents/[id]/page.meta.ts +12 -0
- package/src/modules/documents/backend/documents/[id]/page.tsx +6 -0
- package/src/modules/documents/backend/documents/[id]/relatedRecordModel.ts +49 -0
- package/src/modules/documents/backend/documents/[id]/restoreVersion.ts +49 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentCollaboration.ts +458 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentComments.ts +286 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentEditor.ts +157 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentTitle.ts +77 -0
- package/src/modules/documents/backend/documents/[id]/useEditorInsertions.ts +147 -0
- package/src/modules/documents/backend/documents/[id]/useFallbackContentPersistence.ts +277 -0
- package/src/modules/documents/backend/documents/[id]/useMentionPicker.ts +259 -0
- package/src/modules/documents/backend/documents/[id]/versionHistoryModel.ts +29 -0
- package/src/modules/documents/backend/documents/components/EntityPicker.tsx +171 -0
- package/src/modules/documents/backend/documents/components/EntityPickerResults.tsx +64 -0
- package/src/modules/documents/backend/documents/components/NewFromTemplateDialog.tsx +136 -0
- package/src/modules/documents/backend/documents/components/PrincipalPicker.tsx +90 -0
- package/src/modules/documents/backend/documents/components/ShareDialog.tsx +88 -0
- package/src/modules/documents/backend/documents/components/ShareDialogAddForm.tsx +113 -0
- package/src/modules/documents/backend/documents/components/ShareDialogList.tsx +117 -0
- package/src/modules/documents/backend/documents/components/TemplateBodyEditor.tsx +96 -0
- package/src/modules/documents/backend/documents/components/TemplateEditorDialog.tsx +171 -0
- package/src/modules/documents/backend/documents/components/TemplatePreview.tsx +43 -0
- package/src/modules/documents/backend/documents/components/TemplateSlotFields.tsx +72 -0
- package/src/modules/documents/backend/documents/components/TemplateSlotsEditor.tsx +72 -0
- package/src/modules/documents/backend/documents/components/principalPickerModel.ts +86 -0
- package/src/modules/documents/backend/documents/components/shareDialogModel.ts +94 -0
- package/src/modules/documents/backend/documents/components/templateUi.ts +128 -0
- package/src/modules/documents/backend/documents/components/useAvailableEntityRegistry.ts +43 -0
- package/src/modules/documents/backend/documents/components/useEntitySearch.ts +197 -0
- package/src/modules/documents/backend/documents/components/usePrincipalPicker.ts +165 -0
- package/src/modules/documents/backend/documents/components/useShareDialog.ts +267 -0
- package/src/modules/documents/backend/documents/components/useTemplateDetail.ts +54 -0
- package/src/modules/documents/backend/documents/components/useTemplateInstantiation.ts +252 -0
- package/src/modules/documents/backend/documents/documentUi.ts +134 -0
- package/src/modules/documents/backend/documents/documentsListTypes.ts +163 -0
- package/src/modules/documents/backend/documents/page.meta.ts +24 -0
- package/src/modules/documents/backend/documents/page.tsx +5 -0
- package/src/modules/documents/backend/documents/templates/TemplatesPageClient.tsx +93 -0
- package/src/modules/documents/backend/documents/templates/TemplatesTable.tsx +71 -0
- package/src/modules/documents/backend/documents/templates/page.meta.ts +32 -0
- package/src/modules/documents/backend/documents/templates/page.tsx +5 -0
- package/src/modules/documents/backend/documents/templates/useTemplatesPage.tsx +148 -0
- package/src/modules/documents/backend/documents/useDocumentsList.tsx +305 -0
- package/src/modules/documents/ce.ts +6 -0
- package/src/modules/documents/commands/aggregate.ts +128 -0
- package/src/modules/documents/commands/attachments.ts +309 -0
- package/src/modules/documents/commands/comments.ts +966 -0
- package/src/modules/documents/commands/content.ts +294 -0
- package/src/modules/documents/commands/document-crud.ts +609 -0
- package/src/modules/documents/commands/documents.ts +581 -0
- package/src/modules/documents/commands/duplicate.ts +772 -0
- package/src/modules/documents/commands/favorites.ts +171 -0
- package/src/modules/documents/commands/folders.ts +506 -0
- package/src/modules/documents/commands/index.ts +33 -0
- package/src/modules/documents/commands/interceptors.ts +402 -0
- package/src/modules/documents/commands/lifecycle.ts +333 -0
- package/src/modules/documents/commands/links.ts +486 -0
- package/src/modules/documents/commands/mutation-helpers.ts +48 -0
- package/src/modules/documents/commands/projection-types.ts +77 -0
- package/src/modules/documents/commands/shared.ts +219 -0
- package/src/modules/documents/commands/shares.ts +612 -0
- package/src/modules/documents/commands/side-effects.ts +130 -0
- package/src/modules/documents/commands/templates.ts +522 -0
- package/src/modules/documents/commands/versions.ts +537 -0
- package/src/modules/documents/commands/watchers.ts +181 -0
- package/src/modules/documents/data/entities.ts +631 -0
- package/src/modules/documents/data/extensions.ts +42 -0
- package/src/modules/documents/data/validators.ts +248 -0
- package/src/modules/documents/di.ts +33 -0
- package/src/modules/documents/encryption.ts +14 -0
- package/src/modules/documents/events.ts +23 -0
- package/src/modules/documents/i18n/.hardcoded-allowlist.json +9 -0
- package/src/modules/documents/i18n/de.json +522 -0
- package/src/modules/documents/i18n/en.json +522 -0
- package/src/modules/documents/i18n/es.json +522 -0
- package/src/modules/documents/i18n/ko.json +522 -0
- package/src/modules/documents/i18n/pl.json +522 -0
- package/src/modules/documents/index.ts +17 -0
- package/src/modules/documents/lib/attachmentServicePort.ts +94 -0
- package/src/modules/documents/lib/capabilities.ts +57 -0
- package/src/modules/documents/lib/collabCloseEvents.ts +26 -0
- package/src/modules/documents/lib/collabEndpoint.ts +43 -0
- package/src/modules/documents/lib/collabMaterializer.ts +140 -0
- package/src/modules/documents/lib/collabToken.ts +170 -0
- package/src/modules/documents/lib/collaborationAwareness.ts +102 -0
- package/src/modules/documents/lib/commentAnchors.ts +19 -0
- package/src/modules/documents/lib/constants.ts +39 -0
- package/src/modules/documents/lib/contentService.ts +340 -0
- package/src/modules/documents/lib/displayLabels.ts +31 -0
- package/src/modules/documents/lib/docxRenderer.ts +685 -0
- package/src/modules/documents/lib/duplicateContent.ts +32 -0
- package/src/modules/documents/lib/editorConfig.ts +371 -0
- package/src/modules/documents/lib/entityLinks.ts +250 -0
- package/src/modules/documents/lib/entityRegistry.server.ts +267 -0
- package/src/modules/documents/lib/entityRegistry.ts +345 -0
- package/src/modules/documents/lib/entityRegistryAvailability.server.ts +19 -0
- package/src/modules/documents/lib/entitySuggestion.ts +61 -0
- package/src/modules/documents/lib/favorites.ts +35 -0
- package/src/modules/documents/lib/folderHierarchySerialization.ts +34 -0
- package/src/modules/documents/lib/historyLimits.ts +154 -0
- package/src/modules/documents/lib/historyPolicy.ts +7 -0
- package/src/modules/documents/lib/organizationAccess.ts +44 -0
- package/src/modules/documents/lib/pdfHtml.ts +65 -0
- package/src/modules/documents/lib/pdfRenderer.ts +367 -0
- package/src/modules/documents/lib/permissions.ts +299 -0
- package/src/modules/documents/lib/platformServices.ts +70 -0
- package/src/modules/documents/lib/recordFieldInsertion.ts +72 -0
- package/src/modules/documents/lib/requestBody.ts +97 -0
- package/src/modules/documents/lib/resourceLimits.ts +94 -0
- package/src/modules/documents/lib/shareCounts.ts +44 -0
- package/src/modules/documents/lib/templateFill.ts +138 -0
- package/src/modules/documents/lib/templateInstantiation.ts +206 -0
- package/src/modules/documents/lib/templatePreviewDigest.ts +122 -0
- package/src/modules/documents/lib/templateSeeds.ts +248 -0
- package/src/modules/documents/lib/userLabels.ts +58 -0
- package/src/modules/documents/lib/versionContent.ts +163 -0
- package/src/modules/documents/lib/versionLabels.ts +9 -0
- package/src/modules/documents/lib/versioning.ts +29 -0
- package/src/modules/documents/lib/visibility.ts +610 -0
- package/src/modules/documents/lib/watchers.ts +129 -0
- package/src/modules/documents/migrations/.snapshot-open-mercato.json +2892 -0
- package/src/modules/documents/migrations/Migration20260708163836_documents.ts +50 -0
- package/src/modules/documents/migrations/Migration20260709164720_documents.ts +19 -0
- package/src/modules/documents/migrations/Migration20260710002318_documents.ts +35 -0
- package/src/modules/documents/migrations/Migration20260710071003_documents.ts +13 -0
- package/src/modules/documents/migrations/Migration20260712120000_documents.ts +13 -0
- package/src/modules/documents/migrations/Migration20260712183000_documents.ts +12 -0
- package/src/modules/documents/migrations/Migration20260713092156_documents.ts +43 -0
- package/src/modules/documents/migrations/Migration20260717000000_documents.ts +40 -0
- package/src/modules/documents/notifications.ts +45 -0
- package/src/modules/documents/search.ts +118 -0
- package/src/modules/documents/setup.ts +19 -0
- package/src/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.tsx +224 -0
- package/src/modules/documents/widgets/injection/related-documents/context.ts +101 -0
- package/src/modules/documents/widgets/injection/related-documents/useRelatedDocuments.ts +112 -0
- package/src/modules/documents/widgets/injection/related-documents/widget.client.tsx +76 -0
- package/src/modules/documents/widgets/injection/related-documents/widget.ts +19 -0
- package/src/modules/documents/widgets/injection-table.ts +20 -0
- package/tsconfig.json +9 -0
- package/watch.mjs +6 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
5
|
+
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@open-mercato/ui/primitives/dialog'
|
|
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 type { FolderRow } from './documentsListTypes'
|
|
10
|
+
|
|
11
|
+
export type FolderDialogState = { mode: 'create'; parentFolderId: string | null } | { mode: 'rename'; folder: FolderRow }
|
|
12
|
+
|
|
13
|
+
export function FolderDialog({ state, onOpenChange, onSubmit }: {
|
|
14
|
+
state: FolderDialogState | null
|
|
15
|
+
onOpenChange: (open: boolean) => void
|
|
16
|
+
onSubmit: (name: string) => boolean | void | Promise<boolean | void>
|
|
17
|
+
}) {
|
|
18
|
+
const t = useT()
|
|
19
|
+
const inputId = React.useId()
|
|
20
|
+
const [name, setName] = React.useState('')
|
|
21
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false)
|
|
22
|
+
React.useEffect(() => setName(state?.mode === 'rename' ? state.folder.name : ''), [state])
|
|
23
|
+
|
|
24
|
+
const submit = React.useCallback(async () => {
|
|
25
|
+
const nextName = name.trim()
|
|
26
|
+
if (!nextName || isSubmitting) return
|
|
27
|
+
setIsSubmitting(true)
|
|
28
|
+
try {
|
|
29
|
+
const result = await onSubmit(nextName)
|
|
30
|
+
// Preserve the legacy void callback contract while allowing callers to
|
|
31
|
+
// keep the dialog open by returning false after a handled failure.
|
|
32
|
+
if (result !== false) onOpenChange(false)
|
|
33
|
+
} finally {
|
|
34
|
+
setIsSubmitting(false)
|
|
35
|
+
}
|
|
36
|
+
}, [isSubmitting, name, onOpenChange, onSubmit])
|
|
37
|
+
|
|
38
|
+
const handleOpenChange = React.useCallback((open: boolean) => {
|
|
39
|
+
if (!isSubmitting) onOpenChange(open)
|
|
40
|
+
}, [isSubmitting, onOpenChange])
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Dialog open={state !== null} onOpenChange={handleOpenChange}>
|
|
44
|
+
<DialogContent onKeyDown={(event) => {
|
|
45
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter' && name.trim() && !isSubmitting) { event.preventDefault(); void submit() }
|
|
46
|
+
if (event.key === 'Escape' && !isSubmitting) onOpenChange(false)
|
|
47
|
+
}}>
|
|
48
|
+
<DialogHeader><DialogTitle>{state?.mode === 'rename' ? t('documents.folders.renameTitle') : t('documents.folders.createTitle')}</DialogTitle></DialogHeader>
|
|
49
|
+
<form className="space-y-4" onSubmit={(event) => { event.preventDefault(); void submit() }}>
|
|
50
|
+
<div className="space-y-2">
|
|
51
|
+
<Label htmlFor={inputId}>{t('documents.folders.name')}</Label>
|
|
52
|
+
<Input id={inputId} value={name} onChange={(event) => setName(event.target.value)} placeholder={t('documents.folders.namePlaceholder')} disabled={isSubmitting} />
|
|
53
|
+
</div>
|
|
54
|
+
<DialogFooter>
|
|
55
|
+
<Button type="button" variant="outline" onClick={() => onOpenChange(false)} disabled={isSubmitting}>{t('documents.actions.cancel')}</Button>
|
|
56
|
+
<Button type="submit" disabled={!name.trim() || isSubmitting}>{state?.mode === 'rename' ? t('documents.folders.actions.rename') : t('documents.folders.actions.create')}</Button>
|
|
57
|
+
</DialogFooter>
|
|
58
|
+
</form>
|
|
59
|
+
</DialogContent>
|
|
60
|
+
</Dialog>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { RowActions } from '@open-mercato/ui/backend/RowActions'
|
|
5
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
7
|
+
import { buildFolderTree, type FolderNode, type FolderRow } from './documentsListTypes'
|
|
8
|
+
|
|
9
|
+
type FolderTreeProps = {
|
|
10
|
+
folders: FolderRow[]
|
|
11
|
+
selectedFolderId: string | null
|
|
12
|
+
onSelect: (folderId: string | null) => void
|
|
13
|
+
onCreate: (parentFolderId: string | null) => void
|
|
14
|
+
onRename: (folder: FolderRow) => void
|
|
15
|
+
onDelete: (folder: FolderRow) => void
|
|
16
|
+
canCreateFolder: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function FolderNodes({ nodes, selectedFolderId, onSelect, onRename, onDelete }: {
|
|
20
|
+
nodes: FolderNode[]
|
|
21
|
+
selectedFolderId: string | null
|
|
22
|
+
onSelect: (folderId: string) => void
|
|
23
|
+
onRename: (folder: FolderRow) => void
|
|
24
|
+
onDelete: (folder: FolderRow) => void
|
|
25
|
+
}) {
|
|
26
|
+
const t = useT()
|
|
27
|
+
return (
|
|
28
|
+
<ul className="space-y-1">
|
|
29
|
+
{nodes.map((node) => (
|
|
30
|
+
<li key={node.id} className="space-y-1">
|
|
31
|
+
<div className="flex items-center gap-1">
|
|
32
|
+
<Button type="button" aria-current={selectedFolderId === node.id ? 'page' : undefined} variant={selectedFolderId === node.id ? 'secondary' : 'ghost'} className="min-w-0 flex-1 justify-start" onClick={() => onSelect(node.id)}>
|
|
33
|
+
<span className={node.visibility === 'ancestor' ? 'truncate text-muted-foreground' : 'truncate'}>{node.name}</span>
|
|
34
|
+
</Button>
|
|
35
|
+
{node.canEdit ? (
|
|
36
|
+
<RowActions items={[
|
|
37
|
+
{ id: 'rename', label: t('documents.folders.actions.rename'), onSelect: () => onRename(node) },
|
|
38
|
+
{ id: 'delete', label: t('documents.actions.delete'), destructive: true, onSelect: () => onDelete(node) },
|
|
39
|
+
]} />
|
|
40
|
+
) : null}
|
|
41
|
+
</div>
|
|
42
|
+
{node.visibility === 'ancestor' ? <p className="pl-3 text-xs text-muted-foreground">{t('documents.folders.visibility.ancestor')}</p> : null}
|
|
43
|
+
{node.visibility === 'contains-visible' ? <p className="pl-3 text-xs text-muted-foreground">{t('documents.folders.visibility.shared')}</p> : null}
|
|
44
|
+
{node.children.length > 0 ? <div className="ml-4"><FolderNodes nodes={node.children} selectedFolderId={selectedFolderId} onSelect={onSelect} onRename={onRename} onDelete={onDelete} /></div> : null}
|
|
45
|
+
</li>
|
|
46
|
+
))}
|
|
47
|
+
</ul>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function FolderTree(props: FolderTreeProps) {
|
|
52
|
+
const t = useT()
|
|
53
|
+
const tree = React.useMemo(() => buildFolderTree(props.folders), [props.folders])
|
|
54
|
+
const selected = props.selectedFolderId ? props.folders.find((folder) => folder.id === props.selectedFolderId) : null
|
|
55
|
+
return (
|
|
56
|
+
<aside className="space-y-3 rounded-lg border border-border bg-card p-4 lg:col-span-1 lg:max-h-screen lg:self-start lg:overflow-y-auto">
|
|
57
|
+
<div className="flex items-center justify-between gap-2">
|
|
58
|
+
<h2 className="text-sm font-semibold">{t('documents.folders.title')}</h2>
|
|
59
|
+
{props.canCreateFolder ? (
|
|
60
|
+
<Button type="button" size="sm" variant="outline" onClick={() => props.onCreate(selected?.canEdit ? selected.id : null)}>
|
|
61
|
+
{t(selected && !selected.canEdit ? 'documents.folders.actions.newAtRoot' : 'documents.folders.actions.new')}
|
|
62
|
+
</Button>
|
|
63
|
+
) : null}
|
|
64
|
+
</div>
|
|
65
|
+
{props.canCreateFolder && selected && !selected.canEdit ? <p className="text-xs text-muted-foreground">{t('documents.folders.newAtRootHint')}</p> : null}
|
|
66
|
+
<Button type="button" aria-current={props.selectedFolderId === null ? 'page' : undefined} variant={props.selectedFolderId === null ? 'secondary' : 'ghost'} className="w-full justify-start" onClick={() => props.onSelect(null)}>{t('documents.folders.root')}</Button>
|
|
67
|
+
{tree.length > 0 ? (
|
|
68
|
+
<FolderNodes nodes={tree} selectedFolderId={props.selectedFolderId} onSelect={(id) => props.onSelect(id)} onRename={props.onRename} onDelete={props.onDelete} />
|
|
69
|
+
) : <p className="rounded-md border border-border bg-muted/20 p-3 text-sm text-muted-foreground">{t('documents.folders.empty')}</p>}
|
|
70
|
+
</aside>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
5
|
+
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@open-mercato/ui/primitives/dialog'
|
|
6
|
+
import { Label } from '@open-mercato/ui/primitives/label'
|
|
7
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@open-mercato/ui/primitives/select'
|
|
8
|
+
import { useDialogKeyHandler } from '@open-mercato/ui/hooks/useDialogKeyHandler'
|
|
9
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
10
|
+
import type { DocumentRow, FolderRow } from './documentsListTypes'
|
|
11
|
+
|
|
12
|
+
const ROOT_VALUE = '__documents_root__'
|
|
13
|
+
|
|
14
|
+
export function MoveDocumentDialog({ document, folders, open, onOpenChange, onMove }: {
|
|
15
|
+
document: DocumentRow | null
|
|
16
|
+
folders: FolderRow[]
|
|
17
|
+
open: boolean
|
|
18
|
+
onOpenChange: (open: boolean) => void
|
|
19
|
+
onMove: (document: DocumentRow, folderId: string | null) => Promise<boolean | void>
|
|
20
|
+
}) {
|
|
21
|
+
const t = useT()
|
|
22
|
+
const [value, setValue] = React.useState(ROOT_VALUE)
|
|
23
|
+
const [saving, setSaving] = React.useState(false)
|
|
24
|
+
const writableFolders = React.useMemo(() => folders.filter((folder) => folder.canEdit), [folders])
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
if (document && open) setValue(document.folderId ?? ROOT_VALUE)
|
|
27
|
+
}, [document, open])
|
|
28
|
+
const submit = React.useCallback(async () => {
|
|
29
|
+
if (!document || saving || (document.folderId ?? ROOT_VALUE) === value) return
|
|
30
|
+
setSaving(true)
|
|
31
|
+
try {
|
|
32
|
+
const result = await onMove(document, value === ROOT_VALUE ? null : value)
|
|
33
|
+
if (result !== false) onOpenChange(false)
|
|
34
|
+
} finally {
|
|
35
|
+
setSaving(false)
|
|
36
|
+
}
|
|
37
|
+
}, [document, onMove, onOpenChange, saving, value])
|
|
38
|
+
const onKeyDown = useDialogKeyHandler({
|
|
39
|
+
onConfirm: () => { if (!saving) void submit() },
|
|
40
|
+
onCancel: () => { if (!saving) onOpenChange(false) },
|
|
41
|
+
})
|
|
42
|
+
const handleOpenChange = React.useCallback((nextOpen: boolean) => {
|
|
43
|
+
if (!saving) onOpenChange(nextOpen)
|
|
44
|
+
}, [onOpenChange, saving])
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Dialog open={open} onOpenChange={handleOpenChange}>
|
|
48
|
+
<DialogContent onKeyDown={onKeyDown}>
|
|
49
|
+
<DialogHeader>
|
|
50
|
+
<DialogTitle>{t('documents.folders.moveDocument.title')}</DialogTitle>
|
|
51
|
+
<DialogDescription>{t('documents.folders.moveDocument.description', { title: document?.title ?? '' })}</DialogDescription>
|
|
52
|
+
</DialogHeader>
|
|
53
|
+
<div className="space-y-2">
|
|
54
|
+
<Label htmlFor="documents-move-folder">{t('documents.columns.folder')}</Label>
|
|
55
|
+
<Select value={value} onValueChange={setValue} disabled={saving}>
|
|
56
|
+
<SelectTrigger id="documents-move-folder"><SelectValue /></SelectTrigger>
|
|
57
|
+
<SelectContent>
|
|
58
|
+
<SelectItem value={ROOT_VALUE}>{t('documents.folders.root')}</SelectItem>
|
|
59
|
+
{writableFolders.map((folder) => <SelectItem key={folder.id} value={folder.id}>{folder.name}</SelectItem>)}
|
|
60
|
+
</SelectContent>
|
|
61
|
+
</Select>
|
|
62
|
+
</div>
|
|
63
|
+
<DialogFooter>
|
|
64
|
+
<Button type="button" variant="outline" onClick={() => onOpenChange(false)} disabled={saving}>{t('documents.actions.cancel')}</Button>
|
|
65
|
+
<Button type="button" onClick={() => void submit()} disabled={saving || !document || (document.folderId ?? ROOT_VALUE) === value}>{t('documents.folders.actions.moveDocument')}</Button>
|
|
66
|
+
</DialogFooter>
|
|
67
|
+
</DialogContent>
|
|
68
|
+
</Dialog>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core'
|
|
2
|
+
// Keep this aligned with @tiptap/extension-collaboration. The similarly named
|
|
3
|
+
// y-prosemirror plugin key is a different instance and cannot read its binding.
|
|
4
|
+
import {
|
|
5
|
+
absolutePositionToRelativePosition,
|
|
6
|
+
relativePositionToAbsolutePosition,
|
|
7
|
+
ySyncPluginKey,
|
|
8
|
+
type ProsemirrorBinding,
|
|
9
|
+
} from '@tiptap/y-tiptap'
|
|
10
|
+
import * as Y from 'yjs'
|
|
11
|
+
|
|
12
|
+
export type LegacyCommentAnchor = { from: number; to: number }
|
|
13
|
+
export type RelativeCommentAnchor = { version: 2; relativeFrom: string; relativeTo: string }
|
|
14
|
+
export type CommentAnchor = LegacyCommentAnchor | RelativeCommentAnchor
|
|
15
|
+
|
|
16
|
+
type YSyncState = { binding?: ProsemirrorBinding | null }
|
|
17
|
+
|
|
18
|
+
function encodeBase64(value: Uint8Array): string {
|
|
19
|
+
let binary = ''
|
|
20
|
+
for (const byte of value) binary += String.fromCharCode(byte)
|
|
21
|
+
return window.btoa(binary)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function decodeBase64(value: string): Uint8Array | null {
|
|
25
|
+
try {
|
|
26
|
+
const binary = window.atob(value)
|
|
27
|
+
return Uint8Array.from(binary, (character) => character.charCodeAt(0))
|
|
28
|
+
} catch {
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function readBinding(editor: Editor): ProsemirrorBinding | null {
|
|
34
|
+
const pluginState = ySyncPluginKey.getState(editor.state) as YSyncState | undefined
|
|
35
|
+
return pluginState?.binding ?? null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function validRange(editor: Editor, from: number, to: number): boolean {
|
|
39
|
+
const docSize = editor.state.doc.content.size
|
|
40
|
+
return from >= 0 && to >= 0 && from < to && from <= docSize && to <= docSize
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function captureCommentAnchor(editor: Editor): CommentAnchor | null {
|
|
44
|
+
const { from, to } = editor.state.selection
|
|
45
|
+
if (!validRange(editor, from, to)) return null
|
|
46
|
+
const binding = readBinding(editor)
|
|
47
|
+
if (!binding) return { from, to }
|
|
48
|
+
const relativeFrom = absolutePositionToRelativePosition(from, binding.type, binding.mapping)
|
|
49
|
+
const relativeTo = absolutePositionToRelativePosition(to, binding.type, binding.mapping)
|
|
50
|
+
return {
|
|
51
|
+
version: 2,
|
|
52
|
+
relativeFrom: encodeBase64(Y.encodeRelativePosition(relativeFrom)),
|
|
53
|
+
relativeTo: encodeBase64(Y.encodeRelativePosition(relativeTo)),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function resolveCommentAnchor(editor: Editor, anchor: CommentAnchor): LegacyCommentAnchor | null {
|
|
58
|
+
if (!('version' in anchor)) return validRange(editor, anchor.from, anchor.to) ? anchor : null
|
|
59
|
+
const binding = readBinding(editor)
|
|
60
|
+
const encodedFrom = decodeBase64(anchor.relativeFrom)
|
|
61
|
+
const encodedTo = decodeBase64(anchor.relativeTo)
|
|
62
|
+
if (!binding || !encodedFrom || !encodedTo) return null
|
|
63
|
+
try {
|
|
64
|
+
const from = relativePositionToAbsolutePosition(
|
|
65
|
+
binding.doc,
|
|
66
|
+
binding.type,
|
|
67
|
+
Y.decodeRelativePosition(encodedFrom),
|
|
68
|
+
binding.mapping,
|
|
69
|
+
)
|
|
70
|
+
const to = relativePositionToAbsolutePosition(
|
|
71
|
+
binding.doc,
|
|
72
|
+
binding.type,
|
|
73
|
+
Y.decodeRelativePosition(encodedTo),
|
|
74
|
+
binding.mapping,
|
|
75
|
+
)
|
|
76
|
+
return from !== null && to !== null && validRange(editor, from, to) ? { from, to } : null
|
|
77
|
+
} catch {
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function jumpToCommentAnchor(editor: Editor, anchor: CommentAnchor): boolean {
|
|
83
|
+
const range = resolveCommentAnchor(editor, anchor)
|
|
84
|
+
if (!range) return false
|
|
85
|
+
editor.commands.setTextSelection(range)
|
|
86
|
+
editor.commands.focus()
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { AtSign, CornerDownRight, Send, X } from 'lucide-react'
|
|
5
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { Label } from '@open-mercato/ui/primitives/label'
|
|
7
|
+
import { Textarea } from '@open-mercato/ui/primitives/textarea'
|
|
8
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
9
|
+
import { MentionPicker } from './MentionPicker'
|
|
10
|
+
import {
|
|
11
|
+
bodyContainsPendingMention,
|
|
12
|
+
removePendingMentionOccurrences,
|
|
13
|
+
type PendingMention,
|
|
14
|
+
} from './commentTypes'
|
|
15
|
+
|
|
16
|
+
type CommentComposerProps = {
|
|
17
|
+
documentId: string
|
|
18
|
+
body: string
|
|
19
|
+
pendingMentions: PendingMention[]
|
|
20
|
+
replyToName: string | null
|
|
21
|
+
isSubmitting: boolean
|
|
22
|
+
onBodyChange: (body: string) => void
|
|
23
|
+
onMentionsChange: React.Dispatch<React.SetStateAction<PendingMention[]>>
|
|
24
|
+
onSubmit: () => void
|
|
25
|
+
onCancel: () => void
|
|
26
|
+
focusSignal?: number | string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const CommentComposer = React.forwardRef<HTMLFormElement, CommentComposerProps>(function CommentComposer({
|
|
30
|
+
documentId,
|
|
31
|
+
body,
|
|
32
|
+
pendingMentions,
|
|
33
|
+
replyToName,
|
|
34
|
+
isSubmitting,
|
|
35
|
+
onBodyChange,
|
|
36
|
+
onMentionsChange,
|
|
37
|
+
onSubmit,
|
|
38
|
+
onCancel,
|
|
39
|
+
focusSignal,
|
|
40
|
+
}, forwardedRef) {
|
|
41
|
+
const t = useT()
|
|
42
|
+
const composerId = React.useId()
|
|
43
|
+
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
|
|
44
|
+
const [mentionPickerOpen, setMentionPickerOpen] = React.useState(false)
|
|
45
|
+
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (focusSignal === undefined) return
|
|
48
|
+
window.setTimeout(() => textareaRef.current?.focus(), 0)
|
|
49
|
+
}, [focusSignal])
|
|
50
|
+
|
|
51
|
+
const handleMentionPick = React.useCallback((user: { id: string; name: string }) => {
|
|
52
|
+
const userId = user.id.toLowerCase()
|
|
53
|
+
onMentionsChange((current) => current.some((mention) => mention.userId === userId)
|
|
54
|
+
? current
|
|
55
|
+
: [...current, { userId, name: user.name }])
|
|
56
|
+
onBodyChange(`${body}${body.length > 0 && !/\s$/.test(body) ? ' ' : ''}@${user.name} `)
|
|
57
|
+
setMentionPickerOpen(false)
|
|
58
|
+
window.setTimeout(() => textareaRef.current?.focus(), 0)
|
|
59
|
+
}, [body, onBodyChange, onMentionsChange])
|
|
60
|
+
|
|
61
|
+
const handleBodyChange = React.useCallback((nextBody: string) => {
|
|
62
|
+
onBodyChange(nextBody)
|
|
63
|
+
onMentionsChange((current) => current.filter((mention) => bodyContainsPendingMention(nextBody, mention)))
|
|
64
|
+
}, [onBodyChange, onMentionsChange])
|
|
65
|
+
|
|
66
|
+
const removeMention = React.useCallback((mention: PendingMention) => {
|
|
67
|
+
onBodyChange(removePendingMentionOccurrences(body, mention, pendingMentions))
|
|
68
|
+
onMentionsChange((current) => current.filter((candidate) => candidate.userId !== mention.userId))
|
|
69
|
+
window.setTimeout(() => textareaRef.current?.focus(), 0)
|
|
70
|
+
}, [body, onBodyChange, onMentionsChange, pendingMentions])
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<form
|
|
74
|
+
ref={forwardedRef}
|
|
75
|
+
className="space-y-3 rounded-lg border border-border bg-muted/20 p-3"
|
|
76
|
+
onSubmit={(event) => { event.preventDefault(); onSubmit() }}
|
|
77
|
+
onKeyDown={(event) => {
|
|
78
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
79
|
+
event.preventDefault()
|
|
80
|
+
onSubmit()
|
|
81
|
+
}
|
|
82
|
+
if (event.key === 'Escape') {
|
|
83
|
+
event.preventDefault()
|
|
84
|
+
setMentionPickerOpen(false)
|
|
85
|
+
onCancel()
|
|
86
|
+
}
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<div className="space-y-2">
|
|
90
|
+
<Label htmlFor={composerId}>{t('documents.comments.title')}</Label>
|
|
91
|
+
{replyToName ? (
|
|
92
|
+
<p className="inline-flex items-center gap-2 rounded-full bg-muted px-2 py-1 text-xs text-muted-foreground">
|
|
93
|
+
<CornerDownRight className="size-3" aria-hidden="true" />
|
|
94
|
+
{t('documents.comments.replyTo', { name: replyToName })}
|
|
95
|
+
</p>
|
|
96
|
+
) : null}
|
|
97
|
+
<Textarea
|
|
98
|
+
ref={textareaRef}
|
|
99
|
+
id={composerId}
|
|
100
|
+
value={body}
|
|
101
|
+
onChange={(event) => handleBodyChange(event.target.value)}
|
|
102
|
+
placeholder={t('documents.comments.composer.placeholder')}
|
|
103
|
+
maxLength={8000}
|
|
104
|
+
showCount
|
|
105
|
+
disabled={isSubmitting}
|
|
106
|
+
/>
|
|
107
|
+
{pendingMentions.length > 0 ? (
|
|
108
|
+
<div className="flex flex-wrap gap-2" role="group" aria-label={t('documents.comments.mentions.selected')}>
|
|
109
|
+
{pendingMentions.map((mention) => (
|
|
110
|
+
<Button
|
|
111
|
+
key={mention.userId}
|
|
112
|
+
type="button"
|
|
113
|
+
size="sm"
|
|
114
|
+
variant="secondary"
|
|
115
|
+
onClick={() => removeMention(mention)}
|
|
116
|
+
disabled={isSubmitting}
|
|
117
|
+
aria-label={t('documents.comments.mentions.remove', { name: mention.name })}
|
|
118
|
+
>
|
|
119
|
+
@{mention.name}<X aria-hidden="true" />
|
|
120
|
+
</Button>
|
|
121
|
+
))}
|
|
122
|
+
</div>
|
|
123
|
+
) : null}
|
|
124
|
+
</div>
|
|
125
|
+
{mentionPickerOpen ? <MentionPicker documentId={documentId} onPick={handleMentionPick} disabled={isSubmitting} /> : null}
|
|
126
|
+
<div className="flex flex-wrap items-center justify-between gap-2">
|
|
127
|
+
<Button type="button" variant="outline" onClick={() => setMentionPickerOpen((open) => !open)} disabled={isSubmitting}>
|
|
128
|
+
<AtSign />{t('documents.comments.actions.mention')}
|
|
129
|
+
</Button>
|
|
130
|
+
<Button type="submit" disabled={isSubmitting || body.trim().length === 0}>
|
|
131
|
+
<Send />{t('documents.comments.actions.send')}
|
|
132
|
+
</Button>
|
|
133
|
+
</div>
|
|
134
|
+
</form>
|
|
135
|
+
)
|
|
136
|
+
})
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { CheckCircle2, CornerDownRight, RotateCcw } from 'lucide-react'
|
|
5
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { StatusBadge } from '@open-mercato/ui/primitives/status-badge'
|
|
7
|
+
import type { TranslateFn } from '@open-mercato/shared/lib/i18n/context'
|
|
8
|
+
import type { DocumentComment } from './commentTypes'
|
|
9
|
+
|
|
10
|
+
type LabelFor = (userId: string) => string
|
|
11
|
+
type CommentThreadListProps = {
|
|
12
|
+
comments: DocumentComment[]
|
|
13
|
+
canComment: boolean
|
|
14
|
+
resolvingCommentId: string | null
|
|
15
|
+
labelFor: LabelFor
|
|
16
|
+
onJump: (comment: DocumentComment) => void
|
|
17
|
+
onReply: (comment: DocumentComment) => void
|
|
18
|
+
onResolve: (comment: DocumentComment) => void
|
|
19
|
+
t: TranslateFn
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const MENTION_TOKEN_PATTERN = /@\[([0-9a-f-]{36})\]/gi
|
|
23
|
+
|
|
24
|
+
function formatDateTime(value: string): string {
|
|
25
|
+
const timestamp = Date.parse(value)
|
|
26
|
+
return Number.isFinite(timestamp)
|
|
27
|
+
? new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(new Date(timestamp))
|
|
28
|
+
: ''
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Chips are built from the mention tokens themselves. Rendering display
|
|
33
|
+
* labels back into the text and re-matching them corrupted every label that
|
|
34
|
+
* shares a prefix with another mention, and expanded the `$&`/`$1` sequences
|
|
35
|
+
* a user-controlled label may carry into the replacement string.
|
|
36
|
+
*/
|
|
37
|
+
function formatBody(body: string, labelFor: LabelFor): React.ReactNode[] {
|
|
38
|
+
const parts: React.ReactNode[] = []
|
|
39
|
+
let cursor = 0
|
|
40
|
+
for (const match of body.matchAll(MENTION_TOKEN_PATTERN)) {
|
|
41
|
+
const userId = match[1]
|
|
42
|
+
const start = match.index ?? 0
|
|
43
|
+
if (userId === undefined) continue
|
|
44
|
+
if (start > cursor) parts.push(body.slice(cursor, start))
|
|
45
|
+
parts.push(
|
|
46
|
+
<span key={`mention:${start}`} className="inline-flex rounded-full bg-muted px-2 py-1 text-xs font-medium text-primary">
|
|
47
|
+
@{labelFor(userId)}
|
|
48
|
+
</span>,
|
|
49
|
+
)
|
|
50
|
+
cursor = start + match[0].length
|
|
51
|
+
}
|
|
52
|
+
if (cursor < body.length) parts.push(body.slice(cursor))
|
|
53
|
+
return parts
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function CommentItem({
|
|
57
|
+
comment,
|
|
58
|
+
canComment,
|
|
59
|
+
resolvingCommentId,
|
|
60
|
+
labelFor,
|
|
61
|
+
onJump,
|
|
62
|
+
onReply,
|
|
63
|
+
onResolve,
|
|
64
|
+
t,
|
|
65
|
+
}: CommentThreadListProps & { comment: DocumentComment }) {
|
|
66
|
+
const resolved = comment.resolvedAt !== null
|
|
67
|
+
const canJump = comment.anchor !== null && comment.anchor !== 'changed'
|
|
68
|
+
const content = (
|
|
69
|
+
<>
|
|
70
|
+
<div className="flex items-start justify-between gap-3">
|
|
71
|
+
<div className="min-w-0">
|
|
72
|
+
<p className="truncate text-sm font-medium">{labelFor(comment.authorUserId)}</p>
|
|
73
|
+
<p className="text-xs text-muted-foreground">{formatDateTime(comment.createdAt)}</p>
|
|
74
|
+
</div>
|
|
75
|
+
{resolved ? <StatusBadge variant="success" dot>{t('documents.comments.resolved')}</StatusBadge> : null}
|
|
76
|
+
</div>
|
|
77
|
+
<p className="whitespace-pre-wrap text-sm text-foreground">{formatBody(comment.body, labelFor)}</p>
|
|
78
|
+
{comment.anchor === 'changed' ? (
|
|
79
|
+
<p className="text-xs text-muted-foreground">{t('documents.comments.anchor.changed')}</p>
|
|
80
|
+
) : null}
|
|
81
|
+
</>
|
|
82
|
+
)
|
|
83
|
+
return (
|
|
84
|
+
<article className="space-y-3 rounded-lg border border-border bg-background p-3">
|
|
85
|
+
{canJump ? (
|
|
86
|
+
<Button type="button" variant="ghost" className="h-auto w-full flex-col items-stretch gap-2 p-0 text-left hover:bg-transparent" onClick={() => onJump(comment)}>
|
|
87
|
+
{content}
|
|
88
|
+
</Button>
|
|
89
|
+
) : <div className="space-y-2">{content}</div>}
|
|
90
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
91
|
+
{canComment && comment.parentCommentId === null ? (
|
|
92
|
+
<Button type="button" size="sm" variant="ghost" onClick={() => onReply(comment)}>
|
|
93
|
+
<CornerDownRight />{t('documents.comments.actions.reply')}
|
|
94
|
+
</Button>
|
|
95
|
+
) : null}
|
|
96
|
+
{comment.canResolve ? (
|
|
97
|
+
<Button type="button" size="sm" variant="outline" onClick={() => onResolve(comment)} disabled={resolvingCommentId === comment.id}>
|
|
98
|
+
{resolved ? <RotateCcw /> : <CheckCircle2 />}
|
|
99
|
+
{resolved ? t('documents.comments.actions.reopen') : t('documents.comments.actions.resolve')}
|
|
100
|
+
</Button>
|
|
101
|
+
) : null}
|
|
102
|
+
</div>
|
|
103
|
+
{comment.replies.length > 0 ? (
|
|
104
|
+
<div className="space-y-2 border-l border-border pl-3">
|
|
105
|
+
{comment.replies.map((reply) => (
|
|
106
|
+
<CommentItem
|
|
107
|
+
key={reply.id}
|
|
108
|
+
comment={reply}
|
|
109
|
+
comments={[]}
|
|
110
|
+
canComment={false}
|
|
111
|
+
resolvingCommentId={resolvingCommentId}
|
|
112
|
+
labelFor={labelFor}
|
|
113
|
+
onJump={onJump}
|
|
114
|
+
onReply={onReply}
|
|
115
|
+
onResolve={onResolve}
|
|
116
|
+
t={t}
|
|
117
|
+
/>
|
|
118
|
+
))}
|
|
119
|
+
</div>
|
|
120
|
+
) : null}
|
|
121
|
+
</article>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function CommentThreadList(props: CommentThreadListProps) {
|
|
126
|
+
return (
|
|
127
|
+
<div className="space-y-3">
|
|
128
|
+
{props.comments.map((comment) => <CommentItem key={comment.id} {...props} comment={comment} />)}
|
|
129
|
+
</div>
|
|
130
|
+
)
|
|
131
|
+
}
|