@harbour-enterprises/superdoc 1.0.0-beta.95 → 1.0.0-beta.97

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.
Files changed (27) hide show
  1. package/dist/chunks/{PdfViewer-DC5ZtOHL.es.js → PdfViewer-BHcBfUWj.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer--l9mxuw6.cjs → PdfViewer-YvkZg201.cjs} +1 -1
  3. package/dist/chunks/{index-DA6_gKCn.cjs → index-DZ_AI-HW.cjs} +3 -3
  4. package/dist/chunks/{index-D_AIVJix.es.js → index-DeQfFbTb.es.js} +3 -3
  5. package/dist/chunks/{index-DJD7xO_i-CVT8OSh8.cjs → index-Pvlqsxge-IH3eauKE.cjs} +1 -1
  6. package/dist/chunks/{index-DJD7xO_i-DlZGZmeW.es.js → index-Pvlqsxge-vW641SZt.es.js} +1 -1
  7. package/dist/chunks/{super-editor.es-DLfNMkAR.cjs → super-editor.es-BP3PKkwh.cjs} +244 -91
  8. package/dist/chunks/{super-editor.es-L0F8-awY.es.js → super-editor.es-BinyZw4F.es.js} +244 -91
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-CAiO-oW4.js → converter-BEVM5t3i.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-DRP7HhmI.js → docx-zipper-vETk3IMG.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-D5oQ83xJ.js → editor-B8k1bwD_.js} +245 -92
  13. package/dist/super-editor/chunks/{index-DJD7xO_i.js → index-Pvlqsxge.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-ax2sbcF_.js → toolbar-j1GSUGWU.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +254 -101
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -42421,7 +42421,7 @@ const _SuperConverter = class _SuperConverter2 {
42421
42421
  static getStoredSuperdocVersion(docx) {
42422
42422
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42423
42423
  }
42424
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.95") {
42424
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.97") {
42425
42425
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42426
42426
  }
42427
42427
  /**
@@ -59639,7 +59639,7 @@ const isHeadless = (editor) => {
59639
59639
  const shouldSkipNodeView = (editor) => {
59640
59640
  return isHeadless(editor);
59641
59641
  };
59642
- const summaryVersion = "1.0.0-beta.95";
59642
+ const summaryVersion = "1.0.0-beta.97";
59643
59643
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59644
59644
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59645
59645
  function mapAttributes(attrs) {
@@ -60428,7 +60428,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60428
60428
  { default: remarkStringify },
60429
60429
  { default: remarkGfm }
60430
60430
  ] = await Promise.all([
60431
- Promise.resolve().then(() => require("./index-DJD7xO_i-CVT8OSh8.cjs")),
60431
+ Promise.resolve().then(() => require("./index-Pvlqsxge-IH3eauKE.cjs")),
60432
60432
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
60433
60433
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
60434
60434
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -60633,7 +60633,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60633
60633
  * Process collaboration migrations
60634
60634
  */
60635
60635
  processCollaborationMigrations() {
60636
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.95");
60636
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.97");
60637
60637
  if (!this.options.ydoc) return;
60638
60638
  const metaMap = this.options.ydoc.getMap("meta");
60639
60639
  let docVersion = metaMap.get("version");
@@ -62957,12 +62957,12 @@ var SectionType = /* @__PURE__ */ ((SectionType2) => {
62957
62957
  })(SectionType || {});
62958
62958
  const DEFAULT_PARAGRAPH_SECTION_TYPE = "nextPage";
62959
62959
  const DEFAULT_BODY_SECTION_TYPE = "continuous";
62960
- const TWIPS_PER_INCH$3 = 1440;
62961
- const PX_PER_INCH$2 = 96;
62960
+ const TWIPS_PER_INCH$4 = 1440;
62961
+ const PX_PER_INCH$3 = 96;
62962
62962
  const DEFAULT_COLUMN_GAP_INCHES = 0.5;
62963
62963
  function twipsToPixels$1(twips) {
62964
62964
  const n = Number(twips);
62965
- return Number.isFinite(n) ? n / TWIPS_PER_INCH$3 * PX_PER_INCH$2 : void 0;
62965
+ return Number.isFinite(n) ? n / TWIPS_PER_INCH$4 * PX_PER_INCH$3 : void 0;
62966
62966
  }
62967
62967
  function parseColumnCount(rawValue) {
62968
62968
  if (rawValue == null) return 1;
@@ -62972,7 +62972,7 @@ function parseColumnCount(rawValue) {
62972
62972
  function parseColumnGap(gapTwips) {
62973
62973
  if (gapTwips == null) return DEFAULT_COLUMN_GAP_INCHES;
62974
62974
  const gap = Number(gapTwips);
62975
- return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$3 : DEFAULT_COLUMN_GAP_INCHES;
62975
+ return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$4 : DEFAULT_COLUMN_GAP_INCHES;
62976
62976
  }
62977
62977
  function extractNormalizedMargins(attrs) {
62978
62978
  const sectionMargins = attrs.sectionMargins;
@@ -63056,7 +63056,7 @@ function extractColumns(elements) {
63056
63056
  const gapInches = parseColumnGap(cols.attributes["w:space"]);
63057
63057
  return {
63058
63058
  count,
63059
- gap: gapInches * PX_PER_INCH$2
63059
+ gap: gapInches * PX_PER_INCH$3
63060
63060
  };
63061
63061
  }
63062
63062
  function extractVerticalAlign(elements) {
@@ -63292,8 +63292,8 @@ function analyzeSectionRanges(doc2, bodySectPr) {
63292
63292
  }
63293
63293
  return ranges;
63294
63294
  }
63295
- const TWIPS_PER_INCH$2 = 1440;
63296
- const PX_PER_INCH$1 = 96;
63295
+ const TWIPS_PER_INCH$3 = 1440;
63296
+ const PX_PER_INCH$2 = 96;
63297
63297
  const PX_PER_PT = 96 / 72;
63298
63298
  SectionType.NEXT_PAGE;
63299
63299
  SectionType.CONTINUOUS;
@@ -63432,7 +63432,7 @@ const applyTrackedChangesModeToRuns = (runs, config2, hyperlinkConfig, applyMark
63432
63432
  }
63433
63433
  return filtered;
63434
63434
  };
63435
- const twipsToPx$1 = (value) => value / TWIPS_PER_INCH$2 * PX_PER_INCH$1;
63435
+ const twipsToPx$2 = (value) => value / TWIPS_PER_INCH$3 * PX_PER_INCH$2;
63436
63436
  const ptToPx = (pt) => {
63437
63437
  if (pt == null || !Number.isFinite(pt)) return void 0;
63438
63438
  return pt * PX_PER_PT;
@@ -64942,8 +64942,8 @@ const normalizeParagraphSpacing = (value) => {
64942
64942
  const beforeAutospacing = toBooleanFlag(source.beforeAutospacing ?? source.beforeAutoSpacing);
64943
64943
  const afterAutospacing = toBooleanFlag(source.afterAutospacing ?? source.afterAutoSpacing);
64944
64944
  const contextualSpacing = toBooleanFlag(source.contextualSpacing);
64945
- const before = beforeRaw != null ? twipsToPx$1(beforeRaw) : pickNumber(source.lineSpaceBefore);
64946
- const after = afterRaw != null ? twipsToPx$1(afterRaw) : pickNumber(source.lineSpaceAfter);
64945
+ const before = beforeRaw != null ? twipsToPx$2(beforeRaw) : pickNumber(source.lineSpaceBefore);
64946
+ const after = afterRaw != null ? twipsToPx$2(afterRaw) : pickNumber(source.lineSpaceAfter);
64947
64947
  const line = normalizeLineValue(lineRaw, lineRule);
64948
64948
  if (before != null) spacing.before = before;
64949
64949
  if (after != null) spacing.after = after;
@@ -64973,9 +64973,9 @@ const normalizeLineValue = (value, lineRule) => {
64973
64973
  if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
64974
64974
  return value;
64975
64975
  }
64976
- return twipsToPx$1(value);
64976
+ return twipsToPx$2(value);
64977
64977
  }
64978
- return twipsToPx$1(value);
64978
+ return twipsToPx$2(value);
64979
64979
  };
64980
64980
  const normalizeLineRule = (value) => {
64981
64981
  if (value === "auto" || value === "exact" || value === "atLeast") {
@@ -65012,7 +65012,7 @@ const normalizeParagraphIndent = (value) => {
65012
65012
  if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
65013
65013
  return num;
65014
65014
  }
65015
- return twipsToPx$1(Number(num));
65015
+ return twipsToPx$2(Number(num));
65016
65016
  };
65017
65017
  const left2 = convert(pickNumber(source.left));
65018
65018
  const right2 = convert(pickNumber(source.right));
@@ -65592,9 +65592,9 @@ const buildFontCss = (run2) => {
65592
65592
  const family = run2.fontFamily ?? "Times New Roman";
65593
65593
  return `${style2}${weight}${size2} ${family}`;
65594
65594
  };
65595
- const TWIPS_PER_INCH$1 = 1440;
65595
+ const TWIPS_PER_INCH$2 = 1440;
65596
65596
  const PIXELS_PER_INCH = 96;
65597
- const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$1 / PIXELS_PER_INCH);
65597
+ const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$2 / PIXELS_PER_INCH);
65598
65598
  const PIXELS_PER_TWIP = 1 / TWIPS_PER_PIXEL;
65599
65599
  const toFiniteNumber = (value) => {
65600
65600
  if (value == null) return null;
@@ -66618,7 +66618,7 @@ const extractMarkerRun = (lvl) => {
66618
66618
  }
66619
66619
  const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
66620
66620
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
66621
- run2.letterSpacing = twipsToPx$1(spacingTwips);
66621
+ run2.letterSpacing = twipsToPx$2(spacingTwips);
66622
66622
  }
66623
66623
  return Object.keys(run2).length ? run2 : void 0;
66624
66624
  };
@@ -66693,6 +66693,13 @@ const isTruthy = (value) => {
66693
66693
  }
66694
66694
  return false;
66695
66695
  };
66696
+ const safeGetProperty = (obj, key2) => {
66697
+ if (!obj || typeof obj !== "object") {
66698
+ return void 0;
66699
+ }
66700
+ const record = obj;
66701
+ return record[key2];
66702
+ };
66696
66703
  const isExplicitFalse = (value) => {
66697
66704
  if (value === false || value === 0) return true;
66698
66705
  if (typeof value === "string") {
@@ -66835,10 +66842,19 @@ const buildNumberingPath = (numId, ilvl, counterValue, listCounterContext) => {
66835
66842
  const convertIndentTwipsToPx = (indent) => {
66836
66843
  if (!indent) return void 0;
66837
66844
  const result = {};
66838
- if (isFiniteNumber(indent.left)) result.left = twipsToPx$1(Number(indent.left));
66839
- if (isFiniteNumber(indent.right)) result.right = twipsToPx$1(Number(indent.right));
66840
- if (isFiniteNumber(indent.firstLine)) result.firstLine = twipsToPx$1(Number(indent.firstLine));
66841
- if (isFiniteNumber(indent.hanging)) result.hanging = twipsToPx$1(Number(indent.hanging));
66845
+ const toNum = (v2) => {
66846
+ if (typeof v2 === "string" && v2.trim() !== "" && isFinite(Number(v2))) return Number(v2);
66847
+ if (isFiniteNumber(v2)) return Number(v2);
66848
+ return void 0;
66849
+ };
66850
+ const left2 = toNum(indent.left);
66851
+ const right2 = toNum(indent.right);
66852
+ const firstLine = toNum(indent.firstLine);
66853
+ const hanging = toNum(indent.hanging);
66854
+ if (left2 != null) result.left = twipsToPx$2(left2);
66855
+ if (right2 != null) result.right = twipsToPx$2(right2);
66856
+ if (firstLine != null) result.firstLine = twipsToPx$2(firstLine);
66857
+ if (hanging != null) result.hanging = twipsToPx$2(hanging);
66842
66858
  return Object.keys(result).length > 0 ? result : void 0;
66843
66859
  };
66844
66860
  const toAdapterNumberingProps = (value) => {
@@ -66863,7 +66879,7 @@ const toResolvedTabStops = (tabs) => {
66863
66879
  if (!stop || typeof stop.pos !== "number") continue;
66864
66880
  const alignment2 = normalizeResolvedTabAlignment(stop.val);
66865
66881
  if (!alignment2) continue;
66866
- const position = twipsToPx$1(stop.pos);
66882
+ const position = twipsToPx$2(stop.pos);
66867
66883
  if (!Number.isFinite(position)) continue;
66868
66884
  const resolvedStop = {
66869
66885
  position,
@@ -67185,8 +67201,9 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67185
67201
  paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
67186
67202
  }
67187
67203
  }
67188
- if (normalizedSpacing?.contextualSpacing != null) {
67189
- paragraphAttrs.contextualSpacing = normalizedSpacing.contextualSpacing;
67204
+ const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing");
67205
+ if (contextualSpacingValue != null) {
67206
+ paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
67190
67207
  }
67191
67208
  const hasExplicitIndent = Boolean(normalizedIndent);
67192
67209
  const hasNumberingIndent = Boolean(computed2.numbering?.indent?.left || computed2.numbering?.indent?.hanging);
@@ -67238,7 +67255,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67238
67255
  paragraphAttrs.tabs = normalizedTabs;
67239
67256
  }
67240
67257
  }
67241
- const asString = (value) => {
67258
+ const asString2 = (value) => {
67242
67259
  return typeof value === "string" ? value : void 0;
67243
67260
  };
67244
67261
  const normalizeFramePr = (value) => {
@@ -67261,7 +67278,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67261
67278
  };
67262
67279
  const framePr = normalizeFramePr(attrs.framePr) ?? normalizeFramePr(attrs.paragraphProperties?.framePr) ?? extractFramePrFromElements(attrs.paragraphProperties);
67263
67280
  if (framePr) {
67264
- const rawXAlign = asString(framePr["w:xAlign"] ?? framePr.xAlign);
67281
+ const rawXAlign = asString2(framePr["w:xAlign"] ?? framePr.xAlign);
67265
67282
  const xAlign = typeof rawXAlign === "string" ? rawXAlign.toLowerCase() : void 0;
67266
67283
  if (xAlign === "left" || xAlign === "right" || xAlign === "center") {
67267
67284
  paragraphAttrs.floatAlignment = xAlign;
@@ -67271,7 +67288,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67271
67288
  paragraphAttrs.dropCap = dropCap;
67272
67289
  const dropCapMode = typeof dropCap === "string" ? dropCap.toLowerCase() : "drop";
67273
67290
  const linesValue = pickNumber(framePr["w:lines"] ?? framePr.lines);
67274
- const wrapValue = asString(framePr["w:wrap"] ?? framePr.wrap);
67291
+ const wrapValue = asString2(framePr["w:wrap"] ?? framePr.wrap);
67275
67292
  const dropCapRunInfo = extractDropCapRunFromParagraph(para);
67276
67293
  if (dropCapRunInfo) {
67277
67294
  const descriptor = {
@@ -67289,23 +67306,23 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67289
67306
  }
67290
67307
  }
67291
67308
  const frame = {};
67292
- const wrap2 = asString(framePr["w:wrap"] ?? framePr.wrap);
67309
+ const wrap2 = asString2(framePr["w:wrap"] ?? framePr.wrap);
67293
67310
  if (wrap2) frame.wrap = wrap2;
67294
67311
  if (xAlign) {
67295
67312
  frame.xAlign = xAlign;
67296
67313
  }
67297
- const rawYAlign = asString(framePr["w:yAlign"] ?? framePr.yAlign);
67314
+ const rawYAlign = asString2(framePr["w:yAlign"] ?? framePr.yAlign);
67298
67315
  if (rawYAlign) {
67299
67316
  frame.yAlign = rawYAlign;
67300
67317
  }
67301
- const hAnchor = asString(framePr["w:hAnchor"] ?? framePr.hAnchor);
67318
+ const hAnchor = asString2(framePr["w:hAnchor"] ?? framePr.hAnchor);
67302
67319
  if (hAnchor) frame.hAnchor = hAnchor;
67303
- const vAnchor = asString(framePr["w:vAnchor"] ?? framePr.vAnchor);
67320
+ const vAnchor = asString2(framePr["w:vAnchor"] ?? framePr.vAnchor);
67304
67321
  if (vAnchor) frame.vAnchor = vAnchor;
67305
67322
  const xTwips = pickNumber(framePr["w:x"] ?? framePr.x);
67306
- if (xTwips != null) frame.x = twipsToPx$1(xTwips);
67323
+ if (xTwips != null) frame.x = twipsToPx$2(xTwips);
67307
67324
  const yTwips = pickNumber(framePr["w:y"] ?? framePr.y);
67308
- if (yTwips != null) frame.y = twipsToPx$1(yTwips);
67325
+ if (yTwips != null) frame.y = twipsToPx$2(yTwips);
67309
67326
  if (Object.keys(frame).length > 0) {
67310
67327
  paragraphAttrs.frame = frame;
67311
67328
  }
@@ -67393,7 +67410,29 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67393
67410
  }
67394
67411
  }
67395
67412
  }
67396
- const wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
67413
+ let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
67414
+ if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
67415
+ const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
67416
+ const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
67417
+ if (firstLinePx > 0) {
67418
+ wordLayout = {
67419
+ // Treat as first-line-indent mode: text starts after the marker+firstLine offset.
67420
+ firstLineIndentMode: true,
67421
+ textStartPx: firstLinePx
67422
+ };
67423
+ }
67424
+ }
67425
+ if (wordLayout && (!wordLayout.textStartPx || !Number.isFinite(wordLayout.textStartPx)) && enrichedNumberingProps.resolvedLevelIndent) {
67426
+ const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
67427
+ const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
67428
+ if (firstLinePx > 0) {
67429
+ wordLayout = {
67430
+ ...wordLayout,
67431
+ firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
67432
+ textStartPx: firstLinePx
67433
+ };
67434
+ }
67435
+ }
67397
67436
  if (wordLayout) {
67398
67437
  if (wordLayout.marker) {
67399
67438
  if (listRendering?.markerText) {
@@ -69304,7 +69343,7 @@ const measurementToPx = (value) => {
69304
69343
  const entry = value;
69305
69344
  if (typeof entry.value !== "number") return void 0;
69306
69345
  if (!entry.type || entry.type === "px" || entry.type === "pixel") return entry.value;
69307
- if (entry.type === "dxa") return twipsToPx$1(entry.value);
69346
+ if (entry.type === "dxa") return twipsToPx$2(entry.value);
69308
69347
  return void 0;
69309
69348
  };
69310
69349
  const normalizeTableWidth = (value) => {
@@ -69316,7 +69355,7 @@ const normalizeTableWidth = (value) => {
69316
69355
  return { width: raw, type: measurement.type ?? "px" };
69317
69356
  }
69318
69357
  if (measurement.type === "dxa") {
69319
- return { width: twipsToPx$1(raw), type: "px" };
69358
+ return { width: twipsToPx$2(raw), type: "px" };
69320
69359
  }
69321
69360
  return { width: raw, type: measurement.type };
69322
69361
  };
@@ -69344,13 +69383,13 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
69344
69383
  const line = parseIntSafe$1(attrs["w:line"]);
69345
69384
  const rawLineRule = attrs["w:lineRule"];
69346
69385
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
69347
- if (before != null) spacing.before = twipsToPx$1(before);
69348
- if (after != null) spacing.after = twipsToPx$1(after);
69386
+ if (before != null) spacing.before = twipsToPx$2(before);
69387
+ if (after != null) spacing.after = twipsToPx$2(after);
69349
69388
  if (line != null) {
69350
69389
  if (lineRule === "auto") {
69351
69390
  spacing.line = line / 240;
69352
69391
  } else {
69353
- spacing.line = twipsToPx$1(line);
69392
+ spacing.line = twipsToPx$2(line);
69354
69393
  }
69355
69394
  }
69356
69395
  if (lineRule) spacing.lineRule = lineRule;
@@ -69376,7 +69415,7 @@ const normalizeRowHeight = (rowProps) => {
69376
69415
  if (rawValue == null) return void 0;
69377
69416
  const rawRule = heightObj.rule ?? heightObj.hRule;
69378
69417
  const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
69379
- const valuePx = twipsToPx$1(rawValue);
69418
+ const valuePx = twipsToPx$2(rawValue);
69380
69419
  return {
69381
69420
  value: valuePx,
69382
69421
  rule
@@ -69626,10 +69665,10 @@ function extractFloatingTableAnchorWrap(node) {
69626
69665
  anchor.alignV = floatingProps.tblpYSpec;
69627
69666
  }
69628
69667
  if (floatingProps.tblpX !== void 0) {
69629
- anchor.offsetH = twipsToPx$1(floatingProps.tblpX);
69668
+ anchor.offsetH = twipsToPx$2(floatingProps.tblpX);
69630
69669
  }
69631
69670
  if (floatingProps.tblpY !== void 0) {
69632
- anchor.offsetV = twipsToPx$1(floatingProps.tblpY);
69671
+ anchor.offsetV = twipsToPx$2(floatingProps.tblpY);
69633
69672
  }
69634
69673
  const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
69635
69674
  const wrap2 = {
@@ -69640,16 +69679,16 @@ function extractFloatingTableAnchorWrap(node) {
69640
69679
  };
69641
69680
  if (hasDistances) {
69642
69681
  if (floatingProps.topFromText !== void 0) {
69643
- wrap2.distTop = twipsToPx$1(floatingProps.topFromText);
69682
+ wrap2.distTop = twipsToPx$2(floatingProps.topFromText);
69644
69683
  }
69645
69684
  if (floatingProps.bottomFromText !== void 0) {
69646
- wrap2.distBottom = twipsToPx$1(floatingProps.bottomFromText);
69685
+ wrap2.distBottom = twipsToPx$2(floatingProps.bottomFromText);
69647
69686
  }
69648
69687
  if (floatingProps.leftFromText !== void 0) {
69649
- wrap2.distLeft = twipsToPx$1(floatingProps.leftFromText);
69688
+ wrap2.distLeft = twipsToPx$2(floatingProps.leftFromText);
69650
69689
  }
69651
69690
  if (floatingProps.rightFromText !== void 0) {
69652
- wrap2.distRight = twipsToPx$1(floatingProps.rightFromText);
69691
+ wrap2.distRight = twipsToPx$2(floatingProps.rightFromText);
69653
69692
  }
69654
69693
  }
69655
69694
  return { anchor, wrap: wrap2 };
@@ -76822,7 +76861,7 @@ const _DomPainter = class _DomPainter2 {
76822
76861
  }
76823
76862
  const runsForLine = sliceRunsForLine(block, line);
76824
76863
  const trackedConfig = this.resolveTrackedChangesConfig(block);
76825
- const textSlices = runsForLine.length > 0 ? runsForLine.filter((r2) => (r2.kind === "text" || r2.kind === void 0) && "text" in r2 && r2.text != null).map((r2) => r2.text) : gatherTextSlicesForLine(block, line);
76864
+ runsForLine.length > 0 ? runsForLine.filter((r2) => (r2.kind === "text" || r2.kind === void 0) && "text" in r2 && r2.text != null).map((r2) => r2.text) : gatherTextSlicesForLine(block, line);
76826
76865
  if (runsForLine.length === 0) {
76827
76866
  const span = this.doc.createElement("span");
76828
76867
  span.innerHTML = "&nbsp;";
@@ -76869,19 +76908,7 @@ const _DomPainter = class _DomPainter2 {
76869
76908
  });
76870
76909
  }
76871
76910
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
76872
- const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
76873
- const shouldJustify = !skipJustify && effectiveAlignment === "justify" && !hasExplicitPositioning;
76874
- if (shouldJustify) {
76875
- const spaceCount = textSlices.reduce(
76876
- (sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
76877
- 0
76878
- );
76879
- const slack = availableWidth - line.width;
76880
- if (spaceCount > 0 && slack !== 0) {
76881
- const spacingPerSpace = slack / spaceCount;
76882
- el.style.wordSpacing = `${spacingPerSpace}px`;
76883
- }
76884
- }
76911
+ availableWidthOverride ?? line.maxWidth ?? line.width;
76885
76912
  if (hasExplicitPositioning && line.segments) {
76886
76913
  const paraIndent = block.attrs?.indent;
76887
76914
  const indentLeft = paraIndent?.left ?? 0;
@@ -79044,6 +79071,32 @@ const extractBlockPmRange = (block) => {
79044
79071
  pmEnd: end2 ?? (start2 != null ? start2 + 1 : void 0)
79045
79072
  };
79046
79073
  };
79074
+ const getParagraphAttrs = (block) => {
79075
+ if (!block.attrs || typeof block.attrs !== "object") {
79076
+ return void 0;
79077
+ }
79078
+ return block.attrs;
79079
+ };
79080
+ const asString = (value) => {
79081
+ return typeof value === "string" ? value : void 0;
79082
+ };
79083
+ const asBoolean = (value) => {
79084
+ if (value === true || value === 1) return true;
79085
+ if (typeof value === "string") {
79086
+ const normalized = value.toLowerCase();
79087
+ return normalized === "true" || normalized === "1" || normalized === "on";
79088
+ }
79089
+ return false;
79090
+ };
79091
+ const asSafeNumber = (value) => {
79092
+ if (typeof value !== "number") {
79093
+ return 0;
79094
+ }
79095
+ if (!Number.isFinite(value) || value < 0) {
79096
+ return 0;
79097
+ }
79098
+ return value;
79099
+ };
79047
79100
  function calculateFirstLineIndent(block, measure) {
79048
79101
  const wordLayout = block.attrs?.wordLayout;
79049
79102
  if (!wordLayout?.firstLineIndentMode) {
@@ -79061,7 +79114,8 @@ function calculateFirstLineIndent(block, measure) {
79061
79114
  function layoutParagraphBlock(ctx2, anchors) {
79062
79115
  const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx2;
79063
79116
  const remeasureParagraph2 = ctx2.remeasureParagraph;
79064
- const frame = block.attrs?.frame;
79117
+ const blockAttrs = getParagraphAttrs(block);
79118
+ const frame = blockAttrs?.frame;
79065
79119
  if (anchors?.anchoredDrawings?.length) {
79066
79120
  for (const entry of anchors.anchoredDrawings) {
79067
79121
  if (anchors.placedAnchoredIds.has(entry.block.id)) continue;
@@ -79186,9 +79240,10 @@ function layoutParagraphBlock(ctx2, anchors) {
79186
79240
  didRemeasureForColumnWidth = true;
79187
79241
  }
79188
79242
  let fromLine = 0;
79189
- const spacing = block.attrs?.spacing ?? {};
79190
- const styleId = block.attrs?.styleId;
79191
- const contextualSpacing = Boolean(block.attrs?.contextualSpacing);
79243
+ const attrs = getParagraphAttrs(block);
79244
+ const spacing = attrs?.spacing ?? {};
79245
+ const styleId = asString(attrs?.styleId);
79246
+ const contextualSpacing = asBoolean(attrs?.contextualSpacing);
79192
79247
  let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
79193
79248
  const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
79194
79249
  let appliedSpacingBefore = spacingBefore === 0;
@@ -79269,14 +79324,13 @@ function layoutParagraphBlock(ctx2, anchors) {
79269
79324
  while (fromLine < lines.length) {
79270
79325
  let state2 = ensurePage();
79271
79326
  if (state2.trailingSpacing == null) state2.trailingSpacing = 0;
79272
- if (contextualSpacing) {
79273
- const prevStyle = state2.lastParagraphStyleId;
79274
- if (styleId && prevStyle && prevStyle === styleId) {
79275
- spacingBefore = 0;
79276
- }
79277
- }
79278
79327
  if (contextualSpacing && state2.lastParagraphStyleId && styleId && state2.lastParagraphStyleId === styleId) {
79279
79328
  spacingBefore = 0;
79329
+ const prevTrailing = asSafeNumber(state2.trailingSpacing);
79330
+ if (prevTrailing > 0) {
79331
+ state2.cursorY -= prevTrailing;
79332
+ state2.trailingSpacing = 0;
79333
+ }
79280
79334
  }
79281
79335
  if (!appliedSpacingBefore && spacingBefore > 0) {
79282
79336
  while (!appliedSpacingBefore) {
@@ -82176,7 +82230,13 @@ function getCtx() {
82176
82230
  return ctx$1;
82177
82231
  }
82178
82232
  function isTextRun(run2) {
82179
- return run2.kind === "tab" ? false : true;
82233
+ if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
82234
+ return false;
82235
+ }
82236
+ if ("src" in run2) {
82237
+ return false;
82238
+ }
82239
+ return true;
82180
82240
  }
82181
82241
  function fontString(run2) {
82182
82242
  const textRun = isTextRun(run2) ? run2 : null;
@@ -82189,6 +82249,42 @@ function fontString(run2) {
82189
82249
  function runText(run2) {
82190
82250
  return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
82191
82251
  }
82252
+ const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
82253
+ const TWIPS_PER_INCH$1 = 1440;
82254
+ const PX_PER_INCH$1 = 96;
82255
+ const TWIPS_PER_PX$1 = TWIPS_PER_INCH$1 / PX_PER_INCH$1;
82256
+ const TAB_EPSILON$1 = 0.1;
82257
+ const WIDTH_FUDGE_PX = 0.5;
82258
+ const twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$1;
82259
+ const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
82260
+ const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
82261
+ const paragraphIndentTwips = {
82262
+ left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
82263
+ right: pxToTwips$1(Math.max(0, indent?.right ?? 0)),
82264
+ firstLine: pxToTwips$1(Math.max(0, indent?.firstLine ?? 0)),
82265
+ hanging: pxToTwips$1(Math.max(0, indent?.hanging ?? 0))
82266
+ };
82267
+ const stops = computeTabStops$1({
82268
+ explicitStops: tabs ?? [],
82269
+ defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$1,
82270
+ paragraphIndent: paragraphIndentTwips
82271
+ });
82272
+ return stops.map((stop) => ({
82273
+ pos: twipsToPx$1(stop.pos),
82274
+ val: stop.val,
82275
+ leader: stop.leader
82276
+ }));
82277
+ };
82278
+ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
82279
+ let index2 = startIndex;
82280
+ while (index2 < tabStops.length && tabStops[index2].pos <= currentX + TAB_EPSILON$1) {
82281
+ index2 += 1;
82282
+ }
82283
+ if (index2 < tabStops.length) {
82284
+ return { target: tabStops[index2].pos, nextIndex: index2 + 1 };
82285
+ }
82286
+ return { target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$1), nextIndex: index2 };
82287
+ };
82192
82288
  function measureRunSliceWidth(run2, fromChar, toChar) {
82193
82289
  const context = getCtx();
82194
82290
  const text = runText(run2).slice(fromChar, toChar);
@@ -82212,13 +82308,38 @@ function lineHeightForRuns(runs, fromRun, toRun) {
82212
82308
  return maxSize2 * 1.2;
82213
82309
  }
82214
82310
  function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82311
+ if (!Number.isFinite(maxWidth) || maxWidth <= 0) {
82312
+ throw new Error(`remeasureParagraph: maxWidth must be a positive number, got ${maxWidth}`);
82313
+ }
82314
+ if (!Number.isFinite(firstLineIndent)) {
82315
+ throw new Error(`remeasureParagraph: firstLineIndent must be a finite number, got ${firstLineIndent}`);
82316
+ }
82317
+ if (!block) {
82318
+ throw new Error("remeasureParagraph: block must be defined");
82319
+ }
82320
+ if (!Array.isArray(block.runs)) {
82321
+ throw new Error(`remeasureParagraph: block.runs must be an array, got ${typeof block.runs}`);
82322
+ }
82215
82323
  const runs = block.runs ?? [];
82216
82324
  const lines = [];
82325
+ const attrs = block.attrs;
82326
+ const indent = attrs?.indent;
82327
+ const wordLayout = attrs?.wordLayout;
82328
+ const indentLeft = Math.max(0, indent?.left ?? 0);
82329
+ const indentRight = Math.max(0, indent?.right ?? 0);
82330
+ const indentFirstLine = Math.max(0, indent?.firstLine ?? 0);
82331
+ const indentHanging = Math.max(0, indent?.hanging ?? 0);
82332
+ const rawFirstLineOffset = Math.max(0, firstLineIndent || indentFirstLine - indentHanging);
82333
+ const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
82334
+ const textStartPx = wordLayout?.textStartPx;
82335
+ const treatAsHanging = textStartPx && indentLeft === 0 && indentHanging === 0;
82336
+ const firstLineWidth = typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - textStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
82337
+ const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
82217
82338
  let currentRun = 0;
82218
82339
  let currentChar = 0;
82219
82340
  while (currentRun < runs.length) {
82220
82341
  const isFirstLine = lines.length === 0;
82221
- const effectiveMaxWidth = isFirstLine ? maxWidth - firstLineIndent : maxWidth;
82342
+ const effectiveMaxWidth = Math.max(1, isFirstLine ? firstLineWidth : contentWidth);
82222
82343
  const startRun = currentRun;
82223
82344
  const startChar = currentChar;
82224
82345
  let width = 0;
@@ -82226,13 +82347,26 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82226
82347
  let lastBreakChar = -1;
82227
82348
  let endRun = currentRun;
82228
82349
  let endChar = currentChar;
82350
+ let tabStopCursor = 0;
82351
+ let didBreakInThisLine = false;
82229
82352
  for (let r2 = currentRun; r2 < runs.length; r2 += 1) {
82230
82353
  const run2 = runs[r2];
82354
+ if (run2.kind === "tab") {
82355
+ const { target, nextIndex } = getNextTabStopPx$1(width, tabStops, tabStopCursor);
82356
+ const tabAdvance = Math.max(0, target - width);
82357
+ width += tabAdvance;
82358
+ tabStopCursor = nextIndex;
82359
+ endRun = r2;
82360
+ endChar = 1;
82361
+ lastBreakRun = r2;
82362
+ lastBreakChar = 1;
82363
+ continue;
82364
+ }
82231
82365
  const text = runText(run2);
82232
82366
  const start2 = r2 === currentRun ? currentChar : 0;
82233
82367
  for (let c2 = start2; c2 < text.length; c2 += 1) {
82234
82368
  const w2 = measureRunSliceWidth(run2, c2, c2 + 1);
82235
- if (width + w2 > effectiveMaxWidth && width > 0) {
82369
+ if (width + w2 > effectiveMaxWidth - WIDTH_FUDGE_PX && width > 0) {
82236
82370
  if (lastBreakRun >= 0) {
82237
82371
  endRun = lastBreakRun;
82238
82372
  endChar = lastBreakChar;
@@ -82240,6 +82374,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82240
82374
  endRun = r2;
82241
82375
  endChar = c2;
82242
82376
  }
82377
+ didBreakInThisLine = true;
82243
82378
  break;
82244
82379
  }
82245
82380
  width += w2;
@@ -82251,9 +82386,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82251
82386
  lastBreakChar = c2 + 1;
82252
82387
  }
82253
82388
  }
82254
- if (endRun !== r2 || endRun === r2 && (r2 === lastBreakRun ? endChar === lastBreakChar : false)) {
82255
- break;
82256
- }
82389
+ if (didBreakInThisLine) break;
82257
82390
  }
82258
82391
  if (startRun === endRun && startChar === endChar) {
82259
82392
  endRun = startRun;
@@ -82267,11 +82400,15 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82267
82400
  width,
82268
82401
  ascent: 0,
82269
82402
  descent: 0,
82270
- lineHeight: lineHeightForRuns(runs, startRun, endRun)
82403
+ lineHeight: lineHeightForRuns(runs, startRun, endRun),
82404
+ maxWidth: effectiveMaxWidth
82271
82405
  };
82272
82406
  lines.push(line);
82273
82407
  currentRun = endRun;
82274
82408
  currentChar = endChar;
82409
+ if (currentRun >= runs.length) {
82410
+ break;
82411
+ }
82275
82412
  if (currentChar >= runText(runs[currentRun]).length) {
82276
82413
  currentRun += 1;
82277
82414
  currentChar = 0;
@@ -84484,7 +84621,7 @@ async function measureBlock(block, constraints) {
84484
84621
  async function measureParagraphBlock(block, maxWidth) {
84485
84622
  const ctx2 = getCanvasContext();
84486
84623
  const wordLayout = block.attrs?.wordLayout;
84487
- const WIDTH_FUDGE_PX = 0.5;
84624
+ const WIDTH_FUDGE_PX2 = 0.5;
84488
84625
  const lines = [];
84489
84626
  const indent = block.attrs?.indent;
84490
84627
  const spacing = block.attrs?.spacing;
@@ -84500,7 +84637,8 @@ async function measureParagraphBlock(block, maxWidth) {
84500
84637
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
84501
84638
  let initialAvailableWidth;
84502
84639
  const textStartPx = wordLayout?.textStartPx;
84503
- if (typeof textStartPx === "number" && textStartPx > indentLeft) {
84640
+ const treatAsHanging = isWordLayoutList && indentLeft === 0 && hanging === 0 && typeof textStartPx === "number";
84641
+ if (typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging) {
84504
84642
  initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
84505
84643
  } else {
84506
84644
  initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
@@ -84547,6 +84685,21 @@ async function measureParagraphBlock(block, maxWidth) {
84547
84685
  totalHeight: metrics.lineHeight
84548
84686
  };
84549
84687
  }
84688
+ const isListLike = Boolean(block.attrs?.numId || wordLayout?.marker);
84689
+ if (isListLike) {
84690
+ console.log(
84691
+ "[measureParagraph][list]",
84692
+ JSON.stringify({
84693
+ blockId: block.id,
84694
+ maxWidth,
84695
+ indentLeft,
84696
+ indentRight,
84697
+ textStartPx: textStartPx ?? null,
84698
+ firstLineOffset: firstLineOffset ?? null,
84699
+ initialAvailableWidth
84700
+ })
84701
+ );
84702
+ }
84550
84703
  let currentLine = null;
84551
84704
  const getEffectiveWidth = (baseWidth) => {
84552
84705
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
@@ -84954,7 +85107,7 @@ async function measureParagraphBlock(block, maxWidth) {
84954
85107
  };
84955
85108
  } else {
84956
85109
  const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
84957
- if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
85110
+ if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
84958
85111
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
84959
85112
  const { spaceCount: _sc, ...lineBase } = currentLine;
84960
85113
  const completedLine = {
@@ -85020,7 +85173,7 @@ async function measureParagraphBlock(block, maxWidth) {
85020
85173
  };
85021
85174
  } else {
85022
85175
  const boundarySpacing2 = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
85023
- if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
85176
+ if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
85024
85177
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
85025
85178
  const { spaceCount: _sc, ...lineBase } = currentLine;
85026
85179
  const completedLine = { ...lineBase, ...metrics };
@@ -85078,7 +85231,7 @@ async function measureParagraphBlock(block, maxWidth) {
85078
85231
  const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
85079
85232
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
85080
85233
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
85081
- const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX, font, ctx2, run2);
85234
+ const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
85082
85235
  let chunkCharOffset = wordStartChar;
85083
85236
  for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
85084
85237
  const chunk = chunks[chunkIndex];
@@ -85100,7 +85253,7 @@ async function measureParagraphBlock(block, maxWidth) {
85100
85253
  });
85101
85254
  if (isLastChunk) {
85102
85255
  const ls = run2.letterSpacing ?? 0;
85103
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85256
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85104
85257
  currentLine.toChar = wordEndWithSpace;
85105
85258
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85106
85259
  charPosInRun = wordEndWithSpace;
@@ -85132,7 +85285,7 @@ async function measureParagraphBlock(block, maxWidth) {
85132
85285
  spaceCount: 0
85133
85286
  };
85134
85287
  const ls = run2.letterSpacing ?? 0;
85135
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85288
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85136
85289
  currentLine.toChar = wordEndWithSpace;
85137
85290
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85138
85291
  charPosInRun = wordEndWithSpace;
@@ -85174,7 +85327,7 @@ async function measureParagraphBlock(block, maxWidth) {
85174
85327
  spaceCount: 0
85175
85328
  };
85176
85329
  const ls = run2.letterSpacing ?? 0;
85177
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85330
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85178
85331
  currentLine.toChar = wordEndWithSpace;
85179
85332
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85180
85333
  charPosInRun = wordEndWithSpace;
@@ -85189,7 +85342,7 @@ async function measureParagraphBlock(block, maxWidth) {
85189
85342
  const justifyAlignment = block.attrs?.alignment === "justify";
85190
85343
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
85191
85344
  (isLastWord ? 0 : run2.letterSpacing ?? 0);
85192
- const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX;
85345
+ const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX2;
85193
85346
  let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
85194
85347
  let compressedWidth = null;
85195
85348
  if (shouldBreak && justifyAlignment) {
@@ -85234,7 +85387,7 @@ async function measureParagraphBlock(block, maxWidth) {
85234
85387
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
85235
85388
  spaceCount: 0
85236
85389
  };
85237
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85390
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85238
85391
  currentLine.toChar = wordEndWithSpace;
85239
85392
  currentLine.width = roundValue(currentLine.width + spaceWidth + (run2.letterSpacing ?? 0));
85240
85393
  charPosInRun = wordEndWithSpace;
@@ -85244,7 +85397,7 @@ async function measureParagraphBlock(block, maxWidth) {
85244
85397
  }
85245
85398
  } else {
85246
85399
  currentLine.toRun = runIndex;
85247
- if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX) {
85400
+ if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85248
85401
  currentLine.toChar = wordEndNoSpace;
85249
85402
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
85250
85403
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);