@silurus/ooxml 0.11.0 → 0.13.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.
@@ -141,23 +141,46 @@ export declare class DocxDocument {
141
141
  renderPage(target: HTMLCanvasElement | OffscreenCanvas, pageIndex: number, opts?: RenderPageOptions): Promise<void>;
142
142
  }
143
143
 
144
+ /** Information about a rendered text segment for building a transparent selection overlay. */
145
+ export declare interface DocxTextRunInfo {
146
+ text: string;
147
+ /** Left edge in canvas CSS px. */
148
+ x: number;
149
+ /** Top of line box in canvas CSS px. */
150
+ y: number;
151
+ /** Measured text width in CSS px. */
152
+ w: number;
153
+ /** Line height in CSS px. */
154
+ h: number;
155
+ /** Font size in CSS px. */
156
+ fontSize: number;
157
+ }
158
+
144
159
  export declare class DocxViewer {
145
160
  private _doc;
146
161
  private _currentPage;
147
162
  private _canvas;
163
+ private _wrapper;
164
+ private _textLayer;
148
165
  private _opts;
149
166
  constructor(canvas: HTMLCanvasElement, opts?: DocxViewerOptions);
150
167
  load(source: string | ArrayBuffer): Promise<void>;
151
168
  get pageCount(): number;
152
169
  get currentPage(): number;
153
- goToPage(index: number): void;
154
- nextPage(): void;
155
- prevPage(): void;
170
+ goToPage(index: number): Promise<void>;
171
+ nextPage(): Promise<void>;
172
+ prevPage(): Promise<void>;
156
173
  private _render;
174
+ private _buildTextLayer;
157
175
  }
158
176
 
159
177
  declare interface DocxViewerOptions extends RenderPageOptions {
160
178
  container?: HTMLElement;
179
+ /**
180
+ * When true, adds a transparent text overlay div over the canvas so the
181
+ * browser's native text selection works on document content.
182
+ */
183
+ enableTextSelection?: boolean;
161
184
  }
162
185
 
163
186
  declare interface FieldRun {
@@ -308,6 +331,15 @@ export declare interface RenderPageOptions {
308
331
  width?: number;
309
332
  dpr?: number;
310
333
  defaultTextColor?: string;
334
+ /** Called for each rendered text segment. Used to build a transparent text selection overlay. */
335
+ onTextRun?: (run: {
336
+ text: string;
337
+ x: number;
338
+ y: number;
339
+ w: number;
340
+ h: number;
341
+ fontSize: number;
342
+ }) => void;
311
343
  }
312
344
 
313
345
  export declare interface SectionProps {
@@ -95,6 +95,11 @@ declare interface Cell {
95
95
  formula?: string;
96
96
  }
97
97
 
98
+ declare interface CellAddress {
99
+ row: number;
100
+ col: number;
101
+ }
102
+
98
103
  declare interface CellBorders {
99
104
  top: BorderSpec | null;
100
105
  bottom: BorderSpec | null;
@@ -109,6 +114,12 @@ declare interface CellRange {
109
114
  right: number;
110
115
  }
111
116
 
117
+ declare interface CellRange_2 {
118
+ anchor: CellAddress;
119
+ active: CellAddress;
120
+ mode: SelectionMode_2;
121
+ }
122
+
112
123
  declare type CellValue = {
113
124
  type: 'empty';
114
125
  } | {
@@ -252,6 +263,36 @@ declare interface ChartData {
252
263
  catAxisFontSizeHpt?: number | null;
253
264
  /** Value axis tick-label font size in hpt. */
254
265
  valAxisFontSizeHpt?: number | null;
266
+ /** Outer chartSpace background (ECMA-376 §21.2.2.5 `<c:spPr>`). Hex without
267
+ * '#' for a solid fill, undefined for `<a:noFill/>` or an absent spPr.
268
+ * Combine with `hasChartSpPr` to distinguish explicit-transparent from
269
+ * default-opaque-white. */
270
+ chartBg?: string | null;
271
+ /** True when the parser saw a `<c:chartSpace><c:spPr>` element. Lets the
272
+ * adapter tell "spec said noFill → transparent" from "no spPr → default". */
273
+ hasChartSpPr?: boolean;
274
+ /** `<c:legend><c:manualLayout>` fractions of chart space (§21.2.2.31). */
275
+ legendManualLayout?: LegendManualLayout | null;
276
+ /** `<c:catAx><c:delete val="1"/>` — hide the category axis (§21.2.2.40). */
277
+ catAxisHidden?: boolean;
278
+ /** `<c:valAx><c:delete val="1"/>` — hide the value axis (§21.2.2.40). */
279
+ valAxisHidden?: boolean;
280
+ /** `<c:valAx><c:numFmt@formatCode>` — number format for value-axis tick
281
+ * labels (ECMA-376 §21.2.2.21). */
282
+ valAxisFormatCode?: string | null;
283
+ /** `<c:barChart><c:gapWidth>` — space between category groups as a percent
284
+ * of bar width (§21.2.2.13). */
285
+ barGapWidth?: number | null;
286
+ /** `<c:barChart><c:overlap>` — signed percent overlap between bars in a
287
+ * cluster (§21.2.2.25). Negative = gap. */
288
+ barOverlap?: number | null;
289
+ /** `<c:dLbls><c:dLblPos>` — data label position (§21.2.2.16). */
290
+ dataLabelPosition?: string | null;
291
+ /** Hex (no `#`) for data label text color, resolved from `<c:dLbls><c:txPr>`. */
292
+ dataLabelFontColor?: string | null;
293
+ /** `<c:dLbls><c:numFmt@formatCode>` — chart-level override for data label
294
+ * number format (§21.2.2.35). */
295
+ dataLabelFormatCode?: string | null;
255
296
  }
256
297
 
257
298
  /**
@@ -329,6 +370,12 @@ declare interface ChartSeries {
329
370
  * that don't parse markers (e.g. pptx today) keep their existing behavior.
330
371
  */
331
372
  showMarker?: boolean | null;
373
+ /**
374
+ * Excel number-format code for this series' values (ECMA-376 §21.2.2.37,
375
+ * `<c:val>/<c:numRef>/<c:formatCode>`). Used to format data labels when the
376
+ * chart-level `<c:dLbls><c:numFmt>` is not set. null = no series-level code.
377
+ */
378
+ valFormatCode?: string | null;
332
379
  }
333
380
 
334
381
  declare interface ConditionalFormat {
@@ -435,7 +482,8 @@ export declare namespace docx {
435
482
  DocRun,
436
483
  TextRun_2 as TextRun,
437
484
  ImageRun,
438
- RenderPageOptions
485
+ RenderPageOptions,
486
+ DocxTextRunInfo
439
487
  }
440
488
  }
441
489
 
@@ -453,29 +501,57 @@ declare class DocxDocument {
453
501
  renderPage(target: HTMLCanvasElement | OffscreenCanvas, pageIndex: number, opts?: RenderPageOptions): Promise<void>;
454
502
  }
455
503
 
504
+ /** Information about a rendered text segment for building a transparent selection overlay. */
505
+ declare interface DocxTextRunInfo {
506
+ text: string;
507
+ /** Left edge in canvas CSS px. */
508
+ x: number;
509
+ /** Top of line box in canvas CSS px. */
510
+ y: number;
511
+ /** Measured text width in CSS px. */
512
+ w: number;
513
+ /** Line height in CSS px. */
514
+ h: number;
515
+ /** Font size in CSS px. */
516
+ fontSize: number;
517
+ }
518
+
456
519
  declare class DocxViewer {
457
520
  private _doc;
458
521
  private _currentPage;
459
522
  private _canvas;
523
+ private _wrapper;
524
+ private _textLayer;
460
525
  private _opts;
461
526
  constructor(canvas: HTMLCanvasElement, opts?: DocxViewerOptions);
462
527
  load(source: string | ArrayBuffer): Promise<void>;
463
528
  get pageCount(): number;
464
529
  get currentPage(): number;
465
- goToPage(index: number): void;
466
- nextPage(): void;
467
- prevPage(): void;
530
+ goToPage(index: number): Promise<void>;
531
+ nextPage(): Promise<void>;
532
+ prevPage(): Promise<void>;
468
533
  private _render;
534
+ private _buildTextLayer;
469
535
  }
470
536
 
471
537
  declare interface DocxViewerOptions extends RenderPageOptions {
472
538
  container?: HTMLElement;
539
+ /**
540
+ * When true, adds a transparent text overlay div over the canvas so the
541
+ * browser's native text selection works on document content.
542
+ */
543
+ enableTextSelection?: boolean;
473
544
  }
474
545
 
475
546
  declare interface Dxf {
476
547
  font: Font | null;
477
548
  fill: Fill_2 | null;
478
549
  border: Border | null;
550
+ /** Number format override from the dxf (ECMA-376 §18.8.17). When a
551
+ * conditional-formatting rule matches, this numFmt replaces the cell's own
552
+ * style numFmt for rendering — e.g. switching a calendar cell from `d` to
553
+ * `m"月"d"日"` on the first day of each month. */
554
+ numFmt?: NumFmt | null;
479
555
  }
480
556
 
481
557
  declare interface FieldRun {
@@ -632,6 +708,15 @@ declare interface ImageRun {
632
708
  wrapSide?: string;
633
709
  }
634
710
 
711
+ declare interface LegendManualLayout {
712
+ xMode: string;
713
+ yMode: string;
714
+ x: number;
715
+ y: number;
716
+ w: number;
717
+ h: number;
718
+ }
719
+
635
720
  declare interface LineBreak {
636
721
  type: 'break';
637
722
  }
@@ -778,6 +863,41 @@ declare type PathCmd = {
778
863
  };
779
864
 
780
865
  declare type PathCmd_2 = {
866
+ op: 'moveTo';
867
+ x: number;
868
+ y: number;
869
+ } | {
870
+ op: 'lineTo';
871
+ x: number;
872
+ y: number;
873
+ } | {
874
+ op: 'cubicBezTo';
875
+ x1: number;
876
+ y1: number;
877
+ x2: number;
878
+ y2: number;
879
+ x3: number;
880
+ y3: number;
881
+ } | {
882
+ op: 'quadBezTo';
883
+ x1: number;
884
+ y1: number;
885
+ x2: number;
886
+ y2: number;
887
+ }
888
+ /** ECMA-376 §20.1.9.3. stAng/swAng in 60000ths of a degree. wr/hr in
889
+ * the path's own coordinate units. Pen position is the arc start. */
890
+ | {
891
+ op: 'arcTo';
892
+ wr: number;
893
+ hr: number;
894
+ stAng: number;
895
+ swAng: number;
896
+ } | {
897
+ op: 'close';
898
+ };
899
+
900
+ declare type PathCmd_3 = {
781
901
  cmd: 'moveTo';
782
902
  x: number;
783
903
  y: number;
@@ -803,6 +923,12 @@ declare type PathCmd_2 = {
803
923
  cmd: 'close';
804
924
  };
805
925
 
926
+ declare interface PathInfo {
927
+ w: number;
928
+ h: number;
929
+ commands: PathCmd_2[];
930
+ }
931
+
806
932
  declare interface PictureElement {
807
933
  type: 'picture';
808
934
  x: number;
@@ -839,6 +965,8 @@ export declare namespace pptx {
839
965
  RenderSlideOptions,
840
966
  renderSlide,
841
967
  RenderOptions,
968
+ TextRunInfo,
969
+ TextRunCallback,
842
970
  autoResize,
843
971
  AutoResizeOptions,
844
972
  Presentation,
@@ -922,6 +1050,8 @@ declare class PptxPresentation {
922
1050
  */
923
1051
  declare class PptxViewer {
924
1052
  private readonly canvas;
1053
+ private readonly wrapper;
1054
+ private textLayer;
925
1055
  private engine;
926
1056
  private readonly opts;
927
1057
  private currentSlide;
@@ -938,6 +1068,7 @@ declare class PptxViewer {
938
1068
  /** The underlying <canvas> element. */
939
1069
  get canvasElement(): HTMLCanvasElement;
940
1070
  private renderCurrentSlide;
1071
+ private _buildTextLayer;
941
1072
  /** Clean up the viewer and terminate the background worker. */
942
1073
  destroy(): void;
943
1074
  }
@@ -960,6 +1091,11 @@ declare interface PptxViewerOptions extends RenderOptions {
960
1091
  * badge over media posters.
961
1092
  */
962
1093
  enableMediaPlayback?: boolean;
1094
+ /**
1095
+ * When true, adds a transparent text overlay div over the canvas so the
1096
+ * browser's native text selection works on slide content.
1097
+ */
1098
+ enableTextSelection?: boolean;
963
1099
  }
964
1100
 
965
1101
  declare interface Presentation {
@@ -1006,13 +1142,22 @@ declare interface RenderPageOptions {
1006
1142
  width?: number;
1007
1143
  dpr?: number;
1008
1144
  defaultTextColor?: string;
1145
+ /** Called for each rendered text segment. Used to build a transparent text selection overlay. */
1146
+ onTextRun?: (run: {
1147
+ text: string;
1148
+ x: number;
1149
+ y: number;
1150
+ w: number;
1151
+ h: number;
1152
+ fontSize: number;
1153
+ }) => void;
1009
1154
  }
1010
1155
 
1011
1156
  /**
1012
1157
  * Render a single slide onto a <canvas> element.
1013
1158
  * Returns the canvas for convenience.
1014
1159
  */
1015
- declare function renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slide: Slide, slideWidth: number, slideHeight: number, opts?: RenderOptions): Promise<HTMLCanvasElement | OffscreenCanvas>;
1160
+ declare function renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slide: Slide, slideWidth: number, slideHeight: number, opts?: RenderOptions, onTextRun?: TextRunCallback): Promise<HTMLCanvasElement | OffscreenCanvas>;
1016
1161
 
1017
1162
  /** Options for rendering a single slide onto a canvas. */
1018
1163
  declare interface RenderSlideOptions {
@@ -1020,6 +1165,8 @@ declare interface RenderSlideOptions {
1020
1165
  width?: number;
1021
1166
  /** Device pixel ratio. Defaults to window.devicePixelRatio or 1. */
1022
1167
  dpr?: number;
1168
+ /** Called for each rendered text segment. Used to build a transparent text selection overlay. */
1169
+ onTextRun?: TextRunCallback;
1023
1170
  /**
1024
1171
  * Skip drawing the play badge overlay on media elements. Used internally by
1025
1172
  * {@link PptxPresentation.presentSlide} so its interactive handle can draw
@@ -1042,6 +1189,8 @@ declare interface RenderViewportOptions {
1042
1189
  cellScale?: number;
1043
1190
  /** Pre-loaded Image elements keyed by their dataUrl (for ImageAnchor rendering). */
1044
1191
  loadedImages?: Map<string, HTMLImageElement>;
1192
+ /** Called once per cell that contains text, with canvas-pixel position and cell address. */
1193
+ onTextRun?: (info: TextRunInfo_2) => void;
1045
1194
  }
1046
1195
 
1047
1196
  declare interface Row {
@@ -1084,6 +1233,8 @@ declare interface SectionProps {
1084
1233
  docGridLinePitch?: number | null;
1085
1234
  }
1086
1235
 
1236
+ declare type SelectionMode_2 = 'cells' | 'rows' | 'cols' | 'all';
1237
+
1087
1238
  declare interface Shadow {
1088
1239
  color: string;
1089
1240
  alpha: number;
@@ -1093,6 +1244,18 @@ declare interface Shadow {
1093
1244
  dir: number;
1094
1245
  }
1095
1246
 
1247
+ declare interface ShapeAnchor {
1248
+ fromCol: number;
1249
+ fromColOff: number;
1250
+ fromRow: number;
1251
+ fromRowOff: number;
1252
+ toCol: number;
1253
+ toColOff: number;
1254
+ toRow: number;
1255
+ toRowOff: number;
1256
+ shapes: ShapeInfo[];
1257
+ }
1258
+
1096
1259
  declare interface ShapeElement {
1097
1260
  type: 'shape';
1098
1261
  x: number;
@@ -1142,6 +1305,36 @@ declare type ShapeFill = {
1142
1305
  gradType: string;
1143
1306
  };
1144
1307
 
1308
+ declare type ShapeGeom = {
1309
+ type: 'preset';
1310
+ name: string;
1311
+ } | {
1312
+ type: 'custom';
1313
+ paths: PathInfo[];
1314
+ }
1315
+ /** Bitmap picture leaf inside a `<xdr:grpSp>`. `dataUrl` is a pre-encoded
1316
+ * `data:<mime>;base64,…` produced by the Rust parser from the drawing's
1317
+ * relationship target. */
1318
+ | {
1319
+ type: 'image';
1320
+ dataUrl: string;
1321
+ };
1322
+
1323
+ declare interface ShapeInfo {
1324
+ /** Normalized [0,1] position/size relative to the anchor rect. */
1325
+ x: number;
1326
+ y: number;
1327
+ w: number;
1328
+ h: number;
1329
+ /** Rotation in degrees, clockwise. */
1330
+ rot: number;
1331
+ fillColor?: string;
1332
+ strokeColor?: string;
1333
+ /** Stroke width in EMU. 0 = no stroke. */
1334
+ strokeWidth: number;
1335
+ geom: ShapeGeom;
1336
+ }
1337
+
1145
1338
  declare interface ShapeRun {
1146
1339
  widthPt: number;
1147
1340
  heightPt: number;
@@ -1156,7 +1349,7 @@ declare interface ShapeRun {
1156
1349
  /** Document-order index within a group; lower values render first. */
1157
1350
  zOrder: number;
1158
1351
  /** Normalized [0,1] custom-geometry sub-paths */
1159
- subpaths: PathCmd_2[][];
1352
+ subpaths: PathCmd_3[][];
1160
1353
  fill: ShapeFill | null;
1161
1354
  stroke: string | null;
1162
1355
  strokeWidth?: number;
@@ -1175,6 +1368,24 @@ declare interface SheetMeta {
1175
1368
  rId: string;
1176
1369
  }
1177
1370
 
1371
+ declare interface SlicerAnchor {
1372
+ fromCol: number;
1373
+ fromColOff: number;
1374
+ fromRow: number;
1375
+ fromRowOff: number;
1376
+ toCol: number;
1377
+ toColOff: number;
1378
+ toRow: number;
1379
+ toRowOff: number;
1380
+ caption: string;
1381
+ items: SlicerItem[];
1382
+ }
1383
+
1384
+ declare interface SlicerItem {
1385
+ name: string;
1386
+ selected: boolean;
1387
+ }
1388
+
1178
1389
  declare interface Slide {
1179
1390
  index: number;
1180
1391
  /** 1-based slide number (index + 1); used to render slidenum fields */
@@ -1346,6 +1557,8 @@ declare interface TextRun_2 {
1346
1557
  highlight?: string | null;
1347
1558
  }
1348
1559
 
1560
+ declare type TextRunCallback = (run: TextRunInfo) => void;
1561
+
1349
1562
  declare interface TextRunData {
1350
1563
  type: 'text';
1351
1564
  text: string;
@@ -1366,6 +1579,51 @@ declare interface TextRunData {
1366
1579
  fieldType?: string;
1367
1580
  }
1368
1581
 
1582
+ /** Information about a rendered text segment for building a transparent selection overlay. */
1583
+ declare interface TextRunInfo {
1584
+ text: string;
1585
+ /** X position in CSS px, relative to the shape's top-left corner. */
1586
+ inShapeX: number;
1587
+ /** Y position (top of line box) in CSS px, relative to the shape's top-left corner. */
1588
+ inShapeY: number;
1589
+ /** Measured text width in CSS px. */
1590
+ w: number;
1591
+ /** Line height in CSS px. */
1592
+ h: number;
1593
+ /** Font size in CSS px. */
1594
+ fontSize: number;
1595
+ /** Shape's left edge in canvas CSS px. */
1596
+ shapeX: number;
1597
+ /** Shape's top edge in canvas CSS px. */
1598
+ shapeY: number;
1599
+ /** Shape's width in canvas CSS px. */
1600
+ shapeW: number;
1601
+ /** Shape's height in canvas CSS px. */
1602
+ shapeH: number;
1603
+ /** Shape rotation in degrees (clockwise). */
1604
+ rotation: number;
1605
+ /**
1606
+ * Additional rotation from a vertical text body (`vert="vert"` → 90,
1607
+ * `vert="vert270"` → -90). The CSS overlay must add this to `rotation`.
1608
+ */
1609
+ textBodyRotation?: number;
1610
+ }
1611
+
1612
+ /** Emitted once per cell that has text, with the cell's canvas-pixel bounds. */
1613
+ declare interface TextRunInfo_2 {
1614
+ text: string;
1615
+ /** Canvas CSS-pixel x of the cell's top-left corner. */
1616
+ x: number;
1617
+ /** Canvas CSS-pixel y of the cell's top-left corner. */
1618
+ y: number;
1619
+ /** Cell width in canvas CSS pixels. */
1620
+ width: number;
1621
+ /** Cell height in canvas CSS pixels. */
1622
+ height: number;
1623
+ row: number;
1624
+ col: number;
1625
+ }
1626
+
1369
1627
  declare interface ViewportRange {
1370
1628
  row: number;
1371
1629
  col: number;
@@ -1390,6 +1648,10 @@ declare interface Worksheet {
1390
1648
  conditionalFormats: ConditionalFormat[];
1391
1649
  images: ImageAnchor[];
1392
1650
  charts: ChartAnchor[];
1651
+ /** Grouped shapes from `<xdr:grpSp>` inside twoCellAnchors
1652
+ * (ECMA-376 §20.5.2.17). Each anchor holds leaf shapes pre-flattened
1653
+ * with normalized [0,1] geometry relative to the anchor rect. */
1654
+ shapeGroups?: ShapeAnchor[];
1393
1655
  /** Whether to display zero values (ECMA-376 §18.3.1.94). Defaults to true. */
1394
1656
  showZeros?: boolean;
1395
1657
  /** Whether to draw default grid lines (ECMA-376 §18.3.1.83
@@ -1412,6 +1674,10 @@ declare interface Worksheet {
1412
1674
  /** Excel Tables on this sheet (ECMA-376 §18.5). The renderer overlays a
1413
1675
  * built-in style (bold header, banded rows) on the given ranges. */
1414
1676
  tables?: TableInfo[];
1677
+ /** Pivot / table slicers (Office 2010+ extension). Each anchor carries a
1678
+ * caption and the saved item list (with selection flags) so the renderer
1679
+ * can draw a static button bank without the live pivot engine. */
1680
+ slicers?: SlicerAnchor[];
1415
1681
  }
1416
1682
 
1417
1683
  export declare namespace xlsx {
@@ -1419,6 +1685,9 @@ export declare namespace xlsx {
1419
1685
  XlsxWorkbook,
1420
1686
  XlsxViewer,
1421
1687
  XlsxViewerOptions,
1688
+ CellAddress,
1689
+ CellRange_2 as CellRange,
1690
+ SelectionMode_2 as SelectionMode,
1422
1691
  autoResize,
1423
1692
  AutoResizeOptions,
1424
1693
  Workbook,
@@ -1437,7 +1706,8 @@ export declare namespace xlsx {
1437
1706
  MergeCell,
1438
1707
  ParsedWorkbook,
1439
1708
  ViewportRange,
1440
- RenderViewportOptions
1709
+ RenderViewportOptions,
1710
+ TextRunInfo_2 as TextRunInfo
1441
1711
  }
1442
1712
  }
1443
1713
 
@@ -1456,6 +1726,11 @@ declare interface XlsxChartSeries {
1456
1726
  /** Marker visibility resolved from `<c:marker>`/chart-level default
1457
1727
  * (ECMA-376 §21.2.2.32). */
1458
1728
  showMarker?: boolean;
1729
+ /** `<c:val>/<c:numRef>/<c:formatCode>` — Excel number format for series
1730
+ * values (ECMA-376 §21.2.2.37). */
1731
+ valFormatCode?: string | null;
1732
+ /** `<c:ser><c:order>` — stacking/legend display order (§21.2.2.28). */
1733
+ order?: number;
1459
1734
  }
1460
1735
 
1461
1736
  declare class XlsxViewer {
@@ -1470,9 +1745,30 @@ declare class XlsxViewer {
1470
1745
  private currentWorksheet;
1471
1746
  private opts;
1472
1747
  private resizeObserver;
1748
+ private anchorCell;
1749
+ private activeCell;
1750
+ private selectionMode;
1751
+ private isSelecting;
1752
+ private selectionOverlay;
1753
+ private keydownHandler;
1473
1754
  constructor(container: HTMLElement, opts?: XlsxViewerOptions);
1474
1755
  load(source: string | ArrayBuffer): Promise<void>;
1475
1756
  showSheet(index: number): Promise<void>;
1757
+ /** Returns the cell at canvas-client coordinates, or null if outside the cell grid. */
1758
+ getCellAt(clientX: number, clientY: number): CellAddress | null;
1759
+ /** Returns the CSS-pixel rect of a cell within canvasArea, or null if not computable. */
1760
+ private getCellRect;
1761
+ /** Returns the current selection, including mode. */
1762
+ get selection(): CellRange_2 | null;
1763
+ /**
1764
+ * Returns what the header area contains at the given client coordinates.
1765
+ * Returns null when the point is in the cell grid (not a header).
1766
+ */
1767
+ private getHeaderHit;
1768
+ /** Copy the selected cell range as tab-separated text to the clipboard. */
1769
+ private copySelection;
1770
+ private updateSelectionOverlay;
1771
+ private setupSelectionEvents;
1476
1772
  private buildTabs;
1477
1773
  private updateTabActive;
1478
1774
  private tabStyle;
@@ -1488,6 +1784,8 @@ declare interface XlsxViewerOptions {
1488
1784
  onReady?: (sheetNames: string[]) => void;
1489
1785
  onSheetChange?: (index: number, name: string) => void;
1490
1786
  onError?: (err: Error) => void;
1787
+ /** Called when the selected cell range changes. null means no selection. */
1788
+ onSelectionChange?: (selection: CellRange_2 | null) => void;
1491
1789
  }
1492
1790
 
1493
1791
  declare class XlsxWorkbook {
@@ -123,6 +123,12 @@ declare interface ChartSeries {
123
123
  * that don't parse markers (e.g. pptx today) keep their existing behavior.
124
124
  */
125
125
  showMarker?: boolean | null;
126
+ /**
127
+ * Excel number-format code for this series' values (ECMA-376 §21.2.2.37,
128
+ * `<c:val>/<c:numRef>/<c:formatCode>`). Used to format data labels when the
129
+ * chart-level `<c:dLbls><c:numFmt>` is not set. null = no series-level code.
130
+ */
131
+ valFormatCode?: string | null;
126
132
  }
127
133
 
128
134
  export declare type Fill = SolidFill | NoFill | GradientFill;
@@ -323,6 +329,8 @@ export declare class PptxPresentation {
323
329
  */
324
330
  export declare class PptxViewer {
325
331
  private readonly canvas;
332
+ private readonly wrapper;
333
+ private textLayer;
326
334
  private engine;
327
335
  private readonly opts;
328
336
  private currentSlide;
@@ -339,6 +347,7 @@ export declare class PptxViewer {
339
347
  /** The underlying <canvas> element. */
340
348
  get canvasElement(): HTMLCanvasElement;
341
349
  private renderCurrentSlide;
350
+ private _buildTextLayer;
342
351
  /** Clean up the viewer and terminate the background worker. */
343
352
  destroy(): void;
344
353
  }
@@ -361,6 +370,11 @@ export declare interface PptxViewerOptions extends RenderOptions {
361
370
  * badge over media posters.
362
371
  */
363
372
  enableMediaPlayback?: boolean;
373
+ /**
374
+ * When true, adds a transparent text overlay div over the canvas so the
375
+ * browser's native text selection works on slide content.
376
+ */
377
+ enableTextSelection?: boolean;
364
378
  }
365
379
 
366
380
  export declare interface Presentation {
@@ -406,7 +420,7 @@ export declare interface RenderOptions {
406
420
  * Render a single slide onto a <canvas> element.
407
421
  * Returns the canvas for convenience.
408
422
  */
409
- export declare function renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slide: Slide, slideWidth: number, slideHeight: number, opts?: RenderOptions): Promise<HTMLCanvasElement | OffscreenCanvas>;
423
+ export declare function renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slide: Slide, slideWidth: number, slideHeight: number, opts?: RenderOptions, onTextRun?: TextRunCallback): Promise<HTMLCanvasElement | OffscreenCanvas>;
410
424
 
411
425
  /** Options for rendering a single slide onto a canvas. */
412
426
  export declare interface RenderSlideOptions {
@@ -414,6 +428,8 @@ export declare interface RenderSlideOptions {
414
428
  width?: number;
415
429
  /** Device pixel ratio. Defaults to window.devicePixelRatio or 1. */
416
430
  dpr?: number;
431
+ /** Called for each rendered text segment. Used to build a transparent text selection overlay. */
432
+ onTextRun?: TextRunCallback;
417
433
  /**
418
434
  * Skip drawing the play badge overlay on media elements. Used internally by
419
435
  * {@link PptxPresentation.presentSlide} so its interactive handle can draw
@@ -575,6 +591,8 @@ export declare interface TextBody {
575
591
 
576
592
  export declare type TextRun = TextRunData | LineBreak;
577
593
 
594
+ export declare type TextRunCallback = (run: TextRunInfo) => void;
595
+
578
596
  export declare interface TextRunData {
579
597
  type: 'text';
580
598
  text: string;
@@ -595,4 +613,34 @@ export declare interface TextRunData {
595
613
  fieldType?: string;
596
614
  }
597
615
 
616
+ /** Information about a rendered text segment for building a transparent selection overlay. */
617
+ export declare interface TextRunInfo {
618
+ text: string;
619
+ /** X position in CSS px, relative to the shape's top-left corner. */
620
+ inShapeX: number;
621
+ /** Y position (top of line box) in CSS px, relative to the shape's top-left corner. */
622
+ inShapeY: number;
623
+ /** Measured text width in CSS px. */
624
+ w: number;
625
+ /** Line height in CSS px. */
626
+ h: number;
627
+ /** Font size in CSS px. */
628
+ fontSize: number;
629
+ /** Shape's left edge in canvas CSS px. */
630
+ shapeX: number;
631
+ /** Shape's top edge in canvas CSS px. */
632
+ shapeY: number;
633
+ /** Shape's width in canvas CSS px. */
634
+ shapeW: number;
635
+ /** Shape's height in canvas CSS px. */
636
+ shapeH: number;
637
+ /** Shape rotation in degrees (clockwise). */
638
+ rotation: number;
639
+ /**
640
+ * Additional rotation from a vertical text body (`vert="vert"` → 90,
641
+ * `vert="vert270"` → -90). The CSS overlay must add this to `rotation`.
642
+ */
643
+ textBodyRotation?: number;
644
+ }
645
+
598
646
  export { }