@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,108 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import type { Editor } from '@tiptap/core'
|
|
5
|
+
import { useEditorState } from '@tiptap/react'
|
|
6
|
+
import {
|
|
7
|
+
AlignCenter, AlignJustify, AlignLeft, AlignRight, Bold, Code2, Database, Heading1, Heading2,
|
|
8
|
+
Heading3, ImagePlus, Italic, Link2, List, ListOrdered, ListTodo, Loader2, PanelLeft, Pilcrow,
|
|
9
|
+
Redo2, Strikethrough, Table2, Underline, Undo2,
|
|
10
|
+
} from 'lucide-react'
|
|
11
|
+
import { IconButton } from '@open-mercato/ui/primitives/icon-button'
|
|
12
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
13
|
+
import { EditorColorTools } from './EditorColorTools'
|
|
14
|
+
|
|
15
|
+
type ToolbarAction = { key: string; label: string; icon: React.ReactNode; active?: boolean; disabled?: boolean; run: () => void }
|
|
16
|
+
|
|
17
|
+
const EMPTY_EDITOR_STATE = {
|
|
18
|
+
canUndo: false,
|
|
19
|
+
canRedo: false,
|
|
20
|
+
paragraph: false,
|
|
21
|
+
heading1: false,
|
|
22
|
+
heading2: false,
|
|
23
|
+
heading3: false,
|
|
24
|
+
alignLeft: false,
|
|
25
|
+
alignCenter: false,
|
|
26
|
+
alignRight: false,
|
|
27
|
+
alignJustify: false,
|
|
28
|
+
bold: false,
|
|
29
|
+
italic: false,
|
|
30
|
+
underline: false,
|
|
31
|
+
strike: false,
|
|
32
|
+
bulletList: false,
|
|
33
|
+
orderedList: false,
|
|
34
|
+
taskList: false,
|
|
35
|
+
link: false,
|
|
36
|
+
codeBlock: false,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ToolbarButtons({ actions }: { actions: ToolbarAction[] }) {
|
|
40
|
+
return <>{actions.map((action) => <IconButton className="shrink-0" key={action.key} type="button" variant={action.active ? 'outline' : 'ghost'} aria-label={action.label} aria-pressed={action.active ?? false} title={action.label} disabled={action.disabled} onClick={action.run}>{action.icon}</IconButton>)}</>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function EditorToolbar({ editor, disabled, outlineOpen, uploading, onToggleOutline, onOpenEntityPicker, onOpenLink, onImage }: {
|
|
44
|
+
editor: Editor | null
|
|
45
|
+
disabled: boolean
|
|
46
|
+
outlineOpen: boolean
|
|
47
|
+
uploading: boolean
|
|
48
|
+
onToggleOutline: () => void
|
|
49
|
+
onOpenEntityPicker: () => void
|
|
50
|
+
onOpenLink: () => void
|
|
51
|
+
onImage: () => void
|
|
52
|
+
}) {
|
|
53
|
+
const t = useT()
|
|
54
|
+
const editorState = useEditorState({
|
|
55
|
+
editor,
|
|
56
|
+
selector: ({ editor: current }) => current ? {
|
|
57
|
+
canUndo: current.can().undo(),
|
|
58
|
+
canRedo: current.can().redo(),
|
|
59
|
+
paragraph: current.isActive('paragraph'),
|
|
60
|
+
heading1: current.isActive('heading', { level: 1 }),
|
|
61
|
+
heading2: current.isActive('heading', { level: 2 }),
|
|
62
|
+
heading3: current.isActive('heading', { level: 3 }),
|
|
63
|
+
alignLeft: current.isActive({ textAlign: 'left' }),
|
|
64
|
+
alignCenter: current.isActive({ textAlign: 'center' }),
|
|
65
|
+
alignRight: current.isActive({ textAlign: 'right' }),
|
|
66
|
+
alignJustify: current.isActive({ textAlign: 'justify' }),
|
|
67
|
+
bold: current.isActive('bold'),
|
|
68
|
+
italic: current.isActive('italic'),
|
|
69
|
+
underline: current.isActive('underline'),
|
|
70
|
+
strike: current.isActive('strike'),
|
|
71
|
+
bulletList: current.isActive('bulletList'),
|
|
72
|
+
orderedList: current.isActive('orderedList'),
|
|
73
|
+
taskList: current.isActive('taskList'),
|
|
74
|
+
link: current.isActive('link'),
|
|
75
|
+
codeBlock: current.isActive('codeBlock'),
|
|
76
|
+
} : EMPTY_EDITOR_STATE,
|
|
77
|
+
}) ?? EMPTY_EDITOR_STATE
|
|
78
|
+
const command = (run: (editor: Editor) => void) => () => { if (editor && !disabled) run(editor) }
|
|
79
|
+
const actions: ToolbarAction[] = [
|
|
80
|
+
{ key: 'undo', label: t('documents.editor.toolbar.undo'), icon: <Undo2 />, disabled: disabled || !editorState.canUndo, run: command((current) => { current.chain().focus().undo().run() }) },
|
|
81
|
+
{ key: 'redo', label: t('documents.editor.toolbar.redo'), icon: <Redo2 />, disabled: disabled || !editorState.canRedo, run: command((current) => { current.chain().focus().redo().run() }) },
|
|
82
|
+
{ key: 'outline', label: t('documents.editor.toolbar.outline'), icon: <PanelLeft />, active: outlineOpen, disabled: !editor, run: onToggleOutline },
|
|
83
|
+
{ key: 'paragraph', label: t('documents.editor.toolbar.paragraph'), icon: <Pilcrow />, active: editorState.paragraph, disabled, run: command((current) => { current.chain().focus().setParagraph().run() }) },
|
|
84
|
+
...([1, 2, 3] as const).map((level) => ({ key: `h${level}`, label: t(`documents.editor.toolbar.heading${level}`), icon: level === 1 ? <Heading1 /> : level === 2 ? <Heading2 /> : <Heading3 />, active: editorState[`heading${level}`], disabled, run: command((current) => { current.chain().focus().toggleHeading({ level }).run() }) })),
|
|
85
|
+
{ key: 'left', label: t('documents.editor.toolbar.alignLeft'), icon: <AlignLeft />, active: editorState.alignLeft, disabled, run: command((current) => { current.chain().focus().setTextAlign('left').run() }) },
|
|
86
|
+
{ key: 'center', label: t('documents.editor.toolbar.alignCenter'), icon: <AlignCenter />, active: editorState.alignCenter, disabled, run: command((current) => { current.chain().focus().setTextAlign('center').run() }) },
|
|
87
|
+
{ key: 'right', label: t('documents.editor.toolbar.alignRight'), icon: <AlignRight />, active: editorState.alignRight, disabled, run: command((current) => { current.chain().focus().setTextAlign('right').run() }) },
|
|
88
|
+
{ key: 'justify', label: t('documents.editor.toolbar.alignJustify'), icon: <AlignJustify />, active: editorState.alignJustify, disabled, run: command((current) => { current.chain().focus().setTextAlign('justify').run() }) },
|
|
89
|
+
{ key: 'bold', label: t('documents.editor.toolbar.bold'), icon: <Bold />, active: editorState.bold, disabled, run: command((current) => { current.chain().focus().toggleBold().run() }) },
|
|
90
|
+
{ key: 'italic', label: t('documents.editor.toolbar.italic'), icon: <Italic />, active: editorState.italic, disabled, run: command((current) => { current.chain().focus().toggleItalic().run() }) },
|
|
91
|
+
{ key: 'underline', label: t('documents.editor.toolbar.underline'), icon: <Underline />, active: editorState.underline, disabled, run: command((current) => { current.chain().focus().toggleMark('underline').run() }) },
|
|
92
|
+
{ key: 'strike', label: t('documents.editor.toolbar.strike'), icon: <Strikethrough />, active: editorState.strike, disabled, run: command((current) => { current.chain().focus().toggleStrike().run() }) },
|
|
93
|
+
{ key: 'bullet', label: t('documents.editor.toolbar.bulletList'), icon: <List />, active: editorState.bulletList, disabled, run: command((current) => { current.chain().focus().toggleBulletList().run() }) },
|
|
94
|
+
{ key: 'ordered', label: t('documents.editor.toolbar.orderedList'), icon: <ListOrdered />, active: editorState.orderedList, disabled, run: command((current) => { current.chain().focus().toggleOrderedList().run() }) },
|
|
95
|
+
{ key: 'tasks', label: t('documents.editor.toolbar.taskList'), icon: <ListTodo />, active: editorState.taskList, disabled, run: command((current) => { current.chain().focus().toggleTaskList().run() }) },
|
|
96
|
+
{ key: 'table', label: t('documents.editor.toolbar.table'), icon: <Table2 />, disabled, run: command((current) => { current.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run() }) },
|
|
97
|
+
{ key: 'record', label: t('documents.editor.toolbar.insertRecord'), icon: <Database />, disabled, run: onOpenEntityPicker },
|
|
98
|
+
{ key: 'link', label: t('documents.editor.toolbar.link'), icon: <Link2 />, active: editorState.link, disabled, run: onOpenLink },
|
|
99
|
+
{ key: 'image', label: t('documents.editor.toolbar.image'), icon: uploading ? <Loader2 className="animate-spin" /> : <ImagePlus />, disabled: disabled || uploading, run: onImage },
|
|
100
|
+
{ key: 'code', label: t('documents.editor.toolbar.codeBlock'), icon: <Code2 />, active: editorState.codeBlock, disabled, run: command((current) => { current.chain().focus().toggleCodeBlock().run() }) },
|
|
101
|
+
]
|
|
102
|
+
return (
|
|
103
|
+
<div className="flex max-w-full flex-nowrap items-center gap-1 overflow-x-auto border-b border-border px-2 py-2 overscroll-x-contain sm:px-3" role="toolbar" aria-label={t('documents.editor.toolbar.label')}>
|
|
104
|
+
<ToolbarButtons actions={actions} />
|
|
105
|
+
<EditorColorTools editor={editor} disabled={disabled} />
|
|
106
|
+
</div>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { ChevronDown, FileDown, FileText } from 'lucide-react'
|
|
5
|
+
import type { Editor } from '@tiptap/core'
|
|
6
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
7
|
+
import { apiCallOrThrow } from '@open-mercato/ui/backend/utils/apiCall'
|
|
8
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
9
|
+
import { Popover, PopoverClose, PopoverContent, PopoverTrigger } from '@open-mercato/ui/primitives/popover'
|
|
10
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
11
|
+
|
|
12
|
+
type ExportMenuProps = {
|
|
13
|
+
documentId: string
|
|
14
|
+
editor: Editor | null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ExportFormat = 'docx' | 'pdf'
|
|
18
|
+
|
|
19
|
+
function filenameFromDisposition(disposition: string | null, format: ExportFormat): string {
|
|
20
|
+
const encoded = disposition?.match(/filename\*=UTF-8''([^;]+)/i)?.[1]
|
|
21
|
+
if (encoded) {
|
|
22
|
+
try { return decodeURIComponent(encoded) } catch { /* use the safe fallback */ }
|
|
23
|
+
}
|
|
24
|
+
const quoted = disposition?.match(/filename="([^"]+)"/i)?.[1]
|
|
25
|
+
return quoted || `document.${format}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type DocxPaginationSnapshot = { contentHtml: string; pageBreakMarker: string }
|
|
29
|
+
|
|
30
|
+
export function buildDocxPaginationSnapshot(editor: Editor | null): DocxPaginationSnapshot | null {
|
|
31
|
+
if (!editor || editor.isDestroyed) return null
|
|
32
|
+
const root = editor.view.dom.cloneNode(true) as HTMLElement
|
|
33
|
+
const pageBreaks = root.querySelectorAll<HTMLElement>('[data-document-page-break]')
|
|
34
|
+
if (pageBreaks.length === 0) return null
|
|
35
|
+
const pageBreakMarker = `OM_DOCX_PAGE_BREAK_${crypto.randomUUID()}`
|
|
36
|
+
pageBreaks.forEach((pageBreak) => {
|
|
37
|
+
const marker = document.createElement('p')
|
|
38
|
+
marker.textContent = pageBreakMarker
|
|
39
|
+
pageBreak.replaceWith(marker)
|
|
40
|
+
})
|
|
41
|
+
root.querySelectorAll('.collaboration-carets__caret, .ProseMirror-yjs-selection')
|
|
42
|
+
.forEach((node) => node.remove())
|
|
43
|
+
return { contentHtml: root.innerHTML, pageBreakMarker }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function downloadDocumentExport(
|
|
47
|
+
documentId: string,
|
|
48
|
+
format: ExportFormat,
|
|
49
|
+
snapshot: DocxPaginationSnapshot | null,
|
|
50
|
+
errorMessage: string,
|
|
51
|
+
): Promise<void> {
|
|
52
|
+
const hasSnapshot = format === 'docx' && snapshot !== null
|
|
53
|
+
// Intentionally outside useGuardedMutation: export is read-shaped (no record is
|
|
54
|
+
// mutated); the POST variant only carries the client pagination snapshot payload.
|
|
55
|
+
const call = await apiCallOrThrow<Blob>(
|
|
56
|
+
`/api/documents/${encodeURIComponent(documentId)}/export?format=${format}`,
|
|
57
|
+
{
|
|
58
|
+
method: hasSnapshot ? 'POST' : 'GET',
|
|
59
|
+
credentials: 'same-origin',
|
|
60
|
+
headers: {
|
|
61
|
+
'x-om-forbidden-redirect': '0',
|
|
62
|
+
'x-om-unauthorized-redirect': '0',
|
|
63
|
+
...(hasSnapshot ? { 'content-type': 'application/json' } : {}),
|
|
64
|
+
},
|
|
65
|
+
...(hasSnapshot ? { body: JSON.stringify(snapshot) } : {}),
|
|
66
|
+
},
|
|
67
|
+
{ parse: (response) => response.blob(), errorMessage },
|
|
68
|
+
)
|
|
69
|
+
const response = call.response
|
|
70
|
+
const expectedContentType = format === 'docx'
|
|
71
|
+
? 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
72
|
+
: 'application/pdf'
|
|
73
|
+
const contentType = response.headers.get('content-type')?.split(';', 1)[0]?.trim().toLowerCase()
|
|
74
|
+
if (contentType !== expectedContentType || !call.result) throw new Error(errorMessage)
|
|
75
|
+
|
|
76
|
+
const blob = call.result
|
|
77
|
+
const objectUrl = URL.createObjectURL(blob)
|
|
78
|
+
try {
|
|
79
|
+
const link = document.createElement('a')
|
|
80
|
+
link.href = objectUrl
|
|
81
|
+
link.download = filenameFromDisposition(response.headers.get('content-disposition'), format)
|
|
82
|
+
document.body.append(link)
|
|
83
|
+
link.click()
|
|
84
|
+
link.remove()
|
|
85
|
+
} finally {
|
|
86
|
+
URL.revokeObjectURL(objectUrl)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function ExportMenu({ documentId, editor }: ExportMenuProps) {
|
|
91
|
+
const t = useT()
|
|
92
|
+
const label = t('documents.actions.export')
|
|
93
|
+
const download = React.useCallback((format: ExportFormat) => {
|
|
94
|
+
const snapshot = format === 'docx' ? buildDocxPaginationSnapshot(editor) : null
|
|
95
|
+
void downloadDocumentExport(documentId, format, snapshot, t('documents.export.error')).catch((error) => {
|
|
96
|
+
flash(error instanceof Error ? error.message : t('documents.export.runtimeUnavailable'), 'error')
|
|
97
|
+
})
|
|
98
|
+
}, [documentId, editor, t])
|
|
99
|
+
const items = React.useMemo(() => [
|
|
100
|
+
{
|
|
101
|
+
id: 'docx',
|
|
102
|
+
label: t('documents.export.docx'),
|
|
103
|
+
icon: FileText,
|
|
104
|
+
onSelect: () => download('docx'),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'pdf',
|
|
108
|
+
label: t('documents.export.pdf'),
|
|
109
|
+
icon: FileDown,
|
|
110
|
+
onSelect: () => download('pdf'),
|
|
111
|
+
},
|
|
112
|
+
], [download, t])
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Popover>
|
|
116
|
+
<PopoverTrigger asChild>
|
|
117
|
+
<Button type="button" variant="outline" size="sm" aria-label={label} aria-haspopup="menu">
|
|
118
|
+
{label}
|
|
119
|
+
<ChevronDown className="size-3.5" aria-hidden="true" />
|
|
120
|
+
</Button>
|
|
121
|
+
</PopoverTrigger>
|
|
122
|
+
<PopoverContent role="menu" align="end" className="w-52 min-w-52 p-1">
|
|
123
|
+
{items.map((item) => {
|
|
124
|
+
const Icon = item.icon
|
|
125
|
+
return (
|
|
126
|
+
<PopoverClose key={item.id} asChild>
|
|
127
|
+
<Button
|
|
128
|
+
type="button"
|
|
129
|
+
variant="ghost"
|
|
130
|
+
size="sm"
|
|
131
|
+
role="menuitem"
|
|
132
|
+
className="h-auto min-h-8 w-full justify-start py-1.5 text-left leading-snug whitespace-normal"
|
|
133
|
+
onClick={item.onSelect}
|
|
134
|
+
>
|
|
135
|
+
<Icon className="size-4" aria-hidden="true" />
|
|
136
|
+
{item.label}
|
|
137
|
+
</Button>
|
|
138
|
+
</PopoverClose>
|
|
139
|
+
)
|
|
140
|
+
})}
|
|
141
|
+
</PopoverContent>
|
|
142
|
+
</Popover>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { ErrorMessage } from '@open-mercato/ui/backend/detail'
|
|
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 { useMentionPicker } from './useMentionPicker'
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
buildMentionPrincipalUrl,
|
|
13
|
+
nextMentionIndex,
|
|
14
|
+
readMentionUserItems,
|
|
15
|
+
} from './useMentionPicker'
|
|
16
|
+
|
|
17
|
+
type MentionPickerProps = {
|
|
18
|
+
documentId: string
|
|
19
|
+
onPick: (user: { id: string; name: string }) => void
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function MentionPicker({ documentId, onPick, disabled = false }: MentionPickerProps) {
|
|
24
|
+
const t = useT()
|
|
25
|
+
const reactId = React.useId()
|
|
26
|
+
const inputId = `documents-mention-input-${documentId}-${reactId}`
|
|
27
|
+
const listId = `documents-mention-list-${documentId}-${reactId}`
|
|
28
|
+
const model = useMentionPicker({
|
|
29
|
+
documentId,
|
|
30
|
+
onPick,
|
|
31
|
+
disabled,
|
|
32
|
+
fallbackLabel: t('documents.users.unknown'),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="relative space-y-2">
|
|
37
|
+
<Label htmlFor={inputId}>{t('documents.mentions.placeholder')}</Label>
|
|
38
|
+
<Input
|
|
39
|
+
id={inputId}
|
|
40
|
+
value={model.query}
|
|
41
|
+
onChange={(event) => model.onQueryChange(event.target.value)}
|
|
42
|
+
onKeyDown={(event) => {
|
|
43
|
+
if (model.isDisabled) return
|
|
44
|
+
if (event.key === 'Escape') {
|
|
45
|
+
event.preventDefault()
|
|
46
|
+
event.stopPropagation()
|
|
47
|
+
model.dismiss()
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
51
|
+
event.preventDefault()
|
|
52
|
+
event.stopPropagation()
|
|
53
|
+
model.moveActive(event.key === 'ArrowDown' ? 1 : -1)
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
if (event.key === 'Enter' && model.open && model.resultsAreCurrent && model.activeIndex >= 0) {
|
|
57
|
+
const user = model.users[model.activeIndex]
|
|
58
|
+
if (!user) return
|
|
59
|
+
event.preventDefault()
|
|
60
|
+
event.stopPropagation()
|
|
61
|
+
model.pick(user, model.resultQuery)
|
|
62
|
+
}
|
|
63
|
+
}}
|
|
64
|
+
placeholder={t('documents.mentions.placeholder')}
|
|
65
|
+
disabled={model.isDisabled}
|
|
66
|
+
role="combobox"
|
|
67
|
+
aria-expanded={model.open && !model.isDisabled}
|
|
68
|
+
aria-controls={listId}
|
|
69
|
+
aria-autocomplete="list"
|
|
70
|
+
aria-activedescendant={
|
|
71
|
+
model.resultsAreCurrent && model.activeIndex >= 0
|
|
72
|
+
? `${listId}-option-${model.activeIndex}`
|
|
73
|
+
: undefined
|
|
74
|
+
}
|
|
75
|
+
/>
|
|
76
|
+
{model.unavailable ? (
|
|
77
|
+
<p role="alert" className="text-sm text-muted-foreground">
|
|
78
|
+
{t('documents.mentions.unavailable')}
|
|
79
|
+
</p>
|
|
80
|
+
) : null}
|
|
81
|
+
{model.open && !model.isDisabled ? (
|
|
82
|
+
<div
|
|
83
|
+
id={listId}
|
|
84
|
+
role={
|
|
85
|
+
!model.isLoading
|
|
86
|
+
&& !model.hasError
|
|
87
|
+
&& model.resultsAreCurrent
|
|
88
|
+
&& model.users.length > 0
|
|
89
|
+
? 'listbox'
|
|
90
|
+
: undefined
|
|
91
|
+
}
|
|
92
|
+
className="absolute z-popover max-h-64 w-full overflow-y-auto rounded-md border border-border bg-popover p-1 shadow-lg"
|
|
93
|
+
>
|
|
94
|
+
{model.isLoading ? (
|
|
95
|
+
<p role="status" className="px-3 py-2 text-sm text-muted-foreground">
|
|
96
|
+
{t('documents.mentions.loading')}
|
|
97
|
+
</p>
|
|
98
|
+
) : null}
|
|
99
|
+
{!model.isLoading && model.hasError ? (
|
|
100
|
+
<ErrorMessage
|
|
101
|
+
label={t('documents.mentions.error.search')}
|
|
102
|
+
action={<Button type="button" size="sm" variant="outline" onClick={model.retry}>{t('documents.actions.retry')}</Button>}
|
|
103
|
+
/>
|
|
104
|
+
) : null}
|
|
105
|
+
{!model.isLoading && !model.hasError && model.hasSearched && model.resultsAreCurrent && model.users.length === 0 ? (
|
|
106
|
+
<p role="status" className="px-3 py-2 text-sm text-muted-foreground">
|
|
107
|
+
{t('documents.mentions.noMatches')}
|
|
108
|
+
</p>
|
|
109
|
+
) : null}
|
|
110
|
+
{!model.isLoading && !model.hasError && model.resultsAreCurrent ? model.users.map((user, index) => (
|
|
111
|
+
<Button
|
|
112
|
+
key={user.id}
|
|
113
|
+
id={`${listId}-option-${index}`}
|
|
114
|
+
role="option"
|
|
115
|
+
aria-selected={index === model.activeIndex}
|
|
116
|
+
type="button"
|
|
117
|
+
disabled={model.isDisabled}
|
|
118
|
+
variant={index === model.activeIndex ? 'secondary' : 'ghost'}
|
|
119
|
+
className="h-auto w-full justify-start px-3 py-2 text-left"
|
|
120
|
+
onMouseEnter={() => model.activate(index, model.resultQuery)}
|
|
121
|
+
onClick={() => model.pick(user, model.resultQuery)}
|
|
122
|
+
>
|
|
123
|
+
<span className="min-w-0">
|
|
124
|
+
<span className="block truncate text-sm font-medium">{user.label}</span>
|
|
125
|
+
{user.secondary ? (
|
|
126
|
+
<span className="block truncate text-xs text-muted-foreground">{user.secondary}</span>
|
|
127
|
+
) : null}
|
|
128
|
+
</span>
|
|
129
|
+
</Button>
|
|
130
|
+
)) : null}
|
|
131
|
+
</div>
|
|
132
|
+
) : null}
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export default MentionPicker
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
7
|
+
import { cn } from '@open-mercato/shared/lib/utils'
|
|
8
|
+
|
|
9
|
+
type OutlineHeading = {
|
|
10
|
+
level: number
|
|
11
|
+
text: string
|
|
12
|
+
pos: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type OutlinePaneProps = {
|
|
16
|
+
editor: Editor | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const OUTLINE_REFRESH_DELAY_MS = 300
|
|
20
|
+
|
|
21
|
+
function collectHeadings(editor: Editor): OutlineHeading[] {
|
|
22
|
+
const headings: OutlineHeading[] = []
|
|
23
|
+
editor.state.doc.descendants((node, pos) => {
|
|
24
|
+
if (node.type.name !== 'heading') return
|
|
25
|
+
const text = node.textContent.trim()
|
|
26
|
+
if (!text) return
|
|
27
|
+
const rawLevel = node.attrs.level
|
|
28
|
+
const level = typeof rawLevel === 'number' && Number.isFinite(rawLevel)
|
|
29
|
+
? Math.min(Math.max(rawLevel, 1), 6)
|
|
30
|
+
: 1
|
|
31
|
+
headings.push({ level, text, pos })
|
|
32
|
+
})
|
|
33
|
+
return headings
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getIndentClass(level: number): string {
|
|
37
|
+
if (level <= 1) return 'pl-2'
|
|
38
|
+
if (level === 2) return 'pl-5'
|
|
39
|
+
return 'pl-8'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function OutlinePane({ editor }: OutlinePaneProps) {
|
|
43
|
+
const t = useT()
|
|
44
|
+
const [headings, setHeadings] = React.useState<OutlineHeading[]>([])
|
|
45
|
+
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (!editor) {
|
|
48
|
+
setHeadings([])
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let timer: number | null = null
|
|
53
|
+
const refresh = () => {
|
|
54
|
+
if (timer !== null) window.clearTimeout(timer)
|
|
55
|
+
timer = window.setTimeout(() => {
|
|
56
|
+
timer = null
|
|
57
|
+
setHeadings(collectHeadings(editor))
|
|
58
|
+
}, OUTLINE_REFRESH_DELAY_MS)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setHeadings(collectHeadings(editor))
|
|
62
|
+
editor.on('update', refresh)
|
|
63
|
+
return () => {
|
|
64
|
+
if (timer !== null) window.clearTimeout(timer)
|
|
65
|
+
editor.off('update', refresh)
|
|
66
|
+
}
|
|
67
|
+
}, [editor])
|
|
68
|
+
|
|
69
|
+
const jumpToHeading = React.useCallback((heading: OutlineHeading) => {
|
|
70
|
+
editor?.chain().focus().setTextSelection(heading.pos + 1).scrollIntoView().run()
|
|
71
|
+
}, [editor])
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<aside className="rounded-lg border border-border bg-card p-3 shadow-sm lg:sticky lg:top-20 lg:w-64 lg:shrink-0">
|
|
75
|
+
<h2 className="mb-3 text-sm font-semibold text-foreground">{t('documents.editor.outline.title')}</h2>
|
|
76
|
+
{headings.length === 0 ? (
|
|
77
|
+
<p className="text-sm text-muted-foreground">{t('documents.editor.outline.empty')}</p>
|
|
78
|
+
) : (
|
|
79
|
+
<nav aria-label={t('documents.editor.outline.title')}>
|
|
80
|
+
<div className="space-y-1">
|
|
81
|
+
{headings.map((heading) => (
|
|
82
|
+
<Button
|
|
83
|
+
key={`${heading.pos}:${heading.text}`}
|
|
84
|
+
type="button"
|
|
85
|
+
size="sm"
|
|
86
|
+
variant="ghost"
|
|
87
|
+
className={cn('h-auto w-full justify-start py-1 pr-2 text-left text-sm', getIndentClass(heading.level))}
|
|
88
|
+
onClick={() => jumpToHeading(heading)}
|
|
89
|
+
>
|
|
90
|
+
<span className="truncate">{heading.text}</span>
|
|
91
|
+
</Button>
|
|
92
|
+
))}
|
|
93
|
+
</div>
|
|
94
|
+
</nav>
|
|
95
|
+
)}
|
|
96
|
+
</aside>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Link2 } from 'lucide-react'
|
|
5
|
+
import type { Editor } from '@tiptap/core'
|
|
6
|
+
import { ErrorMessage, LoadingMessage } from '@open-mercato/ui/backend/detail'
|
|
7
|
+
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
8
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
9
|
+
import { CheckboxField } from '@open-mercato/ui/primitives/checkbox-field'
|
|
10
|
+
import {
|
|
11
|
+
Dialog,
|
|
12
|
+
DialogContent,
|
|
13
|
+
DialogDescription,
|
|
14
|
+
DialogFooter,
|
|
15
|
+
DialogHeader,
|
|
16
|
+
DialogTitle,
|
|
17
|
+
} from '@open-mercato/ui/primitives/dialog'
|
|
18
|
+
import { EmptyState } from '@open-mercato/ui/primitives/empty-state'
|
|
19
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
20
|
+
import { getEntityRegistryEntry } from '../../../lib/entityRegistry'
|
|
21
|
+
import {
|
|
22
|
+
insertRecordFieldSnapshot,
|
|
23
|
+
type RecordFieldSnapshot,
|
|
24
|
+
} from '../../../lib/recordFieldInsertion'
|
|
25
|
+
import { readArrayPayload } from '../documentUi'
|
|
26
|
+
import { normalizeRelatedRecord, type RelatedRecord } from './relatedRecordModel'
|
|
27
|
+
|
|
28
|
+
type LoadState =
|
|
29
|
+
| { status: 'idle' }
|
|
30
|
+
| { status: 'loading' }
|
|
31
|
+
| { status: 'error' }
|
|
32
|
+
| { status: 'ready'; record: RelatedRecord | null }
|
|
33
|
+
|
|
34
|
+
type RecordFieldsDialogProps = {
|
|
35
|
+
documentId: string
|
|
36
|
+
linkId: string | null
|
|
37
|
+
editor: Editor | null
|
|
38
|
+
canInsert: boolean
|
|
39
|
+
onOpenChange: (open: boolean) => void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function RecordFieldsDialog({
|
|
43
|
+
documentId,
|
|
44
|
+
linkId,
|
|
45
|
+
editor,
|
|
46
|
+
canInsert,
|
|
47
|
+
onOpenChange,
|
|
48
|
+
}: RecordFieldsDialogProps) {
|
|
49
|
+
const t = useT()
|
|
50
|
+
const open = linkId !== null && canInsert
|
|
51
|
+
const [state, setState] = React.useState<LoadState>({ status: 'idle' })
|
|
52
|
+
const [selectedFields, setSelectedFields] = React.useState<Set<string>>(() => new Set())
|
|
53
|
+
const [loadAttempt, setLoadAttempt] = React.useState(0)
|
|
54
|
+
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (linkId !== null && !canInsert) onOpenChange(false)
|
|
57
|
+
}, [canInsert, linkId, onOpenChange])
|
|
58
|
+
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
if (!open || !linkId) {
|
|
61
|
+
setState({ status: 'idle' })
|
|
62
|
+
setSelectedFields(new Set())
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
const controller = new AbortController()
|
|
66
|
+
setState({ status: 'loading' })
|
|
67
|
+
setSelectedFields(new Set())
|
|
68
|
+
void apiCall<unknown>(
|
|
69
|
+
`/api/documents/${encodeURIComponent(documentId)}/links`,
|
|
70
|
+
{ cache: 'no-store', signal: controller.signal },
|
|
71
|
+
).then((call) => {
|
|
72
|
+
if (controller.signal.aborted) return
|
|
73
|
+
if (!call.ok) {
|
|
74
|
+
setState({ status: 'error' })
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
const record = readArrayPayload(call.result, 'items', 'data')
|
|
78
|
+
.map((value) => normalizeRelatedRecord(value, t('documents.relatedRecords.restricted')))
|
|
79
|
+
.find((item): item is RelatedRecord => item?.id === linkId) ?? null
|
|
80
|
+
setState({ status: 'ready', record })
|
|
81
|
+
}).catch(() => {
|
|
82
|
+
if (!controller.signal.aborted) setState({ status: 'error' })
|
|
83
|
+
})
|
|
84
|
+
return () => controller.abort()
|
|
85
|
+
}, [documentId, linkId, loadAttempt, open, t])
|
|
86
|
+
|
|
87
|
+
const retry = React.useCallback(() => {
|
|
88
|
+
setState({ status: 'loading' })
|
|
89
|
+
setLoadAttempt((current) => current + 1)
|
|
90
|
+
}, [])
|
|
91
|
+
|
|
92
|
+
const fields = React.useMemo<RecordFieldSnapshot[]>(() => {
|
|
93
|
+
if (state.status !== 'ready' || !state.record?.canOpen) return []
|
|
94
|
+
const entry = getEntityRegistryEntry(state.record.entityType)
|
|
95
|
+
if (!entry) return []
|
|
96
|
+
return entry.tokenFields.flatMap((tokenField) => {
|
|
97
|
+
const value = state.record?.values[tokenField.field]
|
|
98
|
+
return value ? [{
|
|
99
|
+
field: tokenField.field,
|
|
100
|
+
label: t(tokenField.labelKey),
|
|
101
|
+
value,
|
|
102
|
+
}] : []
|
|
103
|
+
})
|
|
104
|
+
}, [state, t])
|
|
105
|
+
|
|
106
|
+
const selected = React.useMemo(
|
|
107
|
+
() => fields.filter((field) => selectedFields.has(field.field)),
|
|
108
|
+
[fields, selectedFields],
|
|
109
|
+
)
|
|
110
|
+
const insert = React.useCallback(() => {
|
|
111
|
+
if (!canInsert || !editor?.isEditable || selected.length === 0) return
|
|
112
|
+
if (insertRecordFieldSnapshot(editor, selected)) onOpenChange(false)
|
|
113
|
+
}, [canInsert, editor, onOpenChange, selected])
|
|
114
|
+
const setOpen = React.useCallback((nextOpen: boolean) => {
|
|
115
|
+
if (!nextOpen) onOpenChange(false)
|
|
116
|
+
}, [onOpenChange])
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
120
|
+
<DialogContent size="lg" onKeyDown={(event) => {
|
|
121
|
+
if (event.key === 'Escape') {
|
|
122
|
+
event.preventDefault()
|
|
123
|
+
onOpenChange(false)
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
127
|
+
event.preventDefault()
|
|
128
|
+
insert()
|
|
129
|
+
}
|
|
130
|
+
}}>
|
|
131
|
+
<DialogHeader>
|
|
132
|
+
<DialogTitle>{t('documents.relatedRecords.actions.insertData')}</DialogTitle>
|
|
133
|
+
<DialogDescription>{t('documents.relatedRecords.fields.snapshotDisclosure')}</DialogDescription>
|
|
134
|
+
</DialogHeader>
|
|
135
|
+
|
|
136
|
+
{state.status === 'loading' ? <LoadingMessage label={t('documents.relatedRecords.loading')} /> : null}
|
|
137
|
+
{state.status === 'error' ? (
|
|
138
|
+
<ErrorMessage
|
|
139
|
+
label={t('documents.relatedRecords.error.load')}
|
|
140
|
+
action={<Button type="button" size="sm" variant="outline" onClick={retry}>{t('documents.actions.retry')}</Button>}
|
|
141
|
+
/>
|
|
142
|
+
) : null}
|
|
143
|
+
{state.status === 'ready' && fields.length === 0 ? (
|
|
144
|
+
<EmptyState
|
|
145
|
+
size="sm"
|
|
146
|
+
variant="subtle"
|
|
147
|
+
title={t('documents.relatedRecords.fields.empty')}
|
|
148
|
+
icon={<Link2 className="size-5" />}
|
|
149
|
+
/>
|
|
150
|
+
) : null}
|
|
151
|
+
{state.status === 'ready' && fields.length > 0 ? (
|
|
152
|
+
<div className="space-y-3">
|
|
153
|
+
{fields.map((field) => (
|
|
154
|
+
<CheckboxField
|
|
155
|
+
key={field.field}
|
|
156
|
+
label={field.label}
|
|
157
|
+
description={field.value}
|
|
158
|
+
checked={selectedFields.has(field.field)}
|
|
159
|
+
onCheckedChange={(checked) => setSelectedFields((current) => {
|
|
160
|
+
const next = new Set(current)
|
|
161
|
+
if (checked === true) next.add(field.field)
|
|
162
|
+
else next.delete(field.field)
|
|
163
|
+
return next
|
|
164
|
+
})}
|
|
165
|
+
/>
|
|
166
|
+
))}
|
|
167
|
+
</div>
|
|
168
|
+
) : null}
|
|
169
|
+
|
|
170
|
+
<DialogFooter>
|
|
171
|
+
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
|
|
172
|
+
{t('documents.actions.cancel')}
|
|
173
|
+
</Button>
|
|
174
|
+
<Button
|
|
175
|
+
type="button"
|
|
176
|
+
onClick={insert}
|
|
177
|
+
disabled={!canInsert || !editor?.isEditable || selected.length === 0}
|
|
178
|
+
>
|
|
179
|
+
{t('documents.relatedRecords.fields.insertSelected')}
|
|
180
|
+
</Button>
|
|
181
|
+
</DialogFooter>
|
|
182
|
+
</DialogContent>
|
|
183
|
+
</Dialog>
|
|
184
|
+
)
|
|
185
|
+
}
|