wordinweb 0.3.3 → 0.3.5
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/{chunk-5SLXOYCF.js → chunk-QU3LB5BC.js} +71 -20
- package/dist/chunk-QU3LB5BC.js.map +1 -0
- package/dist/collab.d.ts +2 -2
- package/dist/collab.js +1 -1
- package/dist/{index-BvwqvUF5.d.ts → index-BunX2duN.d.ts} +13 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-5SLXOYCF.js.map +0 -1
|
@@ -6355,6 +6355,10 @@ function parseCell(tc, ctx) {
|
|
|
6355
6355
|
if (tcW && attr(tcW, "type") === "dxa") {
|
|
6356
6356
|
const w = intAttr(tcW, "w");
|
|
6357
6357
|
if (w) props.width = twipsToPx(w);
|
|
6358
|
+
} else if (tcW && attr(tcW, "type") === "pct") {
|
|
6359
|
+
const raw = attr(tcW, "w");
|
|
6360
|
+
const num = raw !== void 0 ? parseFloat(raw) : NaN;
|
|
6361
|
+
if (Number.isFinite(num) && num > 0) props.widthPct = raw.trim().endsWith("%") ? num / 100 : num / 5e3;
|
|
6358
6362
|
} else if (tcW && attr(tcW, "type") === "auto") {
|
|
6359
6363
|
props.widthAuto = true;
|
|
6360
6364
|
}
|
|
@@ -10556,7 +10560,11 @@ var WORD_FONT_METRICS = {
|
|
|
10556
10560
|
// lineGap 99 / upem 2048 = 1.2734em (14.0pt at 11pt - phase23's sub-bullet
|
|
10557
10561
|
// lists run 14.0pt/line among 13.5pt Calibri text).
|
|
10558
10562
|
symbol: { asc: 1.005371, desc: 0.219727, gap: 0.04834 },
|
|
10559
|
-
|
|
10563
|
+
// A Symbol bullet LABEL (the engine's metrics face) sizes its line without
|
|
10564
|
+
// the lineGap: Word runs an 11pt bullet at 13.5pt among 11pt Times New
|
|
10565
|
+
// Roman (wild-termsheet-behinddoc) and a 10pt one at 12.25pt, both
|
|
10566
|
+
// asc + desc; with the gap they would be 14.0pt and 12.75pt.
|
|
10567
|
+
symbolmt: { asc: 1.005371, desc: 0.219727, gap: 0 },
|
|
10560
10568
|
"pingfang sc": { asc: 2.27, desc: 0.7627, gap: 0 },
|
|
10561
10569
|
"songti sc": { asc: 2.27, desc: 0.7627, gap: 0 },
|
|
10562
10570
|
"heiti sc": { asc: 2.27, desc: 0.7627, gap: 0 },
|
|
@@ -10583,13 +10591,19 @@ function quantizeQuarterPt(px) {
|
|
|
10583
10591
|
return Math.round(px / QUARTER_PT_PX) * QUARTER_PT_PX;
|
|
10584
10592
|
}
|
|
10585
10593
|
var FACE_SUFFIX = /\s+(bold italic|italic bold|bold|italic)$/i;
|
|
10594
|
+
var WORD_REPLACES = {
|
|
10595
|
+
"liberation serif": "Times New Roman",
|
|
10596
|
+
"liberation sans": "Arial",
|
|
10597
|
+
"liberation mono": "Courier New"
|
|
10598
|
+
};
|
|
10586
10599
|
function normalizeFamily(family, bold, italic) {
|
|
10587
10600
|
if (family === "\u5B8B\u4F53") family = "SimSun";
|
|
10601
|
+
const replaced = (f) => WORD_REPLACES[f.toLowerCase()] ?? f;
|
|
10588
10602
|
const m = FACE_SUFFIX.exec(family);
|
|
10589
|
-
if (!m) return { family, bold, italic };
|
|
10603
|
+
if (!m) return { family: replaced(family), bold, italic };
|
|
10590
10604
|
const suffix = m[1].toLowerCase();
|
|
10591
10605
|
return {
|
|
10592
|
-
family: family.slice(0, m.index).trim() || family,
|
|
10606
|
+
family: replaced(family.slice(0, m.index).trim() || family),
|
|
10593
10607
|
bold: bold || suffix.includes("bold"),
|
|
10594
10608
|
italic: italic || suffix.includes("italic")
|
|
10595
10609
|
};
|
|
@@ -18641,7 +18655,9 @@ var Engine = class {
|
|
|
18641
18655
|
if (tbl.props.layout === "fixed") return base;
|
|
18642
18656
|
const gridTotal = tbl.grid.reduce((a, b) => a + b, 0);
|
|
18643
18657
|
const target = base.reduce((a, b) => a + b, 0);
|
|
18644
|
-
const cellsDeclareWidths = tbl.rows.some(
|
|
18658
|
+
const cellsDeclareWidths = tbl.rows.some(
|
|
18659
|
+
(r) => r.cells.some((c) => c.props.width !== void 0 || c.props.widthPct !== void 0)
|
|
18660
|
+
);
|
|
18645
18661
|
const containsHyperlink = tbl.rows.some(
|
|
18646
18662
|
(row) => row.cells.some(
|
|
18647
18663
|
(cell) => cell.blocks.some(
|
|
@@ -19800,7 +19816,14 @@ var Engine = class {
|
|
|
19800
19816
|
if (boundaryPara === void 0) continue;
|
|
19801
19817
|
const above = keptTops.filter((t) => paraOfTop(part.keep, t) === boundaryPara);
|
|
19802
19818
|
const below = restTops.filter((t) => paraOfTop(part.rest, t) === boundaryPara);
|
|
19803
|
-
if (
|
|
19819
|
+
if (above.length === 0) continue;
|
|
19820
|
+
if (above.length === 1 && below.length > 1) {
|
|
19821
|
+
const moved2 = part.keep.filter((it) => topOf(it) >= above[0] - 0.01);
|
|
19822
|
+
part.keep = part.keep.filter((it) => topOf(it) < above[0] - 0.01);
|
|
19823
|
+
part.rest = [...moved2, ...part.rest];
|
|
19824
|
+
continue;
|
|
19825
|
+
}
|
|
19826
|
+
if (below.length !== 1) continue;
|
|
19804
19827
|
const moveTop = above.length >= 3 ? above[above.length - 1] : above[0];
|
|
19805
19828
|
const moved = part.keep.filter((it) => topOf(it) >= moveTop - 0.01);
|
|
19806
19829
|
part.keep = part.keep.filter((it) => topOf(it) < moveTop - 0.01);
|
|
@@ -21731,12 +21754,16 @@ function renderToDom(doc, layout, container, options = {}, prev) {
|
|
|
21731
21754
|
}
|
|
21732
21755
|
return handle;
|
|
21733
21756
|
}
|
|
21734
|
-
|
|
21735
|
-
|
|
21736
|
-
|
|
21737
|
-
|
|
21738
|
-
|
|
21739
|
-
|
|
21757
|
+
var pendingPaints = /* @__PURE__ */ new Set();
|
|
21758
|
+
function trackPaint(work) {
|
|
21759
|
+
pendingPaints.add(work);
|
|
21760
|
+
void work.finally(() => pendingPaints.delete(work));
|
|
21761
|
+
}
|
|
21762
|
+
async function paintsSettled() {
|
|
21763
|
+
while (pendingPaints.size > 0) await Promise.allSettled([...pendingPaints]);
|
|
21764
|
+
}
|
|
21765
|
+
function printStylesheet(pageWidthPx, pageHeightPx) {
|
|
21766
|
+
return `
|
|
21740
21767
|
@page { size: ${pageWidthPx / 96}in ${pageHeightPx / 96}in; margin: 0; }
|
|
21741
21768
|
html, body { margin: 0; padding: 0; }
|
|
21742
21769
|
.dxw-pages { display: block !important; padding: 0 !important; gap: 0 !important; }
|
|
@@ -21746,7 +21773,14 @@ function buildPrintHtml(root, pageWidthPx, pageHeightPx) {
|
|
|
21746
21773
|
}
|
|
21747
21774
|
.dxw-page { box-shadow: none !important; margin: 0 !important; break-after: page; }
|
|
21748
21775
|
.dxw-comment-card, .dxw-hf-marker { display: none !important; }
|
|
21749
|
-
|
|
21776
|
+
`;
|
|
21777
|
+
}
|
|
21778
|
+
function buildPrintHtml(root, pageWidthPx, pageHeightPx) {
|
|
21779
|
+
const head = [`<base href="${document.location.href}">`];
|
|
21780
|
+
for (const node of Array.from(document.head.querySelectorAll("style, link[rel=stylesheet]"))) {
|
|
21781
|
+
head.push(node.outerHTML);
|
|
21782
|
+
}
|
|
21783
|
+
head.push(`<style>${printStylesheet(pageWidthPx, pageHeightPx)}</style>`);
|
|
21750
21784
|
return `<!doctype html><html><head>${head.join("")}</head><body>${root.outerHTML}</body></html>`;
|
|
21751
21785
|
}
|
|
21752
21786
|
function printPages(root, pageWidthPx, pageHeightPx) {
|
|
@@ -22905,13 +22939,13 @@ function renderItem(doc, item2, urls, interactive) {
|
|
|
22905
22939
|
if (cachedWmf) {
|
|
22906
22940
|
decoded = cachedWmf;
|
|
22907
22941
|
} else {
|
|
22908
|
-
|
|
22942
|
+
trackPaint(import("./wmf-53LMIKNI.js").then(({ renderWmf }) => {
|
|
22909
22943
|
const url = renderWmf(bytes, item2.width, item2.height);
|
|
22910
22944
|
if (url) {
|
|
22911
22945
|
setDocDerivedSrc(doc, wmfKey, url);
|
|
22912
22946
|
img.src = url;
|
|
22913
22947
|
}
|
|
22914
|
-
});
|
|
22948
|
+
}));
|
|
22915
22949
|
}
|
|
22916
22950
|
} else if (ext === "emf") {
|
|
22917
22951
|
const emfKey = `emf:${item2.part}`;
|
|
@@ -22920,12 +22954,12 @@ function renderItem(doc, item2, urls, interactive) {
|
|
|
22920
22954
|
decoded = cachedEmf;
|
|
22921
22955
|
} else {
|
|
22922
22956
|
const buf = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
22923
|
-
|
|
22957
|
+
trackPaint(import("emf-converter").then(({ convertEmfToDataUrl }) => convertEmfToDataUrl(buf)).then((url) => {
|
|
22924
22958
|
if (url) {
|
|
22925
22959
|
setDocDerivedSrc(doc, emfKey, url);
|
|
22926
22960
|
img.src = url;
|
|
22927
22961
|
}
|
|
22928
|
-
});
|
|
22962
|
+
}));
|
|
22929
22963
|
}
|
|
22930
22964
|
}
|
|
22931
22965
|
if (decoded) {
|
|
@@ -43203,6 +43237,7 @@ function lowestOccurrenceRegion(a, b, aLo, aHi, bLo, bHi) {
|
|
|
43203
43237
|
sawCommon = true;
|
|
43204
43238
|
if (candidates.length > MAX_CHAIN2) continue;
|
|
43205
43239
|
sawUsable = true;
|
|
43240
|
+
if (best !== void 0 && candidates.length > bestCost) continue;
|
|
43206
43241
|
for (const i of candidates) {
|
|
43207
43242
|
let aStart = i;
|
|
43208
43243
|
let bStart = j;
|
|
@@ -43215,12 +43250,12 @@ function lowestOccurrenceRegion(a, b, aLo, aHi, bLo, bHi) {
|
|
|
43215
43250
|
aEnd++;
|
|
43216
43251
|
}
|
|
43217
43252
|
const len = aEnd - aStart;
|
|
43218
|
-
let cost =
|
|
43253
|
+
let cost = candidates.length;
|
|
43219
43254
|
for (let k = aStart; k < aEnd; k++) {
|
|
43220
|
-
cost = Math.
|
|
43255
|
+
cost = Math.min(cost, positions.get(a[k])?.length ?? cost);
|
|
43221
43256
|
}
|
|
43222
43257
|
const offset = Math.abs((aStart - aLo) / (aSpan || 1) - (bStart - bLo) / (bSpan || 1));
|
|
43223
|
-
const better =
|
|
43258
|
+
const better = best !== void 0 && (len > best.len || cost < bestCost || len === best.len && cost === bestCost && offset < bestOffset);
|
|
43224
43259
|
if (best === void 0 || better) {
|
|
43225
43260
|
best = { aStart, bStart, len };
|
|
43226
43261
|
bestCost = cost;
|
|
@@ -45318,6 +45353,21 @@ function setChartData(doc, drawing, input) {
|
|
|
45318
45353
|
return true;
|
|
45319
45354
|
}
|
|
45320
45355
|
|
|
45356
|
+
// ../core/src/render/print.ts
|
|
45357
|
+
async function renderForPrint(bytes, container) {
|
|
45358
|
+
await document.fonts.ready;
|
|
45359
|
+
const doc = DocxDocument.load(bytes);
|
|
45360
|
+
const layout = layoutDocument(doc);
|
|
45361
|
+
renderToDom(doc, layout, container, { zoom: 1, pageGap: 0, pageShadow: false, comments: false });
|
|
45362
|
+
const first = layout.pages[0];
|
|
45363
|
+
const style = document.createElement("style");
|
|
45364
|
+
style.textContent = printStylesheet(first?.width ?? 816, first?.height ?? 1056);
|
|
45365
|
+
document.head.append(style);
|
|
45366
|
+
await paintsSettled();
|
|
45367
|
+
await Promise.all(Array.from(container.querySelectorAll("img"), (img) => img.decode().catch(() => void 0)));
|
|
45368
|
+
return { pageCount: layout.pages.length };
|
|
45369
|
+
}
|
|
45370
|
+
|
|
45321
45371
|
// ../core/src/render/fonts.ts
|
|
45322
45372
|
var GENERIC = /* @__PURE__ */ new Set([
|
|
45323
45373
|
"serif",
|
|
@@ -55746,6 +55796,7 @@ export {
|
|
|
55746
55796
|
removeLink,
|
|
55747
55797
|
insertChartAt,
|
|
55748
55798
|
setChartData,
|
|
55799
|
+
renderForPrint,
|
|
55749
55800
|
compareWithFile,
|
|
55750
55801
|
pickDocx,
|
|
55751
55802
|
downloadDocx,
|
|
@@ -55764,4 +55815,4 @@ export {
|
|
|
55764
55815
|
cfb/cfb.js:
|
|
55765
55816
|
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
|
|
55766
55817
|
*/
|
|
55767
|
-
//# sourceMappingURL=chunk-
|
|
55818
|
+
//# sourceMappingURL=chunk-QU3LB5BC.js.map
|