@silurus/ooxml 0.60.2 → 0.61.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/dist/{docx-C-Xv4gHb.js → docx-DcHz7cyz.js} +388 -348
- package/dist/docx.mjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{pptx-CcRBxO-i.js → pptx-XdCbndbT.js} +2 -2
- package/dist/pptx.mjs +1 -1
- package/dist/render-worker-host-BbPdLKW3.js +27 -0
- package/dist/{render-worker-host-qS8zOCxE.js → render-worker-host-CZI8tWId.js} +1 -1
- package/package.json +1 -1
- package/dist/render-worker-host-BD-wqOCv.js +0 -27
|
@@ -72,8 +72,8 @@ function te(e) {
|
|
|
72
72
|
}
|
|
73
73
|
return !1;
|
|
74
74
|
}
|
|
75
|
-
var
|
|
76
|
-
function
|
|
75
|
+
var ne = "", I = /[\p{P}\p{S}]/u;
|
|
76
|
+
function re(e, t) {
|
|
77
77
|
let n = e.length;
|
|
78
78
|
if (n === 0) return {
|
|
79
79
|
order: [],
|
|
@@ -85,11 +85,11 @@ function ne(e, t) {
|
|
|
85
85
|
};
|
|
86
86
|
for (let t = 0; t < n; t++) {
|
|
87
87
|
let n = N(e[t]) ?? "";
|
|
88
|
-
if (i[t] = r.length, r += n.length > 0 ? n :
|
|
88
|
+
if (i[t] = r.length, r += n.length > 0 ? n : ne, a[t] = r.length, n.length > 0 && (F(e[t]) || P(e[t]))) {
|
|
89
89
|
let n = s(), o = F(e[t]), c = P(e[t]);
|
|
90
90
|
for (let e = i[t]; e < a[t]; e++) {
|
|
91
91
|
let t = r.charCodeAt(e);
|
|
92
|
-
o && t >= 48 && t <= 57 ? n[e] = "AN" : c &&
|
|
92
|
+
o && t >= 48 && t <= 57 ? n[e] = "AN" : c && I.test(r[e]) && (n[e] = "R");
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -115,7 +115,7 @@ function ne(e, t) {
|
|
|
115
115
|
rtl: f
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function ie(e, t) {
|
|
119
119
|
switch (e) {
|
|
120
120
|
case "center": return "center";
|
|
121
121
|
case "both":
|
|
@@ -129,13 +129,13 @@ function re(e, t) {
|
|
|
129
129
|
default: return t ? "right" : "left";
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function ae(e) {
|
|
133
133
|
return e === "square" || e === "topAndBottom" || e === "tight" || e === "through";
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function oe(e, t, n, r, i, a, o, s) {
|
|
136
136
|
return e < a - .01 && t > i + .01 && n < s - .01 && r > o + .01;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function se(e, t, n) {
|
|
139
139
|
let r = e.slice().sort((e, t) => e.l - t.l), i = t, a = null, o = (e, t) => {
|
|
140
140
|
t - e > (a ? a.r - a.l : 0) && (a = {
|
|
141
141
|
l: e,
|
|
@@ -145,7 +145,7 @@ function oe(e, t, n) {
|
|
|
145
145
|
for (let e of r) if (e.l > i && o(i, Math.min(e.l, n)), i = Math.max(i, Math.min(e.r, n)), i >= n) break;
|
|
146
146
|
return i < n && o(i, n), a;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function ce(e, t, n, r, i, a) {
|
|
149
149
|
for (let t = 0; t < 16; t++) {
|
|
150
150
|
let t = e + n, r = null;
|
|
151
151
|
for (let n of a) n.mode === "topAndBottom" && t > n.yTop && e < n.yBottom && (r = r === null ? n.yBottom : Math.max(r, n.yBottom));
|
|
@@ -179,7 +179,7 @@ function se(e, t, n, r, i, a) {
|
|
|
179
179
|
l = 0, u = i;
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
|
-
let f =
|
|
182
|
+
let f = se(r, o, s);
|
|
183
183
|
if (f && f.r - f.l >= c) {
|
|
184
184
|
l = Math.max(0, f.l - o), u = Math.min(i - l, f.r - f.l), u < 0 && (u = 0);
|
|
185
185
|
break;
|
|
@@ -197,9 +197,9 @@ function se(e, t, n, r, i, a) {
|
|
|
197
197
|
maxWidth: u
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function le(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
201
201
|
for (let f = 0; f < 16; f++) {
|
|
202
|
-
let f = e - i, p = e + n + a, m = t - o, h = t + r + s, g = d.filter((e) => (l ? e.paraId !== c : !0) &&
|
|
202
|
+
let f = e - i, p = e + n + a, m = t - o, h = t + r + s, g = d.filter((e) => (l ? e.paraId !== c : !0) && oe(f, p, m, h, e.xLeft, e.xRight, e.yTop, e.yBottom));
|
|
203
203
|
if (g.length === 0) return {
|
|
204
204
|
x: e,
|
|
205
205
|
y: t
|
|
@@ -216,7 +216,7 @@ function ce(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
216
216
|
y: t
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function ue(e, t) {
|
|
220
220
|
for (let n = 0; n < 16; n++) {
|
|
221
221
|
let n = e;
|
|
222
222
|
for (let r of t) r.mode === "topAndBottom" && e >= r.yTop && e < r.yBottom && (n = Math.max(n, r.yBottom));
|
|
@@ -227,7 +227,7 @@ function le(e, t) {
|
|
|
227
227
|
}
|
|
228
228
|
//#endregion
|
|
229
229
|
//#region packages/docx/src/renderer.ts
|
|
230
|
-
var
|
|
230
|
+
var de = {
|
|
231
231
|
yellow: "#FFFF00",
|
|
232
232
|
cyan: "#00FFFF",
|
|
233
233
|
green: "#00FF00",
|
|
@@ -244,11 +244,11 @@ var ue = {
|
|
|
244
244
|
lightGray: "#C0C0C0",
|
|
245
245
|
black: "#000000",
|
|
246
246
|
white: "#FFFFFF"
|
|
247
|
-
},
|
|
248
|
-
function de(e) {
|
|
249
|
-
return fe(e).length > 0;
|
|
250
|
-
}
|
|
247
|
+
}, L = /* @__PURE__ */ new WeakMap();
|
|
251
248
|
function fe(e) {
|
|
249
|
+
return pe(e).length > 0;
|
|
250
|
+
}
|
|
251
|
+
function pe(e) {
|
|
252
252
|
let t = [], n = (e) => {
|
|
253
253
|
for (let n of e) n.type === "math" && t.push({
|
|
254
254
|
nodes: n.nodes,
|
|
@@ -259,19 +259,19 @@ function fe(e) {
|
|
|
259
259
|
};
|
|
260
260
|
return e.forEach(r), t;
|
|
261
261
|
}
|
|
262
|
-
function
|
|
262
|
+
function me(e) {
|
|
263
263
|
let t = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`, n = new Image();
|
|
264
264
|
return new Promise((e, r) => {
|
|
265
265
|
n.onload = () => e(n), n.onerror = r, n.src = t;
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
|
-
async function
|
|
269
|
-
let n =
|
|
268
|
+
async function he(e, t) {
|
|
269
|
+
let n = pe(e);
|
|
270
270
|
if (n.length !== 0) {
|
|
271
271
|
await t.loadMathJax();
|
|
272
|
-
for (let e of n) if (!
|
|
273
|
-
let n = await t.mathMLToSvg(v(e.nodes, e.display)), r = await
|
|
274
|
-
|
|
272
|
+
for (let e of n) if (!L.has(e.nodes)) try {
|
|
273
|
+
let n = await t.mathMLToSvg(v(e.nodes, e.display)), r = await me(C(n.svg, "#000000"));
|
|
274
|
+
L.set(e.nodes, {
|
|
275
275
|
img: r,
|
|
276
276
|
widthEm: n.widthEm,
|
|
277
277
|
ascentEm: n.ascentEm,
|
|
@@ -280,10 +280,10 @@ async function me(e, t) {
|
|
|
280
280
|
} catch {}
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function R(e, t) {
|
|
284
284
|
return t ? `${e}|clr:${t}` : e;
|
|
285
285
|
}
|
|
286
|
-
var
|
|
286
|
+
var ge = [
|
|
287
287
|
"#C00000",
|
|
288
288
|
"#0070C0",
|
|
289
289
|
"#00B050",
|
|
@@ -293,16 +293,16 @@ var he = [
|
|
|
293
293
|
"#9E480E",
|
|
294
294
|
"#525252"
|
|
295
295
|
];
|
|
296
|
-
function
|
|
297
|
-
if (!e) return
|
|
296
|
+
function _e(e) {
|
|
297
|
+
if (!e) return ge[0];
|
|
298
298
|
let t = 2166136261;
|
|
299
299
|
for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
300
|
-
return
|
|
300
|
+
return ge[Math.abs(t) % ge.length];
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function ve(e) {
|
|
303
303
|
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
304
304
|
for (let n of e) if (n.type === "image") {
|
|
305
|
-
let e = n, r =
|
|
305
|
+
let e = n, r = R(e.dataUrl, e.colorReplaceFrom);
|
|
306
306
|
t.has(r) || t.set(r, {
|
|
307
307
|
url: e.dataUrl,
|
|
308
308
|
colorReplaceFrom: e.colorReplaceFrom
|
|
@@ -315,35 +315,35 @@ function _e(e) {
|
|
|
315
315
|
};
|
|
316
316
|
return i(e.body), e.headers.default && i(e.headers.default.body), e.headers.first && i(e.headers.first.body), e.headers.even && i(e.headers.even.body), e.footers.default && i(e.footers.default.body), e.footers.first && i(e.footers.first.body), e.footers.even && i(e.footers.even.body), [...t.values()];
|
|
317
317
|
}
|
|
318
|
-
async function
|
|
318
|
+
async function ye(e, t) {
|
|
319
319
|
let n = parseInt(t.slice(0, 2), 16), r = parseInt(t.slice(2, 4), 16), i = parseInt(t.slice(4, 6), 16), a = new OffscreenCanvas(e.width, e.height), o = a.getContext("2d");
|
|
320
320
|
o.drawImage(e, 0, 0);
|
|
321
321
|
let s = o.getImageData(0, 0, e.width, e.height), c = s.data;
|
|
322
322
|
for (let e = 0; e < c.length; e += 4) c[e] === n && c[e + 1] === r && c[e + 2] === i && (c[e + 3] = 0);
|
|
323
323
|
return o.putImageData(s, 0, 0), createImageBitmap(a);
|
|
324
324
|
}
|
|
325
|
-
async function
|
|
326
|
-
let t =
|
|
325
|
+
async function be(e) {
|
|
326
|
+
let t = ve(e), n = await Promise.all(t.map(async (e) => {
|
|
327
327
|
try {
|
|
328
328
|
let t = await (await fetch(e.url)).blob(), n = await createImageBitmap(t);
|
|
329
|
-
return e.colorReplaceFrom && (n = await
|
|
329
|
+
return e.colorReplaceFrom && (n = await ye(n, e.colorReplaceFrom)), [R(e.url, e.colorReplaceFrom), n];
|
|
330
330
|
} catch {
|
|
331
331
|
return null;
|
|
332
332
|
}
|
|
333
333
|
}));
|
|
334
334
|
return new Map(n.filter((e) => e !== null));
|
|
335
335
|
}
|
|
336
|
-
async function
|
|
336
|
+
async function xe(e, t, n, r = {}) {
|
|
337
337
|
let i = t, a = i.__docxRenderToken = (i.__docxRenderToken ?? 0) + 1, o = () => i.__docxRenderToken !== a, s = e.section, c = r.dpr ?? g(), l = r.width ?? s.pageWidth * 1.3333333333333333, u = l / s.pageWidth, d = s.pageHeight * u;
|
|
338
338
|
t.width = Math.round(l * c), t.height = Math.round(d * c), h(t) && (t.style.width = `${l}px`, t.style.height = `${d}px`, t.style.display || (t.style.display = "block"));
|
|
339
339
|
let f = t.getContext("2d");
|
|
340
340
|
f.scale(c, c), f.fillStyle = "#ffffff", f.fillRect(0, 0, l, d);
|
|
341
|
-
let p =
|
|
341
|
+
let p = st(e.settings), m = r.prebuiltPages ?? je(e.body, s, f, e.fontFamilyClasses ?? {}, p, e.footnotes ?? []), _ = Math.max(r.totalPages ?? m.length, m.length), v = m[n] ?? m[0] ?? [], y = await be(e);
|
|
342
342
|
if (o()) return;
|
|
343
|
-
let b =
|
|
343
|
+
let b = Ee(e.footnotes), x = Ee(e.endnotes), S = /* @__PURE__ */ new Map();
|
|
344
344
|
for (let [e, t] of b) S.set(`footnote:${e}`, t);
|
|
345
345
|
for (let [e, t] of x) S.set(`endnote:${e}`, t);
|
|
346
|
-
let C = {
|
|
346
|
+
let C = Ie(e.body), w = {
|
|
347
347
|
ctx: f,
|
|
348
348
|
scale: u,
|
|
349
349
|
contentX: s.marginLeft * u,
|
|
@@ -366,42 +366,43 @@ async function be(e, t, n, r = {}) {
|
|
|
366
366
|
type: s.docGridType ?? null,
|
|
367
367
|
linePitchPt: s.docGridLinePitch ?? null
|
|
368
368
|
},
|
|
369
|
+
docEastAsian: C,
|
|
369
370
|
fontFamilyClasses: e.fontFamilyClasses ?? {},
|
|
370
371
|
kinsoku: p,
|
|
371
372
|
mathDefJc: e.settings?.mathDefJc,
|
|
372
373
|
onTextRun: r.onTextRun,
|
|
373
374
|
showTrackChanges: r.showTrackChanges ?? !0,
|
|
374
375
|
noteNumbers: S
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
let
|
|
378
|
-
if (
|
|
379
|
-
let e =
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
let
|
|
383
|
-
...
|
|
376
|
+
}, T = Ke(e.headers, n, _, e.section.titlePage, e.section.evenAndOddHeaders);
|
|
377
|
+
T && qe(T, s.headerDistance * u, w);
|
|
378
|
+
let E = Ke(e.footers, n, _, e.section.titlePage, e.section.evenAndOddHeaders);
|
|
379
|
+
if (E) {
|
|
380
|
+
let e = Je(E, w);
|
|
381
|
+
qe(E, d - s.footerDistance * u - e, w);
|
|
382
|
+
}
|
|
383
|
+
let D = {
|
|
384
|
+
...w,
|
|
384
385
|
y: s.marginTop * u
|
|
385
386
|
};
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
function xe(e, t, n, r, i) {
|
|
389
|
-
return De(e, je(t, n, r, i), n.pageWidth - n.marginLeft - n.marginRight);
|
|
387
|
+
Ye(v, D), Ce(v, e, w, u, d, s), n === _ - 1 && we(e, D, u, d, s);
|
|
390
388
|
}
|
|
391
389
|
function Se(e, t, n, r, i, a) {
|
|
390
|
+
return ke(e, Ne(t, n, r, i, a), n.pageWidth - n.marginLeft - n.marginRight);
|
|
391
|
+
}
|
|
392
|
+
function Ce(e, t, n, r, i, a) {
|
|
392
393
|
if (!t.footnotes || t.footnotes.length === 0) return;
|
|
393
|
-
let o =
|
|
394
|
+
let o = De(t.footnotes), s = [], c = /* @__PURE__ */ new Set();
|
|
394
395
|
if (((e) => {
|
|
395
|
-
for (let t of e) if (t.type === "paragraph") for (let e of
|
|
396
|
+
for (let t of e) if (t.type === "paragraph") for (let e of Oe(t.runs)) !c.has(e) && o.has(e) && (c.add(e), s.push(e));
|
|
396
397
|
})(e), s.length === 0) return;
|
|
397
398
|
let l = 0, u = 0;
|
|
398
399
|
for (let e of s) {
|
|
399
400
|
let t = o.get(e);
|
|
400
401
|
if (!t) continue;
|
|
401
|
-
let r =
|
|
402
|
+
let r = Se(t, n.ctx, a, n.fontFamilyClasses, n.kinsoku, n.docEastAsian);
|
|
402
403
|
l += r.total, u = r.trailingSpaceAfter;
|
|
403
404
|
}
|
|
404
|
-
let d = Math.max(0, l - u), f =
|
|
405
|
+
let d = Math.max(0, l - u), f = Te * r, p = i - a.marginBottom * r - d * r, m = a.marginLeft * r, h = Math.round(p - f), g = n.ctx;
|
|
405
406
|
g.save(), g.strokeStyle = n.defaultColor, g.lineWidth = Math.max(1, Math.round(.5 * r)), g.beginPath(), g.moveTo(m, h + .5), g.lineTo(m + (a.pageWidth - a.marginLeft - a.marginRight) * r / 3, h + .5), g.stroke(), g.restore();
|
|
406
407
|
let _ = {
|
|
407
408
|
...n,
|
|
@@ -409,35 +410,35 @@ function Se(e, t, n, r, i, a) {
|
|
|
409
410
|
};
|
|
410
411
|
for (let e of s) {
|
|
411
412
|
let n = o.get(e);
|
|
412
|
-
n && (_.currentNoteNumber = t.footnotes.findIndex((t) => t.id === e) + 1,
|
|
413
|
+
n && (_.currentNoteNumber = t.footnotes.findIndex((t) => t.id === e) + 1, Xe(n.content.filter((e) => e.type === "paragraph"), _));
|
|
413
414
|
}
|
|
414
415
|
}
|
|
415
|
-
function
|
|
416
|
+
function we(e, t, n, r, i) {
|
|
416
417
|
if (!e.endnotes || e.endnotes.length === 0) return;
|
|
417
418
|
let a = e.endnotes.filter((e) => e.content.some((e) => e.type === "paragraph" && e.runs.length > 0));
|
|
418
419
|
if (a.length === 0) return;
|
|
419
|
-
let o = t.ctx, s = t.y +
|
|
420
|
+
let o = t.ctx, s = t.y + Te * 2 * n;
|
|
420
421
|
if (s >= r - i.marginBottom * n) return;
|
|
421
422
|
let c = i.marginLeft * n;
|
|
422
423
|
o.save(), o.strokeStyle = t.defaultColor, o.lineWidth = Math.max(1, Math.round(.5 * n)), o.beginPath(), o.moveTo(c, Math.round(s) + .5), o.lineTo(c + (i.pageWidth - i.marginLeft - i.marginRight) * n / 3, Math.round(s) + .5), o.stroke(), o.restore();
|
|
423
424
|
let l = {
|
|
424
425
|
...t,
|
|
425
|
-
y: s +
|
|
426
|
+
y: s + Te * n
|
|
426
427
|
};
|
|
427
|
-
for (let t of a) l.currentNoteNumber = e.endnotes.findIndex((e) => e.id === t.id) + 1,
|
|
428
|
+
for (let t of a) l.currentNoteNumber = e.endnotes.findIndex((e) => e.id === t.id) + 1, Xe(t.content.filter((e) => e.type === "paragraph"), l);
|
|
428
429
|
}
|
|
429
|
-
var
|
|
430
|
-
function
|
|
430
|
+
var Te = 6;
|
|
431
|
+
function Ee(e) {
|
|
431
432
|
let t = /* @__PURE__ */ new Map();
|
|
432
433
|
return e && e.forEach((e, n) => t.set(e.id, n + 1)), t;
|
|
433
434
|
}
|
|
434
|
-
function
|
|
435
|
+
function De(e) {
|
|
435
436
|
let t = /* @__PURE__ */ new Map();
|
|
436
437
|
if (!e) return t;
|
|
437
438
|
for (let n of e) t.set(n.id, n);
|
|
438
439
|
return t;
|
|
439
440
|
}
|
|
440
|
-
function
|
|
441
|
+
function Oe(e) {
|
|
441
442
|
let t = [];
|
|
442
443
|
for (let n of e) {
|
|
443
444
|
if (n.type !== "text") continue;
|
|
@@ -446,24 +447,24 @@ function Ee(e) {
|
|
|
446
447
|
}
|
|
447
448
|
return t;
|
|
448
449
|
}
|
|
449
|
-
function
|
|
450
|
+
function ke(e, t, n) {
|
|
450
451
|
let r = 0, i = 0;
|
|
451
452
|
for (let a of e.content) {
|
|
452
453
|
if (a.type !== "paragraph") continue;
|
|
453
454
|
let e = a;
|
|
454
|
-
r +=
|
|
455
|
+
r += z(t, e, n, !1), i = e.spaceAfter;
|
|
455
456
|
}
|
|
456
457
|
return {
|
|
457
458
|
total: r,
|
|
458
459
|
trailingSpaceAfter: i
|
|
459
460
|
};
|
|
460
461
|
}
|
|
461
|
-
function
|
|
462
|
-
let { total: i, trailingSpaceAfter: a } =
|
|
463
|
-
return Math.max(0, i - a) + (r ?
|
|
462
|
+
function Ae(e, t, n, r) {
|
|
463
|
+
let { total: i, trailingSpaceAfter: a } = ke(e, t, n);
|
|
464
|
+
return Math.max(0, i - a) + (r ? Te : 0);
|
|
464
465
|
}
|
|
465
|
-
function
|
|
466
|
-
let o = t.pageHeight - t.marginTop - t.marginBottom, s = t.pageWidth - t.marginLeft - t.marginRight, c =
|
|
466
|
+
function je(e, t, n, r = {}, i = ct, a = []) {
|
|
467
|
+
let o = t.pageHeight - t.marginTop - t.marginBottom, s = t.pageWidth - t.marginLeft - t.marginRight, c = Ne(n, t, r, i, Ie(e)), l = De(a), u = l.size > 0, d = [0], f = [[]], p = 0, m = null, h = 0;
|
|
467
468
|
c.y = t.marginTop, c.floats = [], c.floatParaSeq = 0;
|
|
468
469
|
let g = /* @__PURE__ */ new Set(), _ = () => o - (d[f.length - 1] ?? 0), v = () => {
|
|
469
470
|
d[f.length - 1] = 0, g = /* @__PURE__ */ new Set();
|
|
@@ -475,13 +476,13 @@ function ke(e, t, n, r = {}, i = it, a = []) {
|
|
|
475
476
|
if (r.type !== "image") continue;
|
|
476
477
|
let e = r;
|
|
477
478
|
if (!e.anchor || !e.anchorYFromPara) continue;
|
|
478
|
-
let i = (
|
|
479
|
+
let i = (ae(e.wrapMode) ? t : 0) + (e.anchorYPt ?? 0) + e.heightPt;
|
|
479
480
|
i > n && (n = i);
|
|
480
481
|
}
|
|
481
482
|
return n;
|
|
482
483
|
}, x = (t) => {
|
|
483
484
|
let n = e[t];
|
|
484
|
-
return n ? n.type === "paragraph" ?
|
|
485
|
+
return n ? n.type === "paragraph" ? z(c, n, s, !1) : n.type === "table" ? Be(c, n, s) : 0 : 0;
|
|
485
486
|
};
|
|
486
487
|
for (let n = 0; n < e.length; n++) {
|
|
487
488
|
let r = e[n];
|
|
@@ -492,28 +493,28 @@ function ke(e, t, n, r = {}, i = it, a = []) {
|
|
|
492
493
|
if (r.type === "paragraph") {
|
|
493
494
|
let e = r;
|
|
494
495
|
e.pageBreakBefore && y();
|
|
495
|
-
let i =
|
|
496
|
-
p -= o, c.y -= o,
|
|
497
|
-
let v =
|
|
496
|
+
let i = H(m, e), a = i ? 0 : e.spaceBefore, o = Math.min(h, a);
|
|
497
|
+
p -= o, c.y -= o, Dt(e, c, c.y + a);
|
|
498
|
+
let v = z(c, e, s, i, t.marginLeft), S = [], C = 0, w = (e) => {
|
|
498
499
|
let t = 0;
|
|
499
500
|
for (let n = 0; n < e.length; n++) {
|
|
500
501
|
let r = l.get(e[n]);
|
|
501
502
|
if (!r) continue;
|
|
502
503
|
let i = (d[f.length - 1] ?? 0) === 0 && n === 0;
|
|
503
|
-
t +=
|
|
504
|
+
t += Ae(r, c, s, i);
|
|
504
505
|
}
|
|
505
506
|
return t;
|
|
506
507
|
};
|
|
507
508
|
if (u) {
|
|
508
509
|
let t = /* @__PURE__ */ new Set();
|
|
509
|
-
for (let n of
|
|
510
|
+
for (let n of Oe(e.runs)) g.has(n) || t.has(n) || l.has(n) && (t.add(n), S.push(n));
|
|
510
511
|
C = w(S);
|
|
511
512
|
}
|
|
512
|
-
let T = e.keepNext ? x(n + 1) : 0, E = v - e.spaceAfter + T + C,
|
|
513
|
-
(
|
|
514
|
-
let
|
|
515
|
-
if (
|
|
516
|
-
let n =
|
|
513
|
+
let T = e.keepNext ? x(n + 1) : 0, E = v - e.spaceAfter, D = E + T + C, O = b(e, a), k = O > 0 && p + O > _(), A = O > 0 && O <= _(), j = p > 0 && k && A, ee = p > 0 && p + D > _(), M = e.keepLines || T > 0 || C > 0;
|
|
514
|
+
(j || ee && M && D <= _()) && (y(), Dt(e, c, c.y + a), u && S.length > 0 && (C = w(S)));
|
|
515
|
+
let N = _(), P = N - p, F = !e.keepLines || v > N;
|
|
516
|
+
if (E > P && F) {
|
|
517
|
+
let n = Re(c, e, s, i, t.marginLeft, p, N, f, () => {
|
|
517
518
|
y();
|
|
518
519
|
});
|
|
519
520
|
p = n.endY, c.y = t.marginTop + n.endY, u && S.length > 0 && (S = S.filter((e) => !g.has(e)), C = w(S));
|
|
@@ -525,9 +526,9 @@ function ke(e, t, n, r = {}, i = it, a = []) {
|
|
|
525
526
|
}
|
|
526
527
|
m = e, h = e.spaceAfter;
|
|
527
528
|
} else if (r.type === "table") {
|
|
528
|
-
let e = r, n =
|
|
529
|
+
let e = r, n = ze(c, e, s), i = n.reduce((e, t) => e + t, 0), a = _();
|
|
529
530
|
if (i > a) {
|
|
530
|
-
let r =
|
|
531
|
+
let r = We(e, n, p, a, f, () => y());
|
|
531
532
|
p = r, c.y = t.marginTop + r;
|
|
532
533
|
} else p + i > a && y(), f[f.length - 1].push(r), p += i, c.y += i;
|
|
533
534
|
m = null;
|
|
@@ -535,11 +536,11 @@ function ke(e, t, n, r = {}, i = it, a = []) {
|
|
|
535
536
|
}
|
|
536
537
|
return f;
|
|
537
538
|
}
|
|
538
|
-
function
|
|
539
|
+
function Me(e) {
|
|
539
540
|
let t = new OffscreenCanvas(1, 1).getContext("2d");
|
|
540
|
-
return t ?
|
|
541
|
+
return t ? je(e.body, e.section, t, e.fontFamilyClasses ?? {}, st(e.settings), e.footnotes ?? []) : [e.body];
|
|
541
542
|
}
|
|
542
|
-
function
|
|
543
|
+
function Ne(e, t, n = {}, r = ct, i = !1) {
|
|
543
544
|
return {
|
|
544
545
|
ctx: e,
|
|
545
546
|
scale: 1,
|
|
@@ -563,79 +564,112 @@ function je(e, t, n = {}, r = it) {
|
|
|
563
564
|
type: t.docGridType ?? null,
|
|
564
565
|
linePitchPt: t.docGridLinePitch ?? null
|
|
565
566
|
},
|
|
567
|
+
docEastAsian: i,
|
|
566
568
|
fontFamilyClasses: n,
|
|
567
569
|
kinsoku: r,
|
|
568
570
|
showTrackChanges: !1
|
|
569
571
|
};
|
|
570
572
|
}
|
|
571
|
-
function
|
|
572
|
-
let a = t.indentLeft, o = t.indentRight, s = Math.max(1, n - a - o), c =
|
|
573
|
-
|
|
573
|
+
function z(e, t, n, r = !1, i = 0) {
|
|
574
|
+
let a = t.indentLeft, o = t.indentRight, s = Math.max(1, n - a - o), c = i + (t.bidi === !0 ? o : a), l = U(t.runs, e), u = B(t), d = Le(t, e), f = e.floats.length > 0, p = e.y, m = p + (r ? 0 : t.spaceBefore);
|
|
575
|
+
f && (m = ue(m, e.floats));
|
|
576
|
+
let h = () => {
|
|
577
|
+
if (f) {
|
|
578
|
+
let n = ce(m, Z(t, 1), 10, c, s, e.floats);
|
|
579
|
+
n.topY > m && (m = n.topY);
|
|
580
|
+
}
|
|
581
|
+
m += Xt(t, 1, d, u, e.docEastAsian, e.ctx, e.fontFamilyClasses);
|
|
582
|
+
};
|
|
583
|
+
if (l.length === 0) h();
|
|
574
584
|
else {
|
|
575
|
-
let n =
|
|
576
|
-
startPageY:
|
|
577
|
-
paraX:
|
|
585
|
+
let n = f ? {
|
|
586
|
+
startPageY: m,
|
|
587
|
+
paraX: c,
|
|
578
588
|
floats: e.floats,
|
|
579
|
-
lineBoxH: (e, n, r, i) => Q(t.lineSpacing, e, n, 1,
|
|
589
|
+
lineBoxH: (e, n, r, i) => Q(t.lineSpacing, e, n, 1, d, u, i ?? 0, V(t)),
|
|
580
590
|
pageH: e.pageH,
|
|
581
|
-
markEmPx:
|
|
582
|
-
} : void 0, r =
|
|
583
|
-
|
|
591
|
+
markEmPx: Z(t, 1)
|
|
592
|
+
} : void 0, r = W(e.ctx, l, s, t.indentFirst, 1, t.tabStops, n, e.fontFamilyClasses, a, e.kinsoku);
|
|
593
|
+
if (r.length === 0) h();
|
|
594
|
+
else if (u) {
|
|
595
|
+
let e = Pe(Math.max(0, ...r.map((e) => Q(t.lineSpacing, e.ascent, e.descent, 1, d, !0, e.intendedSingle, V(t)))), d, 1);
|
|
596
|
+
for (let t of r) t.topY !== void 0 && t.topY > m && (m = t.topY), m += e;
|
|
597
|
+
} else for (let e of r) e.topY !== void 0 && e.topY > m && (m = e.topY), m += Q(t.lineSpacing, e.ascent, e.descent, 1, d, !1, e.intendedSingle, V(t));
|
|
584
598
|
}
|
|
585
|
-
return
|
|
599
|
+
return m += t.spaceAfter, m - p;
|
|
586
600
|
}
|
|
587
|
-
function
|
|
601
|
+
function Pe(e, t, n) {
|
|
588
602
|
if (!t || !t.linePitchPt || t.linePitchPt <= 0 || t.type !== "lines" && t.type !== "linesAndChars") return e;
|
|
589
603
|
let r = t.linePitchPt * n;
|
|
590
604
|
return r <= 0 ? e : e <= r ? r : Math.ceil(e / r) * r;
|
|
591
605
|
}
|
|
592
|
-
function
|
|
606
|
+
function B(e) {
|
|
593
607
|
for (let t of e.runs) if (t.type === "text" && t.ruby) return !0;
|
|
594
608
|
return !1;
|
|
595
609
|
}
|
|
596
|
-
|
|
610
|
+
var Fe = /[ᄀ-ᇿ⺀- -〿-ヿ-㐀-䶿一-鿿ꥠ-가-豈--]/u;
|
|
611
|
+
function V(e) {
|
|
612
|
+
for (let t of e.runs) if (t.type === "text" && Fe.test(t.text)) return !0;
|
|
613
|
+
return !1;
|
|
614
|
+
}
|
|
615
|
+
function Ie(e) {
|
|
616
|
+
for (let t of e) if (t.type === "paragraph") {
|
|
617
|
+
if (V(t)) return !0;
|
|
618
|
+
} else if (t.type === "table") {
|
|
619
|
+
for (let e of t.rows) for (let t of e.cells) if (Ie(t.content)) return !0;
|
|
620
|
+
}
|
|
621
|
+
return !1;
|
|
622
|
+
}
|
|
623
|
+
function Le(e, t) {
|
|
597
624
|
return e.snapToGrid === !1 ? {
|
|
598
625
|
type: null,
|
|
599
626
|
linePitchPt: null
|
|
600
627
|
} : t.docGrid;
|
|
601
628
|
}
|
|
602
|
-
function
|
|
603
|
-
let l = t.indentLeft, u = t.indentRight, d = Math.max(1, n - l - u), f =
|
|
604
|
-
|
|
605
|
-
|
|
629
|
+
function Re(e, t, n, r, i, a, o, s, c) {
|
|
630
|
+
let l = t.indentLeft, u = t.indentRight, d = Math.max(1, n - l - u), f = i + (t.bidi === !0 ? u : l), p = () => {
|
|
631
|
+
let l = z(e, t, n, r, i), u = a;
|
|
632
|
+
return a > 0 && a + l - t.spaceAfter > o && (c(), u = 0, l = z(e, t, n, r, i)), s[s.length - 1].push(t), { endY: u + l };
|
|
633
|
+
}, m = U(t.runs, e);
|
|
634
|
+
if (m.length === 0) return p();
|
|
635
|
+
let h = e.floats.length > 0 ? {
|
|
606
636
|
startPageY: e.y,
|
|
607
|
-
paraX:
|
|
637
|
+
paraX: f,
|
|
608
638
|
floats: e.floats,
|
|
609
|
-
lineBoxH: (n, r, i, a) => Q(t.lineSpacing, n, r, 1, e.docGrid,
|
|
639
|
+
lineBoxH: (n, r, i, a) => Q(t.lineSpacing, n, r, 1, e.docGrid, B(t), a ?? 0, V(t)),
|
|
610
640
|
pageH: e.pageH,
|
|
611
|
-
markEmPx:
|
|
612
|
-
} : void 0,
|
|
613
|
-
if (
|
|
614
|
-
let
|
|
615
|
-
for (;
|
|
616
|
-
let e = o -
|
|
617
|
-
for (; i <
|
|
641
|
+
markEmPx: Z(t, 1)
|
|
642
|
+
} : void 0, g = W(e.ctx, m, d, t.indentFirst, 1, t.tabStops, h, e.fontFamilyClasses, l, e.kinsoku);
|
|
643
|
+
if (g.length === 0) return p();
|
|
644
|
+
let _ = B(t), v = (n) => Q(t.lineSpacing, n.ascent, n.descent, 1, e.docGrid, _, n.intendedSingle, V(t)), y = _ ? Pe(Math.max(0, ...g.map(v)), e.docGrid, 1) : 0, b = g.map((e) => _ ? y : v(e)), x = r ? 0 : t.spaceBefore, S = t.spaceAfter, C = 0, w = a, T = !0;
|
|
645
|
+
for (; C < g.length;) {
|
|
646
|
+
let e = o - w, n = T ? x : 0, r = C, i = C;
|
|
647
|
+
for (; i < g.length && n + b[i] <= e;) n += b[i], i++;
|
|
618
648
|
if (i === r) {
|
|
619
|
-
if (
|
|
620
|
-
c(),
|
|
649
|
+
if (w > 0) {
|
|
650
|
+
c(), w = 0, T = !0;
|
|
621
651
|
continue;
|
|
622
652
|
}
|
|
623
|
-
i = r + 1, n +=
|
|
653
|
+
i = r + 1, n += b[r];
|
|
654
|
+
}
|
|
655
|
+
if (t.widowControl !== !1 && i < g.length && (g.length - i === 1 && i - r >= 2 && (i--, n -= b[i]), r === 0 && i - r === 1 && w > 0)) {
|
|
656
|
+
c(), w = 0, T = !0;
|
|
657
|
+
continue;
|
|
624
658
|
}
|
|
625
|
-
let a = i ===
|
|
626
|
-
a && (n +=
|
|
659
|
+
let a = i === g.length;
|
|
660
|
+
a && (n += S), s[s.length - 1].push({
|
|
627
661
|
...t,
|
|
628
662
|
type: "paragraph",
|
|
629
663
|
lineSlice: {
|
|
630
664
|
start: r,
|
|
631
665
|
end: i
|
|
632
666
|
}
|
|
633
|
-
}),
|
|
667
|
+
}), C = i, w += n, a || (c(), w = 0, T = !0);
|
|
634
668
|
}
|
|
635
|
-
return { endY:
|
|
669
|
+
return { endY: w };
|
|
636
670
|
}
|
|
637
|
-
function
|
|
638
|
-
let r =
|
|
671
|
+
function ze(e, t, n) {
|
|
672
|
+
let r = He(t, n, e), i = [], a = [];
|
|
639
673
|
for (let n = 0; n < t.rows.length; n++) {
|
|
640
674
|
let o = t.rows[n];
|
|
641
675
|
if (o.rowHeight != null && o.rowHeightRule === "exact") {
|
|
@@ -644,8 +678,8 @@ function Fe(e, t, n) {
|
|
|
644
678
|
}
|
|
645
679
|
let s = o.rowHeight == null ? 10 : o.rowHeight, c = 0;
|
|
646
680
|
for (let i of o.cells) {
|
|
647
|
-
let o = Math.min(i.colSpan, r.length - c), l = r.slice(c, c + o).reduce((e, t) => e + t, 0), u =
|
|
648
|
-
for (let t of i.content) t.type === "paragraph" ? f +=
|
|
681
|
+
let o = Math.min(i.colSpan, r.length - c), l = r.slice(c, c + o).reduce((e, t) => e + t, 0), u = G(i, t), d = Math.max(1, l - u.left - u.right), f = u.top + u.bottom;
|
|
682
|
+
for (let t of i.content) t.type === "paragraph" ? f += z(e, t, d) : t.type === "table" && (f += Be(e, t, d));
|
|
649
683
|
i.vMerge === !0 ? a.push({
|
|
650
684
|
ri: n,
|
|
651
685
|
ci: c,
|
|
@@ -655,44 +689,44 @@ function Fe(e, t, n) {
|
|
|
655
689
|
i.push(s);
|
|
656
690
|
}
|
|
657
691
|
for (let e of a) {
|
|
658
|
-
let n =
|
|
692
|
+
let n = Ge(t, e.ri, e.ci), r = 0;
|
|
659
693
|
for (let t = e.ri; t <= n; t++) r += i[t];
|
|
660
694
|
r < e.contentH && (i[n] += e.contentH - r);
|
|
661
695
|
}
|
|
662
696
|
return i;
|
|
663
697
|
}
|
|
664
|
-
function
|
|
665
|
-
return
|
|
698
|
+
function Be(e, t, n) {
|
|
699
|
+
return ze(e, t, n).reduce((e, t) => e + t, 0);
|
|
666
700
|
}
|
|
667
|
-
function
|
|
701
|
+
function Ve(e, t, n) {
|
|
668
702
|
let { ctx: r, fontFamilyClasses: i } = n, a = 0, o = (e) => {
|
|
669
703
|
for (let t of e.runs) {
|
|
670
704
|
if (t.type !== "text") continue;
|
|
671
705
|
let e = t;
|
|
672
706
|
if (!e.text) continue;
|
|
673
707
|
let n = e.rtl === !0 || e.cs === !0;
|
|
674
|
-
r.font =
|
|
675
|
-
for (let t of e.text.split(" ")) for (let e of
|
|
708
|
+
r.font = J(n ? e.boldCs ?? e.bold : e.bold, n ? e.italicCs ?? e.italic : e.italic, n ? e.fontSizeCs ?? e.fontSize : e.fontSize, n ? e.fontFamilyCs ?? e.fontFamily : e.fontFamily, i);
|
|
709
|
+
for (let t of e.text.split(" ")) for (let e of ht(t)) {
|
|
676
710
|
let t = e.replace(/\s+$/u, "");
|
|
677
711
|
if (!t) continue;
|
|
678
|
-
let n =
|
|
712
|
+
let n = nt(t) ? Math.max(...[...t].map((e) => r.measureText(e).width)) : r.measureText(t).width;
|
|
679
713
|
n > a && (a = n);
|
|
680
714
|
}
|
|
681
715
|
}
|
|
682
716
|
};
|
|
683
717
|
for (let t of e.content) t.type === "paragraph" && o(t);
|
|
684
718
|
if (a === 0) return 0;
|
|
685
|
-
let s =
|
|
719
|
+
let s = G(e, t);
|
|
686
720
|
return a + s.left + s.right;
|
|
687
721
|
}
|
|
688
|
-
function
|
|
722
|
+
function He(e, t, n) {
|
|
689
723
|
let r = e.colWidths.length;
|
|
690
724
|
if (r === 0) return [];
|
|
691
725
|
let i = e.colWidths, a = Array(r).fill(0);
|
|
692
726
|
for (let t of e.rows) {
|
|
693
727
|
let o = 0;
|
|
694
728
|
for (let s of t.cells) {
|
|
695
|
-
let t = Math.min(Math.max(s.colSpan, 1), r - o), c =
|
|
729
|
+
let t = Math.min(Math.max(s.colSpan, 1), r - o), c = Ve(s, e, n);
|
|
696
730
|
if (c > 0) if (t === 1) c > a[o] && (a[o] = c);
|
|
697
731
|
else {
|
|
698
732
|
let e = i.slice(o, o + t), n = e.reduce((e, t) => e + t, 0);
|
|
@@ -769,10 +803,10 @@ function Re(e, t, n) {
|
|
|
769
803
|
}
|
|
770
804
|
return o(s.map((e, t) => Math.max(c[t] ? e : i[t], a[t])));
|
|
771
805
|
}
|
|
772
|
-
function
|
|
806
|
+
function Ue(e, t) {
|
|
773
807
|
return t <= 0 ? !0 : !e.rows[t].cells.some((e) => e.vMerge === !1);
|
|
774
808
|
}
|
|
775
|
-
function
|
|
809
|
+
function We(e, t, n, r, i, a) {
|
|
776
810
|
let o = e.rows.length, s = 0;
|
|
777
811
|
for (; s < o && e.rows[s].isHeader;) s++;
|
|
778
812
|
let c = e.rows.slice(0, s), l = t.slice(0, s).reduce((e, t) => e + t, 0), u = n, d = 0, f = !0;
|
|
@@ -780,7 +814,7 @@ function Be(e, t, n, r, i, a) {
|
|
|
780
814
|
let n = !f && s > 0 && d >= s, p = r - u, m = n ? l : 0, h = d;
|
|
781
815
|
for (; h < o;) {
|
|
782
816
|
let n = t[h];
|
|
783
|
-
if (h > d && m + n > p &&
|
|
817
|
+
if (h > d && m + n > p && Ue(e, h)) break;
|
|
784
818
|
m += n, h++;
|
|
785
819
|
}
|
|
786
820
|
let g = e.rows.slice(d, h), _ = n ? [...c, ...g] : g;
|
|
@@ -792,7 +826,7 @@ function Be(e, t, n, r, i, a) {
|
|
|
792
826
|
}
|
|
793
827
|
return u;
|
|
794
828
|
}
|
|
795
|
-
function
|
|
829
|
+
function Ge(e, t, n) {
|
|
796
830
|
let r = t;
|
|
797
831
|
for (let i = t + 1; i < e.rows.length; i++) {
|
|
798
832
|
let t = e.rows[i], a = 0, o = !1;
|
|
@@ -809,65 +843,65 @@ function Ve(e, t, n) {
|
|
|
809
843
|
}
|
|
810
844
|
return r;
|
|
811
845
|
}
|
|
812
|
-
function
|
|
846
|
+
function Ke(e, t, n, r, i) {
|
|
813
847
|
return r && t === 0 && e.first ? e.first : i && t % 2 == 1 && e.even ? e.even : e.default ?? null;
|
|
814
848
|
}
|
|
815
|
-
function
|
|
849
|
+
function qe(e, t, n) {
|
|
816
850
|
let r = {
|
|
817
851
|
...n,
|
|
818
852
|
y: t
|
|
819
853
|
};
|
|
820
|
-
|
|
854
|
+
Ye(e.body, r);
|
|
821
855
|
}
|
|
822
|
-
function
|
|
856
|
+
function Je(e, t) {
|
|
823
857
|
let n = {
|
|
824
858
|
...t,
|
|
825
859
|
y: 0,
|
|
826
860
|
dryRun: !0,
|
|
827
861
|
floats: []
|
|
828
862
|
};
|
|
829
|
-
return
|
|
863
|
+
return Ye(e.body, n), n.y;
|
|
830
864
|
}
|
|
831
|
-
function
|
|
865
|
+
function H(e, t) {
|
|
832
866
|
return !!(e?.contextualSpacing && t.contextualSpacing && e.styleId && e.styleId === t.styleId);
|
|
833
867
|
}
|
|
834
|
-
function
|
|
868
|
+
function Ye(e, t) {
|
|
835
869
|
let n = null, r = 0;
|
|
836
870
|
for (let i of e) if (i.type === "paragraph") {
|
|
837
|
-
let e = i, a = i.lineSlice, o =
|
|
871
|
+
let e = i, a = i.lineSlice, o = H(n, e), s = o ? 0 : e.spaceBefore;
|
|
838
872
|
t.y -= Math.min(r, s) * t.scale;
|
|
839
873
|
let c = !!a && a.start > 0;
|
|
840
|
-
|
|
841
|
-
} else i.type === "table" && (
|
|
874
|
+
$e(e, t, o || c, a), n = e, r = e.spaceAfter;
|
|
875
|
+
} else i.type === "table" && (Ot(i, t), n = null, r = 0);
|
|
842
876
|
}
|
|
843
|
-
function
|
|
877
|
+
function Xe(e, t) {
|
|
844
878
|
let n = null, r = 0;
|
|
845
879
|
for (let i of e) {
|
|
846
|
-
let e =
|
|
847
|
-
t.y -= Math.min(r, a) * t.scale,
|
|
880
|
+
let e = H(n, i), a = e ? 0 : i.spaceBefore;
|
|
881
|
+
t.y -= Math.min(r, a) * t.scale, $e(i, t, e), n = i, r = i.spaceAfter;
|
|
848
882
|
}
|
|
849
883
|
}
|
|
850
|
-
function
|
|
884
|
+
function Ze(e) {
|
|
851
885
|
switch (e) {
|
|
852
886
|
case "left": return "left";
|
|
853
887
|
case "right": return "right";
|
|
854
888
|
default: return "center";
|
|
855
889
|
}
|
|
856
890
|
}
|
|
857
|
-
function
|
|
891
|
+
function Qe(e, t, n) {
|
|
858
892
|
let { ctx: r, scale: i, dryRun: a } = t, { grid: o, paraHasRuby: s, contentX: c, indLeft: l, paraW: u, textAreaTopY: d, paragraphStartY: f, markTop: p, totalLines: m, lineSlice: h } = n, g = Math.max(0, p - d);
|
|
859
893
|
p > t.y && (t.y = p);
|
|
860
|
-
let _ = t.y, v =
|
|
861
|
-
e.shading && !a && (r.fillStyle = `#${e.shading}`, r.fillRect(c + l, _, u, v)), t.y += v, e.borders && !a &&
|
|
894
|
+
let _ = t.y, v = Xt(e, i, o, s, t.docEastAsian, r, t.fontFamilyClasses);
|
|
895
|
+
e.shading && !a && (r.fillStyle = `#${e.shading}`, r.fillRect(c + l, _, u, v)), t.y += v, e.borders && !a && Lt(r, c + l, _, u, v, e.borders, i), (!h || h.end >= m) && (t.y += e.spaceAfter * i), (!h || h.start === 0) && vt(e, t, f + g);
|
|
862
896
|
}
|
|
863
|
-
function
|
|
897
|
+
function $e(e, t, n = !1, r) {
|
|
864
898
|
let { ctx: i, scale: a, contentX: o, contentW: s, defaultColor: c, dryRun: l, fontFamilyClasses: u } = t, d = t.y;
|
|
865
|
-
n || (t.y += e.spaceBefore * a),
|
|
899
|
+
n || (t.y += e.spaceBefore * a), Dt(e, t, t.y), vt(e, t, d, "behind"), t.y = ue(t.y, t.floats);
|
|
866
900
|
let f = t.y, p = e.bidi === !0, m = (p ? e.indentRight : e.indentLeft) * a, h = (p ? e.indentLeft : e.indentRight) * a, g = e.indentFirst * a, _ = "", v = 0;
|
|
867
901
|
e.numbering && (_ = e.numbering.text + " ", v = e.numbering.tab * a);
|
|
868
|
-
let y = o + m, b = y + g, x = s - m - h, S =
|
|
902
|
+
let y = o + m, b = y + g, x = s - m - h, S = U(e.runs, t), C = B(e), w = Le(e, t), T = () => t.floats.length === 0 ? f : ce(f, Z(e, a), 10 * a, y, x, t.floats).topY;
|
|
869
903
|
if (S.length === 0) {
|
|
870
|
-
|
|
904
|
+
Qe(e, t, {
|
|
871
905
|
grid: w,
|
|
872
906
|
paraHasRuby: C,
|
|
873
907
|
contentX: o,
|
|
@@ -885,12 +919,12 @@ function Ye(e, t, n = !1, r) {
|
|
|
885
919
|
startPageY: t.y,
|
|
886
920
|
paraX: y,
|
|
887
921
|
floats: t.floats,
|
|
888
|
-
lineBoxH: (t, n, r, i) => Q(e.lineSpacing, t, n, a, w, C, i ?? 0),
|
|
922
|
+
lineBoxH: (t, n, r, i) => Q(e.lineSpacing, t, n, a, w, C, i ?? 0, V(e)),
|
|
889
923
|
pageH: t.pageH,
|
|
890
|
-
markEmPx:
|
|
891
|
-
} : void 0, D =
|
|
924
|
+
markEmPx: Z(e, a)
|
|
925
|
+
} : void 0, D = W(i, S, x, b - y, a, e.tabStops, E, t.fontFamilyClasses, m, t.kinsoku);
|
|
892
926
|
if (D.length === 0) {
|
|
893
|
-
|
|
927
|
+
Qe(e, t, {
|
|
894
928
|
grid: w,
|
|
895
929
|
paraHasRuby: C,
|
|
896
930
|
contentX: o,
|
|
@@ -904,7 +938,7 @@ function Ye(e, t, n = !1, r) {
|
|
|
904
938
|
});
|
|
905
939
|
return;
|
|
906
940
|
}
|
|
907
|
-
let O = C ?
|
|
941
|
+
let O = C ? Pe(Math.max(0, ...D.map((t) => Q(e.lineSpacing, t.ascent, t.descent, a, w, !0, t.intendedSingle, V(e)))), w, a) : 0, k = (t) => C ? O : Q(e.lineSpacing, t.ascent, t.descent, a, w, !1, t.intendedSingle, V(e));
|
|
908
942
|
if (e.shading && !l) {
|
|
909
943
|
let t = D.reduce((e, t) => e + k(t), 0);
|
|
910
944
|
i.fillStyle = `#${e.shading}`, i.fillRect(o + m, f, x, t);
|
|
@@ -913,20 +947,20 @@ function Ye(e, t, n = !1, r) {
|
|
|
913
947
|
let t = 0;
|
|
914
948
|
for (let n = e.length - 1; n >= 0 && e[n] === " "; n--) t++;
|
|
915
949
|
return t;
|
|
916
|
-
}, M = p || te(S), N =
|
|
950
|
+
}, M = p || te(S), N = ie(e.alignment, p), P = r ? r.start : 0, F = r ? r.end : D.length;
|
|
917
951
|
for (let n = P; n < F; n++) {
|
|
918
952
|
let r = D[n], o = n === 0, s = n === D.length - 1;
|
|
919
953
|
r.topY !== void 0 && r.topY > t.y && (t.y = r.topY);
|
|
920
|
-
let d = k(r), f = r.ascent + r.descent, m = t.y + (d - f) / 2 + r.ascent, h = y + r.xOffset, b = r.availWidth, x = o && !p ? h + g : h, S = p && o ? b - g : b, C = M ?
|
|
954
|
+
let d = k(r), f = r.ascent + r.descent, m = t.y + (d - f) / 2 + r.ascent, h = y + r.xOffset, b = r.availWidth, x = o && !p ? h + g : h, S = p && o ? b - g : b, C = M ? re(r.segments, p) : null;
|
|
921
955
|
M && (i.textAlign = "left");
|
|
922
|
-
let w = r.segments.length, T = C ? C.order[w - 1] : w - 1, E = r.segments.reduce((e, t) => e + t.measuredWidth, 0), O = S - (x - h) - E, P = A && (!s || j), F = 0, te = r.segments.length === 1 && "mathNodes" in r.segments[0] && r.segments[0].display ? r.segments[0] : null,
|
|
923
|
-
if (
|
|
956
|
+
let w = r.segments.length, T = C ? C.order[w - 1] : w - 1, E = r.segments.reduce((e, t) => e + t.measuredWidth, 0), O = S - (x - h) - E, P = A && (!s || j), F = 0, te = r.segments.length === 1 && "mathNodes" in r.segments[0] && r.segments[0].display ? r.segments[0] : null, ne = (te ? Ze(te.jc ?? t.mathDefJc ?? "centerGroup") : null) ?? N;
|
|
957
|
+
if (ne === "right" ? F = O : ne === "center" ? F = O / 2 : ne === "justify" && p && !P && (F = O), x += F, o && _ && !l) if (i.font = `${X(e) * a}px sans-serif`, i.fillStyle = c, p) {
|
|
924
958
|
let t = i.textAlign, n = i.direction;
|
|
925
959
|
i.textAlign = "left", i.direction = "rtl";
|
|
926
960
|
let r = i.measureText(e.numbering.text).width;
|
|
927
961
|
i.fillText(e.numbering.text, x + E + v - r, m), i.textAlign = t, i.direction = n;
|
|
928
962
|
} else i.fillText(e.numbering.text, h + g - v, m);
|
|
929
|
-
let
|
|
963
|
+
let I = 0;
|
|
930
964
|
if (P) {
|
|
931
965
|
let e = 0;
|
|
932
966
|
for (let t = 0; t < w; t++) {
|
|
@@ -935,23 +969,23 @@ function Ye(e, t, n = !1, r) {
|
|
|
935
969
|
}
|
|
936
970
|
let t = S - (x - h) - E;
|
|
937
971
|
if (e > 0) {
|
|
938
|
-
|
|
972
|
+
I = t / e;
|
|
939
973
|
let n = -r.ascent * .25;
|
|
940
|
-
|
|
974
|
+
I < n && (I = n);
|
|
941
975
|
}
|
|
942
976
|
}
|
|
943
977
|
for (let e = 0; e < w; e++) {
|
|
944
978
|
let n = C ? C.order[e] : e, o = r.segments[n], s = e === w - 1;
|
|
945
979
|
if (C && (i.direction = C.rtl[n] ? "rtl" : "ltr"), "isTab" in o) {
|
|
946
|
-
!l && o.leader && o.leader !== "none" && o.measuredWidth > 1 &&
|
|
980
|
+
!l && o.leader && o.leader !== "none" && o.measuredWidth > 1 && gt(i, o.leader, x, m, o.measuredWidth, o.fontSize * a, c), x += o.measuredWidth;
|
|
947
981
|
continue;
|
|
948
982
|
}
|
|
949
983
|
if ("dataUrl" in o) {
|
|
950
|
-
l ||
|
|
984
|
+
l || _t(i, o, x, m, a, t.images), x += o.measuredWidth;
|
|
951
985
|
continue;
|
|
952
986
|
}
|
|
953
987
|
if ("mathNodes" in o) {
|
|
954
|
-
let e =
|
|
988
|
+
let e = L.get(o.mathNodes);
|
|
955
989
|
if (!l && e) {
|
|
956
990
|
let t = o.fontSize * a, n = e.widthEm * t, r = (e.ascentEm + e.descentEm) * t, s = m - e.ascentEm * t;
|
|
957
991
|
i.drawImage(e.img, x, s, n, r);
|
|
@@ -961,11 +995,11 @@ function Ye(e, t, n = !1, r) {
|
|
|
961
995
|
}
|
|
962
996
|
let f = o;
|
|
963
997
|
if (!l) {
|
|
964
|
-
let e =
|
|
965
|
-
i.font =
|
|
966
|
-
let r = t.showTrackChanges && !!f.revision, o = r ?
|
|
998
|
+
let e = Rt(f, a), n = f.vertAlign === "super" ? -f.fontSize * a * .35 : f.vertAlign === "sub" ? f.fontSize * a * .15 : 0;
|
|
999
|
+
i.font = J(f.bold, f.italic, e, f.fontFamily, u), f.highlight && (i.fillStyle = de[f.highlight] ?? "#FFFF00", i.fillRect(x, m + n - e * .85, f.measuredWidth, e * 1.1));
|
|
1000
|
+
let r = t.showTrackChanges && !!f.revision, o = r ? _e(f.revision.author) : null;
|
|
967
1001
|
if (i.fillStyle = o ?? (f.color ? `#${f.color}` : c), i.fillText(f.text, x, m + n), f.ruby) {
|
|
968
|
-
let t = f.ruby.fontSizePt * a, r =
|
|
1002
|
+
let t = f.ruby.fontSizePt * a, r = J(f.bold, f.italic, t, f.fontFamily, u);
|
|
969
1003
|
i.save(), i.font = r;
|
|
970
1004
|
let o = i.measureText(f.ruby.text).width, s = x + (f.measuredWidth - o) / 2, l = m + n - e * .85 - t * .1;
|
|
971
1005
|
i.fillStyle = f.color ? `#${f.color}` : c, i.fillText(f.ruby.text, s, l), i.restore();
|
|
@@ -996,25 +1030,25 @@ function Ye(e, t, n = !1, r) {
|
|
|
996
1030
|
i.beginPath(), i.moveTo(x, t), i.lineTo(x + p, t), i.stroke(), i.beginPath(), i.moveTo(x, r), i.lineTo(x + p, r), i.stroke();
|
|
997
1031
|
}
|
|
998
1032
|
}
|
|
999
|
-
if (x += f.measuredWidth,
|
|
1033
|
+
if (x += f.measuredWidth, I > 0 && !s) {
|
|
1000
1034
|
let e = ee(f.text);
|
|
1001
|
-
e > 0 && (x += e *
|
|
1035
|
+
e > 0 && (x += e * I);
|
|
1002
1036
|
}
|
|
1003
1037
|
}
|
|
1004
1038
|
M && (i.direction = "ltr"), t.y += d;
|
|
1005
1039
|
}
|
|
1006
1040
|
if (e.borders && !l) {
|
|
1007
1041
|
let n = t.y - f;
|
|
1008
|
-
|
|
1042
|
+
Lt(i, o + m, f, x, n, e.borders, a);
|
|
1009
1043
|
}
|
|
1010
|
-
(!r || r.end >= D.length) && (t.y += e.spaceAfter * a), (!r || r.start === 0) &&
|
|
1044
|
+
(!r || r.end >= D.length) && (t.y += e.spaceAfter * a), (!r || r.start === 0) && vt(e, t, d);
|
|
1011
1045
|
}
|
|
1012
|
-
function
|
|
1046
|
+
function U(e, t) {
|
|
1013
1047
|
let n = [], r = (e, t, r) => {
|
|
1014
1048
|
let i = t.allCaps || t.smallCaps ? e.toUpperCase() : e, a = t.ruby, o = a ? {
|
|
1015
1049
|
text: a.text,
|
|
1016
1050
|
fontSizePt: a.fontSizePt
|
|
1017
|
-
} : void 0, s = t.revision, c = t, l = c.rtl === !0 ? !0 : void 0, u = c.rtl === !0 || c.cs === !0, d = c.fontSizeCs ?? t.fontSize, f = c.fontFamilyCs ?? t.fontFamily, p = c.boldCs ?? t.bold, m = c.italicCs ?? t.italic, h = (u || c.rtl === !0) &&
|
|
1051
|
+
} : void 0, s = t.revision, c = t, l = c.rtl === !0 ? !0 : void 0, u = c.rtl === !0 || c.cs === !0, d = c.fontSizeCs ?? t.fontSize, f = c.fontFamilyCs ?? t.fontFamily, p = c.boldCs ?? t.bold, m = c.italicCs ?? t.italic, h = (u || c.rtl === !0) && dt(c.langBidi, c.rtl === !0), g = !0, _ = (e, i) => {
|
|
1018
1052
|
n.push({
|
|
1019
1053
|
text: e,
|
|
1020
1054
|
bold: i ? p : t.bold,
|
|
@@ -1035,9 +1069,9 @@ function W(e, t) {
|
|
|
1035
1069
|
digitsAsAN: h ? !0 : void 0
|
|
1036
1070
|
}), g = !1;
|
|
1037
1071
|
};
|
|
1038
|
-
for (let e of
|
|
1072
|
+
for (let e of ht(i)) if (u) if (h) for (let t of mt(e)) _(t, !0);
|
|
1039
1073
|
else _(e, !0);
|
|
1040
|
-
else for (let t of
|
|
1074
|
+
else for (let t of pt(e)) _(t.text, t.cs);
|
|
1041
1075
|
};
|
|
1042
1076
|
for (let i of e) if (i.type === "text") {
|
|
1043
1077
|
let e = i, a = e.noteRef ? e.noteRef.id ? t.noteNumbers?.get(`${e.noteRef.kind}:${e.noteRef.id}`) : t.currentNoteNumber : void 0;
|
|
@@ -1068,7 +1102,7 @@ function W(e, t) {
|
|
|
1068
1102
|
});
|
|
1069
1103
|
} else if (i.type === "break") {
|
|
1070
1104
|
if (i.breakType === "line") {
|
|
1071
|
-
let t =
|
|
1105
|
+
let t = et(e, e.indexOf(i));
|
|
1072
1106
|
n.push({
|
|
1073
1107
|
lineBreak: !0,
|
|
1074
1108
|
fontSize: t,
|
|
@@ -1076,10 +1110,10 @@ function W(e, t) {
|
|
|
1076
1110
|
});
|
|
1077
1111
|
}
|
|
1078
1112
|
} else if (i.type === "field") {
|
|
1079
|
-
let e = i, n =
|
|
1113
|
+
let e = i, n = tt(e, t);
|
|
1080
1114
|
n && r(n, e, e.vertAlign);
|
|
1081
1115
|
} else if (i.type === "math") {
|
|
1082
|
-
let t = i.fontSize ||
|
|
1116
|
+
let t = i.fontSize || et(e, e.indexOf(i));
|
|
1083
1117
|
n.push({
|
|
1084
1118
|
mathNodes: i.nodes,
|
|
1085
1119
|
display: i.display,
|
|
@@ -1093,7 +1127,7 @@ function W(e, t) {
|
|
|
1093
1127
|
}
|
|
1094
1128
|
return n;
|
|
1095
1129
|
}
|
|
1096
|
-
function
|
|
1130
|
+
function et(e, t) {
|
|
1097
1131
|
for (let n = t - 1; n >= 0; n--) {
|
|
1098
1132
|
let t = e[n];
|
|
1099
1133
|
if (t.type === "text" || t.type === "field") return t.fontSize;
|
|
@@ -1104,10 +1138,10 @@ function Xe(e, t) {
|
|
|
1104
1138
|
}
|
|
1105
1139
|
return 10;
|
|
1106
1140
|
}
|
|
1107
|
-
function
|
|
1141
|
+
function tt(e, t) {
|
|
1108
1142
|
return e.fieldType === "page" ? String(t.pageIndex + 1) : e.fieldType === "numPages" ? String(t.totalPages) : e.fallbackText;
|
|
1109
1143
|
}
|
|
1110
|
-
function
|
|
1144
|
+
function nt(e) {
|
|
1111
1145
|
for (let t = 0; t < e.length;) {
|
|
1112
1146
|
let n = e.codePointAt(t);
|
|
1113
1147
|
if (n >= 12288 && n <= 40959 || n >= 63744 && n <= 64255 || n >= 44032 && n <= 55215 || n >= 65280 && n <= 65519) return !0;
|
|
@@ -1115,7 +1149,7 @@ function Qe(e) {
|
|
|
1115
1149
|
}
|
|
1116
1150
|
return !1;
|
|
1117
1151
|
}
|
|
1118
|
-
function
|
|
1152
|
+
function rt(e, t, n) {
|
|
1119
1153
|
let r = [...t], i = 0, a = r.length;
|
|
1120
1154
|
for (; i < a;) {
|
|
1121
1155
|
let t = i + a + 1 >> 1;
|
|
@@ -1123,27 +1157,27 @@ function $e(e, t, n) {
|
|
|
1123
1157
|
}
|
|
1124
1158
|
return r.slice(0, i).join("");
|
|
1125
1159
|
}
|
|
1126
|
-
var
|
|
1127
|
-
function
|
|
1160
|
+
var it = "”’)〕]}〉》」』】〙〗〟⦆»、。,.・:;/?!‐ー゠–〜~ぁぃぅぇぉっゃゅょゎゕゖァィゥェォッャュョヮヵヶㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ゝゞヽヾ゛゜%‰℃°′″。」、・ー゙゚!),.:;?]}⦆", at = "“‘(〔[{〈《「『【〘〖〝⦅«$¥#£¢([{⦅";
|
|
1161
|
+
function ot(e) {
|
|
1128
1162
|
let t = /* @__PURE__ */ new Set();
|
|
1129
1163
|
for (let n of e) t.add(n.codePointAt(0));
|
|
1130
1164
|
return t;
|
|
1131
1165
|
}
|
|
1132
|
-
function
|
|
1166
|
+
function st(e) {
|
|
1133
1167
|
return {
|
|
1134
1168
|
enabled: e?.kinsoku !== !1,
|
|
1135
|
-
lineStartForbidden:
|
|
1136
|
-
lineEndForbidden:
|
|
1169
|
+
lineStartForbidden: ot(e?.noLineBreaksBefore ?? it),
|
|
1170
|
+
lineEndForbidden: ot(e?.noLineBreaksAfter ?? at)
|
|
1137
1171
|
};
|
|
1138
1172
|
}
|
|
1139
|
-
var
|
|
1140
|
-
function
|
|
1173
|
+
var ct = st();
|
|
1174
|
+
function lt(e, t, n, r = 1) {
|
|
1141
1175
|
if (!n.enabled || t <= 0 || t >= e.length) return t;
|
|
1142
1176
|
let i = (t) => t < e.length && n.lineStartForbidden.has(e[t].codePointAt(0)), a = (t) => t >= 0 && n.lineEndForbidden.has(e[t].codePointAt(0)), o = t;
|
|
1143
1177
|
for (; o > r && (i(o) || a(o - 1));) o--;
|
|
1144
1178
|
return o <= r && (i(o) || a(o - 1)) ? t : o;
|
|
1145
1179
|
}
|
|
1146
|
-
var
|
|
1180
|
+
var ut = new Set([
|
|
1147
1181
|
"ar",
|
|
1148
1182
|
"fa",
|
|
1149
1183
|
"ur",
|
|
@@ -1158,17 +1192,17 @@ var ot = new Set([
|
|
|
1158
1192
|
"syr",
|
|
1159
1193
|
"ckb"
|
|
1160
1194
|
]);
|
|
1161
|
-
function
|
|
1195
|
+
function dt(e, t) {
|
|
1162
1196
|
if (e) {
|
|
1163
1197
|
let t = e.split("-")[0].toLowerCase();
|
|
1164
|
-
if (
|
|
1198
|
+
if (ut.has(t)) return !0;
|
|
1165
1199
|
}
|
|
1166
1200
|
return t;
|
|
1167
1201
|
}
|
|
1168
|
-
function
|
|
1202
|
+
function ft(e) {
|
|
1169
1203
|
return e >= 1424 && e <= 1535 || e >= 1536 && e <= 1791 || e >= 1792 && e <= 1871 || e >= 1872 && e <= 1919 || e >= 1920 && e <= 1983 || e >= 1984 && e <= 2047 || e >= 2048 && e <= 2111 || e >= 2112 && e <= 2143 || e >= 2144 && e <= 2303 || e >= 64285 && e <= 64335 || e >= 64336 && e <= 65023 || e >= 65136 && e <= 65279 || e >= 67584 && e <= 69631 || e >= 124928 && e <= 126975;
|
|
1170
1204
|
}
|
|
1171
|
-
function
|
|
1205
|
+
function pt(e) {
|
|
1172
1206
|
let t = [], n = null, r = "";
|
|
1173
1207
|
for (let i of e) {
|
|
1174
1208
|
let e = i.codePointAt(0);
|
|
@@ -1176,7 +1210,7 @@ function lt(e) {
|
|
|
1176
1210
|
r += i;
|
|
1177
1211
|
continue;
|
|
1178
1212
|
}
|
|
1179
|
-
let a =
|
|
1213
|
+
let a = ft(e);
|
|
1180
1214
|
n === null ? (n = a, r += i) : a === n ? r += i : (t.push({
|
|
1181
1215
|
text: r,
|
|
1182
1216
|
cs: n
|
|
@@ -1187,7 +1221,7 @@ function lt(e) {
|
|
|
1187
1221
|
cs: n ?? !1
|
|
1188
1222
|
}), t;
|
|
1189
1223
|
}
|
|
1190
|
-
function
|
|
1224
|
+
function mt(e) {
|
|
1191
1225
|
let t = [], n = "", r = null;
|
|
1192
1226
|
for (let i of e) {
|
|
1193
1227
|
let e = i.charCodeAt(0), a = e >= 48 && e <= 57;
|
|
@@ -1195,7 +1229,7 @@ function ut(e) {
|
|
|
1195
1229
|
}
|
|
1196
1230
|
return n.length > 0 && t.push(n), t.length ? t : [e];
|
|
1197
1231
|
}
|
|
1198
|
-
function
|
|
1232
|
+
function ht(e) {
|
|
1199
1233
|
let t = [], n = 0;
|
|
1200
1234
|
for (; n < e.length;) {
|
|
1201
1235
|
let r = n;
|
|
@@ -1205,10 +1239,10 @@ function dt(e) {
|
|
|
1205
1239
|
}
|
|
1206
1240
|
return t.length ? t : [e];
|
|
1207
1241
|
}
|
|
1208
|
-
function
|
|
1242
|
+
function W(e, t, n, r, i, a = [], o, s = {}, c = 0, l = ct) {
|
|
1209
1243
|
let u = [], d = [], f = 0, p = 0, m = 0, h = 0, g = 0, _ = 0, v = !0, y = n, b = 0, x = o?.startPageY ?? 0, S = (e = 0) => {
|
|
1210
1244
|
if (b = 0, y = n, !o) return;
|
|
1211
|
-
let t = 10 * i, r =
|
|
1245
|
+
let t = 10 * i, r = ce(x, e, t, o.paraX, n, o.floats);
|
|
1212
1246
|
x = r.topY, b = r.xOffset, y = r.maxWidth;
|
|
1213
1247
|
}, C = () => y - (v ? r : 0), w = !1, T = (e) => {
|
|
1214
1248
|
let t = e === void 0 ? m || 10 : e, n = h > 0 || g > 0, r = n ? h : t * i * .8, a = n ? g : t * i * .2;
|
|
@@ -1230,7 +1264,7 @@ function G(e, t, n, r, i, a = [], o, s = {}, c = 0, l = it) {
|
|
|
1230
1264
|
let n = j(t.fontFamily, D(t));
|
|
1231
1265
|
n > _ && (_ = n);
|
|
1232
1266
|
}
|
|
1233
|
-
}, D = (e) =>
|
|
1267
|
+
}, D = (e) => Rt(e, i), O = (t) => (e.font = J(t.bold, t.italic, D(t), t.fontFamily, s), e.measureText(t.text)), k = (e) => "isTab" in e ? e.measuredWidth || 0 : "dataUrl" in e ? e.widthPt * i : "mathNodes" in e ? e.measuredWidth || 0 : "lineBreak" in e ? 0 : O(e).width, A = [...t], M = () => {
|
|
1234
1268
|
let e = A.find((e) => !("lineBreak" in e) && !("dataUrl" in e && e.anchor));
|
|
1235
1269
|
if (!e) return N === null ? o ? o.markEmPx : (t[0] && "fontSize" in t[0] ? t[0].fontSize : 10) * i : N * i;
|
|
1236
1270
|
if ("isTab" in e) return e.measuredWidth || 0;
|
|
@@ -1297,7 +1331,7 @@ function G(e, t, n, r, i, a = [], o, s = {}, c = 0, l = it) {
|
|
|
1297
1331
|
continue;
|
|
1298
1332
|
}
|
|
1299
1333
|
if ("mathNodes" in t) {
|
|
1300
|
-
let e =
|
|
1334
|
+
let e = L.get(t.mathNodes);
|
|
1301
1335
|
if (!e) {
|
|
1302
1336
|
t.measuredWidth = 0;
|
|
1303
1337
|
continue;
|
|
@@ -1312,10 +1346,10 @@ function G(e, t, n, r, i, a = [], o, s = {}, c = 0, l = it) {
|
|
|
1312
1346
|
n.ruby && (y += n.ruby.fontSizePt * i * 1.5);
|
|
1313
1347
|
let x = n.text.replace(/ +$/, ""), S = n.text.endsWith(" ") ? u - e.measureText(x).width : 0, w = u - S, j = p * .25;
|
|
1314
1348
|
if (f + w <= C() + j) n.measuredWidth = u, E(n, u, m, y, b, S);
|
|
1315
|
-
else if (
|
|
1349
|
+
else if (nt(n.text)) {
|
|
1316
1350
|
let t = C() - f;
|
|
1317
|
-
e.font =
|
|
1318
|
-
let r = t > 0 ?
|
|
1351
|
+
e.font = J(n.bold, n.italic, D(n), n.fontFamily, s);
|
|
1352
|
+
let r = t > 0 ? rt(e, n.text, t) : "", i = [...n.text], a = [...r].length, o = lt(i, a, l, d.length > 0 ? 0 : 1), c = i.slice(0, o).join("");
|
|
1319
1353
|
if (c.length > 0) {
|
|
1320
1354
|
let t = e.measureText(c);
|
|
1321
1355
|
E({
|
|
@@ -1351,7 +1385,7 @@ function G(e, t, n, r, i, a = [], o, s = {}, c = 0, l = it) {
|
|
|
1351
1385
|
}
|
|
1352
1386
|
return d.length > 0 ? T() : N !== null && T(N), u;
|
|
1353
1387
|
}
|
|
1354
|
-
function
|
|
1388
|
+
function gt(e, t, n, r, i, a, o) {
|
|
1355
1389
|
let s = t === "hyphen" ? "-" : t === "underscore" || t === "heavy" ? "_" : t === "middleDot" ? "·" : ".";
|
|
1356
1390
|
e.save(), e.font = `${a}px serif`, e.fillStyle = o;
|
|
1357
1391
|
let c = e.measureText(s).width;
|
|
@@ -1361,38 +1395,38 @@ function ft(e, t, n, r, i, a, o) {
|
|
|
1361
1395
|
}
|
|
1362
1396
|
e.restore();
|
|
1363
1397
|
}
|
|
1364
|
-
function
|
|
1398
|
+
function _t(e, t, n, r, i, a) {
|
|
1365
1399
|
if (t.anchor) return;
|
|
1366
|
-
let o = a.get(
|
|
1400
|
+
let o = a.get(R(t.dataUrl, t.colorReplaceFrom));
|
|
1367
1401
|
if (!o) return;
|
|
1368
1402
|
let s = t.widthPt * i, c = t.heightPt * i;
|
|
1369
1403
|
e.drawImage(o, n, r - c, s, c);
|
|
1370
1404
|
}
|
|
1371
|
-
function
|
|
1405
|
+
function vt(e, t, n, r = "front") {
|
|
1372
1406
|
if (!t.dryRun) {
|
|
1373
1407
|
if (r === "behind") {
|
|
1374
1408
|
let r = e.runs.filter((e) => e.type === "shape" && !!e.behindDoc).slice().sort((e, t) => (e.zOrder ?? 0) - (t.zOrder ?? 0));
|
|
1375
|
-
for (let e of r)
|
|
1409
|
+
for (let e of r) wt(e, t, n);
|
|
1376
1410
|
return;
|
|
1377
1411
|
}
|
|
1378
1412
|
for (let r of e.runs) {
|
|
1379
1413
|
if (r.type === "shape") {
|
|
1380
1414
|
let e = r;
|
|
1381
1415
|
if (e.behindDoc) continue;
|
|
1382
|
-
|
|
1416
|
+
wt(e, t, n);
|
|
1383
1417
|
continue;
|
|
1384
1418
|
}
|
|
1385
1419
|
if (r.type !== "image") continue;
|
|
1386
1420
|
let e = r;
|
|
1387
|
-
if (!e.anchor ||
|
|
1388
|
-
let i = t.images.get(
|
|
1421
|
+
if (!e.anchor || ae(e.wrapMode)) continue;
|
|
1422
|
+
let i = t.images.get(R(e.dataUrl, e.colorReplaceFrom));
|
|
1389
1423
|
if (!i) continue;
|
|
1390
|
-
let { x: a, y: o, w: s, h: c } =
|
|
1424
|
+
let { x: a, y: o, w: s, h: c } = Et(e, t, n);
|
|
1391
1425
|
t.ctx.drawImage(i, a, o, s, c);
|
|
1392
1426
|
}
|
|
1393
1427
|
}
|
|
1394
1428
|
}
|
|
1395
|
-
function
|
|
1429
|
+
function yt(e, t, n) {
|
|
1396
1430
|
let { scale: r } = n, i = n.pageWidth * r, a = n.marginLeft * r, o = n.marginRight * r;
|
|
1397
1431
|
switch (e ?? (t ? "margin" : "page")) {
|
|
1398
1432
|
case "page": return {
|
|
@@ -1421,7 +1455,7 @@ function ht(e, t, n) {
|
|
|
1421
1455
|
};
|
|
1422
1456
|
}
|
|
1423
1457
|
}
|
|
1424
|
-
function
|
|
1458
|
+
function bt(e, t, n, r) {
|
|
1425
1459
|
let { scale: i } = r, a = r.marginTop * i, o = r.marginBottom * i;
|
|
1426
1460
|
switch (e ?? (t ? "paragraph" : "page")) {
|
|
1427
1461
|
case "page": return {
|
|
@@ -1447,8 +1481,8 @@ function gt(e, t, n, r) {
|
|
|
1447
1481
|
};
|
|
1448
1482
|
}
|
|
1449
1483
|
}
|
|
1450
|
-
function
|
|
1451
|
-
let { scale: c } = i, l =
|
|
1484
|
+
function xt(e, t, n, r, i, a, o, s) {
|
|
1485
|
+
let { scale: c } = i, l = yt(a, t, i), u = n * c;
|
|
1452
1486
|
if (o != null) return l.start + (l.end - l.start) * o + u;
|
|
1453
1487
|
if (!e) return l.start + u;
|
|
1454
1488
|
let d = l.end - l.start, f = s == null ? r : s * c;
|
|
@@ -1459,8 +1493,8 @@ function _t(e, t, n, r, i, a, o, s) {
|
|
|
1459
1493
|
default: return l.start + u;
|
|
1460
1494
|
}
|
|
1461
1495
|
}
|
|
1462
|
-
function
|
|
1463
|
-
let { scale: l } = a, u =
|
|
1496
|
+
function St(e, t, n, r, i, a, o, s, c) {
|
|
1497
|
+
let { scale: l } = a, u = bt(o, t, i, a), d = n * l;
|
|
1464
1498
|
if (s != null) return u.start + (u.end - u.start) * s + d;
|
|
1465
1499
|
if (!e) return u.start + d;
|
|
1466
1500
|
let f = u.end - u.start, p = c == null ? r : c * l;
|
|
@@ -1470,17 +1504,17 @@ function vt(e, t, n, r, i, a, o, s, c) {
|
|
|
1470
1504
|
default: return u.start + d;
|
|
1471
1505
|
}
|
|
1472
1506
|
}
|
|
1473
|
-
function
|
|
1507
|
+
function Ct(e) {
|
|
1474
1508
|
if (e) return {
|
|
1475
1509
|
type: e.type,
|
|
1476
1510
|
w: e.w,
|
|
1477
1511
|
len: e.len
|
|
1478
1512
|
};
|
|
1479
1513
|
}
|
|
1480
|
-
function
|
|
1514
|
+
function wt(e, a, o) {
|
|
1481
1515
|
let { ctx: s, scale: l } = a, u = e.widthPt * l, p = e.heightPt * l, m = e.anchorXPt, h = e.anchorYPt, g = e.groupWidthPt ?? null, _ = e.groupHeightPt ?? null;
|
|
1482
1516
|
if (e.widthPct != null) {
|
|
1483
|
-
let t =
|
|
1517
|
+
let t = yt(e.widthRelativeFrom, !1, a), n = (t.end - t.start) * e.widthPct / l;
|
|
1484
1518
|
if (e.groupWidthPt != null && e.groupWidthPt > 0) {
|
|
1485
1519
|
let t = n / e.groupWidthPt;
|
|
1486
1520
|
u = e.widthPt * l * t, m = e.anchorXPt * t;
|
|
@@ -1488,7 +1522,7 @@ function bt(e, a, o) {
|
|
|
1488
1522
|
g = n;
|
|
1489
1523
|
}
|
|
1490
1524
|
if (e.heightPct != null) {
|
|
1491
|
-
let t =
|
|
1525
|
+
let t = bt(e.heightRelativeFrom, !1, o, a), n = (t.end - t.start) * e.heightPct / l;
|
|
1492
1526
|
if (e.groupHeightPt != null && e.groupHeightPt > 0) {
|
|
1493
1527
|
let t = n / e.groupHeightPt;
|
|
1494
1528
|
p = e.heightPt * l * t, h = e.anchorYPt * t;
|
|
@@ -1497,14 +1531,14 @@ function bt(e, a, o) {
|
|
|
1497
1531
|
}
|
|
1498
1532
|
let v = e.presetGeometry?.toLowerCase() ?? "", y = v === "line" || v.startsWith("straightconnector") || v.startsWith("bentconnector") || v.startsWith("curvedconnector");
|
|
1499
1533
|
if (u < 0 || p < 0 || (y ? u === 0 && p === 0 : u === 0 || p === 0)) return;
|
|
1500
|
-
let b =
|
|
1534
|
+
let b = xt(e.anchorXAlign, e.anchorXFromMargin, m, u, a, e.anchorXRelativeFrom, e.pctPosH, g), S = St(e.anchorYAlign, e.anchorYFromPara, h, p, o, a, e.anchorYRelativeFrom, e.pctPosV, _), C = e.rotation ?? 0, w = e.flipH ?? !1, T = e.flipV ?? !1;
|
|
1501
1535
|
s.save(), (C !== 0 || w || T) && (s.translate(b + u / 2, S + p / 2), C !== 0 && s.rotate(C * Math.PI / 180), w && s.scale(-1, 1), T && s.scale(1, -1), s.translate(-(b + u / 2), -(S + p / 2)));
|
|
1502
|
-
let E = e.presetGeometry?.toLowerCase() ?? "", D = !!e.presetGeometry &&
|
|
1536
|
+
let E = e.presetGeometry?.toLowerCase() ?? "", D = !!e.presetGeometry && t(E), O = e.adjValues ?? [], k = i(e.fill, s, b, S, u, p), A = e.stroke && (e.strokeWidth ?? 0) > 0 ? {
|
|
1503
1537
|
color: e.stroke,
|
|
1504
1538
|
width: e.strokeWidth ?? 0,
|
|
1505
1539
|
dashStyle: e.strokeDash ?? void 0,
|
|
1506
|
-
headEnd:
|
|
1507
|
-
tailEnd:
|
|
1540
|
+
headEnd: Ct(e.headEnd),
|
|
1541
|
+
tailEnd: Ct(e.tailEnd)
|
|
1508
1542
|
} : null, j = A ? () => {
|
|
1509
1543
|
c(s, A, l), s.stroke();
|
|
1510
1544
|
} : null;
|
|
@@ -1521,15 +1555,15 @@ function bt(e, a, o) {
|
|
|
1521
1555
|
let t = d(v, b, S, u, p, e.adjValues ?? []);
|
|
1522
1556
|
t && (s.setLineDash([]), A.tailEnd && f(s, t.end.x, t.end.y, t.end.angle, A.tailEnd, A, l), A.headEnd && f(s, t.start.x, t.start.y, t.start.angle, A.headEnd, A, l));
|
|
1523
1557
|
}
|
|
1524
|
-
s.restore(), e.textBlocks && e.textBlocks.length > 0 &&
|
|
1558
|
+
s.restore(), e.textBlocks && e.textBlocks.length > 0 && Tt(e, b, S, u, p, s, l, a.fontFamilyClasses);
|
|
1525
1559
|
}
|
|
1526
|
-
function
|
|
1560
|
+
function Tt(e, t, n, r, i, a, o, s = {}) {
|
|
1527
1561
|
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", x;
|
|
1528
1562
|
x = y === "b" ? h + Math.max(0, g - v) : y === "ctr" ? h + Math.max(0, (g - v) / 2) : h;
|
|
1529
1563
|
for (let e = 0; e < c.length; e++) {
|
|
1530
1564
|
let t = c[e], n = t.fontSizePt * o;
|
|
1531
|
-
a.font =
|
|
1532
|
-
let r = b(void 0, t.text) === "rtl", i = t.alignment === "distribute" ? "center" :
|
|
1565
|
+
a.font = J(t.bold ?? !1, t.italic ?? !1, n, t.fontFamily ?? null, s), a.fillStyle = t.color ? `#${t.color}` : "#000000";
|
|
1566
|
+
let r = b(void 0, t.text) === "rtl", i = t.alignment === "distribute" ? "center" : ie(t.alignment, r);
|
|
1533
1567
|
a.textAlign = "left", a.direction = r ? "rtl" : "ltr";
|
|
1534
1568
|
let l = a.measureText(t.text), u = p;
|
|
1535
1569
|
i === "center" ? u = p + Math.max(0, (m - l.width) / 2) : i === "right" && (u = p + Math.max(0, m - l.width));
|
|
@@ -1538,7 +1572,7 @@ function xt(e, t, n, r, i, a, o, s = {}) {
|
|
|
1538
1572
|
}
|
|
1539
1573
|
a.direction = "ltr";
|
|
1540
1574
|
}
|
|
1541
|
-
function
|
|
1575
|
+
function Et(e, t, n) {
|
|
1542
1576
|
let r = t.scale;
|
|
1543
1577
|
return {
|
|
1544
1578
|
x: e.anchorXFromMargin ? (t.marginLeft + (e.anchorXPt ?? 0)) * r : (e.anchorXPt ?? 0) * r,
|
|
@@ -1551,15 +1585,15 @@ function St(e, t, n) {
|
|
|
1551
1585
|
db: (e.distBottom ?? 0) * r
|
|
1552
1586
|
};
|
|
1553
1587
|
}
|
|
1554
|
-
function
|
|
1588
|
+
function Dt(e, t, n) {
|
|
1555
1589
|
let r = t.floatParaSeq++;
|
|
1556
1590
|
for (let i of e.runs) {
|
|
1557
1591
|
if (i.type !== "image") continue;
|
|
1558
1592
|
let e = i;
|
|
1559
|
-
if (!e.anchor || !
|
|
1560
|
-
let a = e.wrapMode === "topAndBottom" ? "topAndBottom" : "square", o =
|
|
1593
|
+
if (!e.anchor || !ae(e.wrapMode)) continue;
|
|
1594
|
+
let a = e.wrapMode === "topAndBottom" ? "topAndBottom" : "square", o = Et(e, t, n), { w: s, h: c, dl: l, dr: u, dt: d, db: f } = o, p = o.x, m = o.y, h = e.allowOverlap ?? !0, g = le(p, m, s, c, l, u, d, f, r, h, t.pageWidth * t.scale, t.floats);
|
|
1561
1595
|
p = g.x, m = g.y;
|
|
1562
|
-
let _ =
|
|
1596
|
+
let _ = R(e.dataUrl, e.colorReplaceFrom), v = {
|
|
1563
1597
|
mode: a,
|
|
1564
1598
|
imageKey: _,
|
|
1565
1599
|
imageX: p,
|
|
@@ -1584,10 +1618,10 @@ function Ct(e, t, n) {
|
|
|
1584
1618
|
}
|
|
1585
1619
|
}
|
|
1586
1620
|
}
|
|
1587
|
-
function
|
|
1588
|
-
let { ctx: n, scale: r, contentX: i, contentW: a, dryRun: o } = t, s =
|
|
1621
|
+
function Ot(e, t) {
|
|
1622
|
+
let { ctx: n, scale: r, contentX: i, contentW: a, dryRun: o } = t, s = He(e, a / r, t).map((e) => e * r), c = s.reduce((e, t) => e + t, 0), l = e.jc === "center" ? i + Math.max(0, (a - c) / 2) : e.jc === "right" ? i + Math.max(0, a - c) : i, u = [];
|
|
1589
1623
|
for (let n of e.rows) {
|
|
1590
|
-
let i =
|
|
1624
|
+
let i = kt(n, e, s, r, t);
|
|
1591
1625
|
u.push(i);
|
|
1592
1626
|
}
|
|
1593
1627
|
for (let n = 0; n < e.rows.length; n++) {
|
|
@@ -1595,7 +1629,7 @@ function wt(e, t) {
|
|
|
1595
1629
|
for (let a of e.rows[n].cells) {
|
|
1596
1630
|
let o = Math.min(a.colSpan, s.length - i);
|
|
1597
1631
|
if (a.vMerge === !0) {
|
|
1598
|
-
let c =
|
|
1632
|
+
let c = At(a, e, s.slice(i, i + o).reduce((e, t) => e + t, 0), r, t), l = Ge(e, n, i), d = 0;
|
|
1599
1633
|
for (let e = n; e <= l; e++) d += u[e];
|
|
1600
1634
|
d < c && (u[l] += c - d);
|
|
1601
1635
|
}
|
|
@@ -1610,12 +1644,12 @@ function wt(e, t) {
|
|
|
1610
1644
|
if (h.vMerge !== !1) {
|
|
1611
1645
|
let s = a;
|
|
1612
1646
|
if (h.vMerge === !0) {
|
|
1613
|
-
let t =
|
|
1647
|
+
let t = Ge(e, n, m);
|
|
1614
1648
|
s = 0;
|
|
1615
1649
|
for (let e = n; e <= t; e++) s += u[e];
|
|
1616
1650
|
}
|
|
1617
1651
|
let c = i.rowHeightRule === "exact" && h.vMerge !== !0;
|
|
1618
|
-
o ?
|
|
1652
|
+
o ? Mt(h, e, _, r, t) : Nt(h, e, v, f, _, s, t, d, c);
|
|
1619
1653
|
}
|
|
1620
1654
|
p += _, m += g;
|
|
1621
1655
|
}
|
|
@@ -1623,11 +1657,11 @@ function wt(e, t) {
|
|
|
1623
1657
|
}
|
|
1624
1658
|
t.y = f;
|
|
1625
1659
|
}
|
|
1626
|
-
function
|
|
1660
|
+
function kt(e, t, n, r, i) {
|
|
1627
1661
|
if (e.rowHeight != null && e.rowHeightRule === "exact") return e.rowHeight * r;
|
|
1628
1662
|
let a = e.rowHeight == null ? 10 * r : e.rowHeight * r, o = 0;
|
|
1629
1663
|
for (let s of e.cells) {
|
|
1630
|
-
let e = Math.min(s.colSpan, n.length - o), c = n.slice(o, o + e).reduce((e, t) => e + t, 0), l =
|
|
1664
|
+
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;
|
|
1631
1665
|
if (s.vMerge === !0) {
|
|
1632
1666
|
o += e;
|
|
1633
1667
|
continue;
|
|
@@ -1637,25 +1671,25 @@ function Tt(e, t, n, r, i) {
|
|
|
1637
1671
|
continue;
|
|
1638
1672
|
}
|
|
1639
1673
|
let d = (l.top + l.bottom) * r;
|
|
1640
|
-
for (let e of s.content) d +=
|
|
1674
|
+
for (let e of s.content) d += K(i, e, u, r);
|
|
1641
1675
|
d > a && (a = d), o += e;
|
|
1642
1676
|
}
|
|
1643
1677
|
return a;
|
|
1644
1678
|
}
|
|
1645
|
-
function
|
|
1646
|
-
let a =
|
|
1647
|
-
for (let t of e.content) s +=
|
|
1679
|
+
function At(e, t, n, r, i) {
|
|
1680
|
+
let a = G(e, t), o = n - (a.left + a.right) * r, s = (a.top + a.bottom) * r;
|
|
1681
|
+
for (let t of e.content) s += K(i, t, o, r);
|
|
1648
1682
|
return s;
|
|
1649
1683
|
}
|
|
1650
|
-
function
|
|
1651
|
-
let i =
|
|
1684
|
+
function jt(e, t, n, r) {
|
|
1685
|
+
let i = U(t.runs, e), a = B(t), o = Le(t, e);
|
|
1652
1686
|
if (i.length === 0) {
|
|
1653
|
-
let { asc: e, desc: n } =
|
|
1654
|
-
return Q(t.lineSpacing, e, n, r, o, a,
|
|
1687
|
+
let { asc: e, desc: n } = Yt(X(t), r);
|
|
1688
|
+
return Q(t.lineSpacing, e, n, r, o, a, qt(t, r), V(t));
|
|
1655
1689
|
}
|
|
1656
|
-
return
|
|
1690
|
+
return W(e.ctx, i, n, 0, r, t.tabStops, void 0, e.fontFamilyClasses, 0, e.kinsoku).reduce((e, n) => e + Q(t.lineSpacing, n.ascent, n.descent, r, o, a, n.intendedSingle, V(t)), 0);
|
|
1657
1691
|
}
|
|
1658
|
-
function
|
|
1692
|
+
function G(e, t) {
|
|
1659
1693
|
return {
|
|
1660
1694
|
top: e.marginTop ?? t.cellMarginTop,
|
|
1661
1695
|
bottom: e.marginBottom ?? t.cellMarginBottom,
|
|
@@ -1663,54 +1697,54 @@ function K(e, t) {
|
|
|
1663
1697
|
right: e.marginRight ?? t.cellMarginRight
|
|
1664
1698
|
};
|
|
1665
1699
|
}
|
|
1666
|
-
function
|
|
1667
|
-
let a =
|
|
1668
|
-
for (let t of e.content)
|
|
1700
|
+
function Mt(e, t, n, r, i) {
|
|
1701
|
+
let a = G(e, t), o = a.left * r, s = a.right * r, c = n - o - s;
|
|
1702
|
+
for (let t of e.content) K(i, t, c, r);
|
|
1669
1703
|
}
|
|
1670
|
-
function
|
|
1704
|
+
function K(e, t, n, r) {
|
|
1671
1705
|
if (t.type === "paragraph") {
|
|
1672
1706
|
let i = t;
|
|
1673
|
-
return
|
|
1707
|
+
return jt(e, i, n, r) + (i.spaceBefore + i.spaceAfter) * r;
|
|
1674
1708
|
}
|
|
1675
|
-
return
|
|
1709
|
+
return Be(e, t, n / r) * r;
|
|
1676
1710
|
}
|
|
1677
|
-
function
|
|
1711
|
+
function Nt(e, t, n, r, i, a, o, s = !1, c = !1) {
|
|
1678
1712
|
let { ctx: l, scale: u } = o;
|
|
1679
|
-
e.background && (l.fillStyle = `#${e.background}`, l.fillRect(n, r, i, a)),
|
|
1680
|
-
let d =
|
|
1713
|
+
e.background && (l.fillStyle = `#${e.background}`, l.fillRect(n, r, i, a)), It(l, n, r, i, a, e.borders, t.borders, u, s);
|
|
1714
|
+
let d = G(e, t), f = d.top * u, p = d.bottom * u, m = d.left * u, h = d.right * u, g = {
|
|
1681
1715
|
...o,
|
|
1682
1716
|
contentX: n + m,
|
|
1683
1717
|
contentW: i - m - h,
|
|
1684
1718
|
y: r + f
|
|
1685
1719
|
};
|
|
1686
1720
|
if (e.vAlign === "center" || e.vAlign === "bottom") {
|
|
1687
|
-
let t =
|
|
1721
|
+
let t = Pt(e.content), n = t.reduce((e, t) => e + K(g, t, i - m - h, u), 0), o = t[t.length - 1];
|
|
1688
1722
|
o && o.type === "paragraph" && (n -= o.spaceAfter * u), e.vAlign === "center" ? g.y = r + (a - n) / 2 : g.y = r + a - n - p;
|
|
1689
1723
|
}
|
|
1690
|
-
c ? (l.save(), l.beginPath(), l.rect(n, r, i, a), l.clip(),
|
|
1724
|
+
c ? (l.save(), l.beginPath(), l.rect(n, r, i, a), l.clip(), Ft(e.content, g), l.restore()) : Ft(e.content, g);
|
|
1691
1725
|
}
|
|
1692
|
-
function
|
|
1726
|
+
function Pt(e) {
|
|
1693
1727
|
if (e.length < 2) return e;
|
|
1694
1728
|
let t = e[e.length - 1], n = e[e.length - 2];
|
|
1695
1729
|
return t.type !== "paragraph" || n.type === "paragraph" || t.runs.length > 0 ? e : e.slice(0, -1);
|
|
1696
1730
|
}
|
|
1697
|
-
function
|
|
1731
|
+
function Ft(e, t) {
|
|
1698
1732
|
let n = null, r = 0;
|
|
1699
1733
|
for (let i of e) if (i.type === "paragraph") {
|
|
1700
|
-
let e = i, a =
|
|
1701
|
-
t.y -= Math.min(r, o) * t.scale,
|
|
1702
|
-
} else i.type === "table" && (
|
|
1734
|
+
let e = i, a = H(n, e), o = a ? 0 : e.spaceBefore;
|
|
1735
|
+
t.y -= Math.min(r, o) * t.scale, $e(e, t, a), n = e, r = e.spaceAfter;
|
|
1736
|
+
} else i.type === "table" && (Ot(i, t), n = null, r = 0);
|
|
1703
1737
|
}
|
|
1704
|
-
function
|
|
1738
|
+
function It(e, t, n, r, i, a, o, s, c = !1) {
|
|
1705
1739
|
let l = a.top ?? o.top, u = a.bottom ?? o.bottom, d = c ? a.right ?? o.right : a.left ?? o.left, f = c ? a.left ?? o.left : a.right ?? o.right;
|
|
1706
|
-
l && l.style !== "none" &&
|
|
1740
|
+
l && l.style !== "none" && q(e, t, n, t + r, n, l, s), u && u.style !== "none" && q(e, t, n + i, t + r, n + i, u, s), d && d.style !== "none" && q(e, t, n, t, n + i, d, s), f && f.style !== "none" && q(e, t + r, n, t + r, n + i, f, s);
|
|
1707
1741
|
}
|
|
1708
|
-
function
|
|
1742
|
+
function q(e, t, n, r, i, a, o) {
|
|
1709
1743
|
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();
|
|
1710
1744
|
}
|
|
1711
|
-
function
|
|
1745
|
+
function Lt(e, t, n, r, i, a, o) {
|
|
1712
1746
|
let s = (t, n, r, i, a) => {
|
|
1713
|
-
!t || t.style === "none" ||
|
|
1747
|
+
!t || t.style === "none" || q(e, n, r, i, a, {
|
|
1714
1748
|
width: t.width,
|
|
1715
1749
|
color: t.color,
|
|
1716
1750
|
style: t.style
|
|
@@ -1718,14 +1752,14 @@ function Nt(e, t, n, r, i, a, o) {
|
|
|
1718
1752
|
}, c = (e) => (e?.space ?? 0) * o;
|
|
1719
1753
|
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);
|
|
1720
1754
|
}
|
|
1721
|
-
function
|
|
1755
|
+
function Rt(e, t) {
|
|
1722
1756
|
let n = e.fontSize * t;
|
|
1723
1757
|
return e.smallCaps && (n *= .8), e.vertAlign && (n *= .65), n;
|
|
1724
1758
|
}
|
|
1725
|
-
function
|
|
1726
|
-
return `${t ? "italic" : "normal"} ${e ? "bold" : "normal"} ${n}px ${
|
|
1759
|
+
function J(e, t, n, r, i = {}) {
|
|
1760
|
+
return `${t ? "italic" : "normal"} ${e ? "bold" : "normal"} ${n}px ${Gt(r, i)}`;
|
|
1727
1761
|
}
|
|
1728
|
-
var
|
|
1762
|
+
var zt = new Set([
|
|
1729
1763
|
"sakkal majalla",
|
|
1730
1764
|
"traditional arabic",
|
|
1731
1765
|
"simplified arabic",
|
|
@@ -1733,34 +1767,34 @@ var Ft = new Set([
|
|
|
1733
1767
|
"univers next arabic",
|
|
1734
1768
|
"noto naskh arabic",
|
|
1735
1769
|
"noto sans arabic"
|
|
1736
|
-
]),
|
|
1770
|
+
]), Bt = new Set([
|
|
1737
1771
|
"sakkal majalla",
|
|
1738
1772
|
"traditional arabic",
|
|
1739
1773
|
"simplified arabic",
|
|
1740
1774
|
"arabic typesetting",
|
|
1741
1775
|
"noto naskh arabic"
|
|
1742
1776
|
]);
|
|
1743
|
-
function
|
|
1744
|
-
return
|
|
1777
|
+
function Vt(e) {
|
|
1778
|
+
return zt.has(e.toLowerCase());
|
|
1745
1779
|
}
|
|
1746
|
-
function
|
|
1780
|
+
function Ht(e) {
|
|
1747
1781
|
return e.map((e) => `"${e}"`).join(", ");
|
|
1748
1782
|
}
|
|
1749
|
-
var
|
|
1750
|
-
function
|
|
1751
|
-
return `${
|
|
1783
|
+
var Ut = ["Noto Naskh Arabic", "Noto Sans Arabic"];
|
|
1784
|
+
function Y(e) {
|
|
1785
|
+
return `${Ht([
|
|
1752
1786
|
...e && e !== "jp" ? S(e, "sans") : [
|
|
1753
1787
|
"Noto Sans JP",
|
|
1754
1788
|
"Hiragino Sans",
|
|
1755
1789
|
"Meiryo",
|
|
1756
1790
|
...S("jp", "sans").slice(1)
|
|
1757
1791
|
],
|
|
1758
|
-
...
|
|
1792
|
+
...Ut,
|
|
1759
1793
|
...o
|
|
1760
1794
|
])}, sans-serif`;
|
|
1761
1795
|
}
|
|
1762
|
-
function
|
|
1763
|
-
return `${
|
|
1796
|
+
function Wt(e) {
|
|
1797
|
+
return `${Ht([
|
|
1764
1798
|
...e && e !== "jp" ? S(e, "serif") : [
|
|
1765
1799
|
"Yu Mincho",
|
|
1766
1800
|
"YuMincho",
|
|
@@ -1769,64 +1803,70 @@ function Bt(e) {
|
|
|
1769
1803
|
"Noto Serif JP",
|
|
1770
1804
|
...S("jp", "serif").slice(1)
|
|
1771
1805
|
],
|
|
1772
|
-
...
|
|
1806
|
+
...Ut,
|
|
1773
1807
|
...s
|
|
1774
1808
|
])}, serif`;
|
|
1775
1809
|
}
|
|
1776
|
-
function
|
|
1777
|
-
if (!t) return
|
|
1810
|
+
function Gt(t, n = {}) {
|
|
1811
|
+
if (!t) return Y(null);
|
|
1778
1812
|
let r = `"${((e) => e.replace(/"/g, "\\\""))(t)}"`, i = t.toLowerCase(), a = e(t);
|
|
1779
|
-
if (
|
|
1813
|
+
if (Vt(t)) return Bt.has(i) ? `${r}, "Noto Naskh Arabic", "Noto Sans Arabic", "Noto Serif", "Noto Sans JP", "Hiragino Sans", serif` : `${r}, "Noto Sans Arabic", "Noto Naskh Arabic", "Noto Sans JP", "Hiragino Sans", sans-serif`;
|
|
1780
1814
|
let s = a != null && (/song|sung|simsun|nsimsun|batang|gungsuh|mincho|mingliu|pmingliu|ming\s*liu|fang\s*song|fangsong|kai\s*ti|kaiti|stsong|stkaiti|stfangsong|stzhongsong|simkai|simfang|新細明|細明|宋体|明朝|楷体|楷體|仿宋|標楷|游明朝|MS 明朝/.test(i) || /新細明體|細明體|宋体|明朝|楷体|楷體|仿宋|標楷體|游明朝|MS 明朝/.test(t)), c = n[t];
|
|
1781
1815
|
if (c && c !== "auto") switch (c) {
|
|
1782
|
-
case "roman": return `${r}, ${
|
|
1783
|
-
case "swiss": return `${r}, ${
|
|
1816
|
+
case "roman": return `${r}, ${Wt(a)}`;
|
|
1817
|
+
case "swiss": return `${r}, ${Y(a)}`;
|
|
1784
1818
|
case "modern": return `${r}, "Courier New", monospace`;
|
|
1785
1819
|
default: break;
|
|
1786
1820
|
}
|
|
1787
|
-
if (s || t.includes("明朝") || t.includes("明朝体") || /\bmincho\b/i.test(t) || /\bmin\s*cho\b/i.test(t) || t.includes("MS 明朝") || t.includes("MS Mincho") || t.includes("Yu Mincho") || t.includes("游明朝") || t.includes("Hiragino Mincho") || t.includes("ヒラギノ明朝") || t.includes("Cambria") || t.includes("Caladea") || t.includes("Times") || t.includes("Georgia") || t.includes("Bodoni") || t.includes("Garamond") || t.includes("Playfair") || t.includes("Source Serif") || t.includes("Noto Serif")) return `${r}, ${
|
|
1821
|
+
if (s || t.includes("明朝") || t.includes("明朝体") || /\bmincho\b/i.test(t) || /\bmin\s*cho\b/i.test(t) || t.includes("MS 明朝") || t.includes("MS Mincho") || t.includes("Yu Mincho") || t.includes("游明朝") || t.includes("Hiragino Mincho") || t.includes("ヒラギノ明朝") || t.includes("Cambria") || t.includes("Caladea") || t.includes("Times") || t.includes("Georgia") || t.includes("Bodoni") || t.includes("Garamond") || t.includes("Playfair") || t.includes("Source Serif") || t.includes("Noto Serif")) return `${r}, ${Wt(a)}`;
|
|
1788
1822
|
if (a == null || a === "jp") {
|
|
1789
|
-
if (i.includes("meiryo") || t.includes("メイリオ")) return `${r}, "Meiryo UI", "Meiryo", ${
|
|
1790
|
-
if (t.includes("游ゴシック") || /\byu\s*gothic\b/i.test(t) || i.includes("yugothic")) return `${r}, "Yu Gothic", "YuGothic", ${
|
|
1791
|
-
if (i.includes("ipa")) return `${r}, "IPAexGothic", ${
|
|
1792
|
-
if (i.includes("segoe")) return `${r}, "Segoe UI", ${
|
|
1823
|
+
if (i.includes("meiryo") || t.includes("メイリオ")) return `${r}, "Meiryo UI", "Meiryo", ${Y(a)}`;
|
|
1824
|
+
if (t.includes("游ゴシック") || /\byu\s*gothic\b/i.test(t) || i.includes("yugothic")) return `${r}, "Yu Gothic", "YuGothic", ${Y(a)}`;
|
|
1825
|
+
if (i.includes("ipa")) return `${r}, "IPAexGothic", ${Y(a)}`;
|
|
1826
|
+
if (i.includes("segoe")) return `${r}, "Segoe UI", ${Ht([...Ut, ...o])}, sans-serif`;
|
|
1793
1827
|
}
|
|
1794
|
-
return `${r}, ${
|
|
1828
|
+
return `${r}, ${Y(a)}`;
|
|
1795
1829
|
}
|
|
1796
|
-
function
|
|
1830
|
+
function X(e) {
|
|
1797
1831
|
for (let t of e.runs) if (t.type === "text" || t.type === "field") return t.fontSize;
|
|
1798
1832
|
return typeof e.defaultFontSize == "number" ? e.defaultFontSize : 10;
|
|
1799
1833
|
}
|
|
1800
|
-
function
|
|
1801
|
-
return
|
|
1834
|
+
function Z(e, t) {
|
|
1835
|
+
return X(e) * t;
|
|
1802
1836
|
}
|
|
1803
|
-
function
|
|
1837
|
+
function Kt(e) {
|
|
1804
1838
|
for (let t of e.runs) if (t.type === "text" || t.type === "field") return t.fontFamily;
|
|
1805
1839
|
return e.defaultFontFamily ?? null;
|
|
1806
1840
|
}
|
|
1807
|
-
function
|
|
1808
|
-
return j(
|
|
1841
|
+
function qt(e, t) {
|
|
1842
|
+
return j(Kt(e), X(e) * t);
|
|
1809
1843
|
}
|
|
1810
|
-
function
|
|
1844
|
+
function Jt(e) {
|
|
1811
1845
|
return !e || !e.linePitchPt || e.linePitchPt <= 0 ? !1 : e.type === "lines" || e.type === "linesAndChars";
|
|
1812
1846
|
}
|
|
1813
|
-
function Q(e, t, n, r, i, a, o = 0) {
|
|
1814
|
-
let
|
|
1815
|
-
return !e || (e.rule === "exact" || e.rule === "auto") && e.value <= 0 ?
|
|
1847
|
+
function Q(e, t, n, r, i, a, o = 0, s = !1) {
|
|
1848
|
+
let c = t + n, l = Math.max(c, o), u = Jt(i), d = u ? i.linePitchPt * r : 0, f = () => s ? Math.max(d, Math.ceil(c / d) * d) : Math.max(c, d), p = e !== null && e.explicit !== !0;
|
|
1849
|
+
return !e || (e.rule === "exact" || e.rule === "auto") && e.value <= 0 ? u ? f() : l : e.rule === "auto" ? u ? p ? f() : Math.max(c, d * e.value) : l * e.value : e.rule === "exact" ? e.value * r : e.rule === "atLeast" ? Math.max(l, e.value * r) : l;
|
|
1816
1850
|
}
|
|
1817
|
-
function
|
|
1851
|
+
function Yt(e, t) {
|
|
1818
1852
|
return {
|
|
1819
1853
|
asc: e * t * .8,
|
|
1820
1854
|
desc: e * t * .2
|
|
1821
1855
|
};
|
|
1822
1856
|
}
|
|
1823
|
-
function
|
|
1824
|
-
let
|
|
1825
|
-
|
|
1857
|
+
function Xt(e, t, n, r, i = !1, a, o = {}) {
|
|
1858
|
+
let s = X(e), c, l;
|
|
1859
|
+
if (i && a) {
|
|
1860
|
+
let n = a.font;
|
|
1861
|
+
a.font = J(!1, !1, s * t, Kt(e), o);
|
|
1862
|
+
let r = a.measureText("あ");
|
|
1863
|
+
c = r.fontBoundingBoxAscent ?? r.actualBoundingBoxAscent ?? s * t * .8, l = r.fontBoundingBoxDescent ?? r.actualBoundingBoxDescent ?? s * t * .2, a.font = n;
|
|
1864
|
+
} else ({asc: c, desc: l} = Yt(s, t));
|
|
1865
|
+
return Q(e.lineSpacing, c, l, t, n, r, qt(e, t), i);
|
|
1826
1866
|
}
|
|
1827
1867
|
//#endregion
|
|
1828
1868
|
//#region packages/docx/src/google-fonts.ts
|
|
1829
|
-
var $ = "https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap",
|
|
1869
|
+
var $ = "https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700&display=swap", Zt = "https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;700&display=swap", Qt = {
|
|
1830
1870
|
calibri: {
|
|
1831
1871
|
url: "https://fonts.googleapis.com/css2?family=Carlito:ital,wght@0,400;0,700;1,400;1,700&display=swap",
|
|
1832
1872
|
loadFamily: "Carlito"
|
|
@@ -1861,7 +1901,7 @@ var $ = "https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700
|
|
|
1861
1901
|
loadFamily: "Noto Naskh Arabic"
|
|
1862
1902
|
},
|
|
1863
1903
|
"univers next arabic": {
|
|
1864
|
-
url:
|
|
1904
|
+
url: Zt,
|
|
1865
1905
|
loadFamily: "Noto Sans Arabic"
|
|
1866
1906
|
},
|
|
1867
1907
|
"noto naskh arabic": {
|
|
@@ -1869,12 +1909,12 @@ var $ = "https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;700
|
|
|
1869
1909
|
loadFamily: "Noto Naskh Arabic"
|
|
1870
1910
|
},
|
|
1871
1911
|
"noto sans arabic": {
|
|
1872
|
-
url:
|
|
1912
|
+
url: Zt,
|
|
1873
1913
|
loadFamily: "Noto Sans Arabic"
|
|
1874
1914
|
},
|
|
1875
1915
|
...u
|
|
1876
1916
|
};
|
|
1877
|
-
function*
|
|
1917
|
+
function* $t(e) {
|
|
1878
1918
|
let t = function* (e) {
|
|
1879
1919
|
for (let t of e) if (t.type === "text") yield t.text;
|
|
1880
1920
|
else if (t.type === "field") yield t.fallbackText;
|
|
@@ -1892,17 +1932,17 @@ function* Xt(e) {
|
|
|
1892
1932
|
]) yield* r(e?.body);
|
|
1893
1933
|
for (let t of [...e.footnotes ?? [], ...e.endnotes ?? []]) yield* r(t.content);
|
|
1894
1934
|
}
|
|
1895
|
-
function
|
|
1935
|
+
function en(t) {
|
|
1896
1936
|
let n = e(t.majorFont) ?? e(t.minorFont) ?? null;
|
|
1897
1937
|
return [
|
|
1898
1938
|
t.majorFont,
|
|
1899
1939
|
t.minorFont,
|
|
1900
|
-
...m(
|
|
1940
|
+
...m($t(t), n)
|
|
1901
1941
|
];
|
|
1902
1942
|
}
|
|
1903
1943
|
//#endregion
|
|
1904
1944
|
//#region packages/docx/src/document.ts
|
|
1905
|
-
var
|
|
1945
|
+
var tn = class e {
|
|
1906
1946
|
_document = null;
|
|
1907
1947
|
_meta = null;
|
|
1908
1948
|
_pages = null;
|
|
@@ -1923,13 +1963,13 @@ var Qt = class e {
|
|
|
1923
1963
|
static async load(t, n = {}) {
|
|
1924
1964
|
let r = n.mode ?? "main";
|
|
1925
1965
|
if (r === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
|
|
1926
|
-
let i = new e(r === "worker" ? (await import("./render-worker-host-
|
|
1966
|
+
let i = new e(r === "worker" ? (await import("./render-worker-host-BbPdLKW3.js")).createRenderWorker() : new E(), r), o;
|
|
1927
1967
|
if (typeof t == "string") {
|
|
1928
1968
|
let e = await fetch(t);
|
|
1929
1969
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
1930
1970
|
o = await e.arrayBuffer();
|
|
1931
1971
|
} else o = t;
|
|
1932
|
-
return n.math && r === "worker" && console.warn("[ooxml] the math engine is unavailable in mode: 'worker'; equations will be skipped. Use mode: 'main' for documents with equations."), await i._parse(o, n.maxZipEntryBytes, r === "worker" ? !!n.useGoogleFonts : !1), r === "main" && n.useGoogleFonts && i._document && await a(
|
|
1972
|
+
return n.math && r === "worker" && console.warn("[ooxml] the math engine is unavailable in mode: 'worker'; equations will be skipped. Use mode: 'main' for documents with equations."), await i._parse(o, n.maxZipEntryBytes, r === "worker" ? !!n.useGoogleFonts : !1), r === "main" && n.useGoogleFonts && i._document && await a(en(i._document), Qt), r === "main" && n.math && i._document && fe(i._document.body) && await he(i._document.body, n.math), i;
|
|
1933
1973
|
}
|
|
1934
1974
|
async _parse(e, t, n = !1) {
|
|
1935
1975
|
let r = await this._bridge.request((r) => this._mode === "worker" ? {
|
|
@@ -1967,13 +2007,13 @@ var Qt = class e {
|
|
|
1967
2007
|
return this._meta?.endnotes ?? this._document?.endnotes ?? [];
|
|
1968
2008
|
}
|
|
1969
2009
|
_getPages() {
|
|
1970
|
-
return this._pages ? this._pages : this._document ? (this._pages =
|
|
2010
|
+
return this._pages ? this._pages : this._document ? (this._pages = Me(this._document), this._pages) : [];
|
|
1971
2011
|
}
|
|
1972
2012
|
renderPage(e, t, n = {}) {
|
|
1973
2013
|
if (this._mode === "worker") throw Error("renderPage(canvas) is unavailable in mode: 'worker'; use renderPageToBitmap() and paint it via an ImageBitmapRenderingContext");
|
|
1974
2014
|
if (!this._document) throw Error("Document not loaded");
|
|
1975
2015
|
let r = this._getPages();
|
|
1976
|
-
return
|
|
2016
|
+
return xe(this._document, e, t, {
|
|
1977
2017
|
...n,
|
|
1978
2018
|
totalPages: r.length,
|
|
1979
2019
|
prebuiltPages: r
|
|
@@ -1996,7 +2036,7 @@ var Qt = class e {
|
|
|
1996
2036
|
let r = new OffscreenCanvas(1, 1);
|
|
1997
2037
|
return await this.renderPage(r, e, n), r.transferToImageBitmap();
|
|
1998
2038
|
}
|
|
1999
|
-
},
|
|
2039
|
+
}, nn = class {
|
|
2000
2040
|
_doc = null;
|
|
2001
2041
|
_currentPage = 0;
|
|
2002
2042
|
_canvas;
|
|
@@ -2013,7 +2053,7 @@ var Qt = class e {
|
|
|
2013
2053
|
}
|
|
2014
2054
|
async load(e) {
|
|
2015
2055
|
try {
|
|
2016
|
-
this._doc = await
|
|
2056
|
+
this._doc = await tn.load(e, {
|
|
2017
2057
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
2018
2058
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
2019
2059
|
math: this._opts.math,
|
|
@@ -2078,7 +2118,7 @@ var Qt = class e {
|
|
|
2078
2118
|
};
|
|
2079
2119
|
//#endregion
|
|
2080
2120
|
//#region packages/docx/src/types.ts
|
|
2081
|
-
function
|
|
2121
|
+
function rn(e) {
|
|
2082
2122
|
let t = [];
|
|
2083
2123
|
for (let n of e.content) {
|
|
2084
2124
|
if (n.type !== "paragraph") continue;
|
|
@@ -2090,11 +2130,11 @@ function en(e) {
|
|
|
2090
2130
|
}
|
|
2091
2131
|
//#endregion
|
|
2092
2132
|
//#region src/docx.ts
|
|
2093
|
-
var
|
|
2094
|
-
DocxDocument: () =>
|
|
2095
|
-
DocxViewer: () =>
|
|
2133
|
+
var an = /* @__PURE__ */ p({
|
|
2134
|
+
DocxDocument: () => tn,
|
|
2135
|
+
DocxViewer: () => nn,
|
|
2096
2136
|
autoResize: () => l,
|
|
2097
|
-
noteText: () =>
|
|
2137
|
+
noteText: () => rn
|
|
2098
2138
|
});
|
|
2099
2139
|
//#endregion
|
|
2100
|
-
export {
|
|
2140
|
+
export { tn as i, rn as n, nn as r, an as t };
|