@docx4j/core-ts 0.5.0 → 0.6.0

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 (155) hide show
  1. package/NOTICE +4 -0
  2. package/README.md +32 -4
  3. package/dist/html/convert.mjs +2 -1
  4. package/dist/html/elements.mjs +2 -1
  5. package/dist/model/color/ColorMath.d.mts +29 -0
  6. package/dist/model/color/ColorMath.mjs +146 -0
  7. package/dist/model/color/ColorTables.d.mts +6 -0
  8. package/dist/model/color/ColorTables.mjs +83 -0
  9. package/dist/model/color/DrawingMLColors.d.mts +52 -0
  10. package/dist/model/color/DrawingMLColors.mjs +374 -0
  11. package/dist/model/color/ResolvedColor.d.mts +36 -0
  12. package/dist/model/color/ResolvedColor.mjs +65 -0
  13. package/dist/model/color/SpreadsheetColors.d.mts +36 -0
  14. package/dist/model/color/SpreadsheetColors.mjs +84 -0
  15. package/dist/model/color/StyleFill.d.mts +28 -0
  16. package/dist/model/color/StyleFill.mjs +21 -0
  17. package/dist/model/color/ThemeColors.d.mts +86 -0
  18. package/dist/model/color/ThemeColors.mjs +304 -0
  19. package/dist/model/color/WordColors.d.mts +71 -0
  20. package/dist/model/color/WordColors.mjs +121 -0
  21. package/dist/model/color/index.d.mts +6 -0
  22. package/dist/model/color/index.mjs +30 -0
  23. package/dist/model/content/Body.d.mts +145 -23
  24. package/dist/model/content/Body.mjs +509 -141
  25. package/dist/model/content/Comment.d.mts +21 -3
  26. package/dist/model/content/Comment.mjs +195 -19
  27. package/dist/model/content/ContentControl.d.mts +197 -18
  28. package/dist/model/content/ContentControl.mjs +664 -95
  29. package/dist/model/content/Font.d.mts +67 -17
  30. package/dist/model/content/Font.mjs +114 -35
  31. package/dist/model/content/InlinePicture.d.mts +11 -0
  32. package/dist/model/content/InlinePicture.mjs +21 -1
  33. package/dist/model/content/List.mjs +3 -0
  34. package/dist/model/content/Paragraph.d.mts +189 -13
  35. package/dist/model/content/Paragraph.mjs +870 -74
  36. package/dist/model/content/Range.d.mts +227 -12
  37. package/dist/model/content/Range.mjs +785 -59
  38. package/dist/model/content/ResolvedView.d.mts +104 -0
  39. package/dist/model/content/ResolvedView.mjs +596 -0
  40. package/dist/model/content/Table.d.mts +29 -3
  41. package/dist/model/content/Table.mjs +109 -33
  42. package/dist/model/content/TrackedChange.d.mts +172 -13
  43. package/dist/model/content/TrackedChange.mjs +728 -167
  44. package/dist/model/content/comments.d.mts +20 -6
  45. package/dist/model/content/comments.mjs +67 -57
  46. package/dist/model/content/generalException.d.mts +18 -0
  47. package/dist/model/content/generalException.mjs +24 -0
  48. package/dist/model/content/index.d.mts +8 -3
  49. package/dist/model/content/index.mjs +7 -2
  50. package/dist/model/content/mathText.d.mts +21 -0
  51. package/dist/model/content/mathText.mjs +267 -0
  52. package/dist/model/content/officeText.d.mts +27 -0
  53. package/dist/model/content/officeText.mjs +74 -0
  54. package/dist/model/content/outline.d.mts +5 -0
  55. package/dist/model/content/outline.mjs +13 -0
  56. package/dist/model/content/placeholders.d.mts +110 -0
  57. package/dist/model/content/placeholders.mjs +253 -0
  58. package/dist/model/content/search.d.mts +72 -0
  59. package/dist/model/content/search.mjs +204 -2
  60. package/dist/model/content/spanEdits.d.mts +159 -0
  61. package/dist/model/content/spanEdits.mjs +728 -0
  62. package/dist/model/content/story.d.mts +44 -0
  63. package/dist/model/content/story.mjs +92 -0
  64. package/dist/model/content/tableColumns.d.mts +1 -1
  65. package/dist/model/content/tableColumns.mjs +108 -80
  66. package/dist/model/content/tableRevisions.d.mts +11 -3
  67. package/dist/model/content/tableRevisions.mjs +72 -42
  68. package/dist/model/content/tableRules.d.mts +30 -0
  69. package/dist/model/content/tableRules.mjs +100 -0
  70. package/dist/model/content/textBoxes.d.mts +18 -0
  71. package/dist/model/content/textBoxes.mjs +105 -0
  72. package/dist/model/content/trackedChangeFilter.d.mts +39 -0
  73. package/dist/model/content/trackedChangeFilter.mjs +81 -0
  74. package/dist/model/content/tracking.d.mts +28 -0
  75. package/dist/model/content/tracking.mjs +149 -10
  76. package/dist/model/content/tree.d.mts +171 -22
  77. package/dist/model/content/tree.mjs +329 -53
  78. package/dist/model/customxml/CustomXmlPartCollection.d.mts +8 -0
  79. package/dist/model/customxml/CustomXmlPartCollection.mjs +34 -11
  80. package/dist/model/customxml/XmlMapping.d.mts +1 -1
  81. package/dist/model/customxml/XmlMapping.mjs +11 -0
  82. package/dist/model/customxml/bindings.d.mts +21 -2
  83. package/dist/model/customxml/bindings.mjs +76 -32
  84. package/dist/model/customxml/kinds.d.mts +8 -3
  85. package/dist/model/customxml/kinds.mjs +26 -5
  86. package/dist/model/customxml/picturePlaceholder.d.mts +17 -0
  87. package/dist/model/customxml/picturePlaceholder.mjs +32 -0
  88. package/dist/model/customxml/pictures.d.mts +4 -3
  89. package/dist/model/customxml/pictures.mjs +18 -6
  90. package/dist/model/customxml/xhtml.mjs +8 -2
  91. package/dist/model/index.d.mts +2 -0
  92. package/dist/model/index.mjs +4 -0
  93. package/dist/model/listnumbering/Emulator.d.mts +37 -5
  94. package/dist/model/listnumbering/Emulator.mjs +63 -9
  95. package/dist/model/properties/PropertyResolver.d.mts +60 -1
  96. package/dist/model/properties/PropertyResolver.mjs +115 -2
  97. package/dist/model/properties/catalogue.d.mts +19 -5
  98. package/dist/model/properties/catalogue.mjs +41 -15
  99. package/dist/model/properties/log.d.mts +1 -1
  100. package/dist/model/properties/log.mjs +5 -5
  101. package/dist/model/properties/table.mjs +4 -2
  102. package/dist/model/text/Extractor.d.mts +289 -0
  103. package/dist/model/text/Extractor.mjs +2162 -0
  104. package/dist/model/text/LinkTargets.d.mts +45 -0
  105. package/dist/model/text/LinkTargets.mjs +170 -0
  106. package/dist/model/text/MarkdownExporter.d.mts +140 -0
  107. package/dist/model/text/MarkdownExporter.mjs +255 -0
  108. package/dist/model/text/PlainText.d.mts +29 -0
  109. package/dist/model/text/PlainText.mjs +539 -0
  110. package/dist/model/text/TextContext.d.mts +161 -0
  111. package/dist/model/text/TextContext.mjs +425 -0
  112. package/dist/model/text/TextOptions.d.mts +150 -0
  113. package/dist/model/text/TextOptions.mjs +278 -0
  114. package/dist/model/text/TextResult.d.mts +504 -0
  115. package/dist/model/text/TextResult.mjs +526 -0
  116. package/dist/model/text/Texts.d.mts +99 -0
  117. package/dist/model/text/Texts.mjs +187 -0
  118. package/dist/model/text/WmlToMarkdown.d.mts +120 -0
  119. package/dist/model/text/WmlToMarkdown.mjs +911 -0
  120. package/dist/model/text/commonmark.d.mts +121 -0
  121. package/dist/model/text/commonmark.mjs +655 -0
  122. package/dist/model/text/index.d.mts +7 -0
  123. package/dist/model/text/index.mjs +8 -0
  124. package/dist/model/text/normalize.d.mts +8 -0
  125. package/dist/model/text/normalize.mjs +13 -0
  126. package/dist/model/text/outline.d.mts +4 -0
  127. package/dist/model/text/outline.mjs +71 -0
  128. package/dist/office-js/fragment.d.mts +7 -5
  129. package/dist/office-js/fragment.mjs +63 -14
  130. package/dist/office-js/proxy.d.mts +8 -0
  131. package/dist/office-js/proxy.mjs +29 -0
  132. package/dist/office-js/run.mjs +2 -0
  133. package/dist/office-js/supported.generated.mjs +16 -0
  134. package/dist/office-js/toApiScript.mjs +21 -5
  135. package/dist/opc/Save.d.mts +17 -0
  136. package/dist/opc/Save.mjs +12 -2
  137. package/dist/opc/index.d.mts +3 -3
  138. package/dist/opc/index.mjs +1 -1
  139. package/dist/opc/mce/preprocessor.d.mts +28 -3
  140. package/dist/opc/mce/preprocessor.mjs +4 -4
  141. package/dist/opc/mce/understood.d.mts +30 -6
  142. package/dist/opc/mce/understood.mjs +37 -7
  143. package/dist/packages/OpcPackage.d.mts +13 -0
  144. package/dist/packages/OpcPackage.mjs +1 -0
  145. package/dist/packages/WordprocessingMLPackage.d.mts +45 -8
  146. package/dist/packages/WordprocessingMLPackage.mjs +155 -20
  147. package/dist/parts/DefaultXmlPart.mjs +2 -2
  148. package/dist/parts/Part.d.mts +10 -2
  149. package/dist/parts/XmlPart.d.mts +12 -30
  150. package/dist/parts/XmlPart.mjs +44 -93
  151. package/dist/parts/wml/comments.mjs +30 -0
  152. package/dist/parts/wml/index.mjs +12 -0
  153. package/dist/xml/dom.d.mts +7 -0
  154. package/dist/xml/dom.mjs +18 -0
  155. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { WordColors } from '../color/WordColors.mjs';
1
2
  // ---------------------------------------------------------------- copying
2
3
  /**
3
4
  * A structural copy of a leaf value, without its `PARENT` link: what the merges store, so
@@ -36,6 +37,15 @@ function attr(source, destination) {
36
37
  function statesColour(val, theme) {
37
38
  return !emptyString(val) || !emptyThemeColor(theme);
38
39
  }
40
+ /**
41
+ * docx4j `StyleUtil.statesWordColour` (its CR-060, 1d1b824a9): as {@link statesColour}, for a text or underline
42
+ * colour, whose value Word reads as absent where it rejects it ({@link WordColors.stated}: `F00`, `bogus`, `Auto`).
43
+ * A fill's or a border's colour keeps {@link statesColour}: Word reads any value there, one it rejects as automatic,
44
+ * which overrides a style's (CR-015 section 2, rule 5).
45
+ */
46
+ function statesWordColour(val, theme) {
47
+ return WordColors.stated(val) || !emptyThemeColor(theme);
48
+ }
39
49
  /** A merge with no per-attribute rule: a copy of the source where it has one, else the inherited. */
40
50
  export function mergeReplace(source, destination) {
41
51
  return source === undefined ? destination : copyLeaf(source);
@@ -76,21 +86,37 @@ export function isEmptyRFonts(value) {
76
86
  }
77
87
  /**
78
88
  * A `w:color` stating only a theme colour is not empty: it is inherited, where until docx4j CR-034
79
- * (2e381ef26) it was dropped.
89
+ * (2e381ef26) it was dropped. A value Word reads as absent (`F00`, `bogus`, `Auto`) is empty, so a style's
90
+ * colour beneath still shows, and only exactly `auto` overrides it (docx4j CR-060, {@link WordColors.stated};
91
+ * CR-015 section 2, rules 4 and 5).
80
92
  */
81
93
  export function isEmptyColor(value) {
82
94
  return value === undefined
83
- || (emptyString(value.val) && value.themeColor === undefined
95
+ || (!WordColors.stated(value.val) && value.themeColor === undefined
84
96
  && emptyString(value.themeTint) && emptyString(value.themeShade));
85
97
  }
86
- /** The underline's colour attributes count, the theme ones too (docx4j CR-034, 2e381ef26). */
98
+ /**
99
+ * The underline's colour attributes count, the theme ones too (docx4j CR-034, 2e381ef26); a colour Word reads as
100
+ * absent doesn't (docx4j CR-060, {@link WordColors.stated}).
101
+ */
87
102
  export function isEmptyU(value) {
88
103
  return value === undefined
89
- || (value.val === undefined && emptyString(value.color) && value.themeColor === undefined
104
+ || (value.val === undefined && !WordColors.stated(value.color) && value.themeColor === undefined
90
105
  && emptyString(value.themeTint) && emptyString(value.themeShade));
91
106
  }
107
+ /** `ST_HighlightColor`'s values, which Word compares case-exactly (docx4j `WordRepairs`). */
108
+ const HIGHLIGHT_COLORS = new Set(['black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow',
109
+ 'white', 'darkBlue', 'darkCyan', 'darkGreen', 'darkMagenta', 'darkRed', 'darkYellow', 'darkGray', 'lightGray', 'none']);
110
+ /** Whether a `w:highlight` value is one of `ST_HighlightColor`'s, compared case-exactly, as Word does (docx4j `WordRepairs.isHighlightColor`). */
111
+ export function isHighlightColor(val) {
112
+ return val !== undefined && HIGHLIGHT_COLORS.has(val);
113
+ }
114
+ /**
115
+ * A value outside `ST_HighlightColor` (`YELLOW`, `bogus`), or none, is empty: Word's repair drops it, so a style's
116
+ * highlight beneath still shows (docx4j CR-060, its `StyleUtil.isEmpty(Highlight)`).
117
+ */
92
118
  export function isEmptyHighlight(value) {
93
- return value === undefined || emptyString(value.val);
119
+ return value === undefined || !isHighlightColor(value.val);
94
120
  }
95
121
  /** @since CR-015 phase 1: a style stating only `w:lang` used to count as empty and was never applied. */
96
122
  export function isEmptyLang(value) {
@@ -151,16 +177,18 @@ export function isEmptyNumPr(value) {
151
177
  || ((value.numId === undefined || value.numId.val === undefined)
152
178
  && (value.ilvl === undefined || value.ilvl.val === undefined));
153
179
  }
154
- /** `w:anchorLock` defaults to true, so only an explicit `w:anchorLock="0"` makes a frame non-empty by itself. */
180
+ /**
181
+ * Empty only with `w:anchorLock` absent too, as docx4j 82c64bf14 reads it (its CR-059: until then
182
+ * `isAnchorLock()`, which the schema's old `default="true"` made true for an absent attribute).
183
+ */
155
184
  export function isEmptyFramePr(value) {
156
- var _a;
157
185
  return value === undefined
158
186
  || (value.dropCap === undefined && value.lines === undefined && value.w === undefined
159
187
  && value.h === undefined && value.vSpace === undefined && value.hSpace === undefined
160
188
  && value.wrap === undefined && value.hAnchor === undefined && value.vAnchor === undefined
161
189
  && value.x === undefined && value.xAlign === undefined
162
190
  && value.y === undefined && value.yAlign === undefined && value.hRule === undefined
163
- && ((_a = value.anchorLock) !== null && _a !== void 0 ? _a : true));
191
+ && value.anchorLock === undefined);
164
192
  }
165
193
  function isEmptyTblWidth(value) {
166
194
  // @w:type is ignored, as docx4j does
@@ -317,7 +345,7 @@ export const mergeColor = (source, destination) => {
317
345
  return destination;
318
346
  const s = source;
319
347
  const out = (destination !== null && destination !== void 0 ? destination : {});
320
- if (statesColour(s.val, s.themeColor)) {
348
+ if (statesWordColour(s.val, s.themeColor)) {
321
349
  out.val = s.val;
322
350
  out.themeColor = s.themeColor;
323
351
  out.themeTint = s.themeTint;
@@ -336,7 +364,7 @@ export const mergeU = (source, destination) => {
336
364
  const s = source;
337
365
  const out = destination !== null && destination !== void 0 ? destination : {};
338
366
  out.val = attr(s.val, out.val);
339
- if (statesColour(s.color, s.themeColor)) {
367
+ if (statesWordColour(s.color, s.themeColor)) {
340
368
  out.color = s.color;
341
369
  out.themeColor = s.themeColor;
342
370
  out.themeTint = s.themeTint;
@@ -536,11 +564,10 @@ export const mergeTabs = (source, destination) => {
536
564
  };
537
565
  /**
538
566
  * `w:framePr`'s attributes each inherit on their own: a paragraph whose direct `w:framePr`
539
- * gives only `w:x`/`w:y` keeps the anchors its style states. `w:anchorLock` defaults to true,
540
- * and docx4j's merge writes that default out explicitly.
567
+ * gives only `w:x`/`w:y` keeps the anchors its style states, `w:anchorLock` among them (docx4j
568
+ * 82c64bf14 merges it as stated; until then its merge wrote `isAnchorLock()`'s default out).
541
569
  */
542
570
  export const mergeFramePr = (source, destination) => {
543
- var _a;
544
571
  if (isEmptyFramePr(source))
545
572
  return destination;
546
573
  const s = source;
@@ -559,8 +586,7 @@ export const mergeFramePr = (source, destination) => {
559
586
  out.y = attr(s.y, out.y);
560
587
  out.yAlign = attr(s.yAlign, out.yAlign);
561
588
  out.hRule = attr(s.hRule, out.hRule);
562
- // docx4j reads this through isAnchorLock(), which answers true when the attribute is absent
563
- out.anchorLock = (_a = s.anchorLock) !== null && _a !== void 0 ? _a : true;
589
+ out.anchorLock = attr(s.anchorLock, out.anchorLock);
564
590
  return out;
565
591
  };
566
592
  const mergeTblWidth = (source, destination) => {
@@ -1,7 +1,7 @@
1
1
  export interface Logger {
2
2
  warn(message: string): void;
3
3
  }
4
- /** The logger property resolution writes to. */
4
+ /** The logger property resolution and the Markdown export write to. */
5
5
  export declare const log: Logger;
6
6
  /** Replaces the sink; pass nothing to go back to `console.warn`. */
7
7
  export declare function setLogger(logger?: Logger): void;
@@ -1,7 +1,7 @@
1
- // The one place property resolution writes a diagnostic. docx4j logs through SLF4J; this
2
- // package has no logging framework, so a missing style or a style cycle goes to `console.warn`
3
- // behind a settable sink (an add-in that must stay silent, or a test that wants to assert what
4
- // was logged, replaces it).
1
+ // The one place property resolution writes a diagnostic, and the Markdown export a refused link
2
+ // target (CR-012 section 21). docx4j logs through SLF4J; this package has no logging framework, so
3
+ // a missing style, a style cycle or a refused link goes to `console.warn` behind a settable sink
4
+ // (an add-in that must stay silent, or a test that wants to assert what was logged, replaces it).
5
5
  //
6
6
  // Resolution logs a missing style *once per id* (a `w:pStyle` naming a deleted style is common
7
7
  // in real documents, and docx4j used to log one ERROR per paragraph); the resolver keeps that
@@ -13,7 +13,7 @@ const consoleLogger = {
13
13
  },
14
14
  };
15
15
  let sink = consoleLogger;
16
- /** The logger property resolution writes to. */
16
+ /** The logger property resolution and the Markdown export write to. */
17
17
  export const log = {
18
18
  warn(message) {
19
19
  sink.warn(message);
@@ -110,14 +110,16 @@ export class TableContext {
110
110
  this.look = DEFAULT_LOOK;
111
111
  this.rowBandSize = (tblPr === null || tblPr === void 0 ? void 0 : tblPr.tblStyleRowBandSize) !== undefined ? rowBandSize(tblPr) : rowBandSize(stylePr);
112
112
  this.colBandSize = (tblPr === null || tblPr === void 0 ? void 0 : tblPr.tblStyleColBandSize) !== undefined ? colBandSize(tblPr) : colBandSize(stylePr);
113
- const rows = rowsOf(tbl);
113
+ // the rows and cells Word reads: a kept row- or cell-level mc:AlternateContent's selected branch (CR-013
114
+ // phase 2), so that its rows count for the first row, the last and the bands
115
+ const rows = rowsOf(tbl, 'read');
114
116
  let cols = 0;
115
117
  rows.forEach((located, r) => {
116
118
  var _a, _b;
117
119
  const tr = located.element.value;
118
120
  this.rowIndex.set(tr, r);
119
121
  let c = gridOf(tr, 'gridBefore');
120
- for (const cell of cellsOf(tr)) {
122
+ for (const cell of cellsOf(tr, 'read')) {
121
123
  const tc = cell.element.value;
122
124
  const val = (_b = (_a = tc.tcPr) === null || _a === void 0 ? void 0 : _a.gridSpan) === null || _b === void 0 ? void 0 : _b.val;
123
125
  const span = typeof val === 'number' ? Math.max(1, Math.trunc(val)) : 1;
@@ -0,0 +1,289 @@
1
+ import type * as wml from '@docx4j/generated-objects-ts/modules/org_docx4j_wml';
2
+ import type { Part } from '../../parts/Part.mjs';
3
+ import type { PropertyResolver } from '../properties/PropertyResolver.mjs';
4
+ import type { NumberingState } from '../listnumbering/state.mjs';
5
+ import { type Element } from '../content/tree.mjs';
6
+ import type { ResolvedView } from '../content/ResolvedView.mjs';
7
+ import type { TextOptions, TextModelView } from './TextOptions.mjs';
8
+ import { TextBlock, TextRun, TextRevision, TextWarning, TextResult, type TextStory, type NoteType } from './TextResult.mjs';
9
+ import { type TextContext, type PackageTrees } from './TextContext.mjs';
10
+ /** How the view is read (docx4j `Extractor.Mode`). */
11
+ export type ExtractorMode =
12
+ /** The view's rules: a plan for accepted and original, revisions marked for markup. */
13
+ 'view'
14
+ /** A package already resolved by Accept All or Reject All (the copy route, REQ-406): no view logic. */
15
+ | 'resolved'
16
+ /** Content with no package to plan over: run-level revisions only, no joins or moves. */
17
+ | 'planless';
18
+ interface OfficeSpan {
19
+ offset: number;
20
+ length: number;
21
+ }
22
+ /** An open complex field. */
23
+ declare class FieldState {
24
+ instr: string;
25
+ result: string;
26
+ separated: boolean;
27
+ /** `w:fldLock` on its beginning: never recomputed (REQ-506). */
28
+ locked: boolean;
29
+ /** Its result computed under `fields: update` (REQ-506): the cached result's text is not read. */
30
+ computed: string | undefined;
31
+ /** A HYPERLINK field's target, once its code is read (REQ-703). */
32
+ link: string | undefined;
33
+ /** A table of contents under `toc: false` (D12): nothing of it is read. */
34
+ toc: boolean;
35
+ /** Where its code's runs begin, for a table of contents' to be taken out again. */
36
+ codeBlock: TextBlock | undefined;
37
+ codeStart: number;
38
+ /** The paragraph whose merge floor its code raised, and the floor before. */
39
+ floorParagraph: ParagraphState | undefined;
40
+ previousFloor: number;
41
+ /** The field as a block after the one it began in starts inside it: its code's block and paragraph left behind. */
42
+ copy(): FieldState;
43
+ }
44
+ /** The complex fields open where a container's blocks begin, by the block's index (`Extractor.fieldsAtBlocks`). */
45
+ export type BlockStarts = ReadonlyMap<number, readonly FieldState[]>;
46
+ /** The state of a run-level walk: the revision and the control the runs are in. */
47
+ declare class RunState {
48
+ /** markup: the innermost revision; else undefined. */
49
+ readonly revision: TextRevision | undefined;
50
+ /** accepted, original: inside a revision holder the view keeps (its runs are text whatever their elements). */
51
+ readonly kept: boolean;
52
+ readonly placeholder: boolean;
53
+ constructor(
54
+ /** markup: the innermost revision; else undefined. */
55
+ revision: TextRevision | undefined,
56
+ /** accepted, original: inside a revision holder the view keeps (its runs are text whatever their elements). */
57
+ kept: boolean, placeholder: boolean);
58
+ withRevision(r: TextRevision | undefined, kept: boolean): RunState;
59
+ withPlaceholder(): RunState;
60
+ }
61
+ /** What follows its anchoring paragraph, or the table its anchor is in (REQ-511, REQ-518): a text box, legacy WordArt. */
62
+ interface Anchored {
63
+ prefix: string;
64
+ emit(x: Extractor, anchoring: Story, sink: TextBlock[]): void;
65
+ }
66
+ /** The walk of one story. */
67
+ declare class Story {
68
+ private readonly x;
69
+ readonly kind: TextStory;
70
+ readonly prefix: string;
71
+ readonly part: Part | undefined;
72
+ /** Open complex fields; [0] is the innermost (docx4j's deque head). */
73
+ readonly fields: FieldState[];
74
+ /** What was anchored since the last flush, to follow its anchor (or its table). */
75
+ readonly pending: Anchored[];
76
+ tableDepth: number;
77
+ /** The sections ended so far (the main story only). */
78
+ sections: (wml.SectPr | undefined)[] | undefined;
79
+ noteType: NoteType | undefined;
80
+ noteNumber: number;
81
+ noteId: string | undefined;
82
+ private numberingState;
83
+ constructor(x: Extractor, kind: TextStory, prefix: string, part: Part | undefined);
84
+ /** The resolver the walk reads styles with, for `officeSpans`' hidden rule. */
85
+ get resolver(): PropertyResolver | undefined;
86
+ numbering(): NumberingState;
87
+ }
88
+ /** A paragraph being read: the block its runs go to, its address, what it anchored so far. */
89
+ declare class ParagraphState {
90
+ readonly block: TextBlock;
91
+ readonly p: wml.P;
92
+ readonly address: string;
93
+ readonly story: Story;
94
+ boxes: number;
95
+ charts: number;
96
+ smartArts: number;
97
+ objects: number;
98
+ /** Whether every run with text so far is in a monospaced font; undefined before the first. */
99
+ monospace: boolean | undefined;
100
+ /** The formatting of the run being read (a run carrying only it), or undefined outside a run. */
101
+ format: TextRun | undefined;
102
+ /** The target of the `w:hyperlink` being read. */
103
+ link: string | undefined;
104
+ /** An equation being written, and whether it is a display one. */
105
+ math: boolean;
106
+ displayMath: boolean;
107
+ /** Whether a table of contents left out (D12) is in the paragraph. */
108
+ toc: boolean;
109
+ /** The first of the block's runs a run may be merged into: a field's code starts a run of its own where it may be taken out. */
110
+ mergeFloor: number;
111
+ private office;
112
+ constructor(block: TextBlock, p: wml.P, address: string, story: Story);
113
+ /** Where an item's text is in this paragraph's `Paragraph.text`. */
114
+ officeSpan(item: Element): OfficeSpan | undefined;
115
+ }
116
+ /**
117
+ * The text model's walk (CR-046 section 2.3): `scope(view(resolve(package)))` in one pass over the
118
+ * unresolved tree, producing the block model. docx4j `Extractor`, over trees read before it starts.
119
+ */
120
+ export declare class Extractor {
121
+ readonly trees: PackageTrees;
122
+ readonly options: TextOptions;
123
+ readonly context: TextContext;
124
+ readonly view: TextModelView;
125
+ readonly mode: ExtractorMode;
126
+ /** What a view removes and joins; undefined in markup, and in the resolved and planless modes. */
127
+ readonly plan: ResolvedView | undefined;
128
+ readonly resolver: PropertyResolver | undefined;
129
+ readonly warnings: TextWarning[];
130
+ private readonly warned;
131
+ /** What every address this extraction makes starts with. */
132
+ root: string;
133
+ /** The run properties a paragraph style and character style give, by their ids. */
134
+ private readonly styleRPrCache;
135
+ /** Bookmarks open in the walk, by id (REQ-506's REF, phase 5a). */
136
+ private readonly openBookmarks;
137
+ /** `fieldsAtBlocks`' walk: paragraphs read for their field characters and instructions alone, nothing emitted. */
138
+ private fieldsOnly;
139
+ constructor(trees: PackageTrees, options: TextOptions, mode: ExtractorMode, context: TextContext);
140
+ extract(): TextResult;
141
+ /** The result's metadata: `fields_update_on_open` and the document properties (REQ-801, REQ-515). */
142
+ private metadata;
143
+ private fieldsUpdateOnOpen;
144
+ commentsIncluded(): boolean;
145
+ /** A part's or object's content as one story (`Texts.of(part)`, `Texts.of(pkg, content)`). */
146
+ extractContent(content: unknown, kind: TextStory, prefix: string, part: Part | undefined): TextResult;
147
+ /** The notes of one kind, in the context's reference order (`Texts.of(notesPart)`). */
148
+ extractNotes(type: NoteType): TextResult;
149
+ /** The comments (`Texts.of(commentsPart)`): what the view includes, in the comments part's order. */
150
+ extractComments(): TextResult;
151
+ private glossary;
152
+ /** Block-level content into `sink`: paragraphs (joined in a view), tables, and what is transparent. */
153
+ blocks(items: Element[] | undefined, prefix: string, story: Story, sink: TextBlock[], state?: RunState): void;
154
+ /** A paragraph chain whose deleted mark has a table next: it joins the table's first cell's first paragraph (docx4j CR-043 section 17). */
155
+ private pendingTableJoin;
156
+ /** The block at `items[i]` into `sink`, with the paragraphs a view joins to it; the index of the last item it took. */
157
+ private block;
158
+ /**
159
+ * Some of a container's blocks, by their indices, each as `extractContent` reads it in the whole: a
160
+ * paragraph the view joins to one before it gives nothing (its text is in that one's block), and each
161
+ * block starts inside the complex fields open where it begins (`starts`, from `fieldsAtBlocks`), so that
162
+ * a table of contents left out (D12) is left out here too. Each block is read as a story of its own.
163
+ */
164
+ extractBlocks(content: unknown, kind: TextStory, prefix: string, part: Part | undefined, indices: readonly number[], starts: BlockStarts): TextResult;
165
+ /**
166
+ * The complex fields open where each of a container's blocks begins, for `extractBlocks`: a walk of the
167
+ * blocks reading field characters and instructions alone (`fieldsOnly`), as the whole walk reads them.
168
+ * Blocks with none open are not in the map. Its own context and warnings, so the reading leaves no trace.
169
+ */
170
+ static fieldsAtBlocks(trees: PackageTrees, options: TextOptions, mode: ExtractorMode, context: TextContext, content: unknown, kind: TextStory, prefix: string, part: Part | undefined): BlockStarts;
171
+ /** Whether the view joins the paragraph at `items[i]` to one before it: the item before it, past markers and what the view removes, is a paragraph whose mark goes. */
172
+ private joinedFromBefore;
173
+ /** The index of the paragraph a paragraph joins: the next in the list past markers and what the view removes, or -1. */
174
+ private nextParagraph;
175
+ private paragraph;
176
+ private endSection;
177
+ private flushIfOutsideTable;
178
+ /** An `altChunk`: not expanded until CR-012 phase 5e, which raises `altchunk.not_expanded` with its content type. */
179
+ private altChunk;
180
+ /**
181
+ * A plain-text control's bound value where its binding resolves and is what Word shows: not where the
182
+ * value is empty and the control shows its placeholder, nor under `bindings: surface`. Undefined to read
183
+ * the surface. Raises `sdt.binding_differs` where the two differ.
184
+ */
185
+ private bound;
186
+ /**
187
+ * A control's surface in the view: its `w:t`, tabs and breaks, what the view removes left out, and of an
188
+ * mc:AlternateContent the selected branch only, as the reading takes it (CR-013: every branch's text
189
+ * made a surface no binding could match, and a false `sdt.binding_differs`).
190
+ */
191
+ private surfaceText;
192
+ private bookmark;
193
+ private properties;
194
+ /**
195
+ * A paragraph's numbering from its effective `w:numPr` and the numbering definitions; undefined for none,
196
+ * for `w:numId` 0, and where Word gives the paragraph no number: a `w:numId` its style brought, whose
197
+ * level belongs to another paragraph style (`Emulator.levelStyleId`, REQ-510).
198
+ */
199
+ private numbering;
200
+ /** Whether the level belongs to a paragraph style that is neither the paragraph's nor one its style is based on. */
201
+ private linkedElsewhere;
202
+ /** The paragraph counted in its story's numbering state; undefined where it is not numbered. */
203
+ private count;
204
+ private table;
205
+ private rows;
206
+ private cells;
207
+ private runs;
208
+ private holderState;
209
+ private run;
210
+ private runItem;
211
+ /** Document text: a field's code where a field is in its code (shown only under `field_codes`), else text. */
212
+ private text;
213
+ private addText;
214
+ private endField;
215
+ private simpleField;
216
+ /** The runs of a simple field's result, added to the paragraph; their text. */
217
+ private resultOf;
218
+ /**
219
+ * An equation, `$...$` (`$$...$$` for an `m:oMathPara`). Until CR-012 phase 5b ports a LaTeX converter
220
+ * it is its `m:t` text in document order inside the delimiters, REQ-604's form for an equation that
221
+ * can't be converted. In markup, an equation with tracked changes is its Reject All form deleted and
222
+ * its Accept All form inserted, each as the plan for that view leaves it.
223
+ */
224
+ private math;
225
+ private mathText;
226
+ /** The view's rule for an equation's list members: what the plan removes goes; without a plan, a revision by its type. */
227
+ private keepMathInView;
228
+ /**
229
+ * What a run's drawing, picture or object holds, in document order, branches selected: text boxes and
230
+ * WordArt to follow the paragraph; pictures and objects as runs where they are. A chart or SmartArt
231
+ * contributes nothing until CR-012 phase 5c.
232
+ */
233
+ private anchored;
234
+ /** A `wp:inline` or `wp:anchor`: a chart, SmartArt, a picture, or a shape to walk into. */
235
+ private graphic;
236
+ /** A VML shape: legacy WordArt, a picture, or a shape to walk into for its text box. */
237
+ private vmlShape;
238
+ /** A `w:object`: an object run with its ProgID (REQ-512); its package is read under `embedded: true`, phase 5d. */
239
+ private object;
240
+ /**
241
+ * A DrawingML picture: its `wp:docPr` (or a nested picture's `pic:cNvPr`). `descr` and `title` are the
242
+ * schema's default, `''`, where the element doesn't give them, as docx4j's JAXB getters read them (CR-012
243
+ * section 20).
244
+ */
245
+ private image;
246
+ private imageOf;
247
+ /**
248
+ * `mce.branches_differ` (REQ-307): where the selected branch and another both hold text, and the texts
249
+ * differ after REQ-1201's normalisation. A branch's text is every `w:t`, `m:t` and `a:t` in it, whatever
250
+ * the view and hidden or not, as docx4j reads it: a comparison made at load knows no view, and a branch
251
+ * that differs only in hidden or deleted text is one an agent should hear of (Jason, 2026-10-21, for WD
252
+ * 0.29; CR-012 section 15.6).
253
+ */
254
+ private compareBranches;
255
+ warn(w: TextWarning): void;
256
+ private sectionsWithHeaders;
257
+ private headerOrFooter;
258
+ /** A header or footer part's content as its own story (`Texts.of(headerPart)`). */
259
+ headerOrFooterPart(part: Part, kind: 'HEADER' | 'FOOTER', rId: string): TextResult;
260
+ private notes;
261
+ private comments;
262
+ /** Whether the view removes a list member (always false in markup and on a resolved copy). */
263
+ removes(item: unknown): boolean;
264
+ /** Whether the view takes a content control away and leaves its content (an inserted one, rejected). */
265
+ private unwraps;
266
+ private joinsNext;
267
+ /** The paragraph's properties in the view: its own, or what the plan gives a paragraph whose mark is gone with no paragraph next. */
268
+ private viewPPr;
269
+ private isHiddenRun;
270
+ /**
271
+ * A run's formatting beyond its paragraph style's (CR-046 phase 3): bold, italic, struck through,
272
+ * monospaced, each as the run's own property gives it, else its styles', where the paragraph style
273
+ * alone doesn't give it. A run carrying only that.
274
+ */
275
+ private formatOf;
276
+ /** The run's font for `monospace`: its own `w:rFonts/@w:ascii`, else its styles'. */
277
+ private runFont;
278
+ /** The effective run properties of the paragraph's style and a character style, cached by their ids; undefined without styles. */
279
+ private styleRPr;
280
+ private isHiddenMark;
281
+ }
282
+ /** A TOC field's instruction: a table of contents, of figures (`\c`), of anything it collects. */
283
+ export declare function isTocField(instr: string): boolean;
284
+ /**
285
+ * A HYPERLINK field's target from its instruction (WD REQ-703): its address, and `#` and the bookmark its
286
+ * `\l` names; undefined for any other field, or one with neither.
287
+ */
288
+ export declare function fieldHyperlinkTarget(instr: string): string | undefined;
289
+ export {};