@silurus/ooxml 0.67.0 → 0.69.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.
@@ -237,6 +237,10 @@ export declare interface DocSettings {
237
237
  * justification (ST_Jc math: left|right|center|centerGroup). `undefined`
238
238
  * ⇒ the renderer uses the spec default `centerGroup`. */
239
239
  mathDefJc?: string;
240
+ /** §17.15.1.25 `w:defaultTabStop@w:val` — interval (points) between automatic
241
+ * tab stops generated after all custom stops. `undefined` ⇒ the renderer
242
+ * uses the spec default of 720 twips (36pt). */
243
+ defaultTabStop?: number;
240
244
  }
241
245
 
242
246
  export declare interface DocTable {
@@ -1257,6 +1261,18 @@ export declare interface ShapeText {
1257
1261
  /** ECMA-376 §17.3.1.33 `<w:spacing w:after>` of this text-box paragraph, in
1258
1262
  * pt — reserved BELOW the paragraph. Absent/0 ⇒ no offset. */
1259
1263
  spaceAfter?: number;
1264
+ /** ECMA-376 §17.3.1.12 `<w:ind w:left/@start>` — paragraph left indent (pt).
1265
+ * Absent/0 ⇒ flush to the box's inner left edge. */
1266
+ indentLeft?: number;
1267
+ /** ECMA-376 §17.3.1.12 `<w:ind w:right/@end>` — paragraph right indent (pt).
1268
+ * Absent/0 ⇒ flush to the box's inner right edge. */
1269
+ indentRight?: number;
1270
+ /** `<w:ind>` first-line indent (pt, SIGNED: `w:firstLine` positive,
1271
+ * `w:hanging` negative). A negative value hangs the first line further LEFT
1272
+ * than the continuation lines (the body renderer honors the sign too — Word
1273
+ * applies a signed hanging first-line list-independently). Absent/0 ⇒ the
1274
+ * first line aligns with the continuation lines. */
1275
+ indentFirst?: number;
1260
1276
  /** Zip path of an inline image inside this text-box paragraph
1261
1277
  * (`<w:drawing><wp:inline><a:blip r:embed>`), e.g. `word/media/image1.emf`.
1262
1278
  * Absent for a text-only paragraph. */
@@ -1184,6 +1184,10 @@ declare interface DocSettings {
1184
1184
  * justification (ST_Jc math: left|right|center|centerGroup). `undefined`
1185
1185
  * ⇒ the renderer uses the spec default `centerGroup`. */
1186
1186
  mathDefJc?: string;
1187
+ /** §17.15.1.25 `w:defaultTabStop@w:val` — interval (points) between automatic
1188
+ * tab stops generated after all custom stops. `undefined` ⇒ the renderer
1189
+ * uses the spec default of 720 twips (36pt). */
1190
+ defaultTabStop?: number;
1187
1191
  }
1188
1192
 
1189
1193
  declare interface DocTable {
@@ -3391,6 +3395,16 @@ declare interface ShapeParagraph {
3391
3395
  /** `<a:pPr@rtl>` — whether the paragraph reads right-to-left
3392
3396
  * (ECMA-376 §21.1.2.2.7). Omitted (undefined) when false. */
3393
3397
  rtl?: boolean;
3398
+ /** `<a:pPr@marL>` — left margin in EMU (ECMA-376 §21.1.2.2.7,
3399
+ * `CT_TextParagraphProperties`). Direct attribute only — xlsx text boxes
3400
+ * have no lstStyle/level cascade. Omitted (undefined) when unset. */
3401
+ marL?: number;
3402
+ /** `<a:pPr@marR>` — right margin in EMU (ECMA-376 §21.1.2.2.7).
3403
+ * Omitted (undefined) when unset. */
3404
+ marR?: number;
3405
+ /** `<a:pPr@indent>` — first-line indent in EMU (negative = hanging),
3406
+ * ECMA-376 §21.1.2.2.7. Omitted (undefined) when unset. */
3407
+ indent?: number;
3394
3408
  runs: ShapeTextRun[];
3395
3409
  }
3396
3410
 
@@ -3511,6 +3525,18 @@ declare interface ShapeText_2 {
3511
3525
  /** ECMA-376 §17.3.1.33 `<w:spacing w:after>` of this text-box paragraph, in
3512
3526
  * pt — reserved BELOW the paragraph. Absent/0 ⇒ no offset. */
3513
3527
  spaceAfter?: number;
3528
+ /** ECMA-376 §17.3.1.12 `<w:ind w:left/@start>` — paragraph left indent (pt).
3529
+ * Absent/0 ⇒ flush to the box's inner left edge. */
3530
+ indentLeft?: number;
3531
+ /** ECMA-376 §17.3.1.12 `<w:ind w:right/@end>` — paragraph right indent (pt).
3532
+ * Absent/0 ⇒ flush to the box's inner right edge. */
3533
+ indentRight?: number;
3534
+ /** `<w:ind>` first-line indent (pt, SIGNED: `w:firstLine` positive,
3535
+ * `w:hanging` negative). A negative value hangs the first line further LEFT
3536
+ * than the continuation lines (the body renderer honors the sign too — Word
3537
+ * applies a signed hanging first-line list-independently). Absent/0 ⇒ the
3538
+ * first line aligns with the continuation lines. */
3539
+ indentFirst?: number;
3514
3540
  /** Zip path of an inline image inside this text-box paragraph
3515
3541
  * (`<w:drawing><wp:inline><a:blip r:embed>`), e.g. `word/media/image1.emf`.
3516
3542
  * Absent for a text-only paragraph. */
@@ -4387,6 +4413,7 @@ declare class XlsxViewer {
4387
4413
  private selectionOverlay;
4388
4414
  private keydownHandler;
4389
4415
  private pendingTap;
4416
+ private resizeDrag;
4390
4417
  /** DOM overlay element that shows the hovered cell's comment. Lives in
4391
4418
  * canvasArea above the scrollHost; `pointer-events:none` so it never blocks
4392
4419
  * cell interaction. */
@@ -4500,6 +4527,33 @@ declare class XlsxViewer {
4500
4527
  * Returns null when the point is in the cell grid (not a header).
4501
4528
  */
4502
4529
  private getHeaderHit;
4530
+ /**
4531
+ * If the pointer sits on a column/row-header border (within {@link
4532
+ * RESIZE_GRAB_PX}), return the resize target: which index to resize and the
4533
+ * fixed LTR edge it grows from (in canvasArea CSS px). Excel resizes the band
4534
+ * whose *trailing* border you grab — the column to the left of a vertical
4535
+ * border, the row above a horizontal one — so both that band and its
4536
+ * neighbour-to-the-far-side are checked. Geometry comes straight from {@link
4537
+ * getCellRect}, so the grab line always coincides with the drawn border at any
4538
+ * scroll offset / zoom / RTL. Returns null off the header borders.
4539
+ */
4540
+ private getResizeTarget;
4541
+ /**
4542
+ * Apply a live resize drag: size the band from its fixed origin edge to the
4543
+ * current pointer, clamp to {@link RESIZE_MIN_PX}, and write the result back
4544
+ * into the in-memory worksheet model in its native unit (Excel column widths /
4545
+ * points). This is a *view-only* mutation — the file is never written. The
4546
+ * memoized axis cache for this sheet is invalidated so every geometry read
4547
+ * (spacer, hit-test, overlay, renderer) sees the new size on the next frame.
4548
+ */
4549
+ private applyResize;
4550
+ /**
4551
+ * Change the cell-selection highlight color at runtime (see {@link
4552
+ * XlsxViewerOptions.selectionColor}). The border takes the color as-is and the
4553
+ * fill becomes a translucent shade of it; the current selection repaints
4554
+ * immediately.
4555
+ */
4556
+ setSelectionColor(color: string): void;
4503
4557
  /** Copy the selected cell range as tab-separated text to the clipboard. */
4504
4558
  private copySelection;
4505
4559
  private updateSelectionOverlay;
@@ -4576,9 +4630,15 @@ declare class XlsxViewer {
4576
4630
  destroy(): void;
4577
4631
  }
4578
4632
 
4579
- declare interface XlsxViewerOptions {
4633
+ declare interface XlsxViewerOptions extends LoadOptions_2 {
4580
4634
  /** Scale factor for cell/header dimensions (default 1). 0.5 = half size. */
4581
4635
  cellScale?: number;
4636
+ /**
4637
+ * Enable drag-to-resize of column widths / row heights by dragging header
4638
+ * borders. Resizing only changes the on-screen view — it never modifies the
4639
+ * loaded file. Default: true.
4640
+ */
4641
+ resizable?: boolean;
4582
4642
  /** Show the Excel-style zoom slider at the right end of the sheet-tab bar.
4583
4643
  * Default `true`. Set `false` to hide it (e.g. when the host supplies its
4584
4644
  * own zoom control). */
@@ -4601,27 +4661,15 @@ declare interface XlsxViewerOptions {
4601
4661
  /** Called when the selected cell range changes. null means no selection. */
4602
4662
  onSelectionChange?: (selection: CellRange_2 | null) => void;
4603
4663
  /**
4604
- * Opt in to Google-Fonts-hosted, metric-compatible substitutes for the
4605
- * Office default fonts (Carlito for Calibri, Caladea for Cambria) so
4606
- * column layouts match Excel on systems without Office installed.
4607
- * Default `false`. See `XlsxWorkbook.LoadOptions.useGoogleFonts` for the
4608
- * privacy implications.
4609
- */
4610
- useGoogleFonts?: boolean;
4611
- /**
4612
- * Override the per-entry ZIP decompression cap (bytes) used by the
4613
- * zip-bomb guard in the Rust parser. Defaults to 512 MiB. Zero / negative
4614
- * values fall back to the default.
4664
+ * Color of the cell-selection highlight. A single CSS color drives both the
4665
+ * selection rectangle's border (drawn in this color) and its fill (the same
4666
+ * color made translucent see {@link selectionOverlayStyle}), so callers pick
4667
+ * one accent color instead of a separate border + background. Any CSS color
4668
+ * string works (`#1a73e8`, `rgb(...)`, `tomato`, …). Default `#1a73e8`
4669
+ * (Google blue), matching the historical look. Can also be changed at runtime
4670
+ * via {@link XlsxViewer.setSelectionColor}.
4615
4671
  */
4616
- maxZipEntryBytes?: number;
4617
- /**
4618
- * Opt-in OMML equation engine for rendering math in shapes/text boxes.
4619
- * Import it from the separate `@silurus/ooxml/math` entry and pass it in
4620
- * (`import { math } from '@silurus/ooxml/math'`). When omitted, equations are
4621
- * skipped and the ~3 MB engine never enters the bundle (tree-shaken). Same
4622
- * dependency-injection contract as the docx/pptx viewers.
4623
- */
4624
- math?: MathRenderer;
4672
+ selectionColor?: string;
4625
4673
  /**
4626
4674
  * `'main'` (default): parse in a worker, render on the main thread. `'worker'`:
4627
4675
  * parse AND render entirely inside the worker and paint the returned
@@ -940,6 +940,16 @@ export declare interface ShapeParagraph {
940
940
  /** `<a:pPr@rtl>` — whether the paragraph reads right-to-left
941
941
  * (ECMA-376 §21.1.2.2.7). Omitted (undefined) when false. */
942
942
  rtl?: boolean;
943
+ /** `<a:pPr@marL>` — left margin in EMU (ECMA-376 §21.1.2.2.7,
944
+ * `CT_TextParagraphProperties`). Direct attribute only — xlsx text boxes
945
+ * have no lstStyle/level cascade. Omitted (undefined) when unset. */
946
+ marL?: number;
947
+ /** `<a:pPr@marR>` — right margin in EMU (ECMA-376 §21.1.2.2.7).
948
+ * Omitted (undefined) when unset. */
949
+ marR?: number;
950
+ /** `<a:pPr@indent>` — first-line indent in EMU (negative = hanging),
951
+ * ECMA-376 §21.1.2.2.7. Omitted (undefined) when unset. */
952
+ indent?: number;
943
953
  runs: ShapeTextRun[];
944
954
  }
945
955
 
@@ -1329,6 +1339,7 @@ export declare class XlsxViewer {
1329
1339
  private selectionOverlay;
1330
1340
  private keydownHandler;
1331
1341
  private pendingTap;
1342
+ private resizeDrag;
1332
1343
  /** DOM overlay element that shows the hovered cell's comment. Lives in
1333
1344
  * canvasArea above the scrollHost; `pointer-events:none` so it never blocks
1334
1345
  * cell interaction. */
@@ -1442,6 +1453,33 @@ export declare class XlsxViewer {
1442
1453
  * Returns null when the point is in the cell grid (not a header).
1443
1454
  */
1444
1455
  private getHeaderHit;
1456
+ /**
1457
+ * If the pointer sits on a column/row-header border (within {@link
1458
+ * RESIZE_GRAB_PX}), return the resize target: which index to resize and the
1459
+ * fixed LTR edge it grows from (in canvasArea CSS px). Excel resizes the band
1460
+ * whose *trailing* border you grab — the column to the left of a vertical
1461
+ * border, the row above a horizontal one — so both that band and its
1462
+ * neighbour-to-the-far-side are checked. Geometry comes straight from {@link
1463
+ * getCellRect}, so the grab line always coincides with the drawn border at any
1464
+ * scroll offset / zoom / RTL. Returns null off the header borders.
1465
+ */
1466
+ private getResizeTarget;
1467
+ /**
1468
+ * Apply a live resize drag: size the band from its fixed origin edge to the
1469
+ * current pointer, clamp to {@link RESIZE_MIN_PX}, and write the result back
1470
+ * into the in-memory worksheet model in its native unit (Excel column widths /
1471
+ * points). This is a *view-only* mutation — the file is never written. The
1472
+ * memoized axis cache for this sheet is invalidated so every geometry read
1473
+ * (spacer, hit-test, overlay, renderer) sees the new size on the next frame.
1474
+ */
1475
+ private applyResize;
1476
+ /**
1477
+ * Change the cell-selection highlight color at runtime (see {@link
1478
+ * XlsxViewerOptions.selectionColor}). The border takes the color as-is and the
1479
+ * fill becomes a translucent shade of it; the current selection repaints
1480
+ * immediately.
1481
+ */
1482
+ setSelectionColor(color: string): void;
1445
1483
  /** Copy the selected cell range as tab-separated text to the clipboard. */
1446
1484
  private copySelection;
1447
1485
  private updateSelectionOverlay;
@@ -1518,9 +1556,15 @@ export declare class XlsxViewer {
1518
1556
  destroy(): void;
1519
1557
  }
1520
1558
 
1521
- export declare interface XlsxViewerOptions {
1559
+ export declare interface XlsxViewerOptions extends LoadOptions_2 {
1522
1560
  /** Scale factor for cell/header dimensions (default 1). 0.5 = half size. */
1523
1561
  cellScale?: number;
1562
+ /**
1563
+ * Enable drag-to-resize of column widths / row heights by dragging header
1564
+ * borders. Resizing only changes the on-screen view — it never modifies the
1565
+ * loaded file. Default: true.
1566
+ */
1567
+ resizable?: boolean;
1524
1568
  /** Show the Excel-style zoom slider at the right end of the sheet-tab bar.
1525
1569
  * Default `true`. Set `false` to hide it (e.g. when the host supplies its
1526
1570
  * own zoom control). */
@@ -1543,27 +1587,15 @@ export declare interface XlsxViewerOptions {
1543
1587
  /** Called when the selected cell range changes. null means no selection. */
1544
1588
  onSelectionChange?: (selection: CellRange | null) => void;
1545
1589
  /**
1546
- * Opt in to Google-Fonts-hosted, metric-compatible substitutes for the
1547
- * Office default fonts (Carlito for Calibri, Caladea for Cambria) so
1548
- * column layouts match Excel on systems without Office installed.
1549
- * Default `false`. See `XlsxWorkbook.LoadOptions.useGoogleFonts` for the
1550
- * privacy implications.
1551
- */
1552
- useGoogleFonts?: boolean;
1553
- /**
1554
- * Override the per-entry ZIP decompression cap (bytes) used by the
1555
- * zip-bomb guard in the Rust parser. Defaults to 512 MiB. Zero / negative
1556
- * values fall back to the default.
1590
+ * Color of the cell-selection highlight. A single CSS color drives both the
1591
+ * selection rectangle's border (drawn in this color) and its fill (the same
1592
+ * color made translucent see {@link selectionOverlayStyle}), so callers pick
1593
+ * one accent color instead of a separate border + background. Any CSS color
1594
+ * string works (`#1a73e8`, `rgb(...)`, `tomato`, …). Default `#1a73e8`
1595
+ * (Google blue), matching the historical look. Can also be changed at runtime
1596
+ * via {@link XlsxViewer.setSelectionColor}.
1557
1597
  */
1558
- maxZipEntryBytes?: number;
1559
- /**
1560
- * Opt-in OMML equation engine for rendering math in shapes/text boxes.
1561
- * Import it from the separate `@silurus/ooxml/math` entry and pass it in
1562
- * (`import { math } from '@silurus/ooxml/math'`). When omitted, equations are
1563
- * skipped and the ~3 MB engine never enters the bundle (tree-shaken). Same
1564
- * dependency-injection contract as the docx/pptx viewers.
1565
- */
1566
- math?: MathRenderer;
1598
+ selectionColor?: string;
1567
1599
  /**
1568
1600
  * `'main'` (default): parse in a worker, render on the main thread. `'worker'`:
1569
1601
  * parse AND render entirely inside the worker and paint the returned