Skip to content

Support incremental annotation overlay to avoid full WASM re-conversion #106

@JSv4

Description

@JSv4

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

  1. Separate conversion and projection: A two-step API where convertDocxToHtml(bytes) produces the base HTML once, and projectAnnotations(html, annotationSet) can be called repeatedly on the same base HTML.
  2. DOM-level annotation API: Return a handle/context from the initial conversion that supports addAnnotation() / removeAnnotation() operations directly on the rendered DOM.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions