@silurus/ooxml 0.55.0 → 0.56.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.
@@ -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,6 +137,19 @@ export declare type DocRun = {
131
137
  fontSize: number;
132
138
  };
133
139
 
140
+ 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
+
134
153
  declare interface DocTable {
135
154
  colWidths: number[];
136
155
  rows: DocTableRow[];
@@ -141,6 +160,22 @@ 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
181
  declare interface DocTableCell {
@@ -150,7 +185,13 @@ declare interface DocTableCell {
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. */
@@ -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. */
@@ -705,6 +705,12 @@ declare interface DocParagraph {
705
705
  /** Default font family resolved from the style chain. Used to size empty
706
706
  * paragraphs (no runs) with the intended font's line metrics. */
707
707
  defaultFontFamily?: string | null;
708
+ /**
709
+ * ECMA-376 §17.3.1.6 `<w:bidi>` — right-to-left paragraph. `true` = RTL,
710
+ * `false` = explicitly LTR, absent = unspecified (inherit). Phase 0 of RTL
711
+ * support: recorded only; alignment/column-order resolution is deferred.
712
+ */
713
+ bidi?: boolean;
708
714
  }
709
715
 
710
716
  declare interface DocRevision {
@@ -734,6 +740,19 @@ declare type DocRun = {
734
740
  fontSize: number;
735
741
  };
736
742
 
743
+ declare interface DocSettings {
744
+ /** §17.15.1.58 `w:kinsoku` — East-Asian line-breaking toggle. `undefined`
745
+ * means the element is absent; the spec default is ON (treated as `true`). */
746
+ kinsoku?: boolean;
747
+ /** §17.15.1.60 `w:noLineBreaksBefore@w:val` — custom set of characters that
748
+ * cannot begin a line (行頭禁則). When present it REPLACES the application
749
+ * default set. Word's per-`w:lang` sets are merged into one string. */
750
+ noLineBreaksBefore?: string;
751
+ /** §17.15.1.59 `w:noLineBreaksAfter@w:val` — custom set of characters that
752
+ * cannot end a line (行末禁則). Replaces the default when present. */
753
+ noLineBreaksAfter?: string;
754
+ }
755
+
737
756
  declare interface DocTable {
738
757
  colWidths: number[];
739
758
  rows: DocTableRow[];
@@ -744,6 +763,22 @@ declare interface DocTable {
744
763
  cellMarginRight: number;
745
764
  /** table horizontal alignment on the page: 'left' | 'center' | 'right'. */
746
765
  jc: string;
766
+ /** ECMA-376 §17.4.52 `<w:tblLayout w:type>` — 'fixed' | 'autofit'. Absent
767
+ * (undefined) ⇒ spec default 'autofit': columns are sized by the per-column
768
+ * max preferred width (cell `widthPt`), tblGrid only as fallback. 'fixed'
769
+ * uses tblGrid widths verbatim (scaled to fit). */
770
+ layout?: string;
771
+ /** ECMA-376 §17.4.63 `<w:tblW>` preferred table width (type="dxa"), pt. */
772
+ widthPt?: number;
773
+ /** `<w:tblW>` type="pct": 50ths of a percent of available content width. */
774
+ widthPct?: number;
775
+ /**
776
+ * ECMA-376 §17.4.1 `<w:bidiVisual>` — render columns in right-to-left
777
+ * (visual) order. `true` = RTL columns, `false` = explicitly LTR, absent =
778
+ * unspecified. Phase 0 of RTL support: recorded only; column-order
779
+ * resolution is deferred.
780
+ */
781
+ bidiVisual?: boolean;
747
782
  }
748
783
 
749
784
  declare interface DocTableCell {
@@ -753,7 +788,13 @@ declare interface DocTableCell {
753
788
  borders: CellBorders;
754
789
  background: string | null;
755
790
  vAlign: 'top' | 'center' | 'bottom';
791
+ /** ECMA-376 §17.4.71 `<w:tcW>` preferred cell width (type="dxa"), pt. Drives
792
+ * autofit column sizing: each grid column's width is the max `widthPt` over
793
+ * the cells anchored in it. */
756
794
  widthPt: number | null;
795
+ /** `<w:tcW>` type="pct": 50ths of a percent of available content width.
796
+ * Resolved against the available width at render time. */
797
+ widthPct?: number;
757
798
  /** Per-cell margins (pt) from `<w:tcPr><w:tcMar>` (ECMA-376 §17.4.42). Each
758
799
  * edge overrides the table-level `cellMargin*` default when set; null/absent
759
800
  * = inherit the table default. */
@@ -843,6 +884,11 @@ declare interface DocxDocumentModel {
843
884
  /** ECMA-376 §17.11.4 — `word/endnotes.xml` (id + text). Same shape as
844
885
  * `footnotes`. */
845
886
  endnotes?: DocNote[];
887
+ /** ECMA-376 §17.15.1.* — document-wide compatibility / typography settings
888
+ * from `word/settings.xml`. Currently carries the Japanese line-breaking
889
+ * (kinsoku) configuration. Absent when settings.xml has no relevant
890
+ * elements (the renderer then uses spec defaults: kinsoku ON). */
891
+ settings?: DocSettings;
846
892
  }
847
893
 
848
894
  declare interface DocxTextRun {
@@ -871,6 +917,27 @@ declare interface DocxTextRun {
871
917
  * underline and deletions with an author-coloured strikethrough so
872
918
  * tracked changes appear inline. */
873
919
  revision?: RunRevision;
920
+ /** ECMA-376 §17.3.2.30 `<w:rtl>` — complex-script / right-to-left run.
921
+ * `true` = RTL, `false` = explicitly LTR, absent = unspecified.
922
+ * Phase 0: recorded only; glyph-order resolution is deferred. */
923
+ rtl?: boolean;
924
+ /** ECMA-376 §17.3.2.7 `<w:cs/>` — complex-script run toggle: cs formatting
925
+ * applies to ALL characters of the run (§17.3.2.26). Distinct from
926
+ * `rFonts@cs` (`fontFamilyCs`), which is only a font slot. */
927
+ cs?: boolean;
928
+ /** ECMA-376 §17.3.2.26 `<w:rFonts w:cs>` — complex-script typeface
929
+ * (theme references resolved to a literal family). */
930
+ fontFamilyCs?: string;
931
+ /** ECMA-376 §17.3.2.39 `<w:szCs>` — complex-script font size in pt
932
+ * (same units as `fontSize`). */
933
+ fontSizeCs?: number;
934
+ /** ECMA-376 §17.3.2.3 `<w:bCs>` — complex-script bold toggle. */
935
+ boldCs?: boolean;
936
+ /** ECMA-376 §17.3.2.17 `<w:iCs>` — complex-script italic toggle. */
937
+ italicCs?: boolean;
938
+ /** ECMA-376 §17.3.2.20 `<w:lang w:bidi>` — complex-script (RTL) language tag,
939
+ * lower-cased (e.g. "ar-sa", "ae-ar"). Drives Word's AN digit ordering. */
940
+ langBidi?: string;
874
941
  }
875
942
 
876
943
  /** Information about a rendered text segment for building a transparent selection overlay. */
@@ -2120,6 +2187,9 @@ declare interface ShapeInfo {
2120
2187
  declare interface ShapeParagraph {
2121
2188
  /** `<a:pPr@algn>` — `l` (default) | `ctr` | `r` | `just` | `dist`. */
2122
2189
  align: string;
2190
+ /** `<a:pPr@rtl>` — whether the paragraph reads right-to-left
2191
+ * (ECMA-376 §21.1.2.2.7). Omitted (undefined) when false. */
2192
+ rtl?: boolean;
2123
2193
  runs: ShapeTextRun[];
2124
2194
  }
2125
2195
 
@@ -2427,6 +2497,8 @@ declare interface TableElement {
2427
2497
  /** Column widths in EMU */
2428
2498
  cols: number[];
2429
2499
  rows: TableRow[];
2500
+ /** `<a:tblPr rtl="1">` (ECMA-376 §21.1.3.13): right-to-left table — column 0 at the right edge. */
2501
+ rtl?: boolean;
2430
2502
  }
2431
2503
 
2432
2504
  declare interface TableInfo {
@@ -2476,7 +2548,21 @@ declare interface TabStop_2 {
2476
2548
  leader: 'none' | 'dot' | 'hyphen' | 'underscore' | 'heavy' | 'middleDot';
2477
2549
  }
2478
2550
 
2479
- declare interface TextBody {
2551
+ /**
2552
+ * PPTX text body. Extends the shared core `TextBody` with PPTX-only bodyPr
2553
+ * fields that the pptx parser surfaces but the shared core model does not yet
2554
+ * carry.
2555
+ */
2556
+ declare interface TextBody extends TextBody_2 {
2557
+ /**
2558
+ * `<a:bodyPr rtlCol>` (ECMA-376 §21.1.2.1.1) — when true the columns of a
2559
+ * multi-column text body are laid out right-to-left. Defaults to false;
2560
+ * omitted from JSON when false. Only meaningful when `numCol > 1`.
2561
+ */
2562
+ rtlCol?: boolean;
2563
+ }
2564
+
2565
+ declare interface TextBody_2 {
2480
2566
  /** Vertical anchor: "t" | "ctr" | "b" */
2481
2567
  verticalAnchor: string;
2482
2568
  paragraphs: Paragraph[];
@@ -2646,6 +2732,10 @@ declare interface Worksheet {
2646
2732
  * `<sheetView showGridLines>`). Mirrors the Excel "View → Gridlines"
2647
2733
  * checkbox. Defaults to true. */
2648
2734
  showGridlines?: boolean;
2735
+ /** Whether the sheet grid is laid out right-to-left, mirroring the entire
2736
+ * grid so column A sits on the right (ECMA-376 §18.3.1.87
2737
+ * `<sheetView rightToLeft>`). Defaults to false. */
2738
+ rightToLeft?: boolean;
2649
2739
  /** Sheet tab color (ECMA-376 §18.3.1.79). */
2650
2740
  tabColor?: string | null;
2651
2741
  /** AutoFilter header range (ECMA-376 §18.3.1.2). */
@@ -2813,6 +2903,40 @@ declare class XlsxViewer {
2813
2903
  /** The loaded workbook, or throws if {@link load} has not completed. */
2814
2904
  private get workbook();
2815
2905
  showSheet(index: number): Promise<void>;
2906
+ /** True when the current sheet's grid is laid out right-to-left. */
2907
+ private get isRtl();
2908
+ /** Maximum horizontal scroll offset the native scroll host allows (≥ 0). */
2909
+ private get maxScrollLeft();
2910
+ /**
2911
+ * The logical horizontal scroll position used to find the start-of-sheet
2912
+ * (col A) edge, in *scaled* CSS pixels — the same unit as
2913
+ * `scrollHost.scrollLeft`. The renderer always lays the grid out LTR and then
2914
+ * mirrors it (ECMA-376 §18.3.1.87), so the viewer must hand it a position
2915
+ * where 0 = the START of the sheet (col A) and increasing values reveal later
2916
+ * columns.
2917
+ *
2918
+ * For LTR that is exactly the native `scrollLeft`. For RTL the sheet starts at
2919
+ * the RIGHT, so the native scrollbar runs the opposite way: thumb fully right
2920
+ * (`scrollLeft = maxScrollLeft`) is the start, thumb left is the far columns.
2921
+ * Inverting here makes wheel/trackpad follow the finger and aligns the
2922
+ * thumb↔page mapping with Excel, without depending on browser-specific RTL
2923
+ * `scrollLeft` sign conventions.
2924
+ */
2925
+ private get effectiveScrollLeft();
2926
+ /**
2927
+ * Map between the logical-LTR x used by all the cell-geometry math and the
2928
+ * on-screen (canvasArea CSS-pixel) x, applying the RTL mirror (ECMA-376
2929
+ * §18.3.1.87) via the same {@link rtlMirrorX} the renderer uses. For LTR this
2930
+ * is the identity. The mirror is an involution, so this one method serves
2931
+ * both cell→px (overlay draw, `w` = cell width) and px→cell (pointer
2932
+ * hit-testing, `w` = 0 for a point) — guaranteeing the overlay sits exactly
2933
+ * where the cell is drawn and a click resolves to that same cell at every
2934
+ * scroll offset. `canvasArea.clientWidth` equals the renderer's `canvasW`.
2935
+ */
2936
+ private screenX;
2937
+ /** Park the scrollbar at the sheet's natural start: scrollLeft=0 for LTR,
2938
+ * the right end for RTL (so col A shows first). */
2939
+ private resetHorizontalScroll;
2816
2940
  /** 0-based index of the currently displayed sheet. */
2817
2941
  get sheetIndex(): number;
2818
2942
  /** Total number of sheets in the loaded workbook. */
@@ -1034,6 +1034,8 @@ declare interface TableElement {
1034
1034
  /** Column widths in EMU */
1035
1035
  cols: number[];
1036
1036
  rows: TableRow[];
1037
+ /** `<a:tblPr rtl="1">` (ECMA-376 §21.1.3.13): right-to-left table — column 0 at the right edge. */
1038
+ rtl?: boolean;
1037
1039
  }
1038
1040
 
1039
1041
  declare interface TableRow {
@@ -1049,7 +1051,21 @@ declare interface TabStop {
1049
1051
  algn: string;
1050
1052
  }
1051
1053
 
1052
- export declare interface TextBody {
1054
+ /**
1055
+ * PPTX text body. Extends the shared core `TextBody` with PPTX-only bodyPr
1056
+ * fields that the pptx parser surfaces but the shared core model does not yet
1057
+ * carry.
1058
+ */
1059
+ export declare interface TextBody extends TextBody_2 {
1060
+ /**
1061
+ * `<a:bodyPr rtlCol>` (ECMA-376 §21.1.2.1.1) — when true the columns of a
1062
+ * multi-column text body are laid out right-to-left. Defaults to false;
1063
+ * omitted from JSON when false. Only meaningful when `numCol > 1`.
1064
+ */
1065
+ rtlCol?: boolean;
1066
+ }
1067
+
1068
+ declare interface TextBody_2 {
1053
1069
  /** Vertical anchor: "t" | "ctr" | "b" */
1054
1070
  verticalAnchor: string;
1055
1071
  paragraphs: Paragraph[];
@@ -814,6 +814,9 @@ declare interface ShapeInfo {
814
814
  declare interface ShapeParagraph {
815
815
  /** `<a:pPr@algn>` — `l` (default) | `ctr` | `r` | `just` | `dist`. */
816
816
  align: string;
817
+ /** `<a:pPr@rtl>` — whether the paragraph reads right-to-left
818
+ * (ECMA-376 §21.1.2.2.7). Omitted (undefined) when false. */
819
+ rtl?: boolean;
817
820
  runs: ShapeTextRun[];
818
821
  }
819
822
 
@@ -1009,6 +1012,10 @@ export declare interface Worksheet {
1009
1012
  * `<sheetView showGridLines>`). Mirrors the Excel "View → Gridlines"
1010
1013
  * checkbox. Defaults to true. */
1011
1014
  showGridlines?: boolean;
1015
+ /** Whether the sheet grid is laid out right-to-left, mirroring the entire
1016
+ * grid so column A sits on the right (ECMA-376 §18.3.1.87
1017
+ * `<sheetView rightToLeft>`). Defaults to false. */
1018
+ rightToLeft?: boolean;
1012
1019
  /** Sheet tab color (ECMA-376 §18.3.1.79). */
1013
1020
  tabColor?: string | null;
1014
1021
  /** AutoFilter header range (ECMA-376 §18.3.1.2). */
@@ -1144,6 +1151,40 @@ export declare class XlsxViewer {
1144
1151
  /** The loaded workbook, or throws if {@link load} has not completed. */
1145
1152
  private get workbook();
1146
1153
  showSheet(index: number): Promise<void>;
1154
+ /** True when the current sheet's grid is laid out right-to-left. */
1155
+ private get isRtl();
1156
+ /** Maximum horizontal scroll offset the native scroll host allows (≥ 0). */
1157
+ private get maxScrollLeft();
1158
+ /**
1159
+ * The logical horizontal scroll position used to find the start-of-sheet
1160
+ * (col A) edge, in *scaled* CSS pixels — the same unit as
1161
+ * `scrollHost.scrollLeft`. The renderer always lays the grid out LTR and then
1162
+ * mirrors it (ECMA-376 §18.3.1.87), so the viewer must hand it a position
1163
+ * where 0 = the START of the sheet (col A) and increasing values reveal later
1164
+ * columns.
1165
+ *
1166
+ * For LTR that is exactly the native `scrollLeft`. For RTL the sheet starts at
1167
+ * the RIGHT, so the native scrollbar runs the opposite way: thumb fully right
1168
+ * (`scrollLeft = maxScrollLeft`) is the start, thumb left is the far columns.
1169
+ * Inverting here makes wheel/trackpad follow the finger and aligns the
1170
+ * thumb↔page mapping with Excel, without depending on browser-specific RTL
1171
+ * `scrollLeft` sign conventions.
1172
+ */
1173
+ private get effectiveScrollLeft();
1174
+ /**
1175
+ * Map between the logical-LTR x used by all the cell-geometry math and the
1176
+ * on-screen (canvasArea CSS-pixel) x, applying the RTL mirror (ECMA-376
1177
+ * §18.3.1.87) via the same {@link rtlMirrorX} the renderer uses. For LTR this
1178
+ * is the identity. The mirror is an involution, so this one method serves
1179
+ * both cell→px (overlay draw, `w` = cell width) and px→cell (pointer
1180
+ * hit-testing, `w` = 0 for a point) — guaranteeing the overlay sits exactly
1181
+ * where the cell is drawn and a click resolves to that same cell at every
1182
+ * scroll offset. `canvasArea.clientWidth` equals the renderer's `canvasW`.
1183
+ */
1184
+ private screenX;
1185
+ /** Park the scrollbar at the sheet's natural start: scrollLeft=0 for LTR,
1186
+ * the right end for RTL (so col A shows first). */
1187
+ private resetHorizontalScroll;
1147
1188
  /** 0-based index of the currently displayed sheet. */
1148
1189
  get sheetIndex(): number;
1149
1190
  /** Total number of sheets in the loaded workbook. */