@silurus/ooxml 0.57.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.
@@ -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 {
@@ -172,8 +188,8 @@ export 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
  }
@@ -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. */
@@ -648,6 +695,20 @@ declare interface MathSvg {
648
695
  descentEm: number;
649
696
  }
650
697
 
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
+
651
712
  export declare interface NumberingInfo {
652
713
  numId: number;
653
714
  level: number;