@silurus/ooxml 0.54.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.
@@ -464,6 +464,16 @@ declare interface LoadOptions_2 {
464
464
  * untrusted input. Zero / negative values fall back to the default.
465
465
  */
466
466
  maxZipEntryBytes?: number;
467
+ /**
468
+ * Opt-in OMML equation engine (MathJax + STIX Two Math, ~3 MB). Inject it
469
+ * **once** here and every render of this document / presentation / workbook
470
+ * uses it — the same dependency-injection contract across all three formats
471
+ * and their viewers. Import it from the separate `@silurus/ooxml/math` entry
472
+ * (`import { math } from '@silurus/ooxml/math'`). Omit it and equations are
473
+ * skipped and the engine tree-shakes away entirely (no network, no bundle
474
+ * cost).
475
+ */
476
+ math?: MathRenderer;
467
477
  }
468
478
 
469
479
  declare interface ManualLayout {
@@ -682,11 +692,6 @@ export declare interface RenderViewportOptions {
682
692
  cellScale?: number;
683
693
  /** Pre-loaded Image elements keyed by their dataUrl (for ImageAnchor rendering). */
684
694
  loadedImages?: Map<string, HTMLImageElement>;
685
- /** Opt-in OMML equation engine. Import it from the separate `@silurus/ooxml/math`
686
- * entry and pass it in (`import { math } from '@silurus/ooxml/math'`). When
687
- * omitted, equations in shapes are skipped and the ~3 MB engine never enters
688
- * the bundle. Same DI contract as docx/pptx. */
689
- math?: MathRenderer;
690
695
  /** Called once per cell that contains text, with canvas-pixel position and cell address. */
691
696
  onTextRun?: (info: XlsxTextRunInfo) => void;
692
697
  /** Highlighted row range for selected row headers (1-indexed inclusive).
@@ -809,6 +814,9 @@ declare interface ShapeInfo {
809
814
  declare interface ShapeParagraph {
810
815
  /** `<a:pPr@algn>` — `l` (default) | `ctr` | `r` | `just` | `dist`. */
811
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;
812
820
  runs: ShapeTextRun[];
813
821
  }
814
822
 
@@ -1004,6 +1012,10 @@ export declare interface Worksheet {
1004
1012
  * `<sheetView showGridLines>`). Mirrors the Excel "View → Gridlines"
1005
1013
  * checkbox. Defaults to true. */
1006
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;
1007
1019
  /** Sheet tab color (ECMA-376 §18.3.1.79). */
1008
1020
  tabColor?: string | null;
1009
1021
  /** AutoFilter header range (ECMA-376 §18.3.1.2). */
@@ -1139,6 +1151,40 @@ export declare class XlsxViewer {
1139
1151
  /** The loaded workbook, or throws if {@link load} has not completed. */
1140
1152
  private get workbook();
1141
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;
1142
1188
  /** 0-based index of the currently displayed sheet. */
1143
1189
  get sheetIndex(): number;
1144
1190
  /** Total number of sheets in the loaded workbook. */
@@ -1249,6 +1295,10 @@ export declare class XlsxWorkbook {
1249
1295
  private imageCache;
1250
1296
  private rawData;
1251
1297
  private maxZipEntryBytes;
1298
+ /** Opt-in OMML equation engine, injected once at {@link load}. Every
1299
+ * `renderViewport` call reuses it — equations in shapes render when present,
1300
+ * and are skipped (engine tree-shaken) when omitted. */
1301
+ private math;
1252
1302
  private constructor();
1253
1303
  /** Parse an XLSX from a URL or ArrayBuffer. */
1254
1304
  static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<XlsxWorkbook>;