wordinweb 0.3.4 → 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.
@@ -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
- symbolmt: { asc: 1.005371, desc: 0.219727, gap: 0.04834 },
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((r) => r.cells.some((c) => c.props.width !== void 0));
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 (below.length !== 1 || above.length === 0) continue;
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);
@@ -43214,6 +43237,7 @@ function lowestOccurrenceRegion(a, b, aLo, aHi, bLo, bHi) {
43214
43237
  sawCommon = true;
43215
43238
  if (candidates.length > MAX_CHAIN2) continue;
43216
43239
  sawUsable = true;
43240
+ if (best !== void 0 && candidates.length > bestCost) continue;
43217
43241
  for (const i of candidates) {
43218
43242
  let aStart = i;
43219
43243
  let bStart = j;
@@ -43226,12 +43250,12 @@ function lowestOccurrenceRegion(a, b, aLo, aHi, bLo, bHi) {
43226
43250
  aEnd++;
43227
43251
  }
43228
43252
  const len = aEnd - aStart;
43229
- let cost = 0;
43253
+ let cost = candidates.length;
43230
43254
  for (let k = aStart; k < aEnd; k++) {
43231
- cost = Math.max(cost, positions.get(a[k])?.length ?? 0);
43255
+ cost = Math.min(cost, positions.get(a[k])?.length ?? cost);
43232
43256
  }
43233
43257
  const offset = Math.abs((aStart - aLo) / (aSpan || 1) - (bStart - bLo) / (bSpan || 1));
43234
- const better = cost < bestCost || cost === bestCost && best !== void 0 && len > best.len || cost === bestCost && best !== void 0 && len === best.len && offset < bestOffset;
43258
+ const better = best !== void 0 && (len > best.len || cost < bestCost || len === best.len && cost === bestCost && offset < bestOffset);
43235
43259
  if (best === void 0 || better) {
43236
43260
  best = { aStart, bStart, len };
43237
43261
  bestCost = cost;
@@ -55791,4 +55815,4 @@ export {
55791
55815
  cfb/cfb.js:
55792
55816
  (*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
55793
55817
  */
55794
- //# sourceMappingURL=chunk-PZIJZDQ7.js.map
55818
+ //# sourceMappingURL=chunk-QU3LB5BC.js.map