@usejunior/docx-core 0.0.1 → 0.1.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/LICENSE +21 -0
- package/README.md +86 -28
- package/dist/.tsbuildinfo +1 -0
- package/dist/atomizer.d.ts +218 -0
- package/dist/atomizer.d.ts.map +1 -0
- package/dist/atomizer.js +856 -0
- package/dist/atomizer.js.map +1 -0
- package/dist/baselines/atomizer/atomLcs.d.ts +96 -0
- package/dist/baselines/atomizer/atomLcs.d.ts.map +1 -0
- package/dist/baselines/atomizer/atomLcs.js +347 -0
- package/dist/baselines/atomizer/atomLcs.js.map +1 -0
- package/dist/baselines/atomizer/debug.d.ts +41 -0
- package/dist/baselines/atomizer/debug.d.ts.map +1 -0
- package/dist/baselines/atomizer/debug.js +85 -0
- package/dist/baselines/atomizer/debug.js.map +1 -0
- package/dist/baselines/atomizer/documentReconstructor.d.ts +64 -0
- package/dist/baselines/atomizer/documentReconstructor.d.ts.map +1 -0
- package/dist/baselines/atomizer/documentReconstructor.js +939 -0
- package/dist/baselines/atomizer/documentReconstructor.js.map +1 -0
- package/dist/baselines/atomizer/hierarchicalLcs.d.ts +111 -0
- package/dist/baselines/atomizer/hierarchicalLcs.d.ts.map +1 -0
- package/dist/baselines/atomizer/hierarchicalLcs.js +469 -0
- package/dist/baselines/atomizer/hierarchicalLcs.js.map +1 -0
- package/dist/baselines/atomizer/inPlaceModifier.d.ts +183 -0
- package/dist/baselines/atomizer/inPlaceModifier.d.ts.map +1 -0
- package/dist/baselines/atomizer/inPlaceModifier.js +1600 -0
- package/dist/baselines/atomizer/inPlaceModifier.js.map +1 -0
- package/dist/baselines/atomizer/numberingIntegration.d.ts +59 -0
- package/dist/baselines/atomizer/numberingIntegration.d.ts.map +1 -0
- package/dist/baselines/atomizer/numberingIntegration.js +209 -0
- package/dist/baselines/atomizer/numberingIntegration.js.map +1 -0
- package/dist/baselines/atomizer/pipeline.d.ts +65 -0
- package/dist/baselines/atomizer/pipeline.d.ts.map +1 -0
- package/dist/baselines/atomizer/pipeline.js +510 -0
- package/dist/baselines/atomizer/pipeline.js.map +1 -0
- package/dist/baselines/atomizer/premergeRuns.d.ts +26 -0
- package/dist/baselines/atomizer/premergeRuns.d.ts.map +1 -0
- package/dist/baselines/atomizer/premergeRuns.js +150 -0
- package/dist/baselines/atomizer/premergeRuns.js.map +1 -0
- package/dist/baselines/atomizer/trackChangesAcceptor.d.ts +63 -0
- package/dist/baselines/atomizer/trackChangesAcceptor.d.ts.map +1 -0
- package/dist/baselines/atomizer/trackChangesAcceptor.js +254 -0
- package/dist/baselines/atomizer/trackChangesAcceptor.js.map +1 -0
- package/dist/baselines/atomizer/trackChangesAcceptorAst.d.ts +64 -0
- package/dist/baselines/atomizer/trackChangesAcceptorAst.d.ts.map +1 -0
- package/dist/baselines/atomizer/trackChangesAcceptorAst.js +586 -0
- package/dist/baselines/atomizer/trackChangesAcceptorAst.js.map +1 -0
- package/dist/baselines/atomizer/xmlToWmlElement.d.ts +65 -0
- package/dist/baselines/atomizer/xmlToWmlElement.d.ts.map +1 -0
- package/dist/baselines/atomizer/xmlToWmlElement.js +95 -0
- package/dist/baselines/atomizer/xmlToWmlElement.js.map +1 -0
- package/dist/baselines/diffmatch/documentBuilder.d.ts +44 -0
- package/dist/baselines/diffmatch/documentBuilder.d.ts.map +1 -0
- package/dist/baselines/diffmatch/documentBuilder.js +227 -0
- package/dist/baselines/diffmatch/documentBuilder.js.map +1 -0
- package/dist/baselines/diffmatch/paragraphAlignment.d.ts +75 -0
- package/dist/baselines/diffmatch/paragraphAlignment.d.ts.map +1 -0
- package/dist/baselines/diffmatch/paragraphAlignment.js +206 -0
- package/dist/baselines/diffmatch/paragraphAlignment.js.map +1 -0
- package/dist/baselines/diffmatch/pipeline.d.ts +33 -0
- package/dist/baselines/diffmatch/pipeline.d.ts.map +1 -0
- package/dist/baselines/diffmatch/pipeline.js +84 -0
- package/dist/baselines/diffmatch/pipeline.js.map +1 -0
- package/dist/baselines/diffmatch/runDiff.d.ts +53 -0
- package/dist/baselines/diffmatch/runDiff.d.ts.map +1 -0
- package/dist/baselines/diffmatch/runDiff.js +253 -0
- package/dist/baselines/diffmatch/runDiff.js.map +1 -0
- package/dist/baselines/diffmatch/trackChangesRenderer.d.ts +64 -0
- package/dist/baselines/diffmatch/trackChangesRenderer.d.ts.map +1 -0
- package/dist/baselines/diffmatch/trackChangesRenderer.js +178 -0
- package/dist/baselines/diffmatch/trackChangesRenderer.js.map +1 -0
- package/dist/baselines/diffmatch/xmlParser.d.ts +45 -0
- package/dist/baselines/diffmatch/xmlParser.d.ts.map +1 -0
- package/dist/baselines/diffmatch/xmlParser.js +344 -0
- package/dist/baselines/diffmatch/xmlParser.js.map +1 -0
- package/dist/baselines/wmlcomparer/DocxodusWasm.d.ts +51 -0
- package/dist/baselines/wmlcomparer/DocxodusWasm.d.ts.map +1 -0
- package/dist/baselines/wmlcomparer/DocxodusWasm.js +83 -0
- package/dist/baselines/wmlcomparer/DocxodusWasm.js.map +1 -0
- package/dist/baselines/wmlcomparer/DotnetCli.d.ts +40 -0
- package/dist/baselines/wmlcomparer/DotnetCli.d.ts.map +1 -0
- package/dist/baselines/wmlcomparer/DotnetCli.js +135 -0
- package/dist/baselines/wmlcomparer/DotnetCli.js.map +1 -0
- package/dist/benchmark/metrics.d.ts +72 -0
- package/dist/benchmark/metrics.d.ts.map +1 -0
- package/dist/benchmark/metrics.js +45 -0
- package/dist/benchmark/metrics.js.map +1 -0
- package/dist/benchmark/reporter.d.ts +23 -0
- package/dist/benchmark/reporter.d.ts.map +1 -0
- package/dist/benchmark/reporter.js +147 -0
- package/dist/benchmark/reporter.js.map +1 -0
- package/dist/benchmark/runner.d.ts +30 -0
- package/dist/benchmark/runner.d.ts.map +1 -0
- package/dist/benchmark/runner.js +233 -0
- package/dist/benchmark/runner.js.map +1 -0
- package/dist/cli/compare-two.d.ts +28 -0
- package/dist/cli/compare-two.d.ts.map +1 -0
- package/dist/cli/compare-two.js +110 -0
- package/dist/cli/compare-two.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +21 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core-types.d.ts +296 -0
- package/dist/core-types.d.ts.map +1 -0
- package/dist/core-types.js +122 -0
- package/dist/core-types.js.map +1 -0
- package/dist/footnotes.d.ts +144 -0
- package/dist/footnotes.d.ts.map +1 -0
- package/dist/footnotes.js +291 -0
- package/dist/footnotes.js.map +1 -0
- package/dist/format-detection.d.ts +120 -0
- package/dist/format-detection.d.ts.map +1 -0
- package/dist/format-detection.js +338 -0
- package/dist/format-detection.js.map +1 -0
- package/dist/index.d.ts +177 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/integration/output-artifacts.d.ts +6 -0
- package/dist/integration/output-artifacts.d.ts.map +1 -0
- package/dist/integration/output-artifacts.js +30 -0
- package/dist/integration/output-artifacts.js.map +1 -0
- package/dist/move-detection.d.ts +211 -0
- package/dist/move-detection.d.ts.map +1 -0
- package/dist/move-detection.js +391 -0
- package/dist/move-detection.js.map +1 -0
- package/dist/numbering.d.ts +136 -0
- package/dist/numbering.d.ts.map +1 -0
- package/dist/numbering.js +446 -0
- package/dist/numbering.js.map +1 -0
- package/dist/primitives/accept_changes.d.ts +30 -0
- package/dist/primitives/accept_changes.d.ts.map +1 -0
- package/dist/primitives/accept_changes.js +241 -0
- package/dist/primitives/accept_changes.js.map +1 -0
- package/dist/primitives/bookmarks.d.ts +12 -0
- package/dist/primitives/bookmarks.d.ts.map +1 -0
- package/dist/primitives/bookmarks.js +248 -0
- package/dist/primitives/bookmarks.js.map +1 -0
- package/dist/primitives/comments.d.ts +88 -0
- package/dist/primitives/comments.d.ts.map +1 -0
- package/dist/primitives/comments.js +703 -0
- package/dist/primitives/comments.js.map +1 -0
- package/dist/primitives/document.d.ts +168 -0
- package/dist/primitives/document.d.ts.map +1 -0
- package/dist/primitives/document.js +532 -0
- package/dist/primitives/document.js.map +1 -0
- package/dist/primitives/document_view.d.ts +93 -0
- package/dist/primitives/document_view.d.ts.map +1 -0
- package/dist/primitives/document_view.js +722 -0
- package/dist/primitives/document_view.js.map +1 -0
- package/dist/primitives/dom-helpers.d.ts +94 -0
- package/dist/primitives/dom-helpers.d.ts.map +1 -0
- package/dist/primitives/dom-helpers.js +219 -0
- package/dist/primitives/dom-helpers.js.map +1 -0
- package/dist/primitives/errors.d.ts +7 -0
- package/dist/primitives/errors.d.ts.map +1 -0
- package/dist/primitives/errors.js +10 -0
- package/dist/primitives/errors.js.map +1 -0
- package/dist/primitives/extract_revisions.d.ts +50 -0
- package/dist/primitives/extract_revisions.d.ts.map +1 -0
- package/dist/primitives/extract_revisions.js +340 -0
- package/dist/primitives/extract_revisions.js.map +1 -0
- package/dist/primitives/footnotes.d.ts +37 -0
- package/dist/primitives/footnotes.d.ts.map +1 -0
- package/dist/primitives/footnotes.js +552 -0
- package/dist/primitives/footnotes.js.map +1 -0
- package/dist/primitives/formatting_tags.d.ts +30 -0
- package/dist/primitives/formatting_tags.d.ts.map +1 -0
- package/dist/primitives/formatting_tags.js +217 -0
- package/dist/primitives/formatting_tags.js.map +1 -0
- package/dist/primitives/index.d.ts +26 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +26 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/layout.d.ts +53 -0
- package/dist/primitives/layout.d.ts.map +1 -0
- package/dist/primitives/layout.js +178 -0
- package/dist/primitives/layout.js.map +1 -0
- package/dist/primitives/list_labels.d.ts +19 -0
- package/dist/primitives/list_labels.d.ts.map +1 -0
- package/dist/primitives/list_labels.js +57 -0
- package/dist/primitives/list_labels.js.map +1 -0
- package/dist/primitives/matching.d.ts +17 -0
- package/dist/primitives/matching.d.ts.map +1 -0
- package/dist/primitives/matching.js +144 -0
- package/dist/primitives/matching.js.map +1 -0
- package/dist/primitives/merge_runs.d.ts +23 -0
- package/dist/primitives/merge_runs.d.ts.map +1 -0
- package/dist/primitives/merge_runs.js +195 -0
- package/dist/primitives/merge_runs.js.map +1 -0
- package/dist/primitives/namespaces.d.ts +90 -0
- package/dist/primitives/namespaces.d.ts.map +1 -0
- package/dist/primitives/namespaces.js +107 -0
- package/dist/primitives/namespaces.js.map +1 -0
- package/dist/primitives/numbering.d.ts +27 -0
- package/dist/primitives/numbering.d.ts.map +1 -0
- package/dist/primitives/numbering.js +182 -0
- package/dist/primitives/numbering.js.map +1 -0
- package/dist/primitives/prevent_double_elevation.d.ts +18 -0
- package/dist/primitives/prevent_double_elevation.d.ts.map +1 -0
- package/dist/primitives/prevent_double_elevation.js +190 -0
- package/dist/primitives/prevent_double_elevation.js.map +1 -0
- package/dist/primitives/reject_changes.d.ts +27 -0
- package/dist/primitives/reject_changes.d.ts.map +1 -0
- package/dist/primitives/reject_changes.js +371 -0
- package/dist/primitives/reject_changes.js.map +1 -0
- package/dist/primitives/relationships.d.ts +7 -0
- package/dist/primitives/relationships.d.ts.map +1 -0
- package/dist/primitives/relationships.js +24 -0
- package/dist/primitives/relationships.js.map +1 -0
- package/dist/primitives/semantic_tags.d.ts +32 -0
- package/dist/primitives/semantic_tags.d.ts.map +1 -0
- package/dist/primitives/semantic_tags.js +139 -0
- package/dist/primitives/semantic_tags.js.map +1 -0
- package/dist/primitives/simplify_redlines.d.ts +19 -0
- package/dist/primitives/simplify_redlines.d.ts.map +1 -0
- package/dist/primitives/simplify_redlines.js +94 -0
- package/dist/primitives/simplify_redlines.js.map +1 -0
- package/dist/primitives/styles.d.ts +36 -0
- package/dist/primitives/styles.d.ts.map +1 -0
- package/dist/primitives/styles.js +190 -0
- package/dist/primitives/styles.js.map +1 -0
- package/dist/primitives/text.d.ts +27 -0
- package/dist/primitives/text.d.ts.map +1 -0
- package/dist/primitives/text.js +416 -0
- package/dist/primitives/text.js.map +1 -0
- package/dist/primitives/validate_document.d.ts +24 -0
- package/dist/primitives/validate_document.d.ts.map +1 -0
- package/dist/primitives/validate_document.js +147 -0
- package/dist/primitives/validate_document.js.map +1 -0
- package/dist/primitives/xml.d.ts +5 -0
- package/dist/primitives/xml.d.ts.map +1 -0
- package/dist/primitives/xml.js +19 -0
- package/dist/primitives/xml.js.map +1 -0
- package/dist/primitives/zip.d.ts +25 -0
- package/dist/primitives/zip.d.ts.map +1 -0
- package/dist/primitives/zip.js +78 -0
- package/dist/primitives/zip.js.map +1 -0
- package/dist/shared/docx/DocxArchive.d.ts +94 -0
- package/dist/shared/docx/DocxArchive.d.ts.map +1 -0
- package/dist/shared/docx/DocxArchive.js +169 -0
- package/dist/shared/docx/DocxArchive.js.map +1 -0
- package/dist/shared/ooxml/namespaces.d.ts +149 -0
- package/dist/shared/ooxml/namespaces.d.ts.map +1 -0
- package/dist/shared/ooxml/namespaces.js +224 -0
- package/dist/shared/ooxml/namespaces.js.map +1 -0
- package/dist/shared/ooxml/types.d.ts +136 -0
- package/dist/shared/ooxml/types.d.ts.map +1 -0
- package/dist/shared/ooxml/types.js +7 -0
- package/dist/shared/ooxml/types.js.map +1 -0
- package/package.json +63 -6
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WmlComparer Core Data Structures
|
|
3
|
+
*
|
|
4
|
+
* TypeScript equivalents of WmlComparer's core C# data structures.
|
|
5
|
+
* These types form the foundation for the atomization pipeline that
|
|
6
|
+
* flattens OOXML into comparable units.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/OpenXmlDev/Open-Xml-PowerTools/blob/536ca1fb4bcdce1f4c920658bd66807b970393d7/OpenXmlPowerTools/WmlComparer.cs
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Correlation status for comparison units.
|
|
12
|
+
*
|
|
13
|
+
* Tracks the result of comparing atoms between two documents.
|
|
14
|
+
*
|
|
15
|
+
* @see WmlComparer.cs line 2264
|
|
16
|
+
*/
|
|
17
|
+
export declare enum CorrelationStatus {
|
|
18
|
+
/** Not yet processed by comparison algorithm */
|
|
19
|
+
Unknown = "Unknown",
|
|
20
|
+
/** Content matches in both documents */
|
|
21
|
+
Equal = "Equal",
|
|
22
|
+
/** Content only exists in original document (removed) */
|
|
23
|
+
Deleted = "Deleted",
|
|
24
|
+
/** Content only exists in revised document (added) */
|
|
25
|
+
Inserted = "Inserted",
|
|
26
|
+
/** Content was moved from this location (source of move) */
|
|
27
|
+
MovedSource = "MovedSource",
|
|
28
|
+
/** Content was moved to this location (destination of move) */
|
|
29
|
+
MovedDestination = "MovedDestination",
|
|
30
|
+
/** Text content matches but formatting differs */
|
|
31
|
+
FormatChanged = "FormatChanged"
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Represents an Open Packaging Conventions (OPC) part.
|
|
35
|
+
*
|
|
36
|
+
* Minimal interface for tracking which file/part a node originated from.
|
|
37
|
+
* Integrates with DocxArchive for ZIP extraction.
|
|
38
|
+
*
|
|
39
|
+
* @see OpenXmlPart in DocumentFormat.OpenXml.Packaging
|
|
40
|
+
*/
|
|
41
|
+
export interface OpcPart {
|
|
42
|
+
/** Part URI within the package, e.g., "word/document.xml" */
|
|
43
|
+
uri: string;
|
|
44
|
+
/** Content type of the part, e.g., "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" */
|
|
45
|
+
contentType: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Transition alias: WmlElement is now the native DOM Element from @xmldom/xmldom.
|
|
49
|
+
*
|
|
50
|
+
* All attribute access uses `.getAttribute(name)`, children use DOM traversal,
|
|
51
|
+
* and parent navigation uses `.parentNode` / `.parentElement`.
|
|
52
|
+
*
|
|
53
|
+
* This alias will be removed once all imports are updated to use `Element` directly.
|
|
54
|
+
*/
|
|
55
|
+
export type WmlElement = Element;
|
|
56
|
+
/**
|
|
57
|
+
* Base interface for any comparison unit (atom or group).
|
|
58
|
+
*
|
|
59
|
+
* Represents a unit of content that can be compared between documents.
|
|
60
|
+
*
|
|
61
|
+
* @see ComparisonUnit abstract class in WmlComparer.cs lines 2230-2270
|
|
62
|
+
*/
|
|
63
|
+
export interface ComparisonUnit {
|
|
64
|
+
/** SHA1 hash of the unit's content for quick equality check */
|
|
65
|
+
sha1Hash: string;
|
|
66
|
+
/** Current correlation status after comparison */
|
|
67
|
+
correlationStatus: CorrelationStatus;
|
|
68
|
+
/** Child comparison units (for groups) */
|
|
69
|
+
contents?: ComparisonUnit[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Format change information for atoms where text matches but formatting differs.
|
|
73
|
+
*
|
|
74
|
+
* Stores the old and new run properties along with the specific property names
|
|
75
|
+
* that changed (e.g., "bold", "italic").
|
|
76
|
+
*/
|
|
77
|
+
export interface FormatChangeInfo {
|
|
78
|
+
/** Run properties from the original document (before changes) */
|
|
79
|
+
oldRunProperties: WmlElement | null;
|
|
80
|
+
/** Run properties from the modified document (after changes) */
|
|
81
|
+
newRunProperties: WmlElement | null;
|
|
82
|
+
/** List of property names that changed (e.g., "bold", "italic", "fontSize") */
|
|
83
|
+
changedProperties: string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Atomic leaf-node unit used in LCS comparison.
|
|
87
|
+
*
|
|
88
|
+
* Represents the smallest comparable unit of content. Created by atomizing
|
|
89
|
+
* the document tree into individual text nodes, breaks, and other leaf elements.
|
|
90
|
+
*
|
|
91
|
+
* @see ComparisonUnitAtom class in WmlComparer.cs lines 2305-2350
|
|
92
|
+
*/
|
|
93
|
+
export interface ComparisonUnitAtom extends ComparisonUnit {
|
|
94
|
+
/** The leaf element (w:t, w:br, w:cr, etc.) */
|
|
95
|
+
contentElement: WmlElement;
|
|
96
|
+
/**
|
|
97
|
+
* Convenience references used by some reconstruction paths (e.g. in-place mode).
|
|
98
|
+
* These are optional because they can be derived from `ancestorElements`.
|
|
99
|
+
*/
|
|
100
|
+
sourceRunElement?: WmlElement;
|
|
101
|
+
sourceParagraphElement?: WmlElement;
|
|
102
|
+
/** Ancestor elements from root to parent of contentElement */
|
|
103
|
+
ancestorElements: WmlElement[];
|
|
104
|
+
/** Unique identifiers extracted from ancestors (w:Unid attributes) */
|
|
105
|
+
ancestorUnids: string[];
|
|
106
|
+
/** The OPC part this atom belongs to */
|
|
107
|
+
part: OpcPart;
|
|
108
|
+
/** Revision tracking element if this atom is inside w:ins or w:del */
|
|
109
|
+
revTrackElement?: WmlElement;
|
|
110
|
+
/** Sequential index of the paragraph this atom belongs to (0-indexed) */
|
|
111
|
+
paragraphIndex?: number;
|
|
112
|
+
/** Group ID for atoms that are part of a move operation */
|
|
113
|
+
moveGroupId?: number;
|
|
114
|
+
/** Move name for linking source and destination (e.g., "move1") */
|
|
115
|
+
moveName?: string;
|
|
116
|
+
/** Format change details when text is equal but formatting differs */
|
|
117
|
+
formatChange?: FormatChangeInfo;
|
|
118
|
+
/** Reference to the corresponding atom in the other document (for Equal atoms) */
|
|
119
|
+
comparisonUnitAtomBefore?: ComparisonUnitAtom;
|
|
120
|
+
/** True if this atom represents an empty paragraph (paragraph with only w:pPr, no content) */
|
|
121
|
+
isEmptyParagraph?: boolean;
|
|
122
|
+
/** Original atoms when this atom represents a collapsed field sequence */
|
|
123
|
+
collapsedFieldAtoms?: ComparisonUnitAtom[];
|
|
124
|
+
/** Reference to the parent atom when this atom was created by word-level splitting */
|
|
125
|
+
splitFromAtom?: ComparisonUnitAtom;
|
|
126
|
+
/** Which document this atom originated from (for correct formatting application) */
|
|
127
|
+
sourceDocument?: 'original' | 'revised';
|
|
128
|
+
/** Cloned run properties (w:rPr) captured at atomization time, or null if no formatting */
|
|
129
|
+
rPr?: Element | null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Settings for move detection algorithm.
|
|
133
|
+
*
|
|
134
|
+
* @see WmlComparerSettings in WmlComparer.cs
|
|
135
|
+
*/
|
|
136
|
+
export interface MoveDetectionSettings {
|
|
137
|
+
/** Enable move detection. Default: true */
|
|
138
|
+
detectMoves: boolean;
|
|
139
|
+
/** Minimum Jaccard similarity for a match to be considered a move. Default: 0.8 */
|
|
140
|
+
moveSimilarityThreshold: number;
|
|
141
|
+
/** Minimum word count for a block to be considered for move detection. Default: 5 */
|
|
142
|
+
moveMinimumWordCount: number;
|
|
143
|
+
/** Case insensitive comparison for move matching. Default: true */
|
|
144
|
+
caseInsensitiveMove: boolean;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Default settings for move detection.
|
|
148
|
+
*/
|
|
149
|
+
export declare const DEFAULT_MOVE_DETECTION_SETTINGS: MoveDetectionSettings;
|
|
150
|
+
/**
|
|
151
|
+
* Block of consecutive atoms with the same status.
|
|
152
|
+
*
|
|
153
|
+
* Used during move detection to group atoms into comparable blocks.
|
|
154
|
+
*/
|
|
155
|
+
export interface AtomBlock {
|
|
156
|
+
/** Status of all atoms in this block (Deleted or Inserted) */
|
|
157
|
+
status: CorrelationStatus;
|
|
158
|
+
/** The atoms in this block */
|
|
159
|
+
atoms: ComparisonUnitAtom[];
|
|
160
|
+
/** Joined text content from all atoms */
|
|
161
|
+
text: string;
|
|
162
|
+
/** Number of words in the text */
|
|
163
|
+
wordCount: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Settings for format change detection.
|
|
167
|
+
*/
|
|
168
|
+
export interface FormatDetectionSettings {
|
|
169
|
+
/** Enable format change detection. Default: true */
|
|
170
|
+
detectFormatChanges: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Default settings for format change detection.
|
|
174
|
+
*/
|
|
175
|
+
export declare const DEFAULT_FORMAT_DETECTION_SETTINGS: FormatDetectionSettings;
|
|
176
|
+
/**
|
|
177
|
+
* Mapping of OOXML run property tag names to friendly names.
|
|
178
|
+
*/
|
|
179
|
+
export declare const RUN_PROPERTY_FRIENDLY_NAMES: Record<string, string>;
|
|
180
|
+
/**
|
|
181
|
+
* Combined settings for document comparison.
|
|
182
|
+
*/
|
|
183
|
+
export interface WmlComparerSettings extends MoveDetectionSettings, FormatDetectionSettings {
|
|
184
|
+
/** Author name for revision tracking. Default: "Comparison" */
|
|
185
|
+
author: string;
|
|
186
|
+
/** Timestamp for revisions. Default: current time */
|
|
187
|
+
dateTime: Date;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Default comparison settings.
|
|
191
|
+
*/
|
|
192
|
+
export declare const DEFAULT_COMPARER_SETTINGS: WmlComparerSettings;
|
|
193
|
+
/**
|
|
194
|
+
* Information about list continuation patterns.
|
|
195
|
+
*
|
|
196
|
+
* Used to detect "orphan" list items that should render at a different
|
|
197
|
+
* effective level than their ilvl suggests.
|
|
198
|
+
*/
|
|
199
|
+
export interface ContinuationInfo {
|
|
200
|
+
/** Whether this paragraph is a continuation pattern */
|
|
201
|
+
isContinuation: boolean;
|
|
202
|
+
/** The effective level for rendering (0 for continuations) */
|
|
203
|
+
effectiveLevel: number;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Numbering level properties.
|
|
207
|
+
*/
|
|
208
|
+
export interface ListLevelInfo {
|
|
209
|
+
/** The indentation level (0-based) */
|
|
210
|
+
ilvl: number;
|
|
211
|
+
/** Starting number for this level */
|
|
212
|
+
start: number;
|
|
213
|
+
/** Number format (decimal, lowerLetter, upperRoman, etc.) */
|
|
214
|
+
numFmt: string;
|
|
215
|
+
/** Level text format string (e.g., "%1.", "%1.%2") */
|
|
216
|
+
lvlText: string;
|
|
217
|
+
/** Whether legal numbering is enabled */
|
|
218
|
+
isLgl?: boolean;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Numbering definition with all levels.
|
|
222
|
+
*/
|
|
223
|
+
export interface NumberingDefinition {
|
|
224
|
+
/** Numbering definition ID */
|
|
225
|
+
numId: number;
|
|
226
|
+
/** Abstract numbering ID */
|
|
227
|
+
abstractNumId: number;
|
|
228
|
+
/** Level definitions */
|
|
229
|
+
levels: ListLevelInfo[];
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Reserved footnote/endnote IDs per ECMA-376.
|
|
233
|
+
*/
|
|
234
|
+
export declare const RESERVED_FOOTNOTE_IDS: {
|
|
235
|
+
/** Separator footnote */
|
|
236
|
+
readonly SEPARATOR: "0";
|
|
237
|
+
/** Continuation separator footnote */
|
|
238
|
+
readonly CONTINUATION_SEPARATOR: "1";
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Footnote reference information.
|
|
242
|
+
*/
|
|
243
|
+
export interface FootnoteReference {
|
|
244
|
+
/** XML ID from w:id attribute */
|
|
245
|
+
xmlId: string;
|
|
246
|
+
/** Whether this uses a custom mark (suppresses automatic numbering) */
|
|
247
|
+
customMarkFollows: boolean;
|
|
248
|
+
/** Display number (sequential order in document) */
|
|
249
|
+
displayNumber?: number;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Types of revisions that can be detected.
|
|
253
|
+
*/
|
|
254
|
+
export declare enum WmlComparerRevisionType {
|
|
255
|
+
/** Text was inserted */
|
|
256
|
+
Insertion = "Insertion",
|
|
257
|
+
/** Text was deleted */
|
|
258
|
+
Deletion = "Deletion",
|
|
259
|
+
/** Content was moved (source) */
|
|
260
|
+
MoveFrom = "MoveFrom",
|
|
261
|
+
/** Content was moved (destination) */
|
|
262
|
+
MoveTo = "MoveTo",
|
|
263
|
+
/** Formatting was changed */
|
|
264
|
+
FormatChanged = "FormatChanged"
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Details about a format change revision.
|
|
268
|
+
*/
|
|
269
|
+
export interface FormatChangeDetails {
|
|
270
|
+
/** Properties that were added */
|
|
271
|
+
addedProperties: string[];
|
|
272
|
+
/** Properties that were removed */
|
|
273
|
+
removedProperties: string[];
|
|
274
|
+
/** Properties that were modified */
|
|
275
|
+
changedProperties: string[];
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* A detected revision in the comparison output.
|
|
279
|
+
*/
|
|
280
|
+
export interface WmlComparerRevision {
|
|
281
|
+
/** Type of revision */
|
|
282
|
+
type: WmlComparerRevisionType;
|
|
283
|
+
/** Author of the revision */
|
|
284
|
+
author: string;
|
|
285
|
+
/** Timestamp of the revision */
|
|
286
|
+
date: Date;
|
|
287
|
+
/** Text content affected by the revision */
|
|
288
|
+
text: string;
|
|
289
|
+
/** Revision ID (w:id attribute) */
|
|
290
|
+
revisionId: number;
|
|
291
|
+
/** Move name if this is a move revision */
|
|
292
|
+
moveName?: string;
|
|
293
|
+
/** Format change details if this is a format change */
|
|
294
|
+
formatChangeDetails?: FormatChangeDetails;
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=core-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-types.d.ts","sourceRoot":"","sources":["../src/core-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;GAMG;AACH,oBAAY,iBAAiB;IAC3B,gDAAgD;IAChD,OAAO,YAAY;IACnB,wCAAwC;IACxC,KAAK,UAAU;IACf,yDAAyD;IACzD,OAAO,YAAY;IACnB,sDAAsD;IACtD,QAAQ,aAAa;IACrB,4DAA4D;IAC5D,WAAW,gBAAgB;IAC3B,+DAA+D;IAC/D,gBAAgB,qBAAqB;IACrC,kDAAkD;IAClD,aAAa,kBAAkB;CAChC;AAMD;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,yHAAyH;IACzH,WAAW,EAAE,MAAM,CAAC;CACrB;AAMD;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AAMjC;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBA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IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WmlComparer Core Data Structures
|
|
3
|
+
*
|
|
4
|
+
* TypeScript equivalents of WmlComparer's core C# data structures.
|
|
5
|
+
* These types form the foundation for the atomization pipeline that
|
|
6
|
+
* flattens OOXML into comparable units.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/OpenXmlDev/Open-Xml-PowerTools/blob/536ca1fb4bcdce1f4c920658bd66807b970393d7/OpenXmlPowerTools/WmlComparer.cs
|
|
9
|
+
*/
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Correlation Status Enum
|
|
12
|
+
// =============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Correlation status for comparison units.
|
|
15
|
+
*
|
|
16
|
+
* Tracks the result of comparing atoms between two documents.
|
|
17
|
+
*
|
|
18
|
+
* @see WmlComparer.cs line 2264
|
|
19
|
+
*/
|
|
20
|
+
export var CorrelationStatus;
|
|
21
|
+
(function (CorrelationStatus) {
|
|
22
|
+
/** Not yet processed by comparison algorithm */
|
|
23
|
+
CorrelationStatus["Unknown"] = "Unknown";
|
|
24
|
+
/** Content matches in both documents */
|
|
25
|
+
CorrelationStatus["Equal"] = "Equal";
|
|
26
|
+
/** Content only exists in original document (removed) */
|
|
27
|
+
CorrelationStatus["Deleted"] = "Deleted";
|
|
28
|
+
/** Content only exists in revised document (added) */
|
|
29
|
+
CorrelationStatus["Inserted"] = "Inserted";
|
|
30
|
+
/** Content was moved from this location (source of move) */
|
|
31
|
+
CorrelationStatus["MovedSource"] = "MovedSource";
|
|
32
|
+
/** Content was moved to this location (destination of move) */
|
|
33
|
+
CorrelationStatus["MovedDestination"] = "MovedDestination";
|
|
34
|
+
/** Text content matches but formatting differs */
|
|
35
|
+
CorrelationStatus["FormatChanged"] = "FormatChanged";
|
|
36
|
+
})(CorrelationStatus || (CorrelationStatus = {}));
|
|
37
|
+
/**
|
|
38
|
+
* Default settings for move detection.
|
|
39
|
+
*/
|
|
40
|
+
export const DEFAULT_MOVE_DETECTION_SETTINGS = {
|
|
41
|
+
detectMoves: true,
|
|
42
|
+
moveSimilarityThreshold: 0.8,
|
|
43
|
+
moveMinimumWordCount: 5,
|
|
44
|
+
caseInsensitiveMove: true,
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Default settings for format change detection.
|
|
48
|
+
*/
|
|
49
|
+
export const DEFAULT_FORMAT_DETECTION_SETTINGS = {
|
|
50
|
+
detectFormatChanges: true,
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Mapping of OOXML run property tag names to friendly names.
|
|
54
|
+
*/
|
|
55
|
+
export const RUN_PROPERTY_FRIENDLY_NAMES = {
|
|
56
|
+
'w:b': 'bold',
|
|
57
|
+
'w:bCs': 'boldComplex',
|
|
58
|
+
'w:i': 'italic',
|
|
59
|
+
'w:iCs': 'italicComplex',
|
|
60
|
+
'w:u': 'underline',
|
|
61
|
+
'w:strike': 'strikethrough',
|
|
62
|
+
'w:dstrike': 'doubleStrikethrough',
|
|
63
|
+
'w:sz': 'fontSize',
|
|
64
|
+
'w:szCs': 'fontSizeComplex',
|
|
65
|
+
'w:rFonts': 'font',
|
|
66
|
+
'w:color': 'color',
|
|
67
|
+
'w:highlight': 'highlight',
|
|
68
|
+
'w:shd': 'shading',
|
|
69
|
+
'w:vertAlign': 'verticalAlign',
|
|
70
|
+
'w:caps': 'allCaps',
|
|
71
|
+
'w:smallCaps': 'smallCaps',
|
|
72
|
+
'w:vanish': 'hidden',
|
|
73
|
+
'w:emboss': 'emboss',
|
|
74
|
+
'w:imprint': 'imprint',
|
|
75
|
+
'w:outline': 'outline',
|
|
76
|
+
'w:shadow': 'shadow',
|
|
77
|
+
'w:spacing': 'spacing',
|
|
78
|
+
'w:w': 'width',
|
|
79
|
+
'w:kern': 'kerning',
|
|
80
|
+
'w:position': 'position',
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Default comparison settings.
|
|
84
|
+
*/
|
|
85
|
+
export const DEFAULT_COMPARER_SETTINGS = {
|
|
86
|
+
...DEFAULT_MOVE_DETECTION_SETTINGS,
|
|
87
|
+
...DEFAULT_FORMAT_DETECTION_SETTINGS,
|
|
88
|
+
author: 'Comparison',
|
|
89
|
+
dateTime: new Date(),
|
|
90
|
+
};
|
|
91
|
+
// =============================================================================
|
|
92
|
+
// Footnote Numbering Types
|
|
93
|
+
// =============================================================================
|
|
94
|
+
/**
|
|
95
|
+
* Reserved footnote/endnote IDs per ECMA-376.
|
|
96
|
+
*/
|
|
97
|
+
export const RESERVED_FOOTNOTE_IDS = {
|
|
98
|
+
/** Separator footnote */
|
|
99
|
+
SEPARATOR: '0',
|
|
100
|
+
/** Continuation separator footnote */
|
|
101
|
+
CONTINUATION_SEPARATOR: '1',
|
|
102
|
+
};
|
|
103
|
+
// =============================================================================
|
|
104
|
+
// Revision Reporting Types
|
|
105
|
+
// =============================================================================
|
|
106
|
+
/**
|
|
107
|
+
* Types of revisions that can be detected.
|
|
108
|
+
*/
|
|
109
|
+
export var WmlComparerRevisionType;
|
|
110
|
+
(function (WmlComparerRevisionType) {
|
|
111
|
+
/** Text was inserted */
|
|
112
|
+
WmlComparerRevisionType["Insertion"] = "Insertion";
|
|
113
|
+
/** Text was deleted */
|
|
114
|
+
WmlComparerRevisionType["Deletion"] = "Deletion";
|
|
115
|
+
/** Content was moved (source) */
|
|
116
|
+
WmlComparerRevisionType["MoveFrom"] = "MoveFrom";
|
|
117
|
+
/** Content was moved (destination) */
|
|
118
|
+
WmlComparerRevisionType["MoveTo"] = "MoveTo";
|
|
119
|
+
/** Formatting was changed */
|
|
120
|
+
WmlComparerRevisionType["FormatChanged"] = "FormatChanged";
|
|
121
|
+
})(WmlComparerRevisionType || (WmlComparerRevisionType = {}));
|
|
122
|
+
//# sourceMappingURL=core-types.js.map
|
|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AW;IAC1B,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,SAAS;IACtB,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,SAAS;IACtB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,UAAU;CACzB,CAAC;AAkBF;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAwB;IAC5D,GAAG,+BAA+B;IAClC,GAAG,iCAAiC;IACpC,MAAM,EAAE,YAAY;IACpB,QAAQ,EAAE,IAAI,IAAI,EAAE;CACrB,CAAC;AA+CF,gFAAgF;AAChF,2BAA2B;AAC3B,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,yBAAyB;IACzB,SAAS,EAAE,GAAG;IACd,sCAAsC;IACtC,sBAAsB,EAAE,GAAG;CACnB,CAAC;AAcX,gFAAgF;AAChF,2BAA2B;AAC3B,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAN,IAAY,uBAWX;AAXD,WAAY,uBAAuB;IACjC,wBAAwB;IACxB,kDAAuB,CAAA;IACvB,uBAAuB;IACvB,gDAAqB,CAAA;IACrB,iCAAiC;IACjC,gDAAqB,CAAA;IACrB,sCAAsC;IACtC,4CAAiB,CAAA;IACjB,6BAA6B;IAC7B,0DAA+B,CAAA;AACjC,CAAC,EAXW,uBAAuB,KAAvB,uBAAuB,QAWlC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footnote Numbering Module
|
|
3
|
+
*
|
|
4
|
+
* Handles sequential footnote/endnote numbering by document order.
|
|
5
|
+
*
|
|
6
|
+
* Per ECMA-376, w:id on footnoteReference is a reference identifier, NOT the
|
|
7
|
+
* display number. Display numbers are sequential based on document order.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* Document has 91 footnotes with XML IDs 2-92 (IDs 0, 1 are reserved):
|
|
11
|
+
* - Incorrect: Display as 2, 3, 4, ..., 92
|
|
12
|
+
* - Correct: Display as 1, 2, 3, ..., 91
|
|
13
|
+
*/
|
|
14
|
+
import { FootnoteReference, WmlElement } from './core-types.js';
|
|
15
|
+
/**
|
|
16
|
+
* Find all footnote or endnote references in document order.
|
|
17
|
+
*
|
|
18
|
+
* Recursively traverses the document tree to find references in reading order.
|
|
19
|
+
*
|
|
20
|
+
* @param element - The root element to search from
|
|
21
|
+
* @param tagName - The reference tag to find ('w:footnoteReference' or 'w:endnoteReference')
|
|
22
|
+
* @returns Array of reference elements in document order
|
|
23
|
+
*/
|
|
24
|
+
export declare function findReferencesInOrder(element: WmlElement, tagName: 'w:footnoteReference' | 'w:endnoteReference'): WmlElement[];
|
|
25
|
+
/**
|
|
26
|
+
* Check if a footnote/endnote ID is reserved.
|
|
27
|
+
*
|
|
28
|
+
* IDs 0 and 1 are reserved for separator types per ECMA-376.
|
|
29
|
+
*
|
|
30
|
+
* @param xmlId - The XML ID to check
|
|
31
|
+
* @returns True if this is a reserved ID
|
|
32
|
+
*/
|
|
33
|
+
export declare function isReservedId(xmlId: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Tracks sequential footnote/endnote numbering by document order.
|
|
36
|
+
*
|
|
37
|
+
* Scans the document for footnote/endnote references and builds a mapping
|
|
38
|
+
* from XML IDs to display numbers.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const tracker = new FootnoteNumberingTracker(documentRoot);
|
|
42
|
+
* const displayNum = tracker.getDisplayNumber('42'); // Returns 1 if '42' is the first footnote
|
|
43
|
+
*/
|
|
44
|
+
export declare class FootnoteNumberingTracker {
|
|
45
|
+
private footnoteIdToDisplayNumber;
|
|
46
|
+
private endnoteIdToDisplayNumber;
|
|
47
|
+
private footnoteCustomMarks;
|
|
48
|
+
private endnoteCustomMarks;
|
|
49
|
+
/**
|
|
50
|
+
* Create a new tracker by scanning the document.
|
|
51
|
+
*
|
|
52
|
+
* @param documentRoot - The root element of the main document (w:document or w:body)
|
|
53
|
+
*/
|
|
54
|
+
constructor(documentRoot: WmlElement);
|
|
55
|
+
/**
|
|
56
|
+
* Scan the document for footnote and endnote references.
|
|
57
|
+
*/
|
|
58
|
+
private scanDocument;
|
|
59
|
+
/**
|
|
60
|
+
* Build the ID to display number mapping.
|
|
61
|
+
*/
|
|
62
|
+
private buildNumbering;
|
|
63
|
+
/**
|
|
64
|
+
* Get the display number for a footnote by its XML ID.
|
|
65
|
+
*
|
|
66
|
+
* @param xmlId - The XML ID (w:id attribute)
|
|
67
|
+
* @returns The display number, or undefined if not found or uses custom mark
|
|
68
|
+
*/
|
|
69
|
+
getFootnoteDisplayNumber(xmlId: string): number | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Get the display number for an endnote by its XML ID.
|
|
72
|
+
*
|
|
73
|
+
* @param xmlId - The XML ID (w:id attribute)
|
|
74
|
+
* @returns The display number, or undefined if not found or uses custom mark
|
|
75
|
+
*/
|
|
76
|
+
getEndnoteDisplayNumber(xmlId: string): number | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Get the display number for a footnote or endnote by its XML ID.
|
|
79
|
+
*
|
|
80
|
+
* Convenience method that checks both footnotes and endnotes.
|
|
81
|
+
*
|
|
82
|
+
* @param xmlId - The XML ID
|
|
83
|
+
* @returns The display number, or undefined if not found
|
|
84
|
+
*/
|
|
85
|
+
getDisplayNumber(xmlId: string): number | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Check if a footnote uses a custom mark.
|
|
88
|
+
*
|
|
89
|
+
* @param xmlId - The XML ID
|
|
90
|
+
* @returns True if this footnote has w:customMarkFollows
|
|
91
|
+
*/
|
|
92
|
+
hasFootnoteCustomMark(xmlId: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Check if an endnote uses a custom mark.
|
|
95
|
+
*
|
|
96
|
+
* @param xmlId - The XML ID
|
|
97
|
+
* @returns True if this endnote has w:customMarkFollows
|
|
98
|
+
*/
|
|
99
|
+
hasEndnoteCustomMark(xmlId: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Get the total number of footnotes (excluding custom marks).
|
|
102
|
+
*/
|
|
103
|
+
getFootnoteCount(): number;
|
|
104
|
+
/**
|
|
105
|
+
* Get the total number of endnotes (excluding custom marks).
|
|
106
|
+
*/
|
|
107
|
+
getEndnoteCount(): number;
|
|
108
|
+
/**
|
|
109
|
+
* Get all footnote references as structured data.
|
|
110
|
+
*
|
|
111
|
+
* @returns Array of FootnoteReference objects
|
|
112
|
+
*/
|
|
113
|
+
getFootnoteReferences(): FootnoteReference[];
|
|
114
|
+
/**
|
|
115
|
+
* Get all endnote references as structured data.
|
|
116
|
+
*
|
|
117
|
+
* @returns Array of FootnoteReference objects
|
|
118
|
+
*/
|
|
119
|
+
getEndnoteReferences(): FootnoteReference[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Find a footnote element by its ID in the footnotes.xml part.
|
|
123
|
+
*
|
|
124
|
+
* @param footnotesRoot - The root of the footnotes.xml document
|
|
125
|
+
* @param xmlId - The XML ID to find
|
|
126
|
+
* @returns The w:footnote element, or undefined if not found
|
|
127
|
+
*/
|
|
128
|
+
export declare function findFootnoteById(footnotesRoot: WmlElement, xmlId: string): WmlElement | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Find an endnote element by its ID in the endnotes.xml part.
|
|
131
|
+
*
|
|
132
|
+
* @param endnotesRoot - The root of the endnotes.xml document
|
|
133
|
+
* @param xmlId - The XML ID to find
|
|
134
|
+
* @returns The w:endnote element, or undefined if not found
|
|
135
|
+
*/
|
|
136
|
+
export declare function findEndnoteById(endnotesRoot: WmlElement, xmlId: string): WmlElement | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Extract plain text content from a footnote/endnote element.
|
|
139
|
+
*
|
|
140
|
+
* @param noteElement - The w:footnote or w:endnote element
|
|
141
|
+
* @returns Plain text content
|
|
142
|
+
*/
|
|
143
|
+
export declare function extractNoteText(noteElement: WmlElement): string;
|
|
144
|
+
//# sourceMappingURL=footnotes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footnotes.d.ts","sourceRoot":"","sources":["../src/footnotes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,iBAAiB,EAEjB,UAAU,EACX,MAAM,iBAAiB,CAAC;AAOzB;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,GACpD,UAAU,EAAE,CAcd;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAKnD;AAMD;;;;;;;;;GASG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,yBAAyB,CAAkC;IACnE,OAAO,CAAC,wBAAwB,CAAkC;IAClE,OAAO,CAAC,mBAAmB,CAA0B;IACrD,OAAO,CAAC,kBAAkB,CAA0B;IAEpD;;;;OAIG;gBACS,YAAY,EAAE,UAAU;IAIpC;;OAEG;IACH,OAAO,CAAC,YAAY;IAwBpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAmCtB;;;;;OAKG;IACH,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3D;;;;;OAKG;IACH,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI1D;;;;;;;OAOG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAOnD;;;;;OAKG;IACH,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI7C;;;;;OAKG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAI5C;;OAEG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;;;OAIG;IACH,qBAAqB,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