@silurus/ooxml 0.49.0 → 0.50.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.
|
@@ -172,12 +172,12 @@ async function k(e, t, n, r = {}) {
|
|
|
172
172
|
fontFamilyClasses: e.fontFamilyClasses ?? {},
|
|
173
173
|
onTextRun: r.onTextRun,
|
|
174
174
|
showTrackChanges: r.showTrackChanges ?? !0
|
|
175
|
-
}, h =
|
|
176
|
-
h &&
|
|
177
|
-
let g =
|
|
175
|
+
}, h = re(e.headers, n, d, e.section.titlePage, e.section.evenAndOddHeaders);
|
|
176
|
+
h && ie(h, i.headerDistance * s, m);
|
|
177
|
+
let g = re(e.footers, n, d, e.section.titlePage, e.section.evenAndOddHeaders);
|
|
178
178
|
if (g) {
|
|
179
|
-
let e =
|
|
180
|
-
|
|
179
|
+
let e = ae(g, m);
|
|
180
|
+
ie(g, c - i.footerDistance * s - e, m);
|
|
181
181
|
}
|
|
182
182
|
z(f, {
|
|
183
183
|
...m,
|
|
@@ -203,18 +203,22 @@ function A(e, t, n, r = {}) {
|
|
|
203
203
|
let e = r;
|
|
204
204
|
e.pageBreakBefore && d();
|
|
205
205
|
let p = R(l, e), m = p ? 0 : e.spaceBefore, h = Math.min(u, m);
|
|
206
|
-
c -= h, o.y -= h,
|
|
206
|
+
c -= h, o.y -= h, ye(e, o, o.y + m);
|
|
207
207
|
let g = M(o, e, a, p, t.marginLeft), _ = e.keepNext ? f(n + 1) : 0, v = g - e.spaceAfter + _;
|
|
208
208
|
if (c > 0 && c + v > i && d(), g > i - c && g > i * .5) {
|
|
209
|
-
let n =
|
|
209
|
+
let n = ee(o, e, a, p, t.marginLeft, c, i, s, () => {
|
|
210
210
|
d();
|
|
211
211
|
});
|
|
212
212
|
c = n.endY, o.y = t.marginTop + n.endY;
|
|
213
213
|
} else s[s.length - 1].push(r), c += g, o.y += g;
|
|
214
214
|
l = e, u = e.spaceAfter;
|
|
215
215
|
} else if (r.type === "table") {
|
|
216
|
-
let e =
|
|
217
|
-
|
|
216
|
+
let e = r, n = F(o, e, a), u = n.reduce((e, t) => e + t, 0);
|
|
217
|
+
if (u > i) {
|
|
218
|
+
let r = ne(e, n, c, i, s, () => d());
|
|
219
|
+
c = r, o.y = t.marginTop + r;
|
|
220
|
+
} else c + u > i && d(), s[s.length - 1].push(r), c += u, o.y += u;
|
|
221
|
+
l = null;
|
|
218
222
|
}
|
|
219
223
|
}
|
|
220
224
|
return s;
|
|
@@ -247,19 +251,19 @@ function j(e, t, n = {}) {
|
|
|
247
251
|
};
|
|
248
252
|
}
|
|
249
253
|
function M(e, t, n, r = !1, i = 0) {
|
|
250
|
-
let a = t.indentLeft, o = t.indentRight, s = Math.max(1, n - a - o), c =
|
|
254
|
+
let a = t.indentLeft, o = t.indentRight, s = Math.max(1, n - a - o), c = V(t.runs, e), l = P(t), u;
|
|
251
255
|
if (c.length === 0) {
|
|
252
|
-
let { asc: n, desc: r } =
|
|
253
|
-
u =
|
|
256
|
+
let { asc: n, desc: r } = Q(Y(t), 1);
|
|
257
|
+
u = Z(t.lineSpacing, n, r, 1, e.docGrid, l, X(t, 1));
|
|
254
258
|
} else {
|
|
255
259
|
let n = e.floats.length > 0 ? {
|
|
256
260
|
startPageY: e.y,
|
|
257
261
|
paraX: i,
|
|
258
262
|
floats: e.floats,
|
|
259
|
-
lineBoxH: (n, r, i, a) =>
|
|
263
|
+
lineBoxH: (n, r, i, a) => Z(t.lineSpacing, n, r, 1, e.docGrid, l, a ?? 0),
|
|
260
264
|
pageH: e.pageH
|
|
261
|
-
} : void 0, r =
|
|
262
|
-
u = l ? N(Math.max(0, ...r.map((n) =>
|
|
265
|
+
} : void 0, r = U(e.ctx, c, s, t.indentFirst, 1, t.tabStops, n, e.fontFamilyClasses, a);
|
|
266
|
+
u = l ? N(Math.max(0, ...r.map((n) => Z(t.lineSpacing, n.ascent, n.descent, 1, e.docGrid, !0, n.intendedSingle))), e.docGrid, 1) * r.length : r.reduce((n, r) => n + Z(t.lineSpacing, r.ascent, r.descent, 1, e.docGrid, !1, r.intendedSingle), 0);
|
|
263
267
|
}
|
|
264
268
|
return u + (r ? 0 : t.spaceBefore) + t.spaceAfter;
|
|
265
269
|
}
|
|
@@ -272,16 +276,16 @@ function P(e) {
|
|
|
272
276
|
for (let t of e.runs) if (t.type === "text" && t.ruby) return !0;
|
|
273
277
|
return !1;
|
|
274
278
|
}
|
|
275
|
-
function
|
|
276
|
-
let l = t.indentLeft, u = t.indentRight, d = Math.max(1, n - l - u), f =
|
|
279
|
+
function ee(e, t, n, r, i, a, o, s, c) {
|
|
280
|
+
let l = t.indentLeft, u = t.indentRight, d = Math.max(1, n - l - u), f = V(t.runs, e);
|
|
277
281
|
if (f.length === 0) return s[s.length - 1].push(t), { endY: a + M(e, t, n, r, i) };
|
|
278
282
|
let p = e.floats.length > 0 ? {
|
|
279
283
|
startPageY: e.y,
|
|
280
284
|
paraX: i,
|
|
281
285
|
floats: e.floats,
|
|
282
|
-
lineBoxH: (n, r, i, a) =>
|
|
286
|
+
lineBoxH: (n, r, i, a) => Z(t.lineSpacing, n, r, 1, e.docGrid, P(t), a ?? 0),
|
|
283
287
|
pageH: e.pageH
|
|
284
|
-
} : void 0, m =
|
|
288
|
+
} : void 0, m = U(e.ctx, f, d, t.indentFirst, 1, t.tabStops, p, e.fontFamilyClasses, l), h = P(t), g = (n) => Z(t.lineSpacing, n.ascent, n.descent, 1, e.docGrid, h, n.intendedSingle), _ = h ? N(Math.max(0, ...m.map(g)), e.docGrid, 1) : 0, v = m.map((e) => h ? _ : g(e)), y = r ? 0 : t.spaceBefore, b = t.spaceAfter, x = 0, S = a, C = !0;
|
|
285
289
|
for (; x < m.length;) {
|
|
286
290
|
let e = o - S, n = C ? y : 0, r = x, i = x;
|
|
287
291
|
for (; i < m.length && n + v[i] <= e;) n += v[i], i++;
|
|
@@ -304,7 +308,7 @@ function F(e, t, n, r, i, a, o, s, c) {
|
|
|
304
308
|
}
|
|
305
309
|
return { endY: S };
|
|
306
310
|
}
|
|
307
|
-
function
|
|
311
|
+
function F(e, t, n) {
|
|
308
312
|
let r = t.colWidths.reduce((e, t) => e + t, 0), i = r > n ? n / r : 1, a = t.colWidths.map((e) => e * i), o = [], s = [];
|
|
309
313
|
for (let n = 0; n < t.rows.length; n++) {
|
|
310
314
|
let r = t.rows[n];
|
|
@@ -314,7 +318,7 @@ function I(e, t, n) {
|
|
|
314
318
|
}
|
|
315
319
|
let i = r.rowHeight == null ? 10 : r.rowHeight, c = 0;
|
|
316
320
|
for (let o of r.cells) {
|
|
317
|
-
let r = Math.min(o.colSpan, a.length - c), l = a.slice(c, c + r).reduce((e, t) => e + t, 0), u =
|
|
321
|
+
let r = Math.min(o.colSpan, a.length - c), l = a.slice(c, c + r).reduce((e, t) => e + t, 0), u = G(o, t), d = Math.max(1, l - u.left - u.right), f = u.top + u.bottom;
|
|
318
322
|
for (let t of o.content) t.type === "paragraph" ? f += M(e, t, d) : t.type === "table" && (f += I(e, t, d));
|
|
319
323
|
o.vMerge === !0 ? s.push({
|
|
320
324
|
ri: n,
|
|
@@ -329,7 +333,33 @@ function I(e, t, n) {
|
|
|
329
333
|
for (let t = e.ri; t <= n; t++) r += o[t];
|
|
330
334
|
r < e.contentH && (o[n] += e.contentH - r);
|
|
331
335
|
}
|
|
332
|
-
return o
|
|
336
|
+
return o;
|
|
337
|
+
}
|
|
338
|
+
function I(e, t, n) {
|
|
339
|
+
return F(e, t, n).reduce((e, t) => e + t, 0);
|
|
340
|
+
}
|
|
341
|
+
function te(e, t) {
|
|
342
|
+
return t <= 0 ? !0 : !e.rows[t].cells.some((e) => e.vMerge === !1);
|
|
343
|
+
}
|
|
344
|
+
function ne(e, t, n, r, i, a) {
|
|
345
|
+
let o = e.rows.length, s = 0;
|
|
346
|
+
for (; s < o && e.rows[s].isHeader;) s++;
|
|
347
|
+
let c = e.rows.slice(0, s), l = t.slice(0, s).reduce((e, t) => e + t, 0), u = n, d = 0, f = !0;
|
|
348
|
+
for (; d < o;) {
|
|
349
|
+
let n = !f && s > 0 && d >= s, p = r - u, m = n ? l : 0, h = d;
|
|
350
|
+
for (; h < o;) {
|
|
351
|
+
let n = t[h];
|
|
352
|
+
if (h > d && m + n > p && te(e, h)) break;
|
|
353
|
+
m += n, h++;
|
|
354
|
+
}
|
|
355
|
+
let g = e.rows.slice(d, h), _ = n ? [...c, ...g] : g;
|
|
356
|
+
i[i.length - 1].push({
|
|
357
|
+
...e,
|
|
358
|
+
type: "table",
|
|
359
|
+
rows: _
|
|
360
|
+
}), u += m, d = h, f = !1, d < o && (a(), u = 0);
|
|
361
|
+
}
|
|
362
|
+
return u;
|
|
333
363
|
}
|
|
334
364
|
function L(e, t, n) {
|
|
335
365
|
let r = t;
|
|
@@ -348,17 +378,17 @@ function L(e, t, n) {
|
|
|
348
378
|
}
|
|
349
379
|
return r;
|
|
350
380
|
}
|
|
351
|
-
function
|
|
381
|
+
function re(e, t, n, r, i) {
|
|
352
382
|
return r && t === 0 && e.first ? e.first : i && t % 2 == 1 && e.even ? e.even : e.default ?? null;
|
|
353
383
|
}
|
|
354
|
-
function
|
|
384
|
+
function ie(e, t, n) {
|
|
355
385
|
let r = {
|
|
356
386
|
...n,
|
|
357
387
|
y: t
|
|
358
388
|
};
|
|
359
389
|
z(e.body, r);
|
|
360
390
|
}
|
|
361
|
-
function
|
|
391
|
+
function ae(e, t) {
|
|
362
392
|
let n = {
|
|
363
393
|
...t,
|
|
364
394
|
y: 0,
|
|
@@ -376,27 +406,27 @@ function z(e, t) {
|
|
|
376
406
|
let e = i, a = i.lineSlice, o = R(n, e), s = o ? 0 : e.spaceBefore;
|
|
377
407
|
t.y -= Math.min(r, s) * t.scale;
|
|
378
408
|
let c = !!a && a.start > 0;
|
|
379
|
-
|
|
380
|
-
} else i.type === "table" && (
|
|
409
|
+
B(e, t, o || c, a), n = e, r = e.spaceAfter;
|
|
410
|
+
} else i.type === "table" && (xe(i, t), n = null, r = 0);
|
|
381
411
|
}
|
|
382
|
-
function
|
|
412
|
+
function B(e, t, n = !1, r) {
|
|
383
413
|
let { ctx: i, scale: a, contentX: o, contentW: s, defaultColor: c, dryRun: l, fontFamilyClasses: u } = t, d = t.y;
|
|
384
|
-
n || (t.y += e.spaceBefore * a),
|
|
414
|
+
n || (t.y += e.spaceBefore * a), ye(e, t, t.y), W(e, t, d, "behind"), t.y = be(t.y, t.floats);
|
|
385
415
|
let f = t.y, p = e.indentLeft * a, m = e.indentRight * a, h = e.indentFirst * a, g = "", y = 0;
|
|
386
416
|
e.numbering && (g = e.numbering.text + " ", y = e.numbering.tab * a);
|
|
387
|
-
let b = o + p, x = b + h, S = s - p - m, C =
|
|
417
|
+
let b = o + p, x = b + h, S = s - p - m, C = V(e.runs, t), w = P(e);
|
|
388
418
|
if (C.length === 0) {
|
|
389
|
-
let { asc: n, desc: r } =
|
|
390
|
-
e.shading && !l && (i.fillStyle = `#${e.shading}`, i.fillRect(o + p, f, S, s)), t.y += s, e.borders && !l &&
|
|
419
|
+
let { asc: n, desc: r } = Q(Y(e), a), s = Z(e.lineSpacing, n, r, a, t.docGrid, w, X(e, a));
|
|
420
|
+
e.shading && !l && (i.fillStyle = `#${e.shading}`, i.fillRect(o + p, f, S, s)), t.y += s, e.borders && !l && Ae(i, o + p, f, S, s, e.borders, a), t.y += e.spaceAfter * a, W(e, t, d);
|
|
391
421
|
return;
|
|
392
422
|
}
|
|
393
423
|
let E = t.floats.length > 0 ? {
|
|
394
424
|
startPageY: t.y,
|
|
395
425
|
paraX: b,
|
|
396
426
|
floats: t.floats,
|
|
397
|
-
lineBoxH: (n, r, i, o) =>
|
|
427
|
+
lineBoxH: (n, r, i, o) => Z(e.lineSpacing, n, r, a, t.docGrid, w, o ?? 0),
|
|
398
428
|
pageH: t.pageH
|
|
399
|
-
} : void 0, D =
|
|
429
|
+
} : void 0, D = U(i, C, S, x - b, a, e.tabStops, E, t.fontFamilyClasses, p), O = w ? N(Math.max(0, ...D.map((n) => Z(e.lineSpacing, n.ascent, n.descent, a, t.docGrid, !0, n.intendedSingle))), t.docGrid, a) : 0, k = (n) => w ? O : Z(e.lineSpacing, n.ascent, n.descent, a, t.docGrid, !1, n.intendedSingle);
|
|
400
430
|
if (e.shading && !l) {
|
|
401
431
|
let t = D.reduce((e, t) => e + k(t), 0);
|
|
402
432
|
i.fillStyle = `#${e.shading}`, i.fillRect(o + p, f, S, t);
|
|
@@ -405,12 +435,12 @@ function re(e, t, n = !1, r) {
|
|
|
405
435
|
let t = 0;
|
|
406
436
|
for (let n = e.length - 1; n >= 0 && e[n] === " "; n--) t++;
|
|
407
437
|
return t;
|
|
408
|
-
},
|
|
409
|
-
for (let n =
|
|
438
|
+
}, ee = r ? r.start : 0, F = r ? r.end : D.length;
|
|
439
|
+
for (let n = ee; n < F; n++) {
|
|
410
440
|
let r = D[n], o = n === 0, s = n === D.length - 1;
|
|
411
441
|
r.topY !== void 0 && r.topY > t.y && (t.y = r.topY);
|
|
412
442
|
let d = k(r), f = r.ascent + r.descent, p = t.y + (d - f) / 2 + r.ascent, m = b + r.xOffset, x = r.availWidth, S = o ? m + h : m;
|
|
413
|
-
o && g && !l && (i.font = `${
|
|
443
|
+
o && g && !l && (i.font = `${Y(e) * a}px sans-serif`, i.fillStyle = c, i.fillText(e.numbering.text, S - y, p));
|
|
414
444
|
let C = r.segments.reduce((e, t) => e + t.measuredWidth, 0), w = 0;
|
|
415
445
|
e.alignment === "right" || e.alignment === "end" ? w = x - (S - m) - C : e.alignment === "center" && (w = (x - (S - m) - C) / 2), S += w;
|
|
416
446
|
let E = 0;
|
|
@@ -431,11 +461,11 @@ function re(e, t, n = !1, r) {
|
|
|
431
461
|
for (let e = 0; e < r.segments.length; e++) {
|
|
432
462
|
let n = r.segments[e], o = e === r.segments.length - 1;
|
|
433
463
|
if ("isTab" in n) {
|
|
434
|
-
!l && n.leader && n.leader !== "none" && n.measuredWidth > 1 &&
|
|
464
|
+
!l && n.leader && n.leader !== "none" && n.measuredWidth > 1 && ue(i, n.leader, S, p, n.measuredWidth, n.fontSize * a, c), S += n.measuredWidth;
|
|
435
465
|
continue;
|
|
436
466
|
}
|
|
437
467
|
if ("dataUrl" in n) {
|
|
438
|
-
l ||
|
|
468
|
+
l || de(i, n, S, p, a, t.images), S += n.measuredWidth;
|
|
439
469
|
continue;
|
|
440
470
|
}
|
|
441
471
|
if ("mathNodes" in n) {
|
|
@@ -449,11 +479,11 @@ function re(e, t, n = !1, r) {
|
|
|
449
479
|
}
|
|
450
480
|
let s = n;
|
|
451
481
|
if (!l) {
|
|
452
|
-
let e =
|
|
453
|
-
i.font =
|
|
482
|
+
let e = je(s, a), n = s.vertAlign === "super" ? -s.fontSize * a * .35 : s.vertAlign === "sub" ? s.fontSize * a * .15 : 0;
|
|
483
|
+
i.font = J(s.bold, s.italic, e, s.fontFamily, u), s.highlight && (i.fillStyle = _[s.highlight] ?? "#FFFF00", i.fillRect(S, p + n - e * .85, s.measuredWidth, e * 1.1));
|
|
454
484
|
let r = t.showTrackChanges && !!s.revision, o = r ? T(s.revision.author) : null;
|
|
455
485
|
if (i.fillStyle = o ?? (s.color ? `#${s.color}` : c), i.fillText(s.text, S, p + n), s.ruby) {
|
|
456
|
-
let t = s.ruby.fontSizePt * a, r =
|
|
486
|
+
let t = s.ruby.fontSizePt * a, r = J(s.bold, s.italic, t, s.fontFamily, u);
|
|
457
487
|
i.save(), i.font = r;
|
|
458
488
|
let o = i.measureText(s.ruby.text).width, l = S + (s.measuredWidth - o) / 2, d = p + n - e * .85 - t * .1;
|
|
459
489
|
i.fillStyle = s.color ? `#${s.color}` : c, i.fillText(s.ruby.text, l, d), i.restore();
|
|
@@ -493,17 +523,17 @@ function re(e, t, n = !1, r) {
|
|
|
493
523
|
}
|
|
494
524
|
if (e.borders && !l) {
|
|
495
525
|
let n = t.y - f;
|
|
496
|
-
|
|
526
|
+
Ae(i, o + p, f, S, n, e.borders, a);
|
|
497
527
|
}
|
|
498
|
-
(!r || r.end >= D.length) && (t.y += e.spaceAfter * a), (!r || r.start === 0) &&
|
|
528
|
+
(!r || r.end >= D.length) && (t.y += e.spaceAfter * a), (!r || r.start === 0) && W(e, t, d);
|
|
499
529
|
}
|
|
500
|
-
function
|
|
530
|
+
function V(e, t) {
|
|
501
531
|
let n = [], r = (e, t, r) => {
|
|
502
532
|
let i = t.allCaps || t.smallCaps ? e.toUpperCase() : e, a = t.ruby, o = a ? {
|
|
503
533
|
text: a.text,
|
|
504
534
|
fontSizePt: a.fontSizePt
|
|
505
535
|
} : void 0, s = t.revision, c = !0;
|
|
506
|
-
for (let e of
|
|
536
|
+
for (let e of le(i)) n.push({
|
|
507
537
|
text: e,
|
|
508
538
|
bold: t.bold,
|
|
509
539
|
italic: t.italic,
|
|
@@ -544,7 +574,7 @@ function B(e, t) {
|
|
|
544
574
|
});
|
|
545
575
|
} else if (i.type === "break") {
|
|
546
576
|
if (i.breakType === "line") {
|
|
547
|
-
let t =
|
|
577
|
+
let t = H(e, e.indexOf(i));
|
|
548
578
|
n.push({
|
|
549
579
|
lineBreak: !0,
|
|
550
580
|
fontSize: t,
|
|
@@ -552,10 +582,10 @@ function B(e, t) {
|
|
|
552
582
|
});
|
|
553
583
|
}
|
|
554
584
|
} else if (i.type === "field") {
|
|
555
|
-
let e = i, n =
|
|
585
|
+
let e = i, n = oe(e, t);
|
|
556
586
|
n && r(n, e, e.vertAlign);
|
|
557
587
|
} else if (i.type === "math") {
|
|
558
|
-
let t = i.fontSize ||
|
|
588
|
+
let t = i.fontSize || H(e, e.indexOf(i));
|
|
559
589
|
n.push({
|
|
560
590
|
mathNodes: i.nodes,
|
|
561
591
|
display: i.display,
|
|
@@ -568,7 +598,7 @@ function B(e, t) {
|
|
|
568
598
|
}
|
|
569
599
|
return n;
|
|
570
600
|
}
|
|
571
|
-
function
|
|
601
|
+
function H(e, t) {
|
|
572
602
|
for (let n = t - 1; n >= 0; n--) {
|
|
573
603
|
let t = e[n];
|
|
574
604
|
if (t.type === "text" || t.type === "field") return t.fontSize;
|
|
@@ -579,10 +609,10 @@ function ie(e, t) {
|
|
|
579
609
|
}
|
|
580
610
|
return 10;
|
|
581
611
|
}
|
|
582
|
-
function
|
|
612
|
+
function oe(e, t) {
|
|
583
613
|
return e.fieldType === "page" ? String(t.pageIndex + 1) : e.fieldType === "numPages" ? String(t.totalPages) : e.fallbackText;
|
|
584
614
|
}
|
|
585
|
-
function
|
|
615
|
+
function se(e) {
|
|
586
616
|
for (let t = 0; t < e.length;) {
|
|
587
617
|
let n = e.codePointAt(t);
|
|
588
618
|
if (n >= 12288 && n <= 40959 || n >= 63744 && n <= 64255 || n >= 44032 && n <= 55215 || n >= 65280 && n <= 65519) return !0;
|
|
@@ -590,7 +620,7 @@ function oe(e) {
|
|
|
590
620
|
}
|
|
591
621
|
return !1;
|
|
592
622
|
}
|
|
593
|
-
function
|
|
623
|
+
function ce(e, t, n) {
|
|
594
624
|
let r = [...t], i = 0, a = r.length;
|
|
595
625
|
for (; i < a;) {
|
|
596
626
|
let t = i + a + 1 >> 1;
|
|
@@ -598,7 +628,7 @@ function se(e, t, n) {
|
|
|
598
628
|
}
|
|
599
629
|
return r.slice(0, i).join("");
|
|
600
630
|
}
|
|
601
|
-
function
|
|
631
|
+
function le(e) {
|
|
602
632
|
let t = [], n = 0;
|
|
603
633
|
for (; n < e.length;) {
|
|
604
634
|
let r = n;
|
|
@@ -608,7 +638,7 @@ function ce(e) {
|
|
|
608
638
|
}
|
|
609
639
|
return t.length ? t : [e];
|
|
610
640
|
}
|
|
611
|
-
function
|
|
641
|
+
function U(e, t, n, r, i, a = [], o, s = {}, c = 0) {
|
|
612
642
|
let l = [], u = [], d = 0, f = 0, p = 0, m = 0, h = 0, _ = 0, y = !0, b = n, x = 0, S = o?.startPageY ?? 0, C = () => {
|
|
613
643
|
if (x = 0, b = n, !o) return;
|
|
614
644
|
let e = 10 * i;
|
|
@@ -659,7 +689,7 @@ function V(e, t, n, r, i, a = [], o, s = {}, c = 0) {
|
|
|
659
689
|
let n = g(t.fontFamily, O(t));
|
|
660
690
|
n > _ && (_ = n);
|
|
661
691
|
}
|
|
662
|
-
}, O = (e) =>
|
|
692
|
+
}, O = (e) => je(e, i), k = (t) => (e.font = J(t.bold, t.italic, O(t), t.fontFamily, s), e.measureText(t.text)), A = (e) => "isTab" in e ? e.measuredWidth || 0 : "dataUrl" in e ? e.widthPt * i : "mathNodes" in e ? e.measuredWidth || 0 : "lineBreak" in e ? 0 : k(e).width, j = [...t];
|
|
663
693
|
for (; j.length > 0;) {
|
|
664
694
|
let t = j.shift();
|
|
665
695
|
if ("lineBreak" in t) {
|
|
@@ -721,17 +751,19 @@ function V(e, t, n, r, i, a = [], o, s = {}, c = 0) {
|
|
|
721
751
|
continue;
|
|
722
752
|
}
|
|
723
753
|
let n = t.fontSize * i, r = e.widthEm * n, a = e.ascentEm * n, o = e.descentEm * n;
|
|
724
|
-
t.measuredWidth = r, t.mathAscent = a, t.mathDescent = o
|
|
754
|
+
t.measuredWidth = r, t.mathAscent = a, t.mathDescent = o;
|
|
755
|
+
let s = Math.max(a, n * .8), c = Math.max(o, n * .2);
|
|
756
|
+
u.length > 0 && d + r > w() && E(), D(t, r, t.fontSize, s, c);
|
|
725
757
|
continue;
|
|
726
758
|
}
|
|
727
759
|
let n = t, o = k(n), l = o.width, p = n.fontSize, m = o.fontBoundingBoxAscent ?? o.actualBoundingBoxAscent ?? n.fontSize * i * .8, h = o.fontBoundingBoxDescent ?? o.actualBoundingBoxDescent ?? n.fontSize * i * .2;
|
|
728
760
|
n.ruby && (m += n.ruby.fontSizePt * i * 1.5);
|
|
729
761
|
let g = n.text.replace(/ +$/, ""), _ = n.text.endsWith(" ") ? l - e.measureText(g).width : 0, b = l - _, x = f * .25;
|
|
730
762
|
if (d + b <= w() + x) n.measuredWidth = l, D(n, l, p, m, h, _);
|
|
731
|
-
else if (
|
|
763
|
+
else if (se(n.text)) {
|
|
732
764
|
let t = w() - d;
|
|
733
|
-
e.font =
|
|
734
|
-
let r = t > 0 ?
|
|
765
|
+
e.font = J(n.bold, n.italic, O(n), n.fontFamily, s);
|
|
766
|
+
let r = t > 0 ? ce(e, n.text, t) : "";
|
|
735
767
|
if (r.length > 0) {
|
|
736
768
|
let t = e.measureText(r);
|
|
737
769
|
D({
|
|
@@ -767,7 +799,7 @@ function V(e, t, n, r, i, a = [], o, s = {}, c = 0) {
|
|
|
767
799
|
}
|
|
768
800
|
return u.length > 0 && E(), l;
|
|
769
801
|
}
|
|
770
|
-
function
|
|
802
|
+
function ue(e, t, n, r, i, a, o) {
|
|
771
803
|
let s = t === "hyphen" ? "-" : t === "underscore" || t === "heavy" ? "_" : t === "middleDot" ? "·" : ".";
|
|
772
804
|
e.save(), e.font = `${a}px serif`, e.fillStyle = o;
|
|
773
805
|
let c = e.measureText(s).width;
|
|
@@ -777,30 +809,30 @@ function le(e, t, n, r, i, a, o) {
|
|
|
777
809
|
}
|
|
778
810
|
e.restore();
|
|
779
811
|
}
|
|
780
|
-
function
|
|
812
|
+
function de(e, t, n, r, i, a) {
|
|
781
813
|
if (t.anchor) return;
|
|
782
814
|
let o = a.get(C(t.dataUrl, t.colorReplaceFrom));
|
|
783
815
|
if (!o) return;
|
|
784
816
|
let s = t.widthPt * i, c = t.heightPt * i;
|
|
785
817
|
e.drawImage(o, n, r - c, s, c);
|
|
786
818
|
}
|
|
787
|
-
function
|
|
819
|
+
function W(e, t, n, r = "front") {
|
|
788
820
|
if (!t.dryRun) {
|
|
789
821
|
if (r === "behind") {
|
|
790
822
|
let r = e.runs.filter((e) => e.type === "shape" && !!e.behindDoc).slice().sort((e, t) => (e.zOrder ?? 0) - (t.zOrder ?? 0));
|
|
791
|
-
for (let e of r)
|
|
823
|
+
for (let e of r) ge(e, t, n);
|
|
792
824
|
return;
|
|
793
825
|
}
|
|
794
826
|
for (let r of e.runs) {
|
|
795
827
|
if (r.type === "shape") {
|
|
796
828
|
let e = r;
|
|
797
829
|
if (e.behindDoc) continue;
|
|
798
|
-
|
|
830
|
+
ge(e, t, n);
|
|
799
831
|
continue;
|
|
800
832
|
}
|
|
801
833
|
if (r.type !== "image") continue;
|
|
802
834
|
let e = r;
|
|
803
|
-
if (!e.anchor ||
|
|
835
|
+
if (!e.anchor || ve(e.wrapMode)) continue;
|
|
804
836
|
let i = t.images.get(C(e.dataUrl, e.colorReplaceFrom));
|
|
805
837
|
if (!i) continue;
|
|
806
838
|
let a = e.widthPt * t.scale, o = e.heightPt * t.scale, s = e.anchorXFromMargin ? (t.marginLeft + (e.anchorXPt ?? 0)) * t.scale : (e.anchorXPt ?? 0) * t.scale, c = e.anchorYFromPara ? n + (e.anchorYPt ?? 0) * t.scale : (e.anchorYPt ?? 0) * t.scale;
|
|
@@ -808,7 +840,7 @@ function H(e, t, n, r = "front") {
|
|
|
808
840
|
}
|
|
809
841
|
}
|
|
810
842
|
}
|
|
811
|
-
function
|
|
843
|
+
function fe(e, t, n) {
|
|
812
844
|
let { scale: r } = n, i = n.pageWidth * r, a = n.marginLeft * r, o = n.marginRight * r;
|
|
813
845
|
switch (e ?? (t ? "margin" : "page")) {
|
|
814
846
|
case "page": return {
|
|
@@ -837,7 +869,7 @@ function U(e, t, n) {
|
|
|
837
869
|
};
|
|
838
870
|
}
|
|
839
871
|
}
|
|
840
|
-
function
|
|
872
|
+
function pe(e, t, n, r) {
|
|
841
873
|
let { scale: i } = r, a = r.marginTop * i, o = r.marginBottom * i;
|
|
842
874
|
switch (e ?? (t ? "paragraph" : "page")) {
|
|
843
875
|
case "page": return {
|
|
@@ -863,8 +895,8 @@ function de(e, t, n, r) {
|
|
|
863
895
|
};
|
|
864
896
|
}
|
|
865
897
|
}
|
|
866
|
-
function
|
|
867
|
-
let { scale: c } = i, l =
|
|
898
|
+
function me(e, t, n, r, i, a, o, s) {
|
|
899
|
+
let { scale: c } = i, l = fe(a, t, i), u = n * c;
|
|
868
900
|
if (o != null) return l.start + (l.end - l.start) * o + u;
|
|
869
901
|
if (!e) return l.start + u;
|
|
870
902
|
let d = l.end - l.start, f = s == null ? r : s * c;
|
|
@@ -875,8 +907,8 @@ function fe(e, t, n, r, i, a, o, s) {
|
|
|
875
907
|
default: return l.start + u;
|
|
876
908
|
}
|
|
877
909
|
}
|
|
878
|
-
function
|
|
879
|
-
let { scale: l } = a, u =
|
|
910
|
+
function he(e, t, n, r, i, a, o, s, c) {
|
|
911
|
+
let { scale: l } = a, u = pe(o, t, i, a), d = n * l;
|
|
880
912
|
if (s != null) return u.start + (u.end - u.start) * s + d;
|
|
881
913
|
if (!e) return u.start + d;
|
|
882
914
|
let f = u.end - u.start, p = c == null ? r : c * l;
|
|
@@ -886,10 +918,10 @@ function pe(e, t, n, r, i, a, o, s, c) {
|
|
|
886
918
|
default: return u.start + d;
|
|
887
919
|
}
|
|
888
920
|
}
|
|
889
|
-
function
|
|
921
|
+
function ge(e, t, n) {
|
|
890
922
|
let { ctx: r, scale: c } = t, l = e.widthPt * c, u = e.heightPt * c, d = e.anchorXPt, f = e.anchorYPt, p = e.groupWidthPt ?? null, m = e.groupHeightPt ?? null;
|
|
891
923
|
if (e.widthPct != null) {
|
|
892
|
-
let n =
|
|
924
|
+
let n = fe(e.widthRelativeFrom, !1, t), r = (n.end - n.start) * e.widthPct / c;
|
|
893
925
|
if (e.groupWidthPt != null && e.groupWidthPt > 0) {
|
|
894
926
|
let t = r / e.groupWidthPt;
|
|
895
927
|
l = e.widthPt * c * t, d = e.anchorXPt * t;
|
|
@@ -897,7 +929,7 @@ function me(e, t, n) {
|
|
|
897
929
|
p = r;
|
|
898
930
|
}
|
|
899
931
|
if (e.heightPct != null) {
|
|
900
|
-
let r =
|
|
932
|
+
let r = pe(e.heightRelativeFrom, !1, n, t), i = (r.end - r.start) * e.heightPct / c;
|
|
901
933
|
if (e.groupHeightPt != null && e.groupHeightPt > 0) {
|
|
902
934
|
let t = i / e.groupHeightPt;
|
|
903
935
|
u = e.heightPt * c * t, f = e.anchorYPt * t;
|
|
@@ -905,34 +937,34 @@ function me(e, t, n) {
|
|
|
905
937
|
m = i;
|
|
906
938
|
}
|
|
907
939
|
if (l <= 0 || u <= 0) return;
|
|
908
|
-
let h =
|
|
940
|
+
let h = me(e.anchorXAlign, e.anchorXFromMargin, d, l, t, e.anchorXRelativeFrom, e.pctPosH, p), g = he(e.anchorYAlign, e.anchorYFromPara, f, u, n, t, e.anchorYRelativeFrom, e.pctPosV, m), _ = e.rotation ?? 0;
|
|
909
941
|
if (r.save(), _ !== 0 && (r.translate(h + l / 2, g + u / 2), r.rotate(_ * Math.PI / 180), r.translate(-(h + l / 2), -(g + u / 2))), r.beginPath(), e.presetGeometry) {
|
|
910
942
|
let t = e.adjValues ?? [];
|
|
911
943
|
o(r, e.presetGeometry, h, g, l, u, t[0] ?? null, t[1] ?? null, t[2] ?? null, t[3] ?? null);
|
|
912
944
|
} else s(r, e.subpaths, h, g, l, u);
|
|
913
945
|
let v = i(e.fill, r, h, g, l, u);
|
|
914
|
-
v && (r.fillStyle = v, r.fill()), e.stroke && (e.strokeWidth ?? 0) > 0 && (r.strokeStyle = a(e.stroke), r.lineWidth = Math.max(.5, (e.strokeWidth ?? 0) * c), r.stroke()), r.restore(), e.textBlocks && e.textBlocks.length > 0 &&
|
|
946
|
+
v && (r.fillStyle = v, r.fill()), e.stroke && (e.strokeWidth ?? 0) > 0 && (r.strokeStyle = a(e.stroke), r.lineWidth = Math.max(.5, (e.strokeWidth ?? 0) * c), r.stroke()), r.restore(), e.textBlocks && e.textBlocks.length > 0 && _e(e, h, g, l, u, r, c, t.fontFamilyClasses);
|
|
915
947
|
}
|
|
916
|
-
function
|
|
948
|
+
function _e(e, t, n, r, i, a, o, s = {}) {
|
|
917
949
|
let c = e.textBlocks ?? [], l = (e.textInsetL ?? 0) * o, u = (e.textInsetT ?? 0) * o, d = (e.textInsetR ?? 0) * o, f = (e.textInsetB ?? 0) * o, p = t + l, m = Math.max(0, r - l - d), h = n + u, g = Math.max(0, i - u - f), _ = c.map((e) => e.fontSizePt * o * 1.2), v = _.reduce((e, t) => e + t, 0), y = e.textAnchor ?? "t", b;
|
|
918
950
|
b = y === "b" ? h + Math.max(0, g - v) : y === "ctr" ? h + Math.max(0, (g - v) / 2) : h;
|
|
919
951
|
for (let e = 0; e < c.length; e++) {
|
|
920
952
|
let t = c[e], n = t.fontSizePt * o;
|
|
921
|
-
a.font =
|
|
953
|
+
a.font = J(t.bold ?? !1, t.italic ?? !1, n, t.fontFamily ?? null, s), a.fillStyle = t.color ? `#${t.color}` : "#000000";
|
|
922
954
|
let r = a.measureText(t.text), i = p;
|
|
923
955
|
t.alignment === "center" || t.alignment === "distribute" ? i = p + Math.max(0, (m - r.width) / 2) : (t.alignment === "right" || t.alignment === "end") && (i = p + Math.max(0, m - r.width));
|
|
924
956
|
let l = b + n * .85;
|
|
925
957
|
a.fillText(t.text, i, l), b += _[e];
|
|
926
958
|
}
|
|
927
959
|
}
|
|
928
|
-
function
|
|
960
|
+
function ve(e) {
|
|
929
961
|
return e === "square" || e === "topAndBottom" || e === "tight" || e === "through";
|
|
930
962
|
}
|
|
931
|
-
function
|
|
963
|
+
function ye(e, t, n) {
|
|
932
964
|
for (let r of e.runs) {
|
|
933
965
|
if (r.type !== "image") continue;
|
|
934
966
|
let e = r;
|
|
935
|
-
if (!e.anchor || !
|
|
967
|
+
if (!e.anchor || !ve(e.wrapMode)) continue;
|
|
936
968
|
let i = e.wrapMode === "topAndBottom" ? "topAndBottom" : "square", a = t.scale, o = e.widthPt * a, s = e.heightPt * a, c = e.anchorXFromMargin ? (t.marginLeft + (e.anchorXPt ?? 0)) * a : (e.anchorXPt ?? 0) * a, l = e.anchorYFromPara ? n + (e.anchorYPt ?? 0) * a : (e.anchorYPt ?? 0) * a, u = (e.distTop ?? 0) * a, d = (e.distBottom ?? 0) * a, f = (e.distLeft ?? 0) * a, p = (e.distRight ?? 0) * a, m = C(e.dataUrl, e.colorReplaceFrom), h = {
|
|
937
969
|
mode: i,
|
|
938
970
|
imageKey: m,
|
|
@@ -953,7 +985,7 @@ function _e(e, t, n) {
|
|
|
953
985
|
}
|
|
954
986
|
}
|
|
955
987
|
}
|
|
956
|
-
function
|
|
988
|
+
function be(e, t) {
|
|
957
989
|
for (let n = 0; n < 16; n++) {
|
|
958
990
|
let n = e;
|
|
959
991
|
for (let r of t) r.mode === "topAndBottom" && e >= r.yTop && e < r.yBottom && (n = Math.max(n, r.yBottom));
|
|
@@ -962,10 +994,10 @@ function ve(e, t) {
|
|
|
962
994
|
}
|
|
963
995
|
return e;
|
|
964
996
|
}
|
|
965
|
-
function
|
|
997
|
+
function xe(e, t) {
|
|
966
998
|
let { ctx: n, scale: r, contentX: i, contentW: a, dryRun: o } = t, s = e.colWidths.reduce((e, t) => e + t, 0) * r, c = s > a ? a / s : 1, l = e.colWidths.map((e) => e * r * c), u = l.reduce((e, t) => e + t, 0), d = e.jc === "center" ? i + Math.max(0, (a - u) / 2) : e.jc === "right" ? i + Math.max(0, a - u) : i, f = [];
|
|
967
999
|
for (let n of e.rows) {
|
|
968
|
-
let i =
|
|
1000
|
+
let i = Se(n, e, l, r, t);
|
|
969
1001
|
f.push(i);
|
|
970
1002
|
}
|
|
971
1003
|
for (let n = 0; n < e.rows.length; n++) {
|
|
@@ -973,7 +1005,7 @@ function ye(e, t) {
|
|
|
973
1005
|
for (let a of e.rows[n].cells) {
|
|
974
1006
|
let o = Math.min(a.colSpan, l.length - i);
|
|
975
1007
|
if (a.vMerge === !0) {
|
|
976
|
-
let s =
|
|
1008
|
+
let s = Ce(a, e, l.slice(i, i + o).reduce((e, t) => e + t, 0), r, t), c = L(e, n, i), u = 0;
|
|
977
1009
|
for (let e = n; e <= c; e++) u += f[e];
|
|
978
1010
|
u < s && (f[c] += s - u);
|
|
979
1011
|
}
|
|
@@ -992,7 +1024,7 @@ function ye(e, t) {
|
|
|
992
1024
|
i = 0;
|
|
993
1025
|
for (let e = n; e <= t; e++) i += f[e];
|
|
994
1026
|
}
|
|
995
|
-
o ?
|
|
1027
|
+
o ? Te(u, e, d, r, t) : Ee(u, e, s, p, d, i, t);
|
|
996
1028
|
}
|
|
997
1029
|
s += d, c += i;
|
|
998
1030
|
}
|
|
@@ -1000,11 +1032,11 @@ function ye(e, t) {
|
|
|
1000
1032
|
}
|
|
1001
1033
|
t.y = p;
|
|
1002
1034
|
}
|
|
1003
|
-
function
|
|
1035
|
+
function Se(e, t, n, r, i) {
|
|
1004
1036
|
if (e.rowHeight != null && e.rowHeightRule === "exact") return e.rowHeight * r;
|
|
1005
1037
|
let a = e.rowHeight == null ? 10 * r : e.rowHeight * r, o = 0;
|
|
1006
1038
|
for (let s of e.cells) {
|
|
1007
|
-
let e = Math.min(s.colSpan, n.length - o), c = n.slice(o, o + e).reduce((e, t) => e + t, 0), l =
|
|
1039
|
+
let e = Math.min(s.colSpan, n.length - o), c = n.slice(o, o + e).reduce((e, t) => e + t, 0), l = G(s, t), u = c - (l.left + l.right) * r;
|
|
1008
1040
|
if (s.vMerge === !0) {
|
|
1009
1041
|
o += e;
|
|
1010
1042
|
continue;
|
|
@@ -1014,25 +1046,25 @@ function be(e, t, n, r, i) {
|
|
|
1014
1046
|
continue;
|
|
1015
1047
|
}
|
|
1016
1048
|
let d = (l.top + l.bottom) * r;
|
|
1017
|
-
for (let e of s.content) d +=
|
|
1049
|
+
for (let e of s.content) d += K(i, e, u, r);
|
|
1018
1050
|
d > a && (a = d), o += e;
|
|
1019
1051
|
}
|
|
1020
1052
|
return a;
|
|
1021
1053
|
}
|
|
1022
|
-
function
|
|
1023
|
-
let a =
|
|
1024
|
-
for (let t of e.content) s +=
|
|
1054
|
+
function Ce(e, t, n, r, i) {
|
|
1055
|
+
let a = G(e, t), o = n - (a.left + a.right) * r, s = (a.top + a.bottom) * r;
|
|
1056
|
+
for (let t of e.content) s += K(i, t, o, r);
|
|
1025
1057
|
return s;
|
|
1026
1058
|
}
|
|
1027
|
-
function
|
|
1028
|
-
let i =
|
|
1059
|
+
function we(e, t, n, r) {
|
|
1060
|
+
let i = V(t.runs, e), a = P(t);
|
|
1029
1061
|
if (i.length === 0) {
|
|
1030
|
-
let { asc: n, desc: i } =
|
|
1031
|
-
return
|
|
1062
|
+
let { asc: n, desc: i } = Q(Y(t), r);
|
|
1063
|
+
return Z(t.lineSpacing, n, i, r, e.docGrid, a, X(t, r));
|
|
1032
1064
|
}
|
|
1033
|
-
return
|
|
1065
|
+
return U(e.ctx, i, n, 0, r, t.tabStops, void 0, e.fontFamilyClasses).reduce((n, i) => n + Z(t.lineSpacing, i.ascent, i.descent, r, e.docGrid, a, i.intendedSingle), 0);
|
|
1034
1066
|
}
|
|
1035
|
-
function
|
|
1067
|
+
function G(e, t) {
|
|
1036
1068
|
return {
|
|
1037
1069
|
top: e.marginTop ?? t.cellMarginTop,
|
|
1038
1070
|
bottom: e.marginBottom ?? t.cellMarginBottom,
|
|
@@ -1040,54 +1072,54 @@ function W(e, t) {
|
|
|
1040
1072
|
right: e.marginRight ?? t.cellMarginRight
|
|
1041
1073
|
};
|
|
1042
1074
|
}
|
|
1043
|
-
function
|
|
1044
|
-
let a =
|
|
1045
|
-
for (let t of e.content)
|
|
1075
|
+
function Te(e, t, n, r, i) {
|
|
1076
|
+
let a = G(e, t), o = a.left * r, s = a.right * r, c = n - o - s;
|
|
1077
|
+
for (let t of e.content) K(i, t, c, r);
|
|
1046
1078
|
}
|
|
1047
|
-
function
|
|
1079
|
+
function K(e, t, n, r) {
|
|
1048
1080
|
if (t.type === "paragraph") {
|
|
1049
1081
|
let i = t;
|
|
1050
|
-
return
|
|
1082
|
+
return we(e, i, n, r) + (i.spaceBefore + i.spaceAfter) * r;
|
|
1051
1083
|
}
|
|
1052
1084
|
return I(e, t, n / r) * r;
|
|
1053
1085
|
}
|
|
1054
|
-
function
|
|
1086
|
+
function Ee(e, t, n, r, i, a, o) {
|
|
1055
1087
|
let { ctx: s, scale: c } = o;
|
|
1056
|
-
e.background && (s.fillStyle = `#${e.background}`, s.fillRect(n, r, i, a)),
|
|
1057
|
-
let l =
|
|
1088
|
+
e.background && (s.fillStyle = `#${e.background}`, s.fillRect(n, r, i, a)), ke(s, n, r, i, a, e.borders, t.borders, c);
|
|
1089
|
+
let l = G(e, t), u = l.top * c, d = l.bottom * c, f = l.left * c, p = l.right * c, m = {
|
|
1058
1090
|
...o,
|
|
1059
1091
|
contentX: n + f,
|
|
1060
1092
|
contentW: i - f - p,
|
|
1061
1093
|
y: r + u
|
|
1062
1094
|
};
|
|
1063
1095
|
if (e.vAlign === "center" || e.vAlign === "bottom") {
|
|
1064
|
-
let t =
|
|
1096
|
+
let t = De(e.content).reduce((e, t) => e + K(m, t, i - f - p, c), 0);
|
|
1065
1097
|
e.vAlign === "center" ? m.y = r + (a - t) / 2 : m.y = r + a - t - d;
|
|
1066
1098
|
}
|
|
1067
|
-
|
|
1099
|
+
Oe(e.content, m);
|
|
1068
1100
|
}
|
|
1069
|
-
function
|
|
1101
|
+
function De(e) {
|
|
1070
1102
|
if (e.length < 2) return e;
|
|
1071
1103
|
let t = e[e.length - 1], n = e[e.length - 2];
|
|
1072
1104
|
return t.type !== "paragraph" || n.type === "paragraph" || t.runs.length > 0 ? e : e.slice(0, -1);
|
|
1073
1105
|
}
|
|
1074
|
-
function
|
|
1106
|
+
function Oe(e, t) {
|
|
1075
1107
|
let n = null, r = 0;
|
|
1076
1108
|
for (let i of e) if (i.type === "paragraph") {
|
|
1077
1109
|
let e = i, a = R(n, e), o = a ? 0 : e.spaceBefore;
|
|
1078
|
-
t.y -= Math.min(r, o) * t.scale,
|
|
1079
|
-
} else i.type === "table" && (
|
|
1110
|
+
t.y -= Math.min(r, o) * t.scale, B(e, t, a), n = e, r = e.spaceAfter;
|
|
1111
|
+
} else i.type === "table" && (xe(i, t), n = null, r = 0);
|
|
1080
1112
|
}
|
|
1081
|
-
function
|
|
1113
|
+
function ke(e, t, n, r, i, a, o, s) {
|
|
1082
1114
|
let c = a.top ?? o.top, l = a.bottom ?? o.bottom, u = a.left ?? o.left, d = a.right ?? o.right;
|
|
1083
|
-
c && c.style !== "none" &&
|
|
1115
|
+
c && c.style !== "none" && q(e, t, n, t + r, n, c, s), l && l.style !== "none" && q(e, t, n + i, t + r, n + i, l, s), u && u.style !== "none" && q(e, t, n, t, n + i, u, s), d && d.style !== "none" && q(e, t + r, n, t + r, n + i, d, s);
|
|
1084
1116
|
}
|
|
1085
|
-
function
|
|
1117
|
+
function q(e, t, n, r, i, a, o) {
|
|
1086
1118
|
e.save(), e.strokeStyle = a.color ? `#${a.color}` : "#000000", e.lineWidth = Math.max(.5, a.width * o), e.beginPath(), e.moveTo(t, n), e.lineTo(r, i), e.stroke(), e.restore();
|
|
1087
1119
|
}
|
|
1088
|
-
function
|
|
1120
|
+
function Ae(e, t, n, r, i, a, o) {
|
|
1089
1121
|
let s = (t, n, r, i, a) => {
|
|
1090
|
-
!t || t.style === "none" ||
|
|
1122
|
+
!t || t.style === "none" || q(e, n, r, i, a, {
|
|
1091
1123
|
width: t.width,
|
|
1092
1124
|
color: t.color,
|
|
1093
1125
|
style: t.style
|
|
@@ -1095,14 +1127,14 @@ function Oe(e, t, n, r, i, a, o) {
|
|
|
1095
1127
|
}, c = (e) => (e?.space ?? 0) * o;
|
|
1096
1128
|
s(a.top, t, n - c(a.top), t + r, n - c(a.top)), s(a.bottom, t, n + i + c(a.bottom), t + r, n + i + c(a.bottom)), s(a.left, t - c(a.left), n, t - c(a.left), n + i), s(a.right, t + r + c(a.right), n, t + r + c(a.right), n + i);
|
|
1097
1129
|
}
|
|
1098
|
-
function
|
|
1130
|
+
function je(e, t) {
|
|
1099
1131
|
let n = e.fontSize * t;
|
|
1100
1132
|
return e.smallCaps && (n *= .8), e.vertAlign && (n *= .65), n;
|
|
1101
1133
|
}
|
|
1102
|
-
function
|
|
1103
|
-
return `${t ? "italic" : "normal"} ${e ? "bold" : "normal"} ${n}px ${
|
|
1134
|
+
function J(e, t, n, r, i = {}) {
|
|
1135
|
+
return `${t ? "italic" : "normal"} ${e ? "bold" : "normal"} ${n}px ${Me(r, i)}`;
|
|
1104
1136
|
}
|
|
1105
|
-
function
|
|
1137
|
+
function Me(e, t = {}) {
|
|
1106
1138
|
if (!e) return "\"Noto Sans JP\", \"Hiragino Sans\", \"Meiryo\", sans-serif";
|
|
1107
1139
|
let n = `"${((e) => e.replace(/"/g, "\\\""))(e)}"`, r = e.toLowerCase(), i = t[e];
|
|
1108
1140
|
if (i && i !== "auto") switch (i) {
|
|
@@ -1113,25 +1145,25 @@ function Ae(e, t = {}) {
|
|
|
1113
1145
|
}
|
|
1114
1146
|
return e.includes("明朝") || e.includes("明朝体") || /\bmincho\b/i.test(e) || /\bmin\s*cho\b/i.test(e) || e.includes("MS 明朝") || e.includes("MS Mincho") || e.includes("Yu Mincho") || e.includes("游明朝") || e.includes("Hiragino Mincho") || e.includes("ヒラギノ明朝") || e.includes("Cambria") || e.includes("Caladea") || e.includes("Times") || e.includes("Georgia") || e.includes("Bodoni") || e.includes("Garamond") || e.includes("Playfair") || e.includes("Source Serif") || e.includes("Noto Serif") ? `${n}, "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "MS Mincho", "Noto Serif JP", "Noto Serif", serif` : r.includes("meiryo") || e.includes("メイリオ") ? `${n}, "Meiryo UI", "Meiryo", "Noto Sans JP", "Hiragino Sans", sans-serif` : e.includes("游ゴシック") || /\byu\s*gothic\b/i.test(e) || r.includes("yugothic") ? `${n}, "Yu Gothic", "YuGothic", "Noto Sans JP", "Hiragino Sans", sans-serif` : r.includes("ipa") ? `${n}, "IPAexGothic", "Noto Sans JP", "Hiragino Sans", sans-serif` : r.includes("segoe") ? `${n}, "Segoe UI", sans-serif` : `${n}, "Noto Sans JP", "Hiragino Sans", "Meiryo", sans-serif`;
|
|
1115
1147
|
}
|
|
1116
|
-
function
|
|
1148
|
+
function Y(e) {
|
|
1117
1149
|
for (let t of e.runs) if (t.type === "text" || t.type === "field") return t.fontSize;
|
|
1118
1150
|
return typeof e.defaultFontSize == "number" ? e.defaultFontSize : 10;
|
|
1119
1151
|
}
|
|
1120
|
-
function
|
|
1152
|
+
function Ne(e) {
|
|
1121
1153
|
for (let t of e.runs) if (t.type === "text" || t.type === "field") return t.fontFamily;
|
|
1122
1154
|
return e.defaultFontFamily ?? null;
|
|
1123
1155
|
}
|
|
1124
|
-
function
|
|
1125
|
-
return g(
|
|
1156
|
+
function X(e, t) {
|
|
1157
|
+
return g(Ne(e), Y(e) * t);
|
|
1126
1158
|
}
|
|
1127
|
-
function
|
|
1159
|
+
function Pe(e) {
|
|
1128
1160
|
return !e || !e.linePitchPt || e.linePitchPt <= 0 ? !1 : e.type === "lines" || e.type === "linesAndChars";
|
|
1129
1161
|
}
|
|
1130
|
-
function
|
|
1131
|
-
let s = t + n, c = Math.max(s, o), l =
|
|
1162
|
+
function Z(e, t, n, r, i, a, o = 0) {
|
|
1163
|
+
let s = t + n, c = Math.max(s, o), l = Pe(i), u = l ? i.linePitchPt * r : 0, d = e !== null && e.explicit !== !0;
|
|
1132
1164
|
return e ? e.rule === "auto" ? l ? d ? Math.max(s, u) : Math.max(s, u * e.value) : c * e.value : e.rule === "exact" ? e.value * r : e.rule === "atLeast" ? Math.max(c, e.value * r) : c : l ? Math.max(s, u) : c;
|
|
1133
1165
|
}
|
|
1134
|
-
function
|
|
1166
|
+
function Q(e, t) {
|
|
1135
1167
|
return {
|
|
1136
1168
|
asc: e * t * .8,
|
|
1137
1169
|
desc: e * t * .2
|
|
@@ -1139,7 +1171,7 @@ function Z(e, t) {
|
|
|
1139
1171
|
}
|
|
1140
1172
|
//#endregion
|
|
1141
1173
|
//#region packages/docx/src/document.ts
|
|
1142
|
-
var
|
|
1174
|
+
var Fe = {
|
|
1143
1175
|
calibri: {
|
|
1144
1176
|
url: "https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap",
|
|
1145
1177
|
loadFamily: "Carlito"
|
|
@@ -1157,7 +1189,7 @@ var Ne = {
|
|
|
1157
1189
|
poppins: { url: "https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,700;1,400;1,700&display=swap" },
|
|
1158
1190
|
raleway: { url: "https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,400;0,700;1,400;1,700&display=swap" },
|
|
1159
1191
|
"playfair display": { url: "https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,700&display=swap" }
|
|
1160
|
-
},
|
|
1192
|
+
}, $ = class e {
|
|
1161
1193
|
_document = null;
|
|
1162
1194
|
_pages = null;
|
|
1163
1195
|
_worker;
|
|
@@ -1180,7 +1212,7 @@ var Ne = {
|
|
|
1180
1212
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
1181
1213
|
a = await e.arrayBuffer();
|
|
1182
1214
|
} else a = n;
|
|
1183
|
-
return await i._parse(a, r.maxZipEntryBytes), r.useGoogleFonts && await t([i._document?.majorFont, i._document?.minorFont],
|
|
1215
|
+
return await i._parse(a, r.maxZipEntryBytes), r.useGoogleFonts && await t([i._document?.majorFont, i._document?.minorFont], Fe), r.math && i._document && y(i._document.body) && await S(i._document.body, r.math), i;
|
|
1184
1216
|
}
|
|
1185
1217
|
async _parse(e, t) {
|
|
1186
1218
|
this._document = (await this._bridge.request((n) => ({
|
|
@@ -1215,7 +1247,7 @@ var Ne = {
|
|
|
1215
1247
|
prebuiltPages: r
|
|
1216
1248
|
});
|
|
1217
1249
|
}
|
|
1218
|
-
},
|
|
1250
|
+
}, Ie = class {
|
|
1219
1251
|
_doc = null;
|
|
1220
1252
|
_currentPage = 0;
|
|
1221
1253
|
_canvas;
|
|
@@ -1229,7 +1261,7 @@ var Ne = {
|
|
|
1229
1261
|
}
|
|
1230
1262
|
async load(e) {
|
|
1231
1263
|
try {
|
|
1232
|
-
this._doc = await
|
|
1264
|
+
this._doc = await $.load(e, {
|
|
1233
1265
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
1234
1266
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
1235
1267
|
math: this._opts.math
|
|
@@ -1279,10 +1311,10 @@ var Ne = {
|
|
|
1279
1311
|
t.textContent = n.text, t.style.cssText = `position:absolute;left:${n.x}px;top:${n.y}px;font:${n.font};line-height:${n.h}px;letter-spacing:0;white-space:pre;color:transparent;cursor:text;pointer-events:all;`, e.appendChild(t);
|
|
1280
1312
|
}
|
|
1281
1313
|
}
|
|
1282
|
-
},
|
|
1283
|
-
DocxDocument: () =>
|
|
1284
|
-
DocxViewer: () =>
|
|
1314
|
+
}, Le = /* @__PURE__ */ n({
|
|
1315
|
+
DocxDocument: () => $,
|
|
1316
|
+
DocxViewer: () => Ie,
|
|
1285
1317
|
autoResize: () => e
|
|
1286
1318
|
});
|
|
1287
1319
|
//#endregion
|
|
1288
|
-
export {
|
|
1320
|
+
export { Ie as n, $ as r, Le as t };
|
package/dist/docx.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./xlsx-
|
|
1
|
+
import { t as e } from "./xlsx-BO-a3nOm.js";
|
|
2
2
|
import { t } from "./pptx-DefKBJxp.js";
|
|
3
|
-
import { t as n } from "./docx-
|
|
3
|
+
import { t as n } from "./docx-BmrIhf6p.js";
|
|
4
4
|
export { n as docx, t as pptx, e as xlsx };
|
|
@@ -3172,10 +3172,12 @@ var cn = class {
|
|
|
3172
3172
|
updateTabActive(e) {
|
|
3173
3173
|
this.tabs.forEach((t, n) => {
|
|
3174
3174
|
t.style.cssText = this.tabStyle(n === e, this.tabColors[n]);
|
|
3175
|
-
}), this.tabs[e]?.scrollIntoView({
|
|
3176
|
-
block: "nearest",
|
|
3177
|
-
inline: "nearest"
|
|
3178
3175
|
});
|
|
3176
|
+
let t = this.tabs[e];
|
|
3177
|
+
if (t) {
|
|
3178
|
+
let e = this.tabStrip, n = t.getBoundingClientRect(), r = e.getBoundingClientRect();
|
|
3179
|
+
n.left < r.left ? e.scrollLeft -= r.left - n.left : n.right > r.right && (e.scrollLeft += n.right - r.right);
|
|
3180
|
+
}
|
|
3179
3181
|
}
|
|
3180
3182
|
tabStyle(e, t) {
|
|
3181
3183
|
let n = nn - 2, r = nn - 5, i = t ? `box-shadow:inset 0 -${e ? 2 : 3}px 0 0 ${t};` : "";
|
package/dist/xlsx.mjs
CHANGED
package/package.json
CHANGED