@silurus/ooxml 0.56.0 → 0.58.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.
@@ -32,13 +32,13 @@ export declare type BodyElement = {
32
32
  parity?: 'odd' | 'even';
33
33
  };
34
34
 
35
- declare interface BorderSpec {
35
+ export declare interface BorderSpec {
36
36
  width: number;
37
37
  color: string | null;
38
38
  style: string;
39
39
  }
40
40
 
41
- declare interface CellBorders {
41
+ export declare interface CellBorders {
42
42
  top: BorderSpec | null;
43
43
  bottom: BorderSpec | null;
44
44
  left: BorderSpec | null;
@@ -46,7 +46,7 @@ declare interface CellBorders {
46
46
  }
47
47
 
48
48
  /** ECMA-376 §17.4.7: a table cell may contain paragraphs AND nested tables. */
49
- declare type CellElement = {
49
+ export declare type CellElement = {
50
50
  type: 'paragraph';
51
51
  } & DocParagraph | {
52
52
  type: 'table';
@@ -62,7 +62,12 @@ export declare interface DocComment {
62
62
 
63
63
  export declare interface DocNote {
64
64
  id: string;
65
- text: string;
65
+ /** ECMA-376 §17.11.2 / §17.11.10 — the note's block-level content
66
+ * (paragraphs / nested tables), parsed with the document's styles +
67
+ * numbering. The leading run is the `<w:footnoteRef/>` auto-number marker
68
+ * (carries a {@link DocxTextRun.noteRef}). Use {@link noteText} to extract
69
+ * the plain-text body without the marker. */
70
+ content: BodyElement[];
66
71
  }
67
72
 
68
73
  export declare interface DocParagraph {
@@ -104,10 +109,21 @@ export declare interface DocParagraph {
104
109
  defaultFontFamily?: string | null;
105
110
  /**
106
111
  * ECMA-376 §17.3.1.6 `<w:bidi>` — right-to-left paragraph. `true` = RTL,
107
- * `false` = explicitly LTR, absent = unspecified (inherit). Phase 0 of RTL
108
- * support: recorded only; alignment/column-order resolution is deferred.
112
+ * `false` = explicitly LTR, absent = unspecified (inherit). The renderer uses
113
+ * this as the paragraph base direction: it seeds the UAX#9 reordering pass
114
+ * (`computeLineVisualOrder`), swaps the left/right indents, resolves the
115
+ * `w:jc` start/end edges (`resolveAlignEdge`), and lays out lines from the
116
+ * right.
109
117
  */
110
118
  bidi?: boolean;
119
+ /**
120
+ * ECMA-376 §17.3.1.32 `<w:snapToGrid>` — when `false`, this paragraph opts out
121
+ * of the section's document grid (`w:docGrid`): its lines use natural font
122
+ * metrics / the line-spacing multiplier directly instead of snapping to the
123
+ * grid pitch. `undefined` = inherit (default on). Set on Word's "Footnote
124
+ * Text" style, so footnote bodies use compact natural line height.
125
+ */
126
+ snapToGrid?: boolean;
111
127
  }
112
128
 
113
129
  export declare interface DocRevision {
@@ -137,7 +153,7 @@ export declare type DocRun = {
137
153
  fontSize: number;
138
154
  };
139
155
 
140
- declare interface DocSettings {
156
+ export declare interface DocSettings {
141
157
  /** §17.15.1.58 `w:kinsoku` — East-Asian line-breaking toggle. `undefined`
142
158
  * means the element is absent; the spec default is ON (treated as `true`). */
143
159
  kinsoku?: boolean;
@@ -150,7 +166,7 @@ declare interface DocSettings {
150
166
  noLineBreaksAfter?: string;
151
167
  }
152
168
 
153
- declare interface DocTable {
169
+ export declare interface DocTable {
154
170
  colWidths: number[];
155
171
  rows: DocTableRow[];
156
172
  borders: TableBorders;
@@ -172,13 +188,13 @@ declare interface DocTable {
172
188
  /**
173
189
  * ECMA-376 §17.4.1 `<w:bidiVisual>` — render columns in right-to-left
174
190
  * (visual) order. `true` = RTL columns, `false` = explicitly LTR, absent =
175
- * unspecified. Phase 0 of RTL support: recorded only; column-order
176
- * resolution is deferred.
191
+ * unspecified. When `true` the renderer mirrors the grid so logical column 0
192
+ * is placed rightmost, and flips per-cell left/right borders accordingly.
177
193
  */
178
194
  bidiVisual?: boolean;
179
195
  }
180
196
 
181
- declare interface DocTableCell {
197
+ export declare interface DocTableCell {
182
198
  content: CellElement[];
183
199
  colSpan: number;
184
200
  vMerge: boolean | null;
@@ -201,7 +217,7 @@ declare interface DocTableCell {
201
217
  marginRight?: number | null;
202
218
  }
203
219
 
204
- declare interface DocTableRow {
220
+ export declare interface DocTableRow {
205
221
  cells: DocTableCell[];
206
222
  rowHeight: number | null;
207
223
  /** ECMA-376 §17.4.80 hRule. "auto" (default) = informational; "atLeast" =
@@ -221,6 +237,29 @@ export declare class DocxDocument {
221
237
  destroy(): void;
222
238
  get pageCount(): number;
223
239
  get document(): DocxDocumentModel;
240
+ /**
241
+ * ECMA-376 §17.13.4 — the document's comments (`word/comments.xml`), each with
242
+ * id / author / initials / date / plain-text body. Comments are a data-only
243
+ * API: they are NOT drawn on the page (Word renders them in a margin pane /
244
+ * balloons, which this viewer does not reproduce). Use this to build a review
245
+ * panel, export an annotation list, etc. Returns `[]` when the document has no
246
+ * comments part. The same data is also reachable via `document.comments`.
247
+ */
248
+ get comments(): DocComment[];
249
+ /**
250
+ * ECMA-376 §17.11.10 — the document's footnotes (`word/footnotes.xml`),
251
+ * excluding the reserved separator entries. Each note carries its `id` and
252
+ * block-level `content`; use {@link noteText} for the plain-text body. These
253
+ * ARE drawn at the bottom of the page that holds their reference; this getter
254
+ * additionally exposes them as data. Returns `[]` when absent.
255
+ */
256
+ get footnotes(): DocNote[];
257
+ /**
258
+ * ECMA-376 §17.11.4 — the document's endnotes (`word/endnotes.xml`). Same
259
+ * shape as {@link footnotes}; rendered at the end of the document. Returns
260
+ * `[]` when absent.
261
+ */
262
+ get endnotes(): DocNote[];
224
263
  private _getPages;
225
264
  renderPage(target: HTMLCanvasElement | OffscreenCanvas, pageIndex: number, opts?: RenderPageOptions): Promise<void>;
226
265
  }
@@ -291,8 +330,10 @@ export declare interface DocxTextRun {
291
330
  * tracked changes appear inline. */
292
331
  revision?: RunRevision;
293
332
  /** ECMA-376 §17.3.2.30 `<w:rtl>` — complex-script / right-to-left run.
294
- * `true` = RTL, `false` = explicitly LTR, absent = unspecified.
295
- * Phase 0: recorded only; glyph-order resolution is deferred. */
333
+ * `true` = RTL, `false` = explicitly LTR, absent = unspecified. The renderer
334
+ * treats a `true` run as RTL for the UAX#9 pass (it forces complex-script
335
+ * shaping and marks the segment so `computeLineVisualOrder` reorders it), and
336
+ * draws the slice with `ctx.direction = 'rtl'` so Canvas mirrors the glyphs. */
296
337
  rtl?: boolean;
297
338
  /** ECMA-376 §17.3.2.7 `<w:cs/>` — complex-script run toggle: cs formatting
298
339
  * applies to ALL characters of the run (§17.3.2.26). Distinct from
@@ -311,6 +352,12 @@ export declare interface DocxTextRun {
311
352
  /** ECMA-376 §17.3.2.20 `<w:lang w:bidi>` — complex-script (RTL) language tag,
312
353
  * lower-cased (e.g. "ar-sa", "ae-ar"). Drives Word's AN digit ordering. */
313
354
  langBidi?: string;
355
+ /** ECMA-376 §17.11.6/.7/.16/.17 — set when this run is a footnote/endnote
356
+ * reference marker (`<w:footnoteReference>` in the body, `<w:footnoteRef>` at
357
+ * the start of the note's content, and the endnote equivalents). `text` holds
358
+ * the raw `@w:id`; the renderer overrides the displayed glyph with the note's
359
+ * sequential number. */
360
+ noteRef?: NoteRef;
314
361
  }
315
362
 
316
363
  /** Information about a rendered text segment for building a transparent selection overlay. */
@@ -372,7 +419,7 @@ export declare interface DocxViewerOptions extends RenderPageOptions, LoadOption
372
419
  onError?: (err: Error) => void;
373
420
  }
374
421
 
375
- declare interface FieldRun {
422
+ export declare interface FieldRun {
376
423
  /** "page" | "numPages" | "other" */
377
424
  fieldType: string;
378
425
  instruction: string;
@@ -392,18 +439,18 @@ declare interface FieldRun {
392
439
  highlight?: string | null;
393
440
  }
394
441
 
395
- declare interface GradientStop {
442
+ export declare interface GradientStop {
396
443
  /** 0.0–1.0 */
397
444
  position: number;
398
445
  /** hex 6-char */
399
446
  color: string;
400
447
  }
401
448
 
402
- declare interface HeaderFooter {
449
+ export declare interface HeaderFooter {
403
450
  body: BodyElement[];
404
451
  }
405
452
 
406
- declare interface HeadersFooters {
453
+ export declare interface HeadersFooters {
407
454
  default: HeaderFooter | null;
408
455
  first: HeaderFooter | null;
409
456
  even: HeaderFooter | null;
@@ -453,7 +500,7 @@ export declare interface ImageRun {
453
500
  wrapSide?: string;
454
501
  }
455
502
 
456
- declare interface LineSpacing {
503
+ export declare interface LineSpacing {
457
504
  value: number;
458
505
  rule: 'auto' | 'exact' | 'atLeast';
459
506
  /** True when `w:spacing/@w:line` was set on the paragraph's own pPr or on a
@@ -648,7 +695,21 @@ declare interface MathSvg {
648
695
  descentEm: number;
649
696
  }
650
697
 
651
- declare interface NumberingInfo {
698
+ /** A footnote / endnote reference marker (ECMA-376 §17.11). */
699
+ export declare interface NoteRef {
700
+ /** "footnote" | "endnote" */
701
+ kind: 'footnote' | 'endnote' | string;
702
+ /** `@w:id` linking the marker to its note. Empty for the in-note
703
+ * `<w:footnoteRef/>` placeholder (the renderer uses the enclosing note). */
704
+ id: string;
705
+ }
706
+
707
+ /** Flatten a footnote/endnote's content to its plain-text body, excluding the
708
+ * auto-number reference marker. Convenience for data-only consumers
709
+ * (the renderer draws {@link DocNote.content} directly). */
710
+ export declare function noteText(note: DocNote): string;
711
+
712
+ export declare interface NumberingInfo {
652
713
  numId: number;
653
714
  level: number;
654
715
  format: string;
@@ -657,7 +718,7 @@ declare interface NumberingInfo {
657
718
  tab: number;
658
719
  }
659
720
 
660
- declare interface ParaBorderEdge {
721
+ export declare interface ParaBorderEdge {
661
722
  style: string;
662
723
  color: string | null;
663
724
  /** pt (sz / 8) */
@@ -666,7 +727,7 @@ declare interface ParaBorderEdge {
666
727
  space: number;
667
728
  }
668
729
 
669
- declare interface ParagraphBorders {
730
+ export declare interface ParagraphBorders {
670
731
  top: ParaBorderEdge | null;
671
732
  bottom: ParaBorderEdge | null;
672
733
  left: ParaBorderEdge | null;
@@ -674,7 +735,7 @@ declare interface ParagraphBorders {
674
735
  between: ParaBorderEdge | null;
675
736
  }
676
737
 
677
- declare type PathCmd = {
738
+ export declare type PathCmd = {
678
739
  cmd: 'moveTo';
679
740
  x: number;
680
741
  y: number;
@@ -721,7 +782,7 @@ export declare interface RenderPageOptions {
721
782
  showTrackChanges?: boolean;
722
783
  }
723
784
 
724
- declare interface RubyAnnotation {
785
+ export declare interface RubyAnnotation {
725
786
  text: string;
726
787
  /** Annotation font size in pt. Word stores this as half-points in `<w:hps>`. */
727
788
  fontSizePt: number;
@@ -765,7 +826,7 @@ declare type ShapeFill = {
765
826
  gradType: string;
766
827
  };
767
828
 
768
- declare interface ShapeRun {
829
+ export declare interface ShapeRun {
769
830
  widthPt: number;
770
831
  heightPt: number;
771
832
  /** X offset in pt */
@@ -832,7 +893,7 @@ declare interface ShapeRun {
832
893
  textInsetB?: number;
833
894
  }
834
895
 
835
- declare interface ShapeText {
896
+ export declare interface ShapeText {
836
897
  text: string;
837
898
  fontSizePt: number;
838
899
  color?: string | null;
@@ -842,7 +903,7 @@ declare interface ShapeText {
842
903
  alignment: string;
843
904
  }
844
905
 
845
- declare interface TableBorders {
906
+ export declare interface TableBorders {
846
907
  top: BorderSpec | null;
847
908
  bottom: BorderSpec | null;
848
909
  left: BorderSpec | null;
@@ -851,7 +912,7 @@ declare interface TableBorders {
851
912
  insideV: BorderSpec | null;
852
913
  }
853
914
 
854
- declare interface TabStop {
915
+ export declare interface TabStop {
855
916
  /** tab stop position in pt (from the left of paragraph content area) */
856
917
  pos: number;
857
918
  alignment: 'left' | 'center' | 'right' | 'decimal' | 'bar' | 'clear';