@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
@@ -42422,7 +42422,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42422
42422
  static getStoredSuperdocVersion(docx) {
42423
42423
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42424
42424
  }
42425
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.96") {
42425
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.97") {
42426
42426
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42427
42427
  }
42428
42428
  /**
@@ -67497,7 +67497,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67497
67497
  const shouldSkipNodeView = (editor) => {
67498
67498
  return isHeadless(editor);
67499
67499
  };
67500
- const summaryVersion = "1.0.0-beta.96";
67500
+ const summaryVersion = "1.0.0-beta.97";
67501
67501
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
67502
67502
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
67503
67503
  function mapAttributes(attrs) {
@@ -68286,7 +68286,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68286
68286
  { default: remarkStringify2 },
68287
68287
  { default: remarkGfm2 }
68288
68288
  ] = await Promise.all([
68289
- Promise.resolve().then(() => indexLfdM_gm7),
68289
+ Promise.resolve().then(() => indexPvlqsxge),
68290
68290
  Promise.resolve().then(() => indexDRCvimau),
68291
68291
  Promise.resolve().then(() => indexC_x_N6Uh),
68292
68292
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -68491,7 +68491,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
68491
68491
  * Process collaboration migrations
68492
68492
  */
68493
68493
  processCollaborationMigrations() {
68494
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.96");
68494
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.97");
68495
68495
  if (!this.options.ydoc) return;
68496
68496
  const metaMap = this.options.ydoc.getMap("meta");
68497
68497
  let docVersion = metaMap.get("version");
@@ -70815,12 +70815,12 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70815
70815
  })(SectionType || {});
70816
70816
  const DEFAULT_PARAGRAPH_SECTION_TYPE = "nextPage";
70817
70817
  const DEFAULT_BODY_SECTION_TYPE = "continuous";
70818
- const TWIPS_PER_INCH$3 = 1440;
70819
- const PX_PER_INCH$2 = 96;
70818
+ const TWIPS_PER_INCH$4 = 1440;
70819
+ const PX_PER_INCH$3 = 96;
70820
70820
  const DEFAULT_COLUMN_GAP_INCHES = 0.5;
70821
70821
  function twipsToPixels$1(twips) {
70822
70822
  const n = Number(twips);
70823
- return Number.isFinite(n) ? n / TWIPS_PER_INCH$3 * PX_PER_INCH$2 : void 0;
70823
+ return Number.isFinite(n) ? n / TWIPS_PER_INCH$4 * PX_PER_INCH$3 : void 0;
70824
70824
  }
70825
70825
  function parseColumnCount(rawValue) {
70826
70826
  if (rawValue == null) return 1;
@@ -70830,7 +70830,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70830
70830
  function parseColumnGap(gapTwips) {
70831
70831
  if (gapTwips == null) return DEFAULT_COLUMN_GAP_INCHES;
70832
70832
  const gap = Number(gapTwips);
70833
- return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$3 : DEFAULT_COLUMN_GAP_INCHES;
70833
+ return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$4 : DEFAULT_COLUMN_GAP_INCHES;
70834
70834
  }
70835
70835
  function extractNormalizedMargins(attrs) {
70836
70836
  const sectionMargins = attrs.sectionMargins;
@@ -70914,7 +70914,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
70914
70914
  const gapInches = parseColumnGap(cols.attributes["w:space"]);
70915
70915
  return {
70916
70916
  count,
70917
- gap: gapInches * PX_PER_INCH$2
70917
+ gap: gapInches * PX_PER_INCH$3
70918
70918
  };
70919
70919
  }
70920
70920
  function extractVerticalAlign(elements) {
@@ -71150,8 +71150,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
71150
71150
  }
71151
71151
  return ranges;
71152
71152
  }
71153
- const TWIPS_PER_INCH$2 = 1440;
71154
- const PX_PER_INCH$1 = 96;
71153
+ const TWIPS_PER_INCH$3 = 1440;
71154
+ const PX_PER_INCH$2 = 96;
71155
71155
  const PX_PER_PT = 96 / 72;
71156
71156
  SectionType.NEXT_PAGE;
71157
71157
  SectionType.CONTINUOUS;
@@ -71290,7 +71290,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
71290
71290
  }
71291
71291
  return filtered;
71292
71292
  };
71293
- const twipsToPx$1 = (value) => value / TWIPS_PER_INCH$2 * PX_PER_INCH$1;
71293
+ const twipsToPx$2 = (value) => value / TWIPS_PER_INCH$3 * PX_PER_INCH$2;
71294
71294
  const ptToPx = (pt) => {
71295
71295
  if (pt == null || !Number.isFinite(pt)) return void 0;
71296
71296
  return pt * PX_PER_PT;
@@ -72800,8 +72800,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72800
72800
  const beforeAutospacing = toBooleanFlag(source.beforeAutospacing ?? source.beforeAutoSpacing);
72801
72801
  const afterAutospacing = toBooleanFlag(source.afterAutospacing ?? source.afterAutoSpacing);
72802
72802
  const contextualSpacing = toBooleanFlag(source.contextualSpacing);
72803
- const before = beforeRaw != null ? twipsToPx$1(beforeRaw) : pickNumber(source.lineSpaceBefore);
72804
- const after = afterRaw != null ? twipsToPx$1(afterRaw) : pickNumber(source.lineSpaceAfter);
72803
+ const before = beforeRaw != null ? twipsToPx$2(beforeRaw) : pickNumber(source.lineSpaceBefore);
72804
+ const after = afterRaw != null ? twipsToPx$2(afterRaw) : pickNumber(source.lineSpaceAfter);
72805
72805
  const line = normalizeLineValue(lineRaw, lineRule);
72806
72806
  if (before != null) spacing.before = before;
72807
72807
  if (after != null) spacing.after = after;
@@ -72831,9 +72831,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72831
72831
  if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
72832
72832
  return value;
72833
72833
  }
72834
- return twipsToPx$1(value);
72834
+ return twipsToPx$2(value);
72835
72835
  }
72836
- return twipsToPx$1(value);
72836
+ return twipsToPx$2(value);
72837
72837
  };
72838
72838
  const normalizeLineRule = (value) => {
72839
72839
  if (value === "auto" || value === "exact" || value === "atLeast") {
@@ -72870,7 +72870,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
72870
72870
  if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
72871
72871
  return num;
72872
72872
  }
72873
- return twipsToPx$1(Number(num));
72873
+ return twipsToPx$2(Number(num));
72874
72874
  };
72875
72875
  const left2 = convert2(pickNumber(source.left));
72876
72876
  const right2 = convert2(pickNumber(source.right));
@@ -73450,9 +73450,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
73450
73450
  const family = run2.fontFamily ?? "Times New Roman";
73451
73451
  return `${style2}${weight}${size2} ${family}`;
73452
73452
  };
73453
- const TWIPS_PER_INCH$1 = 1440;
73453
+ const TWIPS_PER_INCH$2 = 1440;
73454
73454
  const PIXELS_PER_INCH = 96;
73455
- const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$1 / PIXELS_PER_INCH);
73455
+ const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$2 / PIXELS_PER_INCH);
73456
73456
  const PIXELS_PER_TWIP = 1 / TWIPS_PER_PIXEL;
73457
73457
  const toFiniteNumber = (value) => {
73458
73458
  if (value == null) return null;
@@ -74476,7 +74476,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74476
74476
  }
74477
74477
  const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
74478
74478
  if (spacingTwips != null && Number.isFinite(spacingTwips)) {
74479
- run2.letterSpacing = twipsToPx$1(spacingTwips);
74479
+ run2.letterSpacing = twipsToPx$2(spacingTwips);
74480
74480
  }
74481
74481
  return Object.keys(run2).length ? run2 : void 0;
74482
74482
  };
@@ -74700,10 +74700,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74700
74700
  const convertIndentTwipsToPx = (indent2) => {
74701
74701
  if (!indent2) return void 0;
74702
74702
  const result = {};
74703
- if (isFiniteNumber(indent2.left)) result.left = twipsToPx$1(Number(indent2.left));
74704
- if (isFiniteNumber(indent2.right)) result.right = twipsToPx$1(Number(indent2.right));
74705
- if (isFiniteNumber(indent2.firstLine)) result.firstLine = twipsToPx$1(Number(indent2.firstLine));
74706
- if (isFiniteNumber(indent2.hanging)) result.hanging = twipsToPx$1(Number(indent2.hanging));
74703
+ const toNum = (v2) => {
74704
+ if (typeof v2 === "string" && v2.trim() !== "" && isFinite(Number(v2))) return Number(v2);
74705
+ if (isFiniteNumber(v2)) return Number(v2);
74706
+ return void 0;
74707
+ };
74708
+ const left2 = toNum(indent2.left);
74709
+ const right2 = toNum(indent2.right);
74710
+ const firstLine = toNum(indent2.firstLine);
74711
+ const hanging = toNum(indent2.hanging);
74712
+ if (left2 != null) result.left = twipsToPx$2(left2);
74713
+ if (right2 != null) result.right = twipsToPx$2(right2);
74714
+ if (firstLine != null) result.firstLine = twipsToPx$2(firstLine);
74715
+ if (hanging != null) result.hanging = twipsToPx$2(hanging);
74707
74716
  return Object.keys(result).length > 0 ? result : void 0;
74708
74717
  };
74709
74718
  const toAdapterNumberingProps = (value) => {
@@ -74728,7 +74737,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
74728
74737
  if (!stop || typeof stop.pos !== "number") continue;
74729
74738
  const alignment2 = normalizeResolvedTabAlignment(stop.val);
74730
74739
  if (!alignment2) continue;
74731
- const position2 = twipsToPx$1(stop.pos);
74740
+ const position2 = twipsToPx$2(stop.pos);
74732
74741
  if (!Number.isFinite(position2)) continue;
74733
74742
  const resolvedStop = {
74734
74743
  position: position2,
@@ -75169,9 +75178,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75169
75178
  const vAnchor = asString2(framePr["w:vAnchor"] ?? framePr.vAnchor);
75170
75179
  if (vAnchor) frame.vAnchor = vAnchor;
75171
75180
  const xTwips = pickNumber(framePr["w:x"] ?? framePr.x);
75172
- if (xTwips != null) frame.x = twipsToPx$1(xTwips);
75181
+ if (xTwips != null) frame.x = twipsToPx$2(xTwips);
75173
75182
  const yTwips = pickNumber(framePr["w:y"] ?? framePr.y);
75174
- if (yTwips != null) frame.y = twipsToPx$1(yTwips);
75183
+ if (yTwips != null) frame.y = twipsToPx$2(yTwips);
75175
75184
  if (Object.keys(frame).length > 0) {
75176
75185
  paragraphAttrs.frame = frame;
75177
75186
  }
@@ -75259,7 +75268,29 @@ Please report this to https://github.com/markedjs/marked.`, e) {
75259
75268
  }
75260
75269
  }
75261
75270
  }
75262
- const wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
75271
+ let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
75272
+ if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
75273
+ const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
75274
+ const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
75275
+ if (firstLinePx > 0) {
75276
+ wordLayout = {
75277
+ // Treat as first-line-indent mode: text starts after the marker+firstLine offset.
75278
+ firstLineIndentMode: true,
75279
+ textStartPx: firstLinePx
75280
+ };
75281
+ }
75282
+ }
75283
+ if (wordLayout && (!wordLayout.textStartPx || !Number.isFinite(wordLayout.textStartPx)) && enrichedNumberingProps.resolvedLevelIndent) {
75284
+ const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
75285
+ const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
75286
+ if (firstLinePx > 0) {
75287
+ wordLayout = {
75288
+ ...wordLayout,
75289
+ firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
75290
+ textStartPx: firstLinePx
75291
+ };
75292
+ }
75293
+ }
75263
75294
  if (wordLayout) {
75264
75295
  if (wordLayout.marker) {
75265
75296
  if (listRendering?.markerText) {
@@ -77170,7 +77201,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77170
77201
  const entry = value;
77171
77202
  if (typeof entry.value !== "number") return void 0;
77172
77203
  if (!entry.type || entry.type === "px" || entry.type === "pixel") return entry.value;
77173
- if (entry.type === "dxa") return twipsToPx$1(entry.value);
77204
+ if (entry.type === "dxa") return twipsToPx$2(entry.value);
77174
77205
  return void 0;
77175
77206
  };
77176
77207
  const normalizeTableWidth = (value) => {
@@ -77182,7 +77213,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77182
77213
  return { width: raw, type: measurement.type ?? "px" };
77183
77214
  }
77184
77215
  if (measurement.type === "dxa") {
77185
- return { width: twipsToPx$1(raw), type: "px" };
77216
+ return { width: twipsToPx$2(raw), type: "px" };
77186
77217
  }
77187
77218
  return { width: raw, type: measurement.type };
77188
77219
  };
@@ -77210,13 +77241,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77210
77241
  const line = parseIntSafe$1(attrs["w:line"]);
77211
77242
  const rawLineRule = attrs["w:lineRule"];
77212
77243
  const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
77213
- if (before != null) spacing.before = twipsToPx$1(before);
77214
- if (after != null) spacing.after = twipsToPx$1(after);
77244
+ if (before != null) spacing.before = twipsToPx$2(before);
77245
+ if (after != null) spacing.after = twipsToPx$2(after);
77215
77246
  if (line != null) {
77216
77247
  if (lineRule === "auto") {
77217
77248
  spacing.line = line / 240;
77218
77249
  } else {
77219
- spacing.line = twipsToPx$1(line);
77250
+ spacing.line = twipsToPx$2(line);
77220
77251
  }
77221
77252
  }
77222
77253
  if (lineRule) spacing.lineRule = lineRule;
@@ -77242,7 +77273,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77242
77273
  if (rawValue == null) return void 0;
77243
77274
  const rawRule = heightObj.rule ?? heightObj.hRule;
77244
77275
  const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
77245
- const valuePx = twipsToPx$1(rawValue);
77276
+ const valuePx = twipsToPx$2(rawValue);
77246
77277
  return {
77247
77278
  value: valuePx,
77248
77279
  rule
@@ -77492,10 +77523,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77492
77523
  anchor.alignV = floatingProps.tblpYSpec;
77493
77524
  }
77494
77525
  if (floatingProps.tblpX !== void 0) {
77495
- anchor.offsetH = twipsToPx$1(floatingProps.tblpX);
77526
+ anchor.offsetH = twipsToPx$2(floatingProps.tblpX);
77496
77527
  }
77497
77528
  if (floatingProps.tblpY !== void 0) {
77498
- anchor.offsetV = twipsToPx$1(floatingProps.tblpY);
77529
+ anchor.offsetV = twipsToPx$2(floatingProps.tblpY);
77499
77530
  }
77500
77531
  const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
77501
77532
  const wrap2 = {
@@ -77506,16 +77537,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
77506
77537
  };
77507
77538
  if (hasDistances) {
77508
77539
  if (floatingProps.topFromText !== void 0) {
77509
- wrap2.distTop = twipsToPx$1(floatingProps.topFromText);
77540
+ wrap2.distTop = twipsToPx$2(floatingProps.topFromText);
77510
77541
  }
77511
77542
  if (floatingProps.bottomFromText !== void 0) {
77512
- wrap2.distBottom = twipsToPx$1(floatingProps.bottomFromText);
77543
+ wrap2.distBottom = twipsToPx$2(floatingProps.bottomFromText);
77513
77544
  }
77514
77545
  if (floatingProps.leftFromText !== void 0) {
77515
- wrap2.distLeft = twipsToPx$1(floatingProps.leftFromText);
77546
+ wrap2.distLeft = twipsToPx$2(floatingProps.leftFromText);
77516
77547
  }
77517
77548
  if (floatingProps.rightFromText !== void 0) {
77518
- wrap2.distRight = twipsToPx$1(floatingProps.rightFromText);
77549
+ wrap2.distRight = twipsToPx$2(floatingProps.rightFromText);
77519
77550
  }
77520
77551
  }
77521
77552
  return { anchor, wrap: wrap2 };
@@ -84688,7 +84719,7 @@ ${l}
84688
84719
  }
84689
84720
  const runsForLine = sliceRunsForLine(block, line);
84690
84721
  const trackedConfig = this.resolveTrackedChangesConfig(block);
84691
- 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);
84722
+ 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);
84692
84723
  if (runsForLine.length === 0) {
84693
84724
  const span = this.doc.createElement("span");
84694
84725
  span.innerHTML = "&nbsp;";
@@ -84735,19 +84766,7 @@ ${l}
84735
84766
  });
84736
84767
  }
84737
84768
  const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
84738
- const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
84739
- const shouldJustify = !skipJustify && effectiveAlignment === "justify" && !hasExplicitPositioning;
84740
- if (shouldJustify) {
84741
- const spaceCount = textSlices.reduce(
84742
- (sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
84743
- 0
84744
- );
84745
- const slack = availableWidth - line.width;
84746
- if (spaceCount > 0 && slack !== 0) {
84747
- const spacingPerSpace = slack / spaceCount;
84748
- el.style.wordSpacing = `${spacingPerSpace}px`;
84749
- }
84750
- }
84769
+ availableWidthOverride ?? line.maxWidth ?? line.width;
84751
84770
  if (hasExplicitPositioning && line.segments) {
84752
84771
  const paraIndent = block.attrs?.indent;
84753
84772
  const indentLeft = paraIndent?.left ?? 0;
@@ -90069,7 +90088,13 @@ ${l}
90069
90088
  return ctx$2;
90070
90089
  }
90071
90090
  function isTextRun(run2) {
90072
- return run2.kind === "tab" ? false : true;
90091
+ if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
90092
+ return false;
90093
+ }
90094
+ if ("src" in run2) {
90095
+ return false;
90096
+ }
90097
+ return true;
90073
90098
  }
90074
90099
  function fontString(run2) {
90075
90100
  const textRun = isTextRun(run2) ? run2 : null;
@@ -90082,6 +90107,42 @@ ${l}
90082
90107
  function runText(run2) {
90083
90108
  return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
90084
90109
  }
90110
+ const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
90111
+ const TWIPS_PER_INCH$1 = 1440;
90112
+ const PX_PER_INCH$1 = 96;
90113
+ const TWIPS_PER_PX$1 = TWIPS_PER_INCH$1 / PX_PER_INCH$1;
90114
+ const TAB_EPSILON$1 = 0.1;
90115
+ const WIDTH_FUDGE_PX = 0.5;
90116
+ const twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$1;
90117
+ const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
90118
+ const buildTabStopsPx$1 = (indent2, tabs, tabIntervalTwips) => {
90119
+ const paragraphIndentTwips = {
90120
+ left: pxToTwips$1(Math.max(0, indent2?.left ?? 0)),
90121
+ right: pxToTwips$1(Math.max(0, indent2?.right ?? 0)),
90122
+ firstLine: pxToTwips$1(Math.max(0, indent2?.firstLine ?? 0)),
90123
+ hanging: pxToTwips$1(Math.max(0, indent2?.hanging ?? 0))
90124
+ };
90125
+ const stops = computeTabStops$1({
90126
+ explicitStops: tabs ?? [],
90127
+ defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$1,
90128
+ paragraphIndent: paragraphIndentTwips
90129
+ });
90130
+ return stops.map((stop) => ({
90131
+ pos: twipsToPx$1(stop.pos),
90132
+ val: stop.val,
90133
+ leader: stop.leader
90134
+ }));
90135
+ };
90136
+ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
90137
+ let index2 = startIndex;
90138
+ while (index2 < tabStops.length && tabStops[index2].pos <= currentX + TAB_EPSILON$1) {
90139
+ index2 += 1;
90140
+ }
90141
+ if (index2 < tabStops.length) {
90142
+ return { target: tabStops[index2].pos, nextIndex: index2 + 1 };
90143
+ }
90144
+ return { target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$1), nextIndex: index2 };
90145
+ };
90085
90146
  function measureRunSliceWidth(run2, fromChar, toChar) {
90086
90147
  const context = getCtx();
90087
90148
  const text2 = runText(run2).slice(fromChar, toChar);
@@ -90105,13 +90166,38 @@ ${l}
90105
90166
  return maxSize2 * 1.2;
90106
90167
  }
90107
90168
  function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
90169
+ if (!Number.isFinite(maxWidth) || maxWidth <= 0) {
90170
+ throw new Error(`remeasureParagraph: maxWidth must be a positive number, got ${maxWidth}`);
90171
+ }
90172
+ if (!Number.isFinite(firstLineIndent)) {
90173
+ throw new Error(`remeasureParagraph: firstLineIndent must be a finite number, got ${firstLineIndent}`);
90174
+ }
90175
+ if (!block) {
90176
+ throw new Error("remeasureParagraph: block must be defined");
90177
+ }
90178
+ if (!Array.isArray(block.runs)) {
90179
+ throw new Error(`remeasureParagraph: block.runs must be an array, got ${typeof block.runs}`);
90180
+ }
90108
90181
  const runs2 = block.runs ?? [];
90109
90182
  const lines = [];
90183
+ const attrs = block.attrs;
90184
+ const indent2 = attrs?.indent;
90185
+ const wordLayout = attrs?.wordLayout;
90186
+ const indentLeft = Math.max(0, indent2?.left ?? 0);
90187
+ const indentRight = Math.max(0, indent2?.right ?? 0);
90188
+ const indentFirstLine = Math.max(0, indent2?.firstLine ?? 0);
90189
+ const indentHanging = Math.max(0, indent2?.hanging ?? 0);
90190
+ const rawFirstLineOffset = Math.max(0, firstLineIndent || indentFirstLine - indentHanging);
90191
+ const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
90192
+ const textStartPx = wordLayout?.textStartPx;
90193
+ const treatAsHanging = textStartPx && indentLeft === 0 && indentHanging === 0;
90194
+ const firstLineWidth = typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - textStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
90195
+ const tabStops = buildTabStopsPx$1(indent2, attrs?.tabs, attrs?.tabIntervalTwips);
90110
90196
  let currentRun = 0;
90111
90197
  let currentChar = 0;
90112
90198
  while (currentRun < runs2.length) {
90113
90199
  const isFirstLine = lines.length === 0;
90114
- const effectiveMaxWidth = isFirstLine ? maxWidth - firstLineIndent : maxWidth;
90200
+ const effectiveMaxWidth = Math.max(1, isFirstLine ? firstLineWidth : contentWidth);
90115
90201
  const startRun = currentRun;
90116
90202
  const startChar = currentChar;
90117
90203
  let width = 0;
@@ -90119,13 +90205,26 @@ ${l}
90119
90205
  let lastBreakChar = -1;
90120
90206
  let endRun = currentRun;
90121
90207
  let endChar = currentChar;
90208
+ let tabStopCursor = 0;
90209
+ let didBreakInThisLine = false;
90122
90210
  for (let r2 = currentRun; r2 < runs2.length; r2 += 1) {
90123
90211
  const run2 = runs2[r2];
90212
+ if (run2.kind === "tab") {
90213
+ const { target, nextIndex } = getNextTabStopPx$1(width, tabStops, tabStopCursor);
90214
+ const tabAdvance = Math.max(0, target - width);
90215
+ width += tabAdvance;
90216
+ tabStopCursor = nextIndex;
90217
+ endRun = r2;
90218
+ endChar = 1;
90219
+ lastBreakRun = r2;
90220
+ lastBreakChar = 1;
90221
+ continue;
90222
+ }
90124
90223
  const text2 = runText(run2);
90125
90224
  const start2 = r2 === currentRun ? currentChar : 0;
90126
90225
  for (let c2 = start2; c2 < text2.length; c2 += 1) {
90127
90226
  const w2 = measureRunSliceWidth(run2, c2, c2 + 1);
90128
- if (width + w2 > effectiveMaxWidth && width > 0) {
90227
+ if (width + w2 > effectiveMaxWidth - WIDTH_FUDGE_PX && width > 0) {
90129
90228
  if (lastBreakRun >= 0) {
90130
90229
  endRun = lastBreakRun;
90131
90230
  endChar = lastBreakChar;
@@ -90133,6 +90232,7 @@ ${l}
90133
90232
  endRun = r2;
90134
90233
  endChar = c2;
90135
90234
  }
90235
+ didBreakInThisLine = true;
90136
90236
  break;
90137
90237
  }
90138
90238
  width += w2;
@@ -90144,9 +90244,7 @@ ${l}
90144
90244
  lastBreakChar = c2 + 1;
90145
90245
  }
90146
90246
  }
90147
- if (endRun !== r2 || endRun === r2 && (r2 === lastBreakRun ? endChar === lastBreakChar : false)) {
90148
- break;
90149
- }
90247
+ if (didBreakInThisLine) break;
90150
90248
  }
90151
90249
  if (startRun === endRun && startChar === endChar) {
90152
90250
  endRun = startRun;
@@ -90160,11 +90258,15 @@ ${l}
90160
90258
  width,
90161
90259
  ascent: 0,
90162
90260
  descent: 0,
90163
- lineHeight: lineHeightForRuns(runs2, startRun, endRun)
90261
+ lineHeight: lineHeightForRuns(runs2, startRun, endRun),
90262
+ maxWidth: effectiveMaxWidth
90164
90263
  };
90165
90264
  lines.push(line);
90166
90265
  currentRun = endRun;
90167
90266
  currentChar = endChar;
90267
+ if (currentRun >= runs2.length) {
90268
+ break;
90269
+ }
90168
90270
  if (currentChar >= runText(runs2[currentRun]).length) {
90169
90271
  currentRun += 1;
90170
90272
  currentChar = 0;
@@ -92377,7 +92479,7 @@ ${l}
92377
92479
  async function measureParagraphBlock(block, maxWidth) {
92378
92480
  const ctx2 = getCanvasContext();
92379
92481
  const wordLayout = block.attrs?.wordLayout;
92380
- const WIDTH_FUDGE_PX = 0.5;
92482
+ const WIDTH_FUDGE_PX2 = 0.5;
92381
92483
  const lines = [];
92382
92484
  const indent2 = block.attrs?.indent;
92383
92485
  const spacing = block.attrs?.spacing;
@@ -92393,7 +92495,8 @@ ${l}
92393
92495
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
92394
92496
  let initialAvailableWidth;
92395
92497
  const textStartPx = wordLayout?.textStartPx;
92396
- if (typeof textStartPx === "number" && textStartPx > indentLeft) {
92498
+ const treatAsHanging = isWordLayoutList && indentLeft === 0 && hanging === 0 && typeof textStartPx === "number";
92499
+ if (typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging) {
92397
92500
  initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
92398
92501
  } else {
92399
92502
  initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
@@ -92440,6 +92543,21 @@ ${l}
92440
92543
  totalHeight: metrics.lineHeight
92441
92544
  };
92442
92545
  }
92546
+ const isListLike = Boolean(block.attrs?.numId || wordLayout?.marker);
92547
+ if (isListLike) {
92548
+ console.log(
92549
+ "[measureParagraph][list]",
92550
+ JSON.stringify({
92551
+ blockId: block.id,
92552
+ maxWidth,
92553
+ indentLeft,
92554
+ indentRight,
92555
+ textStartPx: textStartPx ?? null,
92556
+ firstLineOffset: firstLineOffset ?? null,
92557
+ initialAvailableWidth
92558
+ })
92559
+ );
92560
+ }
92443
92561
  let currentLine = null;
92444
92562
  const getEffectiveWidth = (baseWidth) => {
92445
92563
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
@@ -92847,7 +92965,7 @@ ${l}
92847
92965
  };
92848
92966
  } else {
92849
92967
  const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
92850
- if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
92968
+ if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
92851
92969
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
92852
92970
  const { spaceCount: _sc, ...lineBase } = currentLine;
92853
92971
  const completedLine = {
@@ -92913,7 +93031,7 @@ ${l}
92913
93031
  };
92914
93032
  } else {
92915
93033
  const boundarySpacing2 = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
92916
- if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0) {
93034
+ if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
92917
93035
  const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
92918
93036
  const { spaceCount: _sc, ...lineBase } = currentLine;
92919
93037
  const completedLine = { ...lineBase, ...metrics };
@@ -92971,7 +93089,7 @@ ${l}
92971
93089
  const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
92972
93090
  const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
92973
93091
  const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
92974
- const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX, font, ctx2, run2);
93092
+ const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
92975
93093
  let chunkCharOffset = wordStartChar;
92976
93094
  for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
92977
93095
  const chunk = chunks[chunkIndex];
@@ -92993,7 +93111,7 @@ ${l}
92993
93111
  });
92994
93112
  if (isLastChunk) {
92995
93113
  const ls = run2.letterSpacing ?? 0;
92996
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
93114
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
92997
93115
  currentLine.toChar = wordEndWithSpace;
92998
93116
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
92999
93117
  charPosInRun = wordEndWithSpace;
@@ -93025,7 +93143,7 @@ ${l}
93025
93143
  spaceCount: 0
93026
93144
  };
93027
93145
  const ls = run2.letterSpacing ?? 0;
93028
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
93146
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
93029
93147
  currentLine.toChar = wordEndWithSpace;
93030
93148
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
93031
93149
  charPosInRun = wordEndWithSpace;
@@ -93067,7 +93185,7 @@ ${l}
93067
93185
  spaceCount: 0
93068
93186
  };
93069
93187
  const ls = run2.letterSpacing ?? 0;
93070
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
93188
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
93071
93189
  currentLine.toChar = wordEndWithSpace;
93072
93190
  currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
93073
93191
  charPosInRun = wordEndWithSpace;
@@ -93082,7 +93200,7 @@ ${l}
93082
93200
  const justifyAlignment = block.attrs?.alignment === "justify";
93083
93201
  const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
93084
93202
  (isLastWord ? 0 : run2.letterSpacing ?? 0);
93085
- const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX;
93203
+ const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX2;
93086
93204
  let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
93087
93205
  let compressedWidth = null;
93088
93206
  if (shouldBreak && justifyAlignment) {
@@ -93127,7 +93245,7 @@ ${l}
93127
93245
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
93128
93246
  spaceCount: 0
93129
93247
  };
93130
- if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
93248
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
93131
93249
  currentLine.toChar = wordEndWithSpace;
93132
93250
  currentLine.width = roundValue(currentLine.width + spaceWidth + (run2.letterSpacing ?? 0));
93133
93251
  charPosInRun = wordEndWithSpace;
@@ -93137,7 +93255,7 @@ ${l}
93137
93255
  }
93138
93256
  } else {
93139
93257
  currentLine.toRun = runIndex;
93140
- if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX) {
93258
+ if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2) {
93141
93259
  currentLine.toChar = wordEndNoSpace;
93142
93260
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
93143
93261
  currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
@@ -151985,7 +152103,7 @@ ${style2}
151985
152103
  this.config.colors = shuffleArray(this.config.colors);
151986
152104
  this.userColorMap = /* @__PURE__ */ new Map();
151987
152105
  this.colorIndex = 0;
151988
- this.version = "1.0.0-beta.96";
152106
+ this.version = "1.0.0-beta.97";
151989
152107
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
151990
152108
  this.superdocId = config2.superdocId || v4();
151991
152109
  this.colors = this.config.colors;
@@ -154457,7 +154575,7 @@ ${style2}
154457
154575
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
154458
154576
  );
154459
154577
  }
154460
- const indexLfdM_gm7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
154578
+ const indexPvlqsxge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
154461
154579
  __proto__: null,
154462
154580
  unified
154463
154581
  }, Symbol.toStringTag, { value: "Module" }));