docxodus 12.4.0 → 12.4.1

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.
Files changed (87) hide show
  1. package/README.md +23 -0
  2. package/dist/core.d.ts +924 -0
  3. package/dist/core.d.ts.map +1 -0
  4. package/dist/core.js +2094 -0
  5. package/dist/core.js.map +1 -0
  6. package/dist/embed.bundle.js +12229 -12229
  7. package/dist/embed.iife.js +12231 -12231
  8. package/dist/export-assets.json +39 -39
  9. package/dist/index.d.ts +2 -922
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -2093
  12. package/dist/index.js.map +1 -1
  13. package/dist/wasm/_framework/Docxodus.wasm +0 -0
  14. package/dist/wasm/_framework/Docxodus.wasm.br +0 -0
  15. package/dist/wasm/_framework/DocxodusWasm.wasm +0 -0
  16. package/dist/wasm/_framework/DocxodusWasm.wasm.br +0 -0
  17. package/dist/wasm/_framework/System.Collections.Concurrent.wasm +0 -0
  18. package/dist/wasm/_framework/System.Collections.Concurrent.wasm.br +0 -0
  19. package/dist/wasm/_framework/System.Collections.Immutable.wasm +0 -0
  20. package/dist/wasm/_framework/System.Collections.Immutable.wasm.br +0 -0
  21. package/dist/wasm/_framework/System.Collections.NonGeneric.wasm +0 -0
  22. package/dist/wasm/_framework/System.Collections.NonGeneric.wasm.br +0 -0
  23. package/dist/wasm/_framework/System.Collections.Specialized.wasm +0 -0
  24. package/dist/wasm/_framework/System.Collections.Specialized.wasm.br +0 -0
  25. package/dist/wasm/_framework/System.Collections.wasm +0 -0
  26. package/dist/wasm/_framework/System.Collections.wasm.br +0 -0
  27. package/dist/wasm/_framework/System.ComponentModel.Primitives.wasm +0 -0
  28. package/dist/wasm/_framework/System.ComponentModel.Primitives.wasm.br +0 -0
  29. package/dist/wasm/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
  30. package/dist/wasm/_framework/System.ComponentModel.TypeConverter.wasm.br +0 -0
  31. package/dist/wasm/_framework/System.ComponentModel.wasm +0 -0
  32. package/dist/wasm/_framework/System.ComponentModel.wasm.br +0 -0
  33. package/dist/wasm/_framework/System.Console.wasm +0 -0
  34. package/dist/wasm/_framework/System.Console.wasm.br +0 -0
  35. package/dist/wasm/_framework/System.IO.Compression.wasm +0 -0
  36. package/dist/wasm/_framework/System.IO.Compression.wasm.br +0 -0
  37. package/dist/wasm/_framework/System.IO.Pipelines.wasm +0 -0
  38. package/dist/wasm/_framework/System.IO.Pipelines.wasm.br +0 -0
  39. package/dist/wasm/_framework/System.Linq.Expressions.wasm +0 -0
  40. package/dist/wasm/_framework/System.Linq.Expressions.wasm.br +0 -0
  41. package/dist/wasm/_framework/System.Linq.wasm +0 -0
  42. package/dist/wasm/_framework/System.Linq.wasm.br +0 -0
  43. package/dist/wasm/_framework/System.Memory.wasm +0 -0
  44. package/dist/wasm/_framework/System.Memory.wasm.br +0 -0
  45. package/dist/wasm/_framework/System.Net.Http.wasm +0 -0
  46. package/dist/wasm/_framework/System.Net.Http.wasm.br +0 -0
  47. package/dist/wasm/_framework/System.Net.Primitives.wasm +0 -0
  48. package/dist/wasm/_framework/System.Net.Primitives.wasm.br +0 -0
  49. package/dist/wasm/_framework/System.ObjectModel.wasm +0 -0
  50. package/dist/wasm/_framework/System.ObjectModel.wasm.br +0 -0
  51. package/dist/wasm/_framework/System.Private.CoreLib.wasm +0 -0
  52. package/dist/wasm/_framework/System.Private.CoreLib.wasm.br +0 -0
  53. package/dist/wasm/_framework/System.Private.Uri.wasm +0 -0
  54. package/dist/wasm/_framework/System.Private.Uri.wasm.br +0 -0
  55. package/dist/wasm/_framework/System.Private.Xml.Linq.wasm +0 -0
  56. package/dist/wasm/_framework/System.Private.Xml.Linq.wasm.br +0 -0
  57. package/dist/wasm/_framework/System.Private.Xml.wasm +0 -0
  58. package/dist/wasm/_framework/System.Private.Xml.wasm.br +0 -0
  59. package/dist/wasm/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  60. package/dist/wasm/_framework/System.Runtime.InteropServices.JavaScript.wasm.br +0 -0
  61. package/dist/wasm/_framework/System.Runtime.wasm +0 -0
  62. package/dist/wasm/_framework/System.Runtime.wasm.br +0 -0
  63. package/dist/wasm/_framework/System.Security.Cryptography.wasm +0 -0
  64. package/dist/wasm/_framework/System.Security.Cryptography.wasm.br +0 -0
  65. package/dist/wasm/_framework/System.Text.Encodings.Web.wasm +0 -0
  66. package/dist/wasm/_framework/System.Text.Encodings.Web.wasm.br +0 -0
  67. package/dist/wasm/_framework/System.Text.Json.wasm +0 -0
  68. package/dist/wasm/_framework/System.Text.Json.wasm.br +0 -0
  69. package/dist/wasm/_framework/System.Text.RegularExpressions.wasm +0 -0
  70. package/dist/wasm/_framework/System.Text.RegularExpressions.wasm.br +0 -0
  71. package/dist/wasm/_framework/System.Xml.Linq.wasm +0 -0
  72. package/dist/wasm/_framework/System.Xml.Linq.wasm.br +0 -0
  73. package/dist/wasm/_framework/System.Xml.XDocument.wasm +0 -0
  74. package/dist/wasm/_framework/System.Xml.XDocument.wasm.br +0 -0
  75. package/dist/wasm/_framework/System.wasm +0 -0
  76. package/dist/wasm/_framework/System.wasm.br +0 -0
  77. package/dist/wasm/_framework/dotnet.boot.js +34 -34
  78. package/dist/wasm/_framework/dotnet.boot.js.br +0 -0
  79. package/dist/wasm/_framework/dotnet.js +1 -1
  80. package/dist/wasm/_framework/dotnet.js.br +0 -0
  81. package/dist/wasm/_framework/dotnet.native.js +3 -3
  82. package/dist/wasm/_framework/dotnet.native.js.br +0 -0
  83. package/dist/wasm/_framework/dotnet.native.wasm +0 -0
  84. package/dist/wasm/_framework/dotnet.native.wasm.br +0 -0
  85. package/dist/wasm/_framework/dotnet.runtime.js +1 -1
  86. package/dist/wasm/_framework/dotnet.runtime.js.br +0 -0
  87. package/package.json +8 -1
package/dist/index.d.ts CHANGED
@@ -1,41 +1,5 @@
1
- import type { ConversionOptions, CompareOptions, RevisionListEntry, VersionInfo, ErrorResponse, CompareResult, PackageManifest, DeliverableVerificationResult, DeliveryReceiptVerificationResult, RedlineReversibilityProof, DocxodusWasmExports, FormatChangeDetails, DocxDiffSettings, DocxDiffRevision, DocxDiffBatchCandidate, DocxDiffBatchResult, DocxDiffProduct, DocxDiffProducts, SemanticChange, SemanticChangeFamily, SemanticChangeOperation, SemanticChangeSet, SemanticValue, DocxDiffReviewer, DocxDiffConsolidateSettings, DocxDiffConflict, DocxDiffConflictCompetitor, DocxDiffConsolidatedRevision, Annotation, AddAnnotationRequest, AddAnnotationResponse, RemoveAnnotationResponse, AnnotationOptions, DocumentStructure, DocumentElement, TableColumnInfo, AnnotationTarget, AddAnnotationWithTargetRequest, DocumentMetadata, SectionMetadata, OpenContractDocExport, PawlsPage, PawlsPageBoundary, PawlsToken, OpenContractsAnnotation, OpenContractsSinglePageAnnotation, BoundingBox, TokenId, TextSpan, OpenContractsRelationship, AnnotationLabel, ExternalAnnotationSet, ExternalAnnotationValidationResult, ExternalAnnotationValidationIssue, ExternalAnnotationProjectionSettings, MarkdownProjectionSettings, MarkdownAnchorTarget, MarkdownProjection, DocxSessionSettings } from "./types.js";
2
- import { DocxSession } from "./session.js";
3
- import { DocxHistoryArchive, DocxHistoryClient } from './history.js';
4
- import type { HistoryStorage } from './history.js';
5
- export * from './history.js';
6
- export * from './history-checkpoints.js';
7
- export * from './history-indexeddb.js';
8
- export * from './history-controls.js';
9
- /** Open history over host-owned storage after initialize(). No network layer is installed. */
10
- export declare function openDocxHistory(storage: HistoryStorage): DocxHistoryClient;
11
- /** Open a self-contained readonly .docxhistory file after initialize(); no storage adapter needed. */
12
- export declare function openDocxHistoryArchive(bytes: Uint8Array): Promise<DocxHistoryArchive>;
13
- export { DocxSession } from "./session.js";
14
- export type { AnchorInfo, AnchorRef, AnchorTargetRef, BlockMetadata, BookmarkInfo, BookmarkRangeSegment, CharSpan, CommentListEntry, ContentControlBindingInfo, ContentControlBindingPolicy, ContentControlFillOptions, ContentControlInfo, ContentControlPlacement, ContentControlType, DocumentAnnotation, DocumentRange, DocxSessionProjection, DocxSessionSettings, EditError, EditErrorCode, EditResult, FindOptions, EditorRenderOptions, FormatOp, HyperlinkInfo, HyperlinkKind, ImageBinaryFormat, ImageCapabilities, ImageDimensions, ImageFormatCapability, ImageHorizontalAlignment, ImageHorizontalReference, ImageInsertOptions, ImageMarkupKind, ImageOccurrence, ImagePlacement, ImageVerticalAlignment, ImageVerticalReference, ImageWrapMode, ImageWrapSide, FloatingImageLayout, LineSpacingRule, ListMembership, FormattingInspection, InlineSpan, ParagraphFormatting, RunFormattingInfo, StyleInfo, TableStyleFormatting, MarkdownPatch, NumberFormat, PageCitation, PageCitationFragment, PageCitationPage, PageCitationRequest, PageCitationUnavailableReason, PageMapRegistrationResult, PageMapStatus, PageNumberField, PageNumberingOp, PageSetupOp, ParagraphBorderEdge, ParagraphFormatOp, RevisionDiagnostic, RevisionFamily, RevisionResolutionStatus, SectionInfo, SessionRevisionType, TableOfAuthoritiesOptions, TableOfContentsOptions, TableOfFiguresOptions, TableBorderScope, TableBorderSpec, TableInsertOptions, TableMergeContent, TableShadingScope, PackageManifest, PackageManifestInspectionLimits, PackageManifestEntry, PackageManifestFacts, PackageRelationship, PackageContentTypeDeclaration, PackageRevisionCounts, PackageAnnotationCounts, DeliverableVerificationResult, DeliveryArtifactVerification, DeliveryArtifactVerificationStatus, DeliveryReceiptVerificationResult, DeliverableVerificationMode, DeliverableVerificationDecision, DeliverableFindingDisposition, DeliverableFindingCategory, DeliverableCheckStatus, DeliverablePackageChangeKind, DeliverableArtifactRole, DeliverableArtifactAvailability, DeliverableSemanticChangeFamily, DeliverablePackageIdentity, DeliverableCheckResult, DeliverableFinding, DeliverablePackageChange, DeliverableSemanticChange, DeliverableSemanticDelta, DeliverableArtifactMetadata, VerificationDigest, VerificationFinding, VerificationFindingSeverity, ChangeLocation, RedlineReversibilityProof, RedlineProofPathResult, RedlineProofPackageIdentity, RedlineProofFinding, RedlineProofDirection, RedlineRevisionClassification, RedlineRevisionDisposition, RedlineRevisionIdentity, RedlineRevisionFamily, RedlineRevisionResolutionStatus, RedlineRevisionDiagnostic, RedlineModeledSemanticComparison, RedlinePackageDivergence, RedlinePackageDivergenceKind, } from "./types.js";
15
- export type { FillOptions, BulkEditResult } from "./types.js";
16
- export { PlaceholderKinds, ContextBoundary } from "./types.js";
17
- export { DiffFormat } from "./types.js";
18
- export type { EditSummary, DiffEntry } from "./types.js";
19
- /**
20
- * Open a {@link DocxSession} for surgical mutation of a DOCX. Requires
21
- * {@link initialize} to have been called and awaited.
22
- *
23
- * The returned session keeps the document in WASM memory; call
24
- * {@link DocxSession.close} when done.
25
- */
26
- export declare function openDocxSession(bytes: Uint8Array, settings?: DocxSessionSettings): DocxSession;
27
- /**
28
- * Mint a complete, blank single-paragraph DOCX (Normal style, US-Letter section) as bytes —
29
- * a "New document" seed for editors that draft from scratch. Requires {@link initialize}.
30
- */
31
- export declare function createBlankDocx(): Uint8Array;
32
- import { CommentRenderMode, PaginationMode, AnnotationLabelMode, RevisionType, DocxDiffRevisionGranularity, DocxDiffFormatComparison, ConflictResolution, ProjectionScopes, AnchorRenderMode, TableRenderMode, TrackedChangeMode, EmptyParagraphMode, AnchorIdRendering, ProjectionDepth, DocumentElementType, ComparisonLogLevel, ComparisonLogCodes, isInsertion, isDeletion, isMove, isFormatChange, findElementById, findElementsByType, getParagraphs, getTables, getTableColumns, targetElement, targetParagraph, targetParagraphRange, targetRun, targetTable, targetTableRow, targetTableCell, targetTableColumn, targetSearch, targetSearchInElement } from "./types.js";
33
- export type { PageDimensions, MeasuredBlock, PageInfo, PaginationResult, PaginationOptions, PageMap, PageMapPage, PageMapFragment, PageMapRect, PageMapMode, PageMapAvailability, PageMapStory, PageCitationNavigation, } from "./pagination.js";
34
- export { PaginationEngine, clearPageCitationHighlight, createUnavailablePageMap, navigateToPageCitation, paginateHtml, } from "./pagination.js";
35
- export type { CommentProfile, CompleteRenderReport, DocxodusExportErrorCode, ExportPhase, ExportResourceLimits, FailedRenderReport, FontConfigurationIdentity, FontResolution, FontResolver, PaginatedHtmlOptions, PaginatedHtmlResult, PaginatedRenderMetadata, ReadinessOutcome, RenderReport, RenderReportBase, RenderWarning, ResourceOutcome, ReviewProfile, UnsupportedContentOutcome, UnsupportedContentPolicy, } from "./export-browser.js";
36
- export { DEFAULT_MARGIN, DEFAULT_PAGE_HEIGHT, DEFAULT_PAGE_WIDTH, fitScale, parseSectionDimensions, ptToPx, pxToPt, } from "./page-geometry.js";
37
- export { DocumentViewport } from "./viewport.js";
38
- export type { ColumnWidth, DocumentViewportOptions } from "./viewport.js";
1
+ /** Full browser API. Use docxodus/core for the engine without editor dependencies. */
2
+ export * from "./core.js";
39
3
  export { DocxEditor } from "./editor.js";
40
4
  export type { DocxEditorOptions, DocxEditorExports, EditorAlignment, EditorMatch, EditorPageSetup, FormatKey, } from "./editor.js";
41
5
  export { CommentGutter } from "./editor-comments.js";
@@ -43,888 +7,4 @@ export type { CommentGutterHost, CommentGutterOptions } from "./editor-comments.
43
7
  export type { BandWhich } from "./editor-headerfooter.js";
44
8
  export { mountRibbon } from "./ribbon.js";
45
9
  export type { RibbonEditor, RibbonOptions, RibbonHistoryOptions, RibbonHistoryBinding, RibbonChromeMode, RibbonState, RibbonLoader, RibbonLoaderOptions, RibbonLoaderStage, RibbonLoaderFeature, } from "./ribbon.js";
46
- export type { ConversionOptions, CompareOptions, RevisionListEntry, VersionInfo, ErrorResponse, CompareResult, FormatChangeDetails, Annotation, AddAnnotationRequest, AddAnnotationResponse, RemoveAnnotationResponse, AnnotationOptions, DocumentStructure, DocumentElement, TableColumnInfo, AnnotationTarget, AddAnnotationWithTargetRequest, DocumentMetadata, SectionMetadata, OpenContractDocExport, PawlsPage, PawlsPageBoundary, PawlsToken, OpenContractsAnnotation, OpenContractsSinglePageAnnotation, BoundingBox, TokenId, TextSpan, OpenContractsRelationship, AnnotationLabel, ExternalAnnotationSet, ExternalAnnotationValidationResult, ExternalAnnotationValidationIssue, ExternalAnnotationProjectionSettings, MarkdownProjectionSettings, MarkdownAnchorTarget, MarkdownProjection, DocxDiffSettings, DocxDiffRevision, DocxDiffBatchCandidate, DocxDiffBatchResult, DocxDiffProduct, DocxDiffProducts, SemanticChange, SemanticChangeFamily, SemanticChangeOperation, SemanticChangeSet, SemanticValue, DocxDiffReviewer, DocxDiffConsolidateSettings, DocxDiffConflict, DocxDiffConflictCompetitor, DocxDiffConsolidatedRevision, };
47
- export { CommentRenderMode, PaginationMode, AnnotationLabelMode, RevisionType, DocxDiffRevisionGranularity, DocxDiffFormatComparison, ConflictResolution, ProjectionScopes, AnchorRenderMode, TableRenderMode, TrackedChangeMode, EmptyParagraphMode, AnchorIdRendering, ProjectionDepth, DocumentElementType, ComparisonLogLevel, ComparisonLogCodes, isInsertion, isDeletion, isMove, isFormatChange, findElementById, findElementsByType, getParagraphs, getTables, getTableColumns, targetElement, targetParagraph, targetParagraphRange, targetRun, targetTable, targetTableRow, targetTableCell, targetTableColumn, targetSearch, targetSearchInElement, };
48
- /**
49
- * Current base path for WASM files.
50
- * Empty string means auto-detect from module URL.
51
- */
52
- export declare let wasmBasePath: string;
53
- /**
54
- * Set custom base path for WASM files.
55
- * Pass empty string or don't call this to auto-detect from module location.
56
- *
57
- * @param path - Custom path to WASM files, or empty string for auto-detection
58
- */
59
- export declare function setWasmBasePath(path: string): void;
60
- /**
61
- * Initialize the Docxodus WASM runtime.
62
- * Must be called before using any conversion/comparison functions.
63
- * Safe to call multiple times - will only initialize once.
64
- *
65
- * By default, WASM files are auto-detected from the module's location
66
- * (works with CDN, npm, or local hosting).
67
- * Pass a basePath to load from a custom location instead.
68
- *
69
- * @param basePath - Optional custom path to WASM files. Leave empty for auto-detection.
70
- */
71
- export declare function initialize(basePath?: string): Promise<void>;
72
- /**
73
- * Generate a deterministic, non-mutating verification manifest from DOCX bytes.
74
- * Invalid, malformed, and encrypted packages are represented by structured findings.
75
- */
76
- export declare function generatePackageManifest(document: File | Uint8Array): Promise<PackageManifest>;
77
- /**
78
- * Run the default bounded deliverable-verification policy on exact DOCX bytes.
79
- * Invalid, malformed, encrypted, and safety-limited packages are returned as
80
- * structured report findings rather than editable-session errors. When supplied,
81
- * the exact baseline bytes are used to classify pre-existing, new, and resolved findings.
82
- */
83
- export declare function verifyDeliverable(document: File | Uint8Array, baseline?: File | Uint8Array): Promise<DeliverableVerificationResult>;
84
- /**
85
- * Verify a portable JSON delivery change receipt against supplied artifact bytes.
86
- *
87
- * The receipt travels as its JSON envelope string; `artifacts` maps each artifact id
88
- * the receipt records to the exact bytes to independently re-hash against it. Omitted
89
- * artifacts report `"missing"`. Malformed input yields a structured invalid verdict
90
- * whose findings carry the reason — never a thrown error.
91
- */
92
- export declare function verifyDeliveryReceipt(receiptJson: string, artifacts?: Record<string, Uint8Array>): Promise<DeliveryReceiptVerificationResult>;
93
- /**
94
- * Prove that a redline's generated revisions accept to the intended final and reject to the
95
- * selected baseline without consuming pre-existing review state.
96
- *
97
- * Three packages are inspected and two rebuilt, so on a UI thread prefer the worker proxy's
98
- * `proveRedlineReversibility`. Malformed, encrypted, and safety-limited packages are reported as
99
- * structured proof findings rather than thrown errors. The rebuilt packages are not returned:
100
- * the proof carries their digests and the divergences between them and each expected document.
101
- *
102
- * @param baseline - The document the redline was generated against
103
- * @param intendedFinal - The document accepting the generated revisions must reproduce
104
- * @param redline - The generated redline under proof
105
- */
106
- export declare function proveRedlineReversibility(baseline: File | Uint8Array, intendedFinal: File | Uint8Array, redline: File | Uint8Array): Promise<RedlineReversibilityProof>;
107
- /**
108
- * Convert a DOCX document to HTML.
109
- *
110
- * @param document - DOCX file as File object or Uint8Array
111
- * @param options - Conversion options
112
- * @returns HTML string
113
- * @throws Error if conversion fails
114
- *
115
- * @example
116
- * ```typescript
117
- * // Basic conversion
118
- * const html = await convertDocxToHtml(docxFile);
119
- *
120
- * // With pagination (PDF.js-style page view)
121
- * const html = await convertDocxToHtml(docxFile, {
122
- * paginationMode: PaginationMode.Paginated,
123
- * paginationScale: 0.8
124
- * });
125
- *
126
- * // With annotations rendered
127
- * const html = await convertDocxToHtml(docxFile, {
128
- * renderAnnotations: true,
129
- * annotationLabelMode: AnnotationLabelMode.Above
130
- * });
131
- *
132
- * // With footnotes and endnotes
133
- * const html = await convertDocxToHtml(docxFile, {
134
- * renderFootnotesAndEndnotes: true
135
- * });
136
- *
137
- * // With headers and footers
138
- * const html = await convertDocxToHtml(docxFile, {
139
- * renderHeadersAndFooters: true
140
- * });
141
- *
142
- * // With tracked changes (redlines visible)
143
- * const html = await convertDocxToHtml(docxFile, {
144
- * renderTrackedChanges: true,
145
- * showDeletedContent: true,
146
- * renderMoveOperations: true
147
- * });
148
- * ```
149
- */
150
- /**
151
- * Render a single document block to faithful HTML, addressed by its anchor.
152
- *
153
- * The anchor is the `data-anchor` value stamped on a block during a full
154
- * conversion (a bare 32-hex Unid), or a full `kind:scope:unid` anchor — either
155
- * form works. Powers the editor's incremental per-block re-render: apply an edit
156
- * to a DocxSession, then re-render only the changed block instead of the whole
157
- * document. Returns the block's HTML element (no `<html>`/`<head>` wrapper).
158
- */
159
- export declare function renderBlockHtml(document: File | Uint8Array, anchorId: string, options?: {
160
- cssPrefix?: string;
161
- fabricateClasses?: boolean;
162
- }): Promise<string>;
163
- export declare function convertDocxToHtml(document: File | Uint8Array, options?: ConversionOptions): Promise<string>;
164
- /**
165
- * Compare two DOCX documents and return the redlined result as a DOCX.
166
- *
167
- * @param original - Original DOCX document
168
- * @param modified - Modified DOCX document
169
- * @param options - Comparison options
170
- * @returns Redlined DOCX as Uint8Array
171
- * @throws Error if comparison fails
172
- */
173
- export declare function compareDocuments(original: File | Uint8Array, modified: File | Uint8Array, options?: CompareOptions): Promise<Uint8Array>;
174
- /**
175
- * Compare two DOCX documents and return the result as HTML.
176
- *
177
- * @param original - Original DOCX document
178
- * @param modified - Modified DOCX document
179
- * @param options - Comparison options
180
- * @returns HTML string with redlined content
181
- * @throws Error if comparison fails
182
- */
183
- export declare function compareDocumentsToHtml(original: File | Uint8Array, modified: File | Uint8Array, options?: CompareOptions): Promise<string>;
184
- /**
185
- * Get revisions from a compared document.
186
- *
187
- * @param document - A document that has been through comparison (has tracked changes)
188
- * @param options - Optional move detection configuration
189
- * @returns Array of revisions
190
- * @throws Error if operation fails
191
- *
192
- * @example
193
- * ```typescript
194
- * // Default settings (move detection enabled, 80% threshold)
195
- * const revisions = await getRevisions(comparedDoc);
196
- *
197
- * // Custom move detection settings
198
- * const revisions = await getRevisions(comparedDoc, {
199
- * detectMoves: true,
200
- * moveSimilarityThreshold: 0.9, // Require 90% word overlap
201
- * moveMinimumWordCount: 5, // Only consider phrases of 5+ words
202
- * caseInsensitive: true // Ignore case when matching
203
- * });
204
- *
205
- * // Disable move detection entirely
206
- * const revisions = await getRevisions(comparedDoc, { detectMoves: false });
207
- * ```
208
- */
209
- export declare function getRevisions(document: File | Uint8Array): Promise<RevisionListEntry[]>;
210
- /**
211
- * Compare two DOCX documents with the IR diff engine and return the redlined
212
- * result as a DOCX (native w:ins/w:del/w:moveFrom/w:moveTo/w:rPrChange markup).
213
- *
214
- * @param left - The earlier/original document.
215
- * @param right - The later/revised document.
216
- * @param settings - Optional {@link DocxDiffSettings}; omit for engine defaults.
217
- * @returns Redlined DOCX as Uint8Array.
218
- * @throws Error if comparison fails.
219
- */
220
- export declare function docxDiffCompare(left: File | Uint8Array, right: File | Uint8Array, settings?: DocxDiffSettings): Promise<Uint8Array>;
221
- /**
222
- * Compare two DOCX documents with the IR diff engine and return the
223
- * anchor-addressed revision list.
224
- *
225
- * @param left - The earlier/original document.
226
- * @param right - The later/revised document.
227
- * @param settings - Optional {@link DocxDiffSettings}; omit for engine defaults.
228
- * @returns Array of {@link DocxDiffRevision} (each carrying its left/right block anchors).
229
- * @throws Error if the operation fails.
230
- */
231
- export declare function docxDiffGetRevisions(left: File | Uint8Array, right: File | Uint8Array, settings?: DocxDiffSettings): Promise<DocxDiffRevision[]>;
232
- /**
233
- * Compare two DOCX documents ONCE and return every requested data product from
234
- * that single memoized pass (issue #594). Where a review pipeline calling
235
- * {@link docxDiffCompare}, {@link docxDiffGetRevisions}, and
236
- * {@link docxDiffGetEditScript} separately pays for the alignment per call, this
237
- * runs it once — each product identical to its standalone counterpart (the edit
238
- * script is handed over parsed rather than as the serialized string).
239
- *
240
- * @param left - The earlier/original document.
241
- * @param right - The later/revised document.
242
- * @param settings - Optional {@link DocxDiffSettings}; omit for engine defaults.
243
- * @param products - Products to compute; omit for all four.
244
- * @throws Error if the operation fails.
245
- */
246
- export declare function docxDiffCompareProducts(left: File | Uint8Array, right: File | Uint8Array, settings?: DocxDiffSettings, products?: DocxDiffProduct[]): Promise<DocxDiffProducts>;
247
- /**
248
- * Compare ONE baseline against MANY candidates, reading the baseline once (issue #617).
249
- *
250
- * The read is the single largest stage of a comparison, and a fan-out — one negotiated
251
- * draft against every counterparty's markup — otherwise re-reads the baseline for each
252
- * one. This reads it once and compares every candidate against that snapshot; each
253
- * result is identical to what {@link docxDiffCompareProducts} returns for the same pair.
254
- *
255
- * A candidate that fails carries an `error` instead of products; the rest of the batch
256
- * still comes back, because one malformed markup should not cost the other ninety-nine.
257
- *
258
- * @param baseline - The shared left-hand document.
259
- * @param candidates - The documents to compare against it, in order.
260
- * @param settings - Optional {@link DocxDiffSettings}; omit for engine defaults.
261
- * @param products - Products to compute; omit for all four.
262
- * @throws Error if the batch itself fails (a bad baseline, malformed settings).
263
- */
264
- export declare function docxDiffCompareBatch(baseline: File | Uint8Array, candidates: readonly DocxDiffBatchCandidate[], settings?: DocxDiffSettings, products?: DocxDiffProduct[]): Promise<DocxDiffBatchResult[]>;
265
- /**
266
- * Compare two DOCX documents with the IR diff engine and return the edit script
267
- * as a JSON string — the diff-as-data differentiator. The script is the
268
- * anchor-addressed list of block operations the markup and revision renderers
269
- * both consume: stable and machine-readable for storage, transport, and audit.
270
- *
271
- * @param left - The earlier/original document.
272
- * @param right - The later/revised document.
273
- * @param settings - Optional {@link DocxDiffSettings}; omit for engine defaults.
274
- * @returns The edit script serialized as indented JSON.
275
- * @throws Error if the operation fails.
276
- */
277
- export declare function docxDiffGetEditScript(left: File | Uint8Array, right: File | Uint8Array, settings?: DocxDiffSettings): Promise<string>;
278
- /**
279
- * Compare two DOCX documents and return the stable, versioned semantic-change
280
- * schema. This is the audit/verification surface; it classifies document meaning
281
- * beyond the renderer's internal edit script and preserves unknown package changes.
282
- */
283
- export declare function docxDiffGetSemanticChanges(left: File | Uint8Array, right: File | Uint8Array, settings?: DocxDiffSettings): Promise<SemanticChangeSet>;
284
- /**
285
- * Accept every tracked revision in a redlined DOCX and return the resulting bytes
286
- * (materializes the "right"/revised side). The byte-in, byte-out counterpart of
287
- * {@link docxDiffCompare}: `docxDiffAcceptRevisions(await docxDiffCompare(left, right))`
288
- * equals `right` at the per-block text level — so callers can verify the round-trip
289
- * contract of a redline, not just inspect its shape.
290
- *
291
- * @param redline - A DOCX carrying tracked-changes markup (e.g. {@link docxDiffCompare} output).
292
- * @returns The DOCX bytes with all revisions accepted.
293
- * @throws Error if the operation fails.
294
- */
295
- export declare function docxDiffAcceptRevisions(redline: File | Uint8Array): Promise<Uint8Array>;
296
- /**
297
- * Reject every tracked revision in a redlined DOCX and return the resulting bytes
298
- * (materializes the "left"/original side): `docxDiffRejectRevisions(await
299
- * docxDiffCompare(left, right))` equals `left` at the per-block text level.
300
- *
301
- * @param redline - A DOCX carrying tracked-changes markup (e.g. {@link docxDiffCompare} output).
302
- * @returns The DOCX bytes with all revisions rejected.
303
- * @throws Error if the operation fails.
304
- */
305
- export declare function docxDiffRejectRevisions(redline: File | Uint8Array): Promise<Uint8Array>;
306
- /**
307
- * Consolidate several reviewers' edits against a shared base DOCX and return the
308
- * merged redlined result as a DOCX (native multi-author tracked-changes markup).
309
- *
310
- * @param base - The shared base document all reviewers edited from.
311
- * @param reviewers - The reviewers' edited copies + author names.
312
- * @param settings - Optional {@link DocxDiffConsolidateSettings}; omit for engine defaults.
313
- * @returns Consolidated redlined DOCX as Uint8Array.
314
- * @throws Error if consolidation fails.
315
- */
316
- export declare function docxDiffConsolidate(base: File | Uint8Array, reviewers: DocxDiffReviewer[], settings?: DocxDiffConsolidateSettings): Promise<Uint8Array>;
317
- /**
318
- * Consolidate several reviewers' edits against a shared base DOCX and return the
319
- * per-token conflict report — every base span two or more reviewers edited
320
- * incompatibly, with each reviewer's competing variant.
321
- *
322
- * @param base - The shared base document all reviewers edited from.
323
- * @param reviewers - The reviewers' edited copies + author names.
324
- * @param settings - Optional {@link DocxDiffConsolidateSettings}; omit for engine defaults.
325
- * @returns Array of {@link DocxDiffConflict}.
326
- * @throws Error if the operation fails.
327
- */
328
- export declare function docxDiffGetConflicts(base: File | Uint8Array, reviewers: DocxDiffReviewer[], settings?: DocxDiffConsolidateSettings): Promise<DocxDiffConflict[]>;
329
- /**
330
- * Consolidate several reviewers' edits against a shared base DOCX and return the
331
- * merged revision list — each revision carrying its author, block anchors, and
332
- * (when contested) the {@link DocxDiffConsolidatedRevision.conflictId} linking it
333
- * to a {@link DocxDiffConflict}.
334
- *
335
- * @param base - The shared base document all reviewers edited from.
336
- * @param reviewers - The reviewers' edited copies + author names.
337
- * @param settings - Optional {@link DocxDiffConsolidateSettings}; omit for engine defaults.
338
- * @returns Array of {@link DocxDiffConsolidatedRevision}.
339
- * @throws Error if the operation fails.
340
- */
341
- export declare function docxDiffGetConsolidatedRevisions(base: File | Uint8Array, reviewers: DocxDiffReviewer[], settings?: DocxDiffConsolidateSettings): Promise<DocxDiffConsolidatedRevision[]>;
342
- /**
343
- * Consolidate several reviewers' edits against a shared base DOCX and return the
344
- * merged edit script as a JSON string — the diff-as-data view of the
345
- * consolidation (the anchor-addressed list of composite block operations).
346
- *
347
- * @param base - The shared base document all reviewers edited from.
348
- * @param reviewers - The reviewers' edited copies + author names.
349
- * @param settings - Optional {@link DocxDiffConsolidateSettings}; omit for engine defaults.
350
- * @returns The consolidated edit script serialized as indented JSON.
351
- * @throws Error if the operation fails.
352
- */
353
- export declare function docxDiffGetConsolidatedEditScript(base: File | Uint8Array, reviewers: DocxDiffReviewer[], settings?: DocxDiffConsolidateSettings): Promise<string>;
354
- /**
355
- * Get version information about the library.
356
- */
357
- export declare function getVersion(): VersionInfo;
358
- /**
359
- * Check if the WASM runtime is initialized.
360
- */
361
- export declare function isInitialized(): boolean;
362
- /**
363
- * The raw WASM bridge exports (DocumentConverter, DocxSessionBridge, ...).
364
- *
365
- * For consumers that drive a bridge class directly — most notably
366
- * `DocxEditor.open(container, bytes, exports)`, which needs the exports object
367
- * rather than the wrapped functions in this module. Requires `initialize()` to
368
- * have completed; throws otherwise.
369
- */
370
- export declare function getWasmExports(): DocxodusWasmExports;
371
- /**
372
- * Get all annotations from a document.
373
- *
374
- * @param document - DOCX file as File object or Uint8Array
375
- * @returns Array of annotations
376
- * @throws Error if operation fails
377
- *
378
- * @example
379
- * ```typescript
380
- * const annotations = await getAnnotations(docxFile);
381
- * for (const annot of annotations) {
382
- * console.log(`${annot.label}: "${annot.annotatedText}"`);
383
- * }
384
- * ```
385
- */
386
- export declare function getAnnotations(document: File | Uint8Array): Promise<Annotation[]>;
387
- /**
388
- * Add an annotation to a document.
389
- *
390
- * @param document - DOCX file as File object or Uint8Array
391
- * @param request - Annotation details including search text or paragraph indices
392
- * @returns Response with modified document bytes and annotation info
393
- * @throws Error if operation fails
394
- *
395
- * @example
396
- * ```typescript
397
- * // Annotate by searching for text
398
- * const result = await addAnnotation(docxFile, {
399
- * id: "annot-1",
400
- * labelId: "CLAUSE_A",
401
- * label: "Important Clause",
402
- * color: "#FFEB3B",
403
- * searchText: "shall not be liable",
404
- * occurrence: 1
405
- * });
406
- *
407
- * // Annotate by paragraph range
408
- * const result = await addAnnotation(docxFile, {
409
- * id: "annot-2",
410
- * labelId: "SECTION_1",
411
- * label: "Introduction",
412
- * color: "#4CAF50",
413
- * startParagraphIndex: 0,
414
- * endParagraphIndex: 2
415
- * });
416
- *
417
- * // Get modified document
418
- * const modifiedDocBytes = base64ToBytes(result.documentBytes);
419
- * ```
420
- */
421
- export declare function addAnnotation(document: File | Uint8Array, request: AddAnnotationRequest): Promise<AddAnnotationResponse>;
422
- /**
423
- * Remove an annotation from a document.
424
- *
425
- * @param document - DOCX file as File object or Uint8Array
426
- * @param annotationId - The ID of the annotation to remove
427
- * @returns Response with modified document bytes
428
- * @throws Error if operation fails
429
- *
430
- * @example
431
- * ```typescript
432
- * const result = await removeAnnotation(docxFile, "annot-1");
433
- * const modifiedDocBytes = base64ToBytes(result.documentBytes);
434
- * ```
435
- */
436
- export declare function removeAnnotation(document: File | Uint8Array, annotationId: string): Promise<RemoveAnnotationResponse>;
437
- /**
438
- * Check if a document has any annotations.
439
- *
440
- * @param document - DOCX file as File object or Uint8Array
441
- * @returns true if the document has annotations
442
- * @throws Error if operation fails
443
- *
444
- * @example
445
- * ```typescript
446
- * if (await hasAnnotations(docxFile)) {
447
- * const annotations = await getAnnotations(docxFile);
448
- * console.log(`Document has ${annotations.length} annotations`);
449
- * }
450
- * ```
451
- */
452
- export declare function hasAnnotations(document: File | Uint8Array): Promise<boolean>;
453
- /**
454
- * Get the document structure for element-based annotation targeting.
455
- *
456
- * @param document - DOCX file as File object or Uint8Array
457
- * @returns Document structure with element tree
458
- * @throws Error if operation fails
459
- *
460
- * @example
461
- * ```typescript
462
- * const structure = await getDocumentStructure(docxFile);
463
- *
464
- * // Navigate the structure tree
465
- * console.log(`Document has ${structure.root.children.length} top-level elements`);
466
- *
467
- * // Find all paragraphs
468
- * const paragraphs = getParagraphs(structure);
469
- * console.log(`Found ${paragraphs.length} paragraphs`);
470
- *
471
- * // Find all tables
472
- * const tables = getTables(structure);
473
- * for (const table of tables) {
474
- * const columns = getTableColumns(structure, table.id);
475
- * console.log(`Table ${table.id} has ${columns.length} columns`);
476
- * }
477
- *
478
- * // Look up element by ID
479
- * const element = findElementById(structure, "doc/p-0");
480
- * if (element) {
481
- * console.log(`First paragraph: "${element.textPreview}"`);
482
- * }
483
- * ```
484
- */
485
- export declare function getDocumentStructure(document: File | Uint8Array): Promise<DocumentStructure>;
486
- /**
487
- * Get document metadata for lazy loading pagination.
488
- * This is a fast operation that extracts structure information without full HTML rendering.
489
- *
490
- * @param document - DOCX file as File object or Uint8Array
491
- * @returns Document metadata including sections, dimensions, and content counts
492
- * @throws Error if operation fails
493
- *
494
- * @example
495
- * ```typescript
496
- * const metadata = await getDocumentMetadata(docxFile);
497
- *
498
- * // Check document overview
499
- * console.log(`Document has ${metadata.totalParagraphs} paragraphs`);
500
- * console.log(`Document has ${metadata.sections.length} sections`);
501
- * console.log(`Estimated ${metadata.estimatedPageCount} pages`);
502
- *
503
- * // Check section properties
504
- * for (const section of metadata.sections) {
505
- * console.log(`Section ${section.sectionIndex}: ${section.pageWidthPt}x${section.pageHeightPt}pt`);
506
- * console.log(` Paragraphs: ${section.paragraphCount}, Tables: ${section.tableCount}`);
507
- * console.log(` Has header: ${section.hasHeader}, Has footer: ${section.hasFooter}`);
508
- * }
509
- *
510
- * // Check document features
511
- * if (metadata.hasTrackedChanges) {
512
- * console.log("Document has tracked changes");
513
- * }
514
- * if (metadata.hasFootnotes) {
515
- * console.log("Document has footnotes");
516
- * }
517
- * ```
518
- */
519
- export declare function getDocumentMetadata(document: File | Uint8Array): Promise<DocumentMetadata>;
520
- /**
521
- * Export document to OpenContracts format.
522
- *
523
- * This provides complete document text, structure, and layout information
524
- * compatible with the OpenContracts ecosystem for document analysis.
525
- *
526
- * @param document - DOCX file as File object or Uint8Array
527
- * @returns OpenContractDocExport with complete document data
528
- * @throws Error if export fails
529
- *
530
- * @example
531
- * ```typescript
532
- * const result = await exportToOpenContract(docxFile);
533
- *
534
- * // Access complete document text
535
- * console.log(`Content length: ${result.content.length} characters`);
536
- *
537
- * // Get document structure
538
- * console.log(`Pages: ${result.pageCount}`);
539
- * console.log(`Structural annotations: ${result.labelledText.filter(a => a.structural).length}`);
540
- *
541
- * // Access PAWLS layout data
542
- * for (const page of result.pawlsFileContent) {
543
- * console.log(`Page ${page.page.index}: ${page.tokens.length} tokens`);
544
- * }
545
- * ```
546
- */
547
- export declare function exportToOpenContract(document: File | Uint8Array): Promise<OpenContractDocExport>;
548
- /**
549
- * Convert a DOCX file to an anchor-addressed Markdown projection.
550
- *
551
- * The projection is a deterministic, anchor-keyed Markdown rendering of the document,
552
- * suitable for LLM editing pipelines, structured search indexers, and diff/review UIs.
553
- * Every paragraph, heading, list item, table, table cell, footnote, endnote, and
554
- * comment is addressable by an `{#kind:scope:unid}` anchor that survives reformatting.
555
- *
556
- * See `docs/architecture/markdown_projection.md` for the projection spec.
557
- *
558
- * @param document - DOCX file as `File` or `Uint8Array`
559
- * @param settings - Optional projection settings (defaults: all scopes, anchor blocks, accept tracked changes)
560
- * @throws Error if conversion fails
561
- *
562
- * @example
563
- * ```typescript
564
- * const result = await convertWmlToMarkdown(docxFile);
565
- * console.log(result.markdown);
566
- * for (const [id, target] of Object.entries(result.anchorIndex)) {
567
- * console.log(id, target.partUri);
568
- * }
569
- * ```
570
- */
571
- export declare function convertWmlToMarkdown(document: File | Uint8Array, settings?: MarkdownProjectionSettings): Promise<MarkdownProjection>;
572
- /**
573
- * Add an annotation using flexible targeting (element ID, indices, or text search).
574
- *
575
- * @param document - DOCX file as File object or Uint8Array
576
- * @param request - Annotation details with target specification
577
- * @returns Response with modified document bytes and annotation info
578
- * @throws Error if operation fails
579
- *
580
- * @example
581
- * ```typescript
582
- * // First get the document structure to find target elements
583
- * const structure = await getDocumentStructure(docxFile);
584
- *
585
- * // Annotate a specific paragraph by element ID
586
- * const result1 = await addAnnotationWithTarget(docxFile, {
587
- * id: "annot-1",
588
- * labelId: "INTRO",
589
- * label: "Introduction",
590
- * color: "#4CAF50",
591
- * target: targetElement("doc/p-0")
592
- * });
593
- *
594
- * // Annotate a table cell
595
- * const result2 = await addAnnotationWithTarget(docxFile, {
596
- * id: "annot-2",
597
- * labelId: "CELL_HIGHLIGHT",
598
- * label: "Important Cell",
599
- * color: "#FFEB3B",
600
- * target: targetTableCell(0, 1, 2) // Table 0, Row 1, Cell 2
601
- * });
602
- *
603
- * // Annotate a table column
604
- * const result3 = await addAnnotationWithTarget(docxFile, {
605
- * id: "annot-3",
606
- * labelId: "COLUMN_DATA",
607
- * label: "Values Column",
608
- * color: "#2196F3",
609
- * target: targetTableColumn(0, 1) // Table 0, Column 1
610
- * });
611
- *
612
- * // Search for text within a specific element
613
- * const result4 = await addAnnotationWithTarget(docxFile, {
614
- * id: "annot-4",
615
- * labelId: "KEYWORD",
616
- * label: "Keyword",
617
- * color: "#FF5722",
618
- * target: targetSearchInElement("doc/p-2", "important", 1)
619
- * });
620
- * ```
621
- */
622
- export declare function addAnnotationWithTarget(document: File | Uint8Array, request: AddAnnotationWithTargetRequest): Promise<AddAnnotationResponse>;
623
- /**
624
- * Compute the SHA256 hash of a document for integrity validation.
625
- *
626
- * @param document - DOCX file as File object or Uint8Array
627
- * @returns SHA256 hash as lowercase hex string
628
- * @throws Error if operation fails
629
- *
630
- * @example
631
- * ```typescript
632
- * const hash = await computeDocumentHash(docxFile);
633
- * console.log(`Document hash: ${hash}`);
634
- *
635
- * // Later, verify the document hasn't changed
636
- * const currentHash = await computeDocumentHash(docxFile);
637
- * if (currentHash !== storedHash) {
638
- * console.log("Document has been modified");
639
- * }
640
- * ```
641
- */
642
- export declare function computeDocumentHash(document: File | Uint8Array): Promise<string>;
643
- /**
644
- * Create an ExternalAnnotationSet from a document.
645
- * This extracts the document structure and computes the hash for integrity validation.
646
- *
647
- * @param document - DOCX file as File object or Uint8Array
648
- * @param documentId - Unique identifier for the document (filename, UUID, etc.)
649
- * @returns ExternalAnnotationSet ready for adding annotations
650
- * @throws Error if operation fails
651
- *
652
- * @example
653
- * ```typescript
654
- * // Create an annotation set
655
- * const set = await createExternalAnnotationSet(docxFile, "contract-v1.0");
656
- *
657
- * // Access document text for searching
658
- * console.log(`Document length: ${set.content.length} chars`);
659
- *
660
- * // Add label definitions
661
- * set.textLabels["IMPORTANT"] = {
662
- * id: "IMPORTANT",
663
- * text: "Important",
664
- * color: "#FF0000",
665
- * description: "Important text",
666
- * icon: "",
667
- * labelType: "text"
668
- * };
669
- *
670
- * // Create annotations using the content
671
- * const annotation = createAnnotationFromSearch(
672
- * "ann-001", "IMPORTANT", set.content, "shall not be liable"
673
- * );
674
- * if (annotation) {
675
- * set.labelledText.push(annotation);
676
- * }
677
- *
678
- * // Serialize for storage
679
- * const json = JSON.stringify(set);
680
- * ```
681
- */
682
- export declare function createExternalAnnotationSet(document: File | Uint8Array, documentId: string): Promise<ExternalAnnotationSet>;
683
- /**
684
- * Validate an external annotation set against a document.
685
- * Checks hash match and verifies each annotation's text still matches.
686
- *
687
- * @param document - DOCX file as File object or Uint8Array
688
- * @param annotationSet - The annotation set to validate
689
- * @returns Validation result with any issues found
690
- * @throws Error if operation fails
691
- *
692
- * @example
693
- * ```typescript
694
- * const result = await validateExternalAnnotations(docxFile, annotationSet);
695
- *
696
- * if (!result.isValid) {
697
- * if (result.hashMismatch) {
698
- * console.log("Document has been modified since annotations were created");
699
- * }
700
- * for (const issue of result.issues) {
701
- * console.log(`${issue.issueType}: ${issue.description}`);
702
- * }
703
- * }
704
- * ```
705
- */
706
- export declare function validateExternalAnnotations(document: File | Uint8Array, annotationSet: ExternalAnnotationSet): Promise<ExternalAnnotationValidationResult>;
707
- /**
708
- * Convert a DOCX document to HTML with external annotations projected.
709
- *
710
- * @param document - DOCX file as File object or Uint8Array
711
- * @param annotationSet - The external annotation set to project
712
- * @param conversionOptions - HTML conversion options
713
- * @param projectionOptions - Annotation projection options
714
- * @returns HTML string with annotations projected
715
- * @throws Error if operation fails
716
- *
717
- * @example
718
- * ```typescript
719
- * // Basic usage
720
- * const html = await convertDocxToHtmlWithExternalAnnotations(
721
- * docxFile,
722
- * annotationSet
723
- * );
724
- *
725
- * // With custom options
726
- * const html = await convertDocxToHtmlWithExternalAnnotations(
727
- * docxFile,
728
- * annotationSet,
729
- * { pageTitle: "Annotated Document" },
730
- * { labelMode: AnnotationLabelMode.Inline, cssClassPrefix: "my-annot-" }
731
- * );
732
- * ```
733
- */
734
- export declare function convertDocxToHtmlWithExternalAnnotations(document: File | Uint8Array, annotationSet: ExternalAnnotationSet, conversionOptions?: ConversionOptions, projectionOptions?: ExternalAnnotationProjectionSettings): Promise<string>;
735
- /**
736
- * Search for text in a document and return character offsets.
737
- * Useful for finding text locations to create annotations.
738
- *
739
- * @param document - DOCX file as File object or Uint8Array
740
- * @param searchText - Text to search for
741
- * @param maxResults - Maximum number of results (default: 100)
742
- * @returns Array of TextSpan objects with offsets
743
- * @throws Error if operation fails
744
- *
745
- * @example
746
- * ```typescript
747
- * const occurrences = await searchTextOffsets(docxFile, "liability");
748
- * console.log(`Found ${occurrences.length} occurrences`);
749
- *
750
- * for (const span of occurrences) {
751
- * console.log(`"${span.text}" at offset ${span.start}-${span.end}`);
752
- * }
753
- * ```
754
- */
755
- export declare function searchTextOffsets(document: File | Uint8Array, searchText: string, maxResults?: number): Promise<TextSpan[]>;
756
- /**
757
- * Create an annotation from character offsets.
758
- * This is a client-side helper - no WASM call needed.
759
- *
760
- * @param id - Unique identifier for the annotation
761
- * @param labelId - Label/category ID for the annotation
762
- * @param documentText - Full document text (from annotationSet.content)
763
- * @param startOffset - Start character offset (0-indexed, inclusive)
764
- * @param endOffset - End character offset (exclusive)
765
- * @returns OpenContractsAnnotation ready to add to an annotation set
766
- * @throws Error if offsets are invalid
767
- *
768
- * @example
769
- * ```typescript
770
- * const set = await createExternalAnnotationSet(docxFile, "doc-1");
771
- * const annotation = createAnnotation("ann-001", "IMPORTANT", set.content, 100, 150);
772
- * set.labelledText.push(annotation);
773
- * ```
774
- */
775
- export declare function createAnnotation(id: string, labelId: string, documentText: string, startOffset: number, endOffset: number): OpenContractsAnnotation;
776
- /**
777
- * Create an annotation by searching for text in the document.
778
- * This is a client-side helper - no WASM call needed.
779
- *
780
- * @param id - Unique identifier for the annotation
781
- * @param labelId - Label/category ID for the annotation
782
- * @param documentText - Full document text (from annotationSet.content)
783
- * @param searchText - Text to search for
784
- * @param occurrence - Which occurrence to use (1-based, default: 1)
785
- * @returns OpenContractsAnnotation, or null if text not found
786
- *
787
- * @example
788
- * ```typescript
789
- * const set = await createExternalAnnotationSet(docxFile, "doc-1");
790
- *
791
- * // Find first occurrence
792
- * const ann1 = createAnnotationFromSearch("ann-001", "LIABILITY", set.content, "shall not be liable");
793
- * if (ann1) set.labelledText.push(ann1);
794
- *
795
- * // Find second occurrence
796
- * const ann2 = createAnnotationFromSearch("ann-002", "LIABILITY", set.content, "shall not be liable", 2);
797
- * if (ann2) set.labelledText.push(ann2);
798
- * ```
799
- */
800
- export declare function createAnnotationFromSearch(id: string, labelId: string, documentText: string, searchText: string, occurrence?: number): OpenContractsAnnotation | null;
801
- /**
802
- * Find all occurrences of a text string in the document.
803
- * This is a client-side helper - no WASM call needed.
804
- *
805
- * @param documentText - Full document text
806
- * @param searchText - Text to search for
807
- * @param maxResults - Maximum number of results (default: 100)
808
- * @returns Array of { start, end } offsets
809
- *
810
- * @example
811
- * ```typescript
812
- * const occurrences = findTextOccurrences(set.content, "the");
813
- * console.log(`Found ${occurrences.length} occurrences of "the"`);
814
- * ```
815
- */
816
- export declare function findTextOccurrences(documentText: string, searchText: string, maxResults?: number): Array<{
817
- start: number;
818
- end: number;
819
- }>;
820
- /**
821
- * Project external annotations onto already-converted HTML.
822
- * This avoids full DOCX re-conversion when only annotations change.
823
- *
824
- * Workflow:
825
- * 1. Convert DOCX to HTML once using `convertDocxToHtml()`
826
- * 2. Use this function to overlay annotations on the cached HTML
827
- * 3. When annotations change, call this again with the same base HTML
828
- *
829
- * @param html - HTML string (previously converted via convertDocxToHtml)
830
- * @param annotationSet - The external annotation set to project
831
- * @param projectionOptions - Projection settings (CSS prefix, label mode, etc.)
832
- * @returns HTML string with annotations projected
833
- * @throws Error if projection fails
834
- *
835
- * @example
836
- * ```typescript
837
- * // Step 1: Convert once
838
- * const baseHtml = await convertDocxToHtml(docxFile);
839
- *
840
- * // Step 2: Project annotations (fast, no DOCX re-conversion)
841
- * const annotatedHtml = await projectAnnotationsOntoHtml(baseHtml, annotationSet);
842
- *
843
- * // Step 3: When annotations change, project again on the same base HTML
844
- * annotationSet.labelledText.push(newAnnotation);
845
- * const updatedHtml = await projectAnnotationsOntoHtml(baseHtml, annotationSet);
846
- * ```
847
- */
848
- export declare function projectAnnotationsOntoHtml(html: string, annotationSet: ExternalAnnotationSet, projectionOptions?: ExternalAnnotationProjectionSettings): Promise<string>;
849
- /**
850
- * Add a single annotation to existing HTML without re-converting the document.
851
- * This is the fastest way to add one annotation to already-rendered HTML.
852
- *
853
- * @param html - HTML string (with or without existing annotations)
854
- * @param annotation - The annotation to add
855
- * @param label - Label definition for the annotation (optional, for color/text)
856
- * @param projectionOptions - Projection settings
857
- * @returns HTML string with the annotation added
858
- * @throws Error if operation fails
859
- *
860
- * @example
861
- * ```typescript
862
- * const annotation = createAnnotation("ann-new", "CLAUSE", set.content, 100, 150);
863
- * const label = { id: "CLAUSE", text: "Clause", color: "#FF5722" };
864
- * const updatedHtml = await addAnnotationToHtml(currentHtml, annotation, label);
865
- * ```
866
- */
867
- export declare function addAnnotationToHtml(html: string, annotation: OpenContractsAnnotation, label?: AnnotationLabel, projectionOptions?: ExternalAnnotationProjectionSettings): Promise<string>;
868
- /**
869
- * Remove a single annotation from HTML by annotation ID.
870
- * Unwraps annotation spans back to plain text.
871
- *
872
- * @param html - HTML string with annotations
873
- * @param annotationId - ID of the annotation to remove
874
- * @param cssClassPrefix - CSS class prefix used for annotations (default: "ext-annot-")
875
- * @returns HTML string with the annotation removed
876
- * @throws Error if operation fails
877
- *
878
- * @example
879
- * ```typescript
880
- * const updatedHtml = await removeAnnotationFromHtml(currentHtml, "ann-001");
881
- * ```
882
- */
883
- export declare function removeAnnotationFromHtml(html: string, annotationId: string, cssClassPrefix?: string): Promise<string>;
884
- /**
885
- * Generate CSS to hide annotations with specific label IDs.
886
- * Enables CSS-based label filtering without re-rendering HTML.
887
- *
888
- * Apply the returned CSS to your document (e.g., via a `<style>` element)
889
- * to hide/show annotations by label. This is much faster than re-projecting
890
- * all annotations.
891
- *
892
- * @param hiddenLabelIds - Array of label IDs to hide
893
- * @param cssClassPrefix - CSS class prefix (default: "ext-annot-")
894
- * @returns CSS string that hides the specified labels
895
- * @throws Error if operation fails
896
- *
897
- * @example
898
- * ```typescript
899
- * // Hide annotations with label "DRAFT" and "INTERNAL"
900
- * const css = await generateAnnotationVisibilityCss(["DRAFT", "INTERNAL"]);
901
- *
902
- * // Apply to a <style> element in the DOM
903
- * const styleEl = document.getElementById("visibility-overrides");
904
- * styleEl.textContent = css;
905
- *
906
- * // To show all annotations again, clear the style:
907
- * styleEl.textContent = "";
908
- * ```
909
- */
910
- export declare function generateAnnotationVisibilityCss(hiddenLabelIds: string[], cssClassPrefix?: string): Promise<string>;
911
- /**
912
- * Generate annotation CSS for a set of labels.
913
- * Useful when managing CSS separately from HTML content.
914
- *
915
- * @param labels - Label definitions (keyed by label ID)
916
- * @param projectionOptions - Projection settings
917
- * @returns CSS string for the annotation styles
918
- * @throws Error if operation fails
919
- *
920
- * @example
921
- * ```typescript
922
- * const labels = {
923
- * "CLAUSE": { id: "CLAUSE", text: "Clause", color: "#FF5722" },
924
- * "TERM": { id: "TERM", text: "Term", color: "#2196F3" },
925
- * };
926
- * const css = await generateAnnotationCss(labels);
927
- * ```
928
- */
929
- export declare function generateAnnotationCss(labels: Record<string, AnnotationLabel>, projectionOptions?: ExternalAnnotationProjectionSettings): Promise<string>;
930
10
  //# sourceMappingURL=index.d.ts.map