@silurus/ooxml 0.55.0 → 0.57.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';
@@ -102,6 +102,12 @@ export declare interface DocParagraph {
102
102
  /** Default font family resolved from the style chain. Used to size empty
103
103
  * paragraphs (no runs) with the intended font's line metrics. */
104
104
  defaultFontFamily?: string | null;
105
+ /**
106
+ * 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.
109
+ */
110
+ bidi?: boolean;
105
111
  }
106
112
 
107
113
  export declare interface DocRevision {
@@ -131,7 +137,20 @@ export declare type DocRun = {
131
137
  fontSize: number;
132
138
  };
133
139
 
134
- declare interface DocTable {
140
+ export declare interface DocSettings {
141
+ /** §17.15.1.58 `w:kinsoku` — East-Asian line-breaking toggle. `undefined`
142
+ * means the element is absent; the spec default is ON (treated as `true`). */
143
+ kinsoku?: boolean;
144
+ /** §17.15.1.60 `w:noLineBreaksBefore@w:val` — custom set of characters that
145
+ * cannot begin a line (行頭禁則). When present it REPLACES the application
146
+ * default set. Word's per-`w:lang` sets are merged into one string. */
147
+ noLineBreaksBefore?: string;
148
+ /** §17.15.1.59 `w:noLineBreaksAfter@w:val` — custom set of characters that
149
+ * cannot end a line (行末禁則). Replaces the default when present. */
150
+ noLineBreaksAfter?: string;
151
+ }
152
+
153
+ export declare interface DocTable {
135
154
  colWidths: number[];
136
155
  rows: DocTableRow[];
137
156
  borders: TableBorders;
@@ -141,16 +160,38 @@ declare interface DocTable {
141
160
  cellMarginRight: number;
142
161
  /** table horizontal alignment on the page: 'left' | 'center' | 'right'. */
143
162
  jc: string;
163
+ /** ECMA-376 §17.4.52 `<w:tblLayout w:type>` — 'fixed' | 'autofit'. Absent
164
+ * (undefined) ⇒ spec default 'autofit': columns are sized by the per-column
165
+ * max preferred width (cell `widthPt`), tblGrid only as fallback. 'fixed'
166
+ * uses tblGrid widths verbatim (scaled to fit). */
167
+ layout?: string;
168
+ /** ECMA-376 §17.4.63 `<w:tblW>` preferred table width (type="dxa"), pt. */
169
+ widthPt?: number;
170
+ /** `<w:tblW>` type="pct": 50ths of a percent of available content width. */
171
+ widthPct?: number;
172
+ /**
173
+ * ECMA-376 §17.4.1 `<w:bidiVisual>` — render columns in right-to-left
174
+ * (visual) order. `true` = RTL columns, `false` = explicitly LTR, absent =
175
+ * unspecified. Phase 0 of RTL support: recorded only; column-order
176
+ * resolution is deferred.
177
+ */
178
+ bidiVisual?: boolean;
144
179
  }
145
180
 
146
- declare interface DocTableCell {
181
+ export declare interface DocTableCell {
147
182
  content: CellElement[];
148
183
  colSpan: number;
149
184
  vMerge: boolean | null;
150
185
  borders: CellBorders;
151
186
  background: string | null;
152
187
  vAlign: 'top' | 'center' | 'bottom';
188
+ /** ECMA-376 §17.4.71 `<w:tcW>` preferred cell width (type="dxa"), pt. Drives
189
+ * autofit column sizing: each grid column's width is the max `widthPt` over
190
+ * the cells anchored in it. */
153
191
  widthPt: number | null;
192
+ /** `<w:tcW>` type="pct": 50ths of a percent of available content width.
193
+ * Resolved against the available width at render time. */
194
+ widthPct?: number;
154
195
  /** Per-cell margins (pt) from `<w:tcPr><w:tcMar>` (ECMA-376 §17.4.42). Each
155
196
  * edge overrides the table-level `cellMargin*` default when set; null/absent
156
197
  * = inherit the table default. */
@@ -160,7 +201,7 @@ declare interface DocTableCell {
160
201
  marginRight?: number | null;
161
202
  }
162
203
 
163
- declare interface DocTableRow {
204
+ export declare interface DocTableRow {
164
205
  cells: DocTableCell[];
165
206
  rowHeight: number | null;
166
207
  /** ECMA-376 §17.4.80 hRule. "auto" (default) = informational; "atLeast" =
@@ -216,6 +257,11 @@ export declare interface DocxDocumentModel {
216
257
  /** ECMA-376 §17.11.4 — `word/endnotes.xml` (id + text). Same shape as
217
258
  * `footnotes`. */
218
259
  endnotes?: DocNote[];
260
+ /** ECMA-376 §17.15.1.* — document-wide compatibility / typography settings
261
+ * from `word/settings.xml`. Currently carries the Japanese line-breaking
262
+ * (kinsoku) configuration. Absent when settings.xml has no relevant
263
+ * elements (the renderer then uses spec defaults: kinsoku ON). */
264
+ settings?: DocSettings;
219
265
  }
220
266
 
221
267
  export declare interface DocxTextRun {
@@ -244,6 +290,27 @@ export declare interface DocxTextRun {
244
290
  * underline and deletions with an author-coloured strikethrough so
245
291
  * tracked changes appear inline. */
246
292
  revision?: RunRevision;
293
+ /** 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. */
296
+ rtl?: boolean;
297
+ /** ECMA-376 §17.3.2.7 `<w:cs/>` — complex-script run toggle: cs formatting
298
+ * applies to ALL characters of the run (§17.3.2.26). Distinct from
299
+ * `rFonts@cs` (`fontFamilyCs`), which is only a font slot. */
300
+ cs?: boolean;
301
+ /** ECMA-376 §17.3.2.26 `<w:rFonts w:cs>` — complex-script typeface
302
+ * (theme references resolved to a literal family). */
303
+ fontFamilyCs?: string;
304
+ /** ECMA-376 §17.3.2.39 `<w:szCs>` — complex-script font size in pt
305
+ * (same units as `fontSize`). */
306
+ fontSizeCs?: number;
307
+ /** ECMA-376 §17.3.2.3 `<w:bCs>` — complex-script bold toggle. */
308
+ boldCs?: boolean;
309
+ /** ECMA-376 §17.3.2.17 `<w:iCs>` — complex-script italic toggle. */
310
+ italicCs?: boolean;
311
+ /** ECMA-376 §17.3.2.20 `<w:lang w:bidi>` — complex-script (RTL) language tag,
312
+ * lower-cased (e.g. "ar-sa", "ae-ar"). Drives Word's AN digit ordering. */
313
+ langBidi?: string;
247
314
  }
248
315
 
249
316
  /** Information about a rendered text segment for building a transparent selection overlay. */
@@ -305,7 +372,7 @@ export declare interface DocxViewerOptions extends RenderPageOptions, LoadOption
305
372
  onError?: (err: Error) => void;
306
373
  }
307
374
 
308
- declare interface FieldRun {
375
+ export declare interface FieldRun {
309
376
  /** "page" | "numPages" | "other" */
310
377
  fieldType: string;
311
378
  instruction: string;
@@ -325,18 +392,18 @@ declare interface FieldRun {
325
392
  highlight?: string | null;
326
393
  }
327
394
 
328
- declare interface GradientStop {
395
+ export declare interface GradientStop {
329
396
  /** 0.0–1.0 */
330
397
  position: number;
331
398
  /** hex 6-char */
332
399
  color: string;
333
400
  }
334
401
 
335
- declare interface HeaderFooter {
402
+ export declare interface HeaderFooter {
336
403
  body: BodyElement[];
337
404
  }
338
405
 
339
- declare interface HeadersFooters {
406
+ export declare interface HeadersFooters {
340
407
  default: HeaderFooter | null;
341
408
  first: HeaderFooter | null;
342
409
  even: HeaderFooter | null;
@@ -386,7 +453,7 @@ export declare interface ImageRun {
386
453
  wrapSide?: string;
387
454
  }
388
455
 
389
- declare interface LineSpacing {
456
+ export declare interface LineSpacing {
390
457
  value: number;
391
458
  rule: 'auto' | 'exact' | 'atLeast';
392
459
  /** True when `w:spacing/@w:line` was set on the paragraph's own pPr or on a
@@ -581,7 +648,7 @@ declare interface MathSvg {
581
648
  descentEm: number;
582
649
  }
583
650
 
584
- declare interface NumberingInfo {
651
+ export declare interface NumberingInfo {
585
652
  numId: number;
586
653
  level: number;
587
654
  format: string;
@@ -590,7 +657,7 @@ declare interface NumberingInfo {
590
657
  tab: number;
591
658
  }
592
659
 
593
- declare interface ParaBorderEdge {
660
+ export declare interface ParaBorderEdge {
594
661
  style: string;
595
662
  color: string | null;
596
663
  /** pt (sz / 8) */
@@ -599,7 +666,7 @@ declare interface ParaBorderEdge {
599
666
  space: number;
600
667
  }
601
668
 
602
- declare interface ParagraphBorders {
669
+ export declare interface ParagraphBorders {
603
670
  top: ParaBorderEdge | null;
604
671
  bottom: ParaBorderEdge | null;
605
672
  left: ParaBorderEdge | null;
@@ -607,7 +674,7 @@ declare interface ParagraphBorders {
607
674
  between: ParaBorderEdge | null;
608
675
  }
609
676
 
610
- declare type PathCmd = {
677
+ export declare type PathCmd = {
611
678
  cmd: 'moveTo';
612
679
  x: number;
613
680
  y: number;
@@ -654,7 +721,7 @@ export declare interface RenderPageOptions {
654
721
  showTrackChanges?: boolean;
655
722
  }
656
723
 
657
- declare interface RubyAnnotation {
724
+ export declare interface RubyAnnotation {
658
725
  text: string;
659
726
  /** Annotation font size in pt. Word stores this as half-points in `<w:hps>`. */
660
727
  fontSizePt: number;
@@ -698,7 +765,7 @@ declare type ShapeFill = {
698
765
  gradType: string;
699
766
  };
700
767
 
701
- declare interface ShapeRun {
768
+ export declare interface ShapeRun {
702
769
  widthPt: number;
703
770
  heightPt: number;
704
771
  /** X offset in pt */
@@ -765,7 +832,7 @@ declare interface ShapeRun {
765
832
  textInsetB?: number;
766
833
  }
767
834
 
768
- declare interface ShapeText {
835
+ export declare interface ShapeText {
769
836
  text: string;
770
837
  fontSizePt: number;
771
838
  color?: string | null;
@@ -775,7 +842,7 @@ declare interface ShapeText {
775
842
  alignment: string;
776
843
  }
777
844
 
778
- declare interface TableBorders {
845
+ export declare interface TableBorders {
779
846
  top: BorderSpec | null;
780
847
  bottom: BorderSpec | null;
781
848
  left: BorderSpec | null;
@@ -784,7 +851,7 @@ declare interface TableBorders {
784
851
  insideV: BorderSpec | null;
785
852
  }
786
853
 
787
- declare interface TabStop {
854
+ export declare interface TabStop {
788
855
  /** tab stop position in pt (from the left of paragraph content area) */
789
856
  pos: number;
790
857
  alignment: 'left' | 'center' | 'right' | 'decimal' | 'bar' | 'clear';