@extend-ai/react-docx 0.7.6 → 0.8.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.
- package/README.md +16 -6
- package/dist/{chunk-P3MKA55V.js → chunk-YE7GQOST.js} +158 -3
- package/dist/chunk-YE7GQOST.js.map +1 -0
- package/dist/docx-import-worker.cjs +6 -0
- package/dist/docx-import-worker.cjs.map +1 -1
- package/dist/docx-import-worker.js +1 -1
- package/dist/docx_wasm_bg.wasm +0 -0
- package/dist/index.cjs +5465 -926
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +234 -38
- package/dist/index.d.ts +234 -38
- package/dist/index.js +5281 -926
- package/dist/index.js.map +1 -1
- package/dist/src-AEHDFCS5.js +26 -0
- package/package.json +2 -2
- package/dist/chunk-P3MKA55V.js.map +0 -1
- package/dist/src-VN4V5N3K.js +0 -14
- /package/dist/{src-VN4V5N3K.js.map → src-AEHDFCS5.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -68,7 +68,34 @@ interface TextStyle {
|
|
|
68
68
|
highlight?: string;
|
|
69
69
|
backgroundColor?: string;
|
|
70
70
|
fontSizePt?: number;
|
|
71
|
+
/** Resolved single-family fallback retained for backwards compatibility. */
|
|
71
72
|
fontFamily?: string;
|
|
73
|
+
/** @internal Import-time fallback used to detect fontFamily edits. */
|
|
74
|
+
sourceFontFamily?: string;
|
|
75
|
+
/** Explicit OOXML w:rFonts slots. */
|
|
76
|
+
fontFamilyAscii?: string;
|
|
77
|
+
fontFamilyHAnsi?: string;
|
|
78
|
+
fontFamilyEastAsia?: string;
|
|
79
|
+
fontFamilyCs?: string;
|
|
80
|
+
fontThemeAscii?: string;
|
|
81
|
+
fontThemeHAnsi?: string;
|
|
82
|
+
fontThemeEastAsia?: string;
|
|
83
|
+
fontThemeCs?: string;
|
|
84
|
+
/** @internal Concrete families resolved from the document theme per slot. */
|
|
85
|
+
resolvedFontFamilyAscii?: string;
|
|
86
|
+
/** @internal Concrete families resolved from the document theme per slot. */
|
|
87
|
+
resolvedFontFamilyHAnsi?: string;
|
|
88
|
+
/** @internal Concrete families resolved from the document theme per slot. */
|
|
89
|
+
resolvedFontFamilyEastAsia?: string;
|
|
90
|
+
/** @internal Concrete families resolved from the document theme per slot. */
|
|
91
|
+
resolvedFontFamilyCs?: string;
|
|
92
|
+
fontHint?: string;
|
|
93
|
+
/** OOXML w:lang slots and complex-script direction controls. */
|
|
94
|
+
language?: string;
|
|
95
|
+
languageEastAsia?: string;
|
|
96
|
+
languageBidi?: string;
|
|
97
|
+
rightToLeft?: boolean;
|
|
98
|
+
complexScript?: boolean;
|
|
72
99
|
characterSpacingTwips?: number;
|
|
73
100
|
verticalAlign?: "superscript" | "subscript";
|
|
74
101
|
runBorder?: TextRunBorderStyle;
|
|
@@ -234,10 +261,28 @@ interface ParagraphStyle {
|
|
|
234
261
|
}
|
|
235
262
|
interface ParagraphNode {
|
|
236
263
|
type: "paragraph";
|
|
264
|
+
/** Stable identity for measurement caches; survives edits via cloneParagraph. */
|
|
265
|
+
blockId?: string;
|
|
237
266
|
children: ParagraphChildNode[];
|
|
238
267
|
style?: ParagraphStyle;
|
|
239
268
|
paragraphMarkDeleted?: boolean;
|
|
240
269
|
sourceXml?: string;
|
|
270
|
+
/** @internal Validated provenance for a surgical plain-text sourceXml patch. */
|
|
271
|
+
sourceTextPatch?: {
|
|
272
|
+
runs: Array<{
|
|
273
|
+
style?: TextStyle;
|
|
274
|
+
link?: string;
|
|
275
|
+
noteReference?: TextRunNode["noteReference"];
|
|
276
|
+
}>;
|
|
277
|
+
};
|
|
278
|
+
/** @internal Immutable import-time run metadata used by surgical editors. */
|
|
279
|
+
sourceRunProvenance?: {
|
|
280
|
+
runs: Array<{
|
|
281
|
+
style?: TextStyle;
|
|
282
|
+
link?: string;
|
|
283
|
+
noteReference?: TextRunNode["noteReference"];
|
|
284
|
+
}>;
|
|
285
|
+
};
|
|
241
286
|
}
|
|
242
287
|
interface TableBoxSpacing {
|
|
243
288
|
topTwips?: number;
|
|
@@ -311,9 +356,16 @@ interface TableStyle {
|
|
|
311
356
|
}
|
|
312
357
|
interface TableNode {
|
|
313
358
|
type: "table";
|
|
359
|
+
/** Stable identity for measurement caches; survives edits via cloneTable. */
|
|
360
|
+
blockId?: string;
|
|
314
361
|
rows: TableRowNode[];
|
|
315
362
|
style?: TableStyle;
|
|
316
363
|
sourceXml?: string;
|
|
364
|
+
/** @internal Validated text-only descendant replacements for sourceXml. */
|
|
365
|
+
sourceTextPatches?: Array<{
|
|
366
|
+
sourceParagraphXml: string;
|
|
367
|
+
paragraph: ParagraphNode;
|
|
368
|
+
}>;
|
|
317
369
|
}
|
|
318
370
|
type DocNode = ParagraphNode | TableNode;
|
|
319
371
|
interface HeaderSection {
|
|
@@ -405,6 +457,16 @@ interface DocumentCommentDefinition {
|
|
|
405
457
|
parentId?: number;
|
|
406
458
|
/** True when the comment thread is marked done in commentsExtended. */
|
|
407
459
|
resolved?: boolean;
|
|
460
|
+
/** @internal Original `w:comment` block retained for lossless serialization. */
|
|
461
|
+
sourceXml?: string;
|
|
462
|
+
/** @internal Final comment paragraph id used by `commentsExtended.xml`. */
|
|
463
|
+
extendedParagraphId?: string;
|
|
464
|
+
/** @internal Resolution state read from `commentsExtended.xml`. */
|
|
465
|
+
sourceResolved?: boolean;
|
|
466
|
+
/** @internal True when `resolved` differs from the imported state. */
|
|
467
|
+
resolutionDirty?: boolean;
|
|
468
|
+
/** @internal True for a comment created in the editor rather than imported. */
|
|
469
|
+
isNew?: boolean;
|
|
408
470
|
}
|
|
409
471
|
interface DocumentCompatibilitySettings {
|
|
410
472
|
suppressSpacingBeforeAfterPageBreak?: boolean;
|
|
@@ -436,8 +498,34 @@ interface DocModel {
|
|
|
436
498
|
};
|
|
437
499
|
}
|
|
438
500
|
|
|
501
|
+
/** Returns a fresh block id, unique for the lifetime of this module instance. */
|
|
502
|
+
declare function allocateBlockId(): string;
|
|
503
|
+
/**
|
|
504
|
+
* Assigns a fresh block id to every paragraph/table node (body, headers,
|
|
505
|
+
* footers, footnotes, endnotes, nested table content) that does not already
|
|
506
|
+
* have one. Mutates the model in place and returns it.
|
|
507
|
+
*/
|
|
508
|
+
declare function ensureDocModelBlockIds(model: DocModel): DocModel;
|
|
509
|
+
/**
|
|
510
|
+
* Returns block ids that appear on more than one node within the same
|
|
511
|
+
* container (body, a header/footer part, a note). Nodes without ids are
|
|
512
|
+
* ignored, and the same id may legitimately recur across containers (section
|
|
513
|
+
* views reference the same header/footer parts as the flat metadata lists).
|
|
514
|
+
*/
|
|
515
|
+
declare function collectDuplicateDocModelBlockIds(model: DocModel): string[];
|
|
516
|
+
|
|
517
|
+
declare function cloneParagraphNode(paragraph: ParagraphNode): ParagraphNode;
|
|
518
|
+
declare function cloneTableNode(table: TableNode): TableNode;
|
|
439
519
|
declare function cloneDocModel(model: DocModel): DocModel;
|
|
440
520
|
|
|
521
|
+
/**
|
|
522
|
+
* Dev-only commit guard: freezes a committed model so in-place mutation of
|
|
523
|
+
* structure shared with history snapshots throws instead of corrupting them.
|
|
524
|
+
* Already-frozen subtrees are skipped, so once a model is frozen, freezing a
|
|
525
|
+
* structurally shared successor only pays for the changed nodes.
|
|
526
|
+
*/
|
|
527
|
+
declare function deepFreezeDocModel(model: DocModel): DocModel;
|
|
528
|
+
|
|
441
529
|
declare function normalizeDocModel(model: DocModel): DocModel;
|
|
442
530
|
|
|
443
531
|
declare function buildDocModel(pkg: OoxmlPackage): Promise<DocModel>;
|
|
@@ -511,6 +599,83 @@ interface LayoutPage {
|
|
|
511
599
|
}
|
|
512
600
|
declare function layoutDocument(model: DocModel, options?: LayoutOptions): LayoutPage[];
|
|
513
601
|
|
|
602
|
+
type AnnotationMutationFailureReason = "stale" | "unsupported" | "unsafe-xml";
|
|
603
|
+
type AnnotationMutationResult = {
|
|
604
|
+
ok: true;
|
|
605
|
+
model: DocModel;
|
|
606
|
+
} | {
|
|
607
|
+
ok: false;
|
|
608
|
+
reason: AnnotationMutationFailureReason;
|
|
609
|
+
};
|
|
610
|
+
type CommentCreationResult = {
|
|
611
|
+
ok: true;
|
|
612
|
+
model: DocModel;
|
|
613
|
+
commentId: number;
|
|
614
|
+
} | {
|
|
615
|
+
ok: false;
|
|
616
|
+
reason: AnnotationMutationFailureReason;
|
|
617
|
+
};
|
|
618
|
+
type ParagraphRevisionKind = "insertion" | "deletion" | "move-from" | "move-to" | "format-change" | "paragraph-format-change";
|
|
619
|
+
interface ParagraphRevisionTarget {
|
|
620
|
+
/** Top-level body node containing the revision. Table locations are unsupported. */
|
|
621
|
+
nodeIndex: number;
|
|
622
|
+
/** OOXML `w:id` from the `w:ins` or `w:del` wrapper. */
|
|
623
|
+
revisionId: string | number;
|
|
624
|
+
kind: ParagraphRevisionKind;
|
|
625
|
+
}
|
|
626
|
+
interface CreateParagraphCommentInput {
|
|
627
|
+
/** Top-level body paragraph index. */
|
|
628
|
+
nodeIndex: number;
|
|
629
|
+
/** UTF-16 offsets into the paragraph's plain text, matching DOM selection offsets. */
|
|
630
|
+
startOffset: number;
|
|
631
|
+
endOffset: number;
|
|
632
|
+
text: string;
|
|
633
|
+
author?: string;
|
|
634
|
+
initials?: string;
|
|
635
|
+
date?: string;
|
|
636
|
+
}
|
|
637
|
+
declare function acceptParagraphRevision(model: DocModel, target: ParagraphRevisionTarget): AnnotationMutationResult;
|
|
638
|
+
declare function rejectParagraphRevision(model: DocModel, target: ParagraphRevisionTarget): AnnotationMutationResult;
|
|
639
|
+
declare function setCommentResolved(model: DocModel, commentId: number, resolved: boolean): AnnotationMutationResult;
|
|
640
|
+
/**
|
|
641
|
+
* Creates a comment over a plain-text range in one top-level paragraph. The
|
|
642
|
+
* operation splits only the boundary runs and preserves their original rPr.
|
|
643
|
+
*/
|
|
644
|
+
declare function createParagraphComment(model: DocModel, input: CreateParagraphCommentInput): CommentCreationResult;
|
|
645
|
+
|
|
646
|
+
interface InsertParagraphOptions {
|
|
647
|
+
paragraphStyle?: ParagraphStyle;
|
|
648
|
+
runStyle?: TextStyle;
|
|
649
|
+
}
|
|
650
|
+
interface UpdateTextOptions {
|
|
651
|
+
insertedStyle?: TextStyle;
|
|
652
|
+
}
|
|
653
|
+
declare function splitParagraphChildrenAtTextOffsets(paragraph: ParagraphNode, text: string, startOffset: number, endOffset: number, options?: {
|
|
654
|
+
beforeInsertedStyle?: TextStyle;
|
|
655
|
+
afterInsertedStyle?: TextStyle;
|
|
656
|
+
}): {
|
|
657
|
+
beforeChildren: ParagraphNode["children"];
|
|
658
|
+
afterChildren: ParagraphNode["children"];
|
|
659
|
+
};
|
|
660
|
+
declare function insertParagraph(model: DocModel, text: string, index?: number, options?: InsertParagraphOptions): DocModel;
|
|
661
|
+
declare function removeParagraph(model: DocModel, index: number): DocModel;
|
|
662
|
+
declare function duplicateParagraph(model: DocModel, index: number): DocModel;
|
|
663
|
+
declare function updateParagraphText(model: DocModel, index: number, text: string, options?: UpdateTextOptions): DocModel;
|
|
664
|
+
declare function updateTableCellText(model: DocModel, tableIndex: number, rowIndex: number, cellIndex: number, text: string, options?: UpdateTextOptions): DocModel;
|
|
665
|
+
declare function updateTableCellParagraphText(model: DocModel, tableIndex: number, rowIndex: number, cellIndex: number, paragraphIndex: number, text: string, options?: UpdateTextOptions): DocModel;
|
|
666
|
+
declare function updateTableCellParagraphTextRecursive(model: DocModel, tableIndex: number, rowIndex: number, cellIndex: number, paragraphIndex: number, text: string, options?: UpdateTextOptions): DocModel;
|
|
667
|
+
declare function replaceText(model: DocModel, searchValue: string | RegExp, replacement: string): DocModel;
|
|
668
|
+
declare function setParagraphHeading(model: DocModel, nodeIndex: number, headingLevel?: HeadingLevel): DocModel;
|
|
669
|
+
declare function setParagraphAlignment(model: DocModel, nodeIndex: number, align?: ParagraphAlignment): DocModel;
|
|
670
|
+
declare function applyRunStyle(model: DocModel, nodeIndex: number, runIndex: number, style: Partial<TextStyle>): DocModel;
|
|
671
|
+
declare function toggleRunStyleFlag(model: DocModel, nodeIndex: number, runIndex: number, key: "bold" | "italic" | "underline" | "strike"): DocModel;
|
|
672
|
+
declare function setRunHighlight(model: DocModel, nodeIndex: number, runIndex: number, highlight?: string): DocModel;
|
|
673
|
+
declare function setRunColor(model: DocModel, nodeIndex: number, runIndex: number, color?: string): DocModel;
|
|
674
|
+
declare function copyParagraphs(model: DocModel, startIndex: number, endIndex?: number): ParagraphNode[];
|
|
675
|
+
declare function pasteParagraphs(model: DocModel, index: number, paragraphs: ParagraphNode[]): DocModel;
|
|
676
|
+
declare function serializeParagraphsForClipboard(paragraphs: ParagraphNode[]): string;
|
|
677
|
+
declare function parseParagraphsFromClipboard(input: string): ParagraphNode[] | undefined;
|
|
678
|
+
|
|
514
679
|
interface DocumentLayoutMetrics {
|
|
515
680
|
pageWidthPx: number;
|
|
516
681
|
pageHeightPx: number;
|
|
@@ -617,7 +782,15 @@ type DocxImageDropTarget = ParagraphLocation & {
|
|
|
617
782
|
type DocxTrackedChangeKind = "insertion" | "deletion" | "move-from" | "move-to" | "format-change" | "paragraph-format-change";
|
|
618
783
|
interface DocxTrackedChange {
|
|
619
784
|
id: string;
|
|
785
|
+
/** Document generation that produced this handle. */
|
|
786
|
+
documentLoadNonce: number;
|
|
787
|
+
/** Stable block identity used to reject shifted/stale handles. */
|
|
788
|
+
blockId?: string;
|
|
789
|
+
/** Opaque source-state signature used to fail closed after mutation. */
|
|
790
|
+
sourceFingerprint: string;
|
|
620
791
|
inlineAnchorId?: string;
|
|
792
|
+
/** OOXML `w:id` used by safe accept/reject operations. */
|
|
793
|
+
revisionId?: string;
|
|
621
794
|
kind: DocxTrackedChangeKind;
|
|
622
795
|
author?: string;
|
|
623
796
|
date?: string;
|
|
@@ -635,6 +808,12 @@ interface DocxTrackedChange {
|
|
|
635
808
|
interface DocxComment {
|
|
636
809
|
/** Stable identifier (unique per rendered anchor). */
|
|
637
810
|
id: string;
|
|
811
|
+
/** Document generation that produced this handle. */
|
|
812
|
+
documentLoadNonce: number;
|
|
813
|
+
/** Stable block identity used to reject shifted/stale handles. */
|
|
814
|
+
blockId?: string;
|
|
815
|
+
/** Opaque source/comment signature used to fail closed after mutation. */
|
|
816
|
+
sourceFingerprint: string;
|
|
638
817
|
/** Comment id from `word/comments.xml` (`w:id`). */
|
|
639
818
|
commentId: number;
|
|
640
819
|
author?: string;
|
|
@@ -651,6 +830,25 @@ interface DocxComment {
|
|
|
651
830
|
nodeIndex: number;
|
|
652
831
|
location: DocxTextRangeLocation;
|
|
653
832
|
}
|
|
833
|
+
type DocxAnnotationCommandFailureReason = AnnotationMutationFailureReason;
|
|
834
|
+
type DocxAnnotationCommandResult = {
|
|
835
|
+
ok: true;
|
|
836
|
+
} | {
|
|
837
|
+
ok: false;
|
|
838
|
+
reason: DocxAnnotationCommandFailureReason;
|
|
839
|
+
};
|
|
840
|
+
type DocxCommentCreationCommandResult = {
|
|
841
|
+
ok: true;
|
|
842
|
+
commentId: number;
|
|
843
|
+
} | {
|
|
844
|
+
ok: false;
|
|
845
|
+
reason: DocxAnnotationCommandFailureReason;
|
|
846
|
+
};
|
|
847
|
+
interface DocxCreateCommentOptions {
|
|
848
|
+
author?: string;
|
|
849
|
+
initials?: string;
|
|
850
|
+
date?: string;
|
|
851
|
+
}
|
|
654
852
|
type DocxLineSpacingRule = "auto" | "exact" | "atLeast";
|
|
655
853
|
type DocxSelectionSessionKind = "idle" | "pointer" | "keyboard" | "composition" | "command" | "history-restore";
|
|
656
854
|
interface DocxLineSpacingInfo {
|
|
@@ -768,6 +966,10 @@ interface DocxEditorController {
|
|
|
768
966
|
syncPaginationInfo: (pagination: DocxPaginationInfo) => void;
|
|
769
967
|
toggleShowTrackedChanges: () => void;
|
|
770
968
|
toggleShowComments: () => void;
|
|
969
|
+
acceptTrackedChange: (change: DocxTrackedChange) => DocxAnnotationCommandResult;
|
|
970
|
+
rejectTrackedChange: (change: DocxTrackedChange) => DocxAnnotationCommandResult;
|
|
971
|
+
createComment: (text: string, options?: DocxCreateCommentOptions) => DocxCommentCreationCommandResult;
|
|
972
|
+
setCommentResolved: (comment: DocxComment, resolved: boolean) => DocxAnnotationCommandResult;
|
|
771
973
|
importDocxFile: (file: File) => Promise<void>;
|
|
772
974
|
newDocument: () => void;
|
|
773
975
|
exportDocx: () => void;
|
|
@@ -809,7 +1011,9 @@ interface DocxEditorController {
|
|
|
809
1011
|
resizeImage: (location: DocxImageLocation, widthPx: number, heightPx: number) => void;
|
|
810
1012
|
setSyntheticTextBoxText: (location: DocxImageLocation, text: string) => void;
|
|
811
1013
|
setImageWrapMode: (location: DocxImageLocation, mode: DocxImageWrapMode, seedFloating?: Partial<NonNullable<ImageRunNode["floating"]>>) => void;
|
|
812
|
-
moveFloatingImage: (location: DocxImageLocation, patch: Partial<NonNullable<ImageRunNode["floating"]
|
|
1014
|
+
moveFloatingImage: (location: DocxImageLocation, patch: Partial<NonNullable<ImageRunNode["floating"]>>, options?: {
|
|
1015
|
+
reparentToParagraphNodeIndex?: number;
|
|
1016
|
+
}) => void;
|
|
813
1017
|
moveSectionFloatingImage: (location: DocxSectionImageLocation, patch: Partial<NonNullable<ImageRunNode["floating"]>>) => void;
|
|
814
1018
|
moveParagraphDropCap: (nodeIndex: number, patch: Partial<NonNullable<NonNullable<ParagraphNode["style"]>["dropCap"]>>) => void;
|
|
815
1019
|
setParagraphDropCapFontSizePt: (nodeIndex: number, fontSizePt: number) => void;
|
|
@@ -828,12 +1032,27 @@ interface DocxEditorController {
|
|
|
828
1032
|
deleteTableColumn: (tableIndex: number, cellIndex: number, rowIndex?: number) => void;
|
|
829
1033
|
deleteTable: (tableIndex: number) => void;
|
|
830
1034
|
moveTable: (tableIndex: number, targetNodeIndex: number) => void;
|
|
1035
|
+
setTableFloating: (tableIndex: number, patch: Partial<NonNullable<NonNullable<TableNode["style"]>["floating"]>>, options?: {
|
|
1036
|
+
moveToNodeIndex?: number;
|
|
1037
|
+
}) => void;
|
|
831
1038
|
moveEmbeddedTableToBody: (tableRuntimeKey: string, targetNodeIndex: number) => void;
|
|
832
1039
|
replaceExpandedSelection: (text: string, range?: DocxTextRange) => DocxTextRange | undefined;
|
|
833
1040
|
deleteExpandedSelection: (range?: DocxTextRange) => DocxTextRange | undefined;
|
|
834
1041
|
commitParagraphText: (nodeIndex: number, text: string) => void;
|
|
835
1042
|
commitTableCellText: (tableIndex: number, rowIndex: number, cellIndex: number, text: string) => void;
|
|
836
1043
|
commitTableCellParagraphTextRecursive: (tableIndex: number, rowIndex: number, cellIndex: number, paragraphIndex: number, text: string) => void;
|
|
1044
|
+
commitParagraphTextAtRange: (location: ParagraphLocation, text: string, caret: {
|
|
1045
|
+
start: number;
|
|
1046
|
+
end: number;
|
|
1047
|
+
}, options?: {
|
|
1048
|
+
insertionOffset?: number;
|
|
1049
|
+
coalesceKey?: string;
|
|
1050
|
+
}) => boolean;
|
|
1051
|
+
commitTableCellTextAtRange: (tableIndex: number, rowIndex: number, cellIndex: number, text: string, caret: {
|
|
1052
|
+
paragraphIndex: number;
|
|
1053
|
+
start: number;
|
|
1054
|
+
end: number;
|
|
1055
|
+
}) => boolean;
|
|
837
1056
|
commitSectionParagraphText: (location: DocxSectionParagraphLocation, text: string) => void;
|
|
838
1057
|
}
|
|
839
1058
|
type DocxTableContextMenuActionId = "insert-row-above" | "insert-row-below" | "insert-column-left" | "insert-column-right" | "delete-row" | "delete-column" | "delete-table";
|
|
@@ -1154,6 +1373,10 @@ interface DocxTrackedChangeCardRenderProps {
|
|
|
1154
1373
|
pageIndex: number;
|
|
1155
1374
|
/** Positioning style computed by the viewer. Apply this to the card root. */
|
|
1156
1375
|
style: React.CSSProperties;
|
|
1376
|
+
/** Accept this change. Unsupported or stale markup fails closed. */
|
|
1377
|
+
accept: () => DocxAnnotationCommandResult;
|
|
1378
|
+
/** Reject this change. Unsupported or stale markup fails closed. */
|
|
1379
|
+
reject: () => DocxAnnotationCommandResult;
|
|
1157
1380
|
}
|
|
1158
1381
|
interface DocxCommentCardRenderProps {
|
|
1159
1382
|
/** Comment data represented by the card. */
|
|
@@ -1170,6 +1393,8 @@ interface DocxCommentCardRenderProps {
|
|
|
1170
1393
|
pageIndex: number;
|
|
1171
1394
|
/** Positioning style computed by the viewer. Apply this to the card root. */
|
|
1172
1395
|
style: React.CSSProperties;
|
|
1396
|
+
/** Mark the comment resolved or reopen it. */
|
|
1397
|
+
setResolved: (resolved: boolean) => DocxAnnotationCommandResult;
|
|
1173
1398
|
}
|
|
1174
1399
|
/**
|
|
1175
1400
|
* Viewer interaction mode.
|
|
@@ -1214,6 +1439,8 @@ interface UseDocxTrackChangesResult {
|
|
|
1214
1439
|
toggleShowTrackedChanges: () => void;
|
|
1215
1440
|
changesByLocation: Map<string, DocxTrackedChange[]>;
|
|
1216
1441
|
getChangesForLocation: (location: DocxTextRangeLocation) => DocxTrackedChange[];
|
|
1442
|
+
acceptChange: (change: DocxTrackedChange) => DocxAnnotationCommandResult;
|
|
1443
|
+
rejectChange: (change: DocxTrackedChange) => DocxAnnotationCommandResult;
|
|
1217
1444
|
}
|
|
1218
1445
|
interface UseDocxCommentsResult {
|
|
1219
1446
|
comments: DocxComment[];
|
|
@@ -1222,6 +1449,8 @@ interface UseDocxCommentsResult {
|
|
|
1222
1449
|
toggleShowComments: () => void;
|
|
1223
1450
|
commentsByLocation: Map<string, DocxComment[]>;
|
|
1224
1451
|
getCommentsForLocation: (location: DocxTextRangeLocation) => DocxComment[];
|
|
1452
|
+
createComment: (text: string, options?: DocxCreateCommentOptions) => DocxCommentCreationCommandResult;
|
|
1453
|
+
setCommentResolved: (comment: DocxComment, resolved: boolean) => DocxAnnotationCommandResult;
|
|
1225
1454
|
}
|
|
1226
1455
|
interface DocxSectionColumnLayout {
|
|
1227
1456
|
count: number;
|
|
@@ -1426,50 +1655,17 @@ declare function useDocxImageWrapMenu(menu: Pick<DocxContextMenuRenderProps, "co
|
|
|
1426
1655
|
declare function useDocxLineSpacing(editor: Pick<DocxEditorController, "selectedLineSpacing" | "setLineSpacing">): UseDocxLineSpacingResult;
|
|
1427
1656
|
declare function useDocxBorders(editor: Pick<DocxEditorController, "selectedBorderContext" | "activeBorderPresets" | "applyBorderPreset">): UseDocxBordersResult;
|
|
1428
1657
|
declare function useDocxFormFields(editor: Pick<DocxEditorController, "model" | "selectedFormField" | "selectFormField" | "setFormFieldValue" | "toggleFormCheckbox" | "updateFormFieldWidget">): UseDocxFormFieldsResult;
|
|
1429
|
-
declare function useDocxTrackChanges(editor: Pick<DocxEditorController, "trackedChanges" | "showTrackedChanges" | "setShowTrackedChanges" | "toggleShowTrackedChanges">): UseDocxTrackChangesResult;
|
|
1658
|
+
declare function useDocxTrackChanges(editor: Pick<DocxEditorController, "trackedChanges" | "showTrackedChanges" | "setShowTrackedChanges" | "toggleShowTrackedChanges" | "acceptTrackedChange" | "rejectTrackedChange">): UseDocxTrackChangesResult;
|
|
1430
1659
|
/**
|
|
1431
1660
|
* Exposes document comments and the show/hide state, mirroring
|
|
1432
1661
|
* `useDocxTrackChanges`. Pair with `DocxEditorViewer`'s `renderCommentCard`
|
|
1433
1662
|
* to fully customize how comments render.
|
|
1434
1663
|
*/
|
|
1435
|
-
declare function useDocxComments(editor: Pick<DocxEditorController, "comments" | "showComments" | "setShowComments" | "toggleShowComments">): UseDocxCommentsResult;
|
|
1664
|
+
declare function useDocxComments(editor: Pick<DocxEditorController, "comments" | "showComments" | "setShowComments" | "toggleShowComments" | "createComment" | "setCommentResolved">): UseDocxCommentsResult;
|
|
1436
1665
|
declare function useDocxPageLayout(editor: Pick<DocxEditorController, "model">): UseDocxPageLayoutResult;
|
|
1437
1666
|
declare function useDocxPagination(editor: Pick<DocxEditorController, "currentPage" | "totalPages">): UseDocxPaginationResult;
|
|
1438
1667
|
declare function DocxEditorViewer({ editor, className, style, pageBackgroundColor, pageGapBackgroundColor, deferInitialPaginationPaint, loadingState, pageVirtualization, visiblePageRange, onPageCountChange, onRequestPageReveal, headingStyles, showTrackedChanges, renderTrackedChangeCard, showComments, renderCommentCard, renderTableContextMenu, renderContextMenu, onFormFieldDoubleClick, mode, }: DocxEditorViewerProps): React.JSX.Element;
|
|
1439
1668
|
|
|
1440
|
-
interface InsertParagraphOptions {
|
|
1441
|
-
paragraphStyle?: ParagraphStyle;
|
|
1442
|
-
runStyle?: TextStyle;
|
|
1443
|
-
}
|
|
1444
|
-
interface UpdateTextOptions {
|
|
1445
|
-
insertedStyle?: TextStyle;
|
|
1446
|
-
}
|
|
1447
|
-
declare function splitParagraphChildrenAtTextOffsets(paragraph: ParagraphNode, text: string, startOffset: number, endOffset: number, options?: {
|
|
1448
|
-
beforeInsertedStyle?: TextStyle;
|
|
1449
|
-
afterInsertedStyle?: TextStyle;
|
|
1450
|
-
}): {
|
|
1451
|
-
beforeChildren: ParagraphNode["children"];
|
|
1452
|
-
afterChildren: ParagraphNode["children"];
|
|
1453
|
-
};
|
|
1454
|
-
declare function insertParagraph(model: DocModel, text: string, index?: number, options?: InsertParagraphOptions): DocModel;
|
|
1455
|
-
declare function removeParagraph(model: DocModel, index: number): DocModel;
|
|
1456
|
-
declare function duplicateParagraph(model: DocModel, index: number): DocModel;
|
|
1457
|
-
declare function updateParagraphText(model: DocModel, index: number, text: string, options?: UpdateTextOptions): DocModel;
|
|
1458
|
-
declare function updateTableCellText(model: DocModel, tableIndex: number, rowIndex: number, cellIndex: number, text: string, options?: UpdateTextOptions): DocModel;
|
|
1459
|
-
declare function updateTableCellParagraphText(model: DocModel, tableIndex: number, rowIndex: number, cellIndex: number, paragraphIndex: number, text: string, options?: UpdateTextOptions): DocModel;
|
|
1460
|
-
declare function updateTableCellParagraphTextRecursive(model: DocModel, tableIndex: number, rowIndex: number, cellIndex: number, paragraphIndex: number, text: string, options?: UpdateTextOptions): DocModel;
|
|
1461
|
-
declare function replaceText(model: DocModel, searchValue: string | RegExp, replacement: string): DocModel;
|
|
1462
|
-
declare function setParagraphHeading(model: DocModel, nodeIndex: number, headingLevel?: HeadingLevel): DocModel;
|
|
1463
|
-
declare function setParagraphAlignment(model: DocModel, nodeIndex: number, align?: ParagraphAlignment): DocModel;
|
|
1464
|
-
declare function applyRunStyle(model: DocModel, nodeIndex: number, runIndex: number, style: Partial<TextStyle>): DocModel;
|
|
1465
|
-
declare function toggleRunStyleFlag(model: DocModel, nodeIndex: number, runIndex: number, key: "bold" | "italic" | "underline" | "strike"): DocModel;
|
|
1466
|
-
declare function setRunHighlight(model: DocModel, nodeIndex: number, runIndex: number, highlight?: string): DocModel;
|
|
1467
|
-
declare function setRunColor(model: DocModel, nodeIndex: number, runIndex: number, color?: string): DocModel;
|
|
1468
|
-
declare function copyParagraphs(model: DocModel, startIndex: number, endIndex?: number): ParagraphNode[];
|
|
1469
|
-
declare function pasteParagraphs(model: DocModel, index: number, paragraphs: ParagraphNode[]): DocModel;
|
|
1470
|
-
declare function serializeParagraphsForClipboard(paragraphs: ParagraphNode[]): string;
|
|
1471
|
-
declare function parseParagraphsFromClipboard(input: string): ParagraphNode[] | undefined;
|
|
1472
|
-
|
|
1473
1669
|
interface ResolvedModelSection {
|
|
1474
1670
|
startNodeIndex: number;
|
|
1475
1671
|
sectionPropertiesXml?: string;
|
|
@@ -1750,6 +1946,6 @@ interface UseDocxModelState {
|
|
|
1750
1946
|
error?: Error;
|
|
1751
1947
|
}
|
|
1752
1948
|
declare function useDocxModel(file?: ArrayBuffer): UseDocxModelState;
|
|
1753
|
-
declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState }: ReactDocxViewerProps): React.JSX.Element;
|
|
1949
|
+
declare function ReactDocxViewer({ file, model, className, layoutOptions, emptyState, }: ReactDocxViewerProps): React.JSX.Element;
|
|
1754
1950
|
|
|
1755
|
-
export { DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCommentDefinition, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxComment, type DocxCommentCardRenderProps, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, type DocxDocumentTheme, type DocxEditorController, type DocxEditorSelection, DocxEditorViewer, type DocxEditorViewerMode, type DocxEditorViewerProps, type DocxFormFieldLocation, type DocxHeadingStyleMap, type DocxImageDropTarget, type DocxImageLocation, type DocxImageWrapMenuOption, type DocxImageWrapMode, type DocxImageWrapState, type DocxLineSpacingInfo, type DocxListType, type DocxPageLayoutInfo, type DocxPageThumbnailBounds, type DocxPageThumbnailItem, type DocxPageThumbnailRenderWindow, type DocxPageThumbnailResolution, type DocxPageThumbnailResolutionOptions, type DocxPageThumbnailStatus, type DocxPageVirtualizationOptions, type DocxPaginationInfo, type DocxSectionColumnLayout, type DocxSelectedFormField, type DocxTableContextMenuAction, type DocxTableContextMenuActionId, type DocxTableContextMenuContext, type DocxTableContextMenuRenderProps, type DocxTextRange, type DocxTextRangeLocation, type DocxTrackedChange, type DocxTrackedChangeCardRenderProps, type DocxTrackedChangeKind, type DocxViewerThumbnails, type DocxVisiblePageRange, type FooterSection, type FormFieldCheckboxWidgetSettings, type FormFieldDropdownWidgetSettings, type FormFieldOption, type FormFieldRunNode, type FormFieldSourceKind, type FormFieldTextWidgetSettings, type FormFieldType, type FormFieldWidgetSettings, type HeaderSection, type HeadingLevel, type ImageRunNode, type InsertParagraphOptions, type LayoutBlock, type LayoutFragmentSource, type LayoutImageRun, type LayoutOptions, type LayoutPage, type LayoutParagraphBlock, type LayoutRun, type LayoutSnapshot, type LayoutSnapshotBlockFragment, type LayoutSnapshotImageRun, type LayoutSnapshotMargins, type LayoutSnapshotOptions, type LayoutSnapshotPage, type LayoutSnapshotPageSize, type LayoutSnapshotParagraphFragment, type LayoutSnapshotRect, type LayoutSnapshotRun, type LayoutSnapshotTableCellFragment, type LayoutSnapshotTableFragment, type LayoutSnapshotTableRowFragment, type LayoutSnapshotTextRun, type LayoutTableBlock, type LayoutTableCell, type LayoutTableRow, type LayoutTextRun, type LegacyWasmOoxmlPackage, type LetterheadColumnSegmentGroup, type NumberingAbstractDefinition, type NumberingDefinitionSet, type NumberingInstanceDefinition, type NumberingLevelDefinition, type NumberingPictureBulletDefinition, type OoxmlPackage, type OoxmlPart, type OverflowBreakCollectionOptions, type PageSegmentationCallbacks, type PaginationSectionMetrics, type ParagraphAlignment, type ParagraphBorderSet, type ParagraphBorderStyle, type ParagraphChildNode, type ParagraphIndent, type ParagraphLineRange, type ParagraphNode, type ParagraphNumbering, type ParagraphSpacing, type ParagraphSplitControlOptions, type ParagraphStyle, type ParagraphStyleDefinition, type ParagraphTabStop, ReactDocxViewer, type ReactDocxViewerProps, type ResolvedDocument, type ResolvedDocumentSection, type ResolvedLayoutMetrics, type ResolvedModelSection, type TableBorderSet, type TableBorderStyle, type TableBoxSpacing, type TableCellContentNode, type TableCellNode, type TableCellStyle, type TableExplicitPageBreakInfo, type TableNode, type TableRowNode, type TableRowRange, type TableRowStyle, type TableStyle, type TextRunBorderStyle, type TextRunNode, type TextStyle, type UpdateTextOptions, type UseDocxBordersResult, type UseDocxCommentsResult, type UseDocxDocumentThemeResult, type UseDocxEditorOptions, type UseDocxFormFieldsResult, type UseDocxImageWrapMenuResult, type UseDocxLineSpacingResult, type UseDocxModelState, type UseDocxPageLayoutResult, type UseDocxPageThumbnailsOptions, type UseDocxPageThumbnailsResult, type UseDocxPaginationResult, type UseDocxParagraphStylesResult, type UseDocxTrackChangesResult, type UseDocxViewerThumbnailsOptions, type WasmOoxmlPackage, type WasmSource, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, defaultStarterModel, duplicateParagraph, getPart, initWasm, insertParagraph, layoutDocument, modelToDocumentXml, normalizeDocModel, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocx, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, setWasmSource, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxComments, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
|
|
1951
|
+
export { type AnnotationMutationFailureReason, type AnnotationMutationResult, type CommentCreationResult, type CreateParagraphCommentInput, DEFAULT_MIN_PARAGRAPH_LINE_HEIGHT_PX, DEFAULT_PAGE_OVERFLOW_TOLERANCE_PX, type DocModel, type DocNode, type DocumentCommentDefinition, type DocumentCompatibilitySettings, type DocumentNoteDefinition, type DocumentPageNodeSegment, type DocumentPageRange, type DocumentPageSegmentationOptions, type DocumentSection, type DocxAnnotationCommandFailureReason, type DocxAnnotationCommandResult, type DocxBorderContext, type DocxBorderPreset, type DocxBorderPresetState, type DocxComment, type DocxCommentCardRenderProps, type DocxCommentCreationCommandResult, type DocxContextMenuAction, type DocxContextMenuActionId, type DocxContextMenuContext, type DocxContextMenuRenderProps, type DocxCreateCommentOptions, type DocxDocumentTheme, type DocxEditorController, type DocxEditorSelection, DocxEditorViewer, type DocxEditorViewerMode, type DocxEditorViewerProps, type DocxFormFieldLocation, type DocxHeadingStyleMap, type DocxImageDropTarget, type DocxImageLocation, type DocxImageWrapMenuOption, type DocxImageWrapMode, type DocxImageWrapState, type DocxLineSpacingInfo, type DocxListType, type DocxPageLayoutInfo, type DocxPageThumbnailBounds, type DocxPageThumbnailItem, type DocxPageThumbnailRenderWindow, type DocxPageThumbnailResolution, type DocxPageThumbnailResolutionOptions, type DocxPageThumbnailStatus, type DocxPageVirtualizationOptions, type DocxPaginationInfo, type DocxSectionColumnLayout, type DocxSelectedFormField, type DocxTableContextMenuAction, type DocxTableContextMenuActionId, type DocxTableContextMenuContext, type DocxTableContextMenuRenderProps, type DocxTextRange, type DocxTextRangeLocation, type DocxTrackedChange, type DocxTrackedChangeCardRenderProps, type DocxTrackedChangeKind, type DocxViewerThumbnails, type DocxVisiblePageRange, type FooterSection, type FormFieldCheckboxWidgetSettings, type FormFieldDropdownWidgetSettings, type FormFieldOption, type FormFieldRunNode, type FormFieldSourceKind, type FormFieldTextWidgetSettings, type FormFieldType, type FormFieldWidgetSettings, type HeaderSection, type HeadingLevel, type ImageRunNode, type InsertParagraphOptions, type LayoutBlock, type LayoutFragmentSource, type LayoutImageRun, type LayoutOptions, type LayoutPage, type LayoutParagraphBlock, type LayoutRun, type LayoutSnapshot, type LayoutSnapshotBlockFragment, type LayoutSnapshotImageRun, type LayoutSnapshotMargins, type LayoutSnapshotOptions, type LayoutSnapshotPage, type LayoutSnapshotPageSize, type LayoutSnapshotParagraphFragment, type LayoutSnapshotRect, type LayoutSnapshotRun, type LayoutSnapshotTableCellFragment, type LayoutSnapshotTableFragment, type LayoutSnapshotTableRowFragment, type LayoutSnapshotTextRun, type LayoutTableBlock, type LayoutTableCell, type LayoutTableRow, type LayoutTextRun, type LegacyWasmOoxmlPackage, type LetterheadColumnSegmentGroup, type NumberingAbstractDefinition, type NumberingDefinitionSet, type NumberingInstanceDefinition, type NumberingLevelDefinition, type NumberingPictureBulletDefinition, type OoxmlPackage, type OoxmlPart, type OverflowBreakCollectionOptions, type PageSegmentationCallbacks, type PaginationSectionMetrics, type ParagraphAlignment, type ParagraphBorderSet, type ParagraphBorderStyle, type ParagraphChildNode, type ParagraphIndent, type ParagraphLineRange, type ParagraphNode, type ParagraphNumbering, type ParagraphRevisionKind, type ParagraphRevisionTarget, type ParagraphSpacing, type ParagraphSplitControlOptions, type ParagraphStyle, type ParagraphStyleDefinition, type ParagraphTabStop, ReactDocxViewer, type ReactDocxViewerProps, type ResolvedDocument, type ResolvedDocumentSection, type ResolvedLayoutMetrics, type ResolvedModelSection, type TableBorderSet, type TableBorderStyle, type TableBoxSpacing, type TableCellContentNode, type TableCellNode, type TableCellStyle, type TableExplicitPageBreakInfo, type TableNode, type TableRowNode, type TableRowRange, type TableRowStyle, type TableStyle, type TextRunBorderStyle, type TextRunNode, type TextStyle, type UpdateTextOptions, type UseDocxBordersResult, type UseDocxCommentsResult, type UseDocxDocumentThemeResult, type UseDocxEditorOptions, type UseDocxFormFieldsResult, type UseDocxImageWrapMenuResult, type UseDocxLineSpacingResult, type UseDocxModelState, type UseDocxPageLayoutResult, type UseDocxPageThumbnailsOptions, type UseDocxPageThumbnailsResult, type UseDocxPaginationResult, type UseDocxParagraphStylesResult, type UseDocxTrackChangesResult, type UseDocxViewerThumbnailsOptions, type WasmOoxmlPackage, type WasmSource, acceptParagraphRevision, allocateBlockId, applyRunStyle, buildDocModel, buildDocModelFromBytes, buildDocumentPageNodeSegments, buildDocumentPageRanges, buildLayoutSnapshot, cloneDocModel, cloneParagraphNode, cloneTableNode, collectDocxEstimatedOverflowBreakStartNodeIndexes, collectDocxHardPageBreakStartNodeIndexes, collectDocxLastRenderedPageBreakStartNodeIndexes, collectDuplicateDocModelBlockIds, collectTableExplicitPageBreakInfo, collectTopLevelExplicitPageBreakStartNodeIndexes, copyParagraphs, createMinimalDocxPackage, createParagraphComment, deepFreezeDocModel, defaultStarterModel, duplicateParagraph, ensureDocModelBlockIds, getPart, initWasm, insertParagraph, layoutDocument, modelToDocumentXml, normalizeDocModel, packageToArrayBuffer, paragraphAfterSpacingPx, paragraphBeforeSpacingPx, paragraphHasExplicitPageBreak, paragraphHasLastRenderedPageBreak, paragraphHasPageBreakBefore, paragraphLetterheadColumnGroupAtSegmentOffset, paragraphLetterheadFloatSideAtNodeIndex, paragraphStartsWithLastRenderedPageBreak, parseDocx, parseParagraphsFromClipboard, parseSectionLayout, pasteParagraphs, rejectParagraphRevision, removeParagraph, replaceText, resolveDocumentForLayout, resolveDocumentLayout, resolveDocumentPageSegmentStartNodeIndex, resolveDocumentSectionsFromMetadata, resolveDocxPageThumbnailResolution, resolvePaginationSectionMetricsIndexForNodeIndex, resolveParagraphBeforeSpacingPx, resolveSectionIndexForNodeIndex, resolveSectionPropertiesXmlForNodeIndex, scalePaginationSectionMetricsHeights, scorePaginationAgainstStoredPageBreaks, sectionBreakAfterParagraphStartsNewPage, sectionBreakPropertiesStartNewPage, sectionTitlePageEnabled, selectSectionVariantForPage, serializeDocModel, serializeDocx, serializeParagraphsForClipboard, setCommentResolved, setParagraphAlignment, setParagraphHeading, setRunColor, setRunHighlight, setWasmSource, splitParagraphChildrenAtTextOffsets, toggleRunStyleFlag, updateParagraphText, updateTableCellParagraphText, updateTableCellParagraphTextRecursive, updateTableCellText, useDocxBorders, useDocxComments, useDocxDocumentTheme, useDocxEditor, useDocxFormFields, useDocxImageWrapMenu, useDocxLineSpacing, useDocxModel, useDocxPageLayout, useDocxPageThumbnails, useDocxPagination, useDocxParagraphStyles, useDocxTrackChanges, useDocxViewerThumbnails, withPart };
|