@silurus/ooxml 0.70.2 → 0.72.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.
- package/README.md +122 -6
- package/THIRD_PARTY_NOTICES.md +356 -0
- package/dist/docx-BPF-eH0O.js +10183 -0
- package/dist/docx.mjs +3 -3
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/{line-metrics-DG9p1RvA.js → find-cursor-DTrEBxjE.js} +15946 -6230
- package/dist/highlight-rect-B--cPQOV.js +881 -0
- package/dist/index.mjs +4 -4
- package/dist/math.mjs +1 -1
- package/dist/pptx-BMxDfEYI.js +6641 -0
- package/dist/pptx.mjs +3 -3
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/render-worker-host-DL_kkykF.js +27 -0
- package/dist/render-worker-host-S0HOWgs0.js +27 -0
- package/dist/render-worker-host-l8yqDUfE.js +27 -0
- package/dist/{segments-BTivjRMw.js → segments-Da-soh2U.js} +1 -1
- package/dist/types/docx.d.ts +2109 -45
- package/dist/types/index.d.ts +2867 -96
- package/dist/types/pptx.d.ts +1302 -40
- package/dist/types/xlsx.d.ts +1229 -14
- package/dist/visible-index-5hdq_oAL.js +50 -0
- package/dist/{xlsx-B1XUgnO7.js → xlsx-bwQD8c1Q.js} +2209 -1214
- package/dist/xlsx.mjs +3 -3
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +5 -2
- package/dist/docx-BKsYFx78.js +0 -3895
- package/dist/pptx-B4xa92BQ.js +0 -3325
- package/dist/render-worker-host-2V2UCnvB.js +0 -27
- package/dist/render-worker-host-BcmXt3yA.js +0 -27
- package/dist/render-worker-host-UUYE6Oqt.js +0 -27
- package/dist/virtual-scroll-CsikPntn.js +0 -873
- package/dist/visible-index-B4ljB_dg.js +0 -1266
- /package/dist/{mathjax-BRfWlbSJ.js → mathjax-Dk_JzbFj.js} +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -61,11 +61,18 @@ declare interface BlipBullet {
|
|
|
61
61
|
/** MIME type of the blip at {@link BlipBullet.imagePath} (e.g. `image/png`). */
|
|
62
62
|
mimeType: string;
|
|
63
63
|
/**
|
|
64
|
-
* `<a:buSzPct val>` (ECMA-376 §21.1.2.4.
|
|
64
|
+
* `<a:buSzPct val>` (ECMA-376 §21.1.2.4.9) as a percentage of the text size
|
|
65
65
|
* (100 = same size). `null` when no explicit `<a:buSzPct>` is present, in
|
|
66
66
|
* which case the renderer uses the spec default of 100%.
|
|
67
67
|
*/
|
|
68
68
|
sizePct: number | null;
|
|
69
|
+
/**
|
|
70
|
+
* `<a:buSzPts val>` (ECMA-376 §21.1.2.4.10) — an ABSOLUTE marker size in
|
|
71
|
+
* points, independent of the text size. Mutually exclusive with {@link
|
|
72
|
+
* BlipBullet.sizePct} (both are the one `EG_TextBulletSize` choice). Omitted
|
|
73
|
+
* when no explicit `<a:buSzPts>` is present; when present it takes precedence.
|
|
74
|
+
*/
|
|
75
|
+
sizePts?: number;
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
declare type BodyElement = {
|
|
@@ -109,6 +116,19 @@ declare type BodyElement = {
|
|
|
109
116
|
* (size + margins). Absent when the sectPr inherits both pgSz and pgMar
|
|
110
117
|
* (the renderer then falls back to the body-level section geometry). */
|
|
111
118
|
geom?: SectionGeom;
|
|
119
|
+
/** ECMA-376 §17.6.12 `<w:pgNumType>` — this ENDING section's page-numbering
|
|
120
|
+
* settings (start / fmt). Absent ⇒ numbering continues; decimal. Carried
|
|
121
|
+
* separately from `geom` because a section may inherit its geometry yet
|
|
122
|
+
* still restart / re-format its page numbers. */
|
|
123
|
+
pageNumType?: PageNumType | null;
|
|
124
|
+
/** ECMA-376 §17.6.20 `<w:textDirection w:val>` — this ENDING section's
|
|
125
|
+
* flow direction (TRANSITIONAL ST_TextDirection, same enum and semantics
|
|
126
|
+
* as {@link SectionProps.textDirection}), so a vertical (tbRl/btLr)
|
|
127
|
+
* non-final section can coexist with a horizontal final section (issue
|
|
128
|
+
* #1000). Absent ⇒ horizontal ("lrTb" is collapsed by the parser).
|
|
129
|
+
* Carried separately from `geom` (like `pageNumType`) because a section
|
|
130
|
+
* may inherit its page geometry yet still set its own flow direction. */
|
|
131
|
+
textDirection?: string | null;
|
|
112
132
|
};
|
|
113
133
|
|
|
114
134
|
declare interface Border {
|
|
@@ -137,6 +157,27 @@ declare interface BorderSpec {
|
|
|
137
157
|
style: string;
|
|
138
158
|
}
|
|
139
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Populate a highlight overlay layer with one box per matched run-slice.
|
|
162
|
+
*
|
|
163
|
+
* Every box is positioned as a PERCENTAGE of `cssWidth`/`cssHeight`, and the
|
|
164
|
+
* container's own size is left untouched (`width:100%;height:100%` from the
|
|
165
|
+
* caller), so the highlights track the canvas's ACTUAL rendered box even when a
|
|
166
|
+
* consumer scales the canvas down with external CSS — mirroring
|
|
167
|
+
* {@link buildDocxTextLayer}.
|
|
168
|
+
*
|
|
169
|
+
* @param layer the overlay div (cleared here; sized `100%` by the caller).
|
|
170
|
+
* @param runs the page's runs (same array the page was rendered/text-layered from).
|
|
171
|
+
* @param matches the page's matches (run-slices + active flag).
|
|
172
|
+
* @param cssWidth the page's intended CSS width (px, number) — the x-axis % denominator.
|
|
173
|
+
* @param cssHeight the page's intended CSS height (px, number) — the y-axis % denominator.
|
|
174
|
+
* @param measureForFont returns a width-measurer primed with a run's `font`
|
|
175
|
+
* (the viewer closes over a canvas 2d context). Kept as a
|
|
176
|
+
* factory so the font is set once per run, not per glyph.
|
|
177
|
+
* @param colors optional colour overrides.
|
|
178
|
+
*/
|
|
179
|
+
declare function buildDocxHighlightLayer(layer: HTMLDivElement, runs: DocxTextRunInfo[], matches: DocxHighlightMatch[], cssWidth: number, cssHeight: number, measureForFont: (font: string) => (s: string) => number, colors?: DocxHighlightColors): void;
|
|
180
|
+
|
|
140
181
|
/**
|
|
141
182
|
* Build the transparent text-selection overlay for a rendered docx page: one
|
|
142
183
|
* absolutely-positioned, color-transparent `<span>` per {@link DocxTextRunInfo}
|
|
@@ -144,16 +185,65 @@ declare interface BorderSpec {
|
|
|
144
185
|
* lands on the drawn glyphs. Extracted verbatim from `DocxViewer._buildTextLayer`
|
|
145
186
|
* so both the pager (DocxViewer) and the continuous-scroll viewer (DocxScrollViewer)
|
|
146
187
|
* share one implementation; also public API for integrators building their own
|
|
147
|
-
* overlay (design §10).
|
|
148
|
-
*
|
|
188
|
+
* overlay (design §10). IX6 — usable in BOTH render modes: worker mode collects
|
|
189
|
+
* the same `DocxTextRunInfo[]` off-thread and ships it back beside the bitmap, so
|
|
190
|
+
* the overlay is built from identical geometry regardless of thread.
|
|
191
|
+
*
|
|
192
|
+
* Every span is positioned as a PERCENTAGE of `cssWidth`/`cssHeight` (the page's
|
|
193
|
+
* intended CSS-px box), never literal px, and the container's own width/height are
|
|
194
|
+
* left untouched (the caller sizes it `width:100%;height:100%`). This lets the
|
|
195
|
+
* overlay track the canvas's ACTUAL rendered box even when a consumer scales the
|
|
196
|
+
* canvas down with external CSS (`width:100%!important; height:auto`): the
|
|
197
|
+
* `display:inline-block` wrapper shrinks with the canvas, the `100%` container
|
|
198
|
+
* follows, and every `%`-placed span scales with it, so nothing overflows the
|
|
199
|
+
* wrapper into an ancestor's scroll area.
|
|
149
200
|
*
|
|
150
|
-
* @param layer
|
|
151
|
-
* @param runs
|
|
152
|
-
* @param
|
|
153
|
-
*
|
|
154
|
-
* @param
|
|
201
|
+
* @param layer the overlay div (sized `width:100%;height:100%` by the caller).
|
|
202
|
+
* @param runs per-run geometry from `renderPage({ onTextRun })`.
|
|
203
|
+
* @param cssWidth the page's intended CSS width (px, number) — the %
|
|
204
|
+
* denominator for the x axis.
|
|
205
|
+
* @param cssHeight the page's intended CSS height (px, number) — the %
|
|
206
|
+
* denominator for the y axis.
|
|
207
|
+
* @param onHyperlinkClick IX1 — invoked when a run carrying a resolved
|
|
208
|
+
* {@link HyperlinkTarget} is clicked. A hyperlink run's
|
|
209
|
+
* span keeps its transparent glyphs (the visible link
|
|
210
|
+
* colour/underline is already drawn on the canvas) but
|
|
211
|
+
* gains `cursor:pointer`, a `title` tooltip (the URL or
|
|
212
|
+
* bookmark ref) and this click handler. A plain
|
|
213
|
+
* `<span>` — not an `<a href>` — is used deliberately so
|
|
214
|
+
* the browser's own navigation can never bypass the
|
|
215
|
+
* caller's URL sanitisation. When omitted, link runs are
|
|
216
|
+
* rendered exactly like plain runs (no click affordance).
|
|
217
|
+
* @param measureForFont optional width-measurer factory (primed with a run's
|
|
218
|
+
* `font`), used ONLY to clamp a §17.3.2.10 縦中横
|
|
219
|
+
* (eastAsianVert) span to its drawn one-em cell (#836):
|
|
220
|
+
* the span composes a `scaleX(run.w / naturalWidth)` so
|
|
221
|
+
* its selection extent matches the compressed glyphs
|
|
222
|
+
* instead of the run's natural ~2× width. When omitted,
|
|
223
|
+
* a 縦中横 span keeps the bare rotate (no regression for
|
|
224
|
+
* callers that do not thread a measurer).
|
|
155
225
|
*/
|
|
156
|
-
declare function buildDocxTextLayer(layer: HTMLDivElement, runs: DocxTextRunInfo[],
|
|
226
|
+
declare function buildDocxTextLayer(layer: HTMLDivElement, runs: DocxTextRunInfo[], cssWidth: number, cssHeight: number, onHyperlinkClick?: (target: HyperlinkTarget) => void, measureForFont?: (font: string) => (s: string) => number): void;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Populate a highlight overlay layer with a box per matched run-slice, grouped
|
|
230
|
+
* by shape frame (with the shape's rotation) so each box lands on the drawn
|
|
231
|
+
* glyphs.
|
|
232
|
+
*
|
|
233
|
+
* All coordinates are PERCENTAGES of `cssWidth`/`cssHeight`, and the container's
|
|
234
|
+
* own size is left untouched (`width:100%;height:100%` from the caller), so the
|
|
235
|
+
* highlights track the canvas's ACTUAL rendered box even when a consumer scales
|
|
236
|
+
* the canvas down with external CSS — mirroring {@link buildPptxTextLayer}.
|
|
237
|
+
*
|
|
238
|
+
* @param layer the overlay div (cleared here; sized `100%` by the caller).
|
|
239
|
+
* @param runs the slide's runs (same array the slide was rendered from).
|
|
240
|
+
* @param matches the slide's matches (run-slices + active flag).
|
|
241
|
+
* @param cssWidth the slide's intended CSS width (px, number) — the % denominator.
|
|
242
|
+
* @param cssHeight the slide's intended CSS height (px, number) — the % denominator.
|
|
243
|
+
* @param measureForFont returns a width-measurer primed with a run's font.
|
|
244
|
+
* @param colors optional colour overrides.
|
|
245
|
+
*/
|
|
246
|
+
declare function buildPptxHighlightLayer(layer: HTMLDivElement, runs: PptxTextRunInfo[], matches: PptxHighlightMatch[], cssWidth: number, cssHeight: number, measureForFont: (font: string) => (s: string) => number, colors?: PptxHighlightColors): void;
|
|
157
247
|
|
|
158
248
|
/**
|
|
159
249
|
* Build the transparent text-selection overlay for a rendered pptx slide. Unlike
|
|
@@ -164,16 +254,42 @@ declare function buildDocxTextLayer(layer: HTMLDivElement, runs: DocxTextRunInfo
|
|
|
164
254
|
* shape div (`inShapeX`/`inShapeY`). Extracted verbatim from
|
|
165
255
|
* `PptxViewer._buildTextLayer` so the pager (PptxViewer) and the continuous-scroll
|
|
166
256
|
* viewer (PptxScrollViewer, WS4) share one implementation; public API for
|
|
167
|
-
* integrators (design §10).
|
|
168
|
-
*
|
|
257
|
+
* integrators (design §10). IX6 — usable in BOTH render modes: worker mode
|
|
258
|
+
* collects the same `PptxTextRunInfo[]` off-thread and ships it back beside the
|
|
259
|
+
* bitmap, so the overlay is built from identical geometry regardless of thread.
|
|
260
|
+
*
|
|
261
|
+
* IX1 — when a run carries a resolved `hyperlink` (from `<a:hlinkClick>`) and an
|
|
262
|
+
* `onHyperlinkClick` callback is supplied, its span becomes a click target
|
|
263
|
+
* (`cursor:pointer`, a `title` tooltip, and a `click` handler). A plain span
|
|
264
|
+
* (no hyperlink) is byte-identical to before. A JS click handler is used rather
|
|
265
|
+
* than an `<a href>` so the URL never bypasses the viewer's sanitisation.
|
|
266
|
+
*
|
|
267
|
+
* The overlay's coordinates are all PERCENTAGES of `cssWidth`/`cssHeight` (the
|
|
268
|
+
* slide's intended CSS-px box), never literal px, and the container's own
|
|
269
|
+
* `width`/`height` are left untouched (the caller sizes it `width:100%;
|
|
270
|
+
* height:100%` so it fills the wrapper). This lets the overlay track the canvas's
|
|
271
|
+
* ACTUAL rendered box even when a consumer scales the canvas down with external
|
|
272
|
+
* CSS (e.g. `width:100%!important;height:auto`): the wrapper (and therefore the
|
|
273
|
+
* `100%` container) shrinks with the canvas, and every `%`-placed child scales
|
|
274
|
+
* with it, so nothing overflows the wrapper into an ancestor's scroll area.
|
|
169
275
|
*
|
|
170
|
-
* @param layer the overlay div.
|
|
276
|
+
* @param layer the overlay div (sized `width:100%;height:100%` by the caller).
|
|
171
277
|
* @param runs per-run + per-shape geometry from `renderSlide({ onTextRun })`.
|
|
172
|
-
* @param cssWidth the
|
|
173
|
-
* @param cssHeight the
|
|
278
|
+
* @param cssWidth the slide's intended CSS width (px, number) — the % denominator.
|
|
279
|
+
* @param cssHeight the slide's intended CSS height (px, number) — the % denominator.
|
|
280
|
+
* @param onHyperlinkClick called with the run's resolved {@link HyperlinkTarget}
|
|
281
|
+
* when a hyperlink span is clicked. Omit to leave links
|
|
282
|
+
* non-interactive (spans stay plain, selectable text).
|
|
174
283
|
*/
|
|
175
|
-
declare function buildPptxTextLayer(layer: HTMLDivElement, runs: PptxTextRunInfo[], cssWidth: number, cssHeight: number): void;
|
|
284
|
+
declare function buildPptxTextLayer(layer: HTMLDivElement, runs: PptxTextRunInfo[], cssWidth: number, cssHeight: number, onHyperlinkClick?: (target: HyperlinkTarget) => void): void;
|
|
176
285
|
|
|
286
|
+
/**
|
|
287
|
+
* A paragraph's bullet marker. For `char`, the marker size is EITHER `sizePct`
|
|
288
|
+
* (a percentage of the run size — ECMA-376 §21.1.2.4.9 `<a:buSzPct>`) OR `sizePts`
|
|
289
|
+
* (an absolute size in points — §21.1.2.4.10 `<a:buSzPts>`), never both: they are
|
|
290
|
+
* the one `EG_TextBulletSize` xsd:choice. `sizePts` is optional (absent when no
|
|
291
|
+
* `<a:buSzPts>` was declared); when present it takes precedence over `sizePct`.
|
|
292
|
+
*/
|
|
177
293
|
declare type Bullet = {
|
|
178
294
|
type: 'none';
|
|
179
295
|
} | {
|
|
@@ -183,11 +299,13 @@ declare type Bullet = {
|
|
|
183
299
|
char: string;
|
|
184
300
|
color: string | null;
|
|
185
301
|
sizePct: number | null;
|
|
302
|
+
sizePts?: number;
|
|
186
303
|
fontFamily: string | null;
|
|
187
304
|
} | {
|
|
188
305
|
type: 'autoNum';
|
|
189
306
|
numType: string;
|
|
190
307
|
startAt: number | null;
|
|
308
|
+
color: string | null;
|
|
191
309
|
};
|
|
192
310
|
|
|
193
311
|
/**
|
|
@@ -216,14 +334,23 @@ declare interface Camera3d {
|
|
|
216
334
|
declare interface Cell {
|
|
217
335
|
col: number;
|
|
218
336
|
row: number;
|
|
219
|
-
colRef: string;
|
|
220
337
|
value: CellValue;
|
|
221
|
-
|
|
338
|
+
/** Style index into the styles table. Omitted on the wire when `0` (the
|
|
339
|
+
* common unstyled case), so read it as `styleIndex ?? 0`. */
|
|
340
|
+
styleIndex?: number;
|
|
222
341
|
/** Raw `<f>` formula text (ECMA-376 §18.3.1.40), when present. The renderer
|
|
223
342
|
* uses this to recompute volatile functions (TODAY, NOW) at display time
|
|
224
343
|
* so the cached `<v>` — frozen when the file was last saved — doesn't
|
|
225
344
|
* show a stale date. */
|
|
226
345
|
formula?: string;
|
|
346
|
+
/** Whether this cell displays its phonetic hint (furigana). The parser
|
|
347
|
+
* resolves it as `cell/@ph ?? row/@ph ?? false` — the per-cell `<c ph>`
|
|
348
|
+
* (ECMA-376 §18.3.1.4) wins when present (an explicit `ph="0"` overrides an
|
|
349
|
+
* enabled row), otherwise the row-level `<row ph>` (§18.3.1.73) is inherited,
|
|
350
|
+
* otherwise the schema default (false). Omitted on the wire when false, so
|
|
351
|
+
* read as `showPhonetic ?? false`. A cell whose String Item carries `<rPh>`
|
|
352
|
+
* runs still shows NO furigana unless the resolved value is true. */
|
|
353
|
+
showPhonetic?: boolean;
|
|
227
354
|
}
|
|
228
355
|
|
|
229
356
|
declare interface CellAddress {
|
|
@@ -294,6 +421,15 @@ declare type CellValue = {
|
|
|
294
421
|
type: 'text';
|
|
295
422
|
text: string;
|
|
296
423
|
runs?: Run[];
|
|
424
|
+
/** ECMA-376 §18.4.6 phonetic runs (furigana) carried over from the
|
|
425
|
+
* resolved String Item. Present for inline strings, and populated by
|
|
426
|
+
* {@link resolveSharedStrings} for shared-string cells. Absent when the
|
|
427
|
+
* string has no furigana. */
|
|
428
|
+
phoneticRuns?: PhoneticRun[];
|
|
429
|
+
/** ECMA-376 §18.4.3 phonetic display properties (font index / char set /
|
|
430
|
+
* alignment) for the furigana above. Absent when the `<si>` had no
|
|
431
|
+
* `<phoneticPr>`. */
|
|
432
|
+
phoneticPr?: PhoneticProperties;
|
|
297
433
|
} | {
|
|
298
434
|
type: 'number';
|
|
299
435
|
number: number;
|
|
@@ -303,6 +439,14 @@ declare type CellValue = {
|
|
|
303
439
|
} | {
|
|
304
440
|
type: 'error';
|
|
305
441
|
error: string;
|
|
442
|
+
}
|
|
443
|
+
/** Shared-string reference into `ParsedWorkbook.sharedStrings` (ECMA-376
|
|
444
|
+
* §18.4.8). Resolved to `{ type: 'text', ... }` by the workbook before the
|
|
445
|
+
* renderer (or any other consumer) sees it, so downstream code never
|
|
446
|
+
* encounters this variant. */
|
|
447
|
+
| {
|
|
448
|
+
type: 'shared';
|
|
449
|
+
si: number;
|
|
306
450
|
};
|
|
307
451
|
|
|
308
452
|
declare interface CellXf {
|
|
@@ -415,6 +559,30 @@ declare interface ChartDataLabelOverride {
|
|
|
415
559
|
fontSizeHpt?: number;
|
|
416
560
|
/** `<a:defRPr b="1">` inside the per-idx rich text. */
|
|
417
561
|
fontBold?: boolean;
|
|
562
|
+
/** Per-point callout box (`<c:dLbl><c:spPr>`, ECMA-376 §21.2.2.47/§21.2.2.197):
|
|
563
|
+
* overrides the series-default box for this one slice. */
|
|
564
|
+
labelBox?: ChartLabelBox;
|
|
565
|
+
/**
|
|
566
|
+
* Per-point label-content flags (`<c:dLbl>` §21.2.2.47 carries the same
|
|
567
|
+
* show-flag group as the series `<c:dLbls>` §21.2.2.49: §21.2.2.189
|
|
568
|
+
* `<c:showVal>`, §21.2.2.177 `<c:showCatName>`, §21.2.2.180 `<c:showSerName>`,
|
|
569
|
+
* §21.2.2.187 `<c:showPercent>`). When present they OVERRIDE the series-level
|
|
570
|
+
* defaults for that one point (e.g. sample-14 slide-7's pie sets
|
|
571
|
+
* `showCatName=0 showPercent=1` per slice while the series default is
|
|
572
|
+
* `showCatName=1`, so each label is percent only). undefined = inherit the
|
|
573
|
+
* series default for that flag.
|
|
574
|
+
*/
|
|
575
|
+
showVal?: boolean;
|
|
576
|
+
showCatName?: boolean;
|
|
577
|
+
showSerName?: boolean;
|
|
578
|
+
showPercent?: boolean;
|
|
579
|
+
/**
|
|
580
|
+
* `<c:dLbl><c:delete val="1"/>` (ECMA-376 §21.2.2.43) — the point's label is
|
|
581
|
+
* removed. Distinguishes a genuine delete from a `<c:dLbl>` that only carries
|
|
582
|
+
* style / flag overrides with no `<c:tx>` (both otherwise present as
|
|
583
|
+
* `text === ''`). true = skip the label; undefined/absent = not deleted.
|
|
584
|
+
*/
|
|
585
|
+
deleted?: boolean;
|
|
418
586
|
}
|
|
419
587
|
|
|
420
588
|
declare interface ChartDataPointOverride {
|
|
@@ -425,6 +593,18 @@ declare interface ChartDataPointOverride {
|
|
|
425
593
|
markerSize?: number;
|
|
426
594
|
markerFill?: string;
|
|
427
595
|
markerLine?: string;
|
|
596
|
+
/**
|
|
597
|
+
* `<c:dPt><c:explosion val>` (ECMA-376 §21.2.2.61) — the amount this
|
|
598
|
+
* pie/doughnut slice is moved out from the center. The schema type is
|
|
599
|
+
* `CT_UnsignedInt` (unbounded `xsd:unsignedInt`); the spec text only says
|
|
600
|
+
* "the amount the data point shall be moved from the center of the pie"
|
|
601
|
+
* and does not itself define units or a 0–100 range. We treat it as a
|
|
602
|
+
* de-facto percentage of the outer radius (0–100 typical), matching
|
|
603
|
+
* Office's UI (the Point Explosion slider caps at 100%) rather than a
|
|
604
|
+
* spec-mandated bound. undefined/absent = 0 (no explosion, flush with the
|
|
605
|
+
* ring). Only consulted by the pie/doughnut renderer.
|
|
606
|
+
*/
|
|
607
|
+
explosion?: number;
|
|
428
608
|
}
|
|
429
609
|
|
|
430
610
|
/**
|
|
@@ -464,6 +644,74 @@ declare interface ChartErrBars {
|
|
|
464
644
|
dash?: string;
|
|
465
645
|
}
|
|
466
646
|
|
|
647
|
+
/**
|
|
648
|
+
* One box-and-whisker series (chartEx `boxWhisker`, MS 2014 chartex ext). Each
|
|
649
|
+
* `<cx:series>` references its own raw sample points via `<cx:dataId>`; the
|
|
650
|
+
* parser groups them by category and threads the `<cx:layoutPr>` flags. The
|
|
651
|
+
* renderer derives the statistics.
|
|
652
|
+
*/
|
|
653
|
+
declare interface ChartexBoxSeries {
|
|
654
|
+
/** Series display name (`<cx:tx><cx:v>`). */
|
|
655
|
+
name: string;
|
|
656
|
+
/** Fill (hex, no '#') — theme accent cycled by series index. null = fall
|
|
657
|
+
* back to the renderer palette. */
|
|
658
|
+
color?: string | null;
|
|
659
|
+
/** Raw sample values grouped by category (outer = category index parallel to
|
|
660
|
+
* {@link ChartexBoxWhisker.categories}, inner = the points in that group). */
|
|
661
|
+
valuesByCategory: number[][];
|
|
662
|
+
/** `<cx:visibility meanMarker>` — draw the mean `×`. */
|
|
663
|
+
meanMarker: boolean;
|
|
664
|
+
/** `<cx:visibility meanLine>` — draw a mean connector line across categories. */
|
|
665
|
+
meanLine: boolean;
|
|
666
|
+
/** `<cx:visibility outliers>` — draw outlier points. */
|
|
667
|
+
showOutliers: boolean;
|
|
668
|
+
/** `<cx:visibility nonoutliers>` — draw the interior (non-outlier) sample
|
|
669
|
+
* points as jittered dots on top of the box. Flag parsed; interior-dot
|
|
670
|
+
* rendering is pending a fixture that enables it (every sample-24 series
|
|
671
|
+
* ships `nonoutliers="0"`, so there is nothing to verify against yet). */
|
|
672
|
+
showNonoutliers: boolean;
|
|
673
|
+
/** `<cx:statistics quartileMethod>` — "exclusive" (Excel default) | "inclusive". */
|
|
674
|
+
quartileMethod: string;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/** A chartEx box-and-whisker chart: unique categories + one series per column. */
|
|
678
|
+
declare interface ChartexBoxWhisker {
|
|
679
|
+
/** Unique category labels in first-seen order. */
|
|
680
|
+
categories: string[];
|
|
681
|
+
/** One entry per `<cx:series>`. */
|
|
682
|
+
series: ChartexBoxSeries[];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/** A chartEx sunburst: the flat rows the renderer folds into a ring tree. */
|
|
686
|
+
declare interface ChartexSunburst {
|
|
687
|
+
rows: ChartexSunburstRow[];
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* One row of a chartEx `sunburst`: the branch→…→leaf label chain (empty
|
|
692
|
+
* trailing segments trimmed) and its size value.
|
|
693
|
+
*/
|
|
694
|
+
declare interface ChartexSunburstRow {
|
|
695
|
+
/** Label chain root→leaf. */
|
|
696
|
+
path: string[];
|
|
697
|
+
/** `<cx:numDim type="size">` value attaching to the deepest node in `path`. */
|
|
698
|
+
size: number;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/** Callout-box style for a pie/doughnut data label — the white (or themed)
|
|
702
|
+
* rounded rectangle with a thin border Word draws around a `bestFit` label
|
|
703
|
+
* placed outside its slice. From the label's `<c:spPr>` (§21.2.2.197). All
|
|
704
|
+
* fields optional: absent → transparent / unbordered. Mirror of Rust
|
|
705
|
+
* `ChartLabelBox`. */
|
|
706
|
+
declare interface ChartLabelBox {
|
|
707
|
+
/** `<a:solidFill>` resolved hex (no `#`). Box background. */
|
|
708
|
+
fill?: string;
|
|
709
|
+
/** `<a:ln><a:solidFill>` resolved hex (no `#`). Border stroke. */
|
|
710
|
+
borderColor?: string;
|
|
711
|
+
/** `<a:ln w>` border width in EMU (12700 EMU = 1 pt). */
|
|
712
|
+
borderWidthEmu?: number;
|
|
713
|
+
}
|
|
714
|
+
|
|
467
715
|
/**
|
|
468
716
|
* `<c:manualLayout>` block. Fractions are of the chart-space rect.
|
|
469
717
|
* `xMode`/`yMode`: "edge" = absolute fraction from top-left, "factor" =
|
|
@@ -484,6 +732,14 @@ declare interface ChartModel {
|
|
|
484
732
|
title: string | null;
|
|
485
733
|
categories: string[];
|
|
486
734
|
series: ChartSeries[];
|
|
735
|
+
/**
|
|
736
|
+
* §21.2.2.227 `<c:varyColors val="1"/>` on a SINGLE-series bar/column chart:
|
|
737
|
+
* color each data point (bar) from the theme/palette sequence and list one
|
|
738
|
+
* legend entry per point, matching Office. Set by the shared parser ONLY for
|
|
739
|
+
* that non-pie, single-series case (pie/doughnut already vary by point via
|
|
740
|
+
* `chartType` + `dataPointColors`); absent/false otherwise.
|
|
741
|
+
*/
|
|
742
|
+
varyColors?: boolean | null;
|
|
487
743
|
/** Show data labels on bars / points / slices. */
|
|
488
744
|
showDataLabels: boolean;
|
|
489
745
|
/** Explicit Y-axis minimum (OOXML `<c:valAx><c:min>`). */
|
|
@@ -594,6 +850,35 @@ declare interface ChartModel {
|
|
|
594
850
|
valAxisTitleFontBold?: boolean | null;
|
|
595
851
|
/** `<c:valAx><c:title>` run-prop color (hex without '#'). null = default. */
|
|
596
852
|
valAxisTitleFontColor?: string | null;
|
|
853
|
+
/** `<c:catAx><c:txPr>…<a:latin typeface>` tick-label font. */
|
|
854
|
+
catAxisFontFace?: string | null;
|
|
855
|
+
/** `<c:valAx><c:txPr>…<a:latin typeface>` tick-label font. */
|
|
856
|
+
valAxisFontFace?: string | null;
|
|
857
|
+
/** `<c:catAx><c:title>…<a:latin typeface>` axis-title font. */
|
|
858
|
+
catAxisTitleFontFace?: string | null;
|
|
859
|
+
/** `<c:valAx><c:title>…<a:latin typeface>` axis-title font. */
|
|
860
|
+
valAxisTitleFontFace?: string | null;
|
|
861
|
+
/** `<c:dLbls><c:txPr>…<a:latin typeface>` data-label font. */
|
|
862
|
+
dataLabelFontFace?: string | null;
|
|
863
|
+
/** `<c:legend><c:txPr>…<a:latin typeface>` legend font. */
|
|
864
|
+
legendFontFace?: string | null;
|
|
865
|
+
/** `<c:legend><c:txPr>…<a:solidFill>` legend text color (hex without '#'). */
|
|
866
|
+
legendFontColor?: string | null;
|
|
867
|
+
/** `<c:legend><c:txPr>` legend font size (OOXML hundredths of a point). */
|
|
868
|
+
legendFontSizeHpt?: number | null;
|
|
869
|
+
/** `<c:legend><c:txPr>…defRPr@b` legend bold flag. */
|
|
870
|
+
legendFontBold?: boolean | null;
|
|
871
|
+
/**
|
|
872
|
+
* Theme font-scheme faces (`<a:fontScheme>`, ECMA-376 §20.1.4.2). Latin
|
|
873
|
+
* heading (majorFont) and body (minorFont) typefaces, used as the fallback
|
|
874
|
+
* for any chart text element whose own `<c:txPr>` supplies no `<a:latin>`.
|
|
875
|
+
* null when the theme is not threaded to the chart (then the renderer's
|
|
876
|
+
* built-in sans-serif remains, byte-stable). Axis titles / chart title use
|
|
877
|
+
* the major (heading) face; tick labels / data labels / legend use the
|
|
878
|
+
* minor (body) face — matching Office's default chart text styling.
|
|
879
|
+
*/
|
|
880
|
+
themeMajorFontLatin?: string | null;
|
|
881
|
+
themeMinorFontLatin?: string | null;
|
|
597
882
|
/** Explicit chart border color (hex without '#') from
|
|
598
883
|
* `<c:chartSpace><c:spPr><a:ln><a:solidFill><a:srgbClr>`. Only set when the
|
|
599
884
|
* XML explicitly declares a paintable line; null otherwise (no default
|
|
@@ -668,6 +953,218 @@ declare interface ChartModel {
|
|
|
668
953
|
* value axis (the common case). See {@link SecondaryValueAxis}.
|
|
669
954
|
*/
|
|
670
955
|
secondaryValAxis?: SecondaryValueAxis | null;
|
|
956
|
+
/**
|
|
957
|
+
* `<c:date1904>` (ECMA-376 §21.2.2.38). When true the chart's serial
|
|
958
|
+
* date-times resolve against the 1904 date system (base 1904-01-01) instead
|
|
959
|
+
* of the default 1900 system. Threaded to the date formatters for date-axis
|
|
960
|
+
* category labels and value-axis tick labels. Omitted/false ⇒ 1900 system.
|
|
961
|
+
* Note: per §21.2.2.38 the element's `val` defaults to true when present but
|
|
962
|
+
* the attribute is omitted, so `<c:date1904/>` alone means date1904=true.
|
|
963
|
+
*/
|
|
964
|
+
date1904?: boolean;
|
|
965
|
+
/**
|
|
966
|
+
* `<c:doughnutChart><c:holeSize val>` (ECMA-376 §21.2.2.60,
|
|
967
|
+
* `ST_HoleSizePercent` §21.2.3.55) — the doughnut hole diameter as a
|
|
968
|
+
* percentage 1–90 of the outer diameter. Ignored for pie (which has no
|
|
969
|
+
* hole). null/undefined = use the renderer's doughnut default when the
|
|
970
|
+
* element is absent. Note the ECMA `CT_HoleSize` schema default is 10%, but
|
|
971
|
+
* a real doughnut file always writes an explicit `<c:holeSize>` (Excel /
|
|
972
|
+
* PowerPoint emit 50–75%); the renderer falls back to 50% only for the
|
|
973
|
+
* pathological absent case.
|
|
974
|
+
*/
|
|
975
|
+
holeSize?: number | null;
|
|
976
|
+
/**
|
|
977
|
+
* `<c:pieChart | doughnutChart><c:firstSliceAng val>` (ECMA-376 §21.2.2.52,
|
|
978
|
+
* `ST_FirstSliceAng` §21.2.3.15) — the angle in degrees (0–360, clockwise
|
|
979
|
+
* from the 12 o'clock position) at which the first slice begins.
|
|
980
|
+
* null/undefined = 0 (start at 12 o'clock), which matches the renderer's
|
|
981
|
+
* historical fixed −90° (canvas up) start.
|
|
982
|
+
*/
|
|
983
|
+
firstSliceAngle?: number | null;
|
|
984
|
+
/**
|
|
985
|
+
* `<c:chartSpace><c:chart><c:dispBlanksAs val>` (ECMA-376 §21.2.2.42,
|
|
986
|
+
* `ST_DispBlanksAs` §21.2.3.10) — how blank (null) cells are plotted on
|
|
987
|
+
* line/area charts:
|
|
988
|
+
* - "gap" → leave a gap (break the line). The renderer's historical
|
|
989
|
+
* behavior and the model default when the element is absent.
|
|
990
|
+
* - "zero" → plot the blank as the value 0 (the point drops to the axis).
|
|
991
|
+
* - "span" → skip the blank but connect its neighbours with a straight
|
|
992
|
+
* line (bridge the gap).
|
|
993
|
+
* Note the XSD `@val` default is "zero" (applies when `<c:dispBlanksAs/>` is
|
|
994
|
+
* present but the attribute is omitted); when the ELEMENT is absent entirely
|
|
995
|
+
* Office falls back to "gap", which is what we model as the default. Only
|
|
996
|
+
* consulted for the line and area families. null/undefined = "gap".
|
|
997
|
+
*/
|
|
998
|
+
dispBlanksAs?: string | null;
|
|
999
|
+
/**
|
|
1000
|
+
* `<c:valAx><c:majorGridlines>` presence (ECMA-376 §21.2.2.100). `false` when
|
|
1001
|
+
* the value axis exists but omits the element (Office suppresses value
|
|
1002
|
+
* gridlines). null/undefined ⇒ the renderer's historical always-on value
|
|
1003
|
+
* gridlines (byte-stable). `true` is redundant with the default but honored.
|
|
1004
|
+
*/
|
|
1005
|
+
valAxisMajorGridlines?: boolean | null;
|
|
1006
|
+
/**
|
|
1007
|
+
* `<c:catAx><c:majorGridlines>` presence (§21.2.2.100). `true` turns on
|
|
1008
|
+
* category-axis gridlines (Office omits them by default). null/undefined/false
|
|
1009
|
+
* ⇒ no category gridlines (the historical default, byte-stable).
|
|
1010
|
+
*/
|
|
1011
|
+
catAxisMajorGridlines?: boolean | null;
|
|
1012
|
+
/**
|
|
1013
|
+
* `<c:valAx><c:majorGridlines><c:spPr><a:ln><a:solidFill>` resolved gridline
|
|
1014
|
+
* color (hex without `#`) — ECMA-376 §21.2.2.100. When set, the value-axis
|
|
1015
|
+
* major gridlines are stroked in this color instead of the renderer's faint
|
|
1016
|
+
* `#e0e0e0` default (e.g. sample-1 slide 5's `accent3` gridlines). null/absent
|
|
1017
|
+
* ⇒ the historical default (byte-stable).
|
|
1018
|
+
*/
|
|
1019
|
+
valAxisGridlineColor?: string | null;
|
|
1020
|
+
/**
|
|
1021
|
+
* `<c:valAx><c:majorGridlines><c:spPr><a:ln w>` gridline width in EMU. When
|
|
1022
|
+
* set, the value-axis gridline stroke width is derived from this (floored so a
|
|
1023
|
+
* hairline stays visible). null/absent ⇒ the renderer's 0.5 px default.
|
|
1024
|
+
*/
|
|
1025
|
+
valAxisGridlineWidthEmu?: number | null;
|
|
1026
|
+
/**
|
|
1027
|
+
* `<c:catAx><c:majorGridlines><c:spPr><a:ln><a:solidFill>` resolved gridline
|
|
1028
|
+
* color (hex without `#`). Only meaningful when {@link catAxisMajorGridlines}
|
|
1029
|
+
* is on. null/absent ⇒ the faint default.
|
|
1030
|
+
*/
|
|
1031
|
+
catAxisGridlineColor?: string | null;
|
|
1032
|
+
/** `<c:catAx><c:majorGridlines><c:spPr><a:ln w>` gridline width in EMU. */
|
|
1033
|
+
catAxisGridlineWidthEmu?: number | null;
|
|
1034
|
+
/** `<c:valAx><c:minorGridlines>` presence (§21.2.2.109). Only drawn when a
|
|
1035
|
+
* minor step is resolvable (see {@link valAxisMinorUnit}). */
|
|
1036
|
+
valAxisMinorGridlines?: boolean | null;
|
|
1037
|
+
/**
|
|
1038
|
+
* `<c:valAx><c:majorUnit val>` (§21.2.2.103) — explicit distance between major
|
|
1039
|
+
* gridlines/ticks, overriding the Excel-style auto "nice" step. null/undefined
|
|
1040
|
+
* ⇒ auto step (byte-stable).
|
|
1041
|
+
*/
|
|
1042
|
+
valAxisMajorUnit?: number | null;
|
|
1043
|
+
/** `<c:valAx><c:minorUnit val>` (§21.2.2.112) — explicit minor step. Drives
|
|
1044
|
+
* minor gridlines/ticks when present. null ⇒ no minor divisions. */
|
|
1045
|
+
valAxisMinorUnit?: number | null;
|
|
1046
|
+
/**
|
|
1047
|
+
* `<c:valAx><c:scaling><c:logBase val>` (§21.2.2.98, `ST_LogBase` §21.2.3.25)
|
|
1048
|
+
* — logarithmic value-axis base (>= 2). When set, values map to pixels in log
|
|
1049
|
+
* space and gridlines fall on powers of the base. null/undefined ⇒ linear
|
|
1050
|
+
* (byte-stable).
|
|
1051
|
+
*/
|
|
1052
|
+
valAxisLogBase?: number | null;
|
|
1053
|
+
/**
|
|
1054
|
+
* `<c:valAx><c:scaling><c:orientation val>` (§21.2.2.130, `ST_Orientation`
|
|
1055
|
+
* §21.2.3.30) — "minMax" (normal) | "maxMin" (reversed, so the value axis runs
|
|
1056
|
+
* top→bottom max→min). null/undefined/"minMax" ⇒ normal (byte-stable).
|
|
1057
|
+
*/
|
|
1058
|
+
valAxisOrientation?: 'minMax' | 'maxMin' | string | null;
|
|
1059
|
+
/** `<c:catAx><c:scaling><c:orientation val>` — "maxMin" reverses the category
|
|
1060
|
+
* axis left↔right. null/"minMax" ⇒ normal. */
|
|
1061
|
+
catAxisOrientation?: 'minMax' | 'maxMin' | string | null;
|
|
1062
|
+
/**
|
|
1063
|
+
* `<c:catAx><c:tickLblPos val>` (§21.2.2.207, `ST_TickLblPos` §21.2.3.47) —
|
|
1064
|
+
* "nextTo" (default) | "low" | "high" | "none". "none" hides the category tick
|
|
1065
|
+
* labels. null/undefined ⇒ nextTo (byte-stable).
|
|
1066
|
+
*/
|
|
1067
|
+
catAxisTickLabelPos?: string | null;
|
|
1068
|
+
/** `<c:valAx><c:tickLblPos val>` (§21.2.2.207). "none" hides value tick labels. */
|
|
1069
|
+
valAxisTickLabelPos?: string | null;
|
|
1070
|
+
/**
|
|
1071
|
+
* `<c:catAx><c:txPr><a:bodyPr rot>` (DrawingML `ST_Angle`, 60000ths of a
|
|
1072
|
+
* degree) — category tick-label rotation. e.g. -2700000 = -45°. null/undefined
|
|
1073
|
+
* /0 ⇒ horizontal labels (byte-stable).
|
|
1074
|
+
*/
|
|
1075
|
+
catAxisLabelRotation?: number | null;
|
|
1076
|
+
/**
|
|
1077
|
+
* `<c:stockChart><c:hiLowLines>` presence (ECMA-376 §21.2.2.60). When true
|
|
1078
|
+
* the stock renderer draws a vertical line spanning each category's low↔high
|
|
1079
|
+
* value. Only set for `chartType === "stock"`; null/undefined on every other
|
|
1080
|
+
* chart type (byte-stable).
|
|
1081
|
+
*/
|
|
1082
|
+
stockHiLowLines?: boolean | null;
|
|
1083
|
+
/**
|
|
1084
|
+
* `<c:hiLowLines><c:spPr><a:ln><a:solidFill>` resolved color (hex, no `#`).
|
|
1085
|
+
* null = the renderer's default gray hi-lo line.
|
|
1086
|
+
*/
|
|
1087
|
+
stockHiLowLineColor?: string | null;
|
|
1088
|
+
/**
|
|
1089
|
+
* `<c:stockChart><c:upDownBars>` presence (ECMA-376 §21.2.2.227). Parsed so a
|
|
1090
|
+
* stock file carrying open-close up/down bars is recognized; the renderer does
|
|
1091
|
+
* NOT yet draw them (tracked follow-up). null/undefined when absent.
|
|
1092
|
+
*/
|
|
1093
|
+
stockUpDownBars?: boolean | null;
|
|
1094
|
+
/**
|
|
1095
|
+
* Structured box-and-whisker data (`chartType === 'boxWhisker'`). Present
|
|
1096
|
+
* ONLY for boxWhisker charts; null/absent otherwise so the flat
|
|
1097
|
+
* `categories`/`series` model the other chartEx renderers consume is
|
|
1098
|
+
* untouched. The renderer computes quartiles / mean / whiskers / outliers.
|
|
1099
|
+
*/
|
|
1100
|
+
chartexBox?: ChartexBoxWhisker | null;
|
|
1101
|
+
/**
|
|
1102
|
+
* Structured sunburst hierarchy (`chartType === 'sunburst'`). Present ONLY
|
|
1103
|
+
* for sunburst charts; null/absent otherwise.
|
|
1104
|
+
*/
|
|
1105
|
+
chartexSunburst?: ChartexSunburst | null;
|
|
1106
|
+
/**
|
|
1107
|
+
* Theme accent palette (`accent1..6`, hex without '#') for chartEx charts
|
|
1108
|
+
* that color by branch/series index (boxWhisker series, sunburst branches).
|
|
1109
|
+
* null/absent when the resolver supplies no default palette (pptx); the
|
|
1110
|
+
* renderer then falls back to its own `CHART_PALETTE`.
|
|
1111
|
+
*/
|
|
1112
|
+
chartexAccents?: string[] | null;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
/** ECMA-376 §21.2 — a DrawingML chart embedded in the run flow via
|
|
1116
|
+
* `<w:drawing><wp:inline|wp:anchor>…<a:graphicData uri=".../chart"><c:chart r:id>`.
|
|
1117
|
+
* Mirrors the Rust `ChartRun`. `chart` is the shared {@link ChartModel} the
|
|
1118
|
+
* core `renderChart` consumes (identical to what pptx/xlsx pass), so a docx
|
|
1119
|
+
* chart draws at the same quality through the same code path. `widthPt`/
|
|
1120
|
+
* `heightPt` are the `<wp:extent>` natural size. An inline chart flows as an
|
|
1121
|
+
* inline box of that size; an anchored chart (§20.4.2.3) is painted via
|
|
1122
|
+
* `registerAnchorFloats` when it wraps text, or by `renderAnchorImages` for
|
|
1123
|
+
* wrapNone/no-wrap anchors — all paths use `renderChart`. */
|
|
1124
|
+
declare interface ChartRun {
|
|
1125
|
+
chart: ChartModel;
|
|
1126
|
+
widthPt: number;
|
|
1127
|
+
heightPt: number;
|
|
1128
|
+
/** true = `<wp:anchor>` (absolute page position, drawn by the anchor path);
|
|
1129
|
+
* false = `<wp:inline>` (flows with text). */
|
|
1130
|
+
anchor: boolean;
|
|
1131
|
+
anchorXPt?: number;
|
|
1132
|
+
anchorYPt?: number;
|
|
1133
|
+
anchorXFromMargin?: boolean;
|
|
1134
|
+
anchorYFromPara?: boolean;
|
|
1135
|
+
/**
|
|
1136
|
+
* Wrap mode for anchored charts (ECMA-376 §20.4.2.16/.17):
|
|
1137
|
+
* "square" | "topAndBottom" | "none" | "tight" | "through"
|
|
1138
|
+
* Inline charts and undetermined cases leave this undefined. The renderer
|
|
1139
|
+
* treats "tight" and "through" as "square", matching anchored images.
|
|
1140
|
+
*/
|
|
1141
|
+
wrapMode?: string;
|
|
1142
|
+
/** Padding top (pt). Anchor-only (ECMA-376 §20.4.2.16/.17). */
|
|
1143
|
+
distTop?: number;
|
|
1144
|
+
/** Padding bottom (pt). Anchor-only (ECMA-376 §20.4.2.16/.17). */
|
|
1145
|
+
distBottom?: number;
|
|
1146
|
+
/** Padding left (pt). Anchor-only (ECMA-376 §20.4.2.16/.17). */
|
|
1147
|
+
distLeft?: number;
|
|
1148
|
+
/** Padding right (pt). Anchor-only (ECMA-376 §20.4.2.16/.17). */
|
|
1149
|
+
distRight?: number;
|
|
1150
|
+
/** wrapText attribute: "bothSides" | "left" | "right" | "largest". */
|
|
1151
|
+
wrapSide?: string;
|
|
1152
|
+
/**
|
|
1153
|
+
* ECMA-376 §20.4.2.3 `wp:anchor/@allowOverlap`. The parser omits this
|
|
1154
|
+
* field when true, so renderers must read it as `allowOverlap ?? true`.
|
|
1155
|
+
*/
|
|
1156
|
+
allowOverlap?: boolean;
|
|
1157
|
+
/** ECMA-376 §20.4.3.1 wp:align horizontal: "left" | "center" | "right" |
|
|
1158
|
+
* "inside" | "outside". */
|
|
1159
|
+
anchorXAlign?: string | null;
|
|
1160
|
+
/** Vertical equivalent of anchorXAlign: "top" | "center" | "bottom". */
|
|
1161
|
+
anchorYAlign?: string | null;
|
|
1162
|
+
/**
|
|
1163
|
+
* ECMA-376 §20.4.3.2 `<wp:positionH/@relativeFrom>` / §20.4.3.5
|
|
1164
|
+
* `<wp:positionV/@relativeFrom>` — the raw anchor placement containers.
|
|
1165
|
+
*/
|
|
1166
|
+
anchorXRelativeFrom?: string | null;
|
|
1167
|
+
anchorYRelativeFrom?: string | null;
|
|
671
1168
|
}
|
|
672
1169
|
|
|
673
1170
|
declare interface ChartSeries {
|
|
@@ -777,6 +1274,31 @@ declare interface ChartSeries {
|
|
|
777
1274
|
* series.
|
|
778
1275
|
*/
|
|
779
1276
|
bubbleSizes?: (number | null)[] | null;
|
|
1277
|
+
/**
|
|
1278
|
+
* `<c:ser><c:smooth val>` (ECMA-376 §21.2.2.194) — line/area series flag
|
|
1279
|
+
* requesting a smoothed (spline) curve through the points instead of straight
|
|
1280
|
+
* segments. Only consulted for the line and area families (scatter carries its
|
|
1281
|
+
* smoothing in `ChartModel.scatterStyle`). null/undefined/false = straight
|
|
1282
|
+
* polyline (the default; byte-stable for series that never set it).
|
|
1283
|
+
*/
|
|
1284
|
+
smooth?: boolean | null;
|
|
1285
|
+
/**
|
|
1286
|
+
* `<c:ser><c:trendline>` per-series trendlines (ECMA-376 §21.2.2.211,
|
|
1287
|
+
* `CT_Trendline`). A series can carry several (e.g. a linear fit + a moving
|
|
1288
|
+
* average). null/undefined/empty = no trendline (the default; byte-stable for
|
|
1289
|
+
* series that never declare one).
|
|
1290
|
+
*/
|
|
1291
|
+
trendLines?: ChartTrendline[] | null;
|
|
1292
|
+
/**
|
|
1293
|
+
* `<c:ser><c:spPr><a:ln><a:noFill/>` (ECMA-376 §21.2.2.198 CT_ShapeProperties
|
|
1294
|
+
* → DrawingML §20.1.2.2.24 CT_LineProperties). true when the series connecting
|
|
1295
|
+
* line is explicitly turned OFF. For a scatter/line series this OVERRIDES the
|
|
1296
|
+
* chart-group `<c:scatterStyle>` (§21.2.2.42) / line default — Excel and
|
|
1297
|
+
* PowerPoint draw markers only (no connecting line) even when the group style
|
|
1298
|
+
* is `lineMarker`. null/undefined = no explicit line-off, so the group default
|
|
1299
|
+
* governs (byte-stable for series that carry a paintable line).
|
|
1300
|
+
*/
|
|
1301
|
+
lineHidden?: boolean | null;
|
|
780
1302
|
}
|
|
781
1303
|
|
|
782
1304
|
declare interface ChartSeriesDataLabels {
|
|
@@ -791,6 +1313,51 @@ declare interface ChartSeriesDataLabels {
|
|
|
791
1313
|
fontBold?: boolean;
|
|
792
1314
|
/** Series-level font size for data labels (OOXML hundredths of a point). */
|
|
793
1315
|
fontSizeHpt?: number;
|
|
1316
|
+
/** Series-default callout box (`<c:dLbls><c:spPr>`, ECMA-376 §21.2.2.49/
|
|
1317
|
+
* §21.2.2.197). When present the pie/doughnut renderer draws Word's boxed
|
|
1318
|
+
* callout layout (box + optional leader line) instead of plain text. */
|
|
1319
|
+
labelBox?: ChartLabelBox;
|
|
1320
|
+
/** `<c:dLbls><c:showLeaderLines val>` (§21.2.2.183) — draw leader lines from
|
|
1321
|
+
* a pulled-away label back to its slice. Default false. */
|
|
1322
|
+
showLeaderLines?: boolean;
|
|
1323
|
+
/** `<c:leaderLines><c:spPr><a:ln><a:solidFill>` (§21.2.2.92) resolved hex
|
|
1324
|
+
* (no `#`). undefined → renderer uses a neutral grey. */
|
|
1325
|
+
leaderLineColor?: string;
|
|
1326
|
+
/** `<c:leaderLines><c:spPr><a:ln w>` leader-line width in EMU. */
|
|
1327
|
+
leaderLineWidthEmu?: number;
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* `<c:ser><c:trendline>` (ECMA-376 §21.2.2.211). A regression/smoothing curve
|
|
1332
|
+
* fitted to the series' data points.
|
|
1333
|
+
*/
|
|
1334
|
+
declare interface ChartTrendline {
|
|
1335
|
+
/**
|
|
1336
|
+
* `<c:trendlineType val>` (§21.2.2.213, `ST_TrendlineType` §21.2.3.50):
|
|
1337
|
+
* "linear" | "exp" | "log" | "power" | "poly" | "movingAvg". The renderer
|
|
1338
|
+
* currently draws "linear" (least squares) and "movingAvg"; other types parse
|
|
1339
|
+
* but are not yet plotted (tracked as a follow-up).
|
|
1340
|
+
*/
|
|
1341
|
+
trendlineType: string;
|
|
1342
|
+
/** `<c:order val>` — polynomial order (`poly`, default 2). */
|
|
1343
|
+
order?: number | null;
|
|
1344
|
+
/** `<c:period val>` — moving-average window (`movingAvg`, default 2). */
|
|
1345
|
+
period?: number | null;
|
|
1346
|
+
/** `<c:forward val>` — units to extend the line past the last point. */
|
|
1347
|
+
forward?: number | null;
|
|
1348
|
+
/** `<c:backward val>` — units to extend the line before the first point. */
|
|
1349
|
+
backward?: number | null;
|
|
1350
|
+
/** `<c:intercept val>` — forced y-intercept (linear/exp). null = free fit. */
|
|
1351
|
+
intercept?: number | null;
|
|
1352
|
+
/** `<c:dispRSqr val="1">` — show the R² value (label; not yet rendered). */
|
|
1353
|
+
dispRSqr?: boolean | null;
|
|
1354
|
+
/** `<c:dispEq val="1">` — show the fit equation (label; not yet rendered). */
|
|
1355
|
+
dispEq?: boolean | null;
|
|
1356
|
+
/** `<c:spPr><a:ln><a:solidFill>` trendline color (hex without '#'). null =
|
|
1357
|
+
* inherit the series color. */
|
|
1358
|
+
lineColor?: string | null;
|
|
1359
|
+
/** `<c:spPr><a:ln w>` trendline width in EMU. */
|
|
1360
|
+
lineWidthEmu?: number | null;
|
|
794
1361
|
}
|
|
795
1362
|
|
|
796
1363
|
/**
|
|
@@ -798,7 +1365,7 @@ declare interface ChartSeriesDataLabels {
|
|
|
798
1365
|
* grouping (`Pct` = percent-stacked) so renderers do not need to inspect
|
|
799
1366
|
* separate `barDir`/`grouping` fields.
|
|
800
1367
|
*/
|
|
801
|
-
declare type ChartType = 'line' | 'stackedLine' | 'stackedLinePct' | 'clusteredBar' | 'clusteredBarH' | 'stackedBar' | 'stackedBarH' | 'stackedBarPct' | 'stackedBarHPct' | 'area' | 'stackedArea' | 'stackedAreaPct' | 'pie' | 'doughnut' | 'scatter' | 'bubble' | 'radar' | 'waterfall' | string;
|
|
1368
|
+
declare type ChartType = 'line' | 'stackedLine' | 'stackedLinePct' | 'clusteredBar' | 'clusteredBarH' | 'stackedBar' | 'stackedBarH' | 'stackedBarPct' | 'stackedBarHPct' | 'area' | 'stackedArea' | 'stackedAreaPct' | 'pie' | 'doughnut' | 'scatter' | 'bubble' | 'radar' | 'waterfall' | 'stock' | 'boxWhisker' | 'sunburst' | string;
|
|
802
1369
|
|
|
803
1370
|
/** ECMA-376 §17.6.3 `<w:col>` — one column's width and trailing space (pt). */
|
|
804
1371
|
declare interface ColSpec {
|
|
@@ -899,7 +1466,7 @@ declare interface DocParagraph {
|
|
|
899
1466
|
* both, distribute. Other values (kashida variants, numTab, thaiDistribute)
|
|
900
1467
|
* are treated as start-aligned.
|
|
901
1468
|
*/
|
|
902
|
-
alignment: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | 'both' | 'distribute' | string;
|
|
1469
|
+
alignment: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | 'both' | 'distribute' | 'lowKashida' | 'mediumKashida' | 'highKashida' | 'thaiDistribute' | string;
|
|
903
1470
|
indentLeft: number;
|
|
904
1471
|
indentRight: number;
|
|
905
1472
|
indentFirst: number;
|
|
@@ -909,16 +1476,33 @@ declare interface DocParagraph {
|
|
|
909
1476
|
numbering: NumberingInfo | null;
|
|
910
1477
|
tabStops: TabStop_2[];
|
|
911
1478
|
runs: DocRun[];
|
|
1479
|
+
/**
|
|
1480
|
+
* ECMA-376 §17.13.6.2 `<w:bookmarkStart w:name>` — names of the bookmarks that
|
|
1481
|
+
* start within (or at the head of) this paragraph, in document order. A
|
|
1482
|
+
* `<w:hyperlink w:anchor="X">` internal link (§17.16.23) targets the paragraph
|
|
1483
|
+
* whose `bookmarks` contains `"X"`; {@link buildBookmarkPageMap} turns these
|
|
1484
|
+
* into a `bookmarkName → pageIndex` map after pagination. Absent (`undefined`)
|
|
1485
|
+
* for the common paragraph that anchors nothing.
|
|
1486
|
+
*/
|
|
1487
|
+
bookmarks?: string[];
|
|
912
1488
|
/** Paragraph background hex color (w:shd fill) */
|
|
913
1489
|
shading?: string | null;
|
|
914
1490
|
/** Force a page break before this paragraph (w:pageBreakBefore) */
|
|
915
1491
|
pageBreakBefore?: boolean;
|
|
916
|
-
/**
|
|
1492
|
+
/** ECMA-376 §17.3.1.9 `<w:contextualSpacing>` — between adjacent SAME-style
|
|
1493
|
+
* paragraphs, a toggling paragraph drops its OWN contribution to the
|
|
1494
|
+
* collapsed inter-paragraph gap (per-side, Word-adjudicated — issue #1015;
|
|
1495
|
+
* see the renderer's `contextualSpacingAdjust`). */
|
|
917
1496
|
contextualSpacing?: boolean;
|
|
918
1497
|
/** Keep paragraph on same page as the next paragraph (w:keepNext) */
|
|
919
1498
|
keepNext?: boolean;
|
|
920
1499
|
/** Keep all lines of this paragraph on the same page (w:keepLines) */
|
|
921
1500
|
keepLines?: boolean;
|
|
1501
|
+
/** ECMA-376 §17.3.1.29 + §17.3.2.41 — the paragraph MARK's resolved `w:vanish`
|
|
1502
|
+
* (hidden text). An inkless paragraph whose mark is vanished collapses to zero
|
|
1503
|
+
* height in the normal/print view (hidden-text off), the same way the parser
|
|
1504
|
+
* strips hidden runs; the paginator drops it whole. Absent = mark is visible. */
|
|
1505
|
+
markVanish?: boolean;
|
|
922
1506
|
/** Widow/orphan control (w:widowControl). ECMA-376 default is true. */
|
|
923
1507
|
widowControl?: boolean;
|
|
924
1508
|
/** Paragraph borders (w:pBdr) */
|
|
@@ -930,6 +1514,17 @@ declare interface DocParagraph {
|
|
|
930
1514
|
/** Default font family resolved from the style chain. Used to size empty
|
|
931
1515
|
* paragraphs (no runs) with the intended font's line metrics. */
|
|
932
1516
|
defaultFontFamily?: string | null;
|
|
1517
|
+
/** Default East Asian font family resolved from the style chain. Empty /
|
|
1518
|
+
* anchor-only paragraph marks in East Asian documents use this axis for line
|
|
1519
|
+
* metrics instead of the ASCII fallback. */
|
|
1520
|
+
defaultFontFamilyEastAsia?: string | null;
|
|
1521
|
+
/** ECMA-376 §17.3.1.29 — the paragraph MARK run's resolved `w:color` (direct
|
|
1522
|
+
* pPr/rPr → pStyle chain → docDefaults; hex 6 without `#`, lowercased; an
|
|
1523
|
+
* explicit `auto` surfaces as absent, §17.3.2.6). Word formats a numbering
|
|
1524
|
+
* marker with the level rPr (§17.9.24) layered over the mark's run
|
|
1525
|
+
* properties, so the renderer uses this as the marker-color fallback when
|
|
1526
|
+
* {@link NumberingInfo.color} is absent. */
|
|
1527
|
+
paragraphMarkColor?: string | null;
|
|
933
1528
|
/**
|
|
934
1529
|
* ECMA-376 §17.3.1.6 `<w:bidi>` — right-to-left paragraph. `true` = RTL,
|
|
935
1530
|
* `false` = explicitly LTR, absent = unspecified (inherit). The renderer uses
|
|
@@ -970,6 +1565,8 @@ declare type DocRun = {
|
|
|
970
1565
|
} & DocxTextRun | {
|
|
971
1566
|
type: 'image';
|
|
972
1567
|
} & ImageRun | {
|
|
1568
|
+
type: 'chart';
|
|
1569
|
+
} & ChartRun | {
|
|
973
1570
|
type: 'break';
|
|
974
1571
|
breakType: 'line' | 'page' | 'column';
|
|
975
1572
|
} | {
|
|
@@ -982,7 +1579,9 @@ declare type DocRun = {
|
|
|
982
1579
|
display: boolean;
|
|
983
1580
|
fontSize: number;
|
|
984
1581
|
jc?: string;
|
|
985
|
-
}
|
|
1582
|
+
} | {
|
|
1583
|
+
type: 'ptab';
|
|
1584
|
+
} & PTabRun;
|
|
986
1585
|
|
|
987
1586
|
declare interface DocSettings {
|
|
988
1587
|
/** §17.15.1.58 `w:kinsoku` — East-Asian line-breaking toggle. `undefined`
|
|
@@ -1003,6 +1602,17 @@ declare interface DocSettings {
|
|
|
1003
1602
|
* tab stops generated after all custom stops. `undefined` ⇒ the renderer
|
|
1004
1603
|
* uses the spec default of 720 twips (36pt). */
|
|
1005
1604
|
defaultTabStop?: number;
|
|
1605
|
+
/** §17.15.1.18 `w:characterSpacingControl@w:val` — East Asian punctuation /
|
|
1606
|
+
* character-spacing control. */
|
|
1607
|
+
characterSpacingControl?: string;
|
|
1608
|
+
/** §17.15.3.1 `w:compat/w:useFELayout` — Far East layout compatibility. */
|
|
1609
|
+
useFeLayout?: boolean;
|
|
1610
|
+
/** §17.15.3.1 `w:compat/w:balanceSingleByteDoubleByteWidth` — balance
|
|
1611
|
+
* single-byte and double-byte widths for East Asian layout. */
|
|
1612
|
+
balanceSingleByteDoubleByteWidth?: boolean;
|
|
1613
|
+
/** §17.15.3.1 `w:compat/w:adjustLineHeightInTable` — apply the section
|
|
1614
|
+
* document-grid line pitch to text in table cells. */
|
|
1615
|
+
adjustLineHeightInTable?: boolean;
|
|
1006
1616
|
}
|
|
1007
1617
|
|
|
1008
1618
|
declare interface DocTable {
|
|
@@ -1015,6 +1625,14 @@ declare interface DocTable {
|
|
|
1015
1625
|
cellMarginRight: number;
|
|
1016
1626
|
/** table horizontal alignment on the page: 'left' | 'center' | 'right'. */
|
|
1017
1627
|
jc: string;
|
|
1628
|
+
/** ECMA-376 §17.4.50 `<w:tblInd>` — indentation added before the table's
|
|
1629
|
+
* LEADING edge (left in an LTR table, right in an RTL/`bidiVisual` table), in
|
|
1630
|
+
* pt. SIGNED: a negative value pulls the table outward past the leading margin
|
|
1631
|
+
* toward the page edge (Word writes this for a header banner that must reach
|
|
1632
|
+
* the physical page edge). `type="dxa"` only; `pct`/`auto` are dropped by the
|
|
1633
|
+
* parser per §17.4.50. Absent ⇒ no direct indent. The renderer applies it only
|
|
1634
|
+
* when the resolved `jc` is left/leading (§17.4.50). */
|
|
1635
|
+
tblInd?: number;
|
|
1018
1636
|
/** ECMA-376 §17.4.52 `<w:tblLayout w:type>` — 'fixed' | 'autofit'. Absent
|
|
1019
1637
|
* (undefined) ⇒ spec default 'autofit'. Both paths size columns from the
|
|
1020
1638
|
* tblGrid (§17.4.48) scaled to fit: 'fixed' uses the grid verbatim; 'autofit'
|
|
@@ -1076,25 +1694,44 @@ declare interface DocTableRow {
|
|
|
1076
1694
|
* lower bound; "exact" = fixed clip. */
|
|
1077
1695
|
rowHeightRule: 'auto' | 'atLeast' | 'exact' | string;
|
|
1078
1696
|
isHeader: boolean;
|
|
1697
|
+
/** ECMA-376 §17.4.6 `<w:cantSplit>` — when true, the row must not be split
|
|
1698
|
+
* across page boundaries. Omitted/false rows may split at page boundaries. */
|
|
1699
|
+
cantSplit?: boolean;
|
|
1079
1700
|
}
|
|
1080
1701
|
|
|
1081
1702
|
export declare namespace docx {
|
|
1082
1703
|
export {
|
|
1083
1704
|
DocxDocument,
|
|
1084
1705
|
LoadOptions_4 as LoadOptions,
|
|
1706
|
+
RenderPageToBitmapOptions,
|
|
1085
1707
|
WireRenderPageOptions,
|
|
1086
1708
|
DocxViewer,
|
|
1087
1709
|
DocxViewerOptions,
|
|
1088
1710
|
DocxScrollViewer,
|
|
1089
1711
|
DocxScrollViewerOptions,
|
|
1090
1712
|
buildDocxTextLayer,
|
|
1713
|
+
buildDocxHighlightLayer,
|
|
1714
|
+
DocxHighlightMatch,
|
|
1715
|
+
DocxHighlightColors,
|
|
1716
|
+
DocxMatchLocation,
|
|
1717
|
+
FindMatch,
|
|
1718
|
+
FindMatchesOptions,
|
|
1091
1719
|
autoResize,
|
|
1092
1720
|
AutoResizeOptions,
|
|
1721
|
+
HyperlinkTarget,
|
|
1722
|
+
openExternalHyperlink,
|
|
1723
|
+
OoxmlError,
|
|
1724
|
+
OoxmlErrorCode,
|
|
1093
1725
|
noteText,
|
|
1094
1726
|
DocxDocumentModel,
|
|
1095
1727
|
DocSettings,
|
|
1728
|
+
EmbeddedFontRef,
|
|
1096
1729
|
SectionProps,
|
|
1097
1730
|
SectionGeom,
|
|
1731
|
+
PageNumType,
|
|
1732
|
+
PageBorders,
|
|
1733
|
+
PageBorderEdge,
|
|
1734
|
+
LineNumbering,
|
|
1098
1735
|
ColumnsSpec,
|
|
1099
1736
|
ColSpec,
|
|
1100
1737
|
HeadersFooters,
|
|
@@ -1103,10 +1740,13 @@ export declare namespace docx {
|
|
|
1103
1740
|
BodyElement,
|
|
1104
1741
|
DocParagraph,
|
|
1105
1742
|
DocRun,
|
|
1743
|
+
PTabRun,
|
|
1106
1744
|
DocxTextRun,
|
|
1107
1745
|
FieldRun,
|
|
1108
1746
|
ImageRun,
|
|
1747
|
+
ChartRun,
|
|
1109
1748
|
ShapeRun,
|
|
1749
|
+
TextPath,
|
|
1110
1750
|
ShapeText_2 as ShapeText,
|
|
1111
1751
|
ShapeTextRun_2 as ShapeTextRun,
|
|
1112
1752
|
RubyAnnotation,
|
|
@@ -1141,10 +1781,27 @@ declare class DocxDocument {
|
|
|
1141
1781
|
private _document;
|
|
1142
1782
|
private _meta;
|
|
1143
1783
|
private _pages;
|
|
1784
|
+
/** Lazily-built `bookmarkName → 0-based page index` map for internal hyperlink
|
|
1785
|
+
* anchors (IX-nav). Built on first {@link getBookmarkPage} from the paginated
|
|
1786
|
+
* pages (main) or the worker meta's `bookmarkPages` (worker). Nulled by
|
|
1787
|
+
* {@link destroy} so a reused reference never serves a stale document. */
|
|
1788
|
+
private _bookmarkPages;
|
|
1144
1789
|
private _mode;
|
|
1145
1790
|
private _worker;
|
|
1146
1791
|
private _bridge;
|
|
1147
1792
|
private _imageCache;
|
|
1793
|
+
/** Embedded `FontFace` objects this document registered into `document.fonts`
|
|
1794
|
+
* (main mode only — in worker mode the worker owns them and terminates with
|
|
1795
|
+
* its own FontFaceSet). Released in {@link destroy} so they do not leak into
|
|
1796
|
+
* the shared FontFaceSet for the lifetime of the SPA (deduped + refcounted in
|
|
1797
|
+
* core, so a font shared with another open document survives until both go). */
|
|
1798
|
+
private _embeddedFontFaces;
|
|
1799
|
+
/** Google-Fonts `FontFace` objects this document preloaded into `document.fonts`
|
|
1800
|
+
* (main mode only — in worker mode the worker owns them and terminates with its
|
|
1801
|
+
* own FontFaceSet). Released in {@link destroy} so they do not leak into the
|
|
1802
|
+
* shared FontFaceSet for the lifetime of the SPA (deduped + refcounted in core,
|
|
1803
|
+
* so a web font shared with another open document survives until both go). */
|
|
1804
|
+
private _googleFontFaces;
|
|
1148
1805
|
/** One stable closure per instance: core's path-keyed SVG cache namespaces on
|
|
1149
1806
|
* this identity, so two open documents never swap a shared zip path (e.g.
|
|
1150
1807
|
* word/media/image1.svg). Reusing one reference also lets the SVG cache hit
|
|
@@ -1163,6 +1820,32 @@ declare class DocxDocument {
|
|
|
1163
1820
|
* are decoded lazily rather than inlined as base64 at parse time.
|
|
1164
1821
|
*/
|
|
1165
1822
|
getImage(imagePath: string, mimeType: string): Promise<Blob>;
|
|
1823
|
+
/**
|
|
1824
|
+
* Extract raw bytes for an embedded font part by zip path (e.g.
|
|
1825
|
+
* `word/fonts/font1.odttf`). Routes through the SAME persistent-worker
|
|
1826
|
+
* `extractImage` message as {@link getImage} — `DocxArchive.extract_image`
|
|
1827
|
+
* reads ANY zip entry, not just media — returning the raw (still obfuscated)
|
|
1828
|
+
* `.odttf` bytes rather than a Blob. Consumed by {@link loadEmbeddedFonts},
|
|
1829
|
+
* which de-obfuscates (ECMA-376 §17.8.1) and registers each as a FontFace.
|
|
1830
|
+
*/
|
|
1831
|
+
getFontBytes(partPath: string): Promise<Uint8Array>;
|
|
1832
|
+
/**
|
|
1833
|
+
* Project the document to GitHub-flavoured markdown: headings (from
|
|
1834
|
+
* `<w:outlineLvl>`), bullet / numbered lists, tables (with vMerge
|
|
1835
|
+
* continuation), and rich-text formatting (bold / italic / strikethrough /
|
|
1836
|
+
* hyperlink), with footnotes / endnotes / comments collated at the end.
|
|
1837
|
+
* Positioning, section properties, fonts, and drawing shapes are discarded —
|
|
1838
|
+
* the projection is meant for AI ingestion and full-text search, not layout.
|
|
1839
|
+
*
|
|
1840
|
+
* Runs entirely in the worker off the archive opened at {@link load} (no
|
|
1841
|
+
* re-copy of the file, no re-parse of the model on the main thread), so it
|
|
1842
|
+
* works in BOTH `mode: 'main'` and `mode: 'worker'`.
|
|
1843
|
+
*
|
|
1844
|
+
* @example
|
|
1845
|
+
* const doc = await DocxDocument.load(buffer);
|
|
1846
|
+
* const md = await doc.toMarkdown();
|
|
1847
|
+
*/
|
|
1848
|
+
toMarkdown(): Promise<string>;
|
|
1166
1849
|
get pageCount(): number;
|
|
1167
1850
|
/** The render mode this engine was loaded with ('main' | 'worker'). A fact for
|
|
1168
1851
|
* integrators and the scroll viewer: an injected engine's mode decides whether
|
|
@@ -1198,6 +1881,23 @@ declare class DocxDocument {
|
|
|
1198
1881
|
*/
|
|
1199
1882
|
get endnotes(): DocNote[];
|
|
1200
1883
|
private _getPages;
|
|
1884
|
+
/** Lazily build (and cache) the `bookmarkName → page index` map from either
|
|
1885
|
+
* the worker meta (worker mode) or the paginated pages (main mode). */
|
|
1886
|
+
private _getBookmarkPages;
|
|
1887
|
+
/**
|
|
1888
|
+
* ECMA-376 §17.13.6.2 / §17.16.23 — resolve a bookmark name (a
|
|
1889
|
+
* `<w:hyperlink w:anchor>` internal-link target) to the 0-based index of the
|
|
1890
|
+
* page its `<w:bookmarkStart w:name>` destination falls on, or `undefined`
|
|
1891
|
+
* when the document has no bookmark of that name. When a bookmark's paragraph
|
|
1892
|
+
* spans a page break, the page where it *begins* is returned.
|
|
1893
|
+
*
|
|
1894
|
+
* This is the map an internal-hyperlink click resolves against: a viewer's
|
|
1895
|
+
* `onHyperlinkClick` default (or an integrator) turns the anchor into a page
|
|
1896
|
+
* and calls {@link DocxViewer.goToPage} (or scrolls the scroll viewer to it).
|
|
1897
|
+
* Works in BOTH `main` and `worker` mode (the map rides along in the worker
|
|
1898
|
+
* meta, built from the same paginated pages as `pageSizes`).
|
|
1899
|
+
*/
|
|
1900
|
+
getBookmarkPage(bookmarkName: string): number | undefined;
|
|
1201
1901
|
/**
|
|
1202
1902
|
* ECMA-376 §17.6.13 / §17.6.11 — the page size (pt) of page `pageIndex`, per
|
|
1203
1903
|
* section (a mixed portrait/landscape document returns different sizes per page).
|
|
@@ -1221,8 +1921,23 @@ declare class DocxDocument {
|
|
|
1221
1921
|
* The returned ImageBitmap is owned by the caller: pass it to
|
|
1222
1922
|
* `transferFromImageBitmap` (which consumes it) or call `bitmap.close()`
|
|
1223
1923
|
* when done, or its backing memory is held until GC.
|
|
1924
|
+
*
|
|
1925
|
+
* IX6 — an optional `onTextRun` in `opts` receives the page's text-run
|
|
1926
|
+
* geometry (the same stream `renderPage` emits in main mode), so a caller can
|
|
1927
|
+
* build the selection / find overlay from a worker-rendered page on the SAME
|
|
1928
|
+
* code path as main mode. In worker mode the runs ride back beside the bitmap
|
|
1929
|
+
* (one round-trip, no second render).
|
|
1224
1930
|
*/
|
|
1225
|
-
renderPageToBitmap(pageIndex: number, opts?:
|
|
1931
|
+
renderPageToBitmap(pageIndex: number, opts?: RenderPageToBitmapOptions): Promise<ImageBitmap>;
|
|
1932
|
+
/**
|
|
1933
|
+
* IX6 — collect a page's text-run geometry (`DocxTextRunInfo[]`) without
|
|
1934
|
+
* painting a visible canvas. Works in BOTH modes: worker mode renders the page
|
|
1935
|
+
* off-thread and ships only the runs (no bitmap transfer); main mode renders
|
|
1936
|
+
* to a throwaway offscreen canvas. Used by the find controller to scan every
|
|
1937
|
+
* page for matches. The geometry is identical to a `renderPage` of the same
|
|
1938
|
+
* page at the same width/dpr.
|
|
1939
|
+
*/
|
|
1940
|
+
collectPageRuns(pageIndex: number, opts?: WireRenderPageOptions): Promise<DocxTextRunInfo[]>;
|
|
1226
1941
|
}
|
|
1227
1942
|
|
|
1228
1943
|
declare interface DocxDocumentModel {
|
|
@@ -1243,6 +1958,21 @@ declare interface DocxDocumentModel {
|
|
|
1243
1958
|
* entry is absent or classified as "auto".
|
|
1244
1959
|
*/
|
|
1245
1960
|
fontFamilyClasses?: Record<string, string>;
|
|
1961
|
+
/**
|
|
1962
|
+
* ECMA-376 §17.8.3.29 — per-font pitch from `word/fontTable.xml`
|
|
1963
|
+
* (`<w:pitch>`, ST_Pitch §17.18.66): font name → "fixed" | "variable" |
|
|
1964
|
+
* "default". Present only for fonts that declare `<w:pitch>`. The renderer
|
|
1965
|
+
* pairs this with {@link fontFamilyClasses}: a `family="modern"` face is
|
|
1966
|
+
* treated as monospace ONLY when its pitch is "fixed"; "variable" /
|
|
1967
|
+
* "default" / absent fall through to name-pattern / CJK-sans classification
|
|
1968
|
+
* (§17.8.3.10 `family` classifies the design, not the pitch — issue #855).
|
|
1969
|
+
*/
|
|
1970
|
+
fontFamilyPitches?: Record<string, string>;
|
|
1971
|
+
/** ECMA-376 §17.8.3.3-.6 — embedded fonts from `word/fontTable.xml`, resolved
|
|
1972
|
+
* to their `.odttf` part paths + fontKey. The viewer de-obfuscates (§17.8.1)
|
|
1973
|
+
* and registers each as a FontFace before pagination so text measures/draws
|
|
1974
|
+
* with the authored typeface. */
|
|
1975
|
+
embeddedFonts?: EmbeddedFontRef[];
|
|
1246
1976
|
/** ECMA-376 §17.13.5 — flat list of `<w:ins>` / `<w:del>` events in the
|
|
1247
1977
|
* body. Each entry carries author / date / text. The renderer marks
|
|
1248
1978
|
* runs inline via {@link DocxTextRun.revision}; this array is primarily for
|
|
@@ -1262,6 +1992,31 @@ declare interface DocxDocumentModel {
|
|
|
1262
1992
|
* (kinsoku) configuration. Absent when settings.xml has no relevant
|
|
1263
1993
|
* elements (the renderer then uses spec defaults: kinsoku ON). */
|
|
1264
1994
|
settings?: DocSettings;
|
|
1995
|
+
/** RB7 partial degradation: set when `word/document.xml` (the body part) could
|
|
1996
|
+
* not be read or parsed. The document still "opens" — `body` is empty and this
|
|
1997
|
+
* part-tagged error (e.g. `"word/document.xml: <detail>"`) is carried — so the
|
|
1998
|
+
* viewer shows a visible placeholder page instead of throwing. Absent
|
|
1999
|
+
* (`undefined`) for every healthy document. */
|
|
2000
|
+
parseError?: string;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
declare interface DocxHighlightColors {
|
|
2004
|
+
/** Fill for non-active matches. */
|
|
2005
|
+
match?: string;
|
|
2006
|
+
/** Fill for the active match. */
|
|
2007
|
+
active?: string;
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
/** One page's highlight input: the run-slices a match covers, and whether that
|
|
2011
|
+
* match is the active one (emphasis colour). */
|
|
2012
|
+
declare interface DocxHighlightMatch {
|
|
2013
|
+
slices: MatchRunSlice[];
|
|
2014
|
+
active: boolean;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
/** Where a docx match lives: its 0-based page index. */
|
|
2018
|
+
declare interface DocxMatchLocation {
|
|
2019
|
+
page: number;
|
|
1265
2020
|
}
|
|
1266
2021
|
|
|
1267
2022
|
/** ECMA-376 §17.3.2.4 `<w:bdr>` — a run-level border drawn as a box around the
|
|
@@ -1277,7 +2032,7 @@ declare interface DocxRunBorder {
|
|
|
1277
2032
|
space: number;
|
|
1278
2033
|
}
|
|
1279
2034
|
|
|
1280
|
-
declare class DocxScrollViewer {
|
|
2035
|
+
declare class DocxScrollViewer implements ZoomableViewer {
|
|
1281
2036
|
private _doc;
|
|
1282
2037
|
private readonly _injected;
|
|
1283
2038
|
private readonly _opts;
|
|
@@ -1298,6 +2053,18 @@ declare class DocxScrollViewer {
|
|
|
1298
2053
|
* than a `_scale === 1` sentinel because a fit scale of exactly 1 is a valid
|
|
1299
2054
|
* established state (a 1× fit would otherwise be re-fit forever). */
|
|
1300
2055
|
private _scaleEstablished;
|
|
2056
|
+
/**
|
|
2057
|
+
* IX9 F1 — a `setScale` factor requested BEFORE the base fit is established
|
|
2058
|
+
* (pre-load, or a zero-width container), already clamped to
|
|
2059
|
+
* `[zoomMin, zoomMax]`, or `null` when none is pending. The single-canvas
|
|
2060
|
+
* viewers latch a pre-load `setScale` and honour it on the first render; the
|
|
2061
|
+
* scroll viewers used to silently DROP it — the family-unified semantics are
|
|
2062
|
+
* "latch and apply once the layout establishes". `relayout()` applies (and
|
|
2063
|
+
* clears) this right after establishing the base, firing `onScaleChange` at
|
|
2064
|
+
* application time; `getScale()` reports it while pending so the caller sees
|
|
2065
|
+
* the same value a single-canvas viewer would show.
|
|
2066
|
+
*/
|
|
2067
|
+
private _pendingScale;
|
|
1301
2068
|
/** Live slots keyed by page index. */
|
|
1302
2069
|
private readonly _slots;
|
|
1303
2070
|
/** Recyclable detached slots (canvas + textLayer reused across pages). */
|
|
@@ -1311,6 +2078,27 @@ declare class DocxScrollViewer {
|
|
|
1311
2078
|
* reporting an error so a rejection that lands after teardown is swallowed
|
|
1312
2079
|
* rather than surfaced to a `onError` on a dead viewer. */
|
|
1313
2080
|
private _destroyed;
|
|
2081
|
+
/** Throwaway 2D context reused to measure text for the §17.3.2.10 縦中横 overlay
|
|
2082
|
+
* clamp (#836). Lazily created; `null` when canvas metrics are unavailable
|
|
2083
|
+
* (headless), in which case the overlay degrades to the un-clamped span. */
|
|
2084
|
+
private _measureCtx;
|
|
2085
|
+
/**
|
|
2086
|
+
* Concurrent-load latch (generation token). Every self-loading `load()`
|
|
2087
|
+
* increments this and captures the value; after its engine finishes loading it
|
|
2088
|
+
* re-checks the live value and BAILS (destroying its own just-loaded engine) if
|
|
2089
|
+
* a newer `load()` has since started. Without it, two overlapping
|
|
2090
|
+
* `load(A)`/`load(B)` calls race the WASM parse / worker init, and whichever
|
|
2091
|
+
* RESOLVES last wins the swap — even the stale `load(A)` resolving after
|
|
2092
|
+
* `load(B)`; the loser's freshly created engine (never installed, or installed
|
|
2093
|
+
* then overwritten) then leaks its worker + pinned WASM allocation. The latch
|
|
2094
|
+
* composes with SC20: the check runs AFTER the new engine loads but BEFORE the
|
|
2095
|
+
* field assignment, `previous?.destroy()`, and the recycle/relayout post-load
|
|
2096
|
+
* work, so a superseded load never touches `this._doc` nor frees the current
|
|
2097
|
+
* (newer) engine. Only the self-loading path uses it — the injected path throws
|
|
2098
|
+
* up-front and never reaches here. `destroy()` also bumps it so a load in flight
|
|
2099
|
+
* at teardown is treated as superseded and its engine cleaned up.
|
|
2100
|
+
*/
|
|
2101
|
+
private _loadGen;
|
|
1314
2102
|
/** Worker mode: page indices whose bitmap render is currently dispatched to the
|
|
1315
2103
|
* engine. Coalesces a scroll storm — we never dispatch a second render for a
|
|
1316
2104
|
* page whose first is still in flight — and lets us drop pages that scrolled
|
|
@@ -1341,11 +2129,14 @@ declare class DocxScrollViewer {
|
|
|
1341
2129
|
* is host-agnostic. */
|
|
1342
2130
|
private _settleTimer;
|
|
1343
2131
|
private _wheelListener;
|
|
1344
|
-
/**
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1348
|
-
|
|
2132
|
+
/** Gesture-only pointer anchor for the NEXT `setScale`, in scrollHost-viewport
|
|
2133
|
+
* px (`{ x, y }` from the wheel event, relative to the scroll host's top-left).
|
|
2134
|
+
* Set by the Ctrl/⌘+wheel handler right before it calls `setScale` so the zoom
|
|
2135
|
+
* pivots on the cursor ("zoom toward the pointer") in BOTH axes; consumed and
|
|
2136
|
+
* cleared by `setScale`. `null` for every non-gesture source (the public
|
|
2137
|
+
* `setScale`, the +/- steppers, `fitWidth`/`fitPage`, the resize re-fit), which
|
|
2138
|
+
* keep the historical viewport-TOP re-anchor so their behaviour is unchanged. */
|
|
2139
|
+
private _pendingZoomAnchor;
|
|
1349
2140
|
/** Observes the container so a width change re-fits the base scale. Disconnected
|
|
1350
2141
|
* in `destroy()`. */
|
|
1351
2142
|
private _resizeObserver;
|
|
@@ -1414,6 +2205,12 @@ declare class DocxScrollViewer {
|
|
|
1414
2205
|
* `_positionSlot` (the flush-left floor), and by `_syncSpacer` (the spacer
|
|
1415
2206
|
* width). Resolved here (not stored) to mirror `_gap()`/`_pad()`. */
|
|
1416
2207
|
private _padH;
|
|
2208
|
+
/** Index of the page whose slot spans content-offset `y` (largest `i` with
|
|
2209
|
+
* `offsets[i] <= y`), for the pointer-anchored zoom re-anchor. Mirrors the
|
|
2210
|
+
* `topIndex` search `computeVisibleRange` runs for the scrollTop, but for an
|
|
2211
|
+
* ARBITRARY content-y (the pointer, not the viewport top). Clamped into
|
|
2212
|
+
* `[0, n-1]`; a `y` below the first page (inside the leading pad) yields 0. */
|
|
2213
|
+
private _pageIndexAtOffset;
|
|
1417
2214
|
private _range;
|
|
1418
2215
|
private _syncSpacer;
|
|
1419
2216
|
/** Horizontal scroll extent: the widest page (docx pages can differ in width)
|
|
@@ -1463,10 +2260,34 @@ declare class DocxScrollViewer {
|
|
|
1463
2260
|
* can pass for an old-epoch resolution). We gate them on the captured epoch.
|
|
1464
2261
|
*/
|
|
1465
2262
|
private _renderSlot;
|
|
1466
|
-
/**
|
|
1467
|
-
*
|
|
1468
|
-
*
|
|
1469
|
-
|
|
2263
|
+
/**
|
|
2264
|
+
* IX1/IX-nav — the click handler passed to the text-layer overlay. When the
|
|
2265
|
+
* caller supplied `onHyperlinkClick`, it fully owns the behaviour (the default
|
|
2266
|
+
* is suppressed). Otherwise the built-in default is: an external link opens in
|
|
2267
|
+
* a new tab through core `openExternalHyperlink` (URL sanitised against the
|
|
2268
|
+
* safe scheme allowlist, `noopener,noreferrer`); an internal `<w:anchor>` link
|
|
2269
|
+
* resolves its bookmark name to its destination page via
|
|
2270
|
+
* {@link DocxDocument.getBookmarkPage} (ECMA-376 §17.16.23) and scrolls there
|
|
2271
|
+
* with {@link scrollToPage}. An anchor naming no known bookmark is a safe no-op
|
|
2272
|
+
* rather than a scroll to a guessed page.
|
|
2273
|
+
*
|
|
2274
|
+
* IX1 — returns `undefined` when `enableHyperlinks` is `false`, the single gate
|
|
2275
|
+
* that disables hyperlink interactivity: {@link buildDocxTextLayer} treats a
|
|
2276
|
+
* missing handler as "render link runs like plain runs", so no hit region,
|
|
2277
|
+
* cursor, tooltip, listener, or navigation is wired (a custom
|
|
2278
|
+
* `onHyperlinkClick` is suppressed too).
|
|
2279
|
+
*/
|
|
2280
|
+
private _hyperlinkHandler;
|
|
2281
|
+
/** A width-measurer primed with a run's `font` — used ONLY to clamp a §17.3.2.10
|
|
2282
|
+
* 縦中横 selection span to its drawn one-em cell (#836). Mirrors DocxViewer's
|
|
2283
|
+
* `_measureForFont`. Returns a length-based fallback when canvas metrics are
|
|
2284
|
+
* unavailable so the caller still gets a callable (the overlay then sees scale
|
|
2285
|
+
* 1 and leaves the span un-clamped). */
|
|
2286
|
+
private _measureForFont;
|
|
2287
|
+
/** A canvas's intended CSS box in px (the % denominators the overlay builders
|
|
2288
|
+
* expect). Reads the inline `style.width`/`height` set by the render path,
|
|
2289
|
+
* falling back to the backing-store size when unset; tolerates the `px` suffix. */
|
|
2290
|
+
private _canvasCssPx;
|
|
1470
2291
|
/** Route an async render failure to `onError`, or `console.error` when none is
|
|
1471
2292
|
* set (so failures are never fully silent), and never after teardown. */
|
|
1472
2293
|
private _reportRenderError;
|
|
@@ -1496,7 +2317,10 @@ declare class DocxScrollViewer {
|
|
|
1496
2317
|
* `[zoomMin ?? 0.1, zoomMax ?? 4]` (absolute bounds, XlsxViewer convention — NOT
|
|
1497
2318
|
* multiples of the base fit; design §3 keeps the clamp in the viewer, not core),
|
|
1498
2319
|
* then re-anchor VERTICALLY so the page currently under the viewport top stays
|
|
1499
|
-
* fixed. A no-op when
|
|
2320
|
+
* fixed. A no-op when the clamped scale is unchanged. Called BEFORE the doc is
|
|
2321
|
+
* loaded / the base fit is established, the clamped factor is LATCHED (IX9 F1,
|
|
2322
|
+
* family-unified with the single-canvas viewers) and applied by `relayout()`
|
|
2323
|
+
* once the layout establishes — `onScaleChange` fires then.
|
|
1500
2324
|
*
|
|
1501
2325
|
* FLICKER-FREE (design §7): this does NOT re-render the visible pages inline.
|
|
1502
2326
|
* It shows an immediate CSS preview (stretch the existing bitmaps, scale the
|
|
@@ -1517,6 +2341,38 @@ declare class DocxScrollViewer {
|
|
|
1517
2341
|
* can no longer return below the floor to the original base fit through this API.
|
|
1518
2342
|
*/
|
|
1519
2343
|
setScale(scale: number): void;
|
|
2344
|
+
/** IX9 {@link ZoomableViewer} — the current zoom factor, where `1` = 100% (a
|
|
2345
|
+
* page at its natural pt→px width). This is the viewer's absolute `_scale`
|
|
2346
|
+
* (`widthPt × PT_TO_PX × _scale` is the drawn width), so it reads `1` at true
|
|
2347
|
+
* 100% and, after the initial fit-to-width, the base fit factor. Before the
|
|
2348
|
+
* fit is established it reports a latched pre-load `setScale` (IX9 F1) if one
|
|
2349
|
+
* is pending — matching what a single-canvas viewer would show — else `1`. */
|
|
2350
|
+
getScale(): number;
|
|
2351
|
+
/** IX9 {@link ZoomableViewer} — step up to the next rung of the shared zoom
|
|
2352
|
+
* ladder above the current factor (clamped to `zoomMax` by {@link setScale}). */
|
|
2353
|
+
zoomIn(): void;
|
|
2354
|
+
/** IX9 {@link ZoomableViewer} — step down to the next lower ladder rung. */
|
|
2355
|
+
zoomOut(): void;
|
|
2356
|
+
/**
|
|
2357
|
+
* IX9 {@link ZoomableViewer} — fit a page's WIDTH to the container (the classic
|
|
2358
|
+
* continuous-scroll "fit width"). Sets the scale to the width-fit base for the
|
|
2359
|
+
* current container, then re-anchors + re-renders via {@link setScale}. Defers
|
|
2360
|
+
* (no-op) while the container is unlaid-out. Note the `zoomMin`/`zoomMax` clamp
|
|
2361
|
+
* still applies, so a fit below `zoomMin` pins to `zoomMin`.
|
|
2362
|
+
*/
|
|
2363
|
+
fitWidth(): void;
|
|
2364
|
+
/**
|
|
2365
|
+
* IX9 {@link ZoomableViewer} — fit a WHOLE page (width and height) inside the
|
|
2366
|
+
* container so one page is visible without scrolling; takes the tighter of the
|
|
2367
|
+
* width/height fit. Uses the FIRST page's size (the continuous viewer's fit
|
|
2368
|
+
* reference, matching the base-fit convention). Defers while unlaid-out.
|
|
2369
|
+
*/
|
|
2370
|
+
fitPage(): void;
|
|
2371
|
+
/** Shared fit for {@link fitWidth}/{@link fitPage}: the width-fit factor is the
|
|
2372
|
+
* established base (`_baseScale`); the page-fit additionally bounds by the
|
|
2373
|
+
* container height against the first page's height. Applies via {@link setScale}
|
|
2374
|
+
* so the flicker-free re-anchor / settle path and `onScaleChange` all run. */
|
|
2375
|
+
private _fit;
|
|
1520
2376
|
/**
|
|
1521
2377
|
* CSS preview of the visible window at the current `_scale` (design §7
|
|
1522
2378
|
* mechanism 1), WITHOUT re-rendering. Slots leaving the window recycle normally;
|
|
@@ -1543,12 +2399,11 @@ declare class DocxScrollViewer {
|
|
|
1543
2399
|
private _scheduleSettle;
|
|
1544
2400
|
/** Full-resolution settle re-render of the visible window (design §7 mechanisms
|
|
1545
2401
|
* 2+3). Re-renders each mounted slot at the current scale via the double-buffer
|
|
1546
|
-
* swap (main) / same-canvas transfer (worker).
|
|
1547
|
-
* overlay
|
|
1548
|
-
*
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1551
|
-
* mid-render. */
|
|
2402
|
+
* swap (main) / same-canvas transfer (worker). Both modes rebuild the text
|
|
2403
|
+
* overlay from the fresh render's run geometry (IX6 — worker mode collects the
|
|
2404
|
+
* runs off-thread via `_renderSlotBitmap`) and clear the preview transform.
|
|
2405
|
+
* Dispatched at the CURRENT epoch; the existing epoch gate discards it if a
|
|
2406
|
+
* later `setScale` supersedes it mid-render. */
|
|
1552
2407
|
private _settleRender;
|
|
1553
2408
|
/**
|
|
1554
2409
|
* Settle-render one slot at the current scale (design §7 mechanism 3).
|
|
@@ -1624,6 +2479,8 @@ declare class DocxScrollViewer {
|
|
|
1624
2479
|
/* Excluded from this release type: baseScaleForTest */
|
|
1625
2480
|
/* Excluded from this release type: renderEpochForTest */
|
|
1626
2481
|
/* Excluded from this release type: resizeForTest */
|
|
2482
|
+
/* Excluded from this release type: contentAtViewportYForTest */
|
|
2483
|
+
/* Excluded from this release type: viewportYOfForTest */
|
|
1627
2484
|
/**
|
|
1628
2485
|
* Tear down the viewer: remove the DOM subtree and (only for a self-loaded
|
|
1629
2486
|
* engine) destroy the engine. An injected engine is left intact — the caller
|
|
@@ -1670,9 +2527,10 @@ declare interface DocxScrollViewerOptions extends Omit<RenderPageOptions, 'onTex
|
|
|
1670
2527
|
paddingRight?: number;
|
|
1671
2528
|
/** Pages kept mounted beyond the viewport on each side. Default 1. */
|
|
1672
2529
|
overscan?: number;
|
|
1673
|
-
/** Per-page transparent text-selection overlay.
|
|
1674
|
-
* in worker mode
|
|
1675
|
-
*
|
|
2530
|
+
/** Per-page transparent text-selection overlay. IX6 — works in BOTH render
|
|
2531
|
+
* modes: in worker mode the per-run geometry is collected off-thread and
|
|
2532
|
+
* shipped back beside the page bitmap, so the overlay is populated identically
|
|
2533
|
+
* to main mode (no more empty overlay / one-time warning). */
|
|
1676
2534
|
enableTextSelection?: boolean;
|
|
1677
2535
|
/** Minimum zoom scale (px-per-pt multiplier floor). Default 0.1. */
|
|
1678
2536
|
zoomMin?: number;
|
|
@@ -1715,6 +2573,24 @@ declare interface DocxScrollViewerOptions extends Omit<RenderPageOptions, 'onTex
|
|
|
1715
2573
|
* `computeVisibleRange` (the first page intersecting the viewport top,
|
|
1716
2574
|
* EXCLUDING overscan). */
|
|
1717
2575
|
onVisiblePageChange?: (topIndex: number, total: number) => void;
|
|
2576
|
+
/** IX9 — fires whenever the zoom factor actually changes (`1` = 100% = a page
|
|
2577
|
+
* at its natural pt→px size): from {@link DocxScrollViewer.setScale},
|
|
2578
|
+
* `zoomIn`/`zoomOut`, `fitWidth`/`fitPage`, a Ctrl/⌘+wheel gesture, or a
|
|
2579
|
+
* container-resize re-fit. Named `onScaleChange` to match the single-canvas
|
|
2580
|
+
* viewers so all five share one notification shape. */
|
|
2581
|
+
onScaleChange?: (scale: number) => void;
|
|
2582
|
+
/** IX1 (design decision — NOT user-confirmed, integrator may veto). Called when
|
|
2583
|
+
* a hyperlink run is clicked. When omitted, the default is: external → open in a
|
|
2584
|
+
* new tab via core `openExternalHyperlink` (sanitised, noopener,noreferrer);
|
|
2585
|
+
* internal → jump to the page whose text contains the bookmark (best-effort). */
|
|
2586
|
+
onHyperlinkClick?: (target: HyperlinkTarget) => void;
|
|
2587
|
+
/** IX1 — master switch for hyperlink interactivity. Default `true`. When
|
|
2588
|
+
* `false`, the hyperlink machinery is not wired at all: no overlay hit region
|
|
2589
|
+
* is installed for link runs, so there is no pointer cursor, no title tooltip,
|
|
2590
|
+
* no default navigation (external new-tab / internal bookmark jump), and
|
|
2591
|
+
* `onHyperlinkClick` is never called. Links still render exactly as authored
|
|
2592
|
+
* but are inert, like plain text. */
|
|
2593
|
+
enableHyperlinks?: boolean;
|
|
1718
2594
|
/** Error callback. When set, `load()` invokes it and resolves (otherwise the
|
|
1719
2595
|
* error is rethrown — shared viewer error contract). It ALSO fires for async
|
|
1720
2596
|
* per-slot render failures (both main `renderPage` and worker
|
|
@@ -1729,6 +2605,15 @@ declare interface DocxTextRun {
|
|
|
1729
2605
|
bold: boolean;
|
|
1730
2606
|
italic: boolean;
|
|
1731
2607
|
underline: boolean;
|
|
2608
|
+
/** ECMA-376 §17.3.2.40 `<w:u w:val>` — the raw ST_Underline (§17.18.99) style
|
|
2609
|
+
* value (`double` / `thick` / `dotted` / `wave` / `dashLong` / …). Absent for
|
|
2610
|
+
* the plain single rule (or no underline). The renderer normalizes this
|
|
2611
|
+
* WordprocessingML vocabulary to the shared DrawingML ST_TextUnderlineType
|
|
2612
|
+
* (§20.1.10.82) that `core.drawUnderline` dispatches on. */
|
|
2613
|
+
underlineStyle?: string;
|
|
2614
|
+
/** ECMA-376 §17.3.2.40 `<w:u w:color>` — underline-only colour (hex 6, or the
|
|
2615
|
+
* literal `auto`). Absent ⇒ the underline follows the glyph colour. */
|
|
2616
|
+
underlineColor?: string;
|
|
1732
2617
|
strikethrough: boolean;
|
|
1733
2618
|
fontSize: number;
|
|
1734
2619
|
color: string | null;
|
|
@@ -1756,10 +2641,23 @@ declare interface DocxTextRun {
|
|
|
1756
2641
|
vertAlign: 'super' | 'sub' | null;
|
|
1757
2642
|
/** Target URL for hyperlinks (resolved from relationships.xml) */
|
|
1758
2643
|
hyperlink: string | null;
|
|
2644
|
+
/** ECMA-376 §17.16.23 `<w:hyperlink w:anchor>` — internal bookmark name this
|
|
2645
|
+
* link jumps to (a `<w:bookmarkStart w:name>` in the same document). Set for an
|
|
2646
|
+
* internal cross-reference / TOC entry. When a link carries both `r:id` and
|
|
2647
|
+
* `w:anchor`, {@link DocxTextRun.hyperlink} (external) wins and this still
|
|
2648
|
+
* records the anchor. Absent when the link has no anchor. */
|
|
2649
|
+
hyperlinkAnchor?: string | null;
|
|
1759
2650
|
allCaps?: boolean;
|
|
1760
2651
|
smallCaps?: boolean;
|
|
1761
2652
|
doubleStrikethrough?: boolean;
|
|
1762
2653
|
highlight?: string | null;
|
|
2654
|
+
/** ECMA-376 §17.3.2.12 `<w:em w:val>` — emphasis (boten / 圏点) mark drawn on
|
|
2655
|
+
* every non-space character of the run (§17.18.24 ST_Em). `'dot'` = filled
|
|
2656
|
+
* dot above, `'comma'` = sesame/comma above, `'circle'` = hollow circle
|
|
2657
|
+
* above, `'underDot'` = filled dot below (horizontal writing). Absent (or the
|
|
2658
|
+
* authored `val="none"`) ⇒ no mark. The renderer stamps the mark per glyph
|
|
2659
|
+
* after the text and does NOT change the glyph advance. */
|
|
2660
|
+
emphasisMark?: EmphasisMark;
|
|
1763
2661
|
/** ECMA-376 §17.3.3.25 ruby annotation (furigana). Renders above the
|
|
1764
2662
|
* base text in a smaller font; line height is expanded to fit it. */
|
|
1765
2663
|
ruby?: RubyAnnotation;
|
|
@@ -1791,6 +2689,52 @@ declare interface DocxTextRun {
|
|
|
1791
2689
|
/** ECMA-376 §17.3.2.20 `<w:lang w:bidi>` — complex-script (RTL) language tag,
|
|
1792
2690
|
* lower-cased (e.g. "ar-sa", "ae-ar"). Drives Word's AN digit ordering. */
|
|
1793
2691
|
langBidi?: string;
|
|
2692
|
+
/** ECMA-376 §17.3.2.34 `<w:snapToGrid>` — false opts this run out of the
|
|
2693
|
+
* section character grid; absent inherits participation. */
|
|
2694
|
+
snapToGrid?: boolean;
|
|
2695
|
+
/** ECMA-376 §17.3.2.35 `<w:spacing w:val>` — character-spacing adjustment in
|
|
2696
|
+
* POINTS (signed): the extra pitch added after each character before the next
|
|
2697
|
+
* is rendered. The renderer feeds it to `ctx.letterSpacing` on BOTH the
|
|
2698
|
+
* measure and paint passes so line breaking / pagination stay consistent.
|
|
2699
|
+
* Absent ⇒ no extra pitch. */
|
|
2700
|
+
charSpacing?: number;
|
|
2701
|
+
/** ECMA-376 §17.3.2.14 `<w:fitText>` — manual run-width target in TWIPS
|
|
2702
|
+
* (`w:val`, 1/20 pt) plus the optional `w:id` that links consecutive runs
|
|
2703
|
+
* into one region. The arbitrary-precision XSD integer id is serialized as a
|
|
2704
|
+
* string; numeric synthetic inputs remain supported for layout tests and
|
|
2705
|
+
* direct model construction. An id-less run is always standalone. */
|
|
2706
|
+
fitTextVal?: number;
|
|
2707
|
+
fitTextId?: string | number;
|
|
2708
|
+
/** ECMA-376 §17.3.2.43 `<w:w w:val>` — horizontal text scale as a FRACTION of
|
|
2709
|
+
* normal character width (0.67 = 67%, 2.0 = 200%). Stretches each glyph's
|
|
2710
|
+
* width, not the gap between glyphs. Absent ⇒ 100%. */
|
|
2711
|
+
charScale?: number;
|
|
2712
|
+
/** ECMA-376 §17.3.2.24 `<w:position w:val>` — baseline raise (positive) /
|
|
2713
|
+
* lower (negative) in POINTS, without changing the font size or line box.
|
|
2714
|
+
* Absent ⇒ no shift. */
|
|
2715
|
+
position?: number;
|
|
2716
|
+
/** ECMA-376 §17.3.2.19 `<w:kern w:val>` — font-kerning threshold in POINTS
|
|
2717
|
+
* (the smallest font size that is kerned). Presence enables kerning subject
|
|
2718
|
+
* to the threshold; absent ⇒ kerning off (the hierarchy default). `0` = kern
|
|
2719
|
+
* at all sizes. */
|
|
2720
|
+
kerning?: number;
|
|
2721
|
+
/** ECMA-376 §17.3.2.10 `<w:eastAsianLayout w:vert>` — horizontal-in-vertical
|
|
2722
|
+
* (縦中横 / tate-chū-yoko). `true` means that in a VERTICAL (tbRl) page this
|
|
2723
|
+
* run's characters are laid out horizontally side by side within ONE cell of
|
|
2724
|
+
* the vertical line (rotated 90° relative to the vertical flow). Absent ⇒
|
|
2725
|
+
* normal vertical stacking. Inert in a horizontal page. */
|
|
2726
|
+
eastAsianVert?: boolean;
|
|
2727
|
+
/** ECMA-376 §17.3.2.10 `<w:eastAsianLayout w:vertCompress>` — compress the
|
|
2728
|
+
* 縦中横 run to fit the existing line height without growing the line. Ignored
|
|
2729
|
+
* unless {@link eastAsianVert} is set. Absent ⇒ not compressed. */
|
|
2730
|
+
eastAsianVertCompress?: boolean;
|
|
2731
|
+
/** ECMA-376 §17.3.2.10 `<w:eastAsianLayout w:combine>` — two-lines-in-one.
|
|
2732
|
+
* PARSED for completeness; not yet rendered (no fixture). */
|
|
2733
|
+
eastAsianCombine?: boolean;
|
|
2734
|
+
/** ECMA-376 §17.3.2.10 `<w:eastAsianLayout w:combineBrackets>` (§17.18.8) —
|
|
2735
|
+
* bracket style around two-lines-in-one text. PARSED for completeness; the
|
|
2736
|
+
* two-lines-in-one draw is a follow-up. */
|
|
2737
|
+
eastAsianCombineBrackets?: string;
|
|
1794
2738
|
/** ECMA-376 §17.11.6/.7/.16/.17 — set when this run is a footnote/endnote
|
|
1795
2739
|
* reference marker (`<w:footnoteReference>` in the body, `<w:footnoteRef>` at
|
|
1796
2740
|
* the start of the note's content, and the endnote equivalents). `text` holds
|
|
@@ -1814,11 +2758,43 @@ declare interface DocxTextRunInfo {
|
|
|
1814
2758
|
fontSize: number;
|
|
1815
2759
|
/** CSS `font` shorthand used for canvas drawing (e.g. `"bold 16px Arial"`). */
|
|
1816
2760
|
font: string;
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
2761
|
+
/** Uniform per-code-point pitch in CSS px used to draw a horizontal run.
|
|
2762
|
+
* Absent when the pitch is zero or the run uses vertical / 縦中横 paint. */
|
|
2763
|
+
letterSpacingPx?: number;
|
|
2764
|
+
/** ECMA-376 §17.6.20 (tbRl) — when the page is vertical the canvas is the
|
|
2765
|
+
* physical landscape page rotated +90° at paint, so this run's `x`/`y` are the
|
|
2766
|
+
* PHYSICAL top-left the overlay span must sit at, and `transform` is the CSS
|
|
2767
|
+
* rotation (`"rotate(90deg)"`, applied about the span's top-left) that lays the
|
|
2768
|
+
* horizontal DOM span along the drawn (rotated) glyph run. Absent for
|
|
2769
|
+
* horizontal pages (the span is placed at `x`/`y` untransformed). */
|
|
2770
|
+
transform?: string;
|
|
2771
|
+
/** IX1 — the resolved hyperlink target of this run (ECMA-376 §17.16.22
|
|
2772
|
+
* external URL / §17.16.23 internal `w:anchor` bookmark), or absent for a
|
|
2773
|
+
* non-link run. The text-layer overlay turns a run carrying this into a
|
|
2774
|
+
* clickable region; the drawn glyphs are unaffected. */
|
|
2775
|
+
hyperlink?: HyperlinkTarget;
|
|
2776
|
+
/** ECMA-376 §17.3.2.10 eastAsianLayout `w:vert` (縦中横 / horizontal-in-vertical):
|
|
2777
|
+
* `true` when this run was drawn as tate-chu-yoko — its glyphs laid out
|
|
2778
|
+
* horizontally, side by side, COMPRESSED into ONE em cell of the vertical
|
|
2779
|
+
* column (see {@link drawTateChuYokoRun}). `w` is the drawn cell extent (one
|
|
2780
|
+
* em), NOT the natural text width, so the find / selection overlays must clamp
|
|
2781
|
+
* their horizontal extent to `w` rather than re-measuring the run's natural
|
|
2782
|
+
* glyphs (issue #836). Absent for every ordinary run. */
|
|
2783
|
+
eastAsianVert?: boolean;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
declare class DocxViewer implements ZoomableViewer {
|
|
1820
2787
|
private _doc;
|
|
1821
2788
|
private _currentPage;
|
|
2789
|
+
/**
|
|
2790
|
+
* IX9 explicit zoom factor (`1` = 100% = the page at its natural pt→px width),
|
|
2791
|
+
* or `null` when the caller has never invoked a zoom method. `null` preserves
|
|
2792
|
+
* the pre-IX9 render path EXACTLY: the page renders at `opts.width` (or its
|
|
2793
|
+
* natural width when that is unset), so default rendering is byte-identical. The
|
|
2794
|
+
* first `setScale`/`zoomIn`/`zoomOut`/`fitWidth`/`fitPage` call latches a number
|
|
2795
|
+
* here, after which `_renderPage` derives the canvas width from it instead.
|
|
2796
|
+
*/
|
|
2797
|
+
private _scale;
|
|
1822
2798
|
private _canvas;
|
|
1823
2799
|
private _wrapper;
|
|
1824
2800
|
/** The canvas's DOM position BEFORE the constructor reparented it into
|
|
@@ -1831,20 +2807,56 @@ declare class DocxViewer {
|
|
|
1831
2807
|
* (empty string if it was unset), restored on {@link destroy}. */
|
|
1832
2808
|
private _originalDisplay;
|
|
1833
2809
|
private _textLayer;
|
|
2810
|
+
/** IX2 — the find-highlight overlay layer. Always created (independent of
|
|
2811
|
+
* `enableTextSelection`): highlights ride the same positioned-DOM overlay
|
|
2812
|
+
* mechanism as the selection layer but are visible boxes, not transparent
|
|
2813
|
+
* spans. Sits above the text layer so a highlight shows over a link's hit
|
|
2814
|
+
* region without stealing its clicks (`pointer-events:none`). */
|
|
2815
|
+
private _highlightLayer;
|
|
2816
|
+
/** IX2 — find state (per-page runs, matches, active cursor). */
|
|
2817
|
+
private _find;
|
|
2818
|
+
/** A 2d context used only to measure text for highlight geometry (its own
|
|
2819
|
+
* 1×1 offscreen canvas, so measuring never touches the visible canvas). */
|
|
2820
|
+
private _measureCtx;
|
|
1834
2821
|
private _opts;
|
|
1835
2822
|
private readonly _mode;
|
|
1836
2823
|
/** The canvas's bitmaprenderer context, used only in worker mode (a canvas
|
|
1837
2824
|
* holds one context type for its lifetime; the main-mode 2d render path is
|
|
1838
2825
|
* never used on the same canvas). */
|
|
1839
2826
|
private _bitmapCtx;
|
|
1840
|
-
|
|
2827
|
+
/** Set by {@link destroy} (first line). Guards {@link _reportRenderError} so a
|
|
2828
|
+
* render rejection that lands AFTER teardown is swallowed rather than surfaced
|
|
2829
|
+
* to an `onError` / `console.error` on a dead viewer — parity with the scroll
|
|
2830
|
+
* viewers' `_destroyed` flag. */
|
|
2831
|
+
private _destroyed;
|
|
2832
|
+
/**
|
|
2833
|
+
* Concurrent-load latch (generation token). Every {@link load} increments this
|
|
2834
|
+
* and captures the value; after its engine finishes loading it re-checks the
|
|
2835
|
+
* live value and BAILS (destroying its own just-loaded engine) if a newer
|
|
2836
|
+
* `load()` has since started. Without it, two overlapping `load(A)`/`load(B)`
|
|
2837
|
+
* calls race the WASM parse / worker init, and whichever RESOLVES last wins the
|
|
2838
|
+
* swap — even the stale `load(A)` resolving after `load(B)`; the loser's freshly
|
|
2839
|
+
* created engine (never installed, or installed then overwritten) then leaks its
|
|
2840
|
+
* worker + pinned WASM allocation. The latch composes with SC20: the check runs
|
|
2841
|
+
* AFTER the new engine loads but BEFORE the field assignment and
|
|
2842
|
+
* `previous?.destroy()`, so a superseded load never touches `this._doc` nor
|
|
2843
|
+
* frees the current (newer) engine. {@link destroy} also bumps it so a load in
|
|
2844
|
+
* flight at teardown is treated as superseded and its engine cleaned up.
|
|
2845
|
+
*/
|
|
2846
|
+
private _loadGen;
|
|
1841
2847
|
constructor(canvas: HTMLCanvasElement, opts?: DocxViewerOptions);
|
|
1842
2848
|
/**
|
|
1843
2849
|
* Load a DOCX from URL or ArrayBuffer and render the first page.
|
|
1844
2850
|
*
|
|
1845
|
-
* Error contract (shared by all three viewers):
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
2851
|
+
* Error contract (shared by all three viewers):
|
|
2852
|
+
* - Parse/load failure (the underlying `DocxDocument.load()` call itself
|
|
2853
|
+
* rejects): if an `onError` callback was provided it is invoked and `load`
|
|
2854
|
+
* resolves normally; if not, the error is rethrown so it is never silently
|
|
2855
|
+
* swallowed.
|
|
2856
|
+
* - Render failure (the first page fails to draw AFTER a successful
|
|
2857
|
+
* parse/load): routed to the shared `_reportRenderError` contract (`onError`
|
|
2858
|
+
* if provided, else `console.error` — never silent) and `load` still
|
|
2859
|
+
* RESOLVES, matching every subsequent navigation call.
|
|
1848
2860
|
*/
|
|
1849
2861
|
load(source: string | ArrayBuffer): Promise<void>;
|
|
1850
2862
|
get pageCount(): number;
|
|
@@ -1854,6 +2866,91 @@ declare class DocxViewer {
|
|
|
1854
2866
|
goToPage(index: number): Promise<void>;
|
|
1855
2867
|
nextPage(): Promise<void>;
|
|
1856
2868
|
prevPage(): Promise<void>;
|
|
2869
|
+
/** Natural (100%) CSS-px width of the current page — `widthPt × PT_TO_PX`.
|
|
2870
|
+
* This is the scale-1 reference every zoom factor multiplies. 0 when nothing
|
|
2871
|
+
* is loaded. */
|
|
2872
|
+
private _naturalWidthPx;
|
|
2873
|
+
/**
|
|
2874
|
+
* The width (CSS px) `_renderPage` renders the current page at, honouring the
|
|
2875
|
+
* zoom state. `_scale === null` (no zoom method ever called) ⇒ the pre-IX9
|
|
2876
|
+
* value `opts.width` verbatim (byte-identical default: `undefined` lets the
|
|
2877
|
+
* renderer use the page's natural width). Once a factor latched ⇒
|
|
2878
|
+
* `naturalWidth × scale` (rounded), so the on-screen page is exactly `scale ×`
|
|
2879
|
+
* its natural size regardless of the original `opts.width`.
|
|
2880
|
+
*/
|
|
2881
|
+
private _renderWidth;
|
|
2882
|
+
/** IX9 {@link ZoomableViewer} — the current zoom factor (`1` = 100%). Before
|
|
2883
|
+
* any zoom method is called this is the EFFECTIVE scale implied by the current
|
|
2884
|
+
* render width: `opts.width / naturalWidth`, or `1` when `opts.width` is unset
|
|
2885
|
+
* (the page renders at its natural size) or nothing is loaded. */
|
|
2886
|
+
getScale(): number;
|
|
2887
|
+
private _zoomMin;
|
|
2888
|
+
private _zoomMax;
|
|
2889
|
+
/**
|
|
2890
|
+
* IX9 {@link ZoomableViewer} — set the absolute zoom factor (`1` = 100% = the
|
|
2891
|
+
* page at its natural pt→px width), clamped to `[zoomMin, zoomMax]`, and
|
|
2892
|
+
* re-render the current page at the new size. Fires `onScaleChange` when the
|
|
2893
|
+
* clamped factor actually changes. Resolves once the re-render settles. A no-op
|
|
2894
|
+
* (but still latches the scale) when nothing is loaded.
|
|
2895
|
+
*/
|
|
2896
|
+
setScale(scale: number): Promise<void>;
|
|
2897
|
+
/** IX9 {@link ZoomableViewer} — step up to the next rung of the shared zoom
|
|
2898
|
+
* ladder (clamped to `zoomMax`). */
|
|
2899
|
+
zoomIn(): Promise<void>;
|
|
2900
|
+
/** IX9 {@link ZoomableViewer} — step down to the next lower ladder rung. */
|
|
2901
|
+
zoomOut(): Promise<void>;
|
|
2902
|
+
/**
|
|
2903
|
+
* IX9 {@link ZoomableViewer} — fit the current page's WIDTH to the host
|
|
2904
|
+
* container (the element the canvas lives in, or `opts.container` if supplied),
|
|
2905
|
+
* then re-render. Defers (no-op) when nothing is loaded or the container is
|
|
2906
|
+
* unlaid-out. Routes through {@link setScale}, so the factor is clamped and
|
|
2907
|
+
* `onScaleChange` fires.
|
|
2908
|
+
*/
|
|
2909
|
+
fitWidth(): Promise<void>;
|
|
2910
|
+
/**
|
|
2911
|
+
* IX9 {@link ZoomableViewer} — fit the WHOLE current page (width and height)
|
|
2912
|
+
* inside the container so it is visible without scrolling; takes the tighter of
|
|
2913
|
+
* the width/height fit. Defers when unloaded / unlaid-out.
|
|
2914
|
+
*/
|
|
2915
|
+
fitPage(): Promise<void>;
|
|
2916
|
+
/** Shared fit for {@link fitWidth}/{@link fitPage}: measure the natural page
|
|
2917
|
+
* size + the container box, ask core's pure `fitScale`, apply via setScale. */
|
|
2918
|
+
private _fit;
|
|
2919
|
+
/** The element a fit measures against: the explicit `opts.container`, else the
|
|
2920
|
+
* host the wrapper was inserted into (`_wrapper.parentElement`). `null` when
|
|
2921
|
+
* the canvas was mounted detached (no host to fit to). */
|
|
2922
|
+
private _fitContainer;
|
|
2923
|
+
/**
|
|
2924
|
+
* IX2 — find every occurrence of `query` in the document and highlight them
|
|
2925
|
+
* all (a soft box per match, drawn on the highlight overlay over the drawn
|
|
2926
|
+
* glyphs). Returns every match in document order, each tagged with its
|
|
2927
|
+
* `{ page }` (0-based). Case-insensitive by default (browser find-in-page);
|
|
2928
|
+
* pass `{ caseSensitive: true }` to match case exactly.
|
|
2929
|
+
*
|
|
2930
|
+
* Scans all pages, so a large document renders each page once (offscreen) to
|
|
2931
|
+
* read its text (the visible page reuses its on-screen render). IX6 — works in
|
|
2932
|
+
* BOTH `mode: 'main'` and `mode: 'worker'`: in worker mode each page's run
|
|
2933
|
+
* geometry is collected off-thread and shipped back, so find returns the same
|
|
2934
|
+
* matches on the same code path. An empty query clears the find and returns `[]`.
|
|
2935
|
+
*/
|
|
2936
|
+
findText(query: string, opts?: FindMatchesOptions): Promise<FindMatch<DocxMatchLocation>[]>;
|
|
2937
|
+
/**
|
|
2938
|
+
* IX2 — move to the next match (wrap-around from last to first), navigating to
|
|
2939
|
+
* its page if needed, and draw it in the distinct active-match colour. Returns
|
|
2940
|
+
* the now-active match, or `null` when there are no matches. Call
|
|
2941
|
+
* {@link findText} first.
|
|
2942
|
+
*/
|
|
2943
|
+
findNext(): Promise<FindMatch<DocxMatchLocation> | null>;
|
|
2944
|
+
/** IX2 — move to the previous match (wrap-around from first to last). */
|
|
2945
|
+
findPrev(): Promise<FindMatch<DocxMatchLocation> | null>;
|
|
2946
|
+
/** IX2 — clear all highlights and reset the find state. */
|
|
2947
|
+
clearFind(): void;
|
|
2948
|
+
/** Navigate to the active match's page (if not already there) and redraw the
|
|
2949
|
+
* highlights so the active box shows in the emphasis colour. */
|
|
2950
|
+
private _activateMatch;
|
|
2951
|
+
/** Rebuild the highlight overlay for the current page from cached runs
|
|
2952
|
+
* (no page re-render). */
|
|
2953
|
+
private _redrawHighlights;
|
|
1857
2954
|
/**
|
|
1858
2955
|
* Terminate the parser worker and release resources.
|
|
1859
2956
|
*
|
|
@@ -1865,7 +2962,45 @@ declare class DocxViewer {
|
|
|
1865
2962
|
*/
|
|
1866
2963
|
destroy(): void;
|
|
1867
2964
|
private _render;
|
|
2965
|
+
/** Route a render failure to `onError`, or `console.error` when none is given
|
|
2966
|
+
* (never fully silent), and never after teardown. Mirrors the scroll viewers'
|
|
2967
|
+
* `_reportRenderError`. */
|
|
2968
|
+
private _reportRenderError;
|
|
2969
|
+
private _renderPage;
|
|
2970
|
+
/** Draw the find-highlight boxes for the current page from its runs. Clears
|
|
2971
|
+
* the overlay when there is no active find. */
|
|
2972
|
+
private _buildHighlightLayer;
|
|
2973
|
+
/** The canvas's intended CSS box in px (the % denominators the overlay builders
|
|
2974
|
+
* expect). Reads the inline `style.width`/`height` set by the render path
|
|
2975
|
+
* (which mirror the render's logical size), falling back to the backing-store
|
|
2976
|
+
* dimensions when unset. Parsing tolerates the trailing `px`. */
|
|
2977
|
+
private _canvasCssPx;
|
|
2978
|
+
/** A width-measurer primed with `font`, backed by a private 1×1 canvas so it
|
|
2979
|
+
* never disturbs the visible canvas's context state. */
|
|
2980
|
+
private _measureForFont;
|
|
2981
|
+
/** Render a page to a throwaway offscreen canvas purely to collect its runs
|
|
2982
|
+
* (text + geometry) for search, without touching the visible canvas. Used by
|
|
2983
|
+
* the find controller for pages other than the one on screen. */
|
|
2984
|
+
private _collectPageRuns;
|
|
1868
2985
|
private _buildTextLayer;
|
|
2986
|
+
/**
|
|
2987
|
+
* IX1/IX-nav — the click handler passed to the text-layer overlay. When the
|
|
2988
|
+
* caller supplied `onHyperlinkClick`, it fully owns the behaviour (the default
|
|
2989
|
+
* is suppressed). Otherwise the built-in default is: an external link opens in
|
|
2990
|
+
* a new tab through core `openExternalHyperlink` (URL sanitised against the
|
|
2991
|
+
* safe scheme allowlist, `noopener,noreferrer`); an internal `<w:anchor>` link
|
|
2992
|
+
* resolves its bookmark name to a page via
|
|
2993
|
+
* {@link DocxDocument.getBookmarkPage} (ECMA-376 §17.16.23) and jumps there
|
|
2994
|
+
* with {@link goToPage}. An anchor naming no known bookmark is a safe no-op
|
|
2995
|
+
* rather than a jump to a guessed page.
|
|
2996
|
+
*
|
|
2997
|
+
* IX1 — returns `undefined` when `enableHyperlinks` is `false`, the single gate
|
|
2998
|
+
* that disables hyperlink interactivity: {@link buildDocxTextLayer} treats a
|
|
2999
|
+
* missing handler as "render link runs like plain runs", so no hit region,
|
|
3000
|
+
* cursor, tooltip, listener, or navigation is wired (a custom
|
|
3001
|
+
* `onHyperlinkClick` is suppressed too).
|
|
3002
|
+
*/
|
|
3003
|
+
private _hyperlinkHandler;
|
|
1869
3004
|
}
|
|
1870
3005
|
|
|
1871
3006
|
declare interface DocxViewerOptions extends RenderPageOptions, LoadOptions_4 {
|
|
@@ -1877,10 +3012,58 @@ declare interface DocxViewerOptions extends RenderPageOptions, LoadOptions_4 {
|
|
|
1877
3012
|
enableTextSelection?: boolean;
|
|
1878
3013
|
/** Called when a page finishes rendering. */
|
|
1879
3014
|
onPageChange?: (index: number, total: number) => void;
|
|
3015
|
+
/** IX9 zoom contract ({@link ZoomableViewer}) — the clamp range for
|
|
3016
|
+
* {@link DocxViewer.setScale} / `zoomIn` / `zoomOut` / `fitWidth` / `fitPage`,
|
|
3017
|
+
* as user-facing zoom factors (`1` = 100% = the page at its natural pt→px
|
|
3018
|
+
* size). Defaults 0.1–4 (10%–400%), matching the other viewers. */
|
|
3019
|
+
zoomMin?: number;
|
|
3020
|
+
zoomMax?: number;
|
|
3021
|
+
/** IX9 — fires whenever the zoom factor actually changes (`1` = 100%): from
|
|
3022
|
+
* {@link DocxViewer.setScale}, `zoomIn`/`zoomOut`, or `fitWidth`/`fitPage`.
|
|
3023
|
+
* Named `onScaleChange` to match the pptx/xlsx viewers so all five share one
|
|
3024
|
+
* notification shape. */
|
|
3025
|
+
onScaleChange?: (scale: number) => void;
|
|
3026
|
+
/** IX1 (design decision — NOT user-confirmed, integrator may veto). Called when
|
|
3027
|
+
* a hyperlink run is clicked. When omitted, the default is: external → open in a
|
|
3028
|
+
* new tab via core `openExternalHyperlink` (sanitised, noopener,noreferrer);
|
|
3029
|
+
* internal → jump to the page whose text contains the bookmark (best-effort). */
|
|
3030
|
+
onHyperlinkClick?: (target: HyperlinkTarget) => void;
|
|
3031
|
+
/** IX1 — master switch for hyperlink interactivity. Default `true`. When
|
|
3032
|
+
* `false`, the hyperlink machinery is not wired at all: no overlay hit region
|
|
3033
|
+
* is installed for link runs, so there is no pointer cursor, no title tooltip,
|
|
3034
|
+
* no default navigation (external new-tab / internal bookmark jump), and
|
|
3035
|
+
* `onHyperlinkClick` is never called. Links still render exactly as authored
|
|
3036
|
+
* (their colour/underline are painted on the canvas) but are inert, like plain
|
|
3037
|
+
* text. Set it to disable clickable links entirely — e.g. in a preview where
|
|
3038
|
+
* navigation must not leave the current view. */
|
|
3039
|
+
enableHyperlinks?: boolean;
|
|
1880
3040
|
/** Called on parse or render errors. */
|
|
1881
3041
|
onError?: (err: Error) => void;
|
|
1882
3042
|
}
|
|
1883
3043
|
|
|
3044
|
+
/** A duotone effect resolved to its two endpoint colours. Both are 6-char
|
|
3045
|
+
* uppercase hex WITHOUT a leading `#` (the form the Rust parsers emit). `clr1`
|
|
3046
|
+
* is the dark endpoint (luminance 0), `clr2` the light endpoint (luminance 1),
|
|
3047
|
+
* matching the child order of `<a:duotone>` in §20.1.8.23. Any per-colour
|
|
3048
|
+
* transforms (lumMod/lumOff/tint/satMod/…) are already baked into these hexes
|
|
3049
|
+
* by the parser's colour-resolution machinery. */
|
|
3050
|
+
declare interface Duotone {
|
|
3051
|
+
/** First `EG_ColorChoice` child — the dark endpoint. 6-char hex, no `#`. */
|
|
3052
|
+
clr1: string;
|
|
3053
|
+
/** Second `EG_ColorChoice` child — the light endpoint. 6-char hex, no `#`. */
|
|
3054
|
+
clr2: string;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
/** ECMA-376 §20.1.8.23 `<a:duotone>` image effect, resolved to its two endpoint
|
|
3058
|
+
* colours (mirrors the shared Rust `ooxml_common::blip::Duotone`). `clr1` is the
|
|
3059
|
+
* dark endpoint (luminance 0), `clr2` the light endpoint (luminance 1); both are
|
|
3060
|
+
* 6-char uppercase hex WITHOUT a leading `#`, with per-colour transforms already
|
|
3061
|
+
* applied by the parser. */
|
|
3062
|
+
declare interface Duotone_2 {
|
|
3063
|
+
clr1: string;
|
|
3064
|
+
clr2: string;
|
|
3065
|
+
}
|
|
3066
|
+
|
|
1884
3067
|
declare interface Dxf {
|
|
1885
3068
|
font: CellFont | null;
|
|
1886
3069
|
fill: CellFill | null;
|
|
@@ -1892,6 +3075,20 @@ declare interface Dxf {
|
|
|
1892
3075
|
numFmt?: NumFmt | null;
|
|
1893
3076
|
}
|
|
1894
3077
|
|
|
3078
|
+
/** ECMA-376 §17.8.3.3-.6 — one embedded font-style slot from
|
|
3079
|
+
* `word/fontTable.xml`, resolved to its obfuscated part path + fontKey. */
|
|
3080
|
+
declare interface EmbeddedFontRef {
|
|
3081
|
+
fontName: string;
|
|
3082
|
+
style: 'regular' | 'bold' | 'italic' | 'boldItalic';
|
|
3083
|
+
partPath: string;
|
|
3084
|
+
fontKey: string;
|
|
3085
|
+
}
|
|
3086
|
+
|
|
3087
|
+
/** ECMA-376 §17.18.24 ST_Em — the emphasis-mark styles a run may carry via
|
|
3088
|
+
* `<w:em w:val>` (§17.3.2.12). `'none'` is filtered out by the parser, so the
|
|
3089
|
+
* model only ever carries one of these four positive marks (or `undefined`). */
|
|
3090
|
+
declare type EmphasisMark = 'dot' | 'comma' | 'circle' | 'underDot';
|
|
3091
|
+
|
|
1895
3092
|
/**
|
|
1896
3093
|
* An OMML equation embedded in a paragraph (ECMA-376 §22.1). Parsed into the
|
|
1897
3094
|
* shared math AST and rendered by `@silurus/ooxml-core`'s math engine.
|
|
@@ -1930,6 +3127,10 @@ declare interface FieldRun {
|
|
|
1930
3127
|
smallCaps?: boolean;
|
|
1931
3128
|
doubleStrikethrough?: boolean;
|
|
1932
3129
|
highlight?: string | null;
|
|
3130
|
+
/** ECMA-376 §17.3.2.12 `<w:em w:val>` — emphasis (boten / 圏点) mark, mirrors
|
|
3131
|
+
* {@link DocxTextRun.emphasisMark} (§17.18.24 ST_Em). Absent (or the
|
|
3132
|
+
* authored `val="none"`) ⇒ no mark. */
|
|
3133
|
+
emphasisMark?: EmphasisMark;
|
|
1933
3134
|
}
|
|
1934
3135
|
|
|
1935
3136
|
declare type Fill = SolidFill | NoFill | GradientFill | PatternFill | ImageFill;
|
|
@@ -1947,6 +3148,47 @@ declare interface FillRect {
|
|
|
1947
3148
|
b?: number;
|
|
1948
3149
|
}
|
|
1949
3150
|
|
|
3151
|
+
/**
|
|
3152
|
+
* IX2 public find-result shape, shared by all three viewers.
|
|
3153
|
+
*
|
|
3154
|
+
* `findText` returns an ordered list of {@link FindMatch}. Every match carries
|
|
3155
|
+
* its ordinal position (`matchIndex`, 0-based, document order — the same index
|
|
3156
|
+
* `findNext` / `findPrev` cycle through), the matched `text`, and a
|
|
3157
|
+
* format-specific `location`. The location is where the three formats
|
|
3158
|
+
* legitimately differ — a docx match lives on a page, a pptx match on a slide,
|
|
3159
|
+
* an xlsx match in a sheet cell — so `FindMatch` is generic over it rather than
|
|
3160
|
+
* forcing an artificial common shape. Each viewer instantiates it with its own
|
|
3161
|
+
* location type:
|
|
3162
|
+
*
|
|
3163
|
+
* - `DocxViewer.findText` → `FindMatch<DocxMatchLocation>` ({ page })
|
|
3164
|
+
* - `PptxViewer.findText` → `FindMatch<PptxMatchLocation>` ({ slide })
|
|
3165
|
+
* - `XlsxViewer.findText` → `FindMatch<XlsxMatchLocation>` ({ sheet, ref, … })
|
|
3166
|
+
*
|
|
3167
|
+
* The generic default is `unknown` so `FindMatch` can be referenced without a
|
|
3168
|
+
* type argument (e.g. in generic UI code) while each viewer's return type stays
|
|
3169
|
+
* precise.
|
|
3170
|
+
*/
|
|
3171
|
+
declare interface FindMatch<Loc = unknown> {
|
|
3172
|
+
/** 0-based ordinal among all matches, in document order. This is the index
|
|
3173
|
+
* `findNext`/`findPrev` make active, so a caller can correlate the array it
|
|
3174
|
+
* got from `findText` with the active-match reported by navigation. */
|
|
3175
|
+
matchIndex: number;
|
|
3176
|
+
/** The text that matched (the query as it appears in the document — its
|
|
3177
|
+
* original case, not the folded form used for case-insensitive matching). */
|
|
3178
|
+
text: string;
|
|
3179
|
+
/** Where the match is, in the format's own coordinates. */
|
|
3180
|
+
location: Loc;
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
/** Options for {@link findMatches}. */
|
|
3184
|
+
declare interface FindMatchesOptions {
|
|
3185
|
+
/**
|
|
3186
|
+
* Match case exactly. Default `false` (case-insensitive, like a browser's
|
|
3187
|
+
* find-in-page). IX2 default — an integrator can pass `true`.
|
|
3188
|
+
*/
|
|
3189
|
+
caseSensitive?: boolean;
|
|
3190
|
+
}
|
|
3191
|
+
|
|
1950
3192
|
/**
|
|
1951
3193
|
* ECMA-376 §17.3.1.11 `<w:framePr>` — text-frame / drop-cap properties.
|
|
1952
3194
|
*
|
|
@@ -2050,9 +3292,60 @@ declare type HiddenSlideMode = 'show' | 'skip' | 'dim';
|
|
|
2050
3292
|
declare interface Hyperlink {
|
|
2051
3293
|
col: number;
|
|
2052
3294
|
row: number;
|
|
3295
|
+
/** External target (ECMA-376 §18.3.1.47 `r:id`, resolved via worksheet rels).
|
|
3296
|
+
* `null` for a purely internal hyperlink. */
|
|
2053
3297
|
url: string | null;
|
|
3298
|
+
/** Internal target (§18.3.1.47 `location`): a defined name or a cell reference
|
|
3299
|
+
* such as `Sheet1!A1`. Present when the hyperlink navigates within the
|
|
3300
|
+
* workbook rather than to an external URL. */
|
|
3301
|
+
location?: string | null;
|
|
3302
|
+
/** Optional display text (§18.3.1.47 `display`). Not used for rendering. */
|
|
3303
|
+
display?: string | null;
|
|
2054
3304
|
}
|
|
2055
3305
|
|
|
3306
|
+
/**
|
|
3307
|
+
* Shared hyperlink model + URL sanitisation for docx / pptx / xlsx (IX1).
|
|
3308
|
+
*
|
|
3309
|
+
* All three formats carry the same two ECMA-376 concepts:
|
|
3310
|
+
* - an **external** hyperlink — an absolute URL resolved from a relationship
|
|
3311
|
+
* part target (`document.xml.rels` for docx §17.16.22, the slide rels for
|
|
3312
|
+
* pptx §21.1.2.3.5, the worksheet rels for xlsx §18.3.1.47), with
|
|
3313
|
+
* `TargetMode="External"`.
|
|
3314
|
+
* - an **internal** hyperlink — a jump within the document itself:
|
|
3315
|
+
* docx `w:anchor` -> a `<w:bookmarkStart w:name>` (§17.16.23), pptx
|
|
3316
|
+
* `action="ppaction://hlinksldjump"` -> a slide, xlsx `location` -> a defined
|
|
3317
|
+
* name or a `Sheet!A1` cell reference.
|
|
3318
|
+
*
|
|
3319
|
+
* The parsers (Rust, one per format) do the format-specific rels lookup and hand
|
|
3320
|
+
* each run / shape / cell a {@link HyperlinkTarget}. Everything downstream — the
|
|
3321
|
+
* text-layer overlay, the viewer default click behaviour, and any integrator
|
|
3322
|
+
* callback — is format-agnostic and consumes this one shape. Keeping the type +
|
|
3323
|
+
* the pure `sanitizeHyperlinkUrl` predicate here (not duplicated per package)
|
|
3324
|
+
* follows the cross-package unification principle: a scheme-allowlist bug fixed
|
|
3325
|
+
* once is fixed everywhere.
|
|
3326
|
+
*/
|
|
3327
|
+
/**
|
|
3328
|
+
* A resolved hyperlink attached to a run, shape, or cell.
|
|
3329
|
+
*
|
|
3330
|
+
* - `external` — `url` is the raw target as authored in the file. It is NOT
|
|
3331
|
+
* guaranteed safe; run it through {@link sanitizeHyperlinkUrl} before
|
|
3332
|
+
* navigating. It is kept verbatim here so an integrator can apply its own
|
|
3333
|
+
* policy (e.g. allow `file:` on a trusted intranet viewer).
|
|
3334
|
+
* - `internal` — `ref` is the in-document destination, verbatim from the file:
|
|
3335
|
+
* docx: the bookmark name (`w:anchor`).
|
|
3336
|
+
* pptx: the internal action (e.g. `ppaction://hlinksldjump`), with the
|
|
3337
|
+
* resolved 0-based `slideIndex` when the rels target names a slide.
|
|
3338
|
+
* xlsx: the `location` string (a defined name or `Sheet1!A1`).
|
|
3339
|
+
*/
|
|
3340
|
+
declare type HyperlinkTarget = {
|
|
3341
|
+
kind: 'external';
|
|
3342
|
+
url: string;
|
|
3343
|
+
} | {
|
|
3344
|
+
kind: 'internal';
|
|
3345
|
+
ref: string;
|
|
3346
|
+
slideIndex?: number;
|
|
3347
|
+
};
|
|
3348
|
+
|
|
2056
3349
|
/**
|
|
2057
3350
|
* Image anchored to a rectangle of cells (EMU offsets within the anchor cells).
|
|
2058
3351
|
* 914400 EMU = 1 inch, 9525 EMU = 1 px @ 96 DPI.
|
|
@@ -2101,6 +3394,15 @@ declare interface ImageAnchor {
|
|
|
2101
3394
|
r: number;
|
|
2102
3395
|
b: number;
|
|
2103
3396
|
};
|
|
3397
|
+
/** ECMA-376 §20.1.8.6 `<a:alphaModFix@amt>` — the blip's overall opacity as a
|
|
3398
|
+
* fraction (0..1). Absent ⇒ opaque. The renderer sets `ctx.globalAlpha` so the
|
|
3399
|
+
* picture composites over the cells beneath it (e.g. a pink translucent photo
|
|
3400
|
+
* over a matching cell fill). */
|
|
3401
|
+
alpha?: number;
|
|
3402
|
+
/** ECMA-376 §20.1.8.23 `<a:duotone>` recolour effect. Absent (the common case)
|
|
3403
|
+
* ⇒ no effect. When present, the renderer remaps the image along the
|
|
3404
|
+
* `clr1`→`clr2` luminance ramp before drawing. */
|
|
3405
|
+
duotone?: Duotone_2;
|
|
2104
3406
|
}
|
|
2105
3407
|
|
|
2106
3408
|
/**
|
|
@@ -2132,6 +3434,14 @@ declare interface ImageFill {
|
|
|
2132
3434
|
tile?: TileInfo;
|
|
2133
3435
|
/** `a:blip > a:alphaModFix@amt` as a fraction (0.0–1.0). Absent = opaque. */
|
|
2134
3436
|
alpha?: number;
|
|
3437
|
+
/**
|
|
3438
|
+
* ECMA-376 §20.1.8.23 `<a:duotone>` recolour, resolved to its two endpoint
|
|
3439
|
+
* colours (through the slide theme). Absent ⇒ no duotone. When present the
|
|
3440
|
+
* renderer maps the blip's luminance ramp between the two colours (core
|
|
3441
|
+
* `applyDuotone`) — the same recolour a `<p:pic>` duotone applies, wired onto
|
|
3442
|
+
* the picture-FILL path (§20.1.8.14) by issue #889.
|
|
3443
|
+
*/
|
|
3444
|
+
duotone?: Duotone;
|
|
2135
3445
|
}
|
|
2136
3446
|
|
|
2137
3447
|
declare interface ImageRun {
|
|
@@ -2191,6 +3501,19 @@ declare interface ImageRun {
|
|
|
2191
3501
|
* transparency. Implements a:clrChange (make-background-transparent).
|
|
2192
3502
|
*/
|
|
2193
3503
|
colorReplaceFrom?: string;
|
|
3504
|
+
/**
|
|
3505
|
+
* ECMA-376 §20.1.8.23 `<a:duotone>` recolour, resolved to its two endpoint
|
|
3506
|
+
* colours (through the document theme). Absent ⇒ no duotone. When present the
|
|
3507
|
+
* renderer decodes the raster once, remaps it along the `clr1`→`clr2`
|
|
3508
|
+
* luminance ramp, and caches the recoloured bitmap under a colour-suffixed key.
|
|
3509
|
+
*/
|
|
3510
|
+
duotone?: Duotone;
|
|
3511
|
+
/**
|
|
3512
|
+
* ECMA-376 §20.1.8.6 `<a:alphaModFix@amt>` opacity as 0..1. Absent ⇒ fully
|
|
3513
|
+
* opaque. When present the renderer multiplies the picture's `globalAlpha` by
|
|
3514
|
+
* this fraction.
|
|
3515
|
+
*/
|
|
3516
|
+
alpha?: number;
|
|
2194
3517
|
/**
|
|
2195
3518
|
* Wrap mode for anchor images:
|
|
2196
3519
|
* "square" | "topAndBottom" | "none" | "tight" | "through"
|
|
@@ -2280,6 +3603,24 @@ declare interface LineEnd {
|
|
|
2280
3603
|
len: string;
|
|
2281
3604
|
}
|
|
2282
3605
|
|
|
3606
|
+
/** ECMA-376 §17.6.8 `<w:lnNumType>` — line numbering for a section. Mirrors the
|
|
3607
|
+
* Rust `LineNumbering`. A number is drawn in the left margin of each body line
|
|
3608
|
+
* whose count is a multiple of `countBy`. Absent on {@link SectionProps}
|
|
3609
|
+
* (`lineNumbering` undefined) ⇒ line numbering off. */
|
|
3610
|
+
declare interface LineNumbering {
|
|
3611
|
+
/** `@w:countBy` — only lines whose number is a multiple of this display a
|
|
3612
|
+
* number. Required (absent ⇒ the whole struct is absent per §17.6.8). */
|
|
3613
|
+
countBy: number;
|
|
3614
|
+
/** `@w:start` — the starting number after each restart. Default 1. */
|
|
3615
|
+
start: number;
|
|
3616
|
+
/** `@w:distance` in pt (twips ÷ 20) — gap between the text margin and the
|
|
3617
|
+
* number glyphs. Absent ⇒ implementation-defined (renderer uses a default). */
|
|
3618
|
+
distance?: number;
|
|
3619
|
+
/** `@w:restart` (§17.18.47): "newPage" (default) | "newSection" |
|
|
3620
|
+
* "continuous" — when the counter resets to `start`. */
|
|
3621
|
+
restart: string;
|
|
3622
|
+
}
|
|
3623
|
+
|
|
2283
3624
|
declare interface LineSpacing {
|
|
2284
3625
|
value: number;
|
|
2285
3626
|
rule: 'auto' | 'exact' | 'atLeast';
|
|
@@ -2322,6 +3663,35 @@ declare interface LoadOptions_2 {
|
|
|
2322
3663
|
* via `@font-face` in your application CSS.
|
|
2323
3664
|
*/
|
|
2324
3665
|
useGoogleFonts?: boolean;
|
|
3666
|
+
/**
|
|
3667
|
+
* Password for an encrypted OOXML file ([MS-OFFCRYPTO] Agile Encryption).
|
|
3668
|
+
*
|
|
3669
|
+
* Password-protected Office documents are CFB (OLE2) containers, not ZIPs.
|
|
3670
|
+
* When this is set and the input is Agile-encrypted, `load()` decrypts it on
|
|
3671
|
+
* the main thread (via WebCrypto) and parses the recovered plaintext ZIP.
|
|
3672
|
+
*
|
|
3673
|
+
* Errors (thrown as {@link import('../errors/ooxml-error').OoxmlError}):
|
|
3674
|
+
* - no `password` on an encrypted file → code `'encrypted'`
|
|
3675
|
+
* - wrong `password` → code `'invalid-password'`
|
|
3676
|
+
* - a non-Agile scheme (Standard / Extensible / legacy) → code
|
|
3677
|
+
* `'unsupported-encryption'`
|
|
3678
|
+
*
|
|
3679
|
+
* Note: Agile Encryption uses a high password-hash spin count (commonly
|
|
3680
|
+
* 100,000), so decryption of a protected file adds roughly a second of
|
|
3681
|
+
* WebCrypto work before parsing begins.
|
|
3682
|
+
*
|
|
3683
|
+
* Security notes:
|
|
3684
|
+
* - This value is held as an ordinary JS `string` in memory for the
|
|
3685
|
+
* duration of key derivation. The library does not zero it, and does
|
|
3686
|
+
* not wrap it in a `SecureString`-equivalent — it becomes eligible for
|
|
3687
|
+
* garbage collection like any other string once nothing references it,
|
|
3688
|
+
* but no explicit wipe is performed. It is never logged or included in
|
|
3689
|
+
* thrown errors.
|
|
3690
|
+
* - Decryption recovers the plaintext but does not verify the file's HMAC
|
|
3691
|
+
* data-integrity tag ([MS-OFFCRYPTO] §2.3.4.14), so ciphertext tampering
|
|
3692
|
+
* is not detected — see "Security & Privacy" in the README.
|
|
3693
|
+
*/
|
|
3694
|
+
password?: string;
|
|
2325
3695
|
/**
|
|
2326
3696
|
* Override the URL the parser worker fetches the WebAssembly module from.
|
|
2327
3697
|
*
|
|
@@ -2403,6 +3773,23 @@ declare interface LoadOptions_4 extends LoadOptions_2 {
|
|
|
2403
3773
|
/** @deprecated Use `ChartManualLayout` from @silurus/ooxml-core. */
|
|
2404
3774
|
declare type ManualLayout = ChartManualLayout;
|
|
2405
3775
|
|
|
3776
|
+
/**
|
|
3777
|
+
* The slice of one run a match covers: the run's index in the original `runs[]`
|
|
3778
|
+
* and the `[start, end)` character range within that run's own `text`. A match
|
|
3779
|
+
* that straddles N runs yields N of these (the first sliced from its start
|
|
3780
|
+
* offset to the run end, the last from 0 to its end offset, any middle run
|
|
3781
|
+
* whole). The viewer measures each slice against that run's font to get a pixel
|
|
3782
|
+
* rectangle.
|
|
3783
|
+
*/
|
|
3784
|
+
declare interface MatchRunSlice {
|
|
3785
|
+
/** Index into the original `runs[]` handed to {@link buildTextIndex}. */
|
|
3786
|
+
runIndex: number;
|
|
3787
|
+
/** Start offset within `runs[runIndex].text` (inclusive). */
|
|
3788
|
+
start: number;
|
|
3789
|
+
/** End offset within `runs[runIndex].text` (exclusive). */
|
|
3790
|
+
end: number;
|
|
3791
|
+
}
|
|
3792
|
+
|
|
2406
3793
|
/** Accent (`m:acc`), e.g. hat, bar, vector arrow over the base. */
|
|
2407
3794
|
declare interface MathAccent {
|
|
2408
3795
|
kind: 'accent';
|
|
@@ -2425,6 +3812,31 @@ declare interface MathBar {
|
|
|
2425
3812
|
base: MathNode[];
|
|
2426
3813
|
}
|
|
2427
3814
|
|
|
3815
|
+
/** Border-box object (`m:borderBox`, §22.1.2.11): a border/strikes around the
|
|
3816
|
+
* base. Absent flags ⇒ a full rectangular box. */
|
|
3817
|
+
declare interface MathBorderBox {
|
|
3818
|
+
kind: 'borderBox';
|
|
3819
|
+
/** §22.1.2 hide* — when true the corresponding edge is NOT drawn. */
|
|
3820
|
+
hideTop?: boolean;
|
|
3821
|
+
hideBot?: boolean;
|
|
3822
|
+
hideLeft?: boolean;
|
|
3823
|
+
hideRight?: boolean;
|
|
3824
|
+
/** §22.1.2 strike* — strikeBLTR = bottom-left→top-right, strikeTLBR =
|
|
3825
|
+
* top-left→bottom-right diagonal. */
|
|
3826
|
+
strikeH?: boolean;
|
|
3827
|
+
strikeV?: boolean;
|
|
3828
|
+
strikeBltr?: boolean;
|
|
3829
|
+
strikeTlbr?: boolean;
|
|
3830
|
+
base: MathNode[];
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
/** Box object (`m:box`, §22.1.2.13): a logical grouping (operator emulator /
|
|
3834
|
+
* line-break control). Draws NO border — a transparent group around `base`. */
|
|
3835
|
+
declare interface MathBox {
|
|
3836
|
+
kind: 'box';
|
|
3837
|
+
base: MathNode[];
|
|
3838
|
+
}
|
|
3839
|
+
|
|
2428
3840
|
declare interface MathDelimiter {
|
|
2429
3841
|
kind: 'delimiter';
|
|
2430
3842
|
/** opening char (default '('). */
|
|
@@ -2482,7 +3894,23 @@ declare interface MathNary {
|
|
|
2482
3894
|
body: MathNode[];
|
|
2483
3895
|
}
|
|
2484
3896
|
|
|
2485
|
-
declare type MathNode = MathRun | MathFraction | MathScript | MathNary | MathDelimiter | MathRadical | MathLimit | MathArray | MathGroupChr | MathBar | MathAccent | MathFunc | MathGroup;
|
|
3897
|
+
declare type MathNode = MathRun | MathFraction | MathScript | MathNary | MathDelimiter | MathRadical | MathLimit | MathArray | MathGroupChr | MathBar | MathAccent | MathFunc | MathGroup | MathPhant | MathSPre | MathBox | MathBorderBox;
|
|
3898
|
+
|
|
3899
|
+
/** Phantom object (`m:phant`, §22.1.2.81): contributes the spacing of `base`
|
|
3900
|
+
* while optionally hiding it and/or zeroing individual dimensions. */
|
|
3901
|
+
declare interface MathPhant {
|
|
3902
|
+
kind: 'phant';
|
|
3903
|
+
/** §22.1.2.96 `m:show` — `false` hides the base (invisible but occupies space,
|
|
3904
|
+
* i.e. `<mphantom>`); `true` (default) shows it and the phant only tweaks
|
|
3905
|
+
* spacing. */
|
|
3906
|
+
show: boolean;
|
|
3907
|
+
/** §22.1.2 zeroWid / zeroAsc / zeroDesc — suppress width / ascent / descent so
|
|
3908
|
+
* the base takes no space along that axis. Omitted ⇒ false. */
|
|
3909
|
+
zeroWid?: boolean;
|
|
3910
|
+
zeroAsc?: boolean;
|
|
3911
|
+
zeroDesc?: boolean;
|
|
3912
|
+
base: MathNode[];
|
|
3913
|
+
}
|
|
2486
3914
|
|
|
2487
3915
|
declare interface MathRadical {
|
|
2488
3916
|
kind: 'radical';
|
|
@@ -2525,6 +3953,15 @@ declare interface MathScript {
|
|
|
2525
3953
|
sub?: MathNode[];
|
|
2526
3954
|
}
|
|
2527
3955
|
|
|
3956
|
+
/** Pre-sub-superscript object (`m:sPre`, §22.1.2.99): sub + sup to the LEFT of
|
|
3957
|
+
* the base (e.g. ²₁A). */
|
|
3958
|
+
declare interface MathSPre {
|
|
3959
|
+
kind: 'sPre';
|
|
3960
|
+
sub: MathNode[];
|
|
3961
|
+
sup: MathNode[];
|
|
3962
|
+
base: MathNode[];
|
|
3963
|
+
}
|
|
3964
|
+
|
|
2528
3965
|
declare type MathStyle = 'roman' | 'italic' | 'bold' | 'boldItalic';
|
|
2529
3966
|
|
|
2530
3967
|
declare interface MathSvg {
|
|
@@ -2606,6 +4043,19 @@ declare interface NumberingInfo {
|
|
|
2606
4043
|
* this family. Absent ⇒ the renderer falls back to
|
|
2607
4044
|
* {@link NumberingInfo.fontFamily}. */
|
|
2608
4045
|
fontFamilyEastAsia?: string | null;
|
|
4046
|
+
/** ECMA-376 §17.9.24 — the numbering level rPr's `w:color` (hex 6 without
|
|
4047
|
+
* `#`, lowercased). Colors the marker glyph only, never the paragraph's
|
|
4048
|
+
* runs. Absent ⇒ the renderer falls back to
|
|
4049
|
+
* {@link DocParagraph.paragraphMarkColor} (§17.3.1.29 — Word layers the
|
|
4050
|
+
* level rPr over the paragraph mark's run properties) and finally to its
|
|
4051
|
+
* default ink. An explicit `w:val="auto"` is absent here + {@link colorAuto}. */
|
|
4052
|
+
color?: string | null;
|
|
4053
|
+
/** ECMA-376 §17.3.2.6 / ST_HexColorAuto (§17.18.39) — true when the level
|
|
4054
|
+
* rPr carries an EXPLICIT `w:color w:val="auto"`. Auto names no concrete
|
|
4055
|
+
* color but is not "unset": it breaks the paragraph-mark fallback, so the
|
|
4056
|
+
* marker draws the automatic (default) ink instead of
|
|
4057
|
+
* {@link DocParagraph.paragraphMarkColor}. */
|
|
4058
|
+
colorAuto?: boolean;
|
|
2609
4059
|
/** ECMA-376 §17.9.9/§17.9.20 — when the level uses a `<w:lvlPicBulletId>`,
|
|
2610
4060
|
* the marker is this image (zip path, e.g. `word/media/image1.gif`), drawn in
|
|
2611
4061
|
* place of {@link NumberingInfo.text}. Absent ⇒ ordinary text/glyph marker. */
|
|
@@ -2623,6 +4073,124 @@ declare interface NumFmt {
|
|
|
2623
4073
|
formatCode: string;
|
|
2624
4074
|
}
|
|
2625
4075
|
|
|
4076
|
+
/**
|
|
4077
|
+
* Typed error thrown by the docx / pptx / xlsx `load()` factories for failures
|
|
4078
|
+
* that carry a stable, programmatic {@link OoxmlErrorCode} (e.g. a
|
|
4079
|
+
* password-protected or legacy-binary file detected from its container magic).
|
|
4080
|
+
*
|
|
4081
|
+
* Note on workers: `instanceof OoxmlError` does not survive a structured-clone
|
|
4082
|
+
* across the worker boundary. Detection that needs a typed error is therefore
|
|
4083
|
+
* done on the main thread (before the worker is involved) so a genuine
|
|
4084
|
+
* `OoxmlError` instance is thrown to the caller. Errors that must cross the
|
|
4085
|
+
* worker boundary should carry the `code` string and be reconstructed on the
|
|
4086
|
+
* main side.
|
|
4087
|
+
*/
|
|
4088
|
+
declare class OoxmlError extends Error {
|
|
4089
|
+
readonly code: OoxmlErrorCode;
|
|
4090
|
+
constructor(code: OoxmlErrorCode, message: string);
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4093
|
+
/**
|
|
4094
|
+
* Machine-readable code for a typed load-time failure.
|
|
4095
|
+
*
|
|
4096
|
+
* The container-level failures the `load()` factories detect on the main thread
|
|
4097
|
+
* before handing bytes to the parser worker (see `sniffCfb` / `decryptOoxml`).
|
|
4098
|
+
* This is the seed of the broader typed-error surface tracked as PD4 (OoxmlError
|
|
4099
|
+
* typed errors). Add codes here rather than throwing bare `Error(string)`, so
|
|
4100
|
+
* callers can `switch` on `err.code` instead of matching message text.
|
|
4101
|
+
*
|
|
4102
|
+
* - `'encrypted'` — password-protected, but no `password` was
|
|
4103
|
+
* supplied (pass `LoadOptions.password` to decrypt).
|
|
4104
|
+
* - `'invalid-password'` — a `password` was supplied but did not match.
|
|
4105
|
+
* - `'unsupported-encryption'`— encrypted with a scheme other than Agile
|
|
4106
|
+
* (Standard / Extensible / a legacy binary encryptor), which this library
|
|
4107
|
+
* cannot decrypt (PD8 implements Agile only).
|
|
4108
|
+
* - `'legacy-binary-format'` — a raw .doc / .xls / .ppt (not OOXML).
|
|
4109
|
+
* - `'not-ooxml'` — a CFB of an unrecognised kind, or otherwise
|
|
4110
|
+
* not an OOXML ZIP.
|
|
4111
|
+
*/
|
|
4112
|
+
declare type OoxmlErrorCode = 'encrypted' | 'invalid-password' | 'unsupported-encryption' | 'legacy-binary-format' | 'not-ooxml';
|
|
4113
|
+
|
|
4114
|
+
/**
|
|
4115
|
+
* The default action a viewer takes for an **external** hyperlink click when
|
|
4116
|
+
* the integrator supplies no `onHyperlinkClick` handler: sanitise the URL and,
|
|
4117
|
+
* if allowed, open it in a new tab with `noopener,noreferrer` so the opened page
|
|
4118
|
+
* gets no `window.opener` handle back into this document. A blocked scheme is a
|
|
4119
|
+
* silent no-op (returns `false`) — the click does nothing rather than navigate
|
|
4120
|
+
* somewhere dangerous.
|
|
4121
|
+
*
|
|
4122
|
+
* Internal targets are intentionally NOT handled here: the in-document jump
|
|
4123
|
+
* (page / slide / cell) is format-specific and lives in each viewer.
|
|
4124
|
+
*
|
|
4125
|
+
* Split out (not inlined in three viewers) so the "open in new tab, drop opener,
|
|
4126
|
+
* refuse unsafe schemes" policy is defined once. `win` is injected for tests;
|
|
4127
|
+
* defaults to the ambient `window`.
|
|
4128
|
+
*
|
|
4129
|
+
* @returns `true` if navigation was initiated, `false` if the URL was blocked.
|
|
4130
|
+
*/
|
|
4131
|
+
declare function openExternalHyperlink(url: string, allowed?: readonly string[], win?: Pick<Window, 'open'> | undefined): boolean;
|
|
4132
|
+
|
|
4133
|
+
/** `<sheetPr><outlinePr>` flags (ECMA-376 §18.3.1.61). Both default to `true`. */
|
|
4134
|
+
declare interface OutlinePr {
|
|
4135
|
+
/** `true` (default) ⇒ a group's summary row sits *below* its detail rows;
|
|
4136
|
+
* `false` ⇒ above. */
|
|
4137
|
+
summaryBelow: boolean;
|
|
4138
|
+
/** `true` (default) ⇒ a group's summary column sits to the *right* of its
|
|
4139
|
+
* detail columns; `false` ⇒ to the left. */
|
|
4140
|
+
summaryRight: boolean;
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
/** ECMA-376 §17.18.4 CT_Border for one edge of `<w:pgBorders>`. Mirrors the Rust
|
|
4144
|
+
* `PageBorderEdge`. Same shape as a paragraph border edge. */
|
|
4145
|
+
declare interface PageBorderEdge {
|
|
4146
|
+
/** `@w:val` — ST_Border line style ("single" | "double" | "dashed" | …). */
|
|
4147
|
+
style: string;
|
|
4148
|
+
/** `@w:color` hex 6, or absent for "auto" (renderer defaults to black). */
|
|
4149
|
+
color?: string;
|
|
4150
|
+
/** `@w:sz` in pt (eighths of a point ÷ 8). */
|
|
4151
|
+
width: number;
|
|
4152
|
+
/** `@w:space` in pt — a POINT measure (§17.18.68, 0–31) for page borders, NOT
|
|
4153
|
+
* twips — the inset from the `offsetFrom` reference. */
|
|
4154
|
+
space: number;
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4157
|
+
/** ECMA-376 §17.6.10 `<w:pgBorders>` — page borders drawn around each page of a
|
|
4158
|
+
* section. Mirrors the Rust `PageBorders`. Each edge is a CT_Border (§17.18.4);
|
|
4159
|
+
* the container carries the placement globals. Absent on {@link SectionProps}
|
|
4160
|
+
* (`pageBorders` undefined) ⇒ no page border (the common case). Art borders
|
|
4161
|
+
* (§17.18.2 decorative-image styles) are unsupported — the renderer draws only
|
|
4162
|
+
* the standard line styles (single/double/dashed/dotted/thick/…). */
|
|
4163
|
+
declare interface PageBorders {
|
|
4164
|
+
/** `@w:offsetFrom` (§17.18.63): "page" ⇒ each edge's `space` is from the PAGE
|
|
4165
|
+
* edge; "text" (the default) ⇒ from the text margin. */
|
|
4166
|
+
offsetFrom: string;
|
|
4167
|
+
/** `@w:display` (§17.18.62): "allPages" (default) | "firstPage" |
|
|
4168
|
+
* "notFirstPage" — which physical pages of the section show the border. */
|
|
4169
|
+
display: string;
|
|
4170
|
+
/** `@w:zOrder` (§17.18.64): "front" (default; over text) | "back" (under). */
|
|
4171
|
+
zOrder: string;
|
|
4172
|
+
top?: PageBorderEdge;
|
|
4173
|
+
bottom?: PageBorderEdge;
|
|
4174
|
+
left?: PageBorderEdge;
|
|
4175
|
+
right?: PageBorderEdge;
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
/** ECMA-376 §17.6.12 `<w:pgNumType>` — a section's page-numbering settings.
|
|
4179
|
+
* Mirrors the Rust `PageNumType`. Only the two attributes that change the
|
|
4180
|
+
* DISPLAYED page number are carried:
|
|
4181
|
+
* - `start` — the number shown on the FIRST page of the section (§17.6.12);
|
|
4182
|
+
* absent ⇒ numbering continues from the previous section's highest number.
|
|
4183
|
+
* Kept as a possibly-zero / possibly-negative integer (Word writes `start="0"`).
|
|
4184
|
+
* - `fmt` — the ST_NumberFormat (§17.18.59) for the section's page numbers
|
|
4185
|
+
* (decimal / upperRoman / lowerLetter / …); absent ⇒ decimal.
|
|
4186
|
+
* `chapStyle`/`chapSep` (chapter-prefixed numbering) are out of scope for this
|
|
4187
|
+
* pass and never surfaced. Field names match the Rust `PageNumType` serialization
|
|
4188
|
+
* (`start`, `fmt`). */
|
|
4189
|
+
declare interface PageNumType {
|
|
4190
|
+
start?: number;
|
|
4191
|
+
fmt?: string;
|
|
4192
|
+
}
|
|
4193
|
+
|
|
2626
4194
|
declare interface ParaBorderEdge {
|
|
2627
4195
|
style: string;
|
|
2628
4196
|
color: string | null;
|
|
@@ -2685,6 +4253,14 @@ declare interface Paragraph_2 extends Paragraph {
|
|
|
2685
4253
|
* emits an effective boolean.
|
|
2686
4254
|
*/
|
|
2687
4255
|
eaLnBrk: boolean;
|
|
4256
|
+
/**
|
|
4257
|
+
* `<a:pPr defTabSz>` (ECMA-376 §21.1.2.2.7) — the default tab-stop interval in
|
|
4258
|
+
* EMU. When a `\t` has no reachable explicit `a:tabLst` stop, it advances to
|
|
4259
|
+
* the next multiple of this grid (issue #1006). Absent ⇒ the renderer uses the
|
|
4260
|
+
* PowerPoint universal default of 914400 EMU (1 inch). Omitted from JSON when
|
|
4261
|
+
* the parser found no explicit value.
|
|
4262
|
+
*/
|
|
4263
|
+
defTabSz?: number;
|
|
2688
4264
|
}
|
|
2689
4265
|
|
|
2690
4266
|
declare interface ParagraphBorders {
|
|
@@ -2808,6 +4384,38 @@ declare interface PatternFill {
|
|
|
2808
4384
|
preset: string;
|
|
2809
4385
|
}
|
|
2810
4386
|
|
|
4387
|
+
/** ECMA-376 §18.18.56 ST_PhoneticAlignment — how the furigana is aligned over
|
|
4388
|
+
* the base text. Absent on {@link PhoneticProperties} defaults to `'left'`. */
|
|
4389
|
+
declare type PhoneticAlignment = 'left' | 'center' | 'distributed' | 'noControl';
|
|
4390
|
+
|
|
4391
|
+
/** ECMA-376 §18.4.3 `<phoneticPr>` — phonetic display properties. */
|
|
4392
|
+
declare interface PhoneticProperties {
|
|
4393
|
+
/** Zero-based index into `Styles.fonts` (§18.18.32 ST_FontId). Out of bounds
|
|
4394
|
+
* falls back to font 0 (§18.4.3). Drives the furigana font size / family. */
|
|
4395
|
+
fontId: number;
|
|
4396
|
+
/** §18.18.57 — absent means `'fullwidthKatakana'` (schema default). */
|
|
4397
|
+
type?: PhoneticType;
|
|
4398
|
+
/** §18.18.56 — absent means `'left'` (schema default). */
|
|
4399
|
+
alignment?: PhoneticAlignment;
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4402
|
+
/** ECMA-376 §18.4.6 `<rPh sb=".." eb="..">` — one furigana run. `sb`/`eb` are
|
|
4403
|
+
* zero-based character offsets into the base text; the hint `text` is shown
|
|
4404
|
+
* over base characters `[sb, eb)`. */
|
|
4405
|
+
declare interface PhoneticRun {
|
|
4406
|
+
/** Zero-based start character offset into the base text (inclusive). */
|
|
4407
|
+
sb: number;
|
|
4408
|
+
/** Zero-based end character offset into the base text (exclusive). */
|
|
4409
|
+
eb: number;
|
|
4410
|
+
/** The phonetic hint text (e.g. the katakana reading). */
|
|
4411
|
+
text: string;
|
|
4412
|
+
}
|
|
4413
|
+
|
|
4414
|
+
/** ECMA-376 §18.18.57 ST_PhoneticType — the East-Asian character set the
|
|
4415
|
+
* furigana is displayed in. Absent on {@link PhoneticProperties} defaults to
|
|
4416
|
+
* `'fullwidthKatakana'` per the CT_PhoneticPr schema. */
|
|
4417
|
+
declare type PhoneticType = 'fullwidthKatakana' | 'halfwidthKatakana' | 'Hiragana' | 'noConversion';
|
|
4418
|
+
|
|
2811
4419
|
declare interface PictureElement {
|
|
2812
4420
|
type: 'picture';
|
|
2813
4421
|
x: number;
|
|
@@ -2883,6 +4491,13 @@ declare interface PictureElement {
|
|
|
2883
4491
|
};
|
|
2884
4492
|
/** a:blip > a:alphaModFix@amt as 0..1. Undefined = fully opaque. */
|
|
2885
4493
|
alpha?: number;
|
|
4494
|
+
/**
|
|
4495
|
+
* ECMA-376 §20.1.8.23 `<a:duotone>` recolour, resolved to its two endpoint
|
|
4496
|
+
* colours (through the slide theme). Undefined ⇒ no duotone. When present the
|
|
4497
|
+
* renderer decodes the raster once, remaps it along the `clr1`→`clr2`
|
|
4498
|
+
* luminance ramp, and caches the recoloured bitmap under a colour-suffixed key.
|
|
4499
|
+
*/
|
|
4500
|
+
duotone?: Duotone;
|
|
2886
4501
|
/**
|
|
2887
4502
|
* `<p:spPr><a:custGeom>` clipping path. Same `PathCmd` model as
|
|
2888
4503
|
* `ShapeElement.custGeom` (one entry per `<a:path>`; coords normalized
|
|
@@ -2930,9 +4545,19 @@ export declare namespace pptx {
|
|
|
2930
4545
|
PptxTextRunInfo,
|
|
2931
4546
|
TextRunCallback,
|
|
2932
4547
|
buildPptxTextLayer,
|
|
4548
|
+
buildPptxHighlightLayer,
|
|
4549
|
+
PptxHighlightMatch,
|
|
4550
|
+
PptxHighlightColors,
|
|
4551
|
+
PptxMatchLocation,
|
|
4552
|
+
FindMatch,
|
|
4553
|
+
FindMatchesOptions,
|
|
2933
4554
|
PresentationHandle,
|
|
2934
4555
|
autoResize,
|
|
2935
4556
|
AutoResizeOptions,
|
|
4557
|
+
HyperlinkTarget,
|
|
4558
|
+
openExternalHyperlink,
|
|
4559
|
+
OoxmlError,
|
|
4560
|
+
OoxmlErrorCode,
|
|
2936
4561
|
Presentation,
|
|
2937
4562
|
Slide,
|
|
2938
4563
|
PptxComment,
|
|
@@ -2991,6 +4616,21 @@ declare interface PptxComment {
|
|
|
2991
4616
|
text: string;
|
|
2992
4617
|
}
|
|
2993
4618
|
|
|
4619
|
+
declare interface PptxHighlightColors {
|
|
4620
|
+
match?: string;
|
|
4621
|
+
active?: string;
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4624
|
+
declare interface PptxHighlightMatch {
|
|
4625
|
+
slices: MatchRunSlice[];
|
|
4626
|
+
active: boolean;
|
|
4627
|
+
}
|
|
4628
|
+
|
|
4629
|
+
/** Where a pptx match lives: its 0-based slide index. */
|
|
4630
|
+
declare interface PptxMatchLocation {
|
|
4631
|
+
slide: number;
|
|
4632
|
+
}
|
|
4633
|
+
|
|
2994
4634
|
/**
|
|
2995
4635
|
* Headless PPTX rendering engine.
|
|
2996
4636
|
*
|
|
@@ -3012,15 +4652,24 @@ declare class PptxPresentation {
|
|
|
3012
4652
|
private _mode;
|
|
3013
4653
|
private _presentation;
|
|
3014
4654
|
private _meta;
|
|
4655
|
+
/** Lazily-built `partName → slide index` map for internal hyperlink slide
|
|
4656
|
+
* jumps (IX-nav). Cleared on {@link destroy}; built on first
|
|
4657
|
+
* {@link getSlideIndexByPartName}/{@link resolveInternalTarget} from either
|
|
4658
|
+
* the parsed slides (main) or the worker meta's `partNames` (worker). */
|
|
4659
|
+
private _slidePartIndex;
|
|
3015
4660
|
private _mediaCache;
|
|
3016
4661
|
private _imageCache;
|
|
4662
|
+
/** Google-Fonts `FontFace` objects this deck preloaded into `document.fonts`
|
|
4663
|
+
* (main mode only — in worker mode the worker owns them and terminates with
|
|
4664
|
+
* its own FontFaceSet). Released in {@link destroy} so they do not leak into
|
|
4665
|
+
* the shared FontFaceSet for the lifetime of the SPA (deduped + refcounted in
|
|
4666
|
+
* core, so a web font shared with another open deck survives until both go). */
|
|
4667
|
+
private _googleFontFaces;
|
|
3017
4668
|
/** One stable closure per instance: the decoded-bitmap and SVG caches key on
|
|
3018
4669
|
* this identity to scope decodes per deck (so two open decks never swap
|
|
3019
4670
|
* images for a shared zip path like ppt/media/image1.png). Reusing the same
|
|
3020
4671
|
* reference across every render also lets those caches hit across slides. */
|
|
3021
4672
|
private readonly _fetchImage;
|
|
3022
|
-
private _workerReady;
|
|
3023
|
-
private _workerReadyCallbacks;
|
|
3024
4673
|
/** Opt-in OMML equation engine, injected once at {@link load}. Every
|
|
3025
4674
|
* `renderSlide` / `presentSlide` reuses it — equations render when present,
|
|
3026
4675
|
* and are skipped (engine tree-shaken) when omitted. */
|
|
@@ -3028,7 +4677,6 @@ declare class PptxPresentation {
|
|
|
3028
4677
|
private constructor();
|
|
3029
4678
|
/** Parse a PPTX from URL or ArrayBuffer. */
|
|
3030
4679
|
static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<PptxPresentation>;
|
|
3031
|
-
private _waitForWorker;
|
|
3032
4680
|
private _parse;
|
|
3033
4681
|
/** Total number of slides in the loaded presentation. */
|
|
3034
4682
|
get slideCount(): number;
|
|
@@ -3069,6 +4717,44 @@ declare class PptxPresentation {
|
|
|
3069
4717
|
* caller's policy (see {@link PptxViewer}'s `hiddenSlideMode` modes).
|
|
3070
4718
|
*/
|
|
3071
4719
|
isHidden(slideIndex: number): boolean;
|
|
4720
|
+
/** The per-slide `partName` array (`sldIdLst` order) from either the parsed
|
|
4721
|
+
* model (main) or the worker meta (worker). Backs the lazy part-index map. */
|
|
4722
|
+
private _partNames;
|
|
4723
|
+
/** Lazily build (and cache) the `partName → index` map. Nulled by
|
|
4724
|
+
* {@link destroy} so a reused reference never serves a stale deck's indices. */
|
|
4725
|
+
private _partIndex;
|
|
4726
|
+
/**
|
|
4727
|
+
* Resolve a slide's OPC part name (e.g. `ppt/slides/slide3.xml`) to its
|
|
4728
|
+
* 0-based index in `sldIdLst` order, or `undefined` when no slide has that
|
|
4729
|
+
* part name. This is the map an internal hyperlink slide jump
|
|
4730
|
+
* (`<a:hlinkClick action="ppaction://hlinksldjump" r:id>`, ECMA-376
|
|
4731
|
+
* §21.1.2.3.5) resolves against: the click's rel Target names a slide part, and
|
|
4732
|
+
* this turns it into the index a viewer can navigate to. Works in both `main`
|
|
4733
|
+
* and `worker` mode (the part names ride along in the worker meta).
|
|
4734
|
+
*/
|
|
4735
|
+
getSlideIndexByPartName(partName: string): number | undefined;
|
|
4736
|
+
/**
|
|
4737
|
+
* Resolve an internal hyperlink target string to a 0-based slide index, or
|
|
4738
|
+
* `undefined` when it names no reachable slide. Handles both
|
|
4739
|
+
* `<a:hlinkClick @action>` classes (§21.1.2.3.5):
|
|
4740
|
+
*
|
|
4741
|
+
* - a **relative** show jump — `ppaction://hlinkshowjump?jump=firstslide |
|
|
4742
|
+
* lastslide | nextslide | previousslide` — resolved arithmetically from
|
|
4743
|
+
* `currentIndex` (clamped at the deck ends);
|
|
4744
|
+
* - a **specific** slide-part jump — `ppaction://hlinksldjump`, whose
|
|
4745
|
+
* resolved target is a slide-rel part name like `../slides/slide3.xml` —
|
|
4746
|
+
* resolved through {@link getSlideIndexByPartName}.
|
|
4747
|
+
*
|
|
4748
|
+
* `ref` is the internal reference a `HyperlinkTarget` of kind `'internal'`
|
|
4749
|
+
* carries: the raw `ppaction://…` action string for a relative jump, or the
|
|
4750
|
+
* resolved slide-part target string for a specific jump. A viewer's
|
|
4751
|
+
* `onHyperlinkClick` default calls this with `ref` and the current slide, then
|
|
4752
|
+
* navigates to the returned index.
|
|
4753
|
+
*
|
|
4754
|
+
* @param ref the internal action/target string.
|
|
4755
|
+
* @param currentIndex the 0-based slide the jump is relative to (default 0).
|
|
4756
|
+
*/
|
|
4757
|
+
resolveInternalTarget(ref: string, currentIndex?: number): number | undefined;
|
|
3072
4758
|
/** Render a slide onto the given canvas. */
|
|
3073
4759
|
renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slideIndex: number, opts?: RenderSlideOptions): Promise<void>;
|
|
3074
4760
|
/**
|
|
@@ -3081,6 +4767,16 @@ declare class PptxPresentation {
|
|
|
3081
4767
|
* when done, or its backing memory is held until GC.
|
|
3082
4768
|
*/
|
|
3083
4769
|
renderSlideToBitmap(slideIndex: number, opts?: RenderSlideToBitmapOptions): Promise<ImageBitmap>;
|
|
4770
|
+
/**
|
|
4771
|
+
* IX6 — collect a slide's text-run geometry (`PptxTextRunInfo[]`) without
|
|
4772
|
+
* painting a visible canvas. Works in BOTH modes: worker mode renders the
|
|
4773
|
+
* slide off-thread and ships only the runs (no bitmap transfer); main mode
|
|
4774
|
+
* renders to a throwaway offscreen canvas. Used by the find controller to scan
|
|
4775
|
+
* every slide for matches. Run geometry is in CSS px (independent of dpr) and
|
|
4776
|
+
* dimming does not move glyphs, so only `width` is threaded — matching the
|
|
4777
|
+
* historical main-mode `_collectSlideRuns`.
|
|
4778
|
+
*/
|
|
4779
|
+
collectSlideRuns(slideIndex: number, width?: number): Promise<PptxTextRunInfo[]>;
|
|
3084
4780
|
/**
|
|
3085
4781
|
* Extract raw media bytes for a zip path referenced by {@link MediaElement}.
|
|
3086
4782
|
* Results are cached by path for the lifetime of this instance.
|
|
@@ -3095,6 +4791,23 @@ declare class PptxPresentation {
|
|
|
3095
4791
|
* decoded lazily rather than inlined as base64 at parse time.
|
|
3096
4792
|
*/
|
|
3097
4793
|
getImage(imagePath: string, mimeType: string): Promise<Blob>;
|
|
4794
|
+
/**
|
|
4795
|
+
* Project the presentation to GitHub-flavoured markdown: title slides become
|
|
4796
|
+
* `#` headings, body shapes become nested bullets at each paragraph's `lvl`,
|
|
4797
|
+
* tables become pipe tables, charts become summarised bullets, and speaker
|
|
4798
|
+
* notes and comments are collated. Positioning, animations, images, and
|
|
4799
|
+
* drawing detail are discarded — the projection is meant for AI ingestion and
|
|
4800
|
+
* full-text search, not layout.
|
|
4801
|
+
*
|
|
4802
|
+
* Runs entirely in the worker off the archive opened at {@link load} (no
|
|
4803
|
+
* re-copy of the file, no re-parse of the model on the main thread), so it
|
|
4804
|
+
* works in BOTH `mode: 'main'` and `mode: 'worker'`.
|
|
4805
|
+
*
|
|
4806
|
+
* @example
|
|
4807
|
+
* const pres = await PptxPresentation.load(buffer);
|
|
4808
|
+
* const md = await pres.toMarkdown();
|
|
4809
|
+
*/
|
|
4810
|
+
toMarkdown(): Promise<string>;
|
|
3098
4811
|
/**
|
|
3099
4812
|
* Render a slide and attach canvas-native playback controls for any
|
|
3100
4813
|
* embedded audio/video. Returns a {@link PresentationHandle} that owns the
|
|
@@ -3106,7 +4819,7 @@ declare class PptxPresentation {
|
|
|
3106
4819
|
destroy(): void;
|
|
3107
4820
|
}
|
|
3108
4821
|
|
|
3109
|
-
declare class PptxScrollViewer {
|
|
4822
|
+
declare class PptxScrollViewer implements ZoomableViewer {
|
|
3110
4823
|
private _pres;
|
|
3111
4824
|
private readonly _injected;
|
|
3112
4825
|
private readonly _opts;
|
|
@@ -3130,6 +4843,18 @@ declare class PptxScrollViewer {
|
|
|
3130
4843
|
* than a `_scale === 1` sentinel because a fit scale of exactly 1 is a valid
|
|
3131
4844
|
* established state (a 1× fit would otherwise be re-fit forever). */
|
|
3132
4845
|
private _scaleEstablished;
|
|
4846
|
+
/**
|
|
4847
|
+
* IX9 F1 — a `setScale` factor requested BEFORE the base fit is established
|
|
4848
|
+
* (pre-load, or a zero-width container), already clamped to
|
|
4849
|
+
* `[zoomMin, zoomMax]`, or `null` when none is pending. The single-canvas
|
|
4850
|
+
* viewers latch a pre-load `setScale` and honour it on the first render; the
|
|
4851
|
+
* scroll viewers used to silently DROP it — the family-unified semantics are
|
|
4852
|
+
* "latch and apply once the layout establishes". `relayout()` applies (and
|
|
4853
|
+
* clears) this right after establishing the base, firing `onScaleChange` at
|
|
4854
|
+
* application time; `getScale()` reports it while pending so the caller sees
|
|
4855
|
+
* the same value a single-canvas viewer would show.
|
|
4856
|
+
*/
|
|
4857
|
+
private _pendingScale;
|
|
3133
4858
|
/** Live slots keyed by slide index. */
|
|
3134
4859
|
private readonly _slots;
|
|
3135
4860
|
/** Recyclable detached slots (canvas + textLayer reused across slides). */
|
|
@@ -3144,6 +4869,23 @@ declare class PptxScrollViewer {
|
|
|
3144
4869
|
* reporting an error so a rejection that lands after teardown is swallowed
|
|
3145
4870
|
* rather than surfaced to a `onError` on a dead viewer. */
|
|
3146
4871
|
private _destroyed;
|
|
4872
|
+
/**
|
|
4873
|
+
* Concurrent-load latch (generation token). Every self-loading `load()`
|
|
4874
|
+
* increments this and captures the value; after its engine finishes loading it
|
|
4875
|
+
* re-checks the live value and BAILS (destroying its own just-loaded engine) if
|
|
4876
|
+
* a newer `load()` has since started. Without it, two overlapping
|
|
4877
|
+
* `load(A)`/`load(B)` calls race the WASM parse / worker init, and whichever
|
|
4878
|
+
* RESOLVES last wins the swap — even the stale `load(A)` resolving after
|
|
4879
|
+
* `load(B)`; the loser's freshly created engine (never installed, or installed
|
|
4880
|
+
* then overwritten) then leaks its worker + pinned WASM allocation. The latch
|
|
4881
|
+
* composes with SC20: the check runs AFTER the new engine loads but BEFORE the
|
|
4882
|
+
* field assignment, `previous?.destroy()`, and the recycle/relayout post-load
|
|
4883
|
+
* work, so a superseded load never touches `this._pres` nor frees the current
|
|
4884
|
+
* (newer) engine. Only the self-loading path uses it — the injected path throws
|
|
4885
|
+
* up-front and never reaches here. `destroy()` also bumps it so a load in flight
|
|
4886
|
+
* at teardown is treated as superseded and its engine cleaned up.
|
|
4887
|
+
*/
|
|
4888
|
+
private _loadGen;
|
|
3147
4889
|
/** Worker mode: slide indices whose bitmap render is currently dispatched to the
|
|
3148
4890
|
* engine. Coalesces a scroll storm — we never dispatch a second render for a
|
|
3149
4891
|
* slide whose first is still in flight — and lets us drop slides that scrolled
|
|
@@ -3174,11 +4916,14 @@ declare class PptxScrollViewer {
|
|
|
3174
4916
|
* is host-agnostic. */
|
|
3175
4917
|
private _settleTimer;
|
|
3176
4918
|
private _wheelListener;
|
|
3177
|
-
/**
|
|
3178
|
-
*
|
|
3179
|
-
*
|
|
3180
|
-
*
|
|
3181
|
-
|
|
4919
|
+
/** Gesture-only pointer anchor for the NEXT `setScale`, in scrollHost-viewport
|
|
4920
|
+
* px (`{ x, y }` from the wheel event, relative to the scroll host's top-left).
|
|
4921
|
+
* Set by the Ctrl/⌘+wheel handler right before it calls `setScale` so the zoom
|
|
4922
|
+
* pivots on the cursor ("zoom toward the pointer") in BOTH axes; consumed and
|
|
4923
|
+
* cleared by `setScale`. `null` for every non-gesture source (the public
|
|
4924
|
+
* `setScale`, the +/- steppers, `fitWidth`/`fitPage`, the resize re-fit), which
|
|
4925
|
+
* keep the historical viewport-TOP re-anchor so their behaviour is unchanged. */
|
|
4926
|
+
private _pendingZoomAnchor;
|
|
3182
4927
|
/** Observes the container so a width change re-fits the base scale. Disconnected
|
|
3183
4928
|
* in `destroy()`. */
|
|
3184
4929
|
private _resizeObserver;
|
|
@@ -3254,6 +4999,12 @@ declare class PptxScrollViewer {
|
|
|
3254
4999
|
* `_positionSlot` (the flush-left floor), and by `_syncSpacerWidth` (the spacer
|
|
3255
5000
|
* width). Resolved here (not stored) to mirror `_gap()`/`_pad()`. */
|
|
3256
5001
|
private _padH;
|
|
5002
|
+
/** Index of the slide whose slot spans content-offset `y` (largest `i` with
|
|
5003
|
+
* `offsets[i] <= y`), for the pointer-anchored zoom re-anchor. Mirrors the
|
|
5004
|
+
* `topIndex` search `computeVisibleRange` runs for the scrollTop, but for an
|
|
5005
|
+
* ARBITRARY content-y (the pointer, not the viewport top). Clamped into
|
|
5006
|
+
* `[0, n-1]`; a `y` below the first slide (inside the leading pad) yields 0. */
|
|
5007
|
+
private _slideIndexAtOffset;
|
|
3257
5008
|
private _range;
|
|
3258
5009
|
private _syncSpacer;
|
|
3259
5010
|
/** Horizontal scroll extent: the (uniform deck-wide) slide width plus both
|
|
@@ -3302,10 +5053,6 @@ declare class PptxScrollViewer {
|
|
|
3302
5053
|
* can pass for an old-epoch resolution). We gate them on the captured epoch.
|
|
3303
5054
|
*/
|
|
3304
5055
|
private _renderSlot;
|
|
3305
|
-
/** Warn once when an `enableTextSelection` overlay was requested but the render
|
|
3306
|
-
* mode is `worker` (so the overlay stays empty). Same wording as
|
|
3307
|
-
* `PptxViewer` — one warning per viewer, not per slot. */
|
|
3308
|
-
private _maybeWarnNoTextSelection;
|
|
3309
5056
|
/** Route an async render failure to `onError`, or `console.error` when none is
|
|
3310
5057
|
* set (so failures are never fully silent), and never after teardown. */
|
|
3311
5058
|
private _reportRenderError;
|
|
@@ -3341,7 +5088,10 @@ declare class PptxScrollViewer {
|
|
|
3341
5088
|
* `[zoomMin ?? 0.1, zoomMax ?? 4]` (absolute bounds, XlsxViewer convention — NOT
|
|
3342
5089
|
* multiples of the base fit; design §3 keeps the clamp in the viewer, not core),
|
|
3343
5090
|
* then re-anchor VERTICALLY so the slide currently under the viewport top stays
|
|
3344
|
-
* fixed. A no-op when
|
|
5091
|
+
* fixed. A no-op when the clamped scale is unchanged. Called BEFORE the deck is
|
|
5092
|
+
* loaded / the base fit is established, the clamped factor is LATCHED (IX9 F1,
|
|
5093
|
+
* family-unified with the single-canvas viewers) and applied by `relayout()`
|
|
5094
|
+
* once the layout establishes — `onScaleChange` fires then.
|
|
3345
5095
|
*
|
|
3346
5096
|
* FLICKER-FREE (design §7): this does NOT re-render the visible slides inline.
|
|
3347
5097
|
* It shows an immediate CSS preview (stretch the existing bitmaps, scale the
|
|
@@ -3362,6 +5112,39 @@ declare class PptxScrollViewer {
|
|
|
3362
5112
|
* can no longer return below the floor to the original base fit through this API.
|
|
3363
5113
|
*/
|
|
3364
5114
|
setScale(scale: number): void;
|
|
5115
|
+
/** IX9 {@link ZoomableViewer} — the current zoom factor, where `1` = 100% (a
|
|
5116
|
+
* slide at its natural EMU→px size). This is the viewer's absolute `_scale`
|
|
5117
|
+
* (`slideWidth/EMU_PER_PX × _scale` is the drawn width), so it reads `1` at
|
|
5118
|
+
* true 100% and, after the initial fit-to-width, the base fit factor. Before
|
|
5119
|
+
* the fit is established it reports a latched pre-load `setScale` (IX9 F1) if
|
|
5120
|
+
* one is pending — matching what a single-canvas viewer would show — else `1`. */
|
|
5121
|
+
getScale(): number;
|
|
5122
|
+
/** IX9 {@link ZoomableViewer} — step up to the next rung of the shared zoom
|
|
5123
|
+
* ladder above the current factor (clamped to `zoomMax` by {@link setScale}). */
|
|
5124
|
+
zoomIn(): void;
|
|
5125
|
+
/** IX9 {@link ZoomableViewer} — step down to the next lower ladder rung. */
|
|
5126
|
+
zoomOut(): void;
|
|
5127
|
+
/**
|
|
5128
|
+
* IX9 {@link ZoomableViewer} — fit a slide's WIDTH to the container (the classic
|
|
5129
|
+
* continuous-scroll "fit width"). Sets the scale to the width-fit base for the
|
|
5130
|
+
* current container, then re-anchors + re-renders via {@link setScale}. Defers
|
|
5131
|
+
* (no-op) while the container is unlaid-out. The `zoomMin`/`zoomMax` clamp still
|
|
5132
|
+
* applies, so a fit below `zoomMin` pins to `zoomMin`.
|
|
5133
|
+
*/
|
|
5134
|
+
fitWidth(): void;
|
|
5135
|
+
/**
|
|
5136
|
+
* IX9 {@link ZoomableViewer} — fit a WHOLE slide (width and height) inside the
|
|
5137
|
+
* container so one slide is visible without scrolling; takes the tighter of the
|
|
5138
|
+
* width/height fit. Uses the deck-wide (uniform) slide size. Defers while
|
|
5139
|
+
* unlaid-out.
|
|
5140
|
+
*/
|
|
5141
|
+
fitPage(): void;
|
|
5142
|
+
/** Shared fit for {@link fitWidth}/{@link fitPage}: the width-fit factor is the
|
|
5143
|
+
* established base (`_baseScale`); the page-fit additionally bounds by the
|
|
5144
|
+
* container height against the (uniform) slide height. Applies via
|
|
5145
|
+
* {@link setScale} so the flicker-free re-anchor / settle path and
|
|
5146
|
+
* `onScaleChange` all run. */
|
|
5147
|
+
private _fit;
|
|
3365
5148
|
/**
|
|
3366
5149
|
* CSS preview of the visible window at the current `_scale` (design §7
|
|
3367
5150
|
* mechanism 1), WITHOUT re-rendering. Slots leaving the window recycle normally;
|
|
@@ -3388,12 +5171,11 @@ declare class PptxScrollViewer {
|
|
|
3388
5171
|
private _scheduleSettle;
|
|
3389
5172
|
/** Full-resolution settle re-render of the visible window (design §7 mechanisms
|
|
3390
5173
|
* 2+3). Re-renders each mounted slot at the current scale via the double-buffer
|
|
3391
|
-
* swap (main) / same-canvas transfer (worker).
|
|
3392
|
-
* overlay
|
|
3393
|
-
*
|
|
3394
|
-
*
|
|
3395
|
-
*
|
|
3396
|
-
* mid-render. */
|
|
5174
|
+
* swap (main) / same-canvas transfer (worker). Both modes rebuild the text
|
|
5175
|
+
* overlay from the fresh render's run geometry (IX6 — worker mode collects the
|
|
5176
|
+
* runs off-thread via `_renderSlotBitmap`) and clear the preview transform.
|
|
5177
|
+
* Dispatched at the CURRENT epoch; the existing epoch gate discards it if a
|
|
5178
|
+
* later `setScale` supersedes it mid-render. */
|
|
3397
5179
|
private _settleRender;
|
|
3398
5180
|
/**
|
|
3399
5181
|
* Settle-render one slot at the current scale (design §7 mechanism 3).
|
|
@@ -3435,6 +5217,31 @@ declare class PptxScrollViewer {
|
|
|
3435
5217
|
scrollToSlide(index: number, opts?: {
|
|
3436
5218
|
behavior?: 'auto' | 'smooth';
|
|
3437
5219
|
}): void;
|
|
5220
|
+
/**
|
|
5221
|
+
* IX1 hyperlink click dispatch (mirrors {@link PptxViewer._onHyperlinkClick}).
|
|
5222
|
+
* When the integrator supplies `opts.onHyperlinkClick` it OWNS the click (no
|
|
5223
|
+
* default). Otherwise: an external link opens in a new tab via the shared,
|
|
5224
|
+
* scheme-sanitised {@link openExternalHyperlink}; an internal slide jump scrolls
|
|
5225
|
+
* to the target slide via {@link scrollToSlide} once the action resolves to a
|
|
5226
|
+
* slide index (a jump resolving to no reachable slide is a safe no-op).
|
|
5227
|
+
*/
|
|
5228
|
+
/**
|
|
5229
|
+
* IX1 — the click handler passed to the text-layer overlay, or `undefined` when
|
|
5230
|
+
* `enableHyperlinks` is `false`. This is the single gate that disables hyperlink
|
|
5231
|
+
* interactivity: {@link buildPptxTextLayer} renders link runs exactly like plain
|
|
5232
|
+
* runs when no handler is supplied, so no hit region, cursor, tooltip, listener,
|
|
5233
|
+
* or navigation is wired (a custom `onHyperlinkClick` is suppressed too). When
|
|
5234
|
+
* enabled, the returned handler dispatches through {@link _onHyperlinkClick}.
|
|
5235
|
+
*/
|
|
5236
|
+
private _hyperlinkHandler;
|
|
5237
|
+
private _onHyperlinkClick;
|
|
5238
|
+
/** Populate an internal {@link HyperlinkTarget}'s `slideIndex` from its `ref`
|
|
5239
|
+
* via the engine's stamped part names. Relative `hlinkshowjump` verbs are
|
|
5240
|
+
* resolved against the slide currently at the viewport top
|
|
5241
|
+
* (`_range().topIndex`); a `../slides/slideN.xml` part target resolves through
|
|
5242
|
+
* the part-name map. An already-set index, an external target, and an
|
|
5243
|
+
* unresolvable ref all pass through unchanged (safe no-op). */
|
|
5244
|
+
private _resolveInternalSlideIndex;
|
|
3438
5245
|
/**
|
|
3439
5246
|
* Re-fit the base scale on a container resize while PRESERVING the current zoom
|
|
3440
5247
|
* multiplier (design §11), then re-anchor + re-render. A `ResizeObserver` fires
|
|
@@ -3468,6 +5275,8 @@ declare class PptxScrollViewer {
|
|
|
3468
5275
|
/* Excluded from this release type: baseScaleForTest */
|
|
3469
5276
|
/* Excluded from this release type: renderEpochForTest */
|
|
3470
5277
|
/* Excluded from this release type: resizeForTest */
|
|
5278
|
+
/* Excluded from this release type: contentAtViewportYForTest */
|
|
5279
|
+
/* Excluded from this release type: viewportYOfForTest */
|
|
3471
5280
|
/**
|
|
3472
5281
|
* Tear down the viewer: remove the DOM subtree and (only for a self-loaded
|
|
3473
5282
|
* engine) destroy the engine. An injected engine is left intact — the caller
|
|
@@ -3520,9 +5329,10 @@ declare interface PptxScrollViewerOptions extends Omit<RenderSlideOptions, 'onTe
|
|
|
3520
5329
|
paddingRight?: number;
|
|
3521
5330
|
/** Slides kept mounted beyond the viewport on each side. Default 1. */
|
|
3522
5331
|
overscan?: number;
|
|
3523
|
-
/** Per-slide transparent text-selection overlay.
|
|
3524
|
-
* in worker mode
|
|
3525
|
-
*
|
|
5332
|
+
/** Per-slide transparent text-selection overlay. IX6 — works in BOTH render
|
|
5333
|
+
* modes: in worker mode the per-run geometry is collected off-thread and
|
|
5334
|
+
* shipped back beside the slide bitmap, so the overlay is populated identically
|
|
5335
|
+
* to main mode (no more empty overlay / one-time warning). */
|
|
3526
5336
|
enableTextSelection?: boolean;
|
|
3527
5337
|
/** Minimum zoom scale — a DIMENSIONLESS multiplier over the 96-dpi natural
|
|
3528
5338
|
* slide size (10% = 0.1), matching `DocxScrollViewer`. Default 0.1. */
|
|
@@ -3566,6 +5376,12 @@ declare interface PptxScrollViewerOptions extends Omit<RenderSlideOptions, 'onTe
|
|
|
3566
5376
|
* `computeVisibleRange` (the first slide intersecting the viewport top,
|
|
3567
5377
|
* EXCLUDING overscan). */
|
|
3568
5378
|
onVisibleSlideChange?: (topIndex: number, total: number) => void;
|
|
5379
|
+
/** IX9 — fires whenever the zoom factor actually changes (`1` = 100% = a slide
|
|
5380
|
+
* at its natural EMU→px size): from {@link PptxScrollViewer.setScale},
|
|
5381
|
+
* `zoomIn`/`zoomOut`, `fitWidth`/`fitPage`, a Ctrl/⌘+wheel gesture, or a
|
|
5382
|
+
* container-resize re-fit. Named `onScaleChange` to match the single-canvas
|
|
5383
|
+
* viewers so all five share one notification shape. */
|
|
5384
|
+
onScaleChange?: (scale: number) => void;
|
|
3569
5385
|
/** Error callback. When set, `load()` invokes it and resolves (otherwise the
|
|
3570
5386
|
* error is rethrown — shared viewer error contract). It ALSO fires for async
|
|
3571
5387
|
* per-slot render failures (both main `renderSlide` and worker
|
|
@@ -3573,6 +5389,24 @@ declare interface PptxScrollViewerOptions extends Omit<RenderSlideOptions, 'onTe
|
|
|
3573
5389
|
* crashing the loop. Without an `onError`, render failures are logged via
|
|
3574
5390
|
* `console.error` so they are never fully silent. */
|
|
3575
5391
|
onError?: (err: Error) => void;
|
|
5392
|
+
/**
|
|
5393
|
+
* IX1 (design decision — NOT user-confirmed, integrator may veto). Fires on a
|
|
5394
|
+
* hyperlink click in any mounted slide's text overlay (requires
|
|
5395
|
+
* {@link enableTextSelection}). Default when omitted: external →
|
|
5396
|
+
* {@link openExternalHyperlink} (new tab, sanitised, noopener); internal
|
|
5397
|
+
* slide-jump → {@link scrollToSlide} once the action resolves to a slide index
|
|
5398
|
+
* via {@link PptxPresentation.resolveInternalTarget} (a jump that resolves to
|
|
5399
|
+
* no reachable slide is a safe no-op). When provided, the viewer calls this
|
|
5400
|
+
* instead and takes NO default action.
|
|
5401
|
+
*/
|
|
5402
|
+
onHyperlinkClick?: (target: HyperlinkTarget) => void;
|
|
5403
|
+
/** IX1 — master switch for hyperlink interactivity. Default `true`. When
|
|
5404
|
+
* `false`, the hyperlink machinery is not wired at all: the overlay's link
|
|
5405
|
+
* spans are non-interactive, so there is no pointer cursor, no title tooltip,
|
|
5406
|
+
* no default navigation (external new-tab / internal slide jump), and
|
|
5407
|
+
* `onHyperlinkClick` is never called. Links still render exactly as authored
|
|
5408
|
+
* but are inert, like plain text. */
|
|
5409
|
+
enableHyperlinks?: boolean;
|
|
3576
5410
|
}
|
|
3577
5411
|
|
|
3578
5412
|
/** Information about a rendered text segment for building a transparent selection overlay. */
|
|
@@ -3605,6 +5439,14 @@ declare interface PptxTextRunInfo {
|
|
|
3605
5439
|
* `vert="vert270"` → -90). The CSS overlay must add this to `rotation`.
|
|
3606
5440
|
*/
|
|
3607
5441
|
textBodyRotation?: number;
|
|
5442
|
+
/**
|
|
5443
|
+
* Resolved hyperlink target for this run (IX1), classified into the shared
|
|
5444
|
+
* {@link HyperlinkTarget} shape. Present only for runs whose `<a:rPr>` carried
|
|
5445
|
+
* an `<a:hlinkClick>`; the overlay makes such spans clickable. The glyph
|
|
5446
|
+
* drawing (colour + underline) is unaffected — this is metadata for the
|
|
5447
|
+
* transparent overlay only.
|
|
5448
|
+
*/
|
|
5449
|
+
hyperlink?: HyperlinkTarget;
|
|
3608
5450
|
}
|
|
3609
5451
|
|
|
3610
5452
|
/**
|
|
@@ -3617,9 +5459,18 @@ declare interface PptxTextRunInfo {
|
|
|
3617
5459
|
*
|
|
3618
5460
|
* For custom layouts (multi-canvas, thumbnails, scroll view) use PptxPresentation directly.
|
|
3619
5461
|
*/
|
|
3620
|
-
declare class PptxViewer {
|
|
5462
|
+
declare class PptxViewer implements ZoomableViewer {
|
|
3621
5463
|
private readonly canvas;
|
|
3622
5464
|
private readonly wrapper;
|
|
5465
|
+
/**
|
|
5466
|
+
* IX9 explicit zoom factor (`1` = 100% = the slide at its natural EMU→px
|
|
5467
|
+
* width), or `null` when the caller has never invoked a zoom method. `null`
|
|
5468
|
+
* preserves the pre-IX9 render path EXACTLY: the slide renders at `opts.width`
|
|
5469
|
+
* (or `canvas.offsetWidth || 960` when unset), so default rendering is
|
|
5470
|
+
* byte-identical. The first zoom call latches a number here, after which
|
|
5471
|
+
* {@link _targetWidth} derives the render width from it.
|
|
5472
|
+
*/
|
|
5473
|
+
private _scale;
|
|
3623
5474
|
/** The canvas's DOM position BEFORE the constructor reparented it into
|
|
3624
5475
|
* {@link wrapper}, captured so {@link destroy} can return the caller-owned
|
|
3625
5476
|
* canvas to exactly where it was. `null` parent = canvas was passed
|
|
@@ -3630,6 +5481,13 @@ declare class PptxViewer {
|
|
|
3630
5481
|
* (empty string if it was unset), restored on {@link destroy}. */
|
|
3631
5482
|
private readonly _originalDisplay;
|
|
3632
5483
|
private textLayer;
|
|
5484
|
+
/** IX2 — the find-highlight overlay layer (always created, above the text
|
|
5485
|
+
* layer, `pointer-events:none`). */
|
|
5486
|
+
private highlightLayer;
|
|
5487
|
+
/** IX2 — find state (per-slide runs, matches, active cursor). */
|
|
5488
|
+
private _find;
|
|
5489
|
+
/** Private 2d context for measuring highlight text (own 1×1 canvas). */
|
|
5490
|
+
private _measureCtx;
|
|
3633
5491
|
private engine;
|
|
3634
5492
|
private readonly opts;
|
|
3635
5493
|
private currentSlide;
|
|
@@ -3640,14 +5498,39 @@ declare class PptxViewer {
|
|
|
3640
5498
|
* render path. The media-playback path keeps a 2d context (via presentSlide),
|
|
3641
5499
|
* so this is obtained only when worker mode renders without media playback. */
|
|
3642
5500
|
private _bitmapCtx;
|
|
3643
|
-
|
|
5501
|
+
/** Set by {@link destroy} (first line). Guards {@link _reportRenderError} so a
|
|
5502
|
+
* render rejection that lands AFTER teardown is swallowed rather than surfaced
|
|
5503
|
+
* to an `onError` / `console.error` on a dead viewer — parity with the scroll
|
|
5504
|
+
* viewers' `_destroyed` flag. */
|
|
5505
|
+
private _destroyed;
|
|
5506
|
+
/**
|
|
5507
|
+
* Concurrent-load latch (generation token). Every {@link load} increments this
|
|
5508
|
+
* and captures the value; after its engine finishes loading it re-checks the
|
|
5509
|
+
* live value and BAILS (destroying its own just-loaded engine) if a newer
|
|
5510
|
+
* `load()` has since started. Without it, two overlapping `load(A)`/`load(B)`
|
|
5511
|
+
* calls race the WASM parse / worker init, and whichever RESOLVES last wins the
|
|
5512
|
+
* swap — even the stale `load(A)` resolving after `load(B)`; the loser's freshly
|
|
5513
|
+
* created engine (never installed, or installed then overwritten) then leaks its
|
|
5514
|
+
* worker + pinned WASM allocation. The latch composes with SC20: the check runs
|
|
5515
|
+
* AFTER the new engine loads but BEFORE the field assignment and
|
|
5516
|
+
* `previous?.destroy()`, so a superseded load never touches `this.engine` nor
|
|
5517
|
+
* frees the current (newer) engine. {@link destroy} also bumps it so a load in
|
|
5518
|
+
* flight at teardown is treated as superseded and its engine cleaned up.
|
|
5519
|
+
*/
|
|
5520
|
+
private _loadGen;
|
|
3644
5521
|
constructor(canvas: HTMLCanvasElement, opts?: PptxViewerOptions);
|
|
3645
5522
|
/**
|
|
3646
5523
|
* Load a PPTX from URL or ArrayBuffer and render the first slide.
|
|
3647
5524
|
*
|
|
3648
|
-
* Error contract (shared by all three viewers):
|
|
3649
|
-
*
|
|
3650
|
-
*
|
|
5525
|
+
* Error contract (shared by all three viewers):
|
|
5526
|
+
* - Parse/load failure (the underlying `PptxPresentation.load()` call itself
|
|
5527
|
+
* rejects): if an `onError` callback was provided it is invoked and `load`
|
|
5528
|
+
* resolves normally; if not, the error is rethrown so it is never silently
|
|
5529
|
+
* swallowed.
|
|
5530
|
+
* - Render failure (the first slide fails to draw AFTER a successful
|
|
5531
|
+
* parse/load): routed to the shared `_reportRenderError` contract (`onError`
|
|
5532
|
+
* if provided, else `console.error` — never silent) and `load` still
|
|
5533
|
+
* RESOLVES, matching every subsequent navigation call.
|
|
3651
5534
|
*/
|
|
3652
5535
|
load(source: string | ArrayBuffer): Promise<void>;
|
|
3653
5536
|
/** Navigate to a specific slide (0-indexed). */
|
|
@@ -3680,8 +5563,124 @@ declare class PptxViewer {
|
|
|
3680
5563
|
getNotes(slideIndex: number): string | null;
|
|
3681
5564
|
/** The underlying <canvas> element. */
|
|
3682
5565
|
get canvasElement(): HTMLCanvasElement;
|
|
5566
|
+
/** Natural (100%) CSS-px width of a slide — `slideWidth(EMU) / EMU_PER_PX`.
|
|
5567
|
+
* 0 when nothing is loaded. The scale-1 reference every zoom factor
|
|
5568
|
+
* multiplies. */
|
|
5569
|
+
private _naturalWidthPx;
|
|
5570
|
+
/**
|
|
5571
|
+
* The width (CSS px) the render paths draw the slide at, honouring the zoom
|
|
5572
|
+
* state. `_scale === null` (no zoom method ever called) ⇒ the pre-IX9 value
|
|
5573
|
+
* `opts.width ?? (canvas.offsetWidth || 960)` verbatim (byte-identical
|
|
5574
|
+
* default). Once a factor latched ⇒ `naturalWidth × scale` (rounded), so the
|
|
5575
|
+
* slide is exactly `scale ×` its natural size regardless of `opts.width`.
|
|
5576
|
+
*/
|
|
5577
|
+
private _targetWidth;
|
|
5578
|
+
/** IX9 {@link ZoomableViewer} — the current zoom factor (`1` = 100%). Before
|
|
5579
|
+
* any zoom method is called this is the EFFECTIVE scale implied by the render
|
|
5580
|
+
* width: `targetWidth / naturalWidth`, or `1` when nothing is loaded. */
|
|
5581
|
+
getScale(): number;
|
|
5582
|
+
private _zoomMin;
|
|
5583
|
+
private _zoomMax;
|
|
5584
|
+
/**
|
|
5585
|
+
* IX9 {@link ZoomableViewer} — set the absolute zoom factor (`1` = 100% = the
|
|
5586
|
+
* slide at its natural EMU→px width), clamped to `[zoomMin, zoomMax]`, and
|
|
5587
|
+
* re-render the current slide at the new size. Fires `onScaleChange` when the
|
|
5588
|
+
* clamped factor actually changes. Resolves once the re-render settles.
|
|
5589
|
+
*/
|
|
5590
|
+
setScale(scale: number): Promise<void>;
|
|
5591
|
+
/** IX9 {@link ZoomableViewer} — step up to the next rung of the shared zoom
|
|
5592
|
+
* ladder (clamped to `zoomMax`). */
|
|
5593
|
+
zoomIn(): Promise<void>;
|
|
5594
|
+
/** IX9 {@link ZoomableViewer} — step down to the next lower ladder rung. */
|
|
5595
|
+
zoomOut(): Promise<void>;
|
|
5596
|
+
/**
|
|
5597
|
+
* IX9 {@link ZoomableViewer} — fit the current slide's WIDTH to the host
|
|
5598
|
+
* container (the element the canvas lives in), then re-render. Defers (no-op)
|
|
5599
|
+
* when nothing is loaded or the container is unlaid-out. Routes through
|
|
5600
|
+
* {@link setScale}.
|
|
5601
|
+
*/
|
|
5602
|
+
fitWidth(): Promise<void>;
|
|
5603
|
+
/**
|
|
5604
|
+
* IX9 {@link ZoomableViewer} — fit the WHOLE current slide (width and height)
|
|
5605
|
+
* inside the container so it is fully visible; takes the tighter of the
|
|
5606
|
+
* width/height fit. Defers when unloaded / unlaid-out.
|
|
5607
|
+
*/
|
|
5608
|
+
fitPage(): Promise<void>;
|
|
5609
|
+
/** Shared fit for {@link fitWidth}/{@link fitPage}: measure the natural slide
|
|
5610
|
+
* size + the container box, ask core's pure `fitScale`, apply via setScale. */
|
|
5611
|
+
private _fit;
|
|
3683
5612
|
private renderCurrentSlide;
|
|
5613
|
+
/** Draw the find-highlight boxes for the current slide from its runs. */
|
|
5614
|
+
private _buildHighlightLayer;
|
|
5615
|
+
/** A width-measurer primed with `font`, backed by a private 1×1 canvas. */
|
|
5616
|
+
private _measureForFont;
|
|
5617
|
+
/** IX6 — collect a slide's runs for search without touching the visible
|
|
5618
|
+
* canvas. Delegates to `collectSlideRuns`, which works in BOTH modes (worker:
|
|
5619
|
+
* off-thread, ships only the runs; main: throwaway offscreen canvas). Used for
|
|
5620
|
+
* slides other than the one on screen. */
|
|
5621
|
+
private _collectSlideRuns;
|
|
5622
|
+
/**
|
|
5623
|
+
* IX2 — find every occurrence of `query` across all slides and highlight them
|
|
5624
|
+
* (a soft box per match on the highlight overlay). Returns every match in
|
|
5625
|
+
* document order, each tagged with its `{ slide }` (0-based). Case-insensitive
|
|
5626
|
+
* by default; pass `{ caseSensitive: true }` for an exact match.
|
|
5627
|
+
*
|
|
5628
|
+
* Scans all slides (each rendered once offscreen to read its text; the visible
|
|
5629
|
+
* slide reuses its on-screen render). IX6 — works in BOTH `mode: 'main'` and
|
|
5630
|
+
* `mode: 'worker'`: in worker mode each slide's run geometry is collected
|
|
5631
|
+
* off-thread and shipped back, so find returns the same matches on the same
|
|
5632
|
+
* code path. An empty query clears the find.
|
|
5633
|
+
*/
|
|
5634
|
+
findText(query: string, opts?: FindMatchesOptions): Promise<FindMatch<PptxMatchLocation>[]>;
|
|
5635
|
+
/**
|
|
5636
|
+
* IX2 — move to the next match (wrap-around), navigating to its slide if
|
|
5637
|
+
* needed, and draw it in the active-match colour. Returns the now-active
|
|
5638
|
+
* match, or `null` when there are none. Call {@link findText} first.
|
|
5639
|
+
*/
|
|
5640
|
+
findNext(): Promise<FindMatch<PptxMatchLocation> | null>;
|
|
5641
|
+
/** IX2 — move to the previous match (wrap-around). */
|
|
5642
|
+
findPrev(): Promise<FindMatch<PptxMatchLocation> | null>;
|
|
5643
|
+
/** IX2 — clear all highlights and reset the find state. */
|
|
5644
|
+
clearFind(): void;
|
|
5645
|
+
private _activateMatch;
|
|
5646
|
+
/** Rebuild the highlight overlay for the current slide from cached runs. */
|
|
5647
|
+
private _redrawHighlights;
|
|
3684
5648
|
private _buildTextLayer;
|
|
5649
|
+
/**
|
|
5650
|
+
* IX1 — the click handler passed to the text-layer overlay, or `undefined` when
|
|
5651
|
+
* `enableHyperlinks` is `false`. This is the single gate that disables hyperlink
|
|
5652
|
+
* interactivity: {@link buildPptxTextLayer} renders link runs exactly like plain
|
|
5653
|
+
* runs when no handler is supplied, so no hit region, cursor, tooltip, listener,
|
|
5654
|
+
* or navigation is wired (a custom `onHyperlinkClick` is suppressed too). When
|
|
5655
|
+
* enabled, the returned handler dispatches through {@link _onHyperlinkClick}.
|
|
5656
|
+
*/
|
|
5657
|
+
private _hyperlinkHandler;
|
|
5658
|
+
/**
|
|
5659
|
+
* IX1/IX-nav hyperlink click dispatch. An internal target is first *enriched*
|
|
5660
|
+
* with its resolved 0-based `slideIndex` (via
|
|
5661
|
+
* {@link PptxPresentation.resolveInternalTarget}, relative to the current
|
|
5662
|
+
* slide) so a jump verb / slide-part ref arrives already mapped — this is the
|
|
5663
|
+
* field that was previously always `undefined`. When the integrator supplies
|
|
5664
|
+
* `opts.onHyperlinkClick` it OWNS the (enriched) click and takes NO default
|
|
5665
|
+
* action. Otherwise the viewer's default policy applies: an external link
|
|
5666
|
+
* opens in a new tab via the shared, scheme-sanitised
|
|
5667
|
+
* {@link openExternalHyperlink}; an internal slide jump navigates via
|
|
5668
|
+
* {@link goToSlide} to the resolved index (a target that resolves to no
|
|
5669
|
+
* reachable slide is a safe no-op).
|
|
5670
|
+
*/
|
|
5671
|
+
private _onHyperlinkClick;
|
|
5672
|
+
/** Populate an internal {@link HyperlinkTarget}'s `slideIndex` from its `ref`
|
|
5673
|
+
* (a `ppaction://hlinkshowjump?jump=…` verb resolved relative to the current
|
|
5674
|
+
* slide, or a `../slides/slideN.xml` part target resolved through the stamped
|
|
5675
|
+
* part-name map — no filename-suffix heuristic). Any already-set `slideIndex`
|
|
5676
|
+
* is kept; an external target and an unresolvable ref pass through unchanged so
|
|
5677
|
+
* the caller no-ops safely. */
|
|
5678
|
+
private _resolveInternalSlideIndex;
|
|
5679
|
+
/** PD14 render-error contract: route a render failure to `onError`, or
|
|
5680
|
+
* `console.error` when none is given (never fully silent), and never after
|
|
5681
|
+
* teardown. Mirrors the scroll viewers' `_reportRenderError` so all three
|
|
5682
|
+
* single-canvas viewers agree. */
|
|
5683
|
+
private _reportRenderError;
|
|
3685
5684
|
/**
|
|
3686
5685
|
* Clean up the viewer and terminate the background worker.
|
|
3687
5686
|
*
|
|
@@ -3699,6 +5698,17 @@ declare interface PptxViewerOptions extends RenderOptions, LoadOptions {
|
|
|
3699
5698
|
onSlideChange?: (index: number, total: number) => void;
|
|
3700
5699
|
/** Called on parse or render errors */
|
|
3701
5700
|
onError?: (err: Error) => void;
|
|
5701
|
+
/** IX9 zoom contract ({@link ZoomableViewer}) — the clamp range for
|
|
5702
|
+
* {@link PptxViewer.setScale} / `zoomIn` / `zoomOut` / `fitWidth` / `fitPage`,
|
|
5703
|
+
* as user-facing zoom factors (`1` = 100% = the slide at its natural
|
|
5704
|
+
* EMU→px size). Defaults 0.1–4 (10%–400%), matching the other viewers. */
|
|
5705
|
+
zoomMin?: number;
|
|
5706
|
+
zoomMax?: number;
|
|
5707
|
+
/** IX9 — fires whenever the zoom factor actually changes (`1` = 100%): from
|
|
5708
|
+
* {@link PptxViewer.setScale}, `zoomIn`/`zoomOut`, or `fitWidth`/`fitPage`.
|
|
5709
|
+
* Named `onScaleChange` to match the docx/xlsx viewers so all five share one
|
|
5710
|
+
* notification shape. */
|
|
5711
|
+
onScaleChange?: (scale: number) => void;
|
|
3702
5712
|
/**
|
|
3703
5713
|
* Enable interactive audio/video playback. When true, slides are rendered
|
|
3704
5714
|
* via {@link PptxPresentation.presentSlide} so media elements become
|
|
@@ -3730,6 +5740,25 @@ declare interface PptxViewerOptions extends RenderOptions, LoadOptions {
|
|
|
3730
5740
|
* in sync if {@link DimOptions} gains a field.
|
|
3731
5741
|
*/
|
|
3732
5742
|
hiddenSlideDim?: Partial<DimOptions>;
|
|
5743
|
+
/**
|
|
5744
|
+
* IX1 (design decision — NOT user-confirmed, integrator may veto). Fires on a
|
|
5745
|
+
* hyperlink click (a text run whose `<a:rPr>` carried an `<a:hlinkClick>`;
|
|
5746
|
+
* requires {@link enableTextSelection} so the overlay spans exist). Default
|
|
5747
|
+
* when omitted: external → {@link openExternalHyperlink} (new tab, sanitised,
|
|
5748
|
+
* noopener); internal slide-jump → {@link goToSlide} once the action resolves
|
|
5749
|
+
* to a slide index via {@link PptxPresentation.resolveInternalTarget} (a jump
|
|
5750
|
+
* that resolves to no reachable slide is a safe no-op). When provided, the
|
|
5751
|
+
* viewer calls this instead and takes NO default action.
|
|
5752
|
+
*/
|
|
5753
|
+
onHyperlinkClick?: (target: HyperlinkTarget) => void;
|
|
5754
|
+
/** IX1 — master switch for hyperlink interactivity. Default `true`. When
|
|
5755
|
+
* `false`, the hyperlink machinery is not wired at all: the overlay's link
|
|
5756
|
+
* spans are non-interactive, so there is no pointer cursor, no title tooltip,
|
|
5757
|
+
* no default navigation (external new-tab / internal slide jump), and
|
|
5758
|
+
* `onHyperlinkClick` is never called. Links still render exactly as authored
|
|
5759
|
+
* (theme `hlink` colour + underline are painted on the canvas) but are inert,
|
|
5760
|
+
* like plain text. */
|
|
5761
|
+
enableHyperlinks?: boolean;
|
|
3733
5762
|
}
|
|
3734
5763
|
|
|
3735
5764
|
declare interface Presentation {
|
|
@@ -3760,6 +5789,22 @@ declare interface PresentationHandle {
|
|
|
3760
5789
|
destroy(): void;
|
|
3761
5790
|
}
|
|
3762
5791
|
|
|
5792
|
+
/** ECMA-376 §17.3.3.23 `<w:ptab>` — an absolute-position tab. Advances to a
|
|
5793
|
+
* position derived from {@link PTabRun.alignment} and {@link PTabRun.relativeTo},
|
|
5794
|
+
* independent of the paragraph's custom tab stops / default-tab interval. */
|
|
5795
|
+
declare interface PTabRun {
|
|
5796
|
+
/** ST_PTabAlignment (§17.18.71): where on the line the tab lands, and how the
|
|
5797
|
+
* following text aligns to it. */
|
|
5798
|
+
alignment: 'left' | 'center' | 'right';
|
|
5799
|
+
/** ST_PTabRelativeTo (§17.18.73): the base the position is measured from —
|
|
5800
|
+
* the text margins or the paragraph indents. */
|
|
5801
|
+
relativeTo: 'margin' | 'indent';
|
|
5802
|
+
/** ST_PTabLeader (§17.18.72): the character repeated to fill the tab gap. */
|
|
5803
|
+
leader: 'none' | 'dot' | 'hyphen' | 'underscore' | 'middleDot';
|
|
5804
|
+
/** Resolved run font size (pt) — matches the surrounding text's leader/gap. */
|
|
5805
|
+
fontSize: number;
|
|
5806
|
+
}
|
|
5807
|
+
|
|
3763
5808
|
/** ECMA-376 §20.1.8.27 (CT_ReflectionEffect) — mirrored copy below the
|
|
3764
5809
|
* shape with a linear alpha gradient. Carries the spec attributes whose
|
|
3765
5810
|
* defaults the renderer needs to interpret correctly. */
|
|
@@ -3821,7 +5866,10 @@ declare interface RenderPageOptions {
|
|
|
3821
5866
|
width?: number;
|
|
3822
5867
|
dpr?: number;
|
|
3823
5868
|
defaultTextColor?: string;
|
|
3824
|
-
/** Called for each rendered text segment. Used to build a transparent text
|
|
5869
|
+
/** Called for each rendered text segment. Used to build a transparent text
|
|
5870
|
+
* selection overlay. On a vertical (§17.6.20 tbRl) page `x`/`y` are the
|
|
5871
|
+
* PHYSICAL top-left and `transform` is the CSS rotation the overlay span
|
|
5872
|
+
* applies about its top-left; absent for horizontal pages. */
|
|
3825
5873
|
onTextRun?: (run: {
|
|
3826
5874
|
text: string;
|
|
3827
5875
|
x: number;
|
|
@@ -3830,12 +5878,27 @@ declare interface RenderPageOptions {
|
|
|
3830
5878
|
h: number;
|
|
3831
5879
|
fontSize: number;
|
|
3832
5880
|
font: string;
|
|
5881
|
+
transform?: string;
|
|
3833
5882
|
}) => void;
|
|
3834
5883
|
/** Default `true`. When false, ECMA-376 §17.13.5 track-changes runs render
|
|
3835
5884
|
* in their normal style (no author colour, no underline / strikethrough)
|
|
3836
5885
|
* — equivalent to Word's "Final / No Markup" view. */
|
|
3837
5886
|
showTrackChanges?: boolean;
|
|
3838
|
-
|
|
5887
|
+
/** ECMA-376 §17.16.5.16 DATE / §17.16.5.72 TIME — the "current" instant a
|
|
5888
|
+
* DATE/TIME field formats through its `\@` date picture (§17.16.4.1). A `Date`
|
|
5889
|
+
* or epoch-ms number. Default = the real current time at render. Set a fixed
|
|
5890
|
+
* value for deterministic / reproducible DATE/TIME field output. */
|
|
5891
|
+
currentDate?: Date | number;
|
|
5892
|
+
}
|
|
5893
|
+
|
|
5894
|
+
/** IX6 — options for {@link DocxDocument.renderPageToBitmap}: the serializable
|
|
5895
|
+
* render knobs plus an OPTIONAL `onTextRun`. The callback stays main-thread (it
|
|
5896
|
+
* never crosses the wire); in worker mode the proxy invokes it with the runs
|
|
5897
|
+
* the worker shipped back beside the bitmap, so a caller gets the selection /
|
|
5898
|
+
* find geometry on the same path in both modes. */
|
|
5899
|
+
declare type RenderPageToBitmapOptions = WireRenderPageOptions & {
|
|
5900
|
+
onTextRun?: (run: DocxTextRunInfo) => void;
|
|
5901
|
+
};
|
|
3839
5902
|
|
|
3840
5903
|
/**
|
|
3841
5904
|
* Render a single slide onto a <canvas> element.
|
|
@@ -3870,6 +5933,14 @@ declare interface RenderSlideToBitmapOptions {
|
|
|
3870
5933
|
/* Excluded from this release type: skipMediaControls */
|
|
3871
5934
|
/** Translucent overlay drawn over the finished slide (hidden-slide dimming). */
|
|
3872
5935
|
dim?: DimOptions;
|
|
5936
|
+
/**
|
|
5937
|
+
* IX6 — receives the slide's text-run geometry (the same stream `renderSlide`
|
|
5938
|
+
* emits in main mode). Stays main-thread (never crosses the wire); in worker
|
|
5939
|
+
* mode the proxy invokes it with the runs the worker shipped back beside the
|
|
5940
|
+
* bitmap, so a caller builds the selection / find overlay on the SAME code
|
|
5941
|
+
* path in both modes.
|
|
5942
|
+
*/
|
|
5943
|
+
onTextRun?: TextRunCallback;
|
|
3873
5944
|
}
|
|
3874
5945
|
|
|
3875
5946
|
declare interface RenderViewportOptions {
|
|
@@ -3925,6 +5996,20 @@ declare type ResolvedList = {
|
|
|
3925
5996
|
formula: string;
|
|
3926
5997
|
};
|
|
3927
5998
|
|
|
5999
|
+
/**
|
|
6000
|
+
* Resolve every `{ type: 'shared', si }` cell in `ws` to a concrete
|
|
6001
|
+
* `{ type: 'text', text, runs? }` by looking `si` up in the workbook
|
|
6002
|
+
* `sharedStrings` table (ECMA-376 §18.4.8). Mutates cells in place and returns
|
|
6003
|
+
* `ws` for chaining. Out-of-range / missing `si` resolves to empty text —
|
|
6004
|
+
* matching the parser's historical fallback. Idempotent: a `Worksheet` with no
|
|
6005
|
+
* `shared` cells is returned unchanged.
|
|
6006
|
+
*
|
|
6007
|
+
* This keeps the dedup win on the wire (each shared string ships ONCE in the
|
|
6008
|
+
* workbook) while every downstream consumer — renderer, formula engine, number
|
|
6009
|
+
* formatter, markdown — still sees fully-resolved cell text.
|
|
6010
|
+
*/
|
|
6011
|
+
declare function resolveSharedStrings(ws: Worksheet, sharedStrings: SharedString[]): Worksheet;
|
|
6012
|
+
|
|
3928
6013
|
/**
|
|
3929
6014
|
* 3D rotation in sphere coordinates — ECMA-376 §20.1.5.11 (`CT_SphereCoords`).
|
|
3930
6015
|
* Angles are in **degrees** (the XML carries 60000ths of a degree; the parser
|
|
@@ -3944,12 +6029,26 @@ declare interface Row {
|
|
|
3944
6029
|
index: number;
|
|
3945
6030
|
height: number | null;
|
|
3946
6031
|
cells: Cell[];
|
|
6032
|
+
/** Outline (grouping) depth 0-7 (ECMA-376 §18.3.1.73 `<row outlineLevel>`).
|
|
6033
|
+
* Omitted on the wire when `0` (ungrouped); read as `outlineLevel ?? 0`. */
|
|
6034
|
+
outlineLevel?: number;
|
|
6035
|
+
/** `<row collapsed>` (§18.3.1.73): `true` on a summary row whose
|
|
6036
|
+
* one-level-deeper detail rows are collapsed. Omitted when false. */
|
|
6037
|
+
collapsed?: boolean;
|
|
6038
|
+
/** `<row hidden>` (§18.3.1.73): `true` when the row is hidden — most often
|
|
6039
|
+
* because a collapsed outline hides its detail rows. Distinct from
|
|
6040
|
+
* `height === 0`. Omitted on the wire when false. */
|
|
6041
|
+
hidden?: boolean;
|
|
3947
6042
|
}
|
|
3948
6043
|
|
|
3949
6044
|
declare interface RubyAnnotation {
|
|
3950
6045
|
text: string;
|
|
3951
6046
|
/** Annotation font size in pt. Word stores this as half-points in `<w:hps>`. */
|
|
3952
6047
|
fontSizePt: number;
|
|
6048
|
+
/** Distance “between the phonetic guide base text and the phonetic guide
|
|
6049
|
+
* text” in pt. Word stores this as half-points in `<w:hpsRaise>`
|
|
6050
|
+
* (ECMA-376 §17.3.3.12). */
|
|
6051
|
+
hpsRaisePt?: number;
|
|
3953
6052
|
}
|
|
3954
6053
|
|
|
3955
6054
|
declare interface Run {
|
|
@@ -4025,6 +6124,13 @@ declare interface SecondaryValueAxis {
|
|
|
4025
6124
|
lineHidden: boolean;
|
|
4026
6125
|
/** `<c:majorTickMark>` — "cross" (default) | "out" | "in" | "none". */
|
|
4027
6126
|
majorTickMark: string;
|
|
6127
|
+
/**
|
|
6128
|
+
* `<c:valAx><c:majorUnit val>` (§21.2.2.103) — explicit distance between
|
|
6129
|
+
* major ticks/gridlines on THIS secondary axis, overriding the Excel-style
|
|
6130
|
+
* auto "nice" step. null/undefined ⇒ auto step (byte-stable). Symmetric with
|
|
6131
|
+
* {@link ChartModel.valAxisMajorUnit} on the primary axis.
|
|
6132
|
+
*/
|
|
6133
|
+
majorUnit?: number | null;
|
|
4028
6134
|
/** `<c:title>` run-prop font size (hpt). */
|
|
4029
6135
|
titleFontSizeHpt?: number | null;
|
|
4030
6136
|
/** `<c:title>` run-prop bold flag. */
|
|
@@ -4077,6 +6183,17 @@ declare interface SectionProps {
|
|
|
4077
6183
|
* spec default). Non-final sections carry their start type on their own
|
|
4078
6184
|
* SectionBreak marker. */
|
|
4079
6185
|
sectionStart?: string | null;
|
|
6186
|
+
/** ECMA-376 §17.6.20 `<w:textDirection w:val>` — the section's flow direction,
|
|
6187
|
+
* using the TRANSITIONAL ST_TextDirection enum Word writes (Part 4 §14.11.7:
|
|
6188
|
+
* `lrTb`|`tbRl`|`btLr`|`lrTbV`|`tbLrV`|`tbRlV`), NOT the Part 1 §17.18.93
|
|
6189
|
+
* Strict set. Absent / `null` ⇒ "lrTb" (horizontal, left→right / top→bottom,
|
|
6190
|
+
* the default). `"tbRl"` = vertical Japanese (glyphs stack top→bottom, lines
|
|
6191
|
+
* advance right→left); the renderer (see `isVerticalSection`) lays the page out
|
|
6192
|
+
* horizontally and rotates it +90° at paint for the vertical values
|
|
6193
|
+
* (`tbRl`/`tbRlV`/`tbLrV`), keeping CJK glyphs upright and Latin sideways. Only
|
|
6194
|
+
* a non-default value is emitted by the parser, so horizontal documents keep
|
|
6195
|
+
* byte-identical rendering. */
|
|
6196
|
+
textDirection?: string | null;
|
|
4080
6197
|
/** ECMA-376 §17.6.5 w:docGrid/@w:type — "default" | "lines" | "linesAndChars" | "snapToChars". */
|
|
4081
6198
|
docGridType?: string | null;
|
|
4082
6199
|
/** ECMA-376 §17.6.5 w:docGrid/@w:linePitch in pt. When docGridType is "lines" or
|
|
@@ -4095,6 +6212,23 @@ declare interface SectionProps {
|
|
|
4095
6212
|
* body text flows top-to-bottom through `count` columns (newspaper fill);
|
|
4096
6213
|
* see {@link computeColumns}. */
|
|
4097
6214
|
columns?: ColumnsSpec | null;
|
|
6215
|
+
/** ECMA-376 §17.6.12 `<w:pgNumType>` — the body (final) section's page-numbering
|
|
6216
|
+
* settings (start / fmt). `null`/absent ⇒ numbering continues; decimal. The
|
|
6217
|
+
* renderer resolves the displayed page number per physical page from this plus
|
|
6218
|
+
* the per-section `SectionBreak.pageNumType` markers. */
|
|
6219
|
+
pageNumType?: PageNumType | null;
|
|
6220
|
+
/** ECMA-376 §17.6.10 `<w:pgBorders>` — page borders for this section.
|
|
6221
|
+
* `null`/absent ⇒ no page border (the common case). */
|
|
6222
|
+
pageBorders?: PageBorders | null;
|
|
6223
|
+
/** ECMA-376 §17.6.8 `<w:lnNumType>` — line numbering for this section.
|
|
6224
|
+
* `null`/absent ⇒ line numbering off. */
|
|
6225
|
+
lineNumbering?: LineNumbering | null;
|
|
6226
|
+
/** ECMA-376 §17.6.23 `<w:vAlign w:val>` — body vertical alignment between the
|
|
6227
|
+
* top/bottom margins ("top" | "center" | "both" | "bottom"). `null`/absent ⇒
|
|
6228
|
+
* "top" (body flows from the top margin unchanged). "both" (vertical
|
|
6229
|
+
* justification) is parsed but rendered as "top" until distribution is
|
|
6230
|
+
* implemented (see renderer note). */
|
|
6231
|
+
vAlign?: string | null;
|
|
4098
6232
|
}
|
|
4099
6233
|
|
|
4100
6234
|
declare type SelectionMode_2 = 'cells' | 'rows' | 'cols' | 'all';
|
|
@@ -4188,6 +6322,23 @@ declare interface ShapeElement {
|
|
|
4188
6322
|
/** `<a:sp3d>` 3D shape properties (ECMA-376 §20.1.5.12). Parsed but not
|
|
4189
6323
|
* rendered in Phase A. */
|
|
4190
6324
|
sp3d?: Sp3d;
|
|
6325
|
+
/** `<p:nvSpPr><p:cNvPr @id>` — DrawingML cNvPr id. Present for file-authored
|
|
6326
|
+
* shapes (the attribute is schema-required); absent on parser-synthesized
|
|
6327
|
+
* shapes such as the SmartArt data-model fallback. */
|
|
6328
|
+
id?: string;
|
|
6329
|
+
/** `<p:nvSpPr><p:cNvPr @name>` — author-visible shape name (e.g. "Title 1").
|
|
6330
|
+
* The SmartArt data-model fallback synthesizes `name: "SmartArt"` with no
|
|
6331
|
+
* {@link ShapeElement.id} (see smartart-fallback-contrast.ts). */
|
|
6332
|
+
name?: string;
|
|
6333
|
+
/** Shape-level hyperlink target resolved from `<p:cNvPr><a:hlinkClick @r:id>`
|
|
6334
|
+
* via slide _rels (ECMA-376 §21.1.2.3.5). For an external link this is the
|
|
6335
|
+
* URL; for an internal slide jump it is the resolved internal part name.
|
|
6336
|
+
* Undefined when the shape carries no hlinkClick. */
|
|
6337
|
+
hyperlink?: string;
|
|
6338
|
+
/** Raw `<a:hlinkClick @action>` (e.g. `"ppaction://hlinksldjump"`) when the
|
|
6339
|
+
* shape link is an internal PowerPoint action rather than an external URL.
|
|
6340
|
+
* Undefined when absent. */
|
|
6341
|
+
hyperlinkAction?: string;
|
|
4191
6342
|
}
|
|
4192
6343
|
|
|
4193
6344
|
declare type ShapeFill = {
|
|
@@ -4238,6 +6389,12 @@ declare type ShapeGeom = {
|
|
|
4238
6389
|
r: number;
|
|
4239
6390
|
b: number;
|
|
4240
6391
|
};
|
|
6392
|
+
/** ECMA-376 §20.1.8.6 `<a:alphaModFix@amt>` opacity fraction (0..1) on the
|
|
6393
|
+
* leaf pic. Absent ⇒ opaque. Applied via `globalAlpha`. */
|
|
6394
|
+
alpha?: number;
|
|
6395
|
+
/** ECMA-376 §20.1.8.23 `<a:duotone>` recolour on the leaf pic. Absent ⇒
|
|
6396
|
+
* no effect. */
|
|
6397
|
+
duotone?: Duotone_2;
|
|
4241
6398
|
};
|
|
4242
6399
|
|
|
4243
6400
|
declare interface ShapeInfo {
|
|
@@ -4322,7 +6479,7 @@ declare interface ShapeRun {
|
|
|
4322
6479
|
groupHeightPt?: number | null;
|
|
4323
6480
|
/** Draw behind text when true (wp:anchor behindDoc="1"). */
|
|
4324
6481
|
behindDoc?: boolean;
|
|
4325
|
-
/**
|
|
6482
|
+
/** ECMA-376 §20.4.2.3 `wp:anchor/@relativeHeight`: lower values render first. */
|
|
4326
6483
|
zOrder: number;
|
|
4327
6484
|
/** Normalized [0,1] custom-geometry sub-paths. Empty when `presetGeometry`
|
|
4328
6485
|
* is set; the renderer chooses between buildCustomPath and buildShapePath. */
|
|
@@ -4330,8 +6487,10 @@ declare interface ShapeRun {
|
|
|
4330
6487
|
/** OOXML <a:prstGeom prst> name (e.g. "rect", "ellipse", "rtTriangle").
|
|
4331
6488
|
* When set the renderer calls core's buildShapePath with `adjValues`. */
|
|
4332
6489
|
presetGeometry?: string | null;
|
|
4333
|
-
/**
|
|
4334
|
-
|
|
6490
|
+
/** <a:gd name="adj{n}"> values from prstGeom/avLst in adj1..adj8 order.
|
|
6491
|
+
* `null` preserves omitted named guides so the preset engine can use the
|
|
6492
|
+
* geometry's default for that index. */
|
|
6493
|
+
adjValues?: Array<number | null>;
|
|
4335
6494
|
fill: ShapeFill | null;
|
|
4336
6495
|
stroke: string | null;
|
|
4337
6496
|
strokeWidth?: number;
|
|
@@ -4360,6 +6519,15 @@ declare interface ShapeRun {
|
|
|
4360
6519
|
wrapSide?: string | null;
|
|
4361
6520
|
/** Text rendered INSIDE the shape's bounding box (`<wps:txbx><w:txbxContent>`). */
|
|
4362
6521
|
textBlocks?: ShapeText_2[];
|
|
6522
|
+
/** ECMA-376 §20.1.4.1.17 `<wps:style><a:fontRef>` — the shape's DEFAULT text
|
|
6523
|
+
* color (hex, no `#`). A text-box run ({@link ShapeTextRun}) with no explicit
|
|
6524
|
+
* {@link ShapeTextRun.color} inherits this before falling back to the
|
|
6525
|
+
* document/theme default (black); an explicit run color still wins. This is
|
|
6526
|
+
* the color axis of the fontRef only — the `@idx` (major/minor/none) font-face
|
|
6527
|
+
* selection is out of scope (fonts resolve via rFonts/docDefaults). Mirrors
|
|
6528
|
+
* pptx's per-shape default text color from the placeholder fontRef. Absent ⇒
|
|
6529
|
+
* no shape default (the run color or black applies). */
|
|
6530
|
+
defaultTextColor?: string | null;
|
|
4363
6531
|
/** "t" | "ctr" | "b" — vertical anchor for the shape's text body (`<wps:bodyPr @anchor>`). */
|
|
4364
6532
|
textAnchor?: string | null;
|
|
4365
6533
|
/** ECMA-376 §21.1.2.1.1 auto-fit mode from `<wps:bodyPr>`, normalized to the
|
|
@@ -4372,6 +6540,24 @@ declare interface ShapeRun {
|
|
|
4372
6540
|
textInsetT?: number;
|
|
4373
6541
|
textInsetR?: number;
|
|
4374
6542
|
textInsetB?: number;
|
|
6543
|
+
/** ECMA-376 §20.1.10.83 ST_TextVerticalType — the text-body flow direction from
|
|
6544
|
+
* `<wps:bodyPr vert>` / `<a:bodyPr vert>`. Recognised vertical values:
|
|
6545
|
+
* "vert" (all glyphs 90° CW, chars T→B, lines R→L), "vert270" (all glyphs 270°
|
|
6546
|
+
* CW = 90° CCW, chars B→T, lines L→R), and "eaVert" (East-Asian upright: CJK
|
|
6547
|
+
* stands upright, non-EA rotated 90°, chars T→B, lines R→L). "horz"/absent ⇒
|
|
6548
|
+
* horizontal (unchanged). Unrecognised values ("mongolianVert", "wordArtVert",
|
|
6549
|
+
* …) fall back to horizontal until implemented. */
|
|
6550
|
+
textVert?: string | null;
|
|
6551
|
+
/** ECMA-376 Part 4 §19.1.2.23 `<v:textpath>` — WordArt text laid on the
|
|
6552
|
+
* shape path (a text watermark). When set the renderer draws this string,
|
|
6553
|
+
* scaled to fill the box (`fitshape`), rotated by {@link ShapeRun.rotation},
|
|
6554
|
+
* filled with {@link ShapeRun.fill} at {@link ShapeRun.fillOpacity} alpha —
|
|
6555
|
+
* INSTEAD of a fill/stroke panel + body text. */
|
|
6556
|
+
textPath?: TextPath | null;
|
|
6557
|
+
/** ECMA-376 Part 4 §19.1.2.5 `<v:fill opacity>` — fill alpha in `[0, 1]`
|
|
6558
|
+
* (default 1 = opaque). Used with {@link ShapeRun.textPath} to draw the
|
|
6559
|
+
* watermark semi-transparently. Absent ⇒ opaque. */
|
|
6560
|
+
fillOpacity?: number | null;
|
|
4375
6561
|
}
|
|
4376
6562
|
|
|
4377
6563
|
declare interface ShapeText {
|
|
@@ -4417,6 +6603,8 @@ declare interface ShapeText_2 {
|
|
|
4417
6603
|
* (image blocks / legacy single-format paragraphs). Absent for image-only
|
|
4418
6604
|
* paragraphs. */
|
|
4419
6605
|
runs?: ShapeTextRun_2[];
|
|
6606
|
+
/** ECMA-376 §17.9 paragraph numbering for text-box paragraphs. */
|
|
6607
|
+
numbering?: NumberingInfo | null;
|
|
4420
6608
|
alignment: string;
|
|
4421
6609
|
/** ECMA-376 §17.3.1.33 `<w:spacing w:before>` of this text-box paragraph, in
|
|
4422
6610
|
* pt — reserved ABOVE the paragraph inside the box. Absent/0 ⇒ no offset. */
|
|
@@ -4454,6 +6642,19 @@ declare interface ShapeText_2 {
|
|
|
4454
6642
|
* base direction for the UAX#9 reordering pass (the body renderer reads the
|
|
4455
6643
|
* identical field). */
|
|
4456
6644
|
bidi?: boolean;
|
|
6645
|
+
/** ECMA-376 §17.3.1.9 `<w:contextualSpacing>` — resolved through the style
|
|
6646
|
+
* chain in the parser. When set, this text-box paragraph drops its OWN
|
|
6647
|
+
* contribution to the collapsed gap against an ADJACENT paragraph that
|
|
6648
|
+
* shares its {@link ShapeText.styleId} (per-side, Word-adjudicated — issue
|
|
6649
|
+
* #1015; identical to {@link DocParagraph.contextualSpacing} via the
|
|
6650
|
+
* renderer's `contextualSpacingAdjust`). Absent ⇒ no suppression. */
|
|
6651
|
+
contextualSpacing?: boolean;
|
|
6652
|
+
/** Resolved paragraph style id of this text-box paragraph — the explicit
|
|
6653
|
+
* `<w:pStyle>`, else the document default paragraph style, else "Normal" (the
|
|
6654
|
+
* same stable id {@link DocParagraph.styleId} carries). Paired with
|
|
6655
|
+
* {@link ShapeText.contextualSpacing} to group adjacent same-style paragraphs
|
|
6656
|
+
* for §17.3.1.9. */
|
|
6657
|
+
styleId?: string | null;
|
|
4457
6658
|
/** Zip path of an inline image inside this text-box paragraph
|
|
4458
6659
|
* (`<w:drawing><wp:inline><a:blip r:embed>`), e.g. `word/media/image1.emf`.
|
|
4459
6660
|
* Absent for a text-only paragraph. */
|
|
@@ -4525,11 +6726,19 @@ declare interface ShapeTextRun_2 {
|
|
|
4525
6726
|
fontFamilyEastAsia?: string | null;
|
|
4526
6727
|
bold?: boolean;
|
|
4527
6728
|
italic?: boolean;
|
|
6729
|
+
/** ECMA-376 §17.3.3.25 ruby annotation (furigana) for text-box runs. */
|
|
6730
|
+
ruby?: RubyAnnotation | null;
|
|
4528
6731
|
}
|
|
4529
6732
|
|
|
4530
6733
|
declare interface SharedString {
|
|
4531
6734
|
text: string;
|
|
4532
6735
|
runs?: Run[];
|
|
6736
|
+
/** ECMA-376 §18.4.6 phonetic runs (furigana). Absent when the `<si>` has no
|
|
6737
|
+
* `<rPh>`. */
|
|
6738
|
+
phoneticRuns?: PhoneticRun[];
|
|
6739
|
+
/** ECMA-376 §18.4.3 phonetic display properties. Absent when the `<si>` has
|
|
6740
|
+
* no `<phoneticPr>`. */
|
|
6741
|
+
phoneticPr?: PhoneticProperties;
|
|
4533
6742
|
}
|
|
4534
6743
|
|
|
4535
6744
|
declare interface SheetMeta {
|
|
@@ -4572,6 +6781,17 @@ declare interface Slide {
|
|
|
4572
6781
|
index: number;
|
|
4573
6782
|
/** 1-based slide number (index + 1); used to render slidenum fields */
|
|
4574
6783
|
slideNumber: number;
|
|
6784
|
+
/**
|
|
6785
|
+
* The slide's normalized OPC part name (e.g. `ppt/slides/slide3.xml`),
|
|
6786
|
+
* resolved through `presentation.xml.rels` in `sldIdLst` order (ECMA-376
|
|
6787
|
+
* §19.3.1.42). An internal hyperlink slide jump
|
|
6788
|
+
* (`<a:hlinkClick action="ppaction://hlinksldjump" r:id>`, §21.1.2.3.5)
|
|
6789
|
+
* carries a rel Target that resolves to this same part name — so
|
|
6790
|
+
* {@link PptxPresentation.getSlideIndexByPartName} can turn a click into a
|
|
6791
|
+
* slide index. Absent (`undefined`) only for a slide whose part path was not
|
|
6792
|
+
* recorded; healthy and broken slides both carry it.
|
|
6793
|
+
*/
|
|
6794
|
+
partName?: string;
|
|
4575
6795
|
background: Fill | null;
|
|
4576
6796
|
elements: SlideElement[];
|
|
4577
6797
|
/**
|
|
@@ -4595,6 +6815,14 @@ declare interface Slide {
|
|
|
4595
6815
|
* slide modes (read it via `PptxPresentation.isHidden`).
|
|
4596
6816
|
*/
|
|
4597
6817
|
hidden?: boolean;
|
|
6818
|
+
/**
|
|
6819
|
+
* RB7 partial degradation: set when this slide's part could not be parsed. The
|
|
6820
|
+
* deck still opens with the OTHER slides intact; this one is a placeholder
|
|
6821
|
+
* (`elements` empty) whose `parseError` names the offending part (e.g.
|
|
6822
|
+
* `"ppt/slides/slide3.xml: <detail>"`). Absent (`undefined`) for every healthy
|
|
6823
|
+
* slide. The renderer paints a visible error box instead of slide content.
|
|
6824
|
+
*/
|
|
6825
|
+
parseError?: string;
|
|
4598
6826
|
}
|
|
4599
6827
|
|
|
4600
6828
|
declare type SlideElement = ShapeElement | PictureElement | TableElement | ChartElement | MediaElement;
|
|
@@ -4828,7 +7056,10 @@ declare interface TableRow {
|
|
|
4828
7056
|
}
|
|
4829
7057
|
|
|
4830
7058
|
declare interface TabStop {
|
|
4831
|
-
/** Position in EMU from the
|
|
7059
|
+
/** Position in EMU from the LEADING text-inset edge of the text area —
|
|
7060
|
+
* logical, not physical (ECMA-376 §21.1.2.1): the left edge (after lIns)
|
|
7061
|
+
* in an LTR paragraph, the right edge (before rIns) in an RTL
|
|
7062
|
+
* (`<a:pPr rtl="1">`) paragraph. */
|
|
4832
7063
|
pos: number;
|
|
4833
7064
|
/** Alignment: "l" | "r" | "ctr" | "dec" */
|
|
4834
7065
|
algn: string;
|
|
@@ -4886,6 +7117,19 @@ declare interface TextBody extends TextBody_2 {
|
|
|
4886
7117
|
* omitted from JSON when false. Only meaningful when `numCol > 1`.
|
|
4887
7118
|
*/
|
|
4888
7119
|
rtlCol?: boolean;
|
|
7120
|
+
/**
|
|
7121
|
+
* `<a:bodyPr><a:prstTxWarp>` (ECMA-376 §20.1.9.19) — WordArt text warp. When
|
|
7122
|
+
* present the renderer maps each glyph through the named envelope
|
|
7123
|
+
* (presetTextWarpDefinitions) instead of laying text out flat. Omitted from
|
|
7124
|
+
* JSON when the body has no warp, so unwarped bodies are byte-identical.
|
|
7125
|
+
*/
|
|
7126
|
+
textWarp?: {
|
|
7127
|
+
/** The `prst` name, e.g. `"textArchUp"`, `"textWave1"`. */
|
|
7128
|
+
preset: string;
|
|
7129
|
+
/** `<a:avLst>` adjust values (adj1, adj2, …) in thousandths of a percent.
|
|
7130
|
+
* Omitted when the author supplied none (preset defaults apply). */
|
|
7131
|
+
adj?: number[];
|
|
7132
|
+
};
|
|
4889
7133
|
/**
|
|
4890
7134
|
* Narrow the inherited `paragraphs` to the PPTX `Paragraph` so consumers see
|
|
4891
7135
|
* the PPTX-only `eaLnBrk` flag. PPTX `Paragraph extends CoreParagraph`, so
|
|
@@ -4943,6 +7187,20 @@ declare interface TextOutline {
|
|
|
4943
7187
|
color?: string;
|
|
4944
7188
|
}
|
|
4945
7189
|
|
|
7190
|
+
/** ECMA-376 Part 4 §19.1.2.23 `<v:textpath>` — a WordArt vector text path,
|
|
7191
|
+
* emitted by Word for text watermarks (the `PowerPlusWaterMarkObject` shape).
|
|
7192
|
+
* The text is stretched to fit the shape box (`fitshape`, the WordArt
|
|
7193
|
+
* `#_x0000_t136` shapetype default), so its drawn size derives from the shape
|
|
7194
|
+
* geometry rather than the nominal `font-size` in the textpath style. */
|
|
7195
|
+
declare interface TextPath {
|
|
7196
|
+
/** The `string` attribute — the watermark text (e.g. "DRAFT"). */
|
|
7197
|
+
string: string;
|
|
7198
|
+
/** `font-family` from the textpath style (quotes stripped). */
|
|
7199
|
+
fontFamily?: string | null;
|
|
7200
|
+
bold?: boolean;
|
|
7201
|
+
italic?: boolean;
|
|
7202
|
+
}
|
|
7203
|
+
|
|
4946
7204
|
/** Absolute text-frame rectangle in EMU (from SmartArt `<dsp:txXfrm>`). */
|
|
4947
7205
|
declare interface TextRect {
|
|
4948
7206
|
x: number;
|
|
@@ -5018,10 +7276,19 @@ declare interface TextRunData {
|
|
|
5018
7276
|
/** Set for OOXML field runs (e.g. "slidenum"). When set, renderer replaces text with field value. */
|
|
5019
7277
|
fieldType?: string;
|
|
5020
7278
|
/**
|
|
5021
|
-
* Hyperlink target
|
|
5022
|
-
*
|
|
7279
|
+
* Hyperlink target resolved from rPr > a:hlinkClick @r:id via the slide's _rels.
|
|
7280
|
+
* For an external link this is the URL; for an internal slide jump it is the
|
|
7281
|
+
* resolved internal part name (e.g. "../slides/slide3.xml"). Undefined for runs
|
|
7282
|
+
* without a hyperlink. ECMA-376 §21.1.2.3.5 (CT_Hyperlink).
|
|
5023
7283
|
*/
|
|
5024
7284
|
hyperlink?: string;
|
|
7285
|
+
/**
|
|
7286
|
+
* Raw `<a:hlinkClick @action>` string (e.g. "ppaction://hlinksldjump") when
|
|
7287
|
+
* present — its presence marks {@link hyperlink} as an INTERNAL PowerPoint
|
|
7288
|
+
* action (slide jump / first / last …) rather than an external URL. Undefined
|
|
7289
|
+
* when the hlinkClick has no @action. ECMA-376 §21.1.2.3.5. (IX1)
|
|
7290
|
+
*/
|
|
7291
|
+
hyperlinkAction?: string;
|
|
5025
7292
|
/**
|
|
5026
7293
|
* Run-level drop shadow on glyphs (`<a:rPr><a:effectLst><a:outerShdw>`),
|
|
5027
7294
|
* ECMA-376 §20.1.8.45. Independent of the shape-level shadow on `spPr`.
|
|
@@ -5083,11 +7350,51 @@ declare type WireRenderPageOptions = Omit<RenderPageOptions, 'onTextRun'>;
|
|
|
5083
7350
|
|
|
5084
7351
|
/** Serializable subset of RenderViewportOptions: drop the callback, the image
|
|
5085
7352
|
* cache, and the `fetchImage` loader (all non-cloneable; the worker owns its
|
|
5086
|
-
* own cache and supplies its own in-worker fetchImage).
|
|
5087
|
-
|
|
7353
|
+
* own cache and supplies its own in-worker fetchImage). Extended with the
|
|
7354
|
+
* optional {@link WireSizeOverrides} so view-only size mutations reach the
|
|
7355
|
+
* worker's local sheet copy; absent (the common case) when nothing has been
|
|
7356
|
+
* resized or collapsed, keeping the wire payload unchanged. */
|
|
7357
|
+
declare type WireRenderViewportOptions = Omit<RenderViewportOptions, 'onTextRun' | 'loadedImages' | 'fetchImage'> & {
|
|
7358
|
+
sizeOverrides?: WireSizeOverrides;
|
|
7359
|
+
};
|
|
7360
|
+
|
|
7361
|
+
/**
|
|
7362
|
+
* View-only per-band size overrides for one sheet, carried with every worker
|
|
7363
|
+
* `renderViewport` request. The render worker draws from its own worker-local
|
|
7364
|
+
* parsed-sheet cache, so main-thread Worksheet mutations (outline
|
|
7365
|
+
* collapse/expand via the size-0 hidden encoding, drag-to-resize #567) never
|
|
7366
|
+
* reach it on their own — without this channel the gutter/overlays update but
|
|
7367
|
+
* the grid bitmap stays stale.
|
|
7368
|
+
*
|
|
7369
|
+
* Semantics: keys are 1-based band indices; a number is the band's current
|
|
7370
|
+
* `rowHeights` / `colWidths` model value, `null` means "no entry — fall back
|
|
7371
|
+
* to the sheet default". The main thread accumulates every band the user has
|
|
7372
|
+
* touched this session (entries are updated in place, never removed), so
|
|
7373
|
+
* re-applying the full map is idempotent and converges the worker's cached
|
|
7374
|
+
* sheet to the main model even across worker-side re-parses.
|
|
7375
|
+
*/
|
|
7376
|
+
declare interface WireSizeOverrides {
|
|
7377
|
+
rows?: Record<number, number | null>;
|
|
7378
|
+
cols?: Record<number, number | null>;
|
|
7379
|
+
}
|
|
5088
7380
|
|
|
5089
7381
|
declare interface Workbook {
|
|
5090
7382
|
sheets: SheetMeta[];
|
|
7383
|
+
/** Workbook date system (`<workbookPr date1904>`, ECMA-376 §18.2.28).
|
|
7384
|
+
* `true` selects the 1904 date system (Mac-authored workbooks); serial
|
|
7385
|
+
* dates are resolved against the 1904 epoch (§18.17.4.1). Omitted from the
|
|
7386
|
+
* parser JSON when false (default 1900 date system). */
|
|
7387
|
+
date1904?: boolean;
|
|
7388
|
+
/** #773 partial degradation: a WORKBOOK-LEVEL degradation that leaves every
|
|
7389
|
+
* sheet openable. Set when a shared workbook part was PRESENT but corrupt —
|
|
7390
|
+
* most commonly `xl/sharedStrings.xml` (§18.4.9): a broken shared-string table
|
|
7391
|
+
* silently blanks every string cell across ALL sheets, so unlike a per-sheet
|
|
7392
|
+
* break it can't be attributed to one placeholder sheet. Tagged with the
|
|
7393
|
+
* offending part (e.g. `"xl/sharedStrings.xml: <detail>"`) so the loss is
|
|
7394
|
+
* surfaced instead of silent, while every sheet still renders its non-string
|
|
7395
|
+
* content. Absent (`undefined`) when every shared part read cleanly. Also set
|
|
7396
|
+
* (`"(zip container): <detail>"`) for a whole-container degradation (#774). */
|
|
7397
|
+
parseError?: string;
|
|
5091
7398
|
}
|
|
5092
7399
|
|
|
5093
7400
|
declare interface Worksheet {
|
|
@@ -5095,6 +7402,17 @@ declare interface Worksheet {
|
|
|
5095
7402
|
rows: Row[];
|
|
5096
7403
|
colWidths: Record<number, number>;
|
|
5097
7404
|
rowHeights: Record<number, number>;
|
|
7405
|
+
/** Per-column outline (grouping) depth 0-7 (ECMA-376 §18.3.1.13
|
|
7406
|
+
* `<col outlineLevel>`), keyed by 1-based column index. Present only for
|
|
7407
|
+
* grouped columns; absent (⇒ level 0) on outline-free sheets. */
|
|
7408
|
+
colOutlineLevels?: Record<number, number>;
|
|
7409
|
+
/** Per-column `<col collapsed>` (§18.3.1.13): `true` on a summary column whose
|
|
7410
|
+
* one-level-deeper detail columns are collapsed. Only `true` entries. */
|
|
7411
|
+
colCollapsed?: Record<number, boolean>;
|
|
7412
|
+
/** Per-column `<col hidden>` (§18.3.1.13): `true` when the column is hidden
|
|
7413
|
+
* (e.g. a collapsed outline hides its detail columns). Distinct from
|
|
7414
|
+
* `colWidths[c] === 0`. Only `true` entries. */
|
|
7415
|
+
colHidden?: Record<number, boolean>;
|
|
5098
7416
|
defaultColWidth: number;
|
|
5099
7417
|
defaultRowHeight: number;
|
|
5100
7418
|
mergeCells: MergeCell[];
|
|
@@ -5117,6 +7435,11 @@ declare interface Worksheet {
|
|
|
5117
7435
|
* grid so column A sits on the right (ECMA-376 §18.3.1.87
|
|
5118
7436
|
* `<sheetView rightToLeft>`). Defaults to false. */
|
|
5119
7437
|
rightToLeft?: boolean;
|
|
7438
|
+
/** Outline display flags from `<sheetPr><outlinePr>` (ECMA-376 §18.3.1.61).
|
|
7439
|
+
* Absent when the sheet declares no `<outlinePr>`; consumers apply the
|
|
7440
|
+
* schema defaults (`summaryBelow` / `summaryRight` both `true`). Decides
|
|
7441
|
+
* which side of a group the summary row/column (and its +/- toggle) sits. */
|
|
7442
|
+
outlinePr?: OutlinePr;
|
|
5120
7443
|
/** Sheet tab color (ECMA-376 §18.3.1.79). */
|
|
5121
7444
|
tabColor?: string | null;
|
|
5122
7445
|
/** AutoFilter header range (ECMA-376 §18.3.1.2). */
|
|
@@ -5160,6 +7483,17 @@ declare interface Worksheet {
|
|
|
5160
7483
|
defaultFontFamily?: string;
|
|
5161
7484
|
/** Point size of the workbook's Normal-style font (`<fonts>[N].sz.val`). */
|
|
5162
7485
|
defaultFontSize?: number;
|
|
7486
|
+
/** Workbook date system (`<workbookPr date1904>`, ECMA-376 §18.2.28),
|
|
7487
|
+
* denormalized onto every worksheet by the parser so the cell formatter can
|
|
7488
|
+
* resolve serial dates (§18.17.4.1) without a workbook back-reference.
|
|
7489
|
+
* `true` = 1904 date system. Omitted (⇒ false) for the default 1900 system. */
|
|
7490
|
+
date1904?: boolean;
|
|
7491
|
+
/** RB7 partial degradation: set when THIS sheet's part could not be
|
|
7492
|
+
* read/parsed. The workbook still opens with the OTHER sheets intact; this one
|
|
7493
|
+
* is an empty placeholder (`rows` empty) whose `parseError` names the offending
|
|
7494
|
+
* part (e.g. `"xl/worksheets/sheet3.xml: <detail>"`). Absent (`undefined`) for
|
|
7495
|
+
* every healthy sheet. The renderer paints a visible error overlay. */
|
|
7496
|
+
parseError?: string;
|
|
5163
7497
|
}
|
|
5164
7498
|
|
|
5165
7499
|
export declare namespace xlsx {
|
|
@@ -5167,6 +7501,7 @@ export declare namespace xlsx {
|
|
|
5167
7501
|
XlsxWorkbook,
|
|
5168
7502
|
LoadOptions_3 as LoadOptions,
|
|
5169
7503
|
WireRenderViewportOptions,
|
|
7504
|
+
WireSizeOverrides,
|
|
5170
7505
|
XlsxViewer,
|
|
5171
7506
|
ResolvedList,
|
|
5172
7507
|
XlsxViewerOptions,
|
|
@@ -5174,12 +7509,21 @@ export declare namespace xlsx {
|
|
|
5174
7509
|
CellAddress,
|
|
5175
7510
|
CellRange_2 as CellRange,
|
|
5176
7511
|
SelectionMode_2 as SelectionMode,
|
|
7512
|
+
XlsxMatchLocation,
|
|
7513
|
+
FindMatch,
|
|
7514
|
+
FindMatchesOptions,
|
|
5177
7515
|
autoResize,
|
|
5178
7516
|
AutoResizeOptions,
|
|
7517
|
+
HyperlinkTarget,
|
|
7518
|
+
openExternalHyperlink,
|
|
7519
|
+
resolveSharedStrings,
|
|
7520
|
+
OoxmlError,
|
|
7521
|
+
OoxmlErrorCode,
|
|
5179
7522
|
Workbook,
|
|
5180
7523
|
SheetMeta,
|
|
5181
7524
|
SheetVisibility,
|
|
5182
7525
|
Worksheet,
|
|
7526
|
+
OutlinePr,
|
|
5183
7527
|
Row,
|
|
5184
7528
|
Cell,
|
|
5185
7529
|
CellValue,
|
|
@@ -5198,6 +7542,10 @@ export declare namespace xlsx {
|
|
|
5198
7542
|
Run,
|
|
5199
7543
|
RunFont,
|
|
5200
7544
|
SharedString,
|
|
7545
|
+
PhoneticRun,
|
|
7546
|
+
PhoneticProperties,
|
|
7547
|
+
PhoneticType,
|
|
7548
|
+
PhoneticAlignment,
|
|
5201
7549
|
Dxf,
|
|
5202
7550
|
GradientFillSpec,
|
|
5203
7551
|
ConditionalFormat,
|
|
@@ -5216,6 +7564,7 @@ export declare namespace xlsx {
|
|
|
5216
7564
|
SparklineGroup,
|
|
5217
7565
|
Sparkline,
|
|
5218
7566
|
ImageAnchor,
|
|
7567
|
+
Duotone_2 as Duotone,
|
|
5219
7568
|
ChartAnchor,
|
|
5220
7569
|
ShapeAnchor,
|
|
5221
7570
|
ShapeInfo,
|
|
@@ -5266,6 +7615,20 @@ declare interface XlsxComment {
|
|
|
5266
7615
|
text: string;
|
|
5267
7616
|
}
|
|
5268
7617
|
|
|
7618
|
+
/** Where an xlsx match lives: the sheet, its name, and the cell (A1 + row/col). */
|
|
7619
|
+
declare interface XlsxMatchLocation {
|
|
7620
|
+
/** 0-based sheet index. */
|
|
7621
|
+
sheet: number;
|
|
7622
|
+
/** The sheet's display name. */
|
|
7623
|
+
sheetName: string;
|
|
7624
|
+
/** A1 cell reference, e.g. `"B7"`. */
|
|
7625
|
+
ref: string;
|
|
7626
|
+
/** 1-based row. */
|
|
7627
|
+
row: number;
|
|
7628
|
+
/** 1-based column. */
|
|
7629
|
+
col: number;
|
|
7630
|
+
}
|
|
7631
|
+
|
|
5269
7632
|
/** Emitted once per cell that has text, with the cell's canvas-pixel bounds. */
|
|
5270
7633
|
declare interface XlsxTextRunInfo {
|
|
5271
7634
|
text: string;
|
|
@@ -5281,13 +7644,53 @@ declare interface XlsxTextRunInfo {
|
|
|
5281
7644
|
col: number;
|
|
5282
7645
|
}
|
|
5283
7646
|
|
|
5284
|
-
declare class XlsxViewer {
|
|
7647
|
+
declare class XlsxViewer implements ZoomableViewer {
|
|
5285
7648
|
private wb;
|
|
5286
7649
|
/** The single subtree root the constructor appended to the caller's
|
|
5287
7650
|
* container. destroy() removes it to return the container to its original
|
|
5288
7651
|
* (empty) state. */
|
|
5289
7652
|
private wrapper;
|
|
5290
7653
|
private canvas;
|
|
7654
|
+
/** Region holding the outline gutters (top/left) and the inset {@link canvasArea}.
|
|
7655
|
+
* When the active sheet has no outlining the gutters collapse to 0 px and this
|
|
7656
|
+
* is a transparent pass-through, so an outline-free sheet lays out identically. */
|
|
7657
|
+
private gridRegion;
|
|
7658
|
+
/** Left gutter canvas: row group brackets + toggles (XL4). */
|
|
7659
|
+
private rowGutter;
|
|
7660
|
+
/** Top gutter canvas: column group brackets + toggles (XL4). */
|
|
7661
|
+
private colGutter;
|
|
7662
|
+
/** Top-left corner canvas: numbered level buttons (XL4). */
|
|
7663
|
+
private cornerGutter;
|
|
7664
|
+
/** Cached extents (unscaled CSS px) of the current sheet's gutters; both 0 for
|
|
7665
|
+
* an outline-free sheet. `w` insets {@link canvasArea} from the left, `h` from
|
|
7666
|
+
* the top. */
|
|
7667
|
+
private gutter;
|
|
7668
|
+
/** Per-axis outline layout (group brackets + toggles) for the current sheet,
|
|
7669
|
+
* recomputed on sheet switch and after each collapse/expand. `null` axis ⇒ no
|
|
7670
|
+
* outlining on that axis. */
|
|
7671
|
+
private rowOutline;
|
|
7672
|
+
private colOutline;
|
|
7673
|
+
private rowOutlineBands;
|
|
7674
|
+
private colOutlineBands;
|
|
7675
|
+
/** Original row heights / column widths stashed the first time a band is
|
|
7676
|
+
* collapsed, so expanding restores a custom size rather than the default.
|
|
7677
|
+
* Keyed by band index; per current worksheet (cleared on sheet switch). */
|
|
7678
|
+
private stashedRowHeights;
|
|
7679
|
+
private stashedColWidths;
|
|
7680
|
+
/**
|
|
7681
|
+
* Per-sheet cumulative record of every view-only size mutation (outline
|
|
7682
|
+
* collapse/expand, drag-to-resize #567), keyed by sheet index. Value = the
|
|
7683
|
+
* band's current model size, or `null` when the model has no entry (default
|
|
7684
|
+
* size). Serialized as {@link WireSizeOverrides} with every worker
|
|
7685
|
+
* `renderViewport` so the worker's local sheet cache converges to the
|
|
7686
|
+
* main-thread model — without it the worker keeps drawing the file's
|
|
7687
|
+
* original sizes and the grid bitmap goes stale under the (up-to-date)
|
|
7688
|
+
* gutter and overlays. Entries are updated in place and never removed
|
|
7689
|
+
* (idempotent re-application); the whole store resets when a new workbook
|
|
7690
|
+
* loads. Main mode never reads it (the main renderer draws from the mutated
|
|
7691
|
+
* model directly).
|
|
7692
|
+
*/
|
|
7693
|
+
private sizeOverrideStore;
|
|
5291
7694
|
private canvasArea;
|
|
5292
7695
|
private scrollHost;
|
|
5293
7696
|
private spacer;
|
|
@@ -5311,6 +7714,26 @@ declare class XlsxViewer {
|
|
|
5311
7714
|
* holds one context type for its lifetime, so this is obtained once and the
|
|
5312
7715
|
* main-mode 2d render path is never used on the same canvas. */
|
|
5313
7716
|
private _bitmapCtx;
|
|
7717
|
+
/** Set by {@link destroy} (first line). Guards {@link _reportRenderError} so a
|
|
7718
|
+
* render rejection that lands AFTER teardown is swallowed rather than surfaced
|
|
7719
|
+
* to an `onError` / `console.error` on a dead viewer — parity with the scroll
|
|
7720
|
+
* viewers' `_destroyed` flag. */
|
|
7721
|
+
private _destroyed;
|
|
7722
|
+
/**
|
|
7723
|
+
* Concurrent-load latch (generation token). Every {@link load} increments this
|
|
7724
|
+
* and captures the value; after its workbook finishes loading it re-checks the
|
|
7725
|
+
* live value and BAILS (destroying its own just-loaded workbook) if a newer
|
|
7726
|
+
* `load()` has since started. Without it, two overlapping `load(A)`/`load(B)`
|
|
7727
|
+
* calls race the WASM parse / worker init, and whichever RESOLVES last wins the
|
|
7728
|
+
* swap — even the stale `load(A)` resolving after `load(B)`; the loser's freshly
|
|
7729
|
+
* created workbook (never installed, or installed then overwritten) then leaks
|
|
7730
|
+
* its worker + pinned WASM allocation. The latch composes with SC20: the check
|
|
7731
|
+
* runs AFTER the new workbook loads but BEFORE the field assignment and
|
|
7732
|
+
* `previous?.destroy()`, so a superseded load never touches `this.wb` nor frees
|
|
7733
|
+
* the current (newer) workbook. {@link destroy} also bumps it so a load in
|
|
7734
|
+
* flight at teardown is treated as superseded and its workbook cleaned up.
|
|
7735
|
+
*/
|
|
7736
|
+
private _loadGen;
|
|
5314
7737
|
private resizeObserver;
|
|
5315
7738
|
/**
|
|
5316
7739
|
* Pending `requestAnimationFrame` handle for a coalesced re-render, or `null`
|
|
@@ -5349,13 +7772,27 @@ declare class XlsxViewer {
|
|
|
5349
7772
|
* strand the view at the sheet's far end once the host gains its real size.
|
|
5350
7773
|
*/
|
|
5351
7774
|
private effectiveH;
|
|
7775
|
+
/** Gesture-only pointer anchor for the NEXT `setScale`, in canvasArea-viewport
|
|
7776
|
+
* px (`{ x, y }` from the wheel event, relative to the grid's top-left). Set by
|
|
7777
|
+
* the Ctrl/⌘+wheel handler right before it calls `setScale` so the zoom pivots
|
|
7778
|
+
* on the cursor ("zoom toward the pointer") in BOTH axes, past the fixed
|
|
7779
|
+
* header + frozen-pane lead-in; consumed and cleared by `setScale`. `null` for
|
|
7780
|
+
* every non-gesture source (the public `setScale`, the +/- steppers, the zoom
|
|
7781
|
+
* slider, `fitWidth`/`fitPage`), which keep the historical START-anchored
|
|
7782
|
+
* (top-left) preservation so their behaviour is unchanged. */
|
|
7783
|
+
private _pendingZoomAnchor;
|
|
5352
7784
|
private anchorCell;
|
|
5353
7785
|
private activeCell;
|
|
5354
7786
|
private selectionMode;
|
|
5355
7787
|
private isSelecting;
|
|
5356
7788
|
private selectionOverlay;
|
|
7789
|
+
/** IX2 — find-highlight overlay (matched-cell boxes). */
|
|
7790
|
+
private findOverlay;
|
|
7791
|
+
/** IX2 — find state (matches + active cursor). */
|
|
7792
|
+
private _find;
|
|
5357
7793
|
private keydownHandler;
|
|
5358
7794
|
private pendingTap;
|
|
7795
|
+
private pendingClick;
|
|
5359
7796
|
private resizeDrag;
|
|
5360
7797
|
/** DOM overlay element that shows the hovered cell's comment. Lives in
|
|
5361
7798
|
* canvasArea above the scrollHost; `pointer-events:none` so it never blocks
|
|
@@ -5363,6 +7800,11 @@ declare class XlsxViewer {
|
|
|
5363
7800
|
private commentPopup;
|
|
5364
7801
|
/** `"row:col"` → comment for the current sheet, rebuilt on every showSheet. */
|
|
5365
7802
|
private commentMap;
|
|
7803
|
+
/** IX1 — `"row:col"` → hyperlink for the current sheet, rebuilt on every
|
|
7804
|
+
* showSheet. Keys mirror the renderer's `hyperlinkMap` (1-based row/col, the
|
|
7805
|
+
* first cell of a hyperlink `ref` range per the parser), so a `getCellAt`
|
|
7806
|
+
* {row,col} looks up directly. */
|
|
7807
|
+
private hyperlinkMap;
|
|
5366
7808
|
/** `"row:col"` of the cell whose popup is currently shown (or pending), so a
|
|
5367
7809
|
* pointermove within the same cell doesn't restart the show timer. */
|
|
5368
7810
|
private commentPopupKey;
|
|
@@ -5384,17 +7826,80 @@ declare class XlsxViewer {
|
|
|
5384
7826
|
* click; installed only while the panel is open. */
|
|
5385
7827
|
private validationOutsideHandler;
|
|
5386
7828
|
constructor(container: HTMLElement, opts?: XlsxViewerOptions);
|
|
7829
|
+
/** Every non-empty cell of a sheet with its rendered display text (IX2 find
|
|
7830
|
+
* source). Reads the parsed worksheet model directly — no render — so search
|
|
7831
|
+
* covers the whole sheet, not just the on-screen viewport. */
|
|
7832
|
+
private _collectSheetCells;
|
|
5387
7833
|
/**
|
|
5388
7834
|
* Load an XLSX from URL or ArrayBuffer and render the first sheet.
|
|
5389
7835
|
*
|
|
5390
|
-
* Error contract (shared by all three viewers):
|
|
5391
|
-
*
|
|
5392
|
-
*
|
|
7836
|
+
* Error contract (shared by all three viewers):
|
|
7837
|
+
* - Parse/load failure (the underlying `XlsxWorkbook.load()` call itself
|
|
7838
|
+
* rejects): if an `onError` callback was provided it is invoked and `load`
|
|
7839
|
+
* resolves normally; if not, the error is rethrown so it is never silently
|
|
7840
|
+
* swallowed.
|
|
7841
|
+
* - Render failure (the first sheet fails to draw AFTER a successful
|
|
7842
|
+
* parse/load): routed to the shared `_reportRenderError` contract (`onError`
|
|
7843
|
+
* if provided, else `console.error` — never silent) and `load` still
|
|
7844
|
+
* RESOLVES, matching every subsequent navigation call.
|
|
5393
7845
|
*/
|
|
5394
7846
|
load(source: string | ArrayBuffer): Promise<void>;
|
|
5395
7847
|
/** The loaded workbook, or throws if {@link load} has not completed. */
|
|
5396
7848
|
private get workbook();
|
|
5397
7849
|
showSheet(index: number): Promise<void>;
|
|
7850
|
+
/** Recompute the per-axis outline layout for `ws` and cache the band lists.
|
|
7851
|
+
* Both axes are `null` (gutters collapse to 0) when the sheet has no
|
|
7852
|
+
* outlining, so an outline-free sheet is untouched. */
|
|
7853
|
+
private buildOutline;
|
|
7854
|
+
/** Size and place the three gutter canvases (corner / col / row) from the
|
|
7855
|
+
* current outline, and inset {@link canvasArea} by the gutter extents. When
|
|
7856
|
+
* neither axis is grouped both extents are 0 and canvasArea covers the whole
|
|
7857
|
+
* region — pixel-identical to a viewer built before XL4. */
|
|
7858
|
+
private layoutGutters;
|
|
7859
|
+
/** Paint all visible gutter strips for the current scroll offset. Called at the
|
|
7860
|
+
* end of every grid render so the brackets track scroll / zoom exactly. */
|
|
7861
|
+
private renderGutters;
|
|
7862
|
+
/** Draw one axis's group brackets and +/- toggles into its gutter canvas,
|
|
7863
|
+
* aligned to the on-screen band positions via {@link getCellRect}. */
|
|
7864
|
+
private paintAxisGutter;
|
|
7865
|
+
/** Draw a small square +/- toggle centered at (cx, cy) in gutter-canvas CSS px. */
|
|
7866
|
+
private drawToggleBox;
|
|
7867
|
+
/** Draw one numbered level button centered at (cx, cy) in gutter-canvas CSS
|
|
7868
|
+
* px. Shared by the row bank (in the row gutter's top strip) and the column
|
|
7869
|
+
* bank (in the column gutter's left strip). */
|
|
7870
|
+
private drawLevelButton;
|
|
7871
|
+
/** Paint the corner (intersection of the two gutters) as plain background.
|
|
7872
|
+
* The numbered level banks live in each axis gutter's own header strip
|
|
7873
|
+
* (see paintAxisGutter), so the corner carries no interactive content. */
|
|
7874
|
+
private paintCornerGutter;
|
|
7875
|
+
/** Handle a click in a row/col gutter: hit-test the +/- toggles and toggle the
|
|
7876
|
+
* matching group's collapse state. */
|
|
7877
|
+
private onGutterPointerDown;
|
|
7878
|
+
/** Flip a single group's collapse state in the in-memory model, then rebuild
|
|
7879
|
+
* the outline + repaint. View-only: the file is never written. */
|
|
7880
|
+
private applyGroupToggle;
|
|
7881
|
+
/** Collapse/expand the whole sheet to `level` on one axis. */
|
|
7882
|
+
private applyLevelButton;
|
|
7883
|
+
/** Set a row/column hidden by mapping to the size-0 encoding the axis/renderer
|
|
7884
|
+
* already understand, stashing the original size so expand can restore it. */
|
|
7885
|
+
private setBandHidden;
|
|
7886
|
+
/** Record band `index`'s CURRENT model size (or `null` = no entry) in the
|
|
7887
|
+
* per-sheet override store. Called after every view-only size mutation —
|
|
7888
|
+
* outline hide/show above and drag-to-resize (#567) — so worker renders
|
|
7889
|
+
* converge to the main model. */
|
|
7890
|
+
private recordSizeOverride;
|
|
7891
|
+
/** The current sheet's override store serialized for the wire, or undefined
|
|
7892
|
+
* when nothing has been mutated (keeps the request payload unchanged). */
|
|
7893
|
+
private wireSizeOverrides;
|
|
7894
|
+
/** Update the `collapsed` flag on a band's model entry so the outline rebuild
|
|
7895
|
+
* reflects the new state. */
|
|
7896
|
+
private setBandCollapsed;
|
|
7897
|
+
/** Shared tail of a gutter interaction: invalidate the axis cache, rebuild the
|
|
7898
|
+
* outline (collapsed flags changed), refresh dependent geometry, re-render. */
|
|
7899
|
+
private afterOutlineMutation;
|
|
7900
|
+
/** Rebuild only the layout + band lists (not the stashes) after a collapse
|
|
7901
|
+
* state change, so the +/- glyphs and bracket set stay in sync. */
|
|
7902
|
+
private buildOutlineLayoutOnly;
|
|
5398
7903
|
/** True when the current sheet's grid is laid out right-to-left. */
|
|
5399
7904
|
private get isRtl();
|
|
5400
7905
|
/** Maximum horizontal scroll offset the native scroll host allows (≥ 0). */
|
|
@@ -5519,6 +8024,46 @@ declare class XlsxViewer {
|
|
|
5519
8024
|
* whole range) to mirror Excel, which attaches the button to the active
|
|
5520
8025
|
* cell of the selection. */
|
|
5521
8026
|
private maybeDrawValidationDropdown;
|
|
8027
|
+
/**
|
|
8028
|
+
* Redraw the find-highlight overlay: one translucent box per matched cell on
|
|
8029
|
+
* the current sheet, the active match in a stronger colour. Uses the SAME
|
|
8030
|
+
* `getCellRect` + `screenX` + header/frozen clamp the selection overlay uses,
|
|
8031
|
+
* so a box lands exactly on the drawn cell at any scroll offset / zoom / RTL.
|
|
8032
|
+
* Rebuilt on every render and scroll (cheap DOM geometry, no canvas paint).
|
|
8033
|
+
*/
|
|
8034
|
+
private updateFindOverlay;
|
|
8035
|
+
/**
|
|
8036
|
+
* IX2 — find every occurrence of `query` across every sheet and highlight the
|
|
8037
|
+
* matched cells. Returns every match in document order (sheet ascending, then
|
|
8038
|
+
* row-major within a sheet), each tagged with its
|
|
8039
|
+
* `{ sheet, sheetName, ref, row, col }`. A cell is the search unit: search
|
|
8040
|
+
* runs over each cell's *rendered* display text (number formats, dates, rich
|
|
8041
|
+
* text flattened), so a query matches what the grid shows. Case-insensitive by
|
|
8042
|
+
* default; pass `{ caseSensitive: true }` for an exact match. An empty query
|
|
8043
|
+
* clears the find.
|
|
8044
|
+
*/
|
|
8045
|
+
findText(query: string, opts?: FindMatchesOptions): Promise<FindMatch<XlsxMatchLocation>[]>;
|
|
8046
|
+
/**
|
|
8047
|
+
* IX2 — move to the next match (wrap-around), switching sheets and scrolling
|
|
8048
|
+
* the matched cell into view as needed, and highlight it as the active match.
|
|
8049
|
+
* Returns the now-active match, or `null` when there are none. Call
|
|
8050
|
+
* {@link findText} first.
|
|
8051
|
+
*/
|
|
8052
|
+
findNext(): Promise<FindMatch<XlsxMatchLocation> | null>;
|
|
8053
|
+
/** IX2 — move to the previous match (wrap-around). */
|
|
8054
|
+
findPrev(): Promise<FindMatch<XlsxMatchLocation> | null>;
|
|
8055
|
+
/** IX2 — clear all highlights and reset the find state. */
|
|
8056
|
+
clearFind(): void;
|
|
8057
|
+
private _activateMatch;
|
|
8058
|
+
/**
|
|
8059
|
+
* Scroll the grid so cell (row, col) is comfortably in view. Computes the
|
|
8060
|
+
* cell's absolute logical offset from the axis metrics (the same the renderer
|
|
8061
|
+
* uses) and nudges `scrollHost.scrollTop` / start-anchored horizontal scroll
|
|
8062
|
+
* only when the cell is outside the scrollable viewport — an in-view cell is
|
|
8063
|
+
* left where it is (Excel's find behaviour). Frozen cells are always visible,
|
|
8064
|
+
* so they need no scroll.
|
|
8065
|
+
*/
|
|
8066
|
+
private _scrollCellIntoView;
|
|
5522
8067
|
/** Toggle the dropdown panel for the active cell's list validation. Called
|
|
5523
8068
|
* from pointerdown when the arrow rect is hit. Re-clicking the same arrow
|
|
5524
8069
|
* closes it. */
|
|
@@ -5546,6 +8091,37 @@ declare class XlsxViewer {
|
|
|
5546
8091
|
* collision (Excel allows at most one note per cell, so this is moot in
|
|
5547
8092
|
* practice). */
|
|
5548
8093
|
private buildCommentMap;
|
|
8094
|
+
/** IX1 — index the current sheet's hyperlinks by `"row:col"` (1-based, first
|
|
8095
|
+
* cell of the `ref` range) so a clicked/hovered cell resolves in O(1). Keys
|
|
8096
|
+
* match the renderer's `hyperlinkMap` exactly (`${hl.row}:${hl.col}`). */
|
|
8097
|
+
private buildHyperlinkMap;
|
|
8098
|
+
/** IX1 — the hyperlink at a cell, or null. `getCellAt` returns 1-based
|
|
8099
|
+
* {row,col}, matching the parser/renderer keying.
|
|
8100
|
+
*
|
|
8101
|
+
* Returns null unconditionally when `enableHyperlinks` is `false`: this is the
|
|
8102
|
+
* single gate that disables hyperlink interactivity. Both consumers — the
|
|
8103
|
+
* pointermove pointer-cursor affordance and the click dispatch
|
|
8104
|
+
* ({@link dispatchHyperlink}) — funnel through this hit-test, so a null result
|
|
8105
|
+
* means no cursor change, no default navigation, and no `onHyperlinkClick`. */
|
|
8106
|
+
private hyperlinkAtCell;
|
|
8107
|
+
/**
|
|
8108
|
+
* IX1 — dispatch a click on a hyperlinked cell. Builds a
|
|
8109
|
+
* {@link HyperlinkTarget} from the parsed hyperlink (external `url` wins over
|
|
8110
|
+
* internal `location`, matching Excel: a `<hyperlink>` carrying both navigates
|
|
8111
|
+
* to the external target) and routes it to the caller's `onHyperlinkClick`
|
|
8112
|
+
* (which fully owns behaviour) or the built-in default. Returns true when a
|
|
8113
|
+
* hyperlink was found and dispatched.
|
|
8114
|
+
*/
|
|
8115
|
+
private dispatchHyperlink;
|
|
8116
|
+
/**
|
|
8117
|
+
* IX1 default handler for an internal `location` target (§18.3.1.47): a defined
|
|
8118
|
+
* name or a cell ref like `Sheet1!A1`. Best-effort: if the part before `!`
|
|
8119
|
+
* names a sheet in the workbook, switch to it. There is no scroll-to-cell
|
|
8120
|
+
* primitive on this viewer, so the cell part is not yet honoured (switching the
|
|
8121
|
+
* sheet already lands the user on the right surface). A bare defined name that
|
|
8122
|
+
* does not resolve to a sheet is a documented no-op.
|
|
8123
|
+
*/
|
|
8124
|
+
private navigateInternalHyperlink;
|
|
5549
8125
|
/** Show the popup for the comment on `cell` after the hover dwell, anchored to
|
|
5550
8126
|
* the cell's current on-screen rect. No-op when the cell carries no comment.
|
|
5551
8127
|
* Re-hovering the same cell does not restart the timer. */
|
|
@@ -5580,10 +8156,46 @@ declare class XlsxViewer {
|
|
|
5580
8156
|
private zoomPosToScale;
|
|
5581
8157
|
/** Inverse of {@link zoomPosToScale}: scale factor → slider position [0,100]. */
|
|
5582
8158
|
private zoomScaleToPos;
|
|
5583
|
-
/**
|
|
5584
|
-
*
|
|
5585
|
-
*
|
|
8159
|
+
/**
|
|
8160
|
+
* IX9 {@link ZoomableViewer} — set the cell/header scale (`1` = 100%; the
|
|
8161
|
+
* viewer's `cellScale`) and re-lay-out the current sheet. Clamped to the zoom
|
|
8162
|
+
* bounds and snapped to whole percent; keeps the slider thumb, percentage label
|
|
8163
|
+
* and the row-header-aligned tab-nav width in sync, and fires `onScaleChange`
|
|
8164
|
+
* when the resolved scale actually changes.
|
|
8165
|
+
*/
|
|
5586
8166
|
setScale(scale: number): void;
|
|
8167
|
+
/** IX9 {@link ZoomableViewer} — the current zoom factor (`1` = 100%). This is
|
|
8168
|
+
* the viewer's `cellScale`; `1` before anything is set. */
|
|
8169
|
+
getScale(): number;
|
|
8170
|
+
/** IX9 {@link ZoomableViewer} — step up to the next rung of the shared zoom
|
|
8171
|
+
* ladder (clamped to `zoomMax` by {@link setScale}). */
|
|
8172
|
+
zoomIn(): void;
|
|
8173
|
+
/** IX9 {@link ZoomableViewer} — step down to the next lower ladder rung. */
|
|
8174
|
+
zoomOut(): void;
|
|
8175
|
+
/**
|
|
8176
|
+
* IX9 {@link ZoomableViewer} — fit the used data range's WIDTH to the canvas
|
|
8177
|
+
* area. The "content" is the natural (100%) width of the row header plus the
|
|
8178
|
+
* used columns; the container is `canvasArea.clientWidth`. A no-op (defers) when
|
|
8179
|
+
* nothing is loaded or the container is unlaid-out. Routes through
|
|
8180
|
+
* {@link setScale}, so the result is clamped/snapped and fires `onScaleChange`.
|
|
8181
|
+
*/
|
|
8182
|
+
fitWidth(): void;
|
|
8183
|
+
/**
|
|
8184
|
+
* IX9 {@link ZoomableViewer} — fit the used data range's WIDTH AND HEIGHT inside
|
|
8185
|
+
* the canvas area (header + used columns/rows), so the whole used range is
|
|
8186
|
+
* visible without scrolling. Takes the tighter of the width- and height-fit
|
|
8187
|
+
* factors. Defers when unloaded / unlaid-out; routes through {@link setScale}.
|
|
8188
|
+
*/
|
|
8189
|
+
fitPage(): void;
|
|
8190
|
+
/** Shared fit implementation for {@link fitWidth} / {@link fitPage}: derive the
|
|
8191
|
+
* natural (cs=1) content extent of the used data range, ask core's pure
|
|
8192
|
+
* {@link fitScale} for the factor, and apply it via {@link setScale}. */
|
|
8193
|
+
private _fit;
|
|
8194
|
+
/** Natural (unscaled, cs=1) CSS-px extent of a worksheet's used data range:
|
|
8195
|
+
* the row/column header plus every used column width / row height. Mirrors
|
|
8196
|
+
* {@link updateSpacerSize} at cs=1 (same used-range detection) so the fit
|
|
8197
|
+
* targets exactly the region the spacer/scroll extent covers. */
|
|
8198
|
+
private _naturalContentExtent;
|
|
5587
8199
|
private updateSpacerSize;
|
|
5588
8200
|
/**
|
|
5589
8201
|
* Coalesce a re-render into the next animation frame. Called from the
|
|
@@ -5599,6 +8211,11 @@ declare class XlsxViewer {
|
|
|
5599
8211
|
*/
|
|
5600
8212
|
private scheduleRender;
|
|
5601
8213
|
private renderCurrentSheet;
|
|
8214
|
+
/** Route a render failure to `onError`, or `console.error` when none is given
|
|
8215
|
+
* (never fully silent), and never after teardown. Mirrors the scroll viewers'
|
|
8216
|
+
* `_reportRenderError`. */
|
|
8217
|
+
private _reportRenderError;
|
|
8218
|
+
private _renderCurrentSheet;
|
|
5602
8219
|
private computeHeaderHighlight;
|
|
5603
8220
|
get sheetNames(): string[];
|
|
5604
8221
|
/** The underlying <canvas> element the grid is drawn on. */
|
|
@@ -5635,9 +8252,20 @@ declare interface XlsxViewerOptions extends LoadOptions_2 {
|
|
|
5635
8252
|
* own zoom control). */
|
|
5636
8253
|
showZoomSlider?: boolean;
|
|
5637
8254
|
/** Lower/upper bounds for the zoom slider as scale factors. Default 0.1–4
|
|
5638
|
-
* (10%–400%, matching Excel's zoom range).
|
|
8255
|
+
* (10%–400%, matching Excel's zoom range). Also the clamp range for the IX9
|
|
8256
|
+
* {@link ZoomableViewer} zoom contract ({@link XlsxViewer.setScale} etc.). */
|
|
5639
8257
|
zoomMin?: number;
|
|
5640
8258
|
zoomMax?: number;
|
|
8259
|
+
/**
|
|
8260
|
+
* IX9 — fires whenever the zoom factor actually changes (`1` = 100%), whatever
|
|
8261
|
+
* the source: {@link XlsxViewer.setScale}, {@link XlsxViewer.zoomIn} /
|
|
8262
|
+
* {@link XlsxViewer.zoomOut}, {@link XlsxViewer.fitWidth} /
|
|
8263
|
+
* {@link XlsxViewer.fitPage}, the built-in zoom slider, the +/- buttons, or a
|
|
8264
|
+
* Ctrl/⌘+wheel gesture. Named `onScaleChange` to match the docx/pptx viewers so
|
|
8265
|
+
* all five share one notification shape. Not fired when a call resolves to the
|
|
8266
|
+
* same (clamped/snapped) scale.
|
|
8267
|
+
*/
|
|
8268
|
+
onScaleChange?: (scale: number) => void;
|
|
5641
8269
|
onReady?: (sheetNames: string[]) => void;
|
|
5642
8270
|
/**
|
|
5643
8271
|
* Called when the active sheet changes, with the new sheet's zero-based
|
|
@@ -5651,6 +8279,23 @@ declare interface XlsxViewerOptions extends LoadOptions_2 {
|
|
|
5651
8279
|
onError?: (err: Error) => void;
|
|
5652
8280
|
/** Called when the selected cell range changes. null means no selection. */
|
|
5653
8281
|
onSelectionChange?: (selection: CellRange_2 | null) => void;
|
|
8282
|
+
/**
|
|
8283
|
+
* IX1 (design decision — NOT user-confirmed, integrator may veto). Fires when a
|
|
8284
|
+
* cell carrying a hyperlink (ECMA-376 §18.3.1.47) is clicked. Default when
|
|
8285
|
+
* omitted: external → {@link openExternalHyperlink} (new tab, sanitised,
|
|
8286
|
+
* noopener); internal (`location`) → navigate to the referenced sheet/cell
|
|
8287
|
+
* when resolvable. When supplied, this callback fully owns the behaviour and
|
|
8288
|
+
* receives the raw {@link HyperlinkTarget} verbatim (URL sanitisation is the
|
|
8289
|
+
* default handler's job, so a blocked scheme still reaches a custom callback).
|
|
8290
|
+
*/
|
|
8291
|
+
onHyperlinkClick?: (target: HyperlinkTarget) => void;
|
|
8292
|
+
/** IX1 — master switch for hyperlink interactivity. Default `true`. When
|
|
8293
|
+
* `false`, the cell hit-test reports no hyperlink under any cell, so hyperlink
|
|
8294
|
+
* interactivity is disabled entirely: no pointer cursor over a link, no default
|
|
8295
|
+
* navigation (external new-tab / internal sheet jump), and `onHyperlinkClick`
|
|
8296
|
+
* is never called. Hyperlinked cells still render exactly as authored but are
|
|
8297
|
+
* inert. */
|
|
8298
|
+
enableHyperlinks?: boolean;
|
|
5654
8299
|
/**
|
|
5655
8300
|
* Color of the cell-selection highlight. A single CSS color drives both the
|
|
5656
8301
|
* selection rectangle's border (drawn in this color) and its fill (the same
|
|
@@ -5709,6 +8354,12 @@ declare class XlsxWorkbook {
|
|
|
5709
8354
|
* `renderViewport` call reuses it — equations in shapes render when present,
|
|
5710
8355
|
* and are skipped (engine tree-shaken) when omitted. */
|
|
5711
8356
|
private math;
|
|
8357
|
+
/** Google-Fonts `FontFace` objects this workbook preloaded into `document.fonts`
|
|
8358
|
+
* (main mode only — in worker mode the worker owns them and terminates with its
|
|
8359
|
+
* own FontFaceSet). Released in {@link destroy} so they do not leak into the
|
|
8360
|
+
* shared FontFaceSet for the lifetime of the SPA (deduped + refcounted in core,
|
|
8361
|
+
* so a web font shared with another open workbook survives until both go). */
|
|
8362
|
+
private googleFontFaces;
|
|
5712
8363
|
private _mode;
|
|
5713
8364
|
private constructor();
|
|
5714
8365
|
/** Parse an XLSX from a URL or ArrayBuffer. */
|
|
@@ -5748,6 +8399,22 @@ declare class XlsxWorkbook {
|
|
|
5748
8399
|
* route-through-worker decision).
|
|
5749
8400
|
*/
|
|
5750
8401
|
getImage(imagePath: string, mimeType: string): Promise<Blob>;
|
|
8402
|
+
/**
|
|
8403
|
+
* Project the workbook to GitHub-flavoured markdown: each sheet becomes a
|
|
8404
|
+
* `## SheetName` section followed by a pipe table of its populated bounding
|
|
8405
|
+
* box (fully-empty middle rows trimmed, ULP noise masked). Styling, charts,
|
|
8406
|
+
* and drawings are discarded — the projection is meant for AI ingestion and
|
|
8407
|
+
* full-text search, not layout.
|
|
8408
|
+
*
|
|
8409
|
+
* Runs entirely in the worker off the archive opened at {@link load} (no
|
|
8410
|
+
* re-copy of the file, no re-parse of the model on the main thread), so it
|
|
8411
|
+
* works in BOTH `mode: 'main'` and `mode: 'worker'`.
|
|
8412
|
+
*
|
|
8413
|
+
* @example
|
|
8414
|
+
* const wb = await XlsxWorkbook.load(buffer);
|
|
8415
|
+
* const md = await wb.toMarkdown();
|
|
8416
|
+
*/
|
|
8417
|
+
toMarkdown(): Promise<string>;
|
|
5751
8418
|
/**
|
|
5752
8419
|
* Resolve a `list`-type data-validation `formula1` (ECMA-376 §18.3.1.32) into
|
|
5753
8420
|
* the set of allowed values to display, evaluated relative to `sheetIndex`
|
|
@@ -5764,6 +8431,24 @@ declare class XlsxWorkbook {
|
|
|
5764
8431
|
* Read-only: this only reads cell values for display; it never writes.
|
|
5765
8432
|
*/
|
|
5766
8433
|
resolveValidationList(sheetIndex: number, formula1: string | undefined): Promise<ResolvedList>;
|
|
8434
|
+
/**
|
|
8435
|
+
* IX2 — the display string a cell shows on the grid, i.e. exactly what
|
|
8436
|
+
* {@link renderViewport} would draw (number formats, dates, booleans, rich
|
|
8437
|
+
* text flattened). Used by {@link XlsxViewer.findText} to search the *rendered*
|
|
8438
|
+
* text rather than the raw stored value, so a search matches what the user
|
|
8439
|
+
* sees. Threads the workbook styles + the sheet's date system through the
|
|
8440
|
+
* shared {@link formatCellValue} (the same call the renderer and
|
|
8441
|
+
* validation-list expansion use). Returns `''` before the workbook is loaded.
|
|
8442
|
+
*/
|
|
8443
|
+
cellText(ws: Worksheet, cell: Cell): string;
|
|
8444
|
+
/**
|
|
8445
|
+
* Render a sheet viewport into `target`. Note: `opts.fetchImage` is ignored
|
|
8446
|
+
* here — image bytes always come from this workbook's own archive through its
|
|
8447
|
+
* stable per-instance loader, whose closure identity keys the shared decoded
|
|
8448
|
+
* caches, the render-pass lease, and {@link destroy}'s cache drops. Callers
|
|
8449
|
+
* needing a custom byte source should use the standalone
|
|
8450
|
+
* `renderWorksheetViewport` orchestrator directly.
|
|
8451
|
+
*/
|
|
5767
8452
|
renderViewport(target: HTMLCanvasElement | OffscreenCanvas, sheetIndex: number, viewport: ViewportRange, opts?: RenderViewportOptions): Promise<void>;
|
|
5768
8453
|
/**
|
|
5769
8454
|
* Render a sheet viewport and return it as an ImageBitmap (both modes; in
|
|
@@ -5783,4 +8468,90 @@ declare class XlsxWorkbook {
|
|
|
5783
8468
|
destroy(): void;
|
|
5784
8469
|
}
|
|
5785
8470
|
|
|
8471
|
+
/**
|
|
8472
|
+
* IX9 — the shared zoom API contract for every viewer (DocxViewer, PptxViewer,
|
|
8473
|
+
* DocxScrollViewer, PptxScrollViewer, XlsxViewer).
|
|
8474
|
+
*
|
|
8475
|
+
* This module owns ONLY the pure, DOM-free pieces of the contract: the type
|
|
8476
|
+
* ({@link ZoomableViewer}), the discrete zoom-step ladder ({@link nextZoomStep} /
|
|
8477
|
+
* {@link prevZoomStep}), the fit-to-content scale math ({@link fitScale}), and the
|
|
8478
|
+
* range clamp ({@link clampScale}). Each viewer implements the interface with its
|
|
8479
|
+
* own scale field and re-render path; this keeps ONE definition of "what a zoom
|
|
8480
|
+
* factor means" and "what the +/- steps are" across all five, so a host can drive
|
|
8481
|
+
* any viewer through the same six calls without special-casing the format.
|
|
8482
|
+
*
|
|
8483
|
+
* SCALE SEMANTICS (the contract): a scale of `1` means 100% — the content at its
|
|
8484
|
+
* natural size (a docx page at `widthPt × PT_TO_PX`, a pptx slide at
|
|
8485
|
+
* `slideWidth / EMU_PER_PX`, an xlsx grid at `cellScale` 1). `getScale()` and
|
|
8486
|
+
* `setScale(n)` speak this user-facing factor for EVERY viewer.
|
|
8487
|
+
*
|
|
8488
|
+
* KNOWN FAMILY DIFFERENCE — the INITIAL scale right after load (deliberate,
|
|
8489
|
+
* documented rather than papered over): the single-canvas viewers (DocxViewer /
|
|
8490
|
+
* PptxViewer) and XlsxViewer start at `1` (or the effective factor implied by an
|
|
8491
|
+
* explicit `width` option); the continuous-scroll viewers (DocxScrollViewer /
|
|
8492
|
+
* PptxScrollViewer) AUTO-FIT to the container on first layout, so their
|
|
8493
|
+
* `getScale()` right after load reports the fit-to-width BASE factor (≠ 1 unless
|
|
8494
|
+
* the container happens to match the natural width). The unit is identical — only
|
|
8495
|
+
* the starting point differs, because fit-to-width is the natural resting state
|
|
8496
|
+
* of a continuous document viewer.
|
|
8497
|
+
*
|
|
8498
|
+
* PRE-LOAD `setScale` (family-unified, IX9 F1): a `setScale` called before the
|
|
8499
|
+
* content is loaded / before the layout is established is LATCHED — never
|
|
8500
|
+
* silently dropped — and applied once the viewer establishes its scale (the
|
|
8501
|
+
* single-canvas viewers honour it on the first render; the scroll viewers apply
|
|
8502
|
+
* it right after the base fit establishes, firing `onScaleChange` at application
|
|
8503
|
+
* time). `getScale()` reports the latched factor while it is pending.
|
|
8504
|
+
*
|
|
8505
|
+
* API SHAPE (idiomatic default — the integrator MAY veto; see the IX9 PR): a
|
|
8506
|
+
* six-method surface plus one change notification (`onScaleChange`). Deliberately
|
|
8507
|
+
* NO new UI here — the contract is API only (design decision IX9 §4). Touch-pinch
|
|
8508
|
+
* (IX8) is out of scope.
|
|
8509
|
+
*/
|
|
8510
|
+
/**
|
|
8511
|
+
* The zoom contract every viewer satisfies. All scales are the user-facing factor
|
|
8512
|
+
* where `1` = 100% (see the module note). `fitWidth`/`fitPage` are async because a
|
|
8513
|
+
* fit re-renders at the new scale; the getters/steppers resolve synchronously.
|
|
8514
|
+
*/
|
|
8515
|
+
declare interface ZoomableViewer {
|
|
8516
|
+
/** The current zoom factor (`1` = 100%). Never throws — returns the default
|
|
8517
|
+
* (`1`) before anything is loaded, or the latched pending factor when a
|
|
8518
|
+
* pre-load `setScale` is waiting to be applied (see the module note). */
|
|
8519
|
+
getScale(): number;
|
|
8520
|
+
/** Set the absolute zoom factor (`1` = 100%), clamped to the viewer's
|
|
8521
|
+
* `[zoomMin, zoomMax]`. Re-renders at the new scale and fires `onScaleChange`
|
|
8522
|
+
* when the clamped value actually changes. Called BEFORE the content is
|
|
8523
|
+
* loaded / the layout is established, the (clamped) factor is LATCHED and
|
|
8524
|
+
* applied once the viewer establishes its scale — family-unified semantics
|
|
8525
|
+
* (IX9 F1): never silently dropped by any viewer. */
|
|
8526
|
+
setScale(scale: number): void | Promise<void>;
|
|
8527
|
+
/** Step up to the next larger rung of the shared zoom ladder (25 %→400 %),
|
|
8528
|
+
* clamped to `zoomMax`. Equivalent to `setScale(nextZoomStep(getScale()))`. */
|
|
8529
|
+
zoomIn(): void | Promise<void>;
|
|
8530
|
+
/** Step down to the next smaller ladder rung, clamped to `zoomMin`. */
|
|
8531
|
+
zoomOut(): void | Promise<void>;
|
|
8532
|
+
/** Fit the content's WIDTH to the container (the common "fit width" / "fit
|
|
8533
|
+
* page width" verb). Sets the scale so one page/slide/sheet-column-run spans
|
|
8534
|
+
* the available width, then re-renders. Resolves once the fit render settles.
|
|
8535
|
+
*
|
|
8536
|
+
* PERSISTENCE is viewer-implementation-dependent (deliberate, by family): the
|
|
8537
|
+
* single-canvas viewers (DocxViewer / PptxViewer) and XlsxViewer apply the fit
|
|
8538
|
+
* ONE-SHOT — they observe no container resizes, so a later resize does NOT
|
|
8539
|
+
* re-fit (call `fitWidth()` again after a layout change). The continuous-
|
|
8540
|
+
* scroll viewers (DocxScrollViewer / PptxScrollViewer) re-fit their width-fit
|
|
8541
|
+
* base on every container resize, so a `fitWidth()` there effectively
|
|
8542
|
+
* PERSISTS across resizes (the resize re-fit preserves the width-fit state). */
|
|
8543
|
+
fitWidth(): void | Promise<void>;
|
|
8544
|
+
/** Fit the WHOLE content (width AND height) inside the container, so an entire
|
|
8545
|
+
* page/slide is visible without scrolling. Sets the scale to the smaller of the
|
|
8546
|
+
* width- and height-fit factors, then re-renders.
|
|
8547
|
+
*
|
|
8548
|
+
* PERSISTENCE is viewer-implementation-dependent, and — unlike `fitWidth` —
|
|
8549
|
+
* a page fit does NOT persist across container resizes on ANY viewer: the
|
|
8550
|
+
* single-canvas viewers and XlsxViewer observe no resizes at all (one-shot),
|
|
8551
|
+
* and the continuous-scroll viewers' resize handler re-applies the WIDTH fit
|
|
8552
|
+
* (preserving the zoom multiplier), not the page fit. Re-invoke `fitPage()`
|
|
8553
|
+
* after a layout change to re-fit. */
|
|
8554
|
+
fitPage(): void | Promise<void>;
|
|
8555
|
+
}
|
|
8556
|
+
|
|
5786
8557
|
export { }
|