wordinweb 0.3.2 → 0.3.4

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.
@@ -16744,7 +16744,7 @@ var Engine = class {
16744
16744
  "hRel" in s && s.hRel === "char" ? charX : this.colX,
16745
16745
  "vRel" in s && s.vRel === "line" ? lineY : paraTop
16746
16746
  );
16747
- if ("wrap" in s && s.wrap && s.wrap !== "none" && !("behind" in s && s.behind)) reBreak = true;
16747
+ if ("wrap" in s && s.wrap && s.wrap !== "none") reBreak = true;
16748
16748
  }
16749
16749
  if (reBreak) broken = breakNow(paraTop);
16750
16750
  };
@@ -18444,7 +18444,7 @@ var Engine = class {
18444
18444
  autofit: shape.autofitHeight ? "resizeShape" : shape.shrinkText ? "shrinkText" : "none"
18445
18445
  };
18446
18446
  }
18447
- if (shape.wrap && shape.wrap !== "none" && (!shape.behind || page.physIndex === -1)) {
18447
+ if (shape.wrap && shape.wrap !== "none") {
18448
18448
  const d = shape.dist ?? { t: 0, b: 0, l: 0, r: 0 };
18449
18449
  const list = this.floats.get(page) ?? [];
18450
18450
  list.push({
@@ -20474,7 +20474,8 @@ function distributePctColumns(grid, tableWidth, margins) {
20474
20474
  }
20475
20475
  function resolveGrid(tbl, available, overflowAllowed = false, cellMargins = 0, pctBoxAddsMargins = false) {
20476
20476
  const fixedOverflow = overflowAllowed && tbl.props.layout === "fixed";
20477
- const cap = fixedOverflow ? Number.POSITIVE_INFINITY : available;
20477
+ const pctOverflow = overflowAllowed && (tbl.props.widthPct ?? 0) > 1;
20478
+ const cap = fixedOverflow || pctOverflow ? Number.POSITIVE_INFINITY : available;
20478
20479
  const pctBase = fixedOverflow && pctBoxAddsMargins ? available + cellMargins : available;
20479
20480
  const target = Math.min(
20480
20481
  cap,
@@ -21730,12 +21731,16 @@ function renderToDom(doc, layout, container, options = {}, prev) {
21730
21731
  }
21731
21732
  return handle;
21732
21733
  }
21733
- function buildPrintHtml(root, pageWidthPx, pageHeightPx) {
21734
- const head = [`<base href="${document.location.href}">`];
21735
- for (const node of Array.from(document.head.querySelectorAll("style, link[rel=stylesheet]"))) {
21736
- head.push(node.outerHTML);
21737
- }
21738
- head.push(`<style>
21734
+ var pendingPaints = /* @__PURE__ */ new Set();
21735
+ function trackPaint(work) {
21736
+ pendingPaints.add(work);
21737
+ void work.finally(() => pendingPaints.delete(work));
21738
+ }
21739
+ async function paintsSettled() {
21740
+ while (pendingPaints.size > 0) await Promise.allSettled([...pendingPaints]);
21741
+ }
21742
+ function printStylesheet(pageWidthPx, pageHeightPx) {
21743
+ return `
21739
21744
  @page { size: ${pageWidthPx / 96}in ${pageHeightPx / 96}in; margin: 0; }
21740
21745
  html, body { margin: 0; padding: 0; }
21741
21746
  .dxw-pages { display: block !important; padding: 0 !important; gap: 0 !important; }
@@ -21745,7 +21750,14 @@ function buildPrintHtml(root, pageWidthPx, pageHeightPx) {
21745
21750
  }
21746
21751
  .dxw-page { box-shadow: none !important; margin: 0 !important; break-after: page; }
21747
21752
  .dxw-comment-card, .dxw-hf-marker { display: none !important; }
21748
- </style>`);
21753
+ `;
21754
+ }
21755
+ function buildPrintHtml(root, pageWidthPx, pageHeightPx) {
21756
+ const head = [`<base href="${document.location.href}">`];
21757
+ for (const node of Array.from(document.head.querySelectorAll("style, link[rel=stylesheet]"))) {
21758
+ head.push(node.outerHTML);
21759
+ }
21760
+ head.push(`<style>${printStylesheet(pageWidthPx, pageHeightPx)}</style>`);
21749
21761
  return `<!doctype html><html><head>${head.join("")}</head><body>${root.outerHTML}</body></html>`;
21750
21762
  }
21751
21763
  function printPages(root, pageWidthPx, pageHeightPx) {
@@ -22904,13 +22916,13 @@ function renderItem(doc, item2, urls, interactive) {
22904
22916
  if (cachedWmf) {
22905
22917
  decoded = cachedWmf;
22906
22918
  } else {
22907
- void import("./wmf-53LMIKNI.js").then(({ renderWmf }) => {
22919
+ trackPaint(import("./wmf-53LMIKNI.js").then(({ renderWmf }) => {
22908
22920
  const url = renderWmf(bytes, item2.width, item2.height);
22909
22921
  if (url) {
22910
22922
  setDocDerivedSrc(doc, wmfKey, url);
22911
22923
  img.src = url;
22912
22924
  }
22913
- });
22925
+ }));
22914
22926
  }
22915
22927
  } else if (ext === "emf") {
22916
22928
  const emfKey = `emf:${item2.part}`;
@@ -22919,12 +22931,12 @@ function renderItem(doc, item2, urls, interactive) {
22919
22931
  decoded = cachedEmf;
22920
22932
  } else {
22921
22933
  const buf = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
22922
- void import("emf-converter").then(({ convertEmfToDataUrl }) => convertEmfToDataUrl(buf)).then((url) => {
22934
+ trackPaint(import("emf-converter").then(({ convertEmfToDataUrl }) => convertEmfToDataUrl(buf)).then((url) => {
22923
22935
  if (url) {
22924
22936
  setDocDerivedSrc(doc, emfKey, url);
22925
22937
  img.src = url;
22926
22938
  }
22927
- });
22939
+ }));
22928
22940
  }
22929
22941
  }
22930
22942
  if (decoded) {
@@ -45317,6 +45329,21 @@ function setChartData(doc, drawing, input) {
45317
45329
  return true;
45318
45330
  }
45319
45331
 
45332
+ // ../core/src/render/print.ts
45333
+ async function renderForPrint(bytes, container) {
45334
+ await document.fonts.ready;
45335
+ const doc = DocxDocument.load(bytes);
45336
+ const layout = layoutDocument(doc);
45337
+ renderToDom(doc, layout, container, { zoom: 1, pageGap: 0, pageShadow: false, comments: false });
45338
+ const first = layout.pages[0];
45339
+ const style = document.createElement("style");
45340
+ style.textContent = printStylesheet(first?.width ?? 816, first?.height ?? 1056);
45341
+ document.head.append(style);
45342
+ await paintsSettled();
45343
+ await Promise.all(Array.from(container.querySelectorAll("img"), (img) => img.decode().catch(() => void 0)));
45344
+ return { pageCount: layout.pages.length };
45345
+ }
45346
+
45320
45347
  // ../core/src/render/fonts.ts
45321
45348
  var GENERIC = /* @__PURE__ */ new Set([
45322
45349
  "serif",
@@ -55745,6 +55772,7 @@ export {
55745
55772
  removeLink,
55746
55773
  insertChartAt,
55747
55774
  setChartData,
55775
+ renderForPrint,
55748
55776
  compareWithFile,
55749
55777
  pickDocx,
55750
55778
  downloadDocx,
@@ -55763,4 +55791,4 @@ export {
55763
55791
  cfb/cfb.js:
55764
55792
  (*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
55765
55793
  */
55766
- //# sourceMappingURL=chunk-D6MZHDCC.js.map
55794
+ //# sourceMappingURL=chunk-PZIJZDQ7.js.map