@harbour-enterprises/superdoc 1.0.0-beta.96 → 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-Cdp1WJ9e.es.js → PdfViewer-BHcBfUWj.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-BGTfnD4T.cjs → PdfViewer-YvkZg201.cjs} +1 -1
  3. package/dist/chunks/{index-C-IS20yQ.cjs → index-DZ_AI-HW.cjs} +3 -3
  4. package/dist/chunks/{index-BV9YtiyI.es.js → index-DeQfFbTb.es.js} +3 -3
  5. package/dist/chunks/{index-lfdM_gm7-qtx-V4oF.cjs → index-Pvlqsxge-IH3eauKE.cjs} +1 -1
  6. package/dist/chunks/{index-lfdM_gm7-_EQjLyqH.es.js → index-Pvlqsxge-vW641SZt.es.js} +1 -1
  7. package/dist/chunks/{super-editor.es-D2zn943K.cjs → super-editor.es-BP3PKkwh.cjs} +190 -72
  8. package/dist/chunks/{super-editor.es-De2XS3A1.es.js → super-editor.es-BinyZw4F.es.js} +190 -72
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-B29ATZFC.js → converter-BEVM5t3i.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-BPktKUBx.js → docx-zipper-vETk3IMG.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-BRHMYtPA.js → editor-B8k1bwD_.js} +191 -73
  13. package/dist/super-editor/chunks/{index-lfdM_gm7.js → index-Pvlqsxge.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-CB2cJCLh.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 +192 -74
  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.96") {
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.96";
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-lfdM_gm7-qtx-V4oF.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.96");
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
  };
@@ -66842,10 +66842,19 @@ const buildNumberingPath = (numId, ilvl, counterValue, listCounterContext) => {
66842
66842
  const convertIndentTwipsToPx = (indent) => {
66843
66843
  if (!indent) return void 0;
66844
66844
  const result = {};
66845
- if (isFiniteNumber(indent.left)) result.left = twipsToPx$1(Number(indent.left));
66846
- if (isFiniteNumber(indent.right)) result.right = twipsToPx$1(Number(indent.right));
66847
- if (isFiniteNumber(indent.firstLine)) result.firstLine = twipsToPx$1(Number(indent.firstLine));
66848
- 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);
66849
66858
  return Object.keys(result).length > 0 ? result : void 0;
66850
66859
  };
66851
66860
  const toAdapterNumberingProps = (value) => {
@@ -66870,7 +66879,7 @@ const toResolvedTabStops = (tabs) => {
66870
66879
  if (!stop || typeof stop.pos !== "number") continue;
66871
66880
  const alignment2 = normalizeResolvedTabAlignment(stop.val);
66872
66881
  if (!alignment2) continue;
66873
- const position = twipsToPx$1(stop.pos);
66882
+ const position = twipsToPx$2(stop.pos);
66874
66883
  if (!Number.isFinite(position)) continue;
66875
66884
  const resolvedStop = {
66876
66885
  position,
@@ -67311,9 +67320,9 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67311
67320
  const vAnchor = asString2(framePr["w:vAnchor"] ?? framePr.vAnchor);
67312
67321
  if (vAnchor) frame.vAnchor = vAnchor;
67313
67322
  const xTwips = pickNumber(framePr["w:x"] ?? framePr.x);
67314
- if (xTwips != null) frame.x = twipsToPx$1(xTwips);
67323
+ if (xTwips != null) frame.x = twipsToPx$2(xTwips);
67315
67324
  const yTwips = pickNumber(framePr["w:y"] ?? framePr.y);
67316
- if (yTwips != null) frame.y = twipsToPx$1(yTwips);
67325
+ if (yTwips != null) frame.y = twipsToPx$2(yTwips);
67317
67326
  if (Object.keys(frame).length > 0) {
67318
67327
  paragraphAttrs.frame = frame;
67319
67328
  }
@@ -67401,7 +67410,29 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
67401
67410
  }
67402
67411
  }
67403
67412
  }
67404
- 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
+ }
67405
67436
  if (wordLayout) {
67406
67437
  if (wordLayout.marker) {
67407
67438
  if (listRendering?.markerText) {
@@ -69312,7 +69343,7 @@ const measurementToPx = (value) => {
69312
69343
  const entry = value;
69313
69344
  if (typeof entry.value !== "number") return void 0;
69314
69345
  if (!entry.type || entry.type === "px" || entry.type === "pixel") return entry.value;
69315
- if (entry.type === "dxa") return twipsToPx$1(entry.value);
69346
+ if (entry.type === "dxa") return twipsToPx$2(entry.value);
69316
69347
  return void 0;
69317
69348
  };
69318
69349
  const normalizeTableWidth = (value) => {
@@ -69324,7 +69355,7 @@ const normalizeTableWidth = (value) => {
69324
69355
  return { width: raw, type: measurement.type ?? "px" };
69325
69356
  }
69326
69357
  if (measurement.type === "dxa") {
69327
- return { width: twipsToPx$1(raw), type: "px" };
69358
+ return { width: twipsToPx$2(raw), type: "px" };
69328
69359
  }
69329
69360
  return { width: raw, type: measurement.type };
69330
69361
  };
@@ -69352,13 +69383,13 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
69352
69383
  const line = parseIntSafe$1(attrs["w:line"]);
69353
69384
  const rawLineRule = attrs["w:lineRule"];
69354
69385
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
69355
- if (before != null) spacing.before = twipsToPx$1(before);
69356
- 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);
69357
69388
  if (line != null) {
69358
69389
  if (lineRule === "auto") {
69359
69390
  spacing.line = line / 240;
69360
69391
  } else {
69361
- spacing.line = twipsToPx$1(line);
69392
+ spacing.line = twipsToPx$2(line);
69362
69393
  }
69363
69394
  }
69364
69395
  if (lineRule) spacing.lineRule = lineRule;
@@ -69384,7 +69415,7 @@ const normalizeRowHeight = (rowProps) => {
69384
69415
  if (rawValue == null) return void 0;
69385
69416
  const rawRule = heightObj.rule ?? heightObj.hRule;
69386
69417
  const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
69387
- const valuePx = twipsToPx$1(rawValue);
69418
+ const valuePx = twipsToPx$2(rawValue);
69388
69419
  return {
69389
69420
  value: valuePx,
69390
69421
  rule
@@ -69634,10 +69665,10 @@ function extractFloatingTableAnchorWrap(node) {
69634
69665
  anchor.alignV = floatingProps.tblpYSpec;
69635
69666
  }
69636
69667
  if (floatingProps.tblpX !== void 0) {
69637
- anchor.offsetH = twipsToPx$1(floatingProps.tblpX);
69668
+ anchor.offsetH = twipsToPx$2(floatingProps.tblpX);
69638
69669
  }
69639
69670
  if (floatingProps.tblpY !== void 0) {
69640
- anchor.offsetV = twipsToPx$1(floatingProps.tblpY);
69671
+ anchor.offsetV = twipsToPx$2(floatingProps.tblpY);
69641
69672
  }
69642
69673
  const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
69643
69674
  const wrap2 = {
@@ -69648,16 +69679,16 @@ function extractFloatingTableAnchorWrap(node) {
69648
69679
  };
69649
69680
  if (hasDistances) {
69650
69681
  if (floatingProps.topFromText !== void 0) {
69651
- wrap2.distTop = twipsToPx$1(floatingProps.topFromText);
69682
+ wrap2.distTop = twipsToPx$2(floatingProps.topFromText);
69652
69683
  }
69653
69684
  if (floatingProps.bottomFromText !== void 0) {
69654
- wrap2.distBottom = twipsToPx$1(floatingProps.bottomFromText);
69685
+ wrap2.distBottom = twipsToPx$2(floatingProps.bottomFromText);
69655
69686
  }
69656
69687
  if (floatingProps.leftFromText !== void 0) {
69657
- wrap2.distLeft = twipsToPx$1(floatingProps.leftFromText);
69688
+ wrap2.distLeft = twipsToPx$2(floatingProps.leftFromText);
69658
69689
  }
69659
69690
  if (floatingProps.rightFromText !== void 0) {
69660
- wrap2.distRight = twipsToPx$1(floatingProps.rightFromText);
69691
+ wrap2.distRight = twipsToPx$2(floatingProps.rightFromText);
69661
69692
  }
69662
69693
  }
69663
69694
  return { anchor, wrap: wrap2 };
@@ -76830,7 +76861,7 @@ const _DomPainter = class _DomPainter2 {
76830
76861
  }
76831
76862
  const runsForLine = sliceRunsForLine(block, line);
76832
76863
  const trackedConfig = this.resolveTrackedChangesConfig(block);
76833
- 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);
76834
76865
  if (runsForLine.length === 0) {
76835
76866
  const span = this.doc.createElement("span");
76836
76867
  span.innerHTML = "&nbsp;";
@@ -76877,19 +76908,7 @@ const _DomPainter = class _DomPainter2 {
76877
76908
  });
76878
76909
  }
76879
76910
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
76880
- const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
76881
- const shouldJustify = !skipJustify && effectiveAlignment === "justify" && !hasExplicitPositioning;
76882
- if (shouldJustify) {
76883
- const spaceCount = textSlices.reduce(
76884
- (sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
76885
- 0
76886
- );
76887
- const slack = availableWidth - line.width;
76888
- if (spaceCount > 0 && slack !== 0) {
76889
- const spacingPerSpace = slack / spaceCount;
76890
- el.style.wordSpacing = `${spacingPerSpace}px`;
76891
- }
76892
- }
76911
+ availableWidthOverride ?? line.maxWidth ?? line.width;
76893
76912
  if (hasExplicitPositioning && line.segments) {
76894
76913
  const paraIndent = block.attrs?.indent;
76895
76914
  const indentLeft = paraIndent?.left ?? 0;
@@ -82211,7 +82230,13 @@ function getCtx() {
82211
82230
  return ctx$1;
82212
82231
  }
82213
82232
  function isTextRun(run2) {
82214
- 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;
82215
82240
  }
82216
82241
  function fontString(run2) {
82217
82242
  const textRun = isTextRun(run2) ? run2 : null;
@@ -82224,6 +82249,42 @@ function fontString(run2) {
82224
82249
  function runText(run2) {
82225
82250
  return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
82226
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
+ };
82227
82288
  function measureRunSliceWidth(run2, fromChar, toChar) {
82228
82289
  const context = getCtx();
82229
82290
  const text = runText(run2).slice(fromChar, toChar);
@@ -82247,13 +82308,38 @@ function lineHeightForRuns(runs, fromRun, toRun) {
82247
82308
  return maxSize2 * 1.2;
82248
82309
  }
82249
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
+ }
82250
82323
  const runs = block.runs ?? [];
82251
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);
82252
82338
  let currentRun = 0;
82253
82339
  let currentChar = 0;
82254
82340
  while (currentRun < runs.length) {
82255
82341
  const isFirstLine = lines.length === 0;
82256
- const effectiveMaxWidth = isFirstLine ? maxWidth - firstLineIndent : maxWidth;
82342
+ const effectiveMaxWidth = Math.max(1, isFirstLine ? firstLineWidth : contentWidth);
82257
82343
  const startRun = currentRun;
82258
82344
  const startChar = currentChar;
82259
82345
  let width = 0;
@@ -82261,13 +82347,26 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82261
82347
  let lastBreakChar = -1;
82262
82348
  let endRun = currentRun;
82263
82349
  let endChar = currentChar;
82350
+ let tabStopCursor = 0;
82351
+ let didBreakInThisLine = false;
82264
82352
  for (let r2 = currentRun; r2 < runs.length; r2 += 1) {
82265
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
+ }
82266
82365
  const text = runText(run2);
82267
82366
  const start2 = r2 === currentRun ? currentChar : 0;
82268
82367
  for (let c2 = start2; c2 < text.length; c2 += 1) {
82269
82368
  const w2 = measureRunSliceWidth(run2, c2, c2 + 1);
82270
- if (width + w2 > effectiveMaxWidth && width > 0) {
82369
+ if (width + w2 > effectiveMaxWidth - WIDTH_FUDGE_PX && width > 0) {
82271
82370
  if (lastBreakRun >= 0) {
82272
82371
  endRun = lastBreakRun;
82273
82372
  endChar = lastBreakChar;
@@ -82275,6 +82374,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82275
82374
  endRun = r2;
82276
82375
  endChar = c2;
82277
82376
  }
82377
+ didBreakInThisLine = true;
82278
82378
  break;
82279
82379
  }
82280
82380
  width += w2;
@@ -82286,9 +82386,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82286
82386
  lastBreakChar = c2 + 1;
82287
82387
  }
82288
82388
  }
82289
- if (endRun !== r2 || endRun === r2 && (r2 === lastBreakRun ? endChar === lastBreakChar : false)) {
82290
- break;
82291
- }
82389
+ if (didBreakInThisLine) break;
82292
82390
  }
82293
82391
  if (startRun === endRun && startChar === endChar) {
82294
82392
  endRun = startRun;
@@ -82302,11 +82400,15 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
82302
82400
  width,
82303
82401
  ascent: 0,
82304
82402
  descent: 0,
82305
- lineHeight: lineHeightForRuns(runs, startRun, endRun)
82403
+ lineHeight: lineHeightForRuns(runs, startRun, endRun),
82404
+ maxWidth: effectiveMaxWidth
82306
82405
  };
82307
82406
  lines.push(line);
82308
82407
  currentRun = endRun;
82309
82408
  currentChar = endChar;
82409
+ if (currentRun >= runs.length) {
82410
+ break;
82411
+ }
82310
82412
  if (currentChar >= runText(runs[currentRun]).length) {
82311
82413
  currentRun += 1;
82312
82414
  currentChar = 0;
@@ -84519,7 +84621,7 @@ async function measureBlock(block, constraints) {
84519
84621
  async function measureParagraphBlock(block, maxWidth) {
84520
84622
  const ctx2 = getCanvasContext();
84521
84623
  const wordLayout = block.attrs?.wordLayout;
84522
- const WIDTH_FUDGE_PX = 0.5;
84624
+ const WIDTH_FUDGE_PX2 = 0.5;
84523
84625
  const lines = [];
84524
84626
  const indent = block.attrs?.indent;
84525
84627
  const spacing = block.attrs?.spacing;
@@ -84535,7 +84637,8 @@ async function measureParagraphBlock(block, maxWidth) {
84535
84637
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
84536
84638
  let initialAvailableWidth;
84537
84639
  const textStartPx = wordLayout?.textStartPx;
84538
- 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) {
84539
84642
  initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
84540
84643
  } else {
84541
84644
  initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
@@ -84582,6 +84685,21 @@ async function measureParagraphBlock(block, maxWidth) {
84582
84685
  totalHeight: metrics.lineHeight
84583
84686
  };
84584
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
+ }
84585
84703
  let currentLine = null;
84586
84704
  const getEffectiveWidth = (baseWidth) => {
84587
84705
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
@@ -84989,7 +85107,7 @@ async function measureParagraphBlock(block, maxWidth) {
84989
85107
  };
84990
85108
  } else {
84991
85109
  const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
84992
- 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) {
84993
85111
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
84994
85112
  const { spaceCount: _sc, ...lineBase } = currentLine;
84995
85113
  const completedLine = {
@@ -85055,7 +85173,7 @@ async function measureParagraphBlock(block, maxWidth) {
85055
85173
  };
85056
85174
  } else {
85057
85175
  const boundarySpacing2 = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
85058
- 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) {
85059
85177
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
85060
85178
  const { spaceCount: _sc, ...lineBase } = currentLine;
85061
85179
  const completedLine = { ...lineBase, ...metrics };
@@ -85113,7 +85231,7 @@ async function measureParagraphBlock(block, maxWidth) {
85113
85231
  const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
85114
85232
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
85115
85233
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
85116
- const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX, font, ctx2, run2);
85234
+ const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
85117
85235
  let chunkCharOffset = wordStartChar;
85118
85236
  for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
85119
85237
  const chunk = chunks[chunkIndex];
@@ -85135,7 +85253,7 @@ async function measureParagraphBlock(block, maxWidth) {
85135
85253
  });
85136
85254
  if (isLastChunk) {
85137
85255
  const ls = run2.letterSpacing ?? 0;
85138
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85256
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85139
85257
  currentLine.toChar = wordEndWithSpace;
85140
85258
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85141
85259
  charPosInRun = wordEndWithSpace;
@@ -85167,7 +85285,7 @@ async function measureParagraphBlock(block, maxWidth) {
85167
85285
  spaceCount: 0
85168
85286
  };
85169
85287
  const ls = run2.letterSpacing ?? 0;
85170
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85288
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85171
85289
  currentLine.toChar = wordEndWithSpace;
85172
85290
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85173
85291
  charPosInRun = wordEndWithSpace;
@@ -85209,7 +85327,7 @@ async function measureParagraphBlock(block, maxWidth) {
85209
85327
  spaceCount: 0
85210
85328
  };
85211
85329
  const ls = run2.letterSpacing ?? 0;
85212
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85330
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85213
85331
  currentLine.toChar = wordEndWithSpace;
85214
85332
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85215
85333
  charPosInRun = wordEndWithSpace;
@@ -85224,7 +85342,7 @@ async function measureParagraphBlock(block, maxWidth) {
85224
85342
  const justifyAlignment = block.attrs?.alignment === "justify";
85225
85343
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
85226
85344
  (isLastWord ? 0 : run2.letterSpacing ?? 0);
85227
- const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX;
85345
+ const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX2;
85228
85346
  let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
85229
85347
  let compressedWidth = null;
85230
85348
  if (shouldBreak && justifyAlignment) {
@@ -85269,7 +85387,7 @@ async function measureParagraphBlock(block, maxWidth) {
85269
85387
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
85270
85388
  spaceCount: 0
85271
85389
  };
85272
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85390
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
85273
85391
  currentLine.toChar = wordEndWithSpace;
85274
85392
  currentLine.width = roundValue(currentLine.width + spaceWidth + (run2.letterSpacing ?? 0));
85275
85393
  charPosInRun = wordEndWithSpace;
@@ -85279,7 +85397,7 @@ async function measureParagraphBlock(block, maxWidth) {
85279
85397
  }
85280
85398
  } else {
85281
85399
  currentLine.toRun = runIndex;
85282
- 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) {
85283
85401
  currentLine.toChar = wordEndNoSpace;
85284
85402
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
85285
85403
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);