@xynolog/react-ui 0.0.0-stage → 0.8.0
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/LICENSE +201 -0
- package/README.md +379 -2
- package/dist/PdfAnnotationCanvas.client-S64VRLUN.css +193 -0
- package/dist/PdfAnnotationCanvas.client-V7R4NXFO.js +799 -0
- package/dist/ar-AIV7P4FL.js +594 -0
- package/dist/bn-J2OR57PB.js +594 -0
- package/dist/chunk-4L3TYOIV.js +172 -0
- package/dist/chunk-BM76QBIO.js +594 -0
- package/dist/chunk-D2O46PZQ.js +240 -0
- package/dist/chunk-O23TLLXW.js +42 -0
- package/dist/chunk-WGTUIB6C.js +304 -0
- package/dist/cs-JNEAMHFB.js +594 -0
- package/dist/da-UY5ZRVTZ.js +594 -0
- package/dist/de-EETVXC42.js +594 -0
- package/dist/el-S5YKDMTL.js +594 -0
- package/dist/en-3YQWF45H.js +61 -0
- package/dist/es-GHA7S27R.js +594 -0
- package/dist/fa-JTR3GF6I.js +594 -0
- package/dist/fi-CQZ7BW57.js +594 -0
- package/dist/fr-OJH2WIY7.js +594 -0
- package/dist/he-2DBXWA2V.js +594 -0
- package/dist/hi-NZP7B55I.js +594 -0
- package/dist/id-4KXFKWOI.js +594 -0
- package/dist/index.css +4134 -0
- package/dist/index.d.ts +4040 -0
- package/dist/index.js +29638 -0
- package/dist/it-XBMYGKKY.js +594 -0
- package/dist/ja-OVHZS3EH.js +594 -0
- package/dist/ko-NW2MVM5L.js +594 -0
- package/dist/ms-RXLPBZLK.js +594 -0
- package/dist/nl-77CTBEDA.js +594 -0
- package/dist/no-RAPO56SE.js +594 -0
- package/dist/pl-XCFXZCTT.js +594 -0
- package/dist/pt-EMBE27IS.js +594 -0
- package/dist/ro-M7QLJBYN.js +594 -0
- package/dist/sv-ST6CITQY.js +594 -0
- package/dist/test-utils.css +112 -0
- package/dist/test-utils.d.ts +126 -0
- package/dist/test-utils.js +13119 -0
- package/dist/th-EEQGL3G7.js +594 -0
- package/dist/tr-5FYHZQKD.js +594 -0
- package/dist/uk-VTWDC467.js +594 -0
- package/dist/vi-ISBKJ66X.js +594 -0
- package/dist/zh-2AW2N66Z.js +594 -0
- package/package.json +129 -4
- package/src/components/Button/Button.tsx +188 -0
- package/src/components/Button/__tests__/Button.test.tsx +449 -0
- package/src/components/CodeMirrorRenderer.tsx +536 -0
- package/src/components/DelegateProgress.tsx +308 -0
- package/src/components/ErrorBoundary.tsx +174 -0
- package/src/components/ItemFoundLog.tsx +42 -0
- package/src/components/LiveRegion.tsx +261 -0
- package/src/components/ProtectedErrorBoundary.css +121 -0
- package/src/components/ProtectedErrorBoundary.tsx +114 -0
- package/src/components/ResizeHandle.tsx +167 -0
- package/src/components/ResourceTagsInline.tsx +120 -0
- package/src/components/SessionExpiryBanner.css +67 -0
- package/src/components/SessionExpiryBanner.tsx +74 -0
- package/src/components/SessionTimer.tsx +17 -0
- package/src/components/StatusDisplay.css +439 -0
- package/src/components/StatusDisplay.tsx +131 -0
- package/src/components/Toast.css +136 -0
- package/src/components/Toast.tsx +217 -0
- package/src/components/Toolbar.tsx +194 -0
- package/src/components/UserMenuSkeleton.tsx +13 -0
- package/src/components/__tests__/DelegateProgress.denominator.test.tsx +102 -0
- package/src/components/__tests__/DelegateProgress.test.tsx +649 -0
- package/src/components/__tests__/ErrorBoundary.test.tsx +565 -0
- package/src/components/__tests__/LiveRegion.a11y.test.tsx +258 -0
- package/src/components/__tests__/LiveRegion.hooks.test.tsx +140 -0
- package/src/components/__tests__/ProtectedErrorBoundary.test.tsx +225 -0
- package/src/components/__tests__/ResizeHandle.test.tsx +159 -0
- package/src/components/__tests__/ResourceTagsInline.test.tsx +325 -0
- package/src/components/__tests__/SessionExpiryBanner.test.tsx +124 -0
- package/src/components/__tests__/SessionTimer.test.tsx +199 -0
- package/src/components/__tests__/StatusDisplay.test.tsx +179 -0
- package/src/components/__tests__/Toast.test.tsx +96 -0
- package/src/components/__tests__/Toolbar.test.tsx +111 -0
- package/src/components/__tests__/UserMenuSkeleton.test.tsx +182 -0
- package/src/components/annotation/AnchoredTextNotice.tsx +36 -0
- package/src/components/annotation/AnnotateToolbar.tsx +531 -0
- package/src/components/annotation/__tests__/AnnotateToolbar.display.test.tsx +127 -0
- package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +304 -0
- package/src/components/annotation/annotation-entries.css +138 -0
- package/src/components/annotation/annotations.css +93 -0
- package/src/components/annotation/references.css +300 -0
- package/src/components/annotation-popups/JsonLdView.tsx +127 -0
- package/src/components/annotation-popups/SharedPopupElements.tsx +131 -0
- package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +432 -0
- package/src/components/annotation-popups/__tests__/SharedPopupElements.test.tsx +297 -0
- package/src/components/branding/Branding.css +129 -0
- package/src/components/branding/XynologBranding.tsx +41 -0
- package/src/components/branding/__tests__/XynologBranding.test.tsx +383 -0
- package/src/components/error-states/ResourceErrorState.tsx +30 -0
- package/src/components/error-states/__tests__/ResourceErrorState.test.tsx +102 -0
- package/src/components/error-states/errors.css +34 -0
- package/src/components/image-annotation/AnnotationOverlay.tsx +307 -0
- package/src/components/image-annotation/SvgDrawingCanvas.tsx +514 -0
- package/src/components/image-annotation/__tests__/AnnotationOverlay.click.test.tsx +169 -0
- package/src/components/image-annotation/__tests__/AnnotationOverlay.hover.test.tsx +83 -0
- package/src/components/image-annotation/__tests__/SvgDrawingCanvas.annotate-gate.test.tsx +228 -0
- package/src/components/image-annotation/__tests__/SvgDrawingCanvas.click.test.tsx +204 -0
- package/src/components/layout/Header.css +99 -0
- package/src/components/layout/LeftSidebar.css +115 -0
- package/src/components/layout/LeftSidebar.tsx +150 -0
- package/src/components/layout/PageLayout.tsx +49 -0
- package/src/components/layout/ResizeHandle.css +110 -0
- package/src/components/layout/SkipLinks.css +84 -0
- package/src/components/layout/SkipLinks.tsx +36 -0
- package/src/components/layout/UnifiedHeader.tsx +151 -0
- package/src/components/layout/__tests__/LeftSidebar.test.tsx +426 -0
- package/src/components/layout/__tests__/PageLayout.test.tsx +311 -0
- package/src/components/layout/__tests__/SkipLinks.a11y.test.tsx +218 -0
- package/src/components/layout/__tests__/UnifiedHeader.test.tsx +555 -0
- package/src/components/loading-states/ComposeLoadingState.tsx +19 -0
- package/src/components/loading-states/ResourceLoadingState.tsx +13 -0
- package/src/components/loading-states/__tests__/ComposeLoadingState.test.tsx +37 -0
- package/src/components/loading-states/__tests__/ResourceLoadingState.test.tsx +31 -0
- package/src/components/loading-states/loading.css +42 -0
- package/src/components/modals/ComposeStep.tsx +245 -0
- package/src/components/modals/ConfigureGatherStep.tsx +110 -0
- package/src/components/modals/ConfigureGenerationStep.tsx +458 -0
- package/src/components/modals/ConfigureSearchStep.tsx +124 -0
- package/src/components/modals/ContextSummary.tsx +317 -0
- package/src/components/modals/CorpusPane.tsx +96 -0
- package/src/components/modals/DiscardPrompt.tsx +44 -0
- package/src/components/modals/GatherContextStep.tsx +480 -0
- package/src/components/modals/KbIdentityConflictModal.tsx +122 -0
- package/src/components/modals/KeyboardShortcutsHelpModal.tsx +238 -0
- package/src/components/modals/PermissionDeniedModal.tsx +207 -0
- package/src/components/modals/ReferenceWizardModal.tsx +656 -0
- package/src/components/modals/ResourceGenerateModal.tsx +457 -0
- package/src/components/modals/SearchModal.css +1019 -0
- package/src/components/modals/SearchModal.tsx +334 -0
- package/src/components/modals/SearchResultsStep.tsx +117 -0
- package/src/components/modals/SessionEndedModal.tsx +148 -0
- package/src/components/modals/WizardFooter.tsx +72 -0
- package/src/components/modals/__tests__/ComposeStep.test.tsx +187 -0
- package/src/components/modals/__tests__/ConfigureGatherStep.test.tsx +92 -0
- package/src/components/modals/__tests__/ConfigureGenerationStep.test.tsx +574 -0
- package/src/components/modals/__tests__/ConfigureSearchStep.test.tsx +124 -0
- package/src/components/modals/__tests__/GatherContextStep.resource.test.tsx +702 -0
- package/src/components/modals/__tests__/KbIdentityConflictModal.test.tsx +102 -0
- package/src/components/modals/__tests__/KeyboardShortcutsHelpModal.test.tsx +115 -0
- package/src/components/modals/__tests__/PermissionDeniedModal.test.tsx +218 -0
- package/src/components/modals/__tests__/ReferenceWizardModal.test.tsx +936 -0
- package/src/components/modals/__tests__/ResourceGenerateModal.test.tsx +532 -0
- package/src/components/modals/__tests__/SearchModal.accessibility.test.tsx +95 -0
- package/src/components/modals/__tests__/SearchModal.basic.test.tsx +84 -0
- package/src/components/modals/__tests__/SearchModal.keyboard.test.tsx +162 -0
- package/src/components/modals/__tests__/SearchModal.search-wiring.test.tsx +237 -0
- package/src/components/modals/__tests__/SearchModal.translations.test.tsx +91 -0
- package/src/components/modals/__tests__/SearchResultsStep.test.tsx +95 -0
- package/src/components/modals/__tests__/SessionEndedModal.test.tsx +171 -0
- package/src/components/modals/__tests__/WizardFooter.test.tsx +446 -0
- package/src/components/modals/__tests__/search-modal-harness.ts +82 -0
- package/src/components/modals/modals.css +655 -0
- package/src/components/navigation/CollapsibleResourceNavigation.css +10 -0
- package/src/components/navigation/CollapsibleResourceNavigation.tsx +364 -0
- package/src/components/navigation/NavigationMenu.css +59 -0
- package/src/components/navigation/NavigationMenu.tsx +66 -0
- package/src/components/navigation/NavigationTabs.css +466 -0
- package/src/components/navigation/ObservableLink.tsx +90 -0
- package/src/components/navigation/SimpleNavigation.css +9 -0
- package/src/components/navigation/SimpleNavigation.tsx +169 -0
- package/src/components/navigation/SortableResourceTab.tsx +122 -0
- package/src/components/navigation/__tests__/NavigationMenu.a11y.test.tsx +302 -0
- package/src/components/navigation/__tests__/NavigationMenu.test.tsx +399 -0
- package/src/components/navigation/__tests__/ObservableLink.test.tsx +85 -0
- package/src/components/navigation/__tests__/SimpleNavigation.test.tsx +193 -0
- package/src/components/navigation/__tests__/SortableResourceTab.test.tsx +421 -0
- package/src/components/pdf-annotation/PdfAnnotationCanvas.client.tsx +10 -0
- package/src/components/pdf-annotation/PdfAnnotationCanvas.css +288 -0
- package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +632 -0
- package/src/components/pdf-annotation/PdfPageView.tsx +527 -0
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.annotate-gate.test.tsx +295 -0
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.pixels-before-anchoring.test.tsx +166 -0
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.test.tsx +1719 -0
- package/src/components/pdf-annotation/__tests__/estimate-slot-height.test.ts +61 -0
- package/src/components/pdf-annotation/__tests__/rects-for-page.test.ts +110 -0
- package/src/components/pdf-annotation/estimate-slot-height.ts +31 -0
- package/src/components/pdf-annotation/rects-for-page.ts +50 -0
- package/src/components/resource/AnnotateView.tsx +373 -0
- package/src/components/resource/AnnotationHistory.tsx +169 -0
- package/src/components/resource/BrowseView.tsx +440 -0
- package/src/components/resource/DownloadFileLink.tsx +53 -0
- package/src/components/resource/HistoryEvent.tsx +186 -0
- package/src/components/resource/ResourceViewer.tsx +617 -0
- package/src/components/resource/__tests__/AnnotateView.code-point-offsets.test.tsx +482 -0
- package/src/components/resource/__tests__/AnnotateView.embeddable.test.tsx +78 -0
- package/src/components/resource/__tests__/AnnotateView.focus.test.tsx +147 -0
- package/src/components/resource/__tests__/AnnotateView.registry.test.tsx +143 -0
- package/src/components/resource/__tests__/AnnotationHistory.test.tsx +257 -0
- package/src/components/resource/__tests__/BrowseView.code-point-offsets.test.tsx +123 -0
- package/src/components/resource/__tests__/BrowseView.embeddable.test.tsx +76 -0
- package/src/components/resource/__tests__/BrowseView.links.test.tsx +84 -0
- package/src/components/resource/__tests__/BrowseView.overlay-async.test.tsx +165 -0
- package/src/components/resource/__tests__/BrowseView.reference-hover.test.tsx +200 -0
- package/src/components/resource/__tests__/BrowseView.registry.test.tsx +57 -0
- package/src/components/resource/__tests__/BrowseView.test.tsx +915 -0
- package/src/components/resource/__tests__/HistoryEvent.test.tsx +571 -0
- package/src/components/resource/__tests__/ResourceViewer.delete-failure.test.tsx +103 -0
- package/src/components/resource/__tests__/ResourceViewer.embeddable.test.tsx +250 -0
- package/src/components/resource/__tests__/ResourceViewer.mode-switch.test.tsx +262 -0
- package/src/components/resource/__tests__/ResourceViewer.multi-mount-invalidation.test.tsx +166 -0
- package/src/components/resource/__tests__/ResourceViewer.registry.test.tsx +112 -0
- package/src/components/resource/__tests__/ResourceViewer.toolbar-opt-out.test.tsx +207 -0
- package/src/components/resource/__tests__/ResourceViewer.toolbar-prefs.test.tsx +274 -0
- package/src/components/resource/__tests__/annotation-interactions.test.tsx +116 -0
- package/src/components/resource/__tests__/browse-renderers.dispatch.test.tsx +183 -0
- package/src/components/resource/__tests__/browse-renderers.test.tsx +47 -0
- package/src/components/resource/__tests__/download-link.test.tsx +171 -0
- package/src/components/resource/__tests__/event-formatting.test.ts +379 -0
- package/src/components/resource/__tests__/inline-embedding.test.tsx +133 -0
- package/src/components/resource/__tests__/media-completeness.test.tsx +144 -0
- package/src/components/resource/annotate-renderers.tsx +186 -0
- package/src/components/resource/browse-renderers.tsx +133 -0
- package/src/components/resource/event-formatting.ts +393 -0
- package/src/components/resource/panels/AssessmentEntry.tsx +127 -0
- package/src/components/resource/panels/AssessmentPanel.tsx +309 -0
- package/src/components/resource/panels/CollaborationPanel.css +184 -0
- package/src/components/resource/panels/CollaborationPanel.tsx +228 -0
- package/src/components/resource/panels/CommentEntry.tsx +242 -0
- package/src/components/resource/panels/CommentsPanel.tsx +320 -0
- package/src/components/resource/panels/DelegateSection.css +330 -0
- package/src/components/resource/panels/DelegateSection.tsx +282 -0
- package/src/components/resource/panels/DelegateShell.tsx +134 -0
- package/src/components/resource/panels/HighlightEntry.tsx +83 -0
- package/src/components/resource/panels/HighlightPanel.tsx +212 -0
- package/src/components/resource/panels/JsonLdPanel.css +37 -0
- package/src/components/resource/panels/JsonLdPanel.tsx +119 -0
- package/src/components/resource/panels/PanelHeader.tsx +22 -0
- package/src/components/resource/panels/ReferenceEntry.tsx +232 -0
- package/src/components/resource/panels/ReferencesPanel.css +108 -0
- package/src/components/resource/panels/ReferencesPanel.tsx +626 -0
- package/src/components/resource/panels/ResourceInfoPanel.css +183 -0
- package/src/components/resource/panels/ResourceInfoPanel.tsx +433 -0
- package/src/components/resource/panels/StatisticsPanel.css +127 -0
- package/src/components/resource/panels/StatisticsPanel.tsx +145 -0
- package/src/components/resource/panels/TagEntry.tsx +87 -0
- package/src/components/resource/panels/TaggingPanel.tsx +554 -0
- package/src/components/resource/panels/UnifiedAnnotationsPanel.css +129 -0
- package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +384 -0
- package/src/components/resource/panels/__tests__/AssessmentEntry.test.tsx +292 -0
- package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +685 -0
- package/src/components/resource/panels/__tests__/CollaborationPanel.test.tsx +685 -0
- package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +750 -0
- package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +877 -0
- package/src/components/resource/panels/__tests__/DelegateSection.test.tsx +623 -0
- package/src/components/resource/panels/__tests__/DelegateShell.test.tsx +212 -0
- package/src/components/resource/panels/__tests__/HighlightEntry.test.tsx +236 -0
- package/src/components/resource/panels/__tests__/HighlightPanel.annotationProgress.test.tsx +506 -0
- package/src/components/resource/panels/__tests__/HighlightPanel.out-of-order.test.tsx +132 -0
- package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +230 -0
- package/src/components/resource/panels/__tests__/PanelHeader.test.tsx +54 -0
- package/src/components/resource/panels/__tests__/ReferenceEntry.test.tsx +578 -0
- package/src/components/resource/panels/__tests__/ReferencesPanel.headless.test.tsx +193 -0
- package/src/components/resource/panels/__tests__/ReferencesPanel.observable-flow.test.tsx +193 -0
- package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +1080 -0
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +812 -0
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.text-layer.test.tsx +106 -0
- package/src/components/resource/panels/__tests__/StatisticsPanel.test.tsx +329 -0
- package/src/components/resource/panels/__tests__/TagEntry.test.tsx +250 -0
- package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +772 -0
- package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.delegated-job.test.tsx +207 -0
- package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.failure.test.tsx +89 -0
- package/src/components/resource/panels/__tests__/agent-label.test.ts +136 -0
- package/src/components/resource/panels/agent-label.ts +35 -0
- package/src/components/settings/SettingsPanel.css +92 -0
- package/src/components/settings/SettingsPanel.tsx +251 -0
- package/src/components/settings/__tests__/SettingsPanel.test.tsx +260 -0
- package/src/components/toolbar/Toolbar.css +245 -0
- package/src/components/viewers/ImageViewer.tsx +18 -0
- package/src/components/viewers/__tests__/ImageViewer.test.tsx +57 -0
- package/src/components/viewers/index.ts +1 -0
- package/src/features/auth/__tests__/AuthErrorDisplay.test.tsx +181 -0
- package/src/features/auth/auth.css +120 -0
- package/src/features/auth/components/AuthErrorDisplay.tsx +89 -0
- package/src/features/moderate-entity-tags/__tests__/EntityTagsPage.test.tsx +387 -0
- package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +161 -0
- package/src/features/moderate-entity-tags/state/__tests__/entity-tags-state-unit.test.ts +183 -0
- package/src/features/moderate-entity-tags/state/entity-tags-state-unit.ts +73 -0
- package/src/features/moderate-recent/__tests__/RecentDocumentsPage.test.tsx +422 -0
- package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +117 -0
- package/src/features/moderate-tag-schemas/__tests__/TagSchemasPage.test.tsx +481 -0
- package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +161 -0
- package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +600 -0
- package/src/features/resource-compose/__tests__/UploadProgressBar.test.tsx +256 -0
- package/src/features/resource-compose/components/ResourceComposePage.tsx +809 -0
- package/src/features/resource-compose/components/UploadProgressBar.tsx +125 -0
- package/src/features/resource-compose/state/__tests__/compose-page-state-unit.test.ts +195 -0
- package/src/features/resource-compose/state/compose-page-state-unit.ts +187 -0
- package/src/features/resource-discovery/__tests__/ResourceCard.test.tsx +338 -0
- package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +449 -0
- package/src/features/resource-discovery/components/ResourceCard.tsx +80 -0
- package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +330 -0
- package/src/features/resource-discovery/state/__tests__/discover-state-unit.test.ts +477 -0
- package/src/features/resource-discovery/state/discover-state-unit.ts +162 -0
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.content-loading.test.tsx +260 -0
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +570 -0
- package/src/features/resource-viewer/__tests__/generation-params.test.ts +49 -0
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +1058 -0
- package/src/features/resource-viewer/generation-params.ts +23 -0
- package/src/features/resource-viewer/hooks/__tests__/useResourceViewedReport.test.tsx +77 -0
- package/src/features/resource-viewer/hooks/useResourceViewedReport.ts +38 -0
- package/src/features/resource-viewer/state/__tests__/resource-loader-state-unit.test.ts +178 -0
- package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +505 -0
- package/src/features/resource-viewer/state/resource-loader-state-unit.ts +93 -0
- package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +156 -0
- package/src/styles/base/reset.css +105 -0
- package/src/styles/base/utilities.css +35 -0
- package/src/styles/core/badges.css +17 -0
- package/src/styles/core/buttons.css +772 -0
- package/src/styles/core/checkboxes.css +85 -0
- package/src/styles/core/forms.css +237 -0
- package/src/styles/core/index.css +43 -0
- package/src/styles/core/indicators.css +24 -0
- package/src/styles/core/inputs.css +164 -0
- package/src/styles/core/progress.css +85 -0
- package/src/styles/core/selects.css +119 -0
- package/src/styles/core/sliders.css +180 -0
- package/src/styles/core/tags.css +86 -0
- package/src/styles/core/textareas.css +104 -0
- package/src/styles/core/toggles.css +82 -0
- package/src/styles/features/compose.css +341 -0
- package/src/styles/features/entity-tags.css +140 -0
- package/src/styles/features/recent-docs.css +97 -0
- package/src/styles/features/resource-discovery.css +349 -0
- package/src/styles/features/resource-viewer.css +609 -0
- package/src/styles/features/resource.css +483 -0
- package/src/styles/features/schemas.css +222 -0
- package/src/styles/index.css +84 -0
- package/src/styles/layout/layout.css +28 -0
- package/src/styles/motivations/motivation-assessment.css +179 -0
- package/src/styles/motivations/motivation-comment.css +164 -0
- package/src/styles/motivations/motivation-highlight.css +132 -0
- package/src/styles/motivations/motivation-reference.css +167 -0
- package/src/styles/motivations/motivation-tag.css +182 -0
- package/src/styles/panels/history-panel.css +212 -0
- package/src/styles/panels/user-panel.css +21 -0
- package/src/styles/patterns/cards.css +26 -0
- package/src/styles/patterns/panel-helpers.css +32 -0
- package/src/styles/patterns/panels-base.css +272 -0
- package/src/styles/utilities/contrast.css +280 -0
- package/src/styles/utilities/focus-extended.css +276 -0
- package/src/styles/utilities/focus.css +41 -0
- package/src/styles/utilities/motion-overrides.css +286 -0
- package/src/styles/utilities/motion.css +184 -0
- package/src/styles/utilities/semantic-indicators.css +254 -0
- package/src/styles/variables.css +410 -0
- package/translations/ar.json +534 -0
- package/translations/bn.json +534 -0
- package/translations/cs.json +534 -0
- package/translations/da.json +534 -0
- package/translations/de.json +534 -0
- package/translations/el.json +534 -0
- package/translations/en.json +534 -0
- package/translations/es.json +534 -0
- package/translations/fa.json +534 -0
- package/translations/fi.json +534 -0
- package/translations/fr.json +534 -0
- package/translations/he.json +534 -0
- package/translations/hi.json +534 -0
- package/translations/id.json +534 -0
- package/translations/it.json +534 -0
- package/translations/ja.json +534 -0
- package/translations/ko.json +534 -0
- package/translations/ms.json +534 -0
- package/translations/nl.json +534 -0
- package/translations/no.json +534 -0
- package/translations/pl.json +534 -0
- package/translations/pt.json +534 -0
- package/translations/ro.json +534 -0
- package/translations/sv.json +534 -0
- package/translations/th.json +534 -0
- package/translations/tr.json +534 -0
- package/translations/uk.json +534 -0
- package/translations/vi.json +534 -0
- package/translations/zh.json +534 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The slot-height estimate of the PDF viewer's scroll column.
|
|
3
|
+
*
|
|
4
|
+
* The scroll column reserves space for unmounted pages. If the reservation is
|
|
5
|
+
* wrong, every mount and unmount changes the column's height and the scrollbar
|
|
6
|
+
* jumps — which is what the column first shipped, by reserving the raster
|
|
7
|
+
* height rather than the displayed one.
|
|
8
|
+
*
|
|
9
|
+
* These pins hold the estimate to the CSS the image is actually under:
|
|
10
|
+
* `max-width: 100%; height: auto`.
|
|
11
|
+
*/
|
|
12
|
+
import { describe, it, expect } from 'vitest';
|
|
13
|
+
import { estimateSlotHeight } from '../estimate-slot-height';
|
|
14
|
+
|
|
15
|
+
// US Letter at scale 1.5: 918 × 1188 raster, aspect 792/612.
|
|
16
|
+
const ASPECT = 792 / 612;
|
|
17
|
+
const RASTER_W = 918;
|
|
18
|
+
|
|
19
|
+
describe('estimateSlotHeight', () => {
|
|
20
|
+
it('scales to the column when the column is narrower than the raster', () => {
|
|
21
|
+
// The common case: `max-width: 100%` shrinks the image to the column.
|
|
22
|
+
expect(estimateSlotHeight(600, RASTER_W, ASPECT)).toBe(
|
|
23
|
+
Math.round(600 * ASPECT),
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('never upscales past the raster — max-width shrinks only', () => {
|
|
28
|
+
// A column wider than the raster leaves the image at natural size, so the
|
|
29
|
+
// height stops growing. Reserving columnWidth * aspect here would over-
|
|
30
|
+
// reserve and leave a gap under every page.
|
|
31
|
+
expect(estimateSlotHeight(1600, RASTER_W, ASPECT)).toBe(
|
|
32
|
+
Math.round(RASTER_W * ASPECT),
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('is exactly the raster height when the column matches the raster', () => {
|
|
37
|
+
expect(estimateSlotHeight(RASTER_W, RASTER_W, ASPECT)).toBe(
|
|
38
|
+
Math.round(RASTER_W * ASPECT),
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('does NOT use the raster height as a width-independent constant', () => {
|
|
43
|
+
// The original defect, stated as a pin: the raster is 1188px tall, but in a
|
|
44
|
+
// 600px column the page occupies ~776px. Reserving 1188 is what made the
|
|
45
|
+
// column's height lurch on every mount.
|
|
46
|
+
const rasterHeight = Math.round(RASTER_W * ASPECT); // 1188
|
|
47
|
+
expect(estimateSlotHeight(600, RASTER_W, ASPECT)).not.toBe(rasterHeight);
|
|
48
|
+
expect(estimateSlotHeight(600, RASTER_W, ASPECT)).toBeLessThan(
|
|
49
|
+
rasterHeight,
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('answers null until every measurement is in, rather than guessing', () => {
|
|
54
|
+
// A wrong reservation is worse than none: an unsized slot is stable, a
|
|
55
|
+
// mis-sized one moves when the page lands.
|
|
56
|
+
expect(estimateSlotHeight(null, RASTER_W, ASPECT)).toBeNull();
|
|
57
|
+
expect(estimateSlotHeight(600, null, ASPECT)).toBeNull();
|
|
58
|
+
expect(estimateSlotHeight(600, RASTER_W, null)).toBeNull();
|
|
59
|
+
expect(estimateSlotHeight(0, RASTER_W, ASPECT)).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rectsForPage axioms — the pure partition that distributes an annotation's
|
|
3
|
+
* FragmentSelectors into per-page rects. Geometry (each coord → canvas pixels) is
|
|
4
|
+
* covered separately by the pdf-coordinates transform axioms + the core codec axioms.
|
|
5
|
+
*
|
|
6
|
+
* The producer of multi-selector PDF annotations is AI detection (one
|
|
7
|
+
* FragmentSelector per line); these synthetic fixtures stand in for it.
|
|
8
|
+
*/
|
|
9
|
+
import { describe, it, expect } from 'vitest';
|
|
10
|
+
import * as fc from 'fast-check';
|
|
11
|
+
import { annotationId, resourceId, type Annotation } from '@xynolog/core';
|
|
12
|
+
import { rectsForPage } from '../rects-for-page';
|
|
13
|
+
|
|
14
|
+
const PAGES = 5;
|
|
15
|
+
|
|
16
|
+
type Sel = { page: number; x: number; y: number; w: number; h: number };
|
|
17
|
+
|
|
18
|
+
const selArb: fc.Arbitrary<Sel> = fc.record({
|
|
19
|
+
page: fc.integer({ min: 1, max: PAGES }),
|
|
20
|
+
x: fc.integer({ min: 0, max: 800 }),
|
|
21
|
+
y: fc.integer({ min: 0, max: 800 }),
|
|
22
|
+
w: fc.integer({ min: 1, max: 200 }),
|
|
23
|
+
h: fc.integer({ min: 1, max: 60 }),
|
|
24
|
+
});
|
|
25
|
+
// A "document" is a list of annotations, each a list of 0..4 selectors.
|
|
26
|
+
const docArb = fc.array(fc.array(selArb, { maxLength: 4 }), { maxLength: 6 });
|
|
27
|
+
|
|
28
|
+
function build(doc: ReadonlyArray<ReadonlyArray<Sel>>): Annotation[] {
|
|
29
|
+
return doc.map((sels, i): Annotation => ({
|
|
30
|
+
'@context': 'http://www.w3.org/ns/anno.jsonld',
|
|
31
|
+
type: 'Annotation',
|
|
32
|
+
id: annotationId(`ann-${i}`),
|
|
33
|
+
target: {
|
|
34
|
+
source: resourceId('res-1'),
|
|
35
|
+
selector: sels.map((s) => ({
|
|
36
|
+
type: 'FragmentSelector' as const,
|
|
37
|
+
value: `page=${s.page}&viewrect=${s.x},${s.y},${s.w},${s.h}`,
|
|
38
|
+
conformsTo: 'http://tools.ietf.org/rfc/rfc3778',
|
|
39
|
+
})),
|
|
40
|
+
},
|
|
41
|
+
motivation: 'highlighting',
|
|
42
|
+
created: '2026-01-01T00:00:00.000Z',
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const keysOn = (anns: Annotation[], page: number): string[] =>
|
|
47
|
+
rectsForPage(anns, page).map((r) => `${r.annId}:${r.selectorIndex}`);
|
|
48
|
+
|
|
49
|
+
describe('rectsForPage (multi-rect partition)', () => {
|
|
50
|
+
it('completeness: every FragmentSelector renders exactly once across all pages', () => {
|
|
51
|
+
fc.assert(
|
|
52
|
+
fc.property(docArb, (doc) => {
|
|
53
|
+
const anns = build(doc);
|
|
54
|
+
const total = doc.reduce((n, sels) => n + sels.length, 0);
|
|
55
|
+
let rendered = 0;
|
|
56
|
+
for (let p = 1; p <= PAGES; p++)
|
|
57
|
+
rendered += rectsForPage(anns, p).length;
|
|
58
|
+
expect(rendered).toBe(total);
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('page-locality: every rect on page p came from a selector with page === p', () => {
|
|
64
|
+
fc.assert(
|
|
65
|
+
fc.property(docArb, fc.integer({ min: 1, max: PAGES }), (doc, p) => {
|
|
66
|
+
for (const r of rectsForPage(build(doc), p))
|
|
67
|
+
expect(r.coord.page).toBe(p);
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('key uniqueness: `${annId}:${selectorIndex}` is pairwise unique on any page', () => {
|
|
73
|
+
fc.assert(
|
|
74
|
+
fc.property(docArb, fc.integer({ min: 1, max: PAGES }), (doc, p) => {
|
|
75
|
+
const keys = keysOn(build(doc), p);
|
|
76
|
+
expect(new Set(keys).size).toBe(keys.length);
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('order independence: reversing the annotation list preserves the rendered set per page', () => {
|
|
82
|
+
fc.assert(
|
|
83
|
+
fc.property(docArb, fc.integer({ min: 1, max: PAGES }), (doc, p) => {
|
|
84
|
+
const anns = build(doc);
|
|
85
|
+
expect([...keysOn([...anns].reverse(), p)].sort()).toEqual(
|
|
86
|
+
[...keysOn(anns, p)].sort(),
|
|
87
|
+
);
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('single-selector invariance: a manual (one-selector) annotation → exactly one rect on its page', () => {
|
|
93
|
+
const anns = build([[{ page: 2, x: 72, y: 720, w: 150, h: 12 }]]);
|
|
94
|
+
const onPage2 = rectsForPage(anns, 2);
|
|
95
|
+
expect(onPage2).toHaveLength(1);
|
|
96
|
+
expect(onPage2[0].selectorIndex).toBe(0);
|
|
97
|
+
expect(rectsForPage(anns, 1)).toHaveLength(0);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('multi-line: a 3-selector annotation on one page → 3 distinctly-keyed rects', () => {
|
|
101
|
+
const anns = build([
|
|
102
|
+
[
|
|
103
|
+
{ page: 2, x: 72, y: 720, w: 150, h: 12 },
|
|
104
|
+
{ page: 2, x: 72, y: 700, w: 140, h: 12 },
|
|
105
|
+
{ page: 2, x: 72, y: 680, w: 90, h: 12 },
|
|
106
|
+
],
|
|
107
|
+
]);
|
|
108
|
+
expect(keysOn(anns, 2)).toEqual(['ann-0:0', 'ann-0:1', 'ann-0:2']);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The height a page will occupy once rendered, computed BEFORE rendering it.
|
|
3
|
+
*
|
|
4
|
+
* The scrolling column reserves space for pages it has not mounted. If the
|
|
5
|
+
* reserved height differs from the height the page actually takes, every mount
|
|
6
|
+
* and unmount changes the column's total height and the scrollbar jumps under
|
|
7
|
+
* the reader's cursor — the defect S1 shipped by reserving the *raster* height
|
|
8
|
+
* (`getViewport({ scale }).height`) instead of the *displayed* one.
|
|
9
|
+
*
|
|
10
|
+
* This models the CSS the image is under exactly:
|
|
11
|
+
*
|
|
12
|
+
* .xynolog-pdf-annotation-canvas__image { max-width: 100%; height: auto; }
|
|
13
|
+
*
|
|
14
|
+
* `max-width` shrinks but never upscales, so the displayed width is
|
|
15
|
+
* `min(columnWidth, rasterWidth)` and the height follows the page's aspect
|
|
16
|
+
* ratio. Aspect is scale-invariant, so it can come from any viewport.
|
|
17
|
+
*
|
|
18
|
+
* @param columnWidth Measured inner width of the scroll column, in CSS px.
|
|
19
|
+
* @param rasterWidth Width of the rendered raster, in px (`viewport(scale).width`).
|
|
20
|
+
* @param aspect Page height ÷ width, from any viewport scale.
|
|
21
|
+
* @returns Reserved height in CSS px, or null when a measurement is not in yet.
|
|
22
|
+
*/
|
|
23
|
+
export function estimateSlotHeight(
|
|
24
|
+
columnWidth: number | null,
|
|
25
|
+
rasterWidth: number | null,
|
|
26
|
+
aspect: number | null,
|
|
27
|
+
): number | null {
|
|
28
|
+
if (!columnWidth || !rasterWidth || !aspect) return null;
|
|
29
|
+
if (columnWidth <= 0 || rasterWidth <= 0 || aspect <= 0) return null;
|
|
30
|
+
return Math.round(Math.min(columnWidth, rasterWidth) * aspect);
|
|
31
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Annotation, PdfCoordinate } from '@xynolog/core';
|
|
2
|
+
import { getTargetSelector, parseFragmentSelector } from '@xynolog/core';
|
|
3
|
+
|
|
4
|
+
/** One FragmentSelector rectangle to paint on a PDF page. */
|
|
5
|
+
export interface PageRect {
|
|
6
|
+
/** Owning annotation id — shared by every rect of a multi-line annotation (hover/click routing). */
|
|
7
|
+
annId: Annotation['id'];
|
|
8
|
+
/** Index within the annotation's FragmentSelectors — the stable half of the React key. */
|
|
9
|
+
selectorIndex: number;
|
|
10
|
+
/** PDF-point geometry for this rect. */
|
|
11
|
+
coord: PdfCoordinate;
|
|
12
|
+
/** Owning annotation (motivation colour, etc.). */
|
|
13
|
+
annotation: Annotation;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Every FragmentSelector on a target, in order (`target.selector` may be one or an array). */
|
|
17
|
+
function fragmentSelectors(target: Annotation['target']): { value: string }[] {
|
|
18
|
+
const selector = getTargetSelector(target);
|
|
19
|
+
if (!selector) return [];
|
|
20
|
+
const selectors = Array.isArray(selector) ? selector : [selector];
|
|
21
|
+
return selectors
|
|
22
|
+
.filter((s) => s.type === 'FragmentSelector')
|
|
23
|
+
.map((s) => s as { type: 'FragmentSelector'; value: string });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The rectangles to paint on `pageNumber`: one entry per FragmentSelector whose
|
|
28
|
+
* viewrect page matches. A multi-line (multi-selector) annotation therefore yields
|
|
29
|
+
* one rect per line; a single-selector (manual) annotation yields exactly one.
|
|
30
|
+
*
|
|
31
|
+
* Pure — no React/DOM. `PdfAnnotationCanvas` maps this to `<rect>` keyed
|
|
32
|
+
* `${annId}:${selectorIndex}`, and the rects-for-page axioms exercise it directly.
|
|
33
|
+
* Geometry stays deferred: each `coord` still goes through `pdfToCanvasCoordinates`
|
|
34
|
+
* at paint time (itself covered by the coordinate-transform axioms).
|
|
35
|
+
*/
|
|
36
|
+
export function rectsForPage(
|
|
37
|
+
annotations: Annotation[],
|
|
38
|
+
pageNumber: number,
|
|
39
|
+
): PageRect[] {
|
|
40
|
+
const rects: PageRect[] = [];
|
|
41
|
+
for (const annotation of annotations) {
|
|
42
|
+
fragmentSelectors(annotation.target).forEach((sel, selectorIndex) => {
|
|
43
|
+
const coord = parseFragmentSelector(sel.value);
|
|
44
|
+
if (coord && coord.page === pageNumber) {
|
|
45
|
+
rects.push({ annId: annotation.id, selectorIndex, coord, annotation });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return rects;
|
|
50
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { EventMap, ResourceId } from '@xynolog/core';
|
|
4
|
+
import { useRef, useEffect, useCallback, useMemo } from 'react';
|
|
5
|
+
import { capabilitiesOf, textOffsets } from '@xynolog/core';
|
|
6
|
+
import { ANNOTATORS } from '../../lib/annotation-registry';
|
|
7
|
+
import { documentPositions } from '../../lib/codemirror-logic';
|
|
8
|
+
import {
|
|
9
|
+
buildTextSelectors,
|
|
10
|
+
fallbackTextPosition,
|
|
11
|
+
} from '../../lib/text-selection-handler';
|
|
12
|
+
import {
|
|
13
|
+
defaultAnnotateRenderers,
|
|
14
|
+
type AnnotateMediaRenderers,
|
|
15
|
+
} from './annotate-renderers';
|
|
16
|
+
import { DownloadFileLink } from './DownloadFileLink';
|
|
17
|
+
import {
|
|
18
|
+
TranslationProvider,
|
|
19
|
+
type TranslationSource,
|
|
20
|
+
} from '../../contexts/TranslationContext';
|
|
21
|
+
import { translationSourceOf } from '../../lib/translation-source';
|
|
22
|
+
import { EditorView } from '@codemirror/view';
|
|
23
|
+
import { HOVER_DELAY_MS, type XynologSession } from '@xynolog/sdk';
|
|
24
|
+
import { useSessionEventSubscriptions } from '../../hooks/useSessionEventSubscriptions';
|
|
25
|
+
import { scrollAnnotationIntoView } from '../../lib/scroll-utils';
|
|
26
|
+
import {
|
|
27
|
+
AnnotateToolbar,
|
|
28
|
+
type ClickAction,
|
|
29
|
+
type ShapeType,
|
|
30
|
+
} from '../annotation/AnnotateToolbar';
|
|
31
|
+
import type { Motivation } from '@xynolog/core';
|
|
32
|
+
import type {
|
|
33
|
+
AnnotationsCollection,
|
|
34
|
+
AnnotationUIState,
|
|
35
|
+
} from '../../types/annotation-props';
|
|
36
|
+
|
|
37
|
+
// Re-export for convenience
|
|
38
|
+
export type { ClickAction, ShapeType };
|
|
39
|
+
|
|
40
|
+
interface Props {
|
|
41
|
+
content: string;
|
|
42
|
+
mimeType?: string;
|
|
43
|
+
/** The '@id' of the shown resource — stamped as `source` on mark:requested (multi-viewer routing). */
|
|
44
|
+
resourceUri: ResourceId;
|
|
45
|
+
annotations: AnnotationsCollection;
|
|
46
|
+
/** Zoom the rendered resource content, leaving the annotation toolbar at its normal size. */
|
|
47
|
+
zoom?: number;
|
|
48
|
+
uiState: AnnotationUIState;
|
|
49
|
+
onUIStateChange?: (state: Partial<AnnotationUIState>) => void;
|
|
50
|
+
editable?: boolean;
|
|
51
|
+
enableWidgets?: boolean;
|
|
52
|
+
getTargetResourceName?: (resourceId: string) => string | undefined;
|
|
53
|
+
generatingReferenceId?: string | null;
|
|
54
|
+
showLineNumbers?: boolean;
|
|
55
|
+
hoverDelayMs?: number;
|
|
56
|
+
annotateMode: boolean;
|
|
57
|
+
/** Session for the shown resource — its client emits mark:* / mark.request; its bus feeds toolbar + beckon events. */
|
|
58
|
+
session: XynologSession | null;
|
|
59
|
+
/** Recently-created annotation ids to sparkle (host-provided). */
|
|
60
|
+
sparkleAnnotationIds?: Set<string>;
|
|
61
|
+
/** The bar's Mode control reports the chosen mode here (the owner applies it). */
|
|
62
|
+
onModeChange?: (mode: boolean) => void;
|
|
63
|
+
/** Render the built-in bar (default). false → no bar; selection capture and drawing stay live. */
|
|
64
|
+
showToolbar?: boolean;
|
|
65
|
+
/** Override the annotating media renderers (render mode → renderer); merged over the defaults. */
|
|
66
|
+
renderers?: AnnotateMediaRenderers;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The annotating view, given its language: it mounts the translation provider
|
|
71
|
+
* its subtree reads. Inside `ResourceViewer` it is handed the viewer's own.
|
|
72
|
+
*/
|
|
73
|
+
export function AnnotateView(props: Props & TranslationSource) {
|
|
74
|
+
return (
|
|
75
|
+
<TranslationProvider {...translationSourceOf(props)}>
|
|
76
|
+
<AnnotateViewBody {...props} />
|
|
77
|
+
</TranslationProvider>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* View component for annotating resources with text selection and drawing
|
|
83
|
+
*
|
|
84
|
+
* @emits mark:requested - User requested to create annotation. Payload: { source: ResourceId, selector: Selector | Selector[], motivation: Motivation }
|
|
85
|
+
* @subscribes beckon:hover - Annotation hovered. Payload: { annotationId: string | null }
|
|
86
|
+
* @subscribes beckon:focus - Scroll to and highlight the annotation, or to the top when it names none, unless `resourceId` names a different resource. Payload: { resourceId: string, annotationId?: string }
|
|
87
|
+
*/
|
|
88
|
+
function AnnotateViewBody({
|
|
89
|
+
content,
|
|
90
|
+
mimeType = 'text/plain',
|
|
91
|
+
zoom = 1,
|
|
92
|
+
resourceUri,
|
|
93
|
+
annotations,
|
|
94
|
+
uiState,
|
|
95
|
+
onUIStateChange,
|
|
96
|
+
enableWidgets = false,
|
|
97
|
+
getTargetResourceName,
|
|
98
|
+
generatingReferenceId,
|
|
99
|
+
showLineNumbers = false,
|
|
100
|
+
hoverDelayMs = HOVER_DELAY_MS,
|
|
101
|
+
annotateMode,
|
|
102
|
+
session,
|
|
103
|
+
sparkleAnnotationIds,
|
|
104
|
+
onModeChange,
|
|
105
|
+
showToolbar = true,
|
|
106
|
+
renderers,
|
|
107
|
+
}: Props) {
|
|
108
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
109
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
110
|
+
|
|
111
|
+
const render = capabilitiesOf(mimeType)?.render ?? 'none';
|
|
112
|
+
|
|
113
|
+
// The content's conversions, made once for a content: an offset counts its
|
|
114
|
+
// code points, and a selection is found at a position in the editor's
|
|
115
|
+
// document, which counts UTF-16 code units and each line break as one.
|
|
116
|
+
const offsets = useMemo(() => textOffsets(content), [content]);
|
|
117
|
+
const positions = useMemo(
|
|
118
|
+
() => documentPositions(content, offsets),
|
|
119
|
+
[content, offsets],
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const { highlights, references, assessments, comments, tags } = annotations;
|
|
123
|
+
|
|
124
|
+
const allAnnotations = [
|
|
125
|
+
...highlights,
|
|
126
|
+
...references,
|
|
127
|
+
...assessments,
|
|
128
|
+
...comments,
|
|
129
|
+
...tags,
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
// Extract UI state
|
|
133
|
+
const {
|
|
134
|
+
selectedMotivation,
|
|
135
|
+
selectedClick,
|
|
136
|
+
selectedShape,
|
|
137
|
+
hoveredAnnotationId,
|
|
138
|
+
scrollToAnnotationId,
|
|
139
|
+
} = uiState;
|
|
140
|
+
|
|
141
|
+
// Store onUIStateChange in ref to avoid dependency issues
|
|
142
|
+
const onUIStateChangeRef = useRef(onUIStateChange);
|
|
143
|
+
onUIStateChangeRef.current = onUIStateChange;
|
|
144
|
+
|
|
145
|
+
// Toolbar callbacks: the presentational bar reports chosen values; route them up
|
|
146
|
+
// through the existing onUIStateChange path (the owner applies them).
|
|
147
|
+
const handleToolbarSelectionChange = useCallback(
|
|
148
|
+
(motivation: Motivation | null) => {
|
|
149
|
+
onUIStateChangeRef.current?.({ selectedMotivation: motivation });
|
|
150
|
+
},
|
|
151
|
+
[],
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const handleToolbarClickActionChange = useCallback((action: ClickAction) => {
|
|
155
|
+
onUIStateChangeRef.current?.({ selectedClick: action });
|
|
156
|
+
}, []);
|
|
157
|
+
|
|
158
|
+
const handleToolbarShapeChange = useCallback((shape: ShapeType) => {
|
|
159
|
+
onUIStateChangeRef.current?.({ selectedShape: shape });
|
|
160
|
+
}, []);
|
|
161
|
+
|
|
162
|
+
const handleAnnotationHover = useCallback(
|
|
163
|
+
({ annotationId }: { annotationId: string | null }) => {
|
|
164
|
+
onUIStateChangeRef.current?.({ hoveredAnnotationId: annotationId });
|
|
165
|
+
},
|
|
166
|
+
[],
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
// "Scroll to and highlight this annotation" — the same contract BrowseView
|
|
170
|
+
// serves, so the behaviour does not depend on which view mode is active.
|
|
171
|
+
// The `scrollToAnnotationId` prop path (uiState → renderer) stays as the
|
|
172
|
+
// host-facing capability it is; this is the in-app producer's route.
|
|
173
|
+
// A focus on another resource is not this view's: one on an annotation
|
|
174
|
+
// there is ignored, and one on the resource alone is the host's to bring
|
|
175
|
+
// forward. A focus on this resource and no annotation scrolls to its top.
|
|
176
|
+
const handleFocus = useCallback(
|
|
177
|
+
({ annotationId, resourceId }: EventMap['beckon:focus']) => {
|
|
178
|
+
if (resourceId !== resourceUri) return;
|
|
179
|
+
if (annotationId === undefined) {
|
|
180
|
+
if (!contentRef.current) return;
|
|
181
|
+
contentRef.current.scrollTo({ top: 0, behavior: 'smooth' });
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (!containerRef.current) return;
|
|
185
|
+
scrollAnnotationIntoView(annotationId, containerRef.current, {
|
|
186
|
+
pulse: true,
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
[resourceUri],
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// Annotation hover (session-scoped). Toolbar preference changes flow through
|
|
193
|
+
// props/callbacks, not the bus.
|
|
194
|
+
useSessionEventSubscriptions(session, {
|
|
195
|
+
'beckon:hover': handleAnnotationHover,
|
|
196
|
+
'beckon:focus': handleFocus,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Handle text annotation with sparkle or immediate creation
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
const container = containerRef.current;
|
|
202
|
+
if (!container) return;
|
|
203
|
+
|
|
204
|
+
let clickedOnAnnotation = false;
|
|
205
|
+
|
|
206
|
+
const handleMouseDown = (e: MouseEvent) => {
|
|
207
|
+
// Check if mousedown was on an existing annotation
|
|
208
|
+
const target = e.target as Element;
|
|
209
|
+
clickedOnAnnotation = !!target.closest('[data-annotation-id]');
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const handleMouseUp = (e: MouseEvent) => {
|
|
213
|
+
// Skip if the mouseUp came from PDF or image canvas
|
|
214
|
+
// (those components handle their own mark:requested events)
|
|
215
|
+
const target = e.target as Element;
|
|
216
|
+
if (
|
|
217
|
+
target.closest('.xynolog-pdf-annotation-canvas') ||
|
|
218
|
+
target.closest('.xynolog-svg-drawing-canvas')
|
|
219
|
+
) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const selection = window.getSelection();
|
|
224
|
+
if (!selection || selection.isCollapsed || !selection.toString()) {
|
|
225
|
+
clickedOnAnnotation = false;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// If mousedown was on an existing annotation, don't trigger creation
|
|
230
|
+
// The annotation's click handler will take care of it
|
|
231
|
+
if (clickedOnAnnotation) {
|
|
232
|
+
clickedOnAnnotation = false;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
clickedOnAnnotation = false;
|
|
236
|
+
|
|
237
|
+
if (!selectedMotivation) return;
|
|
238
|
+
|
|
239
|
+
const range = selection.getRangeAt(0);
|
|
240
|
+
const view = EditorView.findFromDOM(container);
|
|
241
|
+
|
|
242
|
+
let selected: { start: number; end: number } | null;
|
|
243
|
+
|
|
244
|
+
if (view) {
|
|
245
|
+
// A selection that begins or ends outside the editor's text is not a
|
|
246
|
+
// selection of the content.
|
|
247
|
+
if (
|
|
248
|
+
!view.contentDOM.contains(range.startContainer) ||
|
|
249
|
+
!view.contentDOM.contains(range.endContainer)
|
|
250
|
+
)
|
|
251
|
+
return;
|
|
252
|
+
// CodeMirror's posAtDOM gives the position in its document of a DOM
|
|
253
|
+
// node/offset; both ends are asked, since the selection's own string
|
|
254
|
+
// is not the content's text between them (a line break of the
|
|
255
|
+
// document is the content's CRLF, and a widget's text is not content).
|
|
256
|
+
selected = {
|
|
257
|
+
start: positions.offsetAt(
|
|
258
|
+
view.posAtDOM(range.startContainer, range.startOffset),
|
|
259
|
+
),
|
|
260
|
+
end: positions.offsetAt(
|
|
261
|
+
view.posAtDOM(range.endContainer, range.endOffset),
|
|
262
|
+
),
|
|
263
|
+
};
|
|
264
|
+
} else {
|
|
265
|
+
// No editor (a host's own text renderer): where the content first has
|
|
266
|
+
// the selected text. For text the content has more than once, that
|
|
267
|
+
// may not be the place selected.
|
|
268
|
+
selected = fallbackTextPosition(content, offsets, selection.toString());
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (!selected) return;
|
|
272
|
+
|
|
273
|
+
const selectors = buildTextSelectors(
|
|
274
|
+
content,
|
|
275
|
+
offsets,
|
|
276
|
+
selected.start,
|
|
277
|
+
selected.end,
|
|
278
|
+
);
|
|
279
|
+
if (!selectors) return;
|
|
280
|
+
|
|
281
|
+
session?.client.mark.request(resourceUri, selectors, selectedMotivation);
|
|
282
|
+
|
|
283
|
+
// Clear selection after creating annotation
|
|
284
|
+
selection.removeAllRanges();
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
container.addEventListener('mouseup', handleMouseUp);
|
|
288
|
+
container.addEventListener('mousedown', handleMouseDown);
|
|
289
|
+
|
|
290
|
+
return () => {
|
|
291
|
+
container.removeEventListener('mouseup', handleMouseUp);
|
|
292
|
+
container.removeEventListener('mousedown', handleMouseDown);
|
|
293
|
+
};
|
|
294
|
+
}, [selectedMotivation, content, offsets, positions, resourceUri]);
|
|
295
|
+
|
|
296
|
+
// One shell for every render mode; the registry supplies the content.
|
|
297
|
+
// A `switch` per mode would repeat this wrapper, the toolbar block and the
|
|
298
|
+
// content div in each branch, so any toolbar prop change would have to be
|
|
299
|
+
// made in every one and stay correct only by vigilance.
|
|
300
|
+
const mediaRenderers: AnnotateMediaRenderers = {
|
|
301
|
+
...defaultAnnotateRenderers,
|
|
302
|
+
...renderers,
|
|
303
|
+
};
|
|
304
|
+
const Renderer = mediaRenderers[render];
|
|
305
|
+
|
|
306
|
+
// A mode with no renderer, in neither the defaults nor the override,
|
|
307
|
+
// gets no annotating surface. That is every type with no preview and every
|
|
308
|
+
// registry miss — both read as 'none' above — and the browse side answers
|
|
309
|
+
// them the same way, with its own no-preview fallback. Annotating a type
|
|
310
|
+
// nothing here can render is not harmless, so the toolbar is deliberately
|
|
311
|
+
// absent in this branch.
|
|
312
|
+
if (!Renderer) {
|
|
313
|
+
return (
|
|
314
|
+
<div
|
|
315
|
+
ref={containerRef}
|
|
316
|
+
className="xynolog-annotate-view xynolog-annotate-view--unsupported"
|
|
317
|
+
data-mime-type="unsupported"
|
|
318
|
+
>
|
|
319
|
+
<div className="xynolog-annotate-view__empty">
|
|
320
|
+
<p className="xynolog-annotate-view__empty-message">
|
|
321
|
+
Annotation not supported for {mimeType}
|
|
322
|
+
</p>
|
|
323
|
+
<DownloadFileLink resourceUri={resourceUri} session={session} />
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return (
|
|
330
|
+
<div
|
|
331
|
+
className="xynolog-annotate-view"
|
|
332
|
+
data-mime-type={render}
|
|
333
|
+
ref={containerRef}
|
|
334
|
+
>
|
|
335
|
+
{showToolbar && (
|
|
336
|
+
<AnnotateToolbar
|
|
337
|
+
selectedMotivation={selectedMotivation}
|
|
338
|
+
selectedClick={selectedClick}
|
|
339
|
+
selectedShape={selectedShape}
|
|
340
|
+
mediaType={mimeType}
|
|
341
|
+
annotateMode={annotateMode}
|
|
342
|
+
annotators={ANNOTATORS}
|
|
343
|
+
onModeChange={onModeChange}
|
|
344
|
+
onClickActionChange={handleToolbarClickActionChange}
|
|
345
|
+
onSelectionChange={handleToolbarSelectionChange}
|
|
346
|
+
onShapeChange={handleToolbarShapeChange}
|
|
347
|
+
/>
|
|
348
|
+
)}
|
|
349
|
+
<div className="xynolog-annotate-view__content" ref={contentRef}>
|
|
350
|
+
<div style={render === 'pdf' ? undefined : { zoom }}>
|
|
351
|
+
<Renderer
|
|
352
|
+
content={content}
|
|
353
|
+
mimeType={mimeType}
|
|
354
|
+
zoom={zoom}
|
|
355
|
+
resourceUri={resourceUri}
|
|
356
|
+
annotations={allAnnotations}
|
|
357
|
+
session={session}
|
|
358
|
+
drawingMode={selectedMotivation ? selectedShape : null}
|
|
359
|
+
selectedMotivation={selectedMotivation}
|
|
360
|
+
hoveredAnnotationId={hoveredAnnotationId}
|
|
361
|
+
hoverDelayMs={hoverDelayMs}
|
|
362
|
+
sparkleAnnotationIds={sparkleAnnotationIds}
|
|
363
|
+
scrollToAnnotationId={scrollToAnnotationId}
|
|
364
|
+
showLineNumbers={showLineNumbers}
|
|
365
|
+
enableWidgets={enableWidgets}
|
|
366
|
+
{...(getTargetResourceName && { getTargetResourceName })}
|
|
367
|
+
generatingReferenceId={generatingReferenceId}
|
|
368
|
+
/>
|
|
369
|
+
</div>
|
|
370
|
+
</div>
|
|
371
|
+
</div>
|
|
372
|
+
);
|
|
373
|
+
}
|