@silurus/ooxml 0.4.0 → 0.5.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-B96_4Bp5.cjs → docx-CGvCIxpo.cjs} +1 -1
- package/dist/{docx-CPf_N42P.js → docx-DUycjjDQ.js} +156 -131
- package/dist/docx.cjs +1 -1
- package/dist/docx.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/types/index.d.ts +21 -0
- package/dist/types/xlsx.d.ts +21 -0
- package/dist/xlsx-BAksLJGU.js +1191 -0
- package/dist/xlsx-Cz9qI8c9.cjs +4 -0
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.mjs +1 -1
- package/package.json +1 -1
- package/dist/xlsx--fOMyOGC.js +0 -1078
- package/dist/xlsx-C2jK_dYK.cjs +0 -4
|
@@ -110,26 +110,30 @@ async function m(e, t, n, r = {}) {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
function h(e, t, n) {
|
|
113
|
-
let r = t.pageHeight - t.marginTop - t.marginBottom, i = t.pageWidth - t.marginLeft - t.marginRight, a = g(n, t), o = [[]], s = 0, c = null
|
|
114
|
-
|
|
113
|
+
let r = t.pageHeight - t.marginTop - t.marginBottom, i = t.pageWidth - t.marginLeft - t.marginRight, a = g(n, t), o = [[]], s = 0, c = null;
|
|
114
|
+
a.y = t.marginTop, a.floats = [];
|
|
115
|
+
let l = () => {
|
|
116
|
+
o[o.length - 1].length > 0 && (o.push([]), s = 0, c = null, a.y = t.marginTop, a.floats = []);
|
|
115
117
|
}, u = (t) => {
|
|
116
118
|
let n = e[t];
|
|
117
119
|
return n ? n.type === "paragraph" ? _(a, n, i, !1) : n.type === "table" ? v(a, n, i) : 0 : 0;
|
|
118
120
|
};
|
|
119
|
-
for (let
|
|
120
|
-
let
|
|
121
|
-
if (
|
|
121
|
+
for (let n = 0; n < e.length; n++) {
|
|
122
|
+
let d = e[n];
|
|
123
|
+
if (d.type === "pageBreak") {
|
|
122
124
|
o.push([]), s = 0, c = null;
|
|
123
125
|
continue;
|
|
124
126
|
}
|
|
125
|
-
if (
|
|
126
|
-
let e =
|
|
127
|
+
if (d.type === "paragraph") {
|
|
128
|
+
let e = d;
|
|
127
129
|
e.pageBreakBefore && l();
|
|
128
|
-
let
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
let f = S(c, e);
|
|
131
|
+
I(e, a, a.y + (f ? 0 : e.spaceBefore));
|
|
132
|
+
let p = _(a, e, i, f, t.marginLeft), m = p + (e.keepNext ? u(n + 1) : 0);
|
|
133
|
+
s > 0 && s + m > r && l(), o[o.length - 1].push(d), s += p, a.y += p, c = e;
|
|
134
|
+
} else if (d.type === "table") {
|
|
135
|
+
let e = v(a, d, i);
|
|
136
|
+
s + e > r && l(), o[o.length - 1].push(d), s += e, a.y += e, c = null;
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
return o;
|
|
@@ -151,13 +155,22 @@ function g(e, t) {
|
|
|
151
155
|
floats: []
|
|
152
156
|
};
|
|
153
157
|
}
|
|
154
|
-
function _(e, t, n, r = !1) {
|
|
155
|
-
let
|
|
156
|
-
if (
|
|
157
|
-
let e =
|
|
158
|
-
|
|
159
|
-
} else
|
|
160
|
-
|
|
158
|
+
function _(e, t, n, r = !1, i = 0) {
|
|
159
|
+
let a = t.indentLeft, o = t.indentRight, s = Math.max(1, n - a - o), c = E(t.runs, e), l;
|
|
160
|
+
if (c.length === 0) {
|
|
161
|
+
let { asc: e, desc: n } = Z(Y(t), 1);
|
|
162
|
+
l = X(t.lineSpacing, e, n, 1);
|
|
163
|
+
} else {
|
|
164
|
+
let n = e.floats.length > 0 ? {
|
|
165
|
+
startPageY: e.y,
|
|
166
|
+
paraX: i,
|
|
167
|
+
floats: e.floats,
|
|
168
|
+
lineBoxH: (e, n) => X(t.lineSpacing, e, n, 1),
|
|
169
|
+
pageH: e.pageH
|
|
170
|
+
} : void 0;
|
|
171
|
+
l = A(e.ctx, c, s, t.indentFirst, 1, t.tabStops, n).reduce((e, n) => e + X(t.lineSpacing, n.ascent, n.descent, 1), 0);
|
|
172
|
+
}
|
|
173
|
+
return l + (r ? 0 : t.spaceBefore) + t.spaceAfter;
|
|
161
174
|
}
|
|
162
175
|
function v(e, t, n) {
|
|
163
176
|
let r = t.colWidths.reduce((e, t) => e + t, 0), i = r > n ? n / r : 1, a = t.colWidths.map((e) => e * i), o = 0;
|
|
@@ -203,7 +216,7 @@ function C(e, t) {
|
|
|
203
216
|
for (let r of e) if (r.type === "paragraph") {
|
|
204
217
|
let e = r;
|
|
205
218
|
T(e, t, S(n, e)), n = e;
|
|
206
|
-
} else r.type === "table" && (
|
|
219
|
+
} else r.type === "table" && (R(r, t), n = null);
|
|
207
220
|
}
|
|
208
221
|
function w(e, t) {
|
|
209
222
|
let n = null;
|
|
@@ -211,24 +224,24 @@ function w(e, t) {
|
|
|
211
224
|
}
|
|
212
225
|
function T(e, t, n = !1) {
|
|
213
226
|
let { ctx: r, scale: i, contentX: a, contentW: o, defaultColor: s, dryRun: l } = t, u = t.y;
|
|
214
|
-
n || (t.y += e.spaceBefore * i),
|
|
227
|
+
n || (t.y += e.spaceBefore * i), I(e, t, t.y), M(e, t, u, "behind"), t.y = L(t.y, t.floats);
|
|
215
228
|
let d = t.y, f = e.indentLeft * i, p = e.indentRight * i, m = e.indentFirst * i, h = "", g = 0;
|
|
216
229
|
e.numbering && (h = e.numbering.text + " ", g = e.numbering.tab * i);
|
|
217
230
|
let _ = a + f, v = _ + m, y = o - f - p, b = E(e.runs, t);
|
|
218
231
|
if (b.length === 0) {
|
|
219
|
-
let n =
|
|
220
|
-
e.shading && !l && (r.fillStyle = `#${e.shading}`, r.fillRect(a + f, d, y,
|
|
232
|
+
let { asc: n, desc: o } = Z(Y(e), i), s = X(e.lineSpacing, n, o, i);
|
|
233
|
+
e.shading && !l && (r.fillStyle = `#${e.shading}`, r.fillRect(a + f, d, y, s)), t.y += s, e.borders && !l && G(r, a + f, d, y, s, e.borders, i), t.y += e.spaceAfter * i, M(e, t, u);
|
|
221
234
|
return;
|
|
222
235
|
}
|
|
223
236
|
let x = t.floats.length > 0 ? {
|
|
224
237
|
startPageY: t.y,
|
|
225
238
|
paraX: _,
|
|
226
239
|
floats: t.floats,
|
|
227
|
-
|
|
240
|
+
lineBoxH: (t, n) => X(e.lineSpacing, t, n, i),
|
|
228
241
|
pageH: t.pageH
|
|
229
|
-
} : void 0, S =
|
|
242
|
+
} : void 0, S = A(r, b, y, v - _, i, e.tabStops, x);
|
|
230
243
|
if (e.shading && !l) {
|
|
231
|
-
let t = S.reduce((t, n) => t +
|
|
244
|
+
let t = S.reduce((t, n) => t + X(e.lineSpacing, n.ascent, n.descent, i), 0);
|
|
232
245
|
r.fillStyle = `#${e.shading}`, r.fillRect(a + f, d, y, t);
|
|
233
246
|
}
|
|
234
247
|
let C = e.alignment === "justify" || e.alignment === "both" || e.alignment === "distribute", w = e.alignment === "distribute", T = (e) => {
|
|
@@ -239,11 +252,11 @@ function T(e, t, n = !1) {
|
|
|
239
252
|
for (let n = 0; n < S.length; n++) {
|
|
240
253
|
let a = S[n], o = n === 0, u = n === S.length - 1;
|
|
241
254
|
a.topY !== void 0 && a.topY > t.y && (t.y = a.topY);
|
|
242
|
-
let d = a.
|
|
243
|
-
o && h && !l && (r.font = `${
|
|
244
|
-
let
|
|
245
|
-
e.alignment === "right" || e.alignment === "end" ?
|
|
246
|
-
let
|
|
255
|
+
let d = X(e.lineSpacing, a.ascent, a.descent, i), f = a.ascent + a.descent, p = t.y + (d - f) / 2 + a.ascent, v = _ + a.xOffset, y = a.availWidth, b = o ? v + m : v;
|
|
256
|
+
o && h && !l && (r.font = `${Y(e) * i}px sans-serif`, r.fillStyle = s, r.fillText(e.numbering.text, b - g, p));
|
|
257
|
+
let x = a.segments.reduce((e, t) => e + t.measuredWidth, 0), E = 0;
|
|
258
|
+
e.alignment === "right" || e.alignment === "end" ? E = y - (b - v) - x : e.alignment === "center" && (E = (y - (b - v) - x) / 2), b += E;
|
|
259
|
+
let D = 0;
|
|
247
260
|
if (C && (!u || w)) {
|
|
248
261
|
let e = 0;
|
|
249
262
|
for (let t = 0; t < a.segments.length; t++) {
|
|
@@ -251,57 +264,57 @@ function T(e, t, n = !1) {
|
|
|
251
264
|
if (t === a.segments.length - 1) break;
|
|
252
265
|
"text" in n && (e += T(n.text));
|
|
253
266
|
}
|
|
254
|
-
let t =
|
|
255
|
-
e > 0 && t > 0 && (
|
|
267
|
+
let t = y - (b - v) - x;
|
|
268
|
+
e > 0 && t > 0 && (D = t / e);
|
|
256
269
|
}
|
|
257
270
|
for (let e = 0; e < a.segments.length; e++) {
|
|
258
271
|
let n = a.segments[e], o = e === a.segments.length - 1;
|
|
259
272
|
if ("isTab" in n) {
|
|
260
|
-
|
|
273
|
+
b += n.measuredWidth;
|
|
261
274
|
continue;
|
|
262
275
|
}
|
|
263
276
|
if ("dataUrl" in n) {
|
|
264
|
-
l ||
|
|
277
|
+
l || j(r, n, b, p, i, t.images), b += n.measuredWidth;
|
|
265
278
|
continue;
|
|
266
279
|
}
|
|
267
280
|
let u = n;
|
|
268
281
|
if (!l) {
|
|
269
|
-
let e =
|
|
270
|
-
r.font =
|
|
282
|
+
let e = K(u, i), t = u.vertAlign === "super" ? -u.fontSize * i * .35 : u.vertAlign === "sub" ? u.fontSize * i * .15 : 0;
|
|
283
|
+
r.font = q(u.bold, u.italic, e, u.fontFamily), u.highlight && (r.fillStyle = c[u.highlight] ?? "#FFFF00", r.fillRect(b, p + t - e * .85, u.measuredWidth, e * 1.1)), r.fillStyle = u.color ? `#${u.color}` : s, r.fillText(u.text, b, p + t);
|
|
271
284
|
let n = u.color ? `#${u.color}` : s, a = Math.max(.5, e * .05), o = r.measureText(u.text).width;
|
|
272
285
|
if (u.underline) {
|
|
273
286
|
r.strokeStyle = n, r.lineWidth = a;
|
|
274
|
-
let i =
|
|
275
|
-
r.beginPath(), r.moveTo(
|
|
287
|
+
let i = p + t + e * .12;
|
|
288
|
+
r.beginPath(), r.moveTo(b, i), r.lineTo(b + o, i), r.stroke();
|
|
276
289
|
}
|
|
277
290
|
if (u.strikethrough) {
|
|
278
291
|
r.strokeStyle = n, r.lineWidth = a;
|
|
279
|
-
let i =
|
|
280
|
-
r.beginPath(), r.moveTo(
|
|
292
|
+
let i = p + t - e * .3;
|
|
293
|
+
r.beginPath(), r.moveTo(b, i), r.lineTo(b + o, i), r.stroke();
|
|
281
294
|
}
|
|
282
295
|
if (u.doubleStrikethrough) {
|
|
283
296
|
r.strokeStyle = n, r.lineWidth = a;
|
|
284
|
-
let i =
|
|
285
|
-
r.beginPath(), r.moveTo(
|
|
297
|
+
let i = p + t - e * .35, s = p + t - e * .22;
|
|
298
|
+
r.beginPath(), r.moveTo(b, i), r.lineTo(b + o, i), r.stroke(), r.beginPath(), r.moveTo(b, s), r.lineTo(b + o, s), r.stroke();
|
|
286
299
|
}
|
|
287
300
|
}
|
|
288
|
-
if (
|
|
301
|
+
if (b += u.measuredWidth, D > 0 && !o) {
|
|
289
302
|
let e = T(u.text);
|
|
290
|
-
e > 0 && (
|
|
303
|
+
e > 0 && (b += e * D);
|
|
291
304
|
}
|
|
292
305
|
}
|
|
293
306
|
t.y += d;
|
|
294
307
|
}
|
|
295
308
|
if (e.borders && !l) {
|
|
296
309
|
let n = t.y - d;
|
|
297
|
-
|
|
310
|
+
G(r, a + f, d, y, n, e.borders, i);
|
|
298
311
|
}
|
|
299
|
-
t.y += e.spaceAfter * i,
|
|
312
|
+
t.y += e.spaceAfter * i, M(e, t, u);
|
|
300
313
|
}
|
|
301
314
|
function E(e, t) {
|
|
302
315
|
let n = [], r = (e, t, r) => {
|
|
303
316
|
let i = t.allCaps || t.smallCaps ? e.toUpperCase() : e;
|
|
304
|
-
for (let e of
|
|
317
|
+
for (let e of k(i)) n.push({
|
|
305
318
|
text: e,
|
|
306
319
|
bold: t.bold,
|
|
307
320
|
italic: t.italic,
|
|
@@ -375,7 +388,7 @@ function ee(e) {
|
|
|
375
388
|
}
|
|
376
389
|
return !1;
|
|
377
390
|
}
|
|
378
|
-
function
|
|
391
|
+
function te(e, t, n) {
|
|
379
392
|
let r = [...t], i = 0, a = r.length;
|
|
380
393
|
for (; i < a;) {
|
|
381
394
|
let t = i + a + 1 >> 1;
|
|
@@ -383,7 +396,7 @@ function k(e, t, n) {
|
|
|
383
396
|
}
|
|
384
397
|
return r.slice(0, i).join("");
|
|
385
398
|
}
|
|
386
|
-
function
|
|
399
|
+
function k(e) {
|
|
387
400
|
let t = [], n = 0;
|
|
388
401
|
for (; n < e.length;) {
|
|
389
402
|
let r = n;
|
|
@@ -393,19 +406,19 @@ function A(e) {
|
|
|
393
406
|
}
|
|
394
407
|
return t.length ? t : [e];
|
|
395
408
|
}
|
|
396
|
-
function
|
|
397
|
-
let s = [], c = [], l = 0, u = 0, d = 0, f =
|
|
398
|
-
if (
|
|
409
|
+
function A(e, t, n, r, i, a = [], o) {
|
|
410
|
+
let s = [], c = [], l = 0, u = 0, d = 0, f = 0, p = !0, m = n, h = 0, g = o?.startPageY ?? 0, _ = () => {
|
|
411
|
+
if (h = 0, m = n, !o) return;
|
|
399
412
|
let e = 10 * i;
|
|
400
413
|
for (let t = 0; t < 16; t++) {
|
|
401
|
-
let t =
|
|
402
|
-
for (let e of o.floats) e.mode === "topAndBottom" && t > e.yTop &&
|
|
414
|
+
let t = g + e, n = null;
|
|
415
|
+
for (let e of o.floats) e.mode === "topAndBottom" && t > e.yTop && g < e.yBottom && (n = n === null ? e.yBottom : Math.max(n, e.yBottom));
|
|
403
416
|
if (n === null) break;
|
|
404
|
-
|
|
417
|
+
g = n;
|
|
405
418
|
}
|
|
406
|
-
let t = o.paraX, r = o.paraX + n, a = t, s = r, c =
|
|
419
|
+
let t = o.paraX, r = o.paraX + n, a = t, s = r, c = g + e;
|
|
407
420
|
for (let e of o.floats) {
|
|
408
|
-
if (e.mode !== "square" || c <= e.yTop ||
|
|
421
|
+
if (e.mode !== "square" || c <= e.yTop || g >= e.yBottom) continue;
|
|
409
422
|
let n = e.xLeft - t, i = r - e.xRight, o;
|
|
410
423
|
switch (e.side) {
|
|
411
424
|
case "left":
|
|
@@ -421,39 +434,40 @@ function j(e, t, n, r, i, a = [], o) {
|
|
|
421
434
|
o ? e.xLeft < s && (s = Math.max(a, e.xLeft)) : e.xRight > a && (a = Math.min(s, e.xRight));
|
|
422
435
|
}
|
|
423
436
|
let l = Math.max(0, s - a);
|
|
424
|
-
|
|
437
|
+
h = Math.max(0, a - t), m = Math.min(n - h, l), m < 0 && (m = 0);
|
|
425
438
|
};
|
|
426
|
-
|
|
427
|
-
let
|
|
428
|
-
let t = e === void 0 ? u || 10 : e;
|
|
439
|
+
_();
|
|
440
|
+
let v = () => m - (p ? r : 0), y = (e) => {
|
|
441
|
+
let t = e === void 0 ? u || 10 : e, n = d > 0 || f > 0, r = n ? d : t * i * .8, a = n ? f : t * i * .2;
|
|
429
442
|
s.push({
|
|
430
443
|
segments: c,
|
|
431
444
|
height: t,
|
|
432
|
-
ascent:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
445
|
+
ascent: r,
|
|
446
|
+
descent: a,
|
|
447
|
+
xOffset: h,
|
|
448
|
+
availWidth: m,
|
|
449
|
+
topY: o ? g : void 0
|
|
450
|
+
}), o && (g += o.lineBoxH(r, a)), c = [], l = 0, u = 0, d = 0, f = 0, p = !1, _();
|
|
451
|
+
}, b = (e, t, n, r, i) => {
|
|
452
|
+
c.push(e), l += t, n > u && (u = n), r > d && (d = r), i > f && (f = i);
|
|
453
|
+
}, x = (e) => K(e, i), S = (t) => (e.font = q(t.bold, t.italic, x(t), t.fontFamily), e.measureText(t.text)), C = [...t];
|
|
454
|
+
for (; C.length > 0;) {
|
|
455
|
+
let t = C.shift();
|
|
442
456
|
if ("lineBreak" in t) {
|
|
443
|
-
|
|
457
|
+
y(t.fontSize);
|
|
444
458
|
continue;
|
|
445
459
|
}
|
|
446
460
|
if ("isTab" in t) {
|
|
447
|
-
let e = l + (
|
|
461
|
+
let e = l + (p ? r : 0), n = a.find((t) => t.pos * i > e), o;
|
|
448
462
|
if (o = n ? n.pos * i - e : Math.ceil((e + .01) / (36 * i)) * (36 * i) - e, o <= 0) {
|
|
449
|
-
|
|
463
|
+
y(), C.unshift(t);
|
|
450
464
|
continue;
|
|
451
465
|
}
|
|
452
|
-
if (l + o >
|
|
453
|
-
|
|
466
|
+
if (l + o > v() && c.length > 0) {
|
|
467
|
+
y(), C.unshift(t);
|
|
454
468
|
continue;
|
|
455
469
|
}
|
|
456
|
-
t.measuredWidth = o,
|
|
470
|
+
t.measuredWidth = o, b(t, o, t.fontSize, t.fontSize * i * .8, t.fontSize * i * .2);
|
|
457
471
|
continue;
|
|
458
472
|
}
|
|
459
473
|
if ("dataUrl" in t) {
|
|
@@ -462,74 +476,74 @@ function j(e, t, n, r, i, a = [], o) {
|
|
|
462
476
|
continue;
|
|
463
477
|
}
|
|
464
478
|
let e = t.widthPt * i, n = t.heightPt, r = t.heightPt * i;
|
|
465
|
-
t.measuredWidth = e, c.length > 0 && l + e >
|
|
479
|
+
t.measuredWidth = e, c.length > 0 && l + e > v() && y(), b(t, e, n, r, 0);
|
|
466
480
|
continue;
|
|
467
481
|
}
|
|
468
|
-
let n = t, o =
|
|
469
|
-
if (l + s <=
|
|
482
|
+
let n = t, o = S(n), s = o.width, u = n.fontSize, d = o.fontBoundingBoxAscent ?? o.actualBoundingBoxAscent ?? n.fontSize * i * .8, f = o.fontBoundingBoxDescent ?? o.actualBoundingBoxDescent ?? n.fontSize * i * .2;
|
|
483
|
+
if (l + s <= v()) n.measuredWidth = s, b(n, s, u, d, f);
|
|
470
484
|
else if (ee(n.text)) {
|
|
471
|
-
let t =
|
|
472
|
-
e.font =
|
|
473
|
-
let r = t > 0 ?
|
|
485
|
+
let t = v() - l;
|
|
486
|
+
e.font = q(n.bold, n.italic, x(n), n.fontFamily);
|
|
487
|
+
let r = t > 0 ? te(e, n.text, t) : "";
|
|
474
488
|
if (r.length > 0) {
|
|
475
489
|
let t = e.measureText(r);
|
|
476
|
-
|
|
490
|
+
b({
|
|
477
491
|
...n,
|
|
478
492
|
text: r,
|
|
479
493
|
measuredWidth: t.width
|
|
480
|
-
}, t.width, u,
|
|
494
|
+
}, t.width, u, d, f);
|
|
481
495
|
let i = n.text.slice(r.length);
|
|
482
|
-
i &&
|
|
496
|
+
i && C.unshift({
|
|
483
497
|
...n,
|
|
484
498
|
text: i,
|
|
485
499
|
measuredWidth: 0
|
|
486
500
|
});
|
|
487
|
-
} else if (c.length > 0)
|
|
501
|
+
} else if (c.length > 0) y(), C.unshift(n);
|
|
488
502
|
else {
|
|
489
503
|
let t = [...n.text][0] ?? "";
|
|
490
504
|
if (t) {
|
|
491
505
|
let r = e.measureText(t);
|
|
492
|
-
|
|
506
|
+
b({
|
|
493
507
|
...n,
|
|
494
508
|
text: t,
|
|
495
509
|
measuredWidth: r.width
|
|
496
|
-
}, r.width, u,
|
|
510
|
+
}, r.width, u, d, f);
|
|
497
511
|
let i = n.text.slice(t.length);
|
|
498
|
-
i &&
|
|
512
|
+
i && C.unshift({
|
|
499
513
|
...n,
|
|
500
514
|
text: i,
|
|
501
515
|
measuredWidth: 0
|
|
502
516
|
});
|
|
503
517
|
}
|
|
504
518
|
}
|
|
505
|
-
} else c.length === 0 ? (n.measuredWidth = s,
|
|
519
|
+
} else c.length === 0 ? (n.measuredWidth = s, b(n, s, u, d, f)) : (y(), n.measuredWidth = s, b(n, s, u, d, f));
|
|
506
520
|
}
|
|
507
|
-
return c.length > 0 &&
|
|
521
|
+
return c.length > 0 && y(), s;
|
|
508
522
|
}
|
|
509
|
-
function
|
|
523
|
+
function j(e, t, n, r, i, a) {
|
|
510
524
|
if (t.anchor) return;
|
|
511
525
|
let o = a.get(u(t.dataUrl, t.colorReplaceFrom));
|
|
512
526
|
if (!o) return;
|
|
513
527
|
let s = t.widthPt * i, c = t.heightPt * i;
|
|
514
528
|
e.drawImage(o, n, r - c, s, c);
|
|
515
529
|
}
|
|
516
|
-
function
|
|
530
|
+
function M(e, t, n, r = "front") {
|
|
517
531
|
if (!t.dryRun) {
|
|
518
532
|
if (r === "behind") {
|
|
519
533
|
let r = e.runs.filter((e) => e.type === "shape" && !!e.behindDoc).slice().sort((e, t) => (e.zOrder ?? 0) - (t.zOrder ?? 0));
|
|
520
|
-
for (let e of r)
|
|
534
|
+
for (let e of r) N(e, t, n);
|
|
521
535
|
return;
|
|
522
536
|
}
|
|
523
537
|
for (let r of e.runs) {
|
|
524
538
|
if (r.type === "shape") {
|
|
525
539
|
let e = r;
|
|
526
540
|
if (e.behindDoc) continue;
|
|
527
|
-
|
|
541
|
+
N(e, t, n);
|
|
528
542
|
continue;
|
|
529
543
|
}
|
|
530
544
|
if (r.type !== "image") continue;
|
|
531
545
|
let e = r;
|
|
532
|
-
if (!e.anchor ||
|
|
546
|
+
if (!e.anchor || F(e.wrapMode)) continue;
|
|
533
547
|
let i = t.images.get(u(e.dataUrl, e.colorReplaceFrom));
|
|
534
548
|
if (!i) continue;
|
|
535
549
|
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;
|
|
@@ -537,15 +551,15 @@ function N(e, t, n, r = "front") {
|
|
|
537
551
|
}
|
|
538
552
|
}
|
|
539
553
|
}
|
|
540
|
-
function
|
|
554
|
+
function N(e, t, i) {
|
|
541
555
|
let { ctx: a, scale: o } = t, s = e.widthPt * o, c = e.heightPt * o;
|
|
542
556
|
if (s <= 0 || c <= 0) return;
|
|
543
557
|
let l = e.anchorXFromMargin ? (t.marginLeft + e.anchorXPt) * o : e.anchorXPt * o, u = e.anchorYFromPara ? i + e.anchorYPt * o : e.anchorYPt * o, d = e.rotation ?? 0;
|
|
544
558
|
a.save(), d !== 0 && (a.translate(l + s / 2, u + c / 2), a.rotate(d * Math.PI / 180), a.translate(-(l + s / 2), -(u + c / 2))), a.beginPath(), n(a, e.subpaths, l, u, s, c);
|
|
545
|
-
let f =
|
|
559
|
+
let f = P(e.fill, a, l, u, s, c);
|
|
546
560
|
f && (a.fillStyle = f, a.fill()), e.stroke && (e.strokeWidth ?? 0) > 0 && (a.strokeStyle = r(e.stroke), a.lineWidth = Math.max(.5, (e.strokeWidth ?? 0) * o), a.stroke()), a.restore();
|
|
547
561
|
}
|
|
548
|
-
function
|
|
562
|
+
function P(e, t, n, i, a, o) {
|
|
549
563
|
if (!e) return null;
|
|
550
564
|
if (e.fillType === "solid") return r(e.color);
|
|
551
565
|
if (e.fillType === "gradient") {
|
|
@@ -564,14 +578,14 @@ function F(e, t, n, i, a, o) {
|
|
|
564
578
|
}
|
|
565
579
|
return null;
|
|
566
580
|
}
|
|
567
|
-
function
|
|
581
|
+
function F(e) {
|
|
568
582
|
return e === "square" || e === "topAndBottom" || e === "tight" || e === "through";
|
|
569
583
|
}
|
|
570
|
-
function
|
|
584
|
+
function I(e, t, n) {
|
|
571
585
|
for (let r of e.runs) {
|
|
572
586
|
if (r.type !== "image") continue;
|
|
573
587
|
let e = r;
|
|
574
|
-
if (!e.anchor || !
|
|
588
|
+
if (!e.anchor || !F(e.wrapMode)) continue;
|
|
575
589
|
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, d = (e.distTop ?? 0) * a, f = (e.distBottom ?? 0) * a, p = (e.distLeft ?? 0) * a, m = (e.distRight ?? 0) * a, h = u(e.dataUrl, e.colorReplaceFrom), g = {
|
|
576
590
|
mode: i,
|
|
577
591
|
imageKey: h,
|
|
@@ -592,7 +606,7 @@ function L(e, t, n) {
|
|
|
592
606
|
}
|
|
593
607
|
}
|
|
594
608
|
}
|
|
595
|
-
function
|
|
609
|
+
function L(e, t) {
|
|
596
610
|
for (let n = 0; n < 16; n++) {
|
|
597
611
|
let n = e;
|
|
598
612
|
for (let r of t) r.mode === "topAndBottom" && e >= r.yTop && e < r.yBottom && (n = Math.max(n, r.yBottom));
|
|
@@ -601,10 +615,10 @@ function R(e, t) {
|
|
|
601
615
|
}
|
|
602
616
|
return e;
|
|
603
617
|
}
|
|
604
|
-
function
|
|
618
|
+
function R(e, t) {
|
|
605
619
|
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 = i, d = [];
|
|
606
620
|
for (let n of e.rows) {
|
|
607
|
-
let i =
|
|
621
|
+
let i = z(n, e, l, r, t);
|
|
608
622
|
d.push(i);
|
|
609
623
|
}
|
|
610
624
|
let f = t.y;
|
|
@@ -612,33 +626,37 @@ function z(e, t) {
|
|
|
612
626
|
let i = e.rows[n], a = d[n], s = u, c = 0;
|
|
613
627
|
for (let n of i.cells) {
|
|
614
628
|
let i = Math.min(n.colSpan, l.length - c), u = l.slice(c, c + i).reduce((e, t) => e + t, 0);
|
|
615
|
-
n.vMerge !== !1 && (o ?
|
|
629
|
+
n.vMerge !== !1 && (o ? V(n, e, u, r, t) : H(n, e, s, f, u, a, t)), s += u, c += i;
|
|
616
630
|
}
|
|
617
631
|
f += a;
|
|
618
632
|
}
|
|
619
633
|
t.y = f;
|
|
620
634
|
}
|
|
621
|
-
function
|
|
635
|
+
function z(e, t, n, r, i) {
|
|
622
636
|
if (e.rowHeight != null) return e.rowHeight * r;
|
|
623
637
|
let a = 10 * r, o = 0;
|
|
624
638
|
for (let s of e.cells) {
|
|
625
639
|
let e = Math.min(s.colSpan, n.length - o), c = n.slice(o, o + e).reduce((e, t) => e + t, 0) - (t.cellMarginLeft + t.cellMarginRight) * r, l = (t.cellMarginTop + t.cellMarginBottom) * r;
|
|
626
|
-
for (let e of s.content) l +=
|
|
640
|
+
for (let e of s.content) l += B(i, e, c, r), l += (e.spaceBefore + e.spaceAfter) * r;
|
|
627
641
|
l > a && (a = l), o += e;
|
|
628
642
|
}
|
|
629
643
|
return a;
|
|
630
644
|
}
|
|
631
|
-
function
|
|
645
|
+
function B(e, t, n, r) {
|
|
632
646
|
let i = E(t.runs, e);
|
|
633
|
-
|
|
647
|
+
if (i.length === 0) {
|
|
648
|
+
let { asc: e, desc: n } = Z(Y(t), r);
|
|
649
|
+
return X(t.lineSpacing, e, n, r);
|
|
650
|
+
}
|
|
651
|
+
return A(e.ctx, i, n, 0, r, t.tabStops).reduce((e, n) => e + X(t.lineSpacing, n.ascent, n.descent, r), 0);
|
|
634
652
|
}
|
|
635
|
-
function
|
|
653
|
+
function V(e, t, n, r, i) {
|
|
636
654
|
let a = t.cellMarginLeft * r, o = t.cellMarginRight * r, s = n - a - o;
|
|
637
|
-
for (let t of e.content)
|
|
655
|
+
for (let t of e.content) B(i, t, s, r);
|
|
638
656
|
}
|
|
639
|
-
function
|
|
657
|
+
function H(e, t, n, r, i, a, o) {
|
|
640
658
|
let { ctx: s, scale: c } = o;
|
|
641
|
-
e.background && (s.fillStyle = `#${e.background}`, s.fillRect(n, r, i, a)),
|
|
659
|
+
e.background && (s.fillStyle = `#${e.background}`, s.fillRect(n, r, i, a)), U(s, n, r, i, a, e.borders, t.borders, c);
|
|
642
660
|
let l = t.cellMarginTop * c, u = t.cellMarginBottom * c, d = t.cellMarginLeft * c, f = t.cellMarginRight * c, p = {
|
|
643
661
|
...o,
|
|
644
662
|
contentX: n + d,
|
|
@@ -646,21 +664,21 @@ function U(e, t, n, r, i, a, o) {
|
|
|
646
664
|
y: r + l
|
|
647
665
|
};
|
|
648
666
|
if (e.vAlign === "center" || e.vAlign === "bottom") {
|
|
649
|
-
let t = e.content.reduce((e, t) => e +
|
|
667
|
+
let t = e.content.reduce((e, t) => e + B(o, t, i - d - f, c) + (t.spaceBefore + t.spaceAfter) * c, 0);
|
|
650
668
|
e.vAlign === "center" ? p.y = r + (a - t) / 2 : p.y = r + a - t - u;
|
|
651
669
|
}
|
|
652
670
|
w(e.content, p);
|
|
653
671
|
}
|
|
654
|
-
function
|
|
672
|
+
function U(e, t, n, r, i, a, o, s) {
|
|
655
673
|
let c = a.top ?? o.top, l = a.bottom ?? o.bottom, u = a.left ?? o.left, d = a.right ?? o.right;
|
|
656
|
-
c && c.style !== "none" &&
|
|
674
|
+
c && c.style !== "none" && W(e, t, n, t + r, n, c, s), l && l.style !== "none" && W(e, t, n + i, t + r, n + i, l, s), u && u.style !== "none" && W(e, t, n, t, n + i, u, s), d && d.style !== "none" && W(e, t + r, n, t + r, n + i, d, s);
|
|
657
675
|
}
|
|
658
|
-
function
|
|
676
|
+
function W(e, t, n, r, i, a, o) {
|
|
659
677
|
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();
|
|
660
678
|
}
|
|
661
|
-
function
|
|
679
|
+
function G(e, t, n, r, i, a, o) {
|
|
662
680
|
let s = (t, n, r, i, a) => {
|
|
663
|
-
!t || t.style === "none" ||
|
|
681
|
+
!t || t.style === "none" || W(e, n, r, i, a, {
|
|
664
682
|
width: t.width,
|
|
665
683
|
color: t.color,
|
|
666
684
|
style: t.style
|
|
@@ -668,24 +686,31 @@ function K(e, t, n, r, i, a, o) {
|
|
|
668
686
|
}, c = (e) => (e?.space ?? 0) * o;
|
|
669
687
|
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);
|
|
670
688
|
}
|
|
671
|
-
function
|
|
689
|
+
function K(e, t) {
|
|
672
690
|
let n = e.fontSize * t;
|
|
673
691
|
return e.smallCaps && (n *= .8), e.vertAlign && (n *= .65), n;
|
|
674
692
|
}
|
|
675
|
-
function
|
|
676
|
-
return `${t ? "italic" : "normal"} ${e ? "bold" : "normal"} ${n}px ${
|
|
693
|
+
function q(e, t, n, r) {
|
|
694
|
+
return `${t ? "italic" : "normal"} ${e ? "bold" : "normal"} ${n}px ${J(r)}`;
|
|
677
695
|
}
|
|
678
|
-
function
|
|
696
|
+
function J(e) {
|
|
679
697
|
if (!e) return "\"Noto Sans JP\", \"Hiragino Sans\", \"Meiryo\", sans-serif";
|
|
680
698
|
let t = e.toLowerCase();
|
|
681
699
|
return t.includes("meiryo") || t.includes("メイリオ") ? "\"Meiryo UI\", \"Meiryo\", \"Noto Sans JP\", sans-serif" : t.includes("游") || t.includes("yu ") ? "\"Yu Gothic\", \"YuGothic\", \"Noto Sans JP\", sans-serif" : t.includes("ipa") ? "\"IPAexGothic\", \"Noto Sans JP\", sans-serif" : t.includes("segoe") ? "\"Segoe UI\", sans-serif" : `"${e}", sans-serif`;
|
|
682
700
|
}
|
|
683
|
-
function
|
|
701
|
+
function Y(e) {
|
|
684
702
|
for (let t of e.runs) if (t.type === "text" || t.type === "field") return t.fontSize;
|
|
685
703
|
return typeof e.defaultFontSize == "number" ? e.defaultFontSize : 10;
|
|
686
704
|
}
|
|
687
|
-
function
|
|
688
|
-
|
|
705
|
+
function X(e, t, n, r) {
|
|
706
|
+
let i = t + n;
|
|
707
|
+
return e ? e.rule === "auto" ? i * e.value : e.rule === "exact" ? e.value * r : e.rule === "atLeast" ? Math.max(i, e.value * r) : i : i;
|
|
708
|
+
}
|
|
709
|
+
function Z(e, t) {
|
|
710
|
+
return {
|
|
711
|
+
asc: e * t * .8,
|
|
712
|
+
desc: e * t * .2
|
|
713
|
+
};
|
|
689
714
|
}
|
|
690
715
|
//#endregion
|
|
691
716
|
//#region packages/docx/src/document.ts
|
|
@@ -775,10 +800,10 @@ var Q = class e {
|
|
|
775
800
|
_render() {
|
|
776
801
|
this._doc && this._doc.renderPage(this._canvas, this._currentPage, this._opts);
|
|
777
802
|
}
|
|
778
|
-
},
|
|
803
|
+
}, ne = /* @__PURE__ */ e({
|
|
779
804
|
DocxDocument: () => Q,
|
|
780
805
|
DocxViewer: () => $,
|
|
781
806
|
autoResize: () => t
|
|
782
807
|
});
|
|
783
808
|
//#endregion
|
|
784
|
-
export { $ as n, Q as r,
|
|
809
|
+
export { $ as n, Q as r, ne as t };
|
package/dist/docx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./autoResize-ggn4hzd8.cjs`),t=require(`./docx-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./autoResize-ggn4hzd8.cjs`),t=require(`./docx-CGvCIxpo.cjs`);exports.DocxDocument=t.r,exports.DocxViewer=t.n,exports.autoResize=e.t;
|
package/dist/docx.mjs
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./pptx-CYYMOWs4.cjs`),t=require(`./xlsx-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./pptx-CYYMOWs4.cjs`),t=require(`./xlsx-Cz9qI8c9.cjs`),n=require(`./docx-CGvCIxpo.cjs`);Object.defineProperty(exports,`docx`,{enumerable:!0,get:function(){return n.t}}),Object.defineProperty(exports,`pptx`,{enumerable:!0,get:function(){return e.t}}),Object.defineProperty(exports,`xlsx`,{enumerable:!0,get:function(){return t.t}});
|
package/dist/index.mjs
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -454,6 +454,8 @@ declare interface Fill_2 {
|
|
|
454
454
|
patternType: string;
|
|
455
455
|
fgColor: string | null;
|
|
456
456
|
bgColor: string | null;
|
|
457
|
+
/** Set when the style's `<fill>` was a `<gradientFill>`; patternType stays "none". */
|
|
458
|
+
gradient?: GradientFillSpec | null;
|
|
457
459
|
}
|
|
458
460
|
|
|
459
461
|
declare interface Font {
|
|
@@ -475,6 +477,22 @@ declare interface GradientFill {
|
|
|
475
477
|
gradType: string;
|
|
476
478
|
}
|
|
477
479
|
|
|
480
|
+
declare interface GradientFillSpec {
|
|
481
|
+
/** "linear" (default) or "path". */
|
|
482
|
+
gradientType: string;
|
|
483
|
+
/** Rotation in degrees for linear gradients (0 = left→right). */
|
|
484
|
+
degree: number;
|
|
485
|
+
/** Path-gradient bounding box (0..1) — unused for linear. */
|
|
486
|
+
left: number;
|
|
487
|
+
right: number;
|
|
488
|
+
top: number;
|
|
489
|
+
bottom: number;
|
|
490
|
+
stops: {
|
|
491
|
+
position: number;
|
|
492
|
+
color: string;
|
|
493
|
+
}[];
|
|
494
|
+
}
|
|
495
|
+
|
|
478
496
|
declare interface GradientStop {
|
|
479
497
|
position: number;
|
|
480
498
|
color: string;
|
|
@@ -1284,6 +1302,9 @@ declare interface Worksheet {
|
|
|
1284
1302
|
autoFilter?: CellRange | null;
|
|
1285
1303
|
/** Hyperlinks in this worksheet (ECMA-376 §18.3.1.47). */
|
|
1286
1304
|
hyperlinks?: Hyperlink[];
|
|
1305
|
+
/** A1-style cell refs of commented cells (ECMA-376 §18.7.3). Rendered as a
|
|
1306
|
+
* small red triangle in each cell's top-right corner. */
|
|
1307
|
+
commentRefs?: string[];
|
|
1287
1308
|
}
|
|
1288
1309
|
|
|
1289
1310
|
export declare namespace xlsx {
|