@harbour-enterprises/superdoc 2.0.0-next.2 → 2.0.0-next.4
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.
- package/dist/chunks/{PdfViewer-C4xgIIbF.es.js → PdfViewer-D3PZ6zBK.es.js} +1 -1
- package/dist/chunks/{PdfViewer-CWO98Qls.cjs → PdfViewer-DW9Jjot9.cjs} +1 -1
- package/dist/chunks/{index-s9GUR_Gc.es.js → index-NcWPPbrQ.es.js} +3 -3
- package/dist/chunks/{index-BY-3Vl72.cjs → index-VXujz1iS.cjs} +3 -3
- package/dist/chunks/{index-BqPa6D4q-Dulj8zfc.cjs → index-YoL4XmHs-DgX6YU__.cjs} +1 -1
- package/dist/chunks/{index-BqPa6D4q-8U4x8RP6.es.js → index-YoL4XmHs-DnigArXx.es.js} +1 -1
- package/dist/chunks/{super-editor.es-BM-ulSRj.cjs → super-editor.es-CeYiIfGN.cjs} +642 -135
- package/dist/chunks/{super-editor.es-CT28vUbx.es.js → super-editor.es-o4f9FxT-.es.js} +642 -135
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-CDlAWcRu.js → converter-Cv-PWHhI.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-B2VXuf8h.js → docx-zipper-aIZi_y1u.js} +1 -1
- package/dist/super-editor/chunks/{editor-B4Q_tNET.js → editor-R1nZ8Y4J.js} +643 -136
- package/dist/super-editor/chunks/{index-BqPa6D4q.js → index-YoL4XmHs.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-BD-lDCLr.js → toolbar-DTrmhth_.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +644 -137
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -42428,7 +42428,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
42428
42428
|
static getStoredSuperdocVersion(docx) {
|
|
42429
42429
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42430
42430
|
}
|
|
42431
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.
|
|
42431
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.4") {
|
|
42432
42432
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42433
42433
|
}
|
|
42434
42434
|
/**
|
|
@@ -68384,7 +68384,7 @@ ${err.toString()}`);
|
|
|
68384
68384
|
const shouldSkipNodeView = (editor) => {
|
|
68385
68385
|
return isHeadless(editor);
|
|
68386
68386
|
};
|
|
68387
|
-
const summaryVersion = "2.0.0-next.
|
|
68387
|
+
const summaryVersion = "2.0.0-next.4";
|
|
68388
68388
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
68389
68389
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
68390
68390
|
function mapAttributes(attrs) {
|
|
@@ -69173,7 +69173,7 @@ ${err.toString()}`);
|
|
|
69173
69173
|
{ default: remarkStringify2 },
|
|
69174
69174
|
{ default: remarkGfm2 }
|
|
69175
69175
|
] = await Promise.all([
|
|
69176
|
-
Promise.resolve().then(() =>
|
|
69176
|
+
Promise.resolve().then(() => indexYoL4XmHs),
|
|
69177
69177
|
Promise.resolve().then(() => indexDRCvimau),
|
|
69178
69178
|
Promise.resolve().then(() => indexC_x_N6Uh),
|
|
69179
69179
|
Promise.resolve().then(() => indexD_sWOSiG),
|
|
@@ -69378,7 +69378,7 @@ ${err.toString()}`);
|
|
|
69378
69378
|
* Process collaboration migrations
|
|
69379
69379
|
*/
|
|
69380
69380
|
processCollaborationMigrations() {
|
|
69381
|
-
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.
|
|
69381
|
+
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.4");
|
|
69382
69382
|
if (!this.options.ydoc) return;
|
|
69383
69383
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
69384
69384
|
let docVersion = metaMap.get("version");
|
|
@@ -76630,7 +76630,7 @@ ${l}
|
|
|
76630
76630
|
return true;
|
|
76631
76631
|
}
|
|
76632
76632
|
const LIST_MARKER_GAP$2 = 8;
|
|
76633
|
-
const DEFAULT_TAB_INTERVAL_PX$
|
|
76633
|
+
const DEFAULT_TAB_INTERVAL_PX$2 = 48;
|
|
76634
76634
|
const DEFAULT_PAGE_HEIGHT_PX = 1056;
|
|
76635
76635
|
const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
|
|
76636
76636
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
@@ -77557,6 +77557,7 @@ ${l}
|
|
|
77557
77557
|
const block = lookup2.block;
|
|
77558
77558
|
const measure = lookup2.measure;
|
|
77559
77559
|
const wordLayout = isMinimalWordLayout(block.attrs?.wordLayout) ? block.attrs.wordLayout : void 0;
|
|
77560
|
+
const alignment2 = block.attrs?.alignment;
|
|
77560
77561
|
const fragmentEl = this.doc.createElement("div");
|
|
77561
77562
|
fragmentEl.classList.add(CLASS_NAMES$1.fragment);
|
|
77562
77563
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
@@ -77635,7 +77636,7 @@ ${l}
|
|
|
77635
77636
|
const textStart = paraIndentLeft + firstLine;
|
|
77636
77637
|
tabWidth = textStart - currentPos;
|
|
77637
77638
|
if (tabWidth <= 0) {
|
|
77638
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
77639
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
77639
77640
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
77640
77641
|
tabWidth = LIST_MARKER_GAP$2;
|
|
77641
77642
|
}
|
|
@@ -77662,6 +77663,21 @@ ${l}
|
|
|
77662
77663
|
let availableWidthOverride = line.maxWidth != null ? Math.min(line.maxWidth, fallbackAvailableWidth) : fallbackAvailableWidth;
|
|
77663
77664
|
if (index2 === 0 && listFirstLineMarkerTabWidth != null) {
|
|
77664
77665
|
availableWidthOverride = fragment.width - listFirstLineMarkerTabWidth - Math.max(0, paraIndentRight);
|
|
77666
|
+
if (alignment2 === "justify" || alignment2 === "both") {
|
|
77667
|
+
console.log(
|
|
77668
|
+
"[justify-debug][painter-firstline-available]",
|
|
77669
|
+
JSON.stringify({
|
|
77670
|
+
blockId: block.id,
|
|
77671
|
+
fragmentWidth: fragment.width,
|
|
77672
|
+
markerTabWidth: listFirstLineMarkerTabWidth,
|
|
77673
|
+
paraIndentRight,
|
|
77674
|
+
availableWidthOverride,
|
|
77675
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
77676
|
+
lineWidth: line.width,
|
|
77677
|
+
lineNaturalWidth: line.naturalWidth ?? null
|
|
77678
|
+
})
|
|
77679
|
+
);
|
|
77680
|
+
}
|
|
77665
77681
|
}
|
|
77666
77682
|
const isLastLineOfFragment = index2 === lines.length - 1;
|
|
77667
77683
|
const isLastLineOfParagraph = isLastLineOfFragment && !fragment.continuesOnNext;
|
|
@@ -77787,7 +77803,7 @@ ${l}
|
|
|
77787
77803
|
const textStart = paraIndentLeft + firstLine;
|
|
77788
77804
|
tabWidth = textStart - currentPos;
|
|
77789
77805
|
if (tabWidth <= 0) {
|
|
77790
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
77806
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
77791
77807
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
77792
77808
|
tabWidth = LIST_MARKER_GAP$2;
|
|
77793
77809
|
}
|
|
@@ -79321,6 +79337,23 @@ ${l}
|
|
|
79321
79337
|
if (spacingPerSpace !== 0) {
|
|
79322
79338
|
el.style.wordSpacing = `${spacingPerSpace}px`;
|
|
79323
79339
|
}
|
|
79340
|
+
if (justifyShouldApply && spacingPerSpace < 0) {
|
|
79341
|
+
console.log(
|
|
79342
|
+
"[justify-debug][painter-wordspacing-negative]",
|
|
79343
|
+
JSON.stringify({
|
|
79344
|
+
blockId: block.id,
|
|
79345
|
+
lineIndex: lineIndex ?? null,
|
|
79346
|
+
alignment: alignment2 ?? null,
|
|
79347
|
+
availableWidth,
|
|
79348
|
+
lineWidth,
|
|
79349
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
79350
|
+
lineNaturalWidth: line.naturalWidth ?? null,
|
|
79351
|
+
spaceCount,
|
|
79352
|
+
hasExplicitPositioning: Boolean(hasExplicitPositioning),
|
|
79353
|
+
skipJustify: Boolean(skipJustify)
|
|
79354
|
+
})
|
|
79355
|
+
);
|
|
79356
|
+
}
|
|
79324
79357
|
if (hasExplicitPositioning && line.segments) {
|
|
79325
79358
|
const paraIndent = block.attrs?.indent;
|
|
79326
79359
|
const indentLeft = paraIndent?.left ?? 0;
|
|
@@ -81514,6 +81547,28 @@ ${l}
|
|
|
81514
81547
|
const TAB_CHAR_LENGTH = 1;
|
|
81515
81548
|
const SPACE_CHARS = SPACE_CHARS$1;
|
|
81516
81549
|
const isTabRun$1 = (run2) => run2?.kind === "tab";
|
|
81550
|
+
const isWordChar$3 = (char) => {
|
|
81551
|
+
if (!char) return false;
|
|
81552
|
+
const code2 = char.charCodeAt(0);
|
|
81553
|
+
return code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 90 || code2 >= 97 && code2 <= 122 || char === "'";
|
|
81554
|
+
};
|
|
81555
|
+
const capitalizeText$2 = (text2) => {
|
|
81556
|
+
if (!text2) return text2;
|
|
81557
|
+
let result = "";
|
|
81558
|
+
for (let i2 = 0; i2 < text2.length; i2 += 1) {
|
|
81559
|
+
const prevChar = i2 > 0 ? text2[i2 - 1] : "";
|
|
81560
|
+
const ch = text2[i2];
|
|
81561
|
+
result += isWordChar$3(ch) && !isWordChar$3(prevChar) ? ch.toUpperCase() : ch;
|
|
81562
|
+
}
|
|
81563
|
+
return result;
|
|
81564
|
+
};
|
|
81565
|
+
const applyTextTransform$2 = (text2, transform) => {
|
|
81566
|
+
if (!text2 || !transform || transform === "none") return text2;
|
|
81567
|
+
if (transform === "uppercase") return text2.toUpperCase();
|
|
81568
|
+
if (transform === "lowercase") return text2.toLowerCase();
|
|
81569
|
+
if (transform === "capitalize") return capitalizeText$2(text2);
|
|
81570
|
+
return text2;
|
|
81571
|
+
};
|
|
81517
81572
|
function getMeasurementContext() {
|
|
81518
81573
|
if (measurementCtx) return measurementCtx;
|
|
81519
81574
|
if (typeof document === "undefined") {
|
|
@@ -81689,17 +81744,19 @@ ${l}
|
|
|
81689
81744
|
}
|
|
81690
81745
|
const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
81691
81746
|
const runLength = text2.length;
|
|
81747
|
+
const transform = isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? void 0 : run2.textTransform;
|
|
81748
|
+
const displayText = applyTextTransform$2(text2, transform);
|
|
81692
81749
|
if (currentCharOffset + runLength >= charOffset) {
|
|
81693
81750
|
const offsetInRun = charOffset - currentCharOffset;
|
|
81694
81751
|
ctx2.font = getRunFontString(run2);
|
|
81695
|
-
const textUpToTarget =
|
|
81752
|
+
const textUpToTarget = displayText.slice(0, offsetInRun);
|
|
81696
81753
|
const measured2 = ctx2.measureText(textUpToTarget);
|
|
81697
81754
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
|
|
81698
|
-
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(
|
|
81755
|
+
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(text2.slice(0, offsetInRun)) : 0;
|
|
81699
81756
|
return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
81700
81757
|
}
|
|
81701
81758
|
ctx2.font = getRunFontString(run2);
|
|
81702
|
-
const measured = ctx2.measureText(
|
|
81759
|
+
const measured = ctx2.measureText(displayText);
|
|
81703
81760
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
81704
81761
|
const spacesInRun = justify.extraPerSpace !== 0 ? countSpaces(text2) : 0;
|
|
81705
81762
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -81738,8 +81795,10 @@ ${l}
|
|
|
81738
81795
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
81739
81796
|
}
|
|
81740
81797
|
const text2 = run2.text ?? "";
|
|
81741
|
-
const
|
|
81742
|
-
const
|
|
81798
|
+
const transform = "textTransform" in run2 ? run2.textTransform : void 0;
|
|
81799
|
+
const displayText = applyTextTransform$2(text2, transform);
|
|
81800
|
+
const displaySegmentText = displayText.slice(segment.fromChar, segment.toChar);
|
|
81801
|
+
const textUpToTarget = displaySegmentText.slice(0, offsetInSegment);
|
|
81743
81802
|
ctx2.font = getRunFontString(run2);
|
|
81744
81803
|
const measured = ctx2.measureText(textUpToTarget);
|
|
81745
81804
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInSegment, segmentChars);
|
|
@@ -81835,12 +81894,14 @@ ${l}
|
|
|
81835
81894
|
}
|
|
81836
81895
|
const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
81837
81896
|
const runLength = text2.length;
|
|
81897
|
+
const transform = isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? void 0 : run2.textTransform;
|
|
81898
|
+
const displayText = applyTextTransform$2(text2, transform);
|
|
81838
81899
|
if (runLength === 0) continue;
|
|
81839
81900
|
ctx2.font = getRunFontString(run2);
|
|
81840
81901
|
for (let i2 = 0; i2 <= runLength; i2++) {
|
|
81841
|
-
const textUpToChar =
|
|
81902
|
+
const textUpToChar = displayText.slice(0, i2);
|
|
81842
81903
|
const measured2 = ctx2.measureText(textUpToChar);
|
|
81843
|
-
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(
|
|
81904
|
+
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text2.slice(0, i2)) : 0;
|
|
81844
81905
|
const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i2, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
81845
81906
|
if (charX >= safeX) {
|
|
81846
81907
|
if (i2 === 0) {
|
|
@@ -81850,7 +81911,7 @@ ${l}
|
|
|
81850
81911
|
pmPosition: pmPosition3
|
|
81851
81912
|
};
|
|
81852
81913
|
}
|
|
81853
|
-
const prevText =
|
|
81914
|
+
const prevText = displayText.slice(0, i2 - 1);
|
|
81854
81915
|
const prevMeasured = ctx2.measureText(prevText);
|
|
81855
81916
|
const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run2, i2 - 1, runLength);
|
|
81856
81917
|
const distToPrev = Math.abs(safeX - prevX);
|
|
@@ -81863,7 +81924,7 @@ ${l}
|
|
|
81863
81924
|
};
|
|
81864
81925
|
}
|
|
81865
81926
|
}
|
|
81866
|
-
const measured = ctx2.measureText(
|
|
81927
|
+
const measured = ctx2.measureText(displayText);
|
|
81867
81928
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
81868
81929
|
const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text2) : 0;
|
|
81869
81930
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -82294,6 +82355,83 @@ ${l}
|
|
|
82294
82355
|
}
|
|
82295
82356
|
return index2;
|
|
82296
82357
|
}
|
|
82358
|
+
const LIST_MARKER_GAP$1 = 8;
|
|
82359
|
+
const MIN_MARKER_GUTTER = 24;
|
|
82360
|
+
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
82361
|
+
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
82362
|
+
const DEFAULT_LIST_HANGING_PX$1 = 18;
|
|
82363
|
+
const SPACE_SUFFIX_GAP_PX = 4;
|
|
82364
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
82365
|
+
function resolveListTextStartPx(wordLayout, indentLeft, firstLine, hanging, measureMarkerText) {
|
|
82366
|
+
const marker = wordLayout?.marker;
|
|
82367
|
+
if (!marker) {
|
|
82368
|
+
const textStartPx = wordLayout?.firstLineIndentMode === true && typeof wordLayout.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
82369
|
+
return textStartPx;
|
|
82370
|
+
}
|
|
82371
|
+
const markerBoxWidth = typeof marker.markerBoxWidthPx === "number" && Number.isFinite(marker.markerBoxWidthPx) ? marker.markerBoxWidthPx : 0;
|
|
82372
|
+
let markerTextWidth = typeof marker.glyphWidthPx === "number" && Number.isFinite(marker.glyphWidthPx) ? marker.glyphWidthPx : void 0;
|
|
82373
|
+
if (markerTextWidth == null && marker.markerText) {
|
|
82374
|
+
markerTextWidth = measureMarkerText(marker.markerText, marker);
|
|
82375
|
+
}
|
|
82376
|
+
if (!Number.isFinite(markerTextWidth) || markerTextWidth !== void 0 && markerTextWidth < 0) {
|
|
82377
|
+
markerTextWidth = markerBoxWidth;
|
|
82378
|
+
}
|
|
82379
|
+
const finalMarkerTextWidth = Math.max(0, markerTextWidth ?? 0);
|
|
82380
|
+
let markerStartPos;
|
|
82381
|
+
if (wordLayout?.firstLineIndentMode === true && typeof marker.markerX === "number" && Number.isFinite(marker.markerX)) {
|
|
82382
|
+
markerStartPos = marker.markerX;
|
|
82383
|
+
} else {
|
|
82384
|
+
markerStartPos = indentLeft - hanging + firstLine;
|
|
82385
|
+
}
|
|
82386
|
+
if (!Number.isFinite(markerStartPos)) {
|
|
82387
|
+
markerStartPos = 0;
|
|
82388
|
+
}
|
|
82389
|
+
const currentPos = markerStartPos + finalMarkerTextWidth;
|
|
82390
|
+
const suffix2 = marker.suffix ?? "tab";
|
|
82391
|
+
if (suffix2 === "space") {
|
|
82392
|
+
return markerStartPos + finalMarkerTextWidth + SPACE_SUFFIX_GAP_PX;
|
|
82393
|
+
}
|
|
82394
|
+
if (suffix2 === "nothing") {
|
|
82395
|
+
return markerStartPos + finalMarkerTextWidth;
|
|
82396
|
+
}
|
|
82397
|
+
const markerJustification = marker.justification ?? "left";
|
|
82398
|
+
if (markerJustification !== "left") {
|
|
82399
|
+
const gutterWidth = typeof marker.gutterWidthPx === "number" && Number.isFinite(marker.gutterWidthPx) && marker.gutterWidthPx > 0 ? marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
82400
|
+
return markerStartPos + finalMarkerTextWidth + Math.max(gutterWidth, LIST_MARKER_GAP$1);
|
|
82401
|
+
}
|
|
82402
|
+
if (wordLayout?.firstLineIndentMode === true) {
|
|
82403
|
+
let targetTabStop;
|
|
82404
|
+
if (Array.isArray(wordLayout.tabsPx)) {
|
|
82405
|
+
for (const tab of wordLayout.tabsPx) {
|
|
82406
|
+
if (typeof tab === "number" && tab > currentPos) {
|
|
82407
|
+
targetTabStop = tab;
|
|
82408
|
+
break;
|
|
82409
|
+
}
|
|
82410
|
+
}
|
|
82411
|
+
}
|
|
82412
|
+
const textStartTarget = typeof marker.textStartX === "number" && Number.isFinite(marker.textStartX) ? marker.textStartX : wordLayout.textStartPx;
|
|
82413
|
+
let tabWidth2;
|
|
82414
|
+
if (targetTabStop !== void 0) {
|
|
82415
|
+
tabWidth2 = targetTabStop - currentPos;
|
|
82416
|
+
} else if (textStartTarget !== void 0 && Number.isFinite(textStartTarget) && textStartTarget > currentPos) {
|
|
82417
|
+
tabWidth2 = textStartTarget - currentPos;
|
|
82418
|
+
} else {
|
|
82419
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
82420
|
+
}
|
|
82421
|
+
if (tabWidth2 < LIST_MARKER_GAP$1) {
|
|
82422
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
82423
|
+
}
|
|
82424
|
+
return markerStartPos + finalMarkerTextWidth + tabWidth2;
|
|
82425
|
+
}
|
|
82426
|
+
const textStart = indentLeft + firstLine;
|
|
82427
|
+
let tabWidth = textStart - currentPos;
|
|
82428
|
+
if (tabWidth <= 0) {
|
|
82429
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
82430
|
+
} else if (tabWidth < LIST_MARKER_GAP$1) {
|
|
82431
|
+
tabWidth = LIST_MARKER_GAP$1;
|
|
82432
|
+
}
|
|
82433
|
+
return markerStartPos + finalMarkerTextWidth + tabWidth;
|
|
82434
|
+
}
|
|
82297
82435
|
function getWordLayoutConfig(block) {
|
|
82298
82436
|
if (!block || block.kind !== "paragraph") {
|
|
82299
82437
|
return void 0;
|
|
@@ -82326,9 +82464,16 @@ ${l}
|
|
|
82326
82464
|
const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
|
|
82327
82465
|
let indentAdjust = paraIndentLeft;
|
|
82328
82466
|
if (isListItem2 && isFirstLine && isFirstLineIndentMode) {
|
|
82467
|
+
const resolvedTextStart = resolveListTextStartPx(
|
|
82468
|
+
wordLayout,
|
|
82469
|
+
paraIndentLeft,
|
|
82470
|
+
Math.max(firstLineIndent, 0),
|
|
82471
|
+
Math.max(hangingIndent, 0),
|
|
82472
|
+
() => markerWidth
|
|
82473
|
+
// Use provided markerWidth since we don't have canvas access here
|
|
82474
|
+
);
|
|
82329
82475
|
const textStartFallback = paraIndentLeft + Math.max(firstLineIndent, 0) + markerWidth;
|
|
82330
|
-
|
|
82331
|
-
indentAdjust = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : textStartFallback;
|
|
82476
|
+
indentAdjust = typeof resolvedTextStart === "number" && Number.isFinite(resolvedTextStart) ? resolvedTextStart : textStartFallback;
|
|
82332
82477
|
} else if (isFirstLine && !isListItem2) {
|
|
82333
82478
|
indentAdjust += firstLineOffset;
|
|
82334
82479
|
}
|
|
@@ -82484,7 +82629,10 @@ ${l}
|
|
|
82484
82629
|
}
|
|
82485
82630
|
function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
82486
82631
|
const zones = [];
|
|
82487
|
-
|
|
82632
|
+
let currentColumns = columns;
|
|
82633
|
+
let currentMargins = margins;
|
|
82634
|
+
let currentPageWidth = pageWidth;
|
|
82635
|
+
let marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
82488
82636
|
return {
|
|
82489
82637
|
registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
82490
82638
|
if (!drawingBlock.anchor?.isAnchored) {
|
|
@@ -82497,7 +82645,7 @@ ${l}
|
|
|
82497
82645
|
}
|
|
82498
82646
|
const objectWidth = measure.width ?? 0;
|
|
82499
82647
|
const objectHeight = measure.height ?? 0;
|
|
82500
|
-
const x2 = computeAnchorX(anchor, columnIndex,
|
|
82648
|
+
const x2 = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
|
|
82501
82649
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
82502
82650
|
const zone = {
|
|
82503
82651
|
imageBlockId: drawingBlock.id,
|
|
@@ -82531,7 +82679,7 @@ ${l}
|
|
|
82531
82679
|
}
|
|
82532
82680
|
const tableWidth = measure.totalWidth ?? 0;
|
|
82533
82681
|
const tableHeight = measure.totalHeight ?? 0;
|
|
82534
|
-
const x2 = computeTableAnchorX(anchor, columnIndex,
|
|
82682
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
|
|
82535
82683
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
82536
82684
|
const zone = {
|
|
82537
82685
|
imageBlockId: tableBlock.id,
|
|
@@ -82579,7 +82727,7 @@ ${l}
|
|
|
82579
82727
|
}
|
|
82580
82728
|
const leftFloats = [];
|
|
82581
82729
|
const rightFloats = [];
|
|
82582
|
-
const columnOrigin = marginLeft + columnIndex * (
|
|
82730
|
+
const columnOrigin = marginLeft + columnIndex * (currentColumns.width + currentColumns.gap);
|
|
82583
82731
|
const columnCenter = columnOrigin + baseWidth / 2;
|
|
82584
82732
|
for (const zone of wrappingZones) {
|
|
82585
82733
|
if (zone.wrapMode === "left") {
|
|
@@ -82618,6 +82766,22 @@ ${l}
|
|
|
82618
82766
|
},
|
|
82619
82767
|
clear() {
|
|
82620
82768
|
zones.length = 0;
|
|
82769
|
+
},
|
|
82770
|
+
/**
|
|
82771
|
+
* Update layout context used for positioning and wrapping (columns, margins, page width).
|
|
82772
|
+
* This method should be called when the layout configuration changes (e.g., section breaks,
|
|
82773
|
+
* column changes, page size changes) to ensure floating objects are positioned and wrapped
|
|
82774
|
+
* correctly relative to the new layout boundaries.
|
|
82775
|
+
*
|
|
82776
|
+
* @param nextColumns - Column layout configuration (width, gap, count)
|
|
82777
|
+
* @param nextMargins - Optional page margins (left, right) in pixels
|
|
82778
|
+
* @param nextPageWidth - Optional total page width in pixels
|
|
82779
|
+
*/
|
|
82780
|
+
setLayoutContext(nextColumns, nextMargins, nextPageWidth) {
|
|
82781
|
+
currentColumns = nextColumns;
|
|
82782
|
+
currentMargins = nextMargins;
|
|
82783
|
+
currentPageWidth = nextPageWidth;
|
|
82784
|
+
marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
82621
82785
|
}
|
|
82622
82786
|
};
|
|
82623
82787
|
}
|
|
@@ -82717,7 +82881,14 @@ ${l}
|
|
|
82717
82881
|
const props = {};
|
|
82718
82882
|
if (source.kind !== "sectionBreak") return props;
|
|
82719
82883
|
if (source.margins) {
|
|
82720
|
-
props.margins = {
|
|
82884
|
+
props.margins = {
|
|
82885
|
+
header: source.margins.header,
|
|
82886
|
+
footer: source.margins.footer,
|
|
82887
|
+
top: source.margins.top,
|
|
82888
|
+
right: source.margins.right,
|
|
82889
|
+
bottom: source.margins.bottom,
|
|
82890
|
+
left: source.margins.left
|
|
82891
|
+
};
|
|
82721
82892
|
}
|
|
82722
82893
|
if (source.pageSize) {
|
|
82723
82894
|
props.pageSize = { w: source.pageSize.w, h: source.pageSize.h };
|
|
@@ -82765,20 +82936,36 @@ ${l}
|
|
|
82765
82936
|
next2.activeOrientation = block.orientation;
|
|
82766
82937
|
next2.pendingOrientation = null;
|
|
82767
82938
|
}
|
|
82939
|
+
const headerDistance = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next2.activeHeaderDistance;
|
|
82940
|
+
const footerDistance = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next2.activeFooterDistance;
|
|
82941
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
82942
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
82768
82943
|
if (block.margins?.header !== void 0) {
|
|
82769
|
-
const headerDistance = Math.max(0, block.margins.header);
|
|
82770
82944
|
next2.activeHeaderDistance = headerDistance;
|
|
82771
82945
|
next2.pendingHeaderDistance = headerDistance;
|
|
82772
|
-
next2.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
|
|
82773
|
-
next2.pendingTopMargin = next2.activeTopMargin;
|
|
82774
82946
|
}
|
|
82775
82947
|
if (block.margins?.footer !== void 0) {
|
|
82776
|
-
const footerDistance = Math.max(0, block.margins.footer);
|
|
82777
82948
|
next2.activeFooterDistance = footerDistance;
|
|
82778
82949
|
next2.pendingFooterDistance = footerDistance;
|
|
82779
|
-
|
|
82950
|
+
}
|
|
82951
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
82952
|
+
next2.activeTopMargin = calcRequiredTopMargin(headerDistance, sectionTop);
|
|
82953
|
+
next2.pendingTopMargin = next2.activeTopMargin;
|
|
82954
|
+
}
|
|
82955
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
82956
|
+
next2.activeBottomMargin = calcRequiredBottomMargin(footerDistance, sectionBottom);
|
|
82780
82957
|
next2.pendingBottomMargin = next2.activeBottomMargin;
|
|
82781
82958
|
}
|
|
82959
|
+
if (block.margins?.left !== void 0) {
|
|
82960
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
82961
|
+
next2.activeLeftMargin = leftMargin;
|
|
82962
|
+
next2.pendingLeftMargin = leftMargin;
|
|
82963
|
+
}
|
|
82964
|
+
if (block.margins?.right !== void 0) {
|
|
82965
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
82966
|
+
next2.activeRightMargin = rightMargin;
|
|
82967
|
+
next2.pendingRightMargin = rightMargin;
|
|
82968
|
+
}
|
|
82782
82969
|
if (block.columns) {
|
|
82783
82970
|
next2.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
82784
82971
|
next2.pendingColumns = null;
|
|
@@ -82787,26 +82974,42 @@ ${l}
|
|
|
82787
82974
|
}
|
|
82788
82975
|
const headerPx = block.margins?.header;
|
|
82789
82976
|
const footerPx = block.margins?.footer;
|
|
82977
|
+
const topPx = block.margins?.top;
|
|
82978
|
+
const bottomPx = block.margins?.bottom;
|
|
82790
82979
|
const nextTop = next2.pendingTopMargin ?? next2.activeTopMargin;
|
|
82791
82980
|
const nextBottom = next2.pendingBottomMargin ?? next2.activeBottomMargin;
|
|
82981
|
+
const nextLeft = next2.pendingLeftMargin ?? next2.activeLeftMargin;
|
|
82982
|
+
const nextRight = next2.pendingRightMargin ?? next2.activeRightMargin;
|
|
82792
82983
|
const nextHeader = next2.pendingHeaderDistance ?? next2.activeHeaderDistance;
|
|
82793
82984
|
const nextFooter = next2.pendingFooterDistance ?? next2.activeFooterDistance;
|
|
82794
|
-
if (typeof headerPx === "number") {
|
|
82795
|
-
const newHeaderDist = Math.max(0, headerPx);
|
|
82985
|
+
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
82986
|
+
const newHeaderDist = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
82987
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
82796
82988
|
next2.pendingHeaderDistance = newHeaderDist;
|
|
82797
|
-
next2.pendingTopMargin = calcRequiredTopMargin(newHeaderDist,
|
|
82989
|
+
next2.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, sectionTop);
|
|
82798
82990
|
} else {
|
|
82799
82991
|
next2.pendingTopMargin = nextTop;
|
|
82800
82992
|
next2.pendingHeaderDistance = nextHeader;
|
|
82801
82993
|
}
|
|
82802
|
-
if (typeof footerPx === "number") {
|
|
82803
|
-
const newFooterDist = Math.max(0, footerPx);
|
|
82994
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
82995
|
+
const newFooterDist = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
82996
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
82804
82997
|
next2.pendingFooterDistance = newFooterDist;
|
|
82805
|
-
next2.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist,
|
|
82998
|
+
next2.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, sectionBottom);
|
|
82806
82999
|
} else {
|
|
82807
83000
|
next2.pendingBottomMargin = nextBottom;
|
|
82808
83001
|
next2.pendingFooterDistance = nextFooter;
|
|
82809
83002
|
}
|
|
83003
|
+
if (typeof block.margins?.left === "number") {
|
|
83004
|
+
next2.pendingLeftMargin = Math.max(0, block.margins.left);
|
|
83005
|
+
} else {
|
|
83006
|
+
next2.pendingLeftMargin = nextLeft;
|
|
83007
|
+
}
|
|
83008
|
+
if (typeof block.margins?.right === "number") {
|
|
83009
|
+
next2.pendingRightMargin = Math.max(0, block.margins.right);
|
|
83010
|
+
} else {
|
|
83011
|
+
next2.pendingRightMargin = nextRight;
|
|
83012
|
+
}
|
|
82810
83013
|
if (block.pageSize) {
|
|
82811
83014
|
next2.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
82812
83015
|
}
|
|
@@ -82866,6 +83069,12 @@ ${l}
|
|
|
82866
83069
|
if (next2.pendingBottomMargin != null) {
|
|
82867
83070
|
next2.activeBottomMargin = next2.pendingBottomMargin;
|
|
82868
83071
|
}
|
|
83072
|
+
if (next2.pendingLeftMargin != null) {
|
|
83073
|
+
next2.activeLeftMargin = next2.pendingLeftMargin;
|
|
83074
|
+
}
|
|
83075
|
+
if (next2.pendingRightMargin != null) {
|
|
83076
|
+
next2.activeRightMargin = next2.pendingRightMargin;
|
|
83077
|
+
}
|
|
82869
83078
|
if (next2.pendingHeaderDistance != null) {
|
|
82870
83079
|
next2.activeHeaderDistance = next2.pendingHeaderDistance;
|
|
82871
83080
|
}
|
|
@@ -82883,6 +83092,8 @@ ${l}
|
|
|
82883
83092
|
}
|
|
82884
83093
|
next2.pendingTopMargin = null;
|
|
82885
83094
|
next2.pendingBottomMargin = null;
|
|
83095
|
+
next2.pendingLeftMargin = null;
|
|
83096
|
+
next2.pendingRightMargin = null;
|
|
82886
83097
|
next2.pendingHeaderDistance = null;
|
|
82887
83098
|
next2.pendingFooterDistance = null;
|
|
82888
83099
|
next2.pendingPageSize = null;
|
|
@@ -83111,7 +83322,8 @@ ${l}
|
|
|
83111
83322
|
if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
|
|
83112
83323
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
83113
83324
|
const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
|
|
83114
|
-
|
|
83325
|
+
const newLines = normalizeLines(newMeasure);
|
|
83326
|
+
lines = newLines;
|
|
83115
83327
|
didRemeasureForColumnWidth = true;
|
|
83116
83328
|
}
|
|
83117
83329
|
let fromLine = 0;
|
|
@@ -83193,7 +83405,8 @@ ${l}
|
|
|
83193
83405
|
if (narrowestRemeasureWidth < remeasureWidth) {
|
|
83194
83406
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
83195
83407
|
const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
|
|
83196
|
-
|
|
83408
|
+
const newLines = normalizeLines(newMeasure);
|
|
83409
|
+
lines = newLines;
|
|
83197
83410
|
didRemeasureForFloats = true;
|
|
83198
83411
|
}
|
|
83199
83412
|
}
|
|
@@ -83537,6 +83750,94 @@ ${l}
|
|
|
83537
83750
|
function getCellTotalLines(cell2) {
|
|
83538
83751
|
return getCellLines(cell2).length;
|
|
83539
83752
|
}
|
|
83753
|
+
function mergePmRange(target, range2) {
|
|
83754
|
+
if (typeof range2.pmStart === "number") {
|
|
83755
|
+
target.pmStart = target.pmStart == null ? range2.pmStart : Math.min(target.pmStart, range2.pmStart);
|
|
83756
|
+
}
|
|
83757
|
+
if (typeof range2.pmEnd === "number") {
|
|
83758
|
+
target.pmEnd = target.pmEnd == null ? range2.pmEnd : Math.max(target.pmEnd, range2.pmEnd);
|
|
83759
|
+
}
|
|
83760
|
+
}
|
|
83761
|
+
function computeCellPmRange(cell2, cellMeasure, fromLine, toLine) {
|
|
83762
|
+
const range2 = {};
|
|
83763
|
+
if (!cell2 || !cellMeasure) return range2;
|
|
83764
|
+
const cellBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
|
|
83765
|
+
const blockMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
|
|
83766
|
+
const maxBlocks = Math.min(cellBlocks.length, blockMeasures.length);
|
|
83767
|
+
let cumulativeLineCount = 0;
|
|
83768
|
+
for (let i2 = 0; i2 < maxBlocks; i2++) {
|
|
83769
|
+
const block = cellBlocks[i2];
|
|
83770
|
+
const blockMeasure = blockMeasures[i2];
|
|
83771
|
+
if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
|
|
83772
|
+
const paraMeasure = blockMeasure;
|
|
83773
|
+
const lines = paraMeasure.lines;
|
|
83774
|
+
const blockLineCount = lines?.length ?? 0;
|
|
83775
|
+
const blockStartGlobal = cumulativeLineCount;
|
|
83776
|
+
const blockEndGlobal = cumulativeLineCount + blockLineCount;
|
|
83777
|
+
const localFrom = Math.max(fromLine, blockStartGlobal) - blockStartGlobal;
|
|
83778
|
+
const localTo = Math.min(toLine, blockEndGlobal) - blockStartGlobal;
|
|
83779
|
+
if (lines && lines.length > 0 && localFrom < localTo) {
|
|
83780
|
+
mergePmRange(range2, computeFragmentPmRange(block, lines, localFrom, localTo));
|
|
83781
|
+
} else {
|
|
83782
|
+
mergePmRange(range2, extractBlockPmRange(block));
|
|
83783
|
+
}
|
|
83784
|
+
cumulativeLineCount += blockLineCount;
|
|
83785
|
+
continue;
|
|
83786
|
+
}
|
|
83787
|
+
mergePmRange(range2, extractBlockPmRange(block));
|
|
83788
|
+
}
|
|
83789
|
+
return range2;
|
|
83790
|
+
}
|
|
83791
|
+
function computeTableFragmentPmRange(block, measure, fromRow, toRow, partialRow) {
|
|
83792
|
+
const range2 = {};
|
|
83793
|
+
for (let rowIndex = fromRow; rowIndex < toRow; rowIndex++) {
|
|
83794
|
+
const row2 = block.rows[rowIndex];
|
|
83795
|
+
const rowMeasure = measure.rows[rowIndex];
|
|
83796
|
+
if (!row2 || !rowMeasure) continue;
|
|
83797
|
+
const isPartial = partialRow?.rowIndex === rowIndex;
|
|
83798
|
+
const cellCount = Math.min(row2.cells.length, rowMeasure.cells.length);
|
|
83799
|
+
for (let cellIndex = 0; cellIndex < cellCount; cellIndex++) {
|
|
83800
|
+
const cell2 = row2.cells[cellIndex];
|
|
83801
|
+
const cellMeasure = rowMeasure.cells[cellIndex];
|
|
83802
|
+
if (!cell2 || !cellMeasure) continue;
|
|
83803
|
+
const totalLines = getCellTotalLines(cellMeasure);
|
|
83804
|
+
let fromLine = 0;
|
|
83805
|
+
let toLine = totalLines;
|
|
83806
|
+
if (isPartial) {
|
|
83807
|
+
const hasValidFromLineByCell = partialRow?.fromLineByCell && cellIndex < partialRow.fromLineByCell.length;
|
|
83808
|
+
const hasValidToLineByCell = partialRow?.toLineByCell && cellIndex < partialRow.toLineByCell.length;
|
|
83809
|
+
if (hasValidFromLineByCell) {
|
|
83810
|
+
const rawFrom = partialRow.fromLineByCell[cellIndex];
|
|
83811
|
+
if (typeof rawFrom === "number" && rawFrom >= 0) {
|
|
83812
|
+
fromLine = rawFrom;
|
|
83813
|
+
}
|
|
83814
|
+
}
|
|
83815
|
+
if (hasValidToLineByCell) {
|
|
83816
|
+
const rawTo = partialRow.toLineByCell[cellIndex];
|
|
83817
|
+
if (typeof rawTo === "number") {
|
|
83818
|
+
toLine = rawTo === -1 ? totalLines : rawTo;
|
|
83819
|
+
}
|
|
83820
|
+
}
|
|
83821
|
+
}
|
|
83822
|
+
fromLine = Math.max(0, Math.min(fromLine, totalLines));
|
|
83823
|
+
toLine = Math.max(0, Math.min(toLine, totalLines));
|
|
83824
|
+
if (toLine < fromLine) {
|
|
83825
|
+
toLine = fromLine;
|
|
83826
|
+
}
|
|
83827
|
+
mergePmRange(range2, computeCellPmRange(cell2, cellMeasure, fromLine, toLine));
|
|
83828
|
+
}
|
|
83829
|
+
}
|
|
83830
|
+
return range2;
|
|
83831
|
+
}
|
|
83832
|
+
function applyTableFragmentPmRange(fragment, block, measure) {
|
|
83833
|
+
const range2 = computeTableFragmentPmRange(block, measure, fragment.fromRow, fragment.toRow, fragment.partialRow);
|
|
83834
|
+
if (range2.pmStart != null) {
|
|
83835
|
+
fragment.pmStart = range2.pmStart;
|
|
83836
|
+
}
|
|
83837
|
+
if (range2.pmEnd != null) {
|
|
83838
|
+
fragment.pmEnd = range2.pmEnd;
|
|
83839
|
+
}
|
|
83840
|
+
}
|
|
83540
83841
|
function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLineByCell) {
|
|
83541
83842
|
const row2 = measure.rows[rowIndex];
|
|
83542
83843
|
if (!row2) {
|
|
@@ -83681,6 +83982,7 @@ ${l}
|
|
|
83681
83982
|
height,
|
|
83682
83983
|
metadata
|
|
83683
83984
|
};
|
|
83985
|
+
applyTableFragmentPmRange(fragment, context.block, context.measure);
|
|
83684
83986
|
state2.page.fragments.push(fragment);
|
|
83685
83987
|
state2.cursorY += height;
|
|
83686
83988
|
}
|
|
@@ -83759,6 +84061,7 @@ ${l}
|
|
|
83759
84061
|
height,
|
|
83760
84062
|
metadata
|
|
83761
84063
|
};
|
|
84064
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
83762
84065
|
state2.page.fragments.push(fragment);
|
|
83763
84066
|
state2.cursorY += height;
|
|
83764
84067
|
return;
|
|
@@ -83822,6 +84125,7 @@ ${l}
|
|
|
83822
84125
|
partialRow: continuationPartialRow,
|
|
83823
84126
|
metadata: generateFragmentMetadata(measure)
|
|
83824
84127
|
};
|
|
84128
|
+
applyTableFragmentPmRange(fragment2, block, measure);
|
|
83825
84129
|
state2.page.fragments.push(fragment2);
|
|
83826
84130
|
state2.cursorY += fragmentHeight2;
|
|
83827
84131
|
}
|
|
@@ -83866,6 +84170,7 @@ ${l}
|
|
|
83866
84170
|
partialRow: forcedPartialRow,
|
|
83867
84171
|
metadata: generateFragmentMetadata(measure)
|
|
83868
84172
|
};
|
|
84173
|
+
applyTableFragmentPmRange(fragment2, block, measure);
|
|
83869
84174
|
state2.page.fragments.push(fragment2);
|
|
83870
84175
|
state2.cursorY += fragmentHeight2;
|
|
83871
84176
|
pendingPartialRow = forcedPartialRow;
|
|
@@ -83901,6 +84206,7 @@ ${l}
|
|
|
83901
84206
|
partialRow: partialRow || void 0,
|
|
83902
84207
|
metadata: generateFragmentMetadata(measure)
|
|
83903
84208
|
};
|
|
84209
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
83904
84210
|
state2.page.fragments.push(fragment);
|
|
83905
84211
|
state2.cursorY += fragmentHeight;
|
|
83906
84212
|
if (partialRow && !partialRow.isLastPart) {
|
|
@@ -83918,7 +84224,7 @@ ${l}
|
|
|
83918
84224
|
columnBoundaries: generateColumnBoundaries(measure),
|
|
83919
84225
|
coordinateSystem: "fragment"
|
|
83920
84226
|
};
|
|
83921
|
-
|
|
84227
|
+
const fragment = {
|
|
83922
84228
|
kind: "table",
|
|
83923
84229
|
blockId: block.id,
|
|
83924
84230
|
fromRow: 0,
|
|
@@ -83929,6 +84235,8 @@ ${l}
|
|
|
83929
84235
|
height: measure.totalHeight ?? 0,
|
|
83930
84236
|
metadata
|
|
83931
84237
|
};
|
|
84238
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
84239
|
+
return fragment;
|
|
83932
84240
|
}
|
|
83933
84241
|
function isPageRelativeAnchor(block) {
|
|
83934
84242
|
const vRelativeFrom = block.anchor?.vRelativeFrom;
|
|
@@ -84350,8 +84658,8 @@ ${l}
|
|
|
84350
84658
|
header: options.margins?.header ?? options.margins?.top ?? DEFAULT_MARGINS$2.top,
|
|
84351
84659
|
footer: options.margins?.footer ?? options.margins?.bottom ?? DEFAULT_MARGINS$2.bottom
|
|
84352
84660
|
};
|
|
84353
|
-
const
|
|
84354
|
-
if (
|
|
84661
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
84662
|
+
if (baseContentWidth <= 0) {
|
|
84355
84663
|
throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
|
|
84356
84664
|
}
|
|
84357
84665
|
const validateContentHeight = (height) => {
|
|
@@ -84381,8 +84689,12 @@ ${l}
|
|
|
84381
84689
|
const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
|
|
84382
84690
|
let activeTopMargin = effectiveTopMargin;
|
|
84383
84691
|
let activeBottomMargin = effectiveBottomMargin;
|
|
84692
|
+
let activeLeftMargin = margins.left;
|
|
84693
|
+
let activeRightMargin = margins.right;
|
|
84384
84694
|
let pendingTopMargin = null;
|
|
84385
84695
|
let pendingBottomMargin = null;
|
|
84696
|
+
let pendingLeftMargin = null;
|
|
84697
|
+
let pendingRightMargin = null;
|
|
84386
84698
|
let activeHeaderDistance = margins.header ?? margins.top;
|
|
84387
84699
|
let pendingHeaderDistance = null;
|
|
84388
84700
|
let activeFooterDistance = margins.footer ?? margins.bottom;
|
|
@@ -84395,10 +84707,11 @@ ${l}
|
|
|
84395
84707
|
let pendingOrientation = null;
|
|
84396
84708
|
let activeVAlign = null;
|
|
84397
84709
|
let pendingVAlign = null;
|
|
84710
|
+
const paginatorMargins = { left: activeLeftMargin, right: activeRightMargin };
|
|
84398
84711
|
const floatManager = createFloatingObjectManager(
|
|
84399
|
-
normalizeColumns(activeColumns,
|
|
84400
|
-
{ left:
|
|
84401
|
-
|
|
84712
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
84713
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
84714
|
+
activePageSize.w
|
|
84402
84715
|
);
|
|
84403
84716
|
const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks2);
|
|
84404
84717
|
const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
|
|
@@ -84415,22 +84728,38 @@ ${l}
|
|
|
84415
84728
|
next2.activeOrientation = block.orientation;
|
|
84416
84729
|
next2.pendingOrientation = null;
|
|
84417
84730
|
}
|
|
84731
|
+
const headerDistance2 = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next2.activeHeaderDistance;
|
|
84732
|
+
const footerDistance2 = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next2.activeFooterDistance;
|
|
84733
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
84734
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
84418
84735
|
if (block.margins?.header !== void 0) {
|
|
84419
|
-
|
|
84420
|
-
next2.
|
|
84421
|
-
next2.pendingHeaderDistance = headerDist;
|
|
84422
|
-
const requiredTop = maxHeaderContentHeight > 0 ? headerDist + maxHeaderContentHeight : headerDist;
|
|
84423
|
-
next2.activeTopMargin = Math.max(baseMargins.top, requiredTop);
|
|
84424
|
-
next2.pendingTopMargin = next2.activeTopMargin;
|
|
84736
|
+
next2.activeHeaderDistance = headerDistance2;
|
|
84737
|
+
next2.pendingHeaderDistance = headerDistance2;
|
|
84425
84738
|
}
|
|
84426
84739
|
if (block.margins?.footer !== void 0) {
|
|
84427
|
-
const footerDistance2 = Math.max(0, block.margins.footer);
|
|
84428
84740
|
next2.activeFooterDistance = footerDistance2;
|
|
84429
84741
|
next2.pendingFooterDistance = footerDistance2;
|
|
84742
|
+
}
|
|
84743
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
84744
|
+
const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : headerDistance2;
|
|
84745
|
+
next2.activeTopMargin = Math.max(sectionTop, requiredTop);
|
|
84746
|
+
next2.pendingTopMargin = next2.activeTopMargin;
|
|
84747
|
+
}
|
|
84748
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
84430
84749
|
const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
|
|
84431
|
-
next2.activeBottomMargin = Math.max(
|
|
84750
|
+
next2.activeBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
84432
84751
|
next2.pendingBottomMargin = next2.activeBottomMargin;
|
|
84433
84752
|
}
|
|
84753
|
+
if (block.margins?.left !== void 0) {
|
|
84754
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
84755
|
+
next2.activeLeftMargin = leftMargin;
|
|
84756
|
+
next2.pendingLeftMargin = leftMargin;
|
|
84757
|
+
}
|
|
84758
|
+
if (block.margins?.right !== void 0) {
|
|
84759
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
84760
|
+
next2.activeRightMargin = rightMargin;
|
|
84761
|
+
next2.pendingRightMargin = rightMargin;
|
|
84762
|
+
}
|
|
84434
84763
|
if (block.columns) {
|
|
84435
84764
|
next2.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
84436
84765
|
next2.pendingColumns = null;
|
|
@@ -84459,27 +84788,35 @@ ${l}
|
|
|
84459
84788
|
const headerPx = block.margins?.header;
|
|
84460
84789
|
const footerPx = block.margins?.footer;
|
|
84461
84790
|
const topPx = block.margins?.top;
|
|
84791
|
+
const bottomPx = block.margins?.bottom;
|
|
84792
|
+
const leftPx = block.margins?.left;
|
|
84793
|
+
const rightPx = block.margins?.right;
|
|
84462
84794
|
const nextTop = next2.pendingTopMargin ?? next2.activeTopMargin;
|
|
84463
84795
|
const nextBottom = next2.pendingBottomMargin ?? next2.activeBottomMargin;
|
|
84796
|
+
const nextLeft = next2.pendingLeftMargin ?? next2.activeLeftMargin;
|
|
84797
|
+
const nextRight = next2.pendingRightMargin ?? next2.activeRightMargin;
|
|
84464
84798
|
const nextHeader = next2.pendingHeaderDistance ?? next2.activeHeaderDistance;
|
|
84465
84799
|
const nextFooter = next2.pendingFooterDistance ?? next2.activeFooterDistance;
|
|
84466
84800
|
next2.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
84467
84801
|
next2.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
84468
84802
|
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
84469
|
-
const sectionTop = topPx
|
|
84803
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
84470
84804
|
const sectionHeader = next2.pendingHeaderDistance;
|
|
84471
84805
|
const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
|
|
84472
84806
|
next2.pendingTopMargin = Math.max(sectionTop, requiredTop);
|
|
84473
84807
|
} else {
|
|
84474
84808
|
next2.pendingTopMargin = nextTop;
|
|
84475
84809
|
}
|
|
84476
|
-
if (typeof footerPx === "number") {
|
|
84810
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
84477
84811
|
const sectionFooter = next2.pendingFooterDistance;
|
|
84812
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
84478
84813
|
const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
|
|
84479
|
-
next2.pendingBottomMargin = Math.max(
|
|
84814
|
+
next2.pendingBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
84480
84815
|
} else {
|
|
84481
84816
|
next2.pendingBottomMargin = nextBottom;
|
|
84482
84817
|
}
|
|
84818
|
+
next2.pendingLeftMargin = typeof leftPx === "number" ? Math.max(0, leftPx) : nextLeft;
|
|
84819
|
+
next2.pendingRightMargin = typeof rightPx === "number" ? Math.max(0, rightPx) : nextRight;
|
|
84483
84820
|
if (block.pageSize) next2.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
84484
84821
|
if (block.orientation) next2.pendingOrientation = block.orientation;
|
|
84485
84822
|
const sectionType = block.type ?? "continuous";
|
|
@@ -84564,7 +84901,7 @@ ${l}
|
|
|
84564
84901
|
let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
|
|
84565
84902
|
let pendingSectionIndex = null;
|
|
84566
84903
|
const paginator = createPaginator({
|
|
84567
|
-
margins:
|
|
84904
|
+
margins: paginatorMargins,
|
|
84568
84905
|
getActiveTopMargin: () => activeTopMargin,
|
|
84569
84906
|
getActiveBottomMargin: () => activeBottomMargin,
|
|
84570
84907
|
getActiveHeaderDistance: () => activeHeaderDistance,
|
|
@@ -84579,8 +84916,12 @@ ${l}
|
|
|
84579
84916
|
const applied = applyPendingToActive({
|
|
84580
84917
|
activeTopMargin,
|
|
84581
84918
|
activeBottomMargin,
|
|
84919
|
+
activeLeftMargin,
|
|
84920
|
+
activeRightMargin,
|
|
84582
84921
|
pendingTopMargin,
|
|
84583
84922
|
pendingBottomMargin,
|
|
84923
|
+
pendingLeftMargin,
|
|
84924
|
+
pendingRightMargin,
|
|
84584
84925
|
activeHeaderDistance,
|
|
84585
84926
|
activeFooterDistance,
|
|
84586
84927
|
pendingHeaderDistance,
|
|
@@ -84595,8 +84936,12 @@ ${l}
|
|
|
84595
84936
|
});
|
|
84596
84937
|
activeTopMargin = applied.activeTopMargin;
|
|
84597
84938
|
activeBottomMargin = applied.activeBottomMargin;
|
|
84939
|
+
activeLeftMargin = applied.activeLeftMargin;
|
|
84940
|
+
activeRightMargin = applied.activeRightMargin;
|
|
84598
84941
|
pendingTopMargin = applied.pendingTopMargin;
|
|
84599
84942
|
pendingBottomMargin = applied.pendingBottomMargin;
|
|
84943
|
+
pendingLeftMargin = applied.pendingLeftMargin;
|
|
84944
|
+
pendingRightMargin = applied.pendingRightMargin;
|
|
84600
84945
|
activeHeaderDistance = applied.activeHeaderDistance;
|
|
84601
84946
|
activeFooterDistance = applied.activeFooterDistance;
|
|
84602
84947
|
pendingHeaderDistance = applied.pendingHeaderDistance;
|
|
@@ -84608,6 +84953,14 @@ ${l}
|
|
|
84608
84953
|
activeOrientation = applied.activeOrientation;
|
|
84609
84954
|
pendingOrientation = applied.pendingOrientation;
|
|
84610
84955
|
cachedColumnsState.state = null;
|
|
84956
|
+
paginatorMargins.left = activeLeftMargin;
|
|
84957
|
+
paginatorMargins.right = activeRightMargin;
|
|
84958
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
84959
|
+
floatManager.setLayoutContext(
|
|
84960
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
84961
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
84962
|
+
activePageSize.w
|
|
84963
|
+
);
|
|
84611
84964
|
if (pendingNumbering) {
|
|
84612
84965
|
if (pendingNumbering.format) activeNumberFormat = pendingNumbering.format;
|
|
84613
84966
|
if (typeof pendingNumbering.start === "number" && Number.isFinite(pendingNumbering.start)) {
|
|
@@ -84652,7 +85005,7 @@ ${l}
|
|
|
84652
85005
|
const getActiveColumnsForState = paginator.getActiveColumnsForState;
|
|
84653
85006
|
let cachedColumnsState = { state: null, constraintIndex: -2, contentWidth: -1, colsConfig: null, normalized: null };
|
|
84654
85007
|
const getCurrentColumns = () => {
|
|
84655
|
-
const currentContentWidth = activePageSize.w - (
|
|
85008
|
+
const currentContentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
84656
85009
|
const state2 = states[states.length - 1] ?? null;
|
|
84657
85010
|
const colsConfig = state2 ? getActiveColumnsForState(state2) : activeColumns;
|
|
84658
85011
|
const constraintIndex = state2 ? state2.activeConstraintIndex : -1;
|
|
@@ -84685,6 +85038,12 @@ ${l}
|
|
|
84685
85038
|
layoutLog(` Current page: ${state2.page.number}, cursorY: ${state2.cursorY}`);
|
|
84686
85039
|
activeColumns = newColumns;
|
|
84687
85040
|
cachedColumnsState.state = null;
|
|
85041
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
85042
|
+
floatManager.setLayoutContext(
|
|
85043
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
85044
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
85045
|
+
activePageSize.w
|
|
85046
|
+
);
|
|
84688
85047
|
};
|
|
84689
85048
|
const anchoredByParagraph = collectAnchoredDrawings(blocks2, measures);
|
|
84690
85049
|
const anchoredTablesByParagraph = collectAnchoredTables(blocks2, measures);
|
|
@@ -84716,10 +85075,10 @@ ${l}
|
|
|
84716
85075
|
if (alignV === "top") {
|
|
84717
85076
|
anchorY = offsetV;
|
|
84718
85077
|
} else if (alignV === "bottom") {
|
|
84719
|
-
const pageHeight = contentBottom + margins
|
|
85078
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
84720
85079
|
anchorY = pageHeight - imageHeight + offsetV;
|
|
84721
85080
|
} else if (alignV === "center") {
|
|
84722
|
-
const pageHeight = contentBottom + margins
|
|
85081
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
84723
85082
|
anchorY = (pageHeight - imageHeight) / 2 + offsetV;
|
|
84724
85083
|
} else {
|
|
84725
85084
|
anchorY = offsetV;
|
|
@@ -84730,11 +85089,11 @@ ${l}
|
|
|
84730
85089
|
const anchorX = entry.block.anchor ? computeAnchorX(
|
|
84731
85090
|
entry.block.anchor,
|
|
84732
85091
|
state2.columnIndex,
|
|
84733
|
-
normalizeColumns(activeColumns,
|
|
85092
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
84734
85093
|
entry.measure.width,
|
|
84735
|
-
{ left:
|
|
85094
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
84736
85095
|
activePageSize.w
|
|
84737
|
-
) :
|
|
85096
|
+
) : activeLeftMargin;
|
|
84738
85097
|
floatManager.registerDrawing(entry.block, entry.measure, anchorY, state2.columnIndex, state2.page.number);
|
|
84739
85098
|
preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state2.page.number });
|
|
84740
85099
|
}
|
|
@@ -84772,8 +85131,12 @@ ${l}
|
|
|
84772
85131
|
const sectionState = {
|
|
84773
85132
|
activeTopMargin,
|
|
84774
85133
|
activeBottomMargin,
|
|
85134
|
+
activeLeftMargin,
|
|
85135
|
+
activeRightMargin,
|
|
84775
85136
|
pendingTopMargin,
|
|
84776
85137
|
pendingBottomMargin,
|
|
85138
|
+
pendingLeftMargin,
|
|
85139
|
+
pendingRightMargin,
|
|
84777
85140
|
activeHeaderDistance,
|
|
84778
85141
|
activeFooterDistance,
|
|
84779
85142
|
pendingHeaderDistance,
|
|
@@ -84807,8 +85170,12 @@ ${l}
|
|
|
84807
85170
|
layoutLog(`[Layout] ========== END SECTION BREAK ==========`);
|
|
84808
85171
|
activeTopMargin = updatedState.activeTopMargin;
|
|
84809
85172
|
activeBottomMargin = updatedState.activeBottomMargin;
|
|
85173
|
+
activeLeftMargin = updatedState.activeLeftMargin;
|
|
85174
|
+
activeRightMargin = updatedState.activeRightMargin;
|
|
84810
85175
|
pendingTopMargin = updatedState.pendingTopMargin;
|
|
84811
85176
|
pendingBottomMargin = updatedState.pendingBottomMargin;
|
|
85177
|
+
pendingLeftMargin = updatedState.pendingLeftMargin;
|
|
85178
|
+
pendingRightMargin = updatedState.pendingRightMargin;
|
|
84812
85179
|
activeHeaderDistance = updatedState.activeHeaderDistance;
|
|
84813
85180
|
activeFooterDistance = updatedState.activeFooterDistance;
|
|
84814
85181
|
pendingHeaderDistance = updatedState.pendingHeaderDistance;
|
|
@@ -84946,8 +85313,8 @@ ${l}
|
|
|
84946
85313
|
pageMargins: {
|
|
84947
85314
|
top: activeTopMargin,
|
|
84948
85315
|
bottom: activeBottomMargin,
|
|
84949
|
-
left:
|
|
84950
|
-
right:
|
|
85316
|
+
left: activeLeftMargin,
|
|
85317
|
+
right: activeRightMargin
|
|
84951
85318
|
},
|
|
84952
85319
|
columns: getCurrentColumns(),
|
|
84953
85320
|
placedAnchoredIds
|
|
@@ -84969,9 +85336,9 @@ ${l}
|
|
|
84969
85336
|
const cols = getCurrentColumns();
|
|
84970
85337
|
let maxWidth;
|
|
84971
85338
|
if (relativeFrom === "page") {
|
|
84972
|
-
maxWidth = cols.count === 1 ? activePageSize.w -
|
|
85339
|
+
maxWidth = cols.count === 1 ? activePageSize.w - (activeLeftMargin + activeRightMargin) : activePageSize.w;
|
|
84973
85340
|
} else if (relativeFrom === "margin") {
|
|
84974
|
-
maxWidth = activePageSize.w -
|
|
85341
|
+
maxWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
84975
85342
|
} else {
|
|
84976
85343
|
maxWidth = cols.width;
|
|
84977
85344
|
}
|
|
@@ -86158,11 +86525,11 @@ ${l}
|
|
|
86158
86525
|
if (text2.length === 0) return null;
|
|
86159
86526
|
const clampedPos = Math.max(0, Math.min(localPos, text2.length));
|
|
86160
86527
|
let wordStart = clampedPos;
|
|
86161
|
-
while (wordStart > 0 && isWordChar(text2[wordStart - 1])) {
|
|
86528
|
+
while (wordStart > 0 && isWordChar$2(text2[wordStart - 1])) {
|
|
86162
86529
|
wordStart--;
|
|
86163
86530
|
}
|
|
86164
86531
|
let wordEnd = clampedPos;
|
|
86165
|
-
while (wordEnd < text2.length && isWordChar(text2[wordEnd])) {
|
|
86532
|
+
while (wordEnd < text2.length && isWordChar$2(text2[wordEnd])) {
|
|
86166
86533
|
wordEnd++;
|
|
86167
86534
|
}
|
|
86168
86535
|
if (wordStart === wordEnd) {
|
|
@@ -86225,7 +86592,7 @@ ${l}
|
|
|
86225
86592
|
}
|
|
86226
86593
|
return null;
|
|
86227
86594
|
}
|
|
86228
|
-
function isWordChar(char) {
|
|
86595
|
+
function isWordChar$2(char) {
|
|
86229
86596
|
return /[\p{L}\p{N}_]/u.test(char);
|
|
86230
86597
|
}
|
|
86231
86598
|
function isWhitespace$1(char) {
|
|
@@ -86260,6 +86627,29 @@ ${l}
|
|
|
86260
86627
|
function runText(run2) {
|
|
86261
86628
|
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
86262
86629
|
}
|
|
86630
|
+
const isWordChar$1 = (char) => {
|
|
86631
|
+
if (!char) return false;
|
|
86632
|
+
const code2 = char.charCodeAt(0);
|
|
86633
|
+
return code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 90 || code2 >= 97 && code2 <= 122 || char === "'";
|
|
86634
|
+
};
|
|
86635
|
+
const capitalizeText$1 = (text2, fullText, startOffset) => {
|
|
86636
|
+
if (!text2) return text2;
|
|
86637
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
86638
|
+
let result = "";
|
|
86639
|
+
for (let i2 = 0; i2 < text2.length; i2 += 1) {
|
|
86640
|
+
const prevChar = hasFullText ? startOffset + i2 > 0 ? fullText[startOffset + i2 - 1] : "" : i2 > 0 ? text2[i2 - 1] : "";
|
|
86641
|
+
const ch = text2[i2];
|
|
86642
|
+
result += isWordChar$1(ch) && !isWordChar$1(prevChar) ? ch.toUpperCase() : ch;
|
|
86643
|
+
}
|
|
86644
|
+
return result;
|
|
86645
|
+
};
|
|
86646
|
+
const applyTextTransform$1 = (text2, transform, fullText, startOffset) => {
|
|
86647
|
+
if (!text2 || !transform || transform === "none") return text2;
|
|
86648
|
+
if (transform === "uppercase") return text2.toUpperCase();
|
|
86649
|
+
if (transform === "lowercase") return text2.toLowerCase();
|
|
86650
|
+
if (transform === "capitalize") return capitalizeText$1(text2, fullText, startOffset);
|
|
86651
|
+
return text2;
|
|
86652
|
+
};
|
|
86263
86653
|
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
86264
86654
|
const TWIPS_PER_INCH$4 = 1440;
|
|
86265
86655
|
const PX_PER_INCH$3 = 96;
|
|
@@ -86268,6 +86658,13 @@ ${l}
|
|
|
86268
86658
|
const WIDTH_FUDGE_PX = 0.5;
|
|
86269
86659
|
const twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$1;
|
|
86270
86660
|
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
86661
|
+
const markerFontString = (run2) => {
|
|
86662
|
+
const size2 = run2?.fontSize ?? 16;
|
|
86663
|
+
const family = run2?.fontFamily ?? "Arial";
|
|
86664
|
+
const italic = run2?.italic ? "italic " : "";
|
|
86665
|
+
const bold = run2?.bold ? "bold " : "";
|
|
86666
|
+
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
86667
|
+
};
|
|
86271
86668
|
const buildTabStopsPx$1 = (indent2, tabs, tabIntervalTwips) => {
|
|
86272
86669
|
const paragraphIndentTwips = {
|
|
86273
86670
|
left: pxToTwips$1(Math.max(0, indent2?.left ?? 0)),
|
|
@@ -86298,7 +86695,9 @@ ${l}
|
|
|
86298
86695
|
};
|
|
86299
86696
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
86300
86697
|
const context = getCtx();
|
|
86301
|
-
const
|
|
86698
|
+
const fullText = runText(run2);
|
|
86699
|
+
const transform = isTextRun$2(run2) ? run2.textTransform : void 0;
|
|
86700
|
+
const text2 = applyTextTransform$1(fullText.slice(fromChar, toChar), transform, fullText, fromChar);
|
|
86302
86701
|
if (!context) {
|
|
86303
86702
|
const textRun = isTextRun$2(run2) ? run2 : null;
|
|
86304
86703
|
const size2 = textRun?.fontSize ?? 16;
|
|
@@ -86344,8 +86743,21 @@ ${l}
|
|
|
86344
86743
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
86345
86744
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
86346
86745
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
86347
|
-
const
|
|
86348
|
-
|
|
86746
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
86747
|
+
wordLayout,
|
|
86748
|
+
indentLeft,
|
|
86749
|
+
indentFirstLine,
|
|
86750
|
+
indentHanging,
|
|
86751
|
+
(markerText, marker) => {
|
|
86752
|
+
const context = getCtx();
|
|
86753
|
+
if (!context) return 0;
|
|
86754
|
+
context.font = markerFontString(marker.run);
|
|
86755
|
+
return context.measureText(markerText).width;
|
|
86756
|
+
}
|
|
86757
|
+
);
|
|
86758
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
86759
|
+
const treatAsHanging = !wordLayout?.marker && effectiveTextStartPx && indentLeft === 0 && indentHanging === 0;
|
|
86760
|
+
const firstLineWidth = typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - effectiveTextStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
86349
86761
|
const tabStops = buildTabStopsPx$1(indent2, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
86350
86762
|
let currentRun = 0;
|
|
86351
86763
|
let currentChar = 0;
|
|
@@ -86885,7 +87297,7 @@ ${l}
|
|
|
86885
87297
|
if (dirty.deletedBlockIds.length > 0) {
|
|
86886
87298
|
measureCache.invalidate(dirty.deletedBlockIds);
|
|
86887
87299
|
}
|
|
86888
|
-
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options);
|
|
87300
|
+
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options, nextBlocks);
|
|
86889
87301
|
if (measurementWidth <= 0 || measurementHeight <= 0) {
|
|
86890
87302
|
throw new Error("incrementalLayout: invalid measurement constraints resolved from options");
|
|
86891
87303
|
}
|
|
@@ -87154,7 +87566,7 @@ ${l}
|
|
|
87154
87566
|
const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
|
|
87155
87567
|
const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
87156
87568
|
const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
|
|
87157
|
-
function resolveMeasurementConstraints(options) {
|
|
87569
|
+
function resolveMeasurementConstraints(options, blocks2) {
|
|
87158
87570
|
const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
|
|
87159
87571
|
const margins = {
|
|
87160
87572
|
top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
|
|
@@ -87162,23 +87574,41 @@ ${l}
|
|
|
87162
87574
|
bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
|
|
87163
87575
|
left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
|
|
87164
87576
|
};
|
|
87165
|
-
const
|
|
87166
|
-
const
|
|
87167
|
-
const
|
|
87168
|
-
|
|
87577
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
87578
|
+
const baseContentHeight = pageSize.h - (margins.top + margins.bottom);
|
|
87579
|
+
const computeColumnWidth = (contentWidth, columns) => {
|
|
87580
|
+
if (!columns || columns.count <= 1) return contentWidth;
|
|
87169
87581
|
const gap = Math.max(0, columns.gap ?? 0);
|
|
87170
87582
|
const totalGap = gap * (columns.count - 1);
|
|
87171
|
-
|
|
87172
|
-
|
|
87173
|
-
|
|
87174
|
-
|
|
87175
|
-
|
|
87583
|
+
return (contentWidth - totalGap) / columns.count;
|
|
87584
|
+
};
|
|
87585
|
+
let measurementWidth = computeColumnWidth(baseContentWidth, options.columns);
|
|
87586
|
+
let measurementHeight = baseContentHeight;
|
|
87587
|
+
if (blocks2 && blocks2.length > 0) {
|
|
87588
|
+
for (const block of blocks2) {
|
|
87589
|
+
if (block.kind !== "sectionBreak") continue;
|
|
87590
|
+
const sectionPageSize = block.pageSize ?? pageSize;
|
|
87591
|
+
const sectionMargins = {
|
|
87592
|
+
top: normalizeMargin(block.margins?.top, margins.top),
|
|
87593
|
+
right: normalizeMargin(block.margins?.right, margins.right),
|
|
87594
|
+
bottom: normalizeMargin(block.margins?.bottom, margins.bottom),
|
|
87595
|
+
left: normalizeMargin(block.margins?.left, margins.left)
|
|
87176
87596
|
};
|
|
87597
|
+
const contentWidth = sectionPageSize.w - (sectionMargins.left + sectionMargins.right);
|
|
87598
|
+
const contentHeight = sectionPageSize.h - (sectionMargins.top + sectionMargins.bottom);
|
|
87599
|
+
if (contentWidth <= 0 || contentHeight <= 0) continue;
|
|
87600
|
+
const columnWidth = computeColumnWidth(contentWidth, block.columns ?? options.columns);
|
|
87601
|
+
if (columnWidth > measurementWidth) {
|
|
87602
|
+
measurementWidth = columnWidth;
|
|
87603
|
+
}
|
|
87604
|
+
if (contentHeight > measurementHeight) {
|
|
87605
|
+
measurementHeight = contentHeight;
|
|
87606
|
+
}
|
|
87177
87607
|
}
|
|
87178
87608
|
}
|
|
87179
87609
|
return {
|
|
87180
|
-
measurementWidth
|
|
87181
|
-
measurementHeight
|
|
87610
|
+
measurementWidth,
|
|
87611
|
+
measurementHeight
|
|
87182
87612
|
};
|
|
87183
87613
|
}
|
|
87184
87614
|
const serializeHeaderFooterResults = (kind, batch2) => {
|
|
@@ -89568,14 +89998,15 @@ ${l}
|
|
|
89568
89998
|
if (!schema) return [];
|
|
89569
89999
|
const types2 = [];
|
|
89570
90000
|
try {
|
|
89571
|
-
schema.nodes
|
|
90001
|
+
for (const name in schema.nodes) {
|
|
89572
90002
|
if (name === "text") {
|
|
89573
|
-
|
|
90003
|
+
continue;
|
|
89574
90004
|
}
|
|
89575
|
-
|
|
90005
|
+
const nodeType = schema.nodes[name];
|
|
90006
|
+
if (nodeType && (nodeType.isAtom || nodeType.isLeaf)) {
|
|
89576
90007
|
types2.push(name);
|
|
89577
90008
|
}
|
|
89578
|
-
}
|
|
90009
|
+
}
|
|
89579
90010
|
} catch {
|
|
89580
90011
|
return [];
|
|
89581
90012
|
}
|
|
@@ -93156,8 +93587,8 @@ ${l}
|
|
|
93156
93587
|
}
|
|
93157
93588
|
return void 0;
|
|
93158
93589
|
}
|
|
93159
|
-
const DEFAULT_LIST_HANGING_PX
|
|
93160
|
-
const LIST_MARKER_GAP
|
|
93590
|
+
const DEFAULT_LIST_HANGING_PX = 18;
|
|
93591
|
+
const LIST_MARKER_GAP = 8;
|
|
93161
93592
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
93162
93593
|
const DEFAULT_DECIMAL_PATTERN = "%1.";
|
|
93163
93594
|
const ASCII_UPPERCASE_A = 65;
|
|
@@ -93568,7 +93999,7 @@ ${l}
|
|
|
93568
93999
|
let markerBoxWidthPx;
|
|
93569
94000
|
let markerX;
|
|
93570
94001
|
if (hasFirstLineIndent) {
|
|
93571
|
-
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP
|
|
94002
|
+
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP : DEFAULT_LIST_HANGING_PX;
|
|
93572
94003
|
markerX = indentLeftPx + (firstLinePx ?? 0);
|
|
93573
94004
|
layout.textStartPx = markerX + markerBoxWidthPx;
|
|
93574
94005
|
layout.hangingPx = 0;
|
|
@@ -93668,12 +94099,12 @@ ${l}
|
|
|
93668
94099
|
let markerBox = Math.max(hangingPxRaw || 0, 0);
|
|
93669
94100
|
if (markerBox <= 0) {
|
|
93670
94101
|
if (glyphWidthPx != null && glyphWidthPx > 0) {
|
|
93671
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
94102
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
93672
94103
|
} else {
|
|
93673
|
-
markerBox = DEFAULT_LIST_HANGING_PX
|
|
94104
|
+
markerBox = DEFAULT_LIST_HANGING_PX;
|
|
93674
94105
|
}
|
|
93675
|
-
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP
|
|
93676
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
94106
|
+
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP > markerBox) {
|
|
94107
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
93677
94108
|
}
|
|
93678
94109
|
return markerBox;
|
|
93679
94110
|
};
|
|
@@ -93693,7 +94124,7 @@ ${l}
|
|
|
93693
94124
|
textStartX: textStartPx,
|
|
93694
94125
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
93695
94126
|
// Gutter is the small gap between marker and text, not the full marker box width
|
|
93696
|
-
gutterWidthPx: LIST_MARKER_GAP
|
|
94127
|
+
gutterWidthPx: LIST_MARKER_GAP,
|
|
93697
94128
|
justification: numbering.lvlJc ?? "left",
|
|
93698
94129
|
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
93699
94130
|
run: markerRun,
|
|
@@ -94385,6 +94816,31 @@ ${l}
|
|
|
94385
94816
|
return null;
|
|
94386
94817
|
}
|
|
94387
94818
|
};
|
|
94819
|
+
const normalizeWordLayoutForIndent = (wordLayout, paragraphIndent) => {
|
|
94820
|
+
const resolvedIndent = wordLayout.resolvedIndent ?? paragraphIndent ?? {};
|
|
94821
|
+
const indentLeft = isFiniteNumber(resolvedIndent.left) ? resolvedIndent.left : 0;
|
|
94822
|
+
const firstLine = isFiniteNumber(resolvedIndent.firstLine) ? resolvedIndent.firstLine : 0;
|
|
94823
|
+
const hanging = isFiniteNumber(resolvedIndent.hanging) ? resolvedIndent.hanging : 0;
|
|
94824
|
+
const shouldFirstLineIndentMode = firstLine > 0 && !hanging;
|
|
94825
|
+
if (wordLayout.firstLineIndentMode === true && !shouldFirstLineIndentMode) {
|
|
94826
|
+
wordLayout.firstLineIndentMode = false;
|
|
94827
|
+
}
|
|
94828
|
+
if (wordLayout.firstLineIndentMode === true) {
|
|
94829
|
+
if (isFiniteNumber(wordLayout.textStartPx)) {
|
|
94830
|
+
if (wordLayout.marker && (!isFiniteNumber(wordLayout.marker.textStartX) || wordLayout.marker.textStartX !== wordLayout.textStartPx)) {
|
|
94831
|
+
wordLayout.marker.textStartX = wordLayout.textStartPx;
|
|
94832
|
+
}
|
|
94833
|
+
} else if (wordLayout.marker && isFiniteNumber(wordLayout.marker.textStartX)) {
|
|
94834
|
+
wordLayout.textStartPx = wordLayout.marker.textStartX;
|
|
94835
|
+
}
|
|
94836
|
+
} else {
|
|
94837
|
+
wordLayout.textStartPx = indentLeft;
|
|
94838
|
+
if (wordLayout.marker) {
|
|
94839
|
+
wordLayout.marker.textStartX = indentLeft;
|
|
94840
|
+
}
|
|
94841
|
+
}
|
|
94842
|
+
return wordLayout;
|
|
94843
|
+
};
|
|
94388
94844
|
const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
|
|
94389
94845
|
const attrs = para.attrs ?? {};
|
|
94390
94846
|
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
@@ -94707,8 +95163,11 @@ ${l}
|
|
|
94707
95163
|
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
94708
95164
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
94709
95165
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
94710
|
-
const
|
|
94711
|
-
|
|
95166
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
95167
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
95168
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
95169
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
95170
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
94712
95171
|
wordLayout = {
|
|
94713
95172
|
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
94714
95173
|
firstLineIndentMode: true,
|
|
@@ -94716,10 +95175,13 @@ ${l}
|
|
|
94716
95175
|
};
|
|
94717
95176
|
}
|
|
94718
95177
|
}
|
|
94719
|
-
if (wordLayout &&
|
|
95178
|
+
if (wordLayout && !Number.isFinite(wordLayout.textStartPx) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
94720
95179
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
94721
|
-
const
|
|
94722
|
-
|
|
95180
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
95181
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
95182
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
95183
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
95184
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
94723
95185
|
wordLayout = {
|
|
94724
95186
|
...wordLayout,
|
|
94725
95187
|
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
@@ -94739,6 +95201,7 @@ ${l}
|
|
|
94739
95201
|
wordLayout.marker.suffix = listRendering.suffix;
|
|
94740
95202
|
}
|
|
94741
95203
|
}
|
|
95204
|
+
wordLayout = normalizeWordLayoutForIndent(wordLayout, paragraphAttrs.indent);
|
|
94742
95205
|
paragraphAttrs.wordLayout = wordLayout;
|
|
94743
95206
|
}
|
|
94744
95207
|
if (enrichedNumberingProps.resolvedLevelIndent) {
|
|
@@ -98855,11 +99318,6 @@ ${l}
|
|
|
98855
99318
|
cleanups
|
|
98856
99319
|
};
|
|
98857
99320
|
}
|
|
98858
|
-
const LIST_MARKER_GAP = 8;
|
|
98859
|
-
const MIN_MARKER_GUTTER = 24;
|
|
98860
|
-
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
98861
|
-
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
98862
|
-
const DEFAULT_LIST_HANGING_PX = 18;
|
|
98863
99321
|
function calculateRotatedBounds(input2) {
|
|
98864
99322
|
const width = Math.max(0, input2.width);
|
|
98865
99323
|
const height = Math.max(0, input2.height);
|
|
@@ -99123,8 +99581,25 @@ ${l}
|
|
|
99123
99581
|
const rawTextStartPx = wordLayout?.textStartPx;
|
|
99124
99582
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
99125
99583
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof rawTextStartPx === "number" && Number.isFinite(rawTextStartPx) ? rawTextStartPx : void 0;
|
|
99126
|
-
|
|
99127
|
-
|
|
99584
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
99585
|
+
wordLayout,
|
|
99586
|
+
indentLeft,
|
|
99587
|
+
firstLine,
|
|
99588
|
+
hanging,
|
|
99589
|
+
(markerText, marker) => {
|
|
99590
|
+
const markerRun = {
|
|
99591
|
+
fontFamily: toCssFontFamily(marker.run?.fontFamily) ?? marker.run?.fontFamily ?? "Arial",
|
|
99592
|
+
fontSize: marker.run?.fontSize ?? 16,
|
|
99593
|
+
bold: marker.run?.bold ?? false,
|
|
99594
|
+
italic: marker.run?.italic ?? false
|
|
99595
|
+
};
|
|
99596
|
+
const { font: markerFont } = buildFontString(markerRun);
|
|
99597
|
+
return measureText(markerText, markerFont, ctx2);
|
|
99598
|
+
}
|
|
99599
|
+
);
|
|
99600
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
99601
|
+
if (typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft) {
|
|
99602
|
+
initialAvailableWidth = Math.max(1, maxWidth - effectiveTextStartPx - indentRight);
|
|
99128
99603
|
} else {
|
|
99129
99604
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
99130
99605
|
}
|
|
@@ -99211,7 +99686,7 @@ ${l}
|
|
|
99211
99686
|
pendingTabAlignment = null;
|
|
99212
99687
|
return startX;
|
|
99213
99688
|
};
|
|
99214
|
-
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
99689
|
+
const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
|
|
99215
99690
|
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
99216
99691
|
const { val } = pendingTabAlignment;
|
|
99217
99692
|
let segmentWidth = 0;
|
|
@@ -99220,11 +99695,11 @@ ${l}
|
|
|
99220
99695
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
99221
99696
|
if (idx >= 0) {
|
|
99222
99697
|
const beforeText = segmentText.slice(0, idx);
|
|
99223
|
-
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
99698
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
99224
99699
|
}
|
|
99225
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
99700
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
99226
99701
|
} else if (val === "end" || val === "center") {
|
|
99227
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
99702
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
99228
99703
|
}
|
|
99229
99704
|
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
99230
99705
|
};
|
|
@@ -99276,8 +99751,8 @@ ${l}
|
|
|
99276
99751
|
const { font } = buildFontString(
|
|
99277
99752
|
lastRun
|
|
99278
99753
|
);
|
|
99279
|
-
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun);
|
|
99280
|
-
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun) : 0;
|
|
99754
|
+
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun, sliceStart);
|
|
99755
|
+
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun, sliceStart) : 0;
|
|
99281
99756
|
const delta = Math.max(0, fullWidth - keptWidth);
|
|
99282
99757
|
lineToTrim.width = roundValue(Math.max(0, lineToTrim.width - delta));
|
|
99283
99758
|
lineToTrim.spaceCount = Math.max(0, lineToTrim.spaceCount - trimCount);
|
|
@@ -99488,7 +99963,8 @@ ${l}
|
|
|
99488
99963
|
continue;
|
|
99489
99964
|
}
|
|
99490
99965
|
if (isFieldAnnotationRun(run2)) {
|
|
99491
|
-
const
|
|
99966
|
+
const rawDisplayText = run2.displayLabel || "";
|
|
99967
|
+
const displayText = applyTextTransform(rawDisplayText, run2);
|
|
99492
99968
|
const annotationFontSize = typeof run2.fontSize === "number" ? run2.fontSize : typeof run2.fontSize === "string" ? parseFloat(run2.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE : DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
|
|
99493
99969
|
const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
|
|
99494
99970
|
const fontWeight = run2.bold ? "bold" : "normal";
|
|
@@ -99591,7 +100067,7 @@ ${l}
|
|
|
99591
100067
|
const spacesLength = segment.length;
|
|
99592
100068
|
const spacesStartChar = charPosInRun;
|
|
99593
100069
|
const spacesEndChar = charPosInRun + spacesLength;
|
|
99594
|
-
const spacesWidth = measureRunWidth(segment, font, ctx2, run2);
|
|
100070
|
+
const spacesWidth = measureRunWidth(segment, font, ctx2, run2, spacesStartChar);
|
|
99595
100071
|
if (!currentLine) {
|
|
99596
100072
|
currentLine = {
|
|
99597
100073
|
fromRun: runIndex,
|
|
@@ -99655,7 +100131,7 @@ ${l}
|
|
|
99655
100131
|
}
|
|
99656
100132
|
let segmentStartX;
|
|
99657
100133
|
if (currentLine && pendingTabAlignment) {
|
|
99658
|
-
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
100134
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2, charPosInRun);
|
|
99659
100135
|
if (segmentStartX == null) {
|
|
99660
100136
|
segmentStartX = currentLine.width;
|
|
99661
100137
|
}
|
|
@@ -99665,7 +100141,7 @@ ${l}
|
|
|
99665
100141
|
if (word2 === "") {
|
|
99666
100142
|
const spaceStartChar = charPosInRun;
|
|
99667
100143
|
const spaceEndChar = charPosInRun + 1;
|
|
99668
|
-
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2);
|
|
100144
|
+
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2, spaceStartChar);
|
|
99669
100145
|
if (!currentLine) {
|
|
99670
100146
|
currentLine = {
|
|
99671
100147
|
fromRun: runIndex,
|
|
@@ -99716,12 +100192,12 @@ ${l}
|
|
|
99716
100192
|
charPosInRun = spaceEndChar;
|
|
99717
100193
|
continue;
|
|
99718
100194
|
}
|
|
99719
|
-
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2);
|
|
99720
|
-
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
99721
|
-
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2) : 0;
|
|
99722
|
-
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
99723
100195
|
const wordStartChar = charPosInRun;
|
|
100196
|
+
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2, wordStartChar);
|
|
100197
|
+
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
99724
100198
|
const wordEndNoSpace = charPosInRun + word2.length;
|
|
100199
|
+
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) : 0;
|
|
100200
|
+
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
99725
100201
|
const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
|
|
99726
100202
|
const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
|
|
99727
100203
|
if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
|
|
@@ -99740,7 +100216,7 @@ ${l}
|
|
|
99740
100216
|
const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
99741
100217
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
99742
100218
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
99743
|
-
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
|
|
100219
|
+
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2, wordStartChar);
|
|
99744
100220
|
let chunkCharOffset = wordStartChar;
|
|
99745
100221
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
99746
100222
|
const chunk = chunks[chunkIndex];
|
|
@@ -99864,7 +100340,7 @@ ${l}
|
|
|
99864
100340
|
if (candidateSpaces > 0) {
|
|
99865
100341
|
const overflow = totalWidthWithWord - availableWidth;
|
|
99866
100342
|
if (overflow > 0) {
|
|
99867
|
-
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2) || Math.max(1, boundarySpacing);
|
|
100343
|
+
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) || Math.max(1, boundarySpacing);
|
|
99868
100344
|
const perSpaceCompression = overflow / candidateSpaces;
|
|
99869
100345
|
const maxPerSpaceCompression = baseSpaceWidth * 0.25;
|
|
99870
100346
|
if (perSpaceCompression <= maxPerSpaceCompression) {
|
|
@@ -100039,8 +100515,8 @@ ${l}
|
|
|
100039
100515
|
const { font: markerFont } = buildFontString(markerRun);
|
|
100040
100516
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
100041
100517
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
100042
|
-
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
100043
|
-
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
|
|
100518
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
100519
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP$1);
|
|
100044
100520
|
markerInfo = {
|
|
100045
100521
|
markerWidth: markerBoxWidth,
|
|
100046
100522
|
markerTextWidth: glyphWidth,
|
|
@@ -100384,7 +100860,7 @@ ${l}
|
|
|
100384
100860
|
markerTextWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
100385
100861
|
indentLeft = resolveIndentLeft(item);
|
|
100386
100862
|
const indentHanging = resolveIndentHanging(item);
|
|
100387
|
-
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP, indentHanging);
|
|
100863
|
+
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP$1, indentHanging);
|
|
100388
100864
|
}
|
|
100389
100865
|
const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
|
|
100390
100866
|
const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
|
|
@@ -100410,16 +100886,46 @@ ${l}
|
|
|
100410
100886
|
fontSize: 16
|
|
100411
100887
|
};
|
|
100412
100888
|
};
|
|
100413
|
-
const
|
|
100889
|
+
const isWordChar = (char) => {
|
|
100890
|
+
if (!char) return false;
|
|
100891
|
+
const code2 = char.charCodeAt(0);
|
|
100892
|
+
return code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 90 || code2 >= 97 && code2 <= 122 || char === "'";
|
|
100893
|
+
};
|
|
100894
|
+
const capitalizeText = (text2, fullText, startOffset) => {
|
|
100895
|
+
if (!text2) return text2;
|
|
100896
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
100897
|
+
let result = "";
|
|
100898
|
+
for (let i2 = 0; i2 < text2.length; i2 += 1) {
|
|
100899
|
+
const prevChar = hasFullText ? startOffset + i2 > 0 ? fullText[startOffset + i2 - 1] : "" : i2 > 0 ? text2[i2 - 1] : "";
|
|
100900
|
+
const ch = text2[i2];
|
|
100901
|
+
result += isWordChar(ch) && !isWordChar(prevChar) ? ch.toUpperCase() : ch;
|
|
100902
|
+
}
|
|
100903
|
+
return result;
|
|
100904
|
+
};
|
|
100905
|
+
const applyTextTransform = (text2, run2, startOffset) => {
|
|
100906
|
+
const transform = "textTransform" in run2 ? run2.textTransform : void 0;
|
|
100907
|
+
if (!text2 || !transform || transform === "none") return text2;
|
|
100908
|
+
if (transform === "uppercase") return text2.toUpperCase();
|
|
100909
|
+
if (transform === "lowercase") return text2.toLowerCase();
|
|
100910
|
+
if (transform === "capitalize") {
|
|
100911
|
+
const fullText = "text" in run2 && typeof run2.text === "string" ? run2.text : text2;
|
|
100912
|
+
return capitalizeText(text2, fullText, startOffset);
|
|
100913
|
+
}
|
|
100914
|
+
return text2;
|
|
100915
|
+
};
|
|
100916
|
+
const measureRunWidth = (text2, font, ctx2, run2, startOffset) => {
|
|
100414
100917
|
const letterSpacing = run2.kind === "text" || run2.kind === void 0 ? run2.letterSpacing || 0 : 0;
|
|
100415
|
-
const
|
|
100918
|
+
const displayText = applyTextTransform(text2, run2, startOffset);
|
|
100919
|
+
const width = getMeasuredTextWidth(displayText, font, letterSpacing, ctx2);
|
|
100416
100920
|
return roundValue(width);
|
|
100417
100921
|
};
|
|
100418
|
-
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
100922
|
+
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2, startOffset) => {
|
|
100419
100923
|
const chunks = [];
|
|
100924
|
+
const baseOffset = typeof startOffset === "number" ? startOffset : 0;
|
|
100420
100925
|
if (maxWidth <= 0) {
|
|
100421
|
-
for (
|
|
100422
|
-
const
|
|
100926
|
+
for (let i2 = 0; i2 < word2.length; i2++) {
|
|
100927
|
+
const char = word2[i2];
|
|
100928
|
+
const charWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i2);
|
|
100423
100929
|
chunks.push({ text: char, width: charWidth });
|
|
100424
100930
|
}
|
|
100425
100931
|
return chunks;
|
|
@@ -100429,11 +100935,11 @@ ${l}
|
|
|
100429
100935
|
for (let i2 = 0; i2 < word2.length; i2++) {
|
|
100430
100936
|
const char = word2[i2];
|
|
100431
100937
|
const testChunk = currentChunk + char;
|
|
100432
|
-
const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
|
|
100938
|
+
const testWidth = measureRunWidth(testChunk, font, ctx2, run2, baseOffset);
|
|
100433
100939
|
if (testWidth > maxWidth && currentChunk.length > 0) {
|
|
100434
100940
|
chunks.push({ text: currentChunk, width: currentWidth });
|
|
100435
100941
|
currentChunk = char;
|
|
100436
|
-
currentWidth = measureRunWidth(char, font, ctx2, run2);
|
|
100942
|
+
currentWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i2);
|
|
100437
100943
|
} else {
|
|
100438
100944
|
currentChunk = testChunk;
|
|
100439
100945
|
currentWidth = testWidth;
|
|
@@ -100487,7 +100993,8 @@ ${l}
|
|
|
100487
100993
|
italic: run2.italic
|
|
100488
100994
|
});
|
|
100489
100995
|
ctx2.font = font;
|
|
100490
|
-
const
|
|
100996
|
+
const displayText = applyTextTransform(run2.text, run2);
|
|
100997
|
+
const metrics = ctx2.measureText(displayText);
|
|
100491
100998
|
const advanceWidth = metrics.width;
|
|
100492
100999
|
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
100493
101000
|
const textWidth = Math.max(advanceWidth, paintedWidth);
|
|
@@ -100513,7 +101020,7 @@ ${l}
|
|
|
100513
101020
|
if (indentHanging > 0) {
|
|
100514
101021
|
return indentHanging;
|
|
100515
101022
|
}
|
|
100516
|
-
return DEFAULT_LIST_HANGING_PX;
|
|
101023
|
+
return DEFAULT_LIST_HANGING_PX$1;
|
|
100517
101024
|
};
|
|
100518
101025
|
const buildTabStopsPx = (indent2, tabs, tabIntervalTwips) => {
|
|
100519
101026
|
const paragraphIndentTwips = {
|
|
@@ -157258,7 +157765,7 @@ ${style2}
|
|
|
157258
157765
|
this.config.colors = shuffleArray(this.config.colors);
|
|
157259
157766
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
157260
157767
|
this.colorIndex = 0;
|
|
157261
|
-
this.version = "2.0.0-next.
|
|
157768
|
+
this.version = "2.0.0-next.4";
|
|
157262
157769
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
157263
157770
|
this.superdocId = config2.superdocId || v4();
|
|
157264
157771
|
this.colors = this.config.colors;
|
|
@@ -159731,7 +160238,7 @@ ${style2}
|
|
|
159731
160238
|
value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
|
|
159732
160239
|
);
|
|
159733
160240
|
}
|
|
159734
|
-
const
|
|
160241
|
+
const indexYoL4XmHs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
159735
160242
|
__proto__: null,
|
|
159736
160243
|
unified
|
|
159737
160244
|
}, Symbol.toStringTag, { value: "Module" }));
|