@silurus/ooxml 0.78.1 → 0.79.1
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 +39 -1
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/dist/{canvas-viewer-mechanics-B4K_t5X_.js → canvas-viewer-mechanics-DJ9yfiLN.js} +1 -1
- package/dist/chart-number-format-tjYUR9eS.js +435 -0
- package/dist/dash-CMzZIDz_.js +824 -0
- package/dist/{document-pull-client-5AakVD6e.js → document-pull-client-DYoybVCn.js} +2119 -2113
- package/dist/{docx-bjhRwb2u.js → docx-CSk_-kj_.js} +65 -56
- package/dist/docx.mjs +4 -4
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/index.mjs +3 -3
- package/dist/{line-distribute-BVFW1-Hs.js → line-distribute-CU7vu7XS.js} +1 -1
- package/dist/{line-metrics-DS0NS2Iq.js → line-metrics-A77J_KRx.js} +4229 -3233
- package/dist/math.mjs +1 -1
- package/dist/node.mjs +322 -322
- package/dist/{pptx-D1rCrHGR.js → pptx-CO1Ut97p.js} +192 -183
- package/dist/pptx.mjs +5 -5
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/region-map.mjs +12708 -0
- package/dist/{render-DhlT5jxZ.js → render-C5m7Ddwx.js} +1 -1
- package/dist/render-worker-host-BhMT5U73.js +27 -0
- package/dist/render-worker-host-DNMxGh5s.js +27 -0
- package/dist/render-worker-host-DWyg7wio.js +27 -0
- package/dist/{resource-measurement-BA-4Q-II.js → resource-measurement-COxqtfGk.js} +1 -1
- package/dist/{session-C_HGxbRD.js → session-CJwZaquG.js} +10 -10
- package/dist/{slide-pull-client-BiC4sVGi.js → slide-pull-client-CFHNk0ek.js} +584 -583
- package/dist/three-d.mjs +2426 -0
- package/dist/types/docx.d.ts +251 -16
- package/dist/types/index.d.ts +266 -20
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +225 -1
- package/dist/types/pptx.d.ts +253 -16
- package/dist/types/region-map.d.ts +586 -0
- package/dist/types/three-d.d.ts +586 -0
- package/dist/types/xlsx.d.ts +256 -16
- package/dist/{worksheet-pull-client-BnvgeqfG.js → worksheet-pull-client-CziyJf24.js} +13 -13
- package/dist/{xlsx-BG_WYSc0.js → xlsx-DHQmjAfh.js} +1246 -1073
- package/dist/xlsx.mjs +5 -5
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +13 -1
- package/dist/render-worker-host-CtJo7hc9.js +0 -27
- package/dist/render-worker-host-D8vv-Asx.js +0 -27
- package/dist/render-worker-host-DAjG9nmw.js +0 -27
- /package/dist/{highlight-rect-CAkCWJ37.js → highlight-rect-cCvVU-MW.js} +0 -0
- /package/dist/{mathjax-CMjda8Ip.js → mathjax-Dqo857oC.js} +0 -0
- /package/dist/{transfer-DCu4c2BL.js → transfer-3QEJrsJa.js} +0 -0
- /package/dist/{visible-index-CgyJLAS_.js → visible-index-CKvgpUrf.js} +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import { B as t, Et as n, It as r, Lt as i, R as a, a as o,
|
|
3
|
-
import { C as
|
|
2
|
+
import { B as t, Et as n, It as r, Lt as i, R as a, a as o, ht as s, it as c, kt as l, on as u, q as d, sn as f, z as p } from "./line-metrics-A77J_KRx.js";
|
|
3
|
+
import { C as m, E as h, S as g, T as _, _ as v, a as y, b, c as x, d as ee, f as te, g as ne, h as re, i as S, l as C, m as ie, n as ae, o as oe, p as se, r as ce, s as le, t as ue, u as de, v as w, w as fe, x as pe, y as T } from "./canvas-viewer-mechanics-DJ9yfiLN.js";
|
|
4
4
|
import { a as me, c as he, i as ge, o as _e, r as ve, s as ye, t as be } from "./bounded-raw-part-cache-C6ro6Ezf.js";
|
|
5
|
-
import { C as xe, S as Se, _ as
|
|
6
|
-
import {
|
|
5
|
+
import { C as xe, S as Se, _ as E, a as Ce, b as we, c as Te, d as Ee, f as De, g as Oe, h as ke, l as Ae, m as je, n as D, o as Me, p as Ne, s as Pe, t as O, v as k, w as Fe, x as A, y as Ie } from "./document-pull-client-DYoybVCn.js";
|
|
6
|
+
import { S as j } from "./dash-CMzZIDz_.js";
|
|
7
|
+
import { n as Le, r as M, t as N } from "./highlight-rect-cCvVU-MW.js";
|
|
7
8
|
//#region packages/core/src/fonts/embedded.ts
|
|
8
9
|
function Re(e, t) {
|
|
9
10
|
let n = ze(t), r = e.slice(), i = Math.min(32, r.length);
|
|
@@ -177,16 +178,16 @@ function $e(e) {
|
|
|
177
178
|
}
|
|
178
179
|
function et(e) {
|
|
179
180
|
let t = $e(e), n = [
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
k(e.pointToPage, t),
|
|
182
|
+
k(e.pointToPage, {
|
|
182
183
|
xPt: t.xPt + t.widthPt,
|
|
183
184
|
yPt: t.yPt
|
|
184
185
|
}),
|
|
185
|
-
|
|
186
|
+
k(e.pointToPage, {
|
|
186
187
|
xPt: t.xPt,
|
|
187
188
|
yPt: t.yPt + t.heightPt
|
|
188
189
|
}),
|
|
189
|
-
|
|
190
|
+
k(e.pointToPage, {
|
|
190
191
|
xPt: t.xPt + t.widthPt,
|
|
191
192
|
yPt: t.yPt + t.heightPt
|
|
192
193
|
})
|
|
@@ -214,7 +215,7 @@ function nt(e, t) {
|
|
|
214
215
|
}
|
|
215
216
|
function rt(e, t, n) {
|
|
216
217
|
for (let n of e.clips) {
|
|
217
|
-
let e =
|
|
218
|
+
let e = E(n.pointToPage, t);
|
|
218
219
|
if (!e || !B(n.bounds, e)) return !1;
|
|
219
220
|
}
|
|
220
221
|
return "drawing" in e ? nt(e.drawing, n) : B(e.placement.bounds, n);
|
|
@@ -262,7 +263,7 @@ function ot(e, t, n, r, i = {}) {
|
|
|
262
263
|
if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
|
|
263
264
|
let a = z(i.maxTextCharacters), o = Oe(e, t);
|
|
264
265
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
265
|
-
let i = o[e], s =
|
|
266
|
+
let i = o[e], s = E(i.pointToPage, n);
|
|
266
267
|
if (!s || !rt(i, n, s)) continue;
|
|
267
268
|
let c = at(i, t, e, n, r, a);
|
|
268
269
|
if (c) return c;
|
|
@@ -295,21 +296,23 @@ var U = class e {
|
|
|
295
296
|
_meta = null;
|
|
296
297
|
_bookmarkPages = null;
|
|
297
298
|
_mode = "main";
|
|
299
|
+
_threeD;
|
|
300
|
+
_regionMap;
|
|
298
301
|
_worker;
|
|
299
302
|
_bridge;
|
|
300
303
|
_rawParts = new be({
|
|
301
304
|
maxEntries: 64,
|
|
302
|
-
maxBytes:
|
|
305
|
+
maxBytes: d
|
|
303
306
|
});
|
|
304
307
|
_embeddedFontFaces = [];
|
|
305
308
|
_googleFontFaces = [];
|
|
306
309
|
_localMetricFontFaces = [];
|
|
307
310
|
_fetchImage = (e, t) => this.getImage(e, t);
|
|
308
311
|
constructor(e, t, n, r) {
|
|
309
|
-
this._worker = e, this._mode = t, we(this, n), this._bridge = new
|
|
312
|
+
this._worker = e, this._mode = t, we(this, n), this._bridge = new m(this._worker, {
|
|
310
313
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
311
314
|
toError: (e) => {
|
|
312
|
-
if (!("protocol" in e || e.type !== "error")) return Object.assign(
|
|
315
|
+
if (!("protocol" in e || e.type !== "error")) return Object.assign(c(e), {
|
|
313
316
|
...e.reason === void 0 ? {} : { reason: e.reason },
|
|
314
317
|
...e.outgoingColumnIndex === void 0 ? {} : { outgoingColumnIndex: e.outgoingColumnIndex },
|
|
315
318
|
...e.outgoingColumnCount === void 0 ? {} : { outgoingColumnCount: e.outgoingColumnCount },
|
|
@@ -340,10 +343,10 @@ var U = class e {
|
|
|
340
343
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
341
344
|
t = await e.arrayBuffer();
|
|
342
345
|
} else t = n;
|
|
343
|
-
t =
|
|
344
|
-
let a = s === "worker" ? (await import("./render-worker-host-
|
|
346
|
+
t = h(await _(t, r.password)), c.setSourceBytes(t.byteLength), c.checkpoint("container ready");
|
|
347
|
+
let a = s === "worker" ? (await import("./render-worker-host-DWyg7wio.js")).createRenderWorker() : new Ue(), l;
|
|
345
348
|
try {
|
|
346
|
-
if (l = new e(a, s, o, r.wasmUrl), l._metrics = c, await l._parse(t, i.policy, s === "worker" ? !!r.useGoogleFonts : !1, r.workerTimeoutMs, (e) => c.observeUsage(e)), s === "worker" && l._mode === "main" && (c.setMode("main"), console.warn("[ooxml] mode: 'worker' fell back to main-thread rendering because this document requires DOM OpenType vertical glyph selection.")), r.math && l._mode === "worker" && console.warn("[ooxml] the math engine is unavailable in mode: 'worker'; equations will be skipped. Use mode: 'main' for documents with equations."), l._mode === "main" && r.useGoogleFonts && l._document && (l._googleFontFaces = await ge(Ne(l._document), De)), l._mode === "main" && l._document?.embeddedFonts?.length) {
|
|
349
|
+
if (l = new e(a, s, o, r.wasmUrl), l._metrics = c, await l._parse(t, i.policy, s === "worker" ? !!r.useGoogleFonts : !1, r.workerTimeoutMs, (e) => c.observeUsage(e)), s === "worker" && l._mode === "main" && (c.setMode("main"), console.warn("[ooxml] mode: 'worker' fell back to main-thread rendering because this document requires DOM OpenType vertical glyph selection.")), r.math && l._mode === "worker" && console.warn("[ooxml] the math engine is unavailable in mode: 'worker'; equations will be skipped. Use mode: 'main' for documents with equations."), r.threeD && l._mode === "worker" && console.warn("[ooxml] the 3-D chart addon is unavailable in mode: 'worker'; charts use their 2-D family fallback. Use mode: 'main' for authored 3-D charts."), l._threeD = l._mode === "worker" ? void 0 : r.threeD, r.regionMap && l._mode === "worker" && console.warn("[ooxml] the Region Map addon is unavailable in mode: 'worker'; geospatial charts use the unsupported-chart placeholder. Use mode: 'main' for Region Maps."), l._regionMap = l._mode === "worker" ? void 0 : r.regionMap, l._mode === "main" && r.useGoogleFonts && l._document && (l._googleFontFaces = await ge(Ne(l._document), De)), l._mode === "main" && l._document?.embeddedFonts?.length) {
|
|
347
350
|
let e = l;
|
|
348
351
|
l._embeddedFontFaces = await Ke(l._document, (t) => e.getFontBytes(t));
|
|
349
352
|
}
|
|
@@ -351,7 +354,7 @@ var U = class e {
|
|
|
351
354
|
l._mode === "main" && l._document && (n = await Ee(l._document), l._localMetricFontFaces = n.faces);
|
|
352
355
|
let u;
|
|
353
356
|
if (l._mode === "main" && r.math && l._document && Me(l._document) && (u = await Pe(l._document, r.math)), l._mode === "main" && l._document && l._source) {
|
|
354
|
-
let e =
|
|
357
|
+
let e = A(l);
|
|
355
358
|
e.services = Ae(l._source, {
|
|
356
359
|
localMetrics: n?.metrics,
|
|
357
360
|
useGoogleFonts: !!r.useGoogleFonts,
|
|
@@ -366,7 +369,7 @@ var U = class e {
|
|
|
366
369
|
return await l._resourceUsage(r.workerTimeoutMs ?? 1e3).then((e) => c.observeUsage(e), () => void 0), c.checkpoint("model and layout ready"), c.succeed({ pages: l.pageCount }), l;
|
|
367
370
|
} catch (e) {
|
|
368
371
|
let t = l;
|
|
369
|
-
throw
|
|
372
|
+
throw g(a, t ? () => t.destroy() : void 0), e;
|
|
370
373
|
}
|
|
371
374
|
} catch (e) {
|
|
372
375
|
throw c.fail(e), e;
|
|
@@ -379,7 +382,7 @@ var U = class e {
|
|
|
379
382
|
data: e,
|
|
380
383
|
resourcePolicy: t,
|
|
381
384
|
useGoogleFonts: n,
|
|
382
|
-
defaultCurrentDateMs:
|
|
385
|
+
defaultCurrentDateMs: A(this).defaultCurrentDateMs
|
|
383
386
|
} : {
|
|
384
387
|
type: "parse",
|
|
385
388
|
id: r,
|
|
@@ -388,14 +391,14 @@ var U = class e {
|
|
|
388
391
|
}, [e], { timeoutMs: r });
|
|
389
392
|
if ("protocol" in a) throw Error("DOCX parse open returned a pull-protocol response");
|
|
390
393
|
if (this._mode === "worker") if ("usage" in a && a.usage && i?.(a.usage), a.type === "mainThreadVerticalFallback") {
|
|
391
|
-
let e = await
|
|
394
|
+
let e = await D(this._bridge.transport(O), a, {
|
|
392
395
|
timeoutMs: r,
|
|
393
396
|
onUsage: i
|
|
394
397
|
});
|
|
395
398
|
this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
|
|
396
399
|
} else this._meta = a.meta;
|
|
397
400
|
else {
|
|
398
|
-
let e = a, t = await
|
|
401
|
+
let e = a, t = await D(this._bridge.transport(O), e, {
|
|
399
402
|
timeoutMs: r,
|
|
400
403
|
onUsage: i
|
|
401
404
|
});
|
|
@@ -403,7 +406,7 @@ var U = class e {
|
|
|
403
406
|
}
|
|
404
407
|
}
|
|
405
408
|
destroy() {
|
|
406
|
-
this._bridge.terminate(), this._document = null, this._source = null, this._meta = null,
|
|
409
|
+
this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, A(this).services = null, this._bookmarkPages = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (He(this._embeddedFontFaces), this._embeddedFontFaces = []), this._googleFontFaces.length > 0 && (me(this._googleFontFaces), this._googleFontFaces = []), this._localMetricFontFaces.length > 0 && (Fe(this._localMetricFontFaces), this._localMetricFontFaces = []), l(this._fetchImage), n(this._fetchImage);
|
|
407
410
|
}
|
|
408
411
|
async getImage(e, t) {
|
|
409
412
|
return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
|
|
@@ -432,7 +435,7 @@ var U = class e {
|
|
|
432
435
|
async getResourceMetrics() {
|
|
433
436
|
let e = this._metrics;
|
|
434
437
|
if (!e) throw Error("Document not loaded");
|
|
435
|
-
return
|
|
438
|
+
return p(e, (e) => this._resourceUsage(e));
|
|
436
439
|
}
|
|
437
440
|
async toMarkdown() {
|
|
438
441
|
return (await this._bridge.request((e) => ({
|
|
@@ -462,7 +465,7 @@ var U = class e {
|
|
|
462
465
|
}
|
|
463
466
|
_getLayout() {
|
|
464
467
|
if (!this._document) return null;
|
|
465
|
-
let e =
|
|
468
|
+
let e = A(this).services;
|
|
466
469
|
if (!e) throw Error("Document layout services are not initialized");
|
|
467
470
|
let t = Se(e);
|
|
468
471
|
if (!t) throw Error("Document layout variant store is not initialized");
|
|
@@ -509,14 +512,16 @@ var U = class e {
|
|
|
509
512
|
return Te(this._source, e, t, {
|
|
510
513
|
...n,
|
|
511
514
|
fetchImage: this._fetchImage,
|
|
512
|
-
layoutServices:
|
|
513
|
-
defaultCurrentDateMs:
|
|
515
|
+
layoutServices: A(this).services ?? void 0,
|
|
516
|
+
defaultCurrentDateMs: A(this).defaultCurrentDateMs,
|
|
517
|
+
threeD: this._threeD,
|
|
518
|
+
regionMap: this._regionMap
|
|
514
519
|
});
|
|
515
520
|
}
|
|
516
521
|
async renderPageToBitmap(e, t = {}) {
|
|
517
522
|
let { onTextRun: n, ...r } = t, i = {
|
|
518
523
|
...r,
|
|
519
|
-
dpr: r.dpr ??
|
|
524
|
+
dpr: r.dpr ?? s()
|
|
520
525
|
};
|
|
521
526
|
if (this._mode === "worker") {
|
|
522
527
|
let t = await this._bridge.request((t) => ({
|
|
@@ -542,7 +547,7 @@ var U = class e {
|
|
|
542
547
|
pageIndex: e,
|
|
543
548
|
opts: n
|
|
544
549
|
}))).runs;
|
|
545
|
-
let r =
|
|
550
|
+
let r = A(this), i = r.services;
|
|
546
551
|
if (!i) throw Error("Document layout services are not initialized");
|
|
547
552
|
return ke(i, e, {
|
|
548
553
|
currentDate: n.currentDate,
|
|
@@ -558,7 +563,7 @@ var U = class e {
|
|
|
558
563
|
point: t,
|
|
559
564
|
opts: n
|
|
560
565
|
}))).context;
|
|
561
|
-
let r =
|
|
566
|
+
let r = A(this), i = r.services;
|
|
562
567
|
if (!i) throw Error("Document layout services are not initialized");
|
|
563
568
|
return st(i, e, t, {
|
|
564
569
|
...n,
|
|
@@ -806,13 +811,13 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
806
811
|
constructor(e, t = {}) {
|
|
807
812
|
this._canvas = e, this._opts = t;
|
|
808
813
|
let n = t[Q];
|
|
809
|
-
this._borrowed = n !== void 0, this._mode =
|
|
814
|
+
this._borrowed = n !== void 0, this._mode = C("DocxViewer", t.mode, n), this._documentOwner = new y("DocxViewer", n ?? null, !1);
|
|
810
815
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
811
816
|
if (!r) throw Error("DocxViewer requires a canvas with an active Window");
|
|
812
817
|
this._hostWindow = r, this._canvasMount = new ue(e, {
|
|
813
818
|
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
814
819
|
forceDisplayBlock: !0
|
|
815
|
-
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new
|
|
820
|
+
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new S(e, this._mode === "worker"), this._errorRouter = new ce("DocxViewer", t.onError);
|
|
816
821
|
let i = new ae(this._wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
|
|
817
822
|
this._textLayer = i.textLayer, this._highlightLayer = i.highlightLayer, this._elementLayer = i.elementLayer, this._textLayer && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
818
823
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
@@ -833,6 +838,8 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
833
838
|
workerTimeoutMs: this._opts.workerTimeoutMs,
|
|
834
839
|
wasmUrl: this._opts.wasmUrl,
|
|
835
840
|
math: this._opts.math,
|
|
841
|
+
threeD: this._opts.threeD,
|
|
842
|
+
regionMap: this._opts.regionMap,
|
|
836
843
|
mode: this._mode
|
|
837
844
|
}), () => {
|
|
838
845
|
this._invalidateElementContext(!1), t = !0, this._renderDispatcher.begin(), this._find.invalidate();
|
|
@@ -865,7 +872,7 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
865
872
|
await this.goToPage(this._currentPage - 1);
|
|
866
873
|
}
|
|
867
874
|
_naturalWidthPx() {
|
|
868
|
-
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt *
|
|
875
|
+
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt * j;
|
|
869
876
|
}
|
|
870
877
|
_renderWidth() {
|
|
871
878
|
if (this._scale === null) return this._opts.width;
|
|
@@ -888,10 +895,10 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
888
895
|
this._scale = t, await this._render(), n && this._opts.onScaleChange?.(t);
|
|
889
896
|
}
|
|
890
897
|
async zoomIn() {
|
|
891
|
-
await this.setScale(
|
|
898
|
+
await this.setScale(w(this.getScale()));
|
|
892
899
|
}
|
|
893
900
|
async zoomOut() {
|
|
894
|
-
await this.setScale(
|
|
901
|
+
await this.setScale(T(this.getScale()));
|
|
895
902
|
}
|
|
896
903
|
async fitWidth() {
|
|
897
904
|
await this._fit("width");
|
|
@@ -903,9 +910,9 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
903
910
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
904
911
|
let t = this._doc.pageSize(this._currentPage), n = this._fitContainer();
|
|
905
912
|
if (!n) return;
|
|
906
|
-
let r =
|
|
907
|
-
contentWidth: t.widthPt *
|
|
908
|
-
contentHeight: t.heightPt *
|
|
913
|
+
let r = v({
|
|
914
|
+
contentWidth: t.widthPt * j,
|
|
915
|
+
contentHeight: t.heightPt * j,
|
|
909
916
|
containerWidth: n.clientWidth,
|
|
910
917
|
containerHeight: n.clientHeight
|
|
911
918
|
}, e);
|
|
@@ -958,11 +965,11 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
958
965
|
_redrawElementOutline() {
|
|
959
966
|
let e = this._elementContext, t = this._doc;
|
|
960
967
|
if (!e || !t || e.pageIndex !== this._currentPage) {
|
|
961
|
-
|
|
968
|
+
x(this._elementLayer, null);
|
|
962
969
|
return;
|
|
963
970
|
}
|
|
964
971
|
let n = t.pageSize(e.pageIndex);
|
|
965
|
-
|
|
972
|
+
x(this._elementLayer, {
|
|
966
973
|
x: e.bounds.xPt / n.widthPt,
|
|
967
974
|
y: e.bounds.yPt / n.heightPt,
|
|
968
975
|
width: e.bounds.widthPt / n.widthPt,
|
|
@@ -1127,7 +1134,7 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1127
1134
|
if (e.tagName === "CANVAS") throw Error("DocxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-page canvas API use DocxViewer.");
|
|
1128
1135
|
this._container = e, this._opts = t, this._pageShadow = t.pageShadow ?? ft;
|
|
1129
1136
|
let n = t[pt];
|
|
1130
|
-
this._borrowed = n !== void 0, n ? (this._documentOwner = new
|
|
1137
|
+
this._borrowed = n !== void 0, n ? (this._documentOwner = new y("DocxScrollViewer", n, !1), this._mode = C("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new y("DocxScrollViewer"), this._mode = C("DocxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), t.enableTextSelection && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
1131
1138
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1132
1139
|
}, this._scrollHost.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._scrollHost.addEventListener("contextmenu", this._contextMenuListener)), this._scrollListener = () => this._onScroll(), this._scrollHost.addEventListener("scroll", this._scrollListener), this._opts.enableZoom !== !1 && (this._wheelListener = (e) => {
|
|
1133
1140
|
if (!(e.ctrlKey || e.metaKey) || (e.preventDefault(), e.deltaY === 0)) return;
|
|
@@ -1153,6 +1160,8 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1153
1160
|
workerTimeoutMs: this._opts.workerTimeoutMs,
|
|
1154
1161
|
wasmUrl: this._opts.wasmUrl,
|
|
1155
1162
|
math: this._opts.math,
|
|
1163
|
+
threeD: this._opts.threeD,
|
|
1164
|
+
regionMap: this._opts.regionMap,
|
|
1156
1165
|
mode: this._mode
|
|
1157
1166
|
}), (e) => {
|
|
1158
1167
|
if (this._invalidateElementContext(!1), t = !0, this._find.invalidate(), this._findActive = !1, e) {
|
|
@@ -1173,10 +1182,10 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1173
1182
|
return this._doc?.pageCount ?? 0;
|
|
1174
1183
|
}
|
|
1175
1184
|
_pageWidthPx(e) {
|
|
1176
|
-
return this._doc.pageSize(e).widthPt *
|
|
1185
|
+
return this._doc.pageSize(e).widthPt * j * this._scale;
|
|
1177
1186
|
}
|
|
1178
1187
|
_pageHeightPx(e) {
|
|
1179
|
-
return this._doc.pageSize(e).heightPt *
|
|
1188
|
+
return this._doc.pageSize(e).heightPt * j * this._scale;
|
|
1180
1189
|
}
|
|
1181
1190
|
_fitWidthPx() {
|
|
1182
1191
|
if (this._opts.width && this._opts.width > 0) return this._opts.width;
|
|
@@ -1190,7 +1199,7 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1190
1199
|
let e = this._fitWidthPx();
|
|
1191
1200
|
if (e <= 0) return 0;
|
|
1192
1201
|
let t = this._doc.pageSize(0).widthPt;
|
|
1193
|
-
return t <= 0 ? 0 : e / (t *
|
|
1202
|
+
return t <= 0 ? 0 : e / (t * j);
|
|
1194
1203
|
}
|
|
1195
1204
|
relayout() {
|
|
1196
1205
|
this._relayout();
|
|
@@ -1297,11 +1306,11 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1297
1306
|
elementLayer: a,
|
|
1298
1307
|
renderedPage: -1,
|
|
1299
1308
|
renderedScale: -1,
|
|
1300
|
-
dispatcher: new
|
|
1309
|
+
dispatcher: new S(n, this._mode === "worker")
|
|
1301
1310
|
};
|
|
1302
1311
|
}
|
|
1303
1312
|
_recycleSlot(e, t) {
|
|
1304
|
-
this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new
|
|
1313
|
+
this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new S(t.canvas, this._mode === "worker")), t.textLayer && (t.textLayer.innerHTML = "", t.textLayer.style.transform = "", t.textLayer.style.transformOrigin = ""), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", x(t.elementLayer, null), t.renderedPage = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
|
|
1305
1314
|
}
|
|
1306
1315
|
_positionSlot(e, t, n) {
|
|
1307
1316
|
e.wrapper.style.top = `${n.offsets[t]}px`;
|
|
@@ -1420,7 +1429,7 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1420
1429
|
let g = Math.max(0, h.totalHeight - this._scrollHost.clientHeight), _ = (h.offsets[u] ?? 0) + f * (this._heights[u] || 0), v = l < (s.offsets[0] ?? 0) ? c : _ - o;
|
|
1421
1430
|
if (this._scrollHost.scrollTop = Math.min(g, Math.max(0, v)), i) {
|
|
1422
1431
|
let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
|
|
1423
|
-
this._scrollHost.scrollLeft =
|
|
1432
|
+
this._scrollHost.scrollLeft = b(m, i.x - p, a, r, { maxScroll: e });
|
|
1424
1433
|
}
|
|
1425
1434
|
this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
|
|
1426
1435
|
}
|
|
@@ -1428,10 +1437,10 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1428
1437
|
return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
|
|
1429
1438
|
}
|
|
1430
1439
|
zoomIn() {
|
|
1431
|
-
this.setScale(
|
|
1440
|
+
this.setScale(w(this.getScale()));
|
|
1432
1441
|
}
|
|
1433
1442
|
zoomOut() {
|
|
1434
|
-
this.setScale(
|
|
1443
|
+
this.setScale(T(this.getScale()));
|
|
1435
1444
|
}
|
|
1436
1445
|
fitWidth() {
|
|
1437
1446
|
this._fit("width");
|
|
@@ -1441,9 +1450,9 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1441
1450
|
}
|
|
1442
1451
|
_fit(e) {
|
|
1443
1452
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
1444
|
-
let t = this._doc.pageSize(0), n =
|
|
1445
|
-
contentWidth: t.widthPt *
|
|
1446
|
-
contentHeight: t.heightPt *
|
|
1453
|
+
let t = this._doc.pageSize(0), n = v({
|
|
1454
|
+
contentWidth: t.widthPt * j,
|
|
1455
|
+
contentHeight: t.heightPt * j,
|
|
1447
1456
|
containerWidth: this._fitWidthPx(),
|
|
1448
1457
|
containerHeight: this._scrollHost.clientHeight
|
|
1449
1458
|
}, e);
|
|
@@ -1487,7 +1496,7 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1487
1496
|
}
|
|
1488
1497
|
let o = document.createElement("canvas");
|
|
1489
1498
|
o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
|
|
1490
|
-
let s = new
|
|
1499
|
+
let s = new S(o, !1), c = s.begin(), l = [], u = !!this._opts.enableTextSelection && !!t.textLayer, d = u || this._findActive, f = d ? (e) => l.push(e) : void 0;
|
|
1491
1500
|
this._doc.renderPage(o, e, {
|
|
1492
1501
|
width: r,
|
|
1493
1502
|
dpr: n,
|
|
@@ -1634,11 +1643,11 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1634
1643
|
_redrawElementOutlineForSlot(e, t) {
|
|
1635
1644
|
let n = this._elementContext, r = this._doc;
|
|
1636
1645
|
if (!n || !r || n.pageIndex !== e) {
|
|
1637
|
-
|
|
1646
|
+
x(t.elementLayer, null);
|
|
1638
1647
|
return;
|
|
1639
1648
|
}
|
|
1640
1649
|
let i = r.pageSize(e);
|
|
1641
|
-
|
|
1650
|
+
x(t.elementLayer, {
|
|
1642
1651
|
x: n.bounds.xPt / i.widthPt,
|
|
1643
1652
|
y: n.bounds.yPt / i.heightPt,
|
|
1644
1653
|
width: n.bounds.widthPt / i.widthPt,
|
|
@@ -1708,8 +1717,8 @@ var ht = /* @__PURE__ */ e({
|
|
|
1708
1717
|
DocxScrollViewer: () => mt,
|
|
1709
1718
|
DocxViewer: () => ut,
|
|
1710
1719
|
OoxmlDecodedImageLimitError: () => r,
|
|
1711
|
-
OoxmlError: () =>
|
|
1712
|
-
OoxmlResourceLimitError: () =>
|
|
1720
|
+
OoxmlError: () => u,
|
|
1721
|
+
OoxmlResourceLimitError: () => f,
|
|
1713
1722
|
autoResize: () => fe,
|
|
1714
1723
|
buildDocxHighlightLayer: () => q,
|
|
1715
1724
|
buildDocxTextLayer: () => K,
|
package/dist/docx.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { It as e, Lt as t, a as n,
|
|
2
|
-
import { w as a } from "./canvas-viewer-mechanics-
|
|
3
|
-
import { a as o, c as s, i as c, n as l, o as u, r as d, s as f } from "./docx-
|
|
4
|
-
export { s as DocxDocument, d as DocxScrollViewer, c as DocxViewer, e as OoxmlDecodedImageLimitError,
|
|
1
|
+
import { It as e, Lt as t, a as n, on as r, sn as i } from "./line-metrics-A77J_KRx.js";
|
|
2
|
+
import { w as a } from "./canvas-viewer-mechanics-DJ9yfiLN.js";
|
|
3
|
+
import { a as o, c as s, i as c, n as l, o as u, r as d, s as f } from "./docx-CSk_-kj_.js";
|
|
4
|
+
export { s as DocxDocument, d as DocxScrollViewer, c as DocxViewer, e as OoxmlDecodedImageLimitError, r as OoxmlError, i as OoxmlResourceLimitError, a as autoResize, u as buildDocxHighlightLayer, f as buildDocxTextLayer, t as isOoxmlDecodedImageLimitError, l as noteText, n as openExternalHyperlink, o as readDocxTextSelectionContext };
|
package/dist/docx_parser_bg.wasm
CHANGED
|
Binary file
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./docx-
|
|
2
|
-
import { t } from "./xlsx-
|
|
3
|
-
import { t as n } from "./pptx-
|
|
1
|
+
import { t as e } from "./docx-CSk_-kj_.js";
|
|
2
|
+
import { t } from "./xlsx-DHQmjAfh.js";
|
|
3
|
+
import { t as n } from "./pptx-CO1Ut97p.js";
|
|
4
4
|
export { e as docx, n as pptx, t as xlsx };
|