-
Notifications
You must be signed in to change notification settings - Fork 1
Support incremental annotation overlay to avoid full WASM re-conversion #106
Description
Problem
When using Docxodus in OpenContracts' DocxAnnotator component, any annotation creation/deletion or label filter toggle triggers a full WASM re-conversion of the entire document via convertDocxToHtmlWithExternalAnnotations(). For large legal documents, this causes a noticeable delay on every interaction.
The current useEffect depends on [wasmReady, docxBytes, docText, annotations, visibleLabels, showStructuralAnnotations], meaning any change to annotations or visible labels re-runs the full conversion pipeline.
Desired Behavior
An API that allows updating annotation overlays incrementally (e.g., adding/removing individual annotation spans in the DOM) without re-converting the entire DOCX document from bytes. This would enable:
- Instant annotation creation feedback
- Fast label filter toggling
- Smooth annotation selection highlighting
Possible Approaches
- Separate conversion and projection: A two-step API where
convertDocxToHtml(bytes)produces the base HTML once, andprojectAnnotations(html, annotationSet)can be called repeatedly on the same base HTML. - DOM-level annotation API: Return a handle/context from the initial conversion that supports
addAnnotation()/removeAnnotation()operations directly on the rendered DOM. - CSS-only annotation visibility: Use CSS classes for annotation visibility toggling rather than re-rendering (for label filter changes specifically).
Context
Found during code review of OpenContracts PR #1102 which adds first-class DOCX support.