@wordinweb/agent 0.2.2 → 0.2.3

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.
@@ -4618,6 +4618,10 @@ function parseCell(tc, ctx) {
4618
4618
  if (tcW && attr(tcW, "type") === "dxa") {
4619
4619
  const w = intAttr(tcW, "w");
4620
4620
  if (w) props.width = twipsToPx(w);
4621
+ } else if (tcW && attr(tcW, "type") === "pct") {
4622
+ const raw = attr(tcW, "w");
4623
+ const num = raw !== void 0 ? parseFloat(raw) : NaN;
4624
+ if (Number.isFinite(num) && num > 0) props.widthPct = raw.trim().endsWith("%") ? num / 100 : num / 5e3;
4621
4625
  } else if (tcW && attr(tcW, "type") === "auto") {
4622
4626
  props.widthAuto = true;
4623
4627
  }
@@ -8778,7 +8782,11 @@ var WORD_FONT_METRICS = {
8778
8782
  // lineGap 99 / upem 2048 = 1.2734em (14.0pt at 11pt - phase23's sub-bullet
8779
8783
  // lists run 14.0pt/line among 13.5pt Calibri text).
8780
8784
  symbol: { asc: 1.005371, desc: 0.219727, gap: 0.04834 },
8781
- symbolmt: { asc: 1.005371, desc: 0.219727, gap: 0.04834 },
8785
+ // A Symbol bullet LABEL (the engine's metrics face) sizes its line without
8786
+ // the lineGap: Word runs an 11pt bullet at 13.5pt among 11pt Times New
8787
+ // Roman (wild-termsheet-behinddoc) and a 10pt one at 12.25pt, both
8788
+ // asc + desc; with the gap they would be 14.0pt and 12.75pt.
8789
+ symbolmt: { asc: 1.005371, desc: 0.219727, gap: 0 },
8782
8790
  "pingfang sc": { asc: 2.27, desc: 0.7627, gap: 0 },
8783
8791
  "songti sc": { asc: 2.27, desc: 0.7627, gap: 0 },
8784
8792
  "heiti sc": { asc: 2.27, desc: 0.7627, gap: 0 },
@@ -8805,13 +8813,19 @@ function quantizeQuarterPt(px2) {
8805
8813
  return Math.round(px2 / QUARTER_PT_PX) * QUARTER_PT_PX;
8806
8814
  }
8807
8815
  var FACE_SUFFIX = /\s+(bold italic|italic bold|bold|italic)$/i;
8816
+ var WORD_REPLACES = {
8817
+ "liberation serif": "Times New Roman",
8818
+ "liberation sans": "Arial",
8819
+ "liberation mono": "Courier New"
8820
+ };
8808
8821
  function normalizeFamily(family, bold, italic) {
8809
8822
  if (family === "\u5B8B\u4F53") family = "SimSun";
8823
+ const replaced = (f) => WORD_REPLACES[f.toLowerCase()] ?? f;
8810
8824
  const m = FACE_SUFFIX.exec(family);
8811
- if (!m) return { family, bold, italic };
8825
+ if (!m) return { family: replaced(family), bold, italic };
8812
8826
  const suffix = m[1].toLowerCase();
8813
8827
  return {
8814
- family: family.slice(0, m.index).trim() || family,
8828
+ family: replaced(family.slice(0, m.index).trim() || family),
8815
8829
  bold: bold || suffix.includes("bold"),
8816
8830
  italic: italic || suffix.includes("italic")
8817
8831
  };
@@ -16832,7 +16846,9 @@ var Engine = class {
16832
16846
  if (tbl.props.layout === "fixed") return base;
16833
16847
  const gridTotal = tbl.grid.reduce((a, b) => a + b, 0);
16834
16848
  const target = base.reduce((a, b) => a + b, 0);
16835
- const cellsDeclareWidths = tbl.rows.some((r) => r.cells.some((c) => c.props.width !== void 0));
16849
+ const cellsDeclareWidths = tbl.rows.some(
16850
+ (r) => r.cells.some((c) => c.props.width !== void 0 || c.props.widthPct !== void 0)
16851
+ );
16836
16852
  const containsHyperlink = tbl.rows.some(
16837
16853
  (row) => row.cells.some(
16838
16854
  (cell) => cell.blocks.some(
@@ -17991,7 +18007,14 @@ var Engine = class {
17991
18007
  if (boundaryPara === void 0) continue;
17992
18008
  const above = keptTops.filter((t) => paraOfTop(part.keep, t) === boundaryPara);
17993
18009
  const below = restTops.filter((t) => paraOfTop(part.rest, t) === boundaryPara);
17994
- if (below.length !== 1 || above.length === 0) continue;
18010
+ if (above.length === 0) continue;
18011
+ if (above.length === 1 && below.length > 1) {
18012
+ const moved2 = part.keep.filter((it) => topOf(it) >= above[0] - 0.01);
18013
+ part.keep = part.keep.filter((it) => topOf(it) < above[0] - 0.01);
18014
+ part.rest = [...moved2, ...part.rest];
18015
+ continue;
18016
+ }
18017
+ if (below.length !== 1) continue;
17995
18018
  const moveTop = above.length >= 3 ? above[above.length - 1] : above[0];
17996
18019
  const moved = part.keep.filter((it) => topOf(it) >= moveTop - 0.01);
17997
18020
  part.keep = part.keep.filter((it) => topOf(it) < moveTop - 0.01);
@@ -45395,4 +45418,4 @@ export {
45395
45418
  AgentDocument,
45396
45419
  collaborativeAgentTarget
45397
45420
  };
45398
- //# sourceMappingURL=chunk-ATE5QKBU.js.map
45421
+ //# sourceMappingURL=chunk-RQ74KQML.js.map