feat(annotations): add external annotation system (Issue #57)#73
Merged
Conversation
Add a parallel annotation system that stores annotations externally as JSON without modifying the source DOCX file. Annotations are validated against a SHA256 document hash and projected onto HTML during rendering. Core components: - ExternalAnnotationSet: extends OpenContractDocExport with document binding (documentId, documentHash, timestamps, label definitions) - ExternalAnnotationManager: hash computation, annotation creation from offsets or text search, validation, JSON serialization - ExternalAnnotationProjector: projects annotations onto HTML as styled spans with configurable label modes (Above, Inline, Tooltip, None) WASM layer: - AOT-safe JSON deserialization using source-generated JsonContext - camelCase property naming for JavaScript interop - JSExport methods: ComputeDocumentHash, CreateExternalAnnotationSet, ValidateExternalAnnotations, ConvertDocxToHtmlWithExternalAnnotations, SearchTextOffsets TypeScript/npm: - Full type definitions for external annotation types - Wrapper functions matching WASM exports - Client-side helpers for annotation creation - Test harness with external annotation API Testing: - 21 C# unit tests for core functionality - 11 Playwright browser tests including visual demo - Visual demo renders document with annotations and JSON panel Closes #57
084e645 to
3250f93
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements External Annotation Storage and Projection System - a parallel annotation system that stores annotations externally as JSON without modifying the source DOCX file.
OpenContractDocExportformatKey Components
ExternalAnnotationSetExternalAnnotationManagerExternalAnnotationProjectorAPI Additions
C# / .NET:
ExternalAnnotationManager.ComputeDocumentHash()ExternalAnnotationManager.CreateAnnotationSet()ExternalAnnotationManager.CreateAnnotation()/CreateAnnotationFromSearch()ExternalAnnotationManager.Validate()ExternalAnnotationProjector.ProjectAnnotations()/ConvertWithAnnotations()TypeScript/npm:
computeDocumentHash()createExternalAnnotationSet()validateExternalAnnotations()convertDocxToHtmlWithExternalAnnotations()searchTextOffsets()Label Display Modes
Test plan
dotnet test+npx playwright test)Screenshots
The visual demo shows:
Closes #57