@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
|
@@ -42427,7 +42427,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42427
42427
|
static getStoredSuperdocVersion(docx) {
|
|
42428
42428
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42429
42429
|
}
|
|
42430
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.
|
|
42430
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.4") {
|
|
42431
42431
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42432
42432
|
}
|
|
42433
42433
|
/**
|
|
@@ -60508,7 +60508,7 @@ const isHeadless = (editor) => {
|
|
|
60508
60508
|
const shouldSkipNodeView = (editor) => {
|
|
60509
60509
|
return isHeadless(editor);
|
|
60510
60510
|
};
|
|
60511
|
-
const summaryVersion = "2.0.0-next.
|
|
60511
|
+
const summaryVersion = "2.0.0-next.4";
|
|
60512
60512
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
60513
60513
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
60514
60514
|
function mapAttributes(attrs) {
|
|
@@ -61297,7 +61297,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
61297
61297
|
{ default: remarkStringify },
|
|
61298
61298
|
{ default: remarkGfm }
|
|
61299
61299
|
] = await Promise.all([
|
|
61300
|
-
Promise.resolve().then(() => require("./index-
|
|
61300
|
+
Promise.resolve().then(() => require("./index-YoL4XmHs-DgX6YU__.cjs")),
|
|
61301
61301
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
61302
61302
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
61303
61303
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -61502,7 +61502,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
61502
61502
|
* Process collaboration migrations
|
|
61503
61503
|
*/
|
|
61504
61504
|
processCollaborationMigrations() {
|
|
61505
|
-
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.
|
|
61505
|
+
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.4");
|
|
61506
61506
|
if (!this.options.ydoc) return;
|
|
61507
61507
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
61508
61508
|
let docVersion = metaMap.get("version");
|
|
@@ -68754,7 +68754,7 @@ function isMinimalWordLayout(value) {
|
|
|
68754
68754
|
return true;
|
|
68755
68755
|
}
|
|
68756
68756
|
const LIST_MARKER_GAP$2 = 8;
|
|
68757
|
-
const DEFAULT_TAB_INTERVAL_PX$
|
|
68757
|
+
const DEFAULT_TAB_INTERVAL_PX$2 = 48;
|
|
68758
68758
|
const DEFAULT_PAGE_HEIGHT_PX = 1056;
|
|
68759
68759
|
const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
|
|
68760
68760
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
@@ -69681,6 +69681,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69681
69681
|
const block = lookup2.block;
|
|
69682
69682
|
const measure = lookup2.measure;
|
|
69683
69683
|
const wordLayout = isMinimalWordLayout(block.attrs?.wordLayout) ? block.attrs.wordLayout : void 0;
|
|
69684
|
+
const alignment2 = block.attrs?.alignment;
|
|
69684
69685
|
const fragmentEl = this.doc.createElement("div");
|
|
69685
69686
|
fragmentEl.classList.add(CLASS_NAMES$1.fragment);
|
|
69686
69687
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
@@ -69759,7 +69760,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69759
69760
|
const textStart = paraIndentLeft + firstLine;
|
|
69760
69761
|
tabWidth = textStart - currentPos;
|
|
69761
69762
|
if (tabWidth <= 0) {
|
|
69762
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
69763
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
69763
69764
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
69764
69765
|
tabWidth = LIST_MARKER_GAP$2;
|
|
69765
69766
|
}
|
|
@@ -69786,6 +69787,21 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69786
69787
|
let availableWidthOverride = line.maxWidth != null ? Math.min(line.maxWidth, fallbackAvailableWidth) : fallbackAvailableWidth;
|
|
69787
69788
|
if (index2 === 0 && listFirstLineMarkerTabWidth != null) {
|
|
69788
69789
|
availableWidthOverride = fragment.width - listFirstLineMarkerTabWidth - Math.max(0, paraIndentRight);
|
|
69790
|
+
if (alignment2 === "justify" || alignment2 === "both") {
|
|
69791
|
+
console.log(
|
|
69792
|
+
"[justify-debug][painter-firstline-available]",
|
|
69793
|
+
JSON.stringify({
|
|
69794
|
+
blockId: block.id,
|
|
69795
|
+
fragmentWidth: fragment.width,
|
|
69796
|
+
markerTabWidth: listFirstLineMarkerTabWidth,
|
|
69797
|
+
paraIndentRight,
|
|
69798
|
+
availableWidthOverride,
|
|
69799
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
69800
|
+
lineWidth: line.width,
|
|
69801
|
+
lineNaturalWidth: line.naturalWidth ?? null
|
|
69802
|
+
})
|
|
69803
|
+
);
|
|
69804
|
+
}
|
|
69789
69805
|
}
|
|
69790
69806
|
const isLastLineOfFragment = index2 === lines.length - 1;
|
|
69791
69807
|
const isLastLineOfParagraph = isLastLineOfFragment && !fragment.continuesOnNext;
|
|
@@ -69911,7 +69927,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69911
69927
|
const textStart = paraIndentLeft + firstLine;
|
|
69912
69928
|
tabWidth = textStart - currentPos;
|
|
69913
69929
|
if (tabWidth <= 0) {
|
|
69914
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
69930
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
69915
69931
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
69916
69932
|
tabWidth = LIST_MARKER_GAP$2;
|
|
69917
69933
|
}
|
|
@@ -71445,6 +71461,23 @@ const _DomPainter = class _DomPainter2 {
|
|
|
71445
71461
|
if (spacingPerSpace !== 0) {
|
|
71446
71462
|
el.style.wordSpacing = `${spacingPerSpace}px`;
|
|
71447
71463
|
}
|
|
71464
|
+
if (justifyShouldApply && spacingPerSpace < 0) {
|
|
71465
|
+
console.log(
|
|
71466
|
+
"[justify-debug][painter-wordspacing-negative]",
|
|
71467
|
+
JSON.stringify({
|
|
71468
|
+
blockId: block.id,
|
|
71469
|
+
lineIndex: lineIndex ?? null,
|
|
71470
|
+
alignment: alignment2 ?? null,
|
|
71471
|
+
availableWidth,
|
|
71472
|
+
lineWidth,
|
|
71473
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
71474
|
+
lineNaturalWidth: line.naturalWidth ?? null,
|
|
71475
|
+
spaceCount,
|
|
71476
|
+
hasExplicitPositioning: Boolean(hasExplicitPositioning),
|
|
71477
|
+
skipJustify: Boolean(skipJustify)
|
|
71478
|
+
})
|
|
71479
|
+
);
|
|
71480
|
+
}
|
|
71448
71481
|
if (hasExplicitPositioning && line.segments) {
|
|
71449
71482
|
const paraIndent = block.attrs?.indent;
|
|
71450
71483
|
const indentLeft = paraIndent?.left ?? 0;
|
|
@@ -73638,6 +73671,28 @@ let measurementCtx = null;
|
|
|
73638
73671
|
const TAB_CHAR_LENGTH = 1;
|
|
73639
73672
|
const SPACE_CHARS = SPACE_CHARS$1;
|
|
73640
73673
|
const isTabRun$1 = (run2) => run2?.kind === "tab";
|
|
73674
|
+
const isWordChar$3 = (char) => {
|
|
73675
|
+
if (!char) return false;
|
|
73676
|
+
const code = char.charCodeAt(0);
|
|
73677
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
73678
|
+
};
|
|
73679
|
+
const capitalizeText$2 = (text) => {
|
|
73680
|
+
if (!text) return text;
|
|
73681
|
+
let result = "";
|
|
73682
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
73683
|
+
const prevChar = i > 0 ? text[i - 1] : "";
|
|
73684
|
+
const ch = text[i];
|
|
73685
|
+
result += isWordChar$3(ch) && !isWordChar$3(prevChar) ? ch.toUpperCase() : ch;
|
|
73686
|
+
}
|
|
73687
|
+
return result;
|
|
73688
|
+
};
|
|
73689
|
+
const applyTextTransform$2 = (text, transform) => {
|
|
73690
|
+
if (!text || !transform || transform === "none") return text;
|
|
73691
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
73692
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
73693
|
+
if (transform === "capitalize") return capitalizeText$2(text);
|
|
73694
|
+
return text;
|
|
73695
|
+
};
|
|
73641
73696
|
function getMeasurementContext() {
|
|
73642
73697
|
if (measurementCtx) return measurementCtx;
|
|
73643
73698
|
if (typeof document === "undefined") {
|
|
@@ -73813,17 +73868,19 @@ function measureCharacterX(block, line, charOffset, availableWidthOverride, alig
|
|
|
73813
73868
|
}
|
|
73814
73869
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73815
73870
|
const runLength = text.length;
|
|
73871
|
+
const transform = isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? void 0 : run2.textTransform;
|
|
73872
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73816
73873
|
if (currentCharOffset + runLength >= charOffset) {
|
|
73817
73874
|
const offsetInRun = charOffset - currentCharOffset;
|
|
73818
73875
|
ctx2.font = getRunFontString(run2);
|
|
73819
|
-
const textUpToTarget =
|
|
73876
|
+
const textUpToTarget = displayText.slice(0, offsetInRun);
|
|
73820
73877
|
const measured2 = ctx2.measureText(textUpToTarget);
|
|
73821
73878
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
|
|
73822
|
-
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(
|
|
73879
|
+
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(text.slice(0, offsetInRun)) : 0;
|
|
73823
73880
|
return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73824
73881
|
}
|
|
73825
73882
|
ctx2.font = getRunFontString(run2);
|
|
73826
|
-
const measured = ctx2.measureText(
|
|
73883
|
+
const measured = ctx2.measureText(displayText);
|
|
73827
73884
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73828
73885
|
const spacesInRun = justify.extraPerSpace !== 0 ? countSpaces(text) : 0;
|
|
73829
73886
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -73862,8 +73919,10 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
73862
73919
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
73863
73920
|
}
|
|
73864
73921
|
const text = run2.text ?? "";
|
|
73865
|
-
const
|
|
73866
|
-
const
|
|
73922
|
+
const transform = "textTransform" in run2 ? run2.textTransform : void 0;
|
|
73923
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73924
|
+
const displaySegmentText = displayText.slice(segment.fromChar, segment.toChar);
|
|
73925
|
+
const textUpToTarget = displaySegmentText.slice(0, offsetInSegment);
|
|
73867
73926
|
ctx2.font = getRunFontString(run2);
|
|
73868
73927
|
const measured = ctx2.measureText(textUpToTarget);
|
|
73869
73928
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInSegment, segmentChars);
|
|
@@ -73959,12 +74018,14 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73959
74018
|
}
|
|
73960
74019
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73961
74020
|
const runLength = text.length;
|
|
74021
|
+
const transform = isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? void 0 : run2.textTransform;
|
|
74022
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73962
74023
|
if (runLength === 0) continue;
|
|
73963
74024
|
ctx2.font = getRunFontString(run2);
|
|
73964
74025
|
for (let i = 0; i <= runLength; i++) {
|
|
73965
|
-
const textUpToChar =
|
|
74026
|
+
const textUpToChar = displayText.slice(0, i);
|
|
73966
74027
|
const measured2 = ctx2.measureText(textUpToChar);
|
|
73967
|
-
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(
|
|
74028
|
+
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text.slice(0, i)) : 0;
|
|
73968
74029
|
const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73969
74030
|
if (charX >= safeX) {
|
|
73970
74031
|
if (i === 0) {
|
|
@@ -73974,7 +74035,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73974
74035
|
pmPosition: pmPosition3
|
|
73975
74036
|
};
|
|
73976
74037
|
}
|
|
73977
|
-
const prevText =
|
|
74038
|
+
const prevText = displayText.slice(0, i - 1);
|
|
73978
74039
|
const prevMeasured = ctx2.measureText(prevText);
|
|
73979
74040
|
const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run2, i - 1, runLength);
|
|
73980
74041
|
const distToPrev = Math.abs(safeX - prevX);
|
|
@@ -73987,7 +74048,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73987
74048
|
};
|
|
73988
74049
|
}
|
|
73989
74050
|
}
|
|
73990
|
-
const measured = ctx2.measureText(
|
|
74051
|
+
const measured = ctx2.measureText(displayText);
|
|
73991
74052
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73992
74053
|
const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
|
|
73993
74054
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -74418,6 +74479,83 @@ function findCharIndexAtX(textNode, container, targetX) {
|
|
|
74418
74479
|
}
|
|
74419
74480
|
return index2;
|
|
74420
74481
|
}
|
|
74482
|
+
const LIST_MARKER_GAP$1 = 8;
|
|
74483
|
+
const MIN_MARKER_GUTTER = 24;
|
|
74484
|
+
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
74485
|
+
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
74486
|
+
const DEFAULT_LIST_HANGING_PX$1 = 18;
|
|
74487
|
+
const SPACE_SUFFIX_GAP_PX = 4;
|
|
74488
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
74489
|
+
function resolveListTextStartPx(wordLayout, indentLeft, firstLine, hanging, measureMarkerText) {
|
|
74490
|
+
const marker = wordLayout?.marker;
|
|
74491
|
+
if (!marker) {
|
|
74492
|
+
const textStartPx = wordLayout?.firstLineIndentMode === true && typeof wordLayout.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
74493
|
+
return textStartPx;
|
|
74494
|
+
}
|
|
74495
|
+
const markerBoxWidth = typeof marker.markerBoxWidthPx === "number" && Number.isFinite(marker.markerBoxWidthPx) ? marker.markerBoxWidthPx : 0;
|
|
74496
|
+
let markerTextWidth = typeof marker.glyphWidthPx === "number" && Number.isFinite(marker.glyphWidthPx) ? marker.glyphWidthPx : void 0;
|
|
74497
|
+
if (markerTextWidth == null && marker.markerText) {
|
|
74498
|
+
markerTextWidth = measureMarkerText(marker.markerText, marker);
|
|
74499
|
+
}
|
|
74500
|
+
if (!Number.isFinite(markerTextWidth) || markerTextWidth !== void 0 && markerTextWidth < 0) {
|
|
74501
|
+
markerTextWidth = markerBoxWidth;
|
|
74502
|
+
}
|
|
74503
|
+
const finalMarkerTextWidth = Math.max(0, markerTextWidth ?? 0);
|
|
74504
|
+
let markerStartPos;
|
|
74505
|
+
if (wordLayout?.firstLineIndentMode === true && typeof marker.markerX === "number" && Number.isFinite(marker.markerX)) {
|
|
74506
|
+
markerStartPos = marker.markerX;
|
|
74507
|
+
} else {
|
|
74508
|
+
markerStartPos = indentLeft - hanging + firstLine;
|
|
74509
|
+
}
|
|
74510
|
+
if (!Number.isFinite(markerStartPos)) {
|
|
74511
|
+
markerStartPos = 0;
|
|
74512
|
+
}
|
|
74513
|
+
const currentPos = markerStartPos + finalMarkerTextWidth;
|
|
74514
|
+
const suffix2 = marker.suffix ?? "tab";
|
|
74515
|
+
if (suffix2 === "space") {
|
|
74516
|
+
return markerStartPos + finalMarkerTextWidth + SPACE_SUFFIX_GAP_PX;
|
|
74517
|
+
}
|
|
74518
|
+
if (suffix2 === "nothing") {
|
|
74519
|
+
return markerStartPos + finalMarkerTextWidth;
|
|
74520
|
+
}
|
|
74521
|
+
const markerJustification = marker.justification ?? "left";
|
|
74522
|
+
if (markerJustification !== "left") {
|
|
74523
|
+
const gutterWidth = typeof marker.gutterWidthPx === "number" && Number.isFinite(marker.gutterWidthPx) && marker.gutterWidthPx > 0 ? marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
74524
|
+
return markerStartPos + finalMarkerTextWidth + Math.max(gutterWidth, LIST_MARKER_GAP$1);
|
|
74525
|
+
}
|
|
74526
|
+
if (wordLayout?.firstLineIndentMode === true) {
|
|
74527
|
+
let targetTabStop;
|
|
74528
|
+
if (Array.isArray(wordLayout.tabsPx)) {
|
|
74529
|
+
for (const tab of wordLayout.tabsPx) {
|
|
74530
|
+
if (typeof tab === "number" && tab > currentPos) {
|
|
74531
|
+
targetTabStop = tab;
|
|
74532
|
+
break;
|
|
74533
|
+
}
|
|
74534
|
+
}
|
|
74535
|
+
}
|
|
74536
|
+
const textStartTarget = typeof marker.textStartX === "number" && Number.isFinite(marker.textStartX) ? marker.textStartX : wordLayout.textStartPx;
|
|
74537
|
+
let tabWidth2;
|
|
74538
|
+
if (targetTabStop !== void 0) {
|
|
74539
|
+
tabWidth2 = targetTabStop - currentPos;
|
|
74540
|
+
} else if (textStartTarget !== void 0 && Number.isFinite(textStartTarget) && textStartTarget > currentPos) {
|
|
74541
|
+
tabWidth2 = textStartTarget - currentPos;
|
|
74542
|
+
} else {
|
|
74543
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74544
|
+
}
|
|
74545
|
+
if (tabWidth2 < LIST_MARKER_GAP$1) {
|
|
74546
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74547
|
+
}
|
|
74548
|
+
return markerStartPos + finalMarkerTextWidth + tabWidth2;
|
|
74549
|
+
}
|
|
74550
|
+
const textStart = indentLeft + firstLine;
|
|
74551
|
+
let tabWidth = textStart - currentPos;
|
|
74552
|
+
if (tabWidth <= 0) {
|
|
74553
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
74554
|
+
} else if (tabWidth < LIST_MARKER_GAP$1) {
|
|
74555
|
+
tabWidth = LIST_MARKER_GAP$1;
|
|
74556
|
+
}
|
|
74557
|
+
return markerStartPos + finalMarkerTextWidth + tabWidth;
|
|
74558
|
+
}
|
|
74421
74559
|
function getWordLayoutConfig(block) {
|
|
74422
74560
|
if (!block || block.kind !== "paragraph") {
|
|
74423
74561
|
return void 0;
|
|
@@ -74450,9 +74588,16 @@ function calculateTextStartIndent(params2) {
|
|
|
74450
74588
|
const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
|
|
74451
74589
|
let indentAdjust = paraIndentLeft;
|
|
74452
74590
|
if (isListItem2 && isFirstLine && isFirstLineIndentMode) {
|
|
74591
|
+
const resolvedTextStart = resolveListTextStartPx(
|
|
74592
|
+
wordLayout,
|
|
74593
|
+
paraIndentLeft,
|
|
74594
|
+
Math.max(firstLineIndent, 0),
|
|
74595
|
+
Math.max(hangingIndent, 0),
|
|
74596
|
+
() => markerWidth
|
|
74597
|
+
// Use provided markerWidth since we don't have canvas access here
|
|
74598
|
+
);
|
|
74453
74599
|
const textStartFallback = paraIndentLeft + Math.max(firstLineIndent, 0) + markerWidth;
|
|
74454
|
-
|
|
74455
|
-
indentAdjust = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : textStartFallback;
|
|
74600
|
+
indentAdjust = typeof resolvedTextStart === "number" && Number.isFinite(resolvedTextStart) ? resolvedTextStart : textStartFallback;
|
|
74456
74601
|
} else if (isFirstLine && !isListItem2) {
|
|
74457
74602
|
indentAdjust += firstLineOffset;
|
|
74458
74603
|
}
|
|
@@ -74608,7 +74753,10 @@ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, opt
|
|
|
74608
74753
|
}
|
|
74609
74754
|
function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
74610
74755
|
const zones = [];
|
|
74611
|
-
|
|
74756
|
+
let currentColumns = columns;
|
|
74757
|
+
let currentMargins = margins;
|
|
74758
|
+
let currentPageWidth = pageWidth;
|
|
74759
|
+
let marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74612
74760
|
return {
|
|
74613
74761
|
registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
74614
74762
|
if (!drawingBlock.anchor?.isAnchored) {
|
|
@@ -74621,7 +74769,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74621
74769
|
}
|
|
74622
74770
|
const objectWidth = measure.width ?? 0;
|
|
74623
74771
|
const objectHeight = measure.height ?? 0;
|
|
74624
|
-
const x2 = computeAnchorX(anchor, columnIndex,
|
|
74772
|
+
const x2 = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
|
|
74625
74773
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74626
74774
|
const zone = {
|
|
74627
74775
|
imageBlockId: drawingBlock.id,
|
|
@@ -74655,7 +74803,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74655
74803
|
}
|
|
74656
74804
|
const tableWidth = measure.totalWidth ?? 0;
|
|
74657
74805
|
const tableHeight = measure.totalHeight ?? 0;
|
|
74658
|
-
const x2 = computeTableAnchorX(anchor, columnIndex,
|
|
74806
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
|
|
74659
74807
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74660
74808
|
const zone = {
|
|
74661
74809
|
imageBlockId: tableBlock.id,
|
|
@@ -74703,7 +74851,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74703
74851
|
}
|
|
74704
74852
|
const leftFloats = [];
|
|
74705
74853
|
const rightFloats = [];
|
|
74706
|
-
const columnOrigin = marginLeft + columnIndex * (
|
|
74854
|
+
const columnOrigin = marginLeft + columnIndex * (currentColumns.width + currentColumns.gap);
|
|
74707
74855
|
const columnCenter = columnOrigin + baseWidth / 2;
|
|
74708
74856
|
for (const zone of wrappingZones) {
|
|
74709
74857
|
if (zone.wrapMode === "left") {
|
|
@@ -74742,6 +74890,22 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74742
74890
|
},
|
|
74743
74891
|
clear() {
|
|
74744
74892
|
zones.length = 0;
|
|
74893
|
+
},
|
|
74894
|
+
/**
|
|
74895
|
+
* Update layout context used for positioning and wrapping (columns, margins, page width).
|
|
74896
|
+
* This method should be called when the layout configuration changes (e.g., section breaks,
|
|
74897
|
+
* column changes, page size changes) to ensure floating objects are positioned and wrapped
|
|
74898
|
+
* correctly relative to the new layout boundaries.
|
|
74899
|
+
*
|
|
74900
|
+
* @param nextColumns - Column layout configuration (width, gap, count)
|
|
74901
|
+
* @param nextMargins - Optional page margins (left, right) in pixels
|
|
74902
|
+
* @param nextPageWidth - Optional total page width in pixels
|
|
74903
|
+
*/
|
|
74904
|
+
setLayoutContext(nextColumns, nextMargins, nextPageWidth) {
|
|
74905
|
+
currentColumns = nextColumns;
|
|
74906
|
+
currentMargins = nextMargins;
|
|
74907
|
+
currentPageWidth = nextPageWidth;
|
|
74908
|
+
marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74745
74909
|
}
|
|
74746
74910
|
};
|
|
74747
74911
|
}
|
|
@@ -74841,7 +75005,14 @@ function computeNextSectionPropsAtBreak(blocks) {
|
|
|
74841
75005
|
const props = {};
|
|
74842
75006
|
if (source.kind !== "sectionBreak") return props;
|
|
74843
75007
|
if (source.margins) {
|
|
74844
|
-
props.margins = {
|
|
75008
|
+
props.margins = {
|
|
75009
|
+
header: source.margins.header,
|
|
75010
|
+
footer: source.margins.footer,
|
|
75011
|
+
top: source.margins.top,
|
|
75012
|
+
right: source.margins.right,
|
|
75013
|
+
bottom: source.margins.bottom,
|
|
75014
|
+
left: source.margins.left
|
|
75015
|
+
};
|
|
74845
75016
|
}
|
|
74846
75017
|
if (source.pageSize) {
|
|
74847
75018
|
props.pageSize = { w: source.pageSize.w, h: source.pageSize.h };
|
|
@@ -74889,20 +75060,36 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74889
75060
|
next.activeOrientation = block.orientation;
|
|
74890
75061
|
next.pendingOrientation = null;
|
|
74891
75062
|
}
|
|
75063
|
+
const headerDistance = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
75064
|
+
const footerDistance = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
75065
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
75066
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
74892
75067
|
if (block.margins?.header !== void 0) {
|
|
74893
|
-
const headerDistance = Math.max(0, block.margins.header);
|
|
74894
75068
|
next.activeHeaderDistance = headerDistance;
|
|
74895
75069
|
next.pendingHeaderDistance = headerDistance;
|
|
74896
|
-
next.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
|
|
74897
|
-
next.pendingTopMargin = next.activeTopMargin;
|
|
74898
75070
|
}
|
|
74899
75071
|
if (block.margins?.footer !== void 0) {
|
|
74900
|
-
const footerDistance = Math.max(0, block.margins.footer);
|
|
74901
75072
|
next.activeFooterDistance = footerDistance;
|
|
74902
75073
|
next.pendingFooterDistance = footerDistance;
|
|
74903
|
-
|
|
75074
|
+
}
|
|
75075
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
75076
|
+
next.activeTopMargin = calcRequiredTopMargin(headerDistance, sectionTop);
|
|
75077
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
75078
|
+
}
|
|
75079
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
75080
|
+
next.activeBottomMargin = calcRequiredBottomMargin(footerDistance, sectionBottom);
|
|
74904
75081
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
74905
75082
|
}
|
|
75083
|
+
if (block.margins?.left !== void 0) {
|
|
75084
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
75085
|
+
next.activeLeftMargin = leftMargin;
|
|
75086
|
+
next.pendingLeftMargin = leftMargin;
|
|
75087
|
+
}
|
|
75088
|
+
if (block.margins?.right !== void 0) {
|
|
75089
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
75090
|
+
next.activeRightMargin = rightMargin;
|
|
75091
|
+
next.pendingRightMargin = rightMargin;
|
|
75092
|
+
}
|
|
74906
75093
|
if (block.columns) {
|
|
74907
75094
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
74908
75095
|
next.pendingColumns = null;
|
|
@@ -74911,26 +75098,42 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74911
75098
|
}
|
|
74912
75099
|
const headerPx = block.margins?.header;
|
|
74913
75100
|
const footerPx = block.margins?.footer;
|
|
75101
|
+
const topPx = block.margins?.top;
|
|
75102
|
+
const bottomPx = block.margins?.bottom;
|
|
74914
75103
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
74915
75104
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
75105
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
75106
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
74916
75107
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
74917
75108
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
74918
|
-
if (typeof headerPx === "number") {
|
|
74919
|
-
const newHeaderDist = Math.max(0, headerPx);
|
|
75109
|
+
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
75110
|
+
const newHeaderDist = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
75111
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
74920
75112
|
next.pendingHeaderDistance = newHeaderDist;
|
|
74921
|
-
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist,
|
|
75113
|
+
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, sectionTop);
|
|
74922
75114
|
} else {
|
|
74923
75115
|
next.pendingTopMargin = nextTop;
|
|
74924
75116
|
next.pendingHeaderDistance = nextHeader;
|
|
74925
75117
|
}
|
|
74926
|
-
if (typeof footerPx === "number") {
|
|
74927
|
-
const newFooterDist = Math.max(0, footerPx);
|
|
75118
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
75119
|
+
const newFooterDist = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
75120
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
74928
75121
|
next.pendingFooterDistance = newFooterDist;
|
|
74929
|
-
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist,
|
|
75122
|
+
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, sectionBottom);
|
|
74930
75123
|
} else {
|
|
74931
75124
|
next.pendingBottomMargin = nextBottom;
|
|
74932
75125
|
next.pendingFooterDistance = nextFooter;
|
|
74933
75126
|
}
|
|
75127
|
+
if (typeof block.margins?.left === "number") {
|
|
75128
|
+
next.pendingLeftMargin = Math.max(0, block.margins.left);
|
|
75129
|
+
} else {
|
|
75130
|
+
next.pendingLeftMargin = nextLeft;
|
|
75131
|
+
}
|
|
75132
|
+
if (typeof block.margins?.right === "number") {
|
|
75133
|
+
next.pendingRightMargin = Math.max(0, block.margins.right);
|
|
75134
|
+
} else {
|
|
75135
|
+
next.pendingRightMargin = nextRight;
|
|
75136
|
+
}
|
|
74934
75137
|
if (block.pageSize) {
|
|
74935
75138
|
next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
74936
75139
|
}
|
|
@@ -74990,6 +75193,12 @@ function applyPendingToActive(state2) {
|
|
|
74990
75193
|
if (next.pendingBottomMargin != null) {
|
|
74991
75194
|
next.activeBottomMargin = next.pendingBottomMargin;
|
|
74992
75195
|
}
|
|
75196
|
+
if (next.pendingLeftMargin != null) {
|
|
75197
|
+
next.activeLeftMargin = next.pendingLeftMargin;
|
|
75198
|
+
}
|
|
75199
|
+
if (next.pendingRightMargin != null) {
|
|
75200
|
+
next.activeRightMargin = next.pendingRightMargin;
|
|
75201
|
+
}
|
|
74993
75202
|
if (next.pendingHeaderDistance != null) {
|
|
74994
75203
|
next.activeHeaderDistance = next.pendingHeaderDistance;
|
|
74995
75204
|
}
|
|
@@ -75007,6 +75216,8 @@ function applyPendingToActive(state2) {
|
|
|
75007
75216
|
}
|
|
75008
75217
|
next.pendingTopMargin = null;
|
|
75009
75218
|
next.pendingBottomMargin = null;
|
|
75219
|
+
next.pendingLeftMargin = null;
|
|
75220
|
+
next.pendingRightMargin = null;
|
|
75010
75221
|
next.pendingHeaderDistance = null;
|
|
75011
75222
|
next.pendingFooterDistance = null;
|
|
75012
75223
|
next.pendingPageSize = null;
|
|
@@ -75235,7 +75446,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75235
75446
|
if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
|
|
75236
75447
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75237
75448
|
const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
|
|
75238
|
-
|
|
75449
|
+
const newLines = normalizeLines(newMeasure);
|
|
75450
|
+
lines = newLines;
|
|
75239
75451
|
didRemeasureForColumnWidth = true;
|
|
75240
75452
|
}
|
|
75241
75453
|
let fromLine = 0;
|
|
@@ -75317,7 +75529,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75317
75529
|
if (narrowestRemeasureWidth < remeasureWidth) {
|
|
75318
75530
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75319
75531
|
const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
|
|
75320
|
-
|
|
75532
|
+
const newLines = normalizeLines(newMeasure);
|
|
75533
|
+
lines = newLines;
|
|
75321
75534
|
didRemeasureForFloats = true;
|
|
75322
75535
|
}
|
|
75323
75536
|
}
|
|
@@ -75661,6 +75874,94 @@ function getCellPadding(cellIdx, blockRow) {
|
|
|
75661
75874
|
function getCellTotalLines(cell) {
|
|
75662
75875
|
return getCellLines(cell).length;
|
|
75663
75876
|
}
|
|
75877
|
+
function mergePmRange(target, range2) {
|
|
75878
|
+
if (typeof range2.pmStart === "number") {
|
|
75879
|
+
target.pmStart = target.pmStart == null ? range2.pmStart : Math.min(target.pmStart, range2.pmStart);
|
|
75880
|
+
}
|
|
75881
|
+
if (typeof range2.pmEnd === "number") {
|
|
75882
|
+
target.pmEnd = target.pmEnd == null ? range2.pmEnd : Math.max(target.pmEnd, range2.pmEnd);
|
|
75883
|
+
}
|
|
75884
|
+
}
|
|
75885
|
+
function computeCellPmRange(cell, cellMeasure, fromLine, toLine) {
|
|
75886
|
+
const range2 = {};
|
|
75887
|
+
if (!cell || !cellMeasure) return range2;
|
|
75888
|
+
const cellBlocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
|
|
75889
|
+
const blockMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
|
|
75890
|
+
const maxBlocks = Math.min(cellBlocks.length, blockMeasures.length);
|
|
75891
|
+
let cumulativeLineCount = 0;
|
|
75892
|
+
for (let i = 0; i < maxBlocks; i++) {
|
|
75893
|
+
const block = cellBlocks[i];
|
|
75894
|
+
const blockMeasure = blockMeasures[i];
|
|
75895
|
+
if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
|
|
75896
|
+
const paraMeasure = blockMeasure;
|
|
75897
|
+
const lines = paraMeasure.lines;
|
|
75898
|
+
const blockLineCount = lines?.length ?? 0;
|
|
75899
|
+
const blockStartGlobal = cumulativeLineCount;
|
|
75900
|
+
const blockEndGlobal = cumulativeLineCount + blockLineCount;
|
|
75901
|
+
const localFrom = Math.max(fromLine, blockStartGlobal) - blockStartGlobal;
|
|
75902
|
+
const localTo = Math.min(toLine, blockEndGlobal) - blockStartGlobal;
|
|
75903
|
+
if (lines && lines.length > 0 && localFrom < localTo) {
|
|
75904
|
+
mergePmRange(range2, computeFragmentPmRange(block, lines, localFrom, localTo));
|
|
75905
|
+
} else {
|
|
75906
|
+
mergePmRange(range2, extractBlockPmRange(block));
|
|
75907
|
+
}
|
|
75908
|
+
cumulativeLineCount += blockLineCount;
|
|
75909
|
+
continue;
|
|
75910
|
+
}
|
|
75911
|
+
mergePmRange(range2, extractBlockPmRange(block));
|
|
75912
|
+
}
|
|
75913
|
+
return range2;
|
|
75914
|
+
}
|
|
75915
|
+
function computeTableFragmentPmRange(block, measure, fromRow, toRow, partialRow) {
|
|
75916
|
+
const range2 = {};
|
|
75917
|
+
for (let rowIndex = fromRow; rowIndex < toRow; rowIndex++) {
|
|
75918
|
+
const row = block.rows[rowIndex];
|
|
75919
|
+
const rowMeasure = measure.rows[rowIndex];
|
|
75920
|
+
if (!row || !rowMeasure) continue;
|
|
75921
|
+
const isPartial = partialRow?.rowIndex === rowIndex;
|
|
75922
|
+
const cellCount = Math.min(row.cells.length, rowMeasure.cells.length);
|
|
75923
|
+
for (let cellIndex = 0; cellIndex < cellCount; cellIndex++) {
|
|
75924
|
+
const cell = row.cells[cellIndex];
|
|
75925
|
+
const cellMeasure = rowMeasure.cells[cellIndex];
|
|
75926
|
+
if (!cell || !cellMeasure) continue;
|
|
75927
|
+
const totalLines = getCellTotalLines(cellMeasure);
|
|
75928
|
+
let fromLine = 0;
|
|
75929
|
+
let toLine = totalLines;
|
|
75930
|
+
if (isPartial) {
|
|
75931
|
+
const hasValidFromLineByCell = partialRow?.fromLineByCell && cellIndex < partialRow.fromLineByCell.length;
|
|
75932
|
+
const hasValidToLineByCell = partialRow?.toLineByCell && cellIndex < partialRow.toLineByCell.length;
|
|
75933
|
+
if (hasValidFromLineByCell) {
|
|
75934
|
+
const rawFrom = partialRow.fromLineByCell[cellIndex];
|
|
75935
|
+
if (typeof rawFrom === "number" && rawFrom >= 0) {
|
|
75936
|
+
fromLine = rawFrom;
|
|
75937
|
+
}
|
|
75938
|
+
}
|
|
75939
|
+
if (hasValidToLineByCell) {
|
|
75940
|
+
const rawTo = partialRow.toLineByCell[cellIndex];
|
|
75941
|
+
if (typeof rawTo === "number") {
|
|
75942
|
+
toLine = rawTo === -1 ? totalLines : rawTo;
|
|
75943
|
+
}
|
|
75944
|
+
}
|
|
75945
|
+
}
|
|
75946
|
+
fromLine = Math.max(0, Math.min(fromLine, totalLines));
|
|
75947
|
+
toLine = Math.max(0, Math.min(toLine, totalLines));
|
|
75948
|
+
if (toLine < fromLine) {
|
|
75949
|
+
toLine = fromLine;
|
|
75950
|
+
}
|
|
75951
|
+
mergePmRange(range2, computeCellPmRange(cell, cellMeasure, fromLine, toLine));
|
|
75952
|
+
}
|
|
75953
|
+
}
|
|
75954
|
+
return range2;
|
|
75955
|
+
}
|
|
75956
|
+
function applyTableFragmentPmRange(fragment, block, measure) {
|
|
75957
|
+
const range2 = computeTableFragmentPmRange(block, measure, fragment.fromRow, fragment.toRow, fragment.partialRow);
|
|
75958
|
+
if (range2.pmStart != null) {
|
|
75959
|
+
fragment.pmStart = range2.pmStart;
|
|
75960
|
+
}
|
|
75961
|
+
if (range2.pmEnd != null) {
|
|
75962
|
+
fragment.pmEnd = range2.pmEnd;
|
|
75963
|
+
}
|
|
75964
|
+
}
|
|
75664
75965
|
function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLineByCell) {
|
|
75665
75966
|
const row = measure.rows[rowIndex];
|
|
75666
75967
|
if (!row) {
|
|
@@ -75805,6 +76106,7 @@ function layoutMonolithicTable(context) {
|
|
|
75805
76106
|
height,
|
|
75806
76107
|
metadata
|
|
75807
76108
|
};
|
|
76109
|
+
applyTableFragmentPmRange(fragment, context.block, context.measure);
|
|
75808
76110
|
state2.page.fragments.push(fragment);
|
|
75809
76111
|
state2.cursorY += height;
|
|
75810
76112
|
}
|
|
@@ -75883,6 +76185,7 @@ function layoutTableBlock({
|
|
|
75883
76185
|
height,
|
|
75884
76186
|
metadata
|
|
75885
76187
|
};
|
|
76188
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
75886
76189
|
state2.page.fragments.push(fragment);
|
|
75887
76190
|
state2.cursorY += height;
|
|
75888
76191
|
return;
|
|
@@ -75946,6 +76249,7 @@ function layoutTableBlock({
|
|
|
75946
76249
|
partialRow: continuationPartialRow,
|
|
75947
76250
|
metadata: generateFragmentMetadata(measure)
|
|
75948
76251
|
};
|
|
76252
|
+
applyTableFragmentPmRange(fragment2, block, measure);
|
|
75949
76253
|
state2.page.fragments.push(fragment2);
|
|
75950
76254
|
state2.cursorY += fragmentHeight2;
|
|
75951
76255
|
}
|
|
@@ -75990,6 +76294,7 @@ function layoutTableBlock({
|
|
|
75990
76294
|
partialRow: forcedPartialRow,
|
|
75991
76295
|
metadata: generateFragmentMetadata(measure)
|
|
75992
76296
|
};
|
|
76297
|
+
applyTableFragmentPmRange(fragment2, block, measure);
|
|
75993
76298
|
state2.page.fragments.push(fragment2);
|
|
75994
76299
|
state2.cursorY += fragmentHeight2;
|
|
75995
76300
|
pendingPartialRow = forcedPartialRow;
|
|
@@ -76025,6 +76330,7 @@ function layoutTableBlock({
|
|
|
76025
76330
|
partialRow: partialRow || void 0,
|
|
76026
76331
|
metadata: generateFragmentMetadata(measure)
|
|
76027
76332
|
};
|
|
76333
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
76028
76334
|
state2.page.fragments.push(fragment);
|
|
76029
76335
|
state2.cursorY += fragmentHeight;
|
|
76030
76336
|
if (partialRow && !partialRow.isLastPart) {
|
|
@@ -76042,7 +76348,7 @@ function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
|
76042
76348
|
columnBoundaries: generateColumnBoundaries(measure),
|
|
76043
76349
|
coordinateSystem: "fragment"
|
|
76044
76350
|
};
|
|
76045
|
-
|
|
76351
|
+
const fragment = {
|
|
76046
76352
|
kind: "table",
|
|
76047
76353
|
blockId: block.id,
|
|
76048
76354
|
fromRow: 0,
|
|
@@ -76053,6 +76359,8 @@ function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
|
76053
76359
|
height: measure.totalHeight ?? 0,
|
|
76054
76360
|
metadata
|
|
76055
76361
|
};
|
|
76362
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
76363
|
+
return fragment;
|
|
76056
76364
|
}
|
|
76057
76365
|
function isPageRelativeAnchor(block) {
|
|
76058
76366
|
const vRelativeFrom = block.anchor?.vRelativeFrom;
|
|
@@ -76474,8 +76782,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76474
76782
|
header: options.margins?.header ?? options.margins?.top ?? DEFAULT_MARGINS$2.top,
|
|
76475
76783
|
footer: options.margins?.footer ?? options.margins?.bottom ?? DEFAULT_MARGINS$2.bottom
|
|
76476
76784
|
};
|
|
76477
|
-
const
|
|
76478
|
-
if (
|
|
76785
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
76786
|
+
if (baseContentWidth <= 0) {
|
|
76479
76787
|
throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
|
|
76480
76788
|
}
|
|
76481
76789
|
const validateContentHeight = (height) => {
|
|
@@ -76505,8 +76813,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76505
76813
|
const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
|
|
76506
76814
|
let activeTopMargin = effectiveTopMargin;
|
|
76507
76815
|
let activeBottomMargin = effectiveBottomMargin;
|
|
76816
|
+
let activeLeftMargin = margins.left;
|
|
76817
|
+
let activeRightMargin = margins.right;
|
|
76508
76818
|
let pendingTopMargin = null;
|
|
76509
76819
|
let pendingBottomMargin = null;
|
|
76820
|
+
let pendingLeftMargin = null;
|
|
76821
|
+
let pendingRightMargin = null;
|
|
76510
76822
|
let activeHeaderDistance = margins.header ?? margins.top;
|
|
76511
76823
|
let pendingHeaderDistance = null;
|
|
76512
76824
|
let activeFooterDistance = margins.footer ?? margins.bottom;
|
|
@@ -76519,10 +76831,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76519
76831
|
let pendingOrientation = null;
|
|
76520
76832
|
let activeVAlign = null;
|
|
76521
76833
|
let pendingVAlign = null;
|
|
76834
|
+
const paginatorMargins = { left: activeLeftMargin, right: activeRightMargin };
|
|
76522
76835
|
const floatManager = createFloatingObjectManager(
|
|
76523
|
-
normalizeColumns(activeColumns,
|
|
76524
|
-
{ left:
|
|
76525
|
-
|
|
76836
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76837
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76838
|
+
activePageSize.w
|
|
76526
76839
|
);
|
|
76527
76840
|
const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks);
|
|
76528
76841
|
const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
|
|
@@ -76539,22 +76852,38 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76539
76852
|
next.activeOrientation = block.orientation;
|
|
76540
76853
|
next.pendingOrientation = null;
|
|
76541
76854
|
}
|
|
76855
|
+
const headerDistance2 = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
76856
|
+
const footerDistance2 = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
76857
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
76858
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
76542
76859
|
if (block.margins?.header !== void 0) {
|
|
76543
|
-
|
|
76544
|
-
next.
|
|
76545
|
-
next.pendingHeaderDistance = headerDist;
|
|
76546
|
-
const requiredTop = maxHeaderContentHeight > 0 ? headerDist + maxHeaderContentHeight : headerDist;
|
|
76547
|
-
next.activeTopMargin = Math.max(baseMargins.top, requiredTop);
|
|
76548
|
-
next.pendingTopMargin = next.activeTopMargin;
|
|
76860
|
+
next.activeHeaderDistance = headerDistance2;
|
|
76861
|
+
next.pendingHeaderDistance = headerDistance2;
|
|
76549
76862
|
}
|
|
76550
76863
|
if (block.margins?.footer !== void 0) {
|
|
76551
|
-
const footerDistance2 = Math.max(0, block.margins.footer);
|
|
76552
76864
|
next.activeFooterDistance = footerDistance2;
|
|
76553
76865
|
next.pendingFooterDistance = footerDistance2;
|
|
76866
|
+
}
|
|
76867
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
76868
|
+
const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : headerDistance2;
|
|
76869
|
+
next.activeTopMargin = Math.max(sectionTop, requiredTop);
|
|
76870
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
76871
|
+
}
|
|
76872
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
76554
76873
|
const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
|
|
76555
|
-
next.activeBottomMargin = Math.max(
|
|
76874
|
+
next.activeBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76556
76875
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
76557
76876
|
}
|
|
76877
|
+
if (block.margins?.left !== void 0) {
|
|
76878
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
76879
|
+
next.activeLeftMargin = leftMargin;
|
|
76880
|
+
next.pendingLeftMargin = leftMargin;
|
|
76881
|
+
}
|
|
76882
|
+
if (block.margins?.right !== void 0) {
|
|
76883
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
76884
|
+
next.activeRightMargin = rightMargin;
|
|
76885
|
+
next.pendingRightMargin = rightMargin;
|
|
76886
|
+
}
|
|
76558
76887
|
if (block.columns) {
|
|
76559
76888
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
76560
76889
|
next.pendingColumns = null;
|
|
@@ -76583,27 +76912,35 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76583
76912
|
const headerPx = block.margins?.header;
|
|
76584
76913
|
const footerPx = block.margins?.footer;
|
|
76585
76914
|
const topPx = block.margins?.top;
|
|
76915
|
+
const bottomPx = block.margins?.bottom;
|
|
76916
|
+
const leftPx = block.margins?.left;
|
|
76917
|
+
const rightPx = block.margins?.right;
|
|
76586
76918
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
76587
76919
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
76920
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
76921
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
76588
76922
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
76589
76923
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
76590
76924
|
next.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
76591
76925
|
next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
76592
76926
|
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
76593
|
-
const sectionTop = topPx
|
|
76927
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
76594
76928
|
const sectionHeader = next.pendingHeaderDistance;
|
|
76595
76929
|
const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
|
|
76596
76930
|
next.pendingTopMargin = Math.max(sectionTop, requiredTop);
|
|
76597
76931
|
} else {
|
|
76598
76932
|
next.pendingTopMargin = nextTop;
|
|
76599
76933
|
}
|
|
76600
|
-
if (typeof footerPx === "number") {
|
|
76934
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
76601
76935
|
const sectionFooter = next.pendingFooterDistance;
|
|
76936
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
76602
76937
|
const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
|
|
76603
|
-
next.pendingBottomMargin = Math.max(
|
|
76938
|
+
next.pendingBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76604
76939
|
} else {
|
|
76605
76940
|
next.pendingBottomMargin = nextBottom;
|
|
76606
76941
|
}
|
|
76942
|
+
next.pendingLeftMargin = typeof leftPx === "number" ? Math.max(0, leftPx) : nextLeft;
|
|
76943
|
+
next.pendingRightMargin = typeof rightPx === "number" ? Math.max(0, rightPx) : nextRight;
|
|
76607
76944
|
if (block.pageSize) next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
76608
76945
|
if (block.orientation) next.pendingOrientation = block.orientation;
|
|
76609
76946
|
const sectionType = block.type ?? "continuous";
|
|
@@ -76688,7 +77025,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76688
77025
|
let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
|
|
76689
77026
|
let pendingSectionIndex = null;
|
|
76690
77027
|
const paginator = createPaginator({
|
|
76691
|
-
margins:
|
|
77028
|
+
margins: paginatorMargins,
|
|
76692
77029
|
getActiveTopMargin: () => activeTopMargin,
|
|
76693
77030
|
getActiveBottomMargin: () => activeBottomMargin,
|
|
76694
77031
|
getActiveHeaderDistance: () => activeHeaderDistance,
|
|
@@ -76703,8 +77040,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76703
77040
|
const applied = applyPendingToActive({
|
|
76704
77041
|
activeTopMargin,
|
|
76705
77042
|
activeBottomMargin,
|
|
77043
|
+
activeLeftMargin,
|
|
77044
|
+
activeRightMargin,
|
|
76706
77045
|
pendingTopMargin,
|
|
76707
77046
|
pendingBottomMargin,
|
|
77047
|
+
pendingLeftMargin,
|
|
77048
|
+
pendingRightMargin,
|
|
76708
77049
|
activeHeaderDistance,
|
|
76709
77050
|
activeFooterDistance,
|
|
76710
77051
|
pendingHeaderDistance,
|
|
@@ -76719,8 +77060,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76719
77060
|
});
|
|
76720
77061
|
activeTopMargin = applied.activeTopMargin;
|
|
76721
77062
|
activeBottomMargin = applied.activeBottomMargin;
|
|
77063
|
+
activeLeftMargin = applied.activeLeftMargin;
|
|
77064
|
+
activeRightMargin = applied.activeRightMargin;
|
|
76722
77065
|
pendingTopMargin = applied.pendingTopMargin;
|
|
76723
77066
|
pendingBottomMargin = applied.pendingBottomMargin;
|
|
77067
|
+
pendingLeftMargin = applied.pendingLeftMargin;
|
|
77068
|
+
pendingRightMargin = applied.pendingRightMargin;
|
|
76724
77069
|
activeHeaderDistance = applied.activeHeaderDistance;
|
|
76725
77070
|
activeFooterDistance = applied.activeFooterDistance;
|
|
76726
77071
|
pendingHeaderDistance = applied.pendingHeaderDistance;
|
|
@@ -76732,6 +77077,14 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76732
77077
|
activeOrientation = applied.activeOrientation;
|
|
76733
77078
|
pendingOrientation = applied.pendingOrientation;
|
|
76734
77079
|
cachedColumnsState.state = null;
|
|
77080
|
+
paginatorMargins.left = activeLeftMargin;
|
|
77081
|
+
paginatorMargins.right = activeRightMargin;
|
|
77082
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77083
|
+
floatManager.setLayoutContext(
|
|
77084
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
77085
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
77086
|
+
activePageSize.w
|
|
77087
|
+
);
|
|
76735
77088
|
if (pendingNumbering) {
|
|
76736
77089
|
if (pendingNumbering.format) activeNumberFormat = pendingNumbering.format;
|
|
76737
77090
|
if (typeof pendingNumbering.start === "number" && Number.isFinite(pendingNumbering.start)) {
|
|
@@ -76776,7 +77129,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76776
77129
|
const getActiveColumnsForState = paginator.getActiveColumnsForState;
|
|
76777
77130
|
let cachedColumnsState = { state: null, constraintIndex: -2, contentWidth: -1, colsConfig: null, normalized: null };
|
|
76778
77131
|
const getCurrentColumns = () => {
|
|
76779
|
-
const currentContentWidth = activePageSize.w - (
|
|
77132
|
+
const currentContentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
76780
77133
|
const state2 = states[states.length - 1] ?? null;
|
|
76781
77134
|
const colsConfig = state2 ? getActiveColumnsForState(state2) : activeColumns;
|
|
76782
77135
|
const constraintIndex = state2 ? state2.activeConstraintIndex : -1;
|
|
@@ -76809,6 +77162,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76809
77162
|
layoutLog(` Current page: ${state2.page.number}, cursorY: ${state2.cursorY}`);
|
|
76810
77163
|
activeColumns = newColumns;
|
|
76811
77164
|
cachedColumnsState.state = null;
|
|
77165
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77166
|
+
floatManager.setLayoutContext(
|
|
77167
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
77168
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
77169
|
+
activePageSize.w
|
|
77170
|
+
);
|
|
76812
77171
|
};
|
|
76813
77172
|
const anchoredByParagraph = collectAnchoredDrawings(blocks, measures);
|
|
76814
77173
|
const anchoredTablesByParagraph = collectAnchoredTables(blocks, measures);
|
|
@@ -76840,10 +77199,10 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76840
77199
|
if (alignV === "top") {
|
|
76841
77200
|
anchorY = offsetV;
|
|
76842
77201
|
} else if (alignV === "bottom") {
|
|
76843
|
-
const pageHeight = contentBottom + margins
|
|
77202
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76844
77203
|
anchorY = pageHeight - imageHeight + offsetV;
|
|
76845
77204
|
} else if (alignV === "center") {
|
|
76846
|
-
const pageHeight = contentBottom + margins
|
|
77205
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76847
77206
|
anchorY = (pageHeight - imageHeight) / 2 + offsetV;
|
|
76848
77207
|
} else {
|
|
76849
77208
|
anchorY = offsetV;
|
|
@@ -76854,11 +77213,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76854
77213
|
const anchorX = entry.block.anchor ? computeAnchorX(
|
|
76855
77214
|
entry.block.anchor,
|
|
76856
77215
|
state2.columnIndex,
|
|
76857
|
-
normalizeColumns(activeColumns,
|
|
77216
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76858
77217
|
entry.measure.width,
|
|
76859
|
-
{ left:
|
|
77218
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76860
77219
|
activePageSize.w
|
|
76861
|
-
) :
|
|
77220
|
+
) : activeLeftMargin;
|
|
76862
77221
|
floatManager.registerDrawing(entry.block, entry.measure, anchorY, state2.columnIndex, state2.page.number);
|
|
76863
77222
|
preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state2.page.number });
|
|
76864
77223
|
}
|
|
@@ -76896,8 +77255,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76896
77255
|
const sectionState = {
|
|
76897
77256
|
activeTopMargin,
|
|
76898
77257
|
activeBottomMargin,
|
|
77258
|
+
activeLeftMargin,
|
|
77259
|
+
activeRightMargin,
|
|
76899
77260
|
pendingTopMargin,
|
|
76900
77261
|
pendingBottomMargin,
|
|
77262
|
+
pendingLeftMargin,
|
|
77263
|
+
pendingRightMargin,
|
|
76901
77264
|
activeHeaderDistance,
|
|
76902
77265
|
activeFooterDistance,
|
|
76903
77266
|
pendingHeaderDistance,
|
|
@@ -76931,8 +77294,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76931
77294
|
layoutLog(`[Layout] ========== END SECTION BREAK ==========`);
|
|
76932
77295
|
activeTopMargin = updatedState.activeTopMargin;
|
|
76933
77296
|
activeBottomMargin = updatedState.activeBottomMargin;
|
|
77297
|
+
activeLeftMargin = updatedState.activeLeftMargin;
|
|
77298
|
+
activeRightMargin = updatedState.activeRightMargin;
|
|
76934
77299
|
pendingTopMargin = updatedState.pendingTopMargin;
|
|
76935
77300
|
pendingBottomMargin = updatedState.pendingBottomMargin;
|
|
77301
|
+
pendingLeftMargin = updatedState.pendingLeftMargin;
|
|
77302
|
+
pendingRightMargin = updatedState.pendingRightMargin;
|
|
76936
77303
|
activeHeaderDistance = updatedState.activeHeaderDistance;
|
|
76937
77304
|
activeFooterDistance = updatedState.activeFooterDistance;
|
|
76938
77305
|
pendingHeaderDistance = updatedState.pendingHeaderDistance;
|
|
@@ -77070,8 +77437,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77070
77437
|
pageMargins: {
|
|
77071
77438
|
top: activeTopMargin,
|
|
77072
77439
|
bottom: activeBottomMargin,
|
|
77073
|
-
left:
|
|
77074
|
-
right:
|
|
77440
|
+
left: activeLeftMargin,
|
|
77441
|
+
right: activeRightMargin
|
|
77075
77442
|
},
|
|
77076
77443
|
columns: getCurrentColumns(),
|
|
77077
77444
|
placedAnchoredIds
|
|
@@ -77093,9 +77460,9 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77093
77460
|
const cols = getCurrentColumns();
|
|
77094
77461
|
let maxWidth;
|
|
77095
77462
|
if (relativeFrom === "page") {
|
|
77096
|
-
maxWidth = cols.count === 1 ? activePageSize.w -
|
|
77463
|
+
maxWidth = cols.count === 1 ? activePageSize.w - (activeLeftMargin + activeRightMargin) : activePageSize.w;
|
|
77097
77464
|
} else if (relativeFrom === "margin") {
|
|
77098
|
-
maxWidth = activePageSize.w -
|
|
77465
|
+
maxWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77099
77466
|
} else {
|
|
77100
77467
|
maxWidth = cols.width;
|
|
77101
77468
|
}
|
|
@@ -78282,11 +78649,11 @@ function findWordBoundaries(blocks, pos) {
|
|
|
78282
78649
|
if (text.length === 0) return null;
|
|
78283
78650
|
const clampedPos = Math.max(0, Math.min(localPos, text.length));
|
|
78284
78651
|
let wordStart = clampedPos;
|
|
78285
|
-
while (wordStart > 0 && isWordChar(text[wordStart - 1])) {
|
|
78652
|
+
while (wordStart > 0 && isWordChar$2(text[wordStart - 1])) {
|
|
78286
78653
|
wordStart--;
|
|
78287
78654
|
}
|
|
78288
78655
|
let wordEnd = clampedPos;
|
|
78289
|
-
while (wordEnd < text.length && isWordChar(text[wordEnd])) {
|
|
78656
|
+
while (wordEnd < text.length && isWordChar$2(text[wordEnd])) {
|
|
78290
78657
|
wordEnd++;
|
|
78291
78658
|
}
|
|
78292
78659
|
if (wordStart === wordEnd) {
|
|
@@ -78349,7 +78716,7 @@ function findBlockAtPosition(blocks, pos) {
|
|
|
78349
78716
|
}
|
|
78350
78717
|
return null;
|
|
78351
78718
|
}
|
|
78352
|
-
function isWordChar(char) {
|
|
78719
|
+
function isWordChar$2(char) {
|
|
78353
78720
|
return /[\p{L}\p{N}_]/u.test(char);
|
|
78354
78721
|
}
|
|
78355
78722
|
function isWhitespace(char) {
|
|
@@ -78384,6 +78751,29 @@ function fontString(run2) {
|
|
|
78384
78751
|
function runText(run2) {
|
|
78385
78752
|
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
78386
78753
|
}
|
|
78754
|
+
const isWordChar$1 = (char) => {
|
|
78755
|
+
if (!char) return false;
|
|
78756
|
+
const code = char.charCodeAt(0);
|
|
78757
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
78758
|
+
};
|
|
78759
|
+
const capitalizeText$1 = (text, fullText, startOffset) => {
|
|
78760
|
+
if (!text) return text;
|
|
78761
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
78762
|
+
let result = "";
|
|
78763
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
78764
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
78765
|
+
const ch = text[i];
|
|
78766
|
+
result += isWordChar$1(ch) && !isWordChar$1(prevChar) ? ch.toUpperCase() : ch;
|
|
78767
|
+
}
|
|
78768
|
+
return result;
|
|
78769
|
+
};
|
|
78770
|
+
const applyTextTransform$1 = (text, transform, fullText, startOffset) => {
|
|
78771
|
+
if (!text || !transform || transform === "none") return text;
|
|
78772
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
78773
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
78774
|
+
if (transform === "capitalize") return capitalizeText$1(text, fullText, startOffset);
|
|
78775
|
+
return text;
|
|
78776
|
+
};
|
|
78387
78777
|
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
78388
78778
|
const TWIPS_PER_INCH$4 = 1440;
|
|
78389
78779
|
const PX_PER_INCH$3 = 96;
|
|
@@ -78392,6 +78782,13 @@ const TAB_EPSILON$1 = 0.1;
|
|
|
78392
78782
|
const WIDTH_FUDGE_PX = 0.5;
|
|
78393
78783
|
const twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$1;
|
|
78394
78784
|
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
78785
|
+
const markerFontString = (run2) => {
|
|
78786
|
+
const size2 = run2?.fontSize ?? 16;
|
|
78787
|
+
const family = run2?.fontFamily ?? "Arial";
|
|
78788
|
+
const italic = run2?.italic ? "italic " : "";
|
|
78789
|
+
const bold = run2?.bold ? "bold " : "";
|
|
78790
|
+
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
78791
|
+
};
|
|
78395
78792
|
const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
|
|
78396
78793
|
const paragraphIndentTwips = {
|
|
78397
78794
|
left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
|
|
@@ -78422,7 +78819,9 @@ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
|
|
|
78422
78819
|
};
|
|
78423
78820
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
78424
78821
|
const context = getCtx();
|
|
78425
|
-
const
|
|
78822
|
+
const fullText = runText(run2);
|
|
78823
|
+
const transform = isTextRun$2(run2) ? run2.textTransform : void 0;
|
|
78824
|
+
const text = applyTextTransform$1(fullText.slice(fromChar, toChar), transform, fullText, fromChar);
|
|
78426
78825
|
if (!context) {
|
|
78427
78826
|
const textRun = isTextRun$2(run2) ? run2 : null;
|
|
78428
78827
|
const size2 = textRun?.fontSize ?? 16;
|
|
@@ -78468,8 +78867,21 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
78468
78867
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
78469
78868
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
78470
78869
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
78471
|
-
const
|
|
78472
|
-
|
|
78870
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
78871
|
+
wordLayout,
|
|
78872
|
+
indentLeft,
|
|
78873
|
+
indentFirstLine,
|
|
78874
|
+
indentHanging,
|
|
78875
|
+
(markerText, marker) => {
|
|
78876
|
+
const context = getCtx();
|
|
78877
|
+
if (!context) return 0;
|
|
78878
|
+
context.font = markerFontString(marker.run);
|
|
78879
|
+
return context.measureText(markerText).width;
|
|
78880
|
+
}
|
|
78881
|
+
);
|
|
78882
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
78883
|
+
const treatAsHanging = !wordLayout?.marker && effectiveTextStartPx && indentLeft === 0 && indentHanging === 0;
|
|
78884
|
+
const firstLineWidth = typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - effectiveTextStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
78473
78885
|
const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
78474
78886
|
let currentRun = 0;
|
|
78475
78887
|
let currentChar = 0;
|
|
@@ -79009,7 +79421,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
79009
79421
|
if (dirty.deletedBlockIds.length > 0) {
|
|
79010
79422
|
measureCache.invalidate(dirty.deletedBlockIds);
|
|
79011
79423
|
}
|
|
79012
|
-
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options);
|
|
79424
|
+
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options, nextBlocks);
|
|
79013
79425
|
if (measurementWidth <= 0 || measurementHeight <= 0) {
|
|
79014
79426
|
throw new Error("incrementalLayout: invalid measurement constraints resolved from options");
|
|
79015
79427
|
}
|
|
@@ -79278,7 +79690,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
79278
79690
|
const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
|
|
79279
79691
|
const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
79280
79692
|
const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
|
|
79281
|
-
function resolveMeasurementConstraints(options) {
|
|
79693
|
+
function resolveMeasurementConstraints(options, blocks) {
|
|
79282
79694
|
const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
|
|
79283
79695
|
const margins = {
|
|
79284
79696
|
top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
|
|
@@ -79286,23 +79698,41 @@ function resolveMeasurementConstraints(options) {
|
|
|
79286
79698
|
bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
|
|
79287
79699
|
left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
|
|
79288
79700
|
};
|
|
79289
|
-
const
|
|
79290
|
-
const
|
|
79291
|
-
const
|
|
79292
|
-
|
|
79701
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
79702
|
+
const baseContentHeight = pageSize.h - (margins.top + margins.bottom);
|
|
79703
|
+
const computeColumnWidth = (contentWidth, columns) => {
|
|
79704
|
+
if (!columns || columns.count <= 1) return contentWidth;
|
|
79293
79705
|
const gap = Math.max(0, columns.gap ?? 0);
|
|
79294
79706
|
const totalGap = gap * (columns.count - 1);
|
|
79295
|
-
|
|
79296
|
-
|
|
79297
|
-
|
|
79298
|
-
|
|
79299
|
-
|
|
79707
|
+
return (contentWidth - totalGap) / columns.count;
|
|
79708
|
+
};
|
|
79709
|
+
let measurementWidth = computeColumnWidth(baseContentWidth, options.columns);
|
|
79710
|
+
let measurementHeight = baseContentHeight;
|
|
79711
|
+
if (blocks && blocks.length > 0) {
|
|
79712
|
+
for (const block of blocks) {
|
|
79713
|
+
if (block.kind !== "sectionBreak") continue;
|
|
79714
|
+
const sectionPageSize = block.pageSize ?? pageSize;
|
|
79715
|
+
const sectionMargins = {
|
|
79716
|
+
top: normalizeMargin(block.margins?.top, margins.top),
|
|
79717
|
+
right: normalizeMargin(block.margins?.right, margins.right),
|
|
79718
|
+
bottom: normalizeMargin(block.margins?.bottom, margins.bottom),
|
|
79719
|
+
left: normalizeMargin(block.margins?.left, margins.left)
|
|
79300
79720
|
};
|
|
79721
|
+
const contentWidth = sectionPageSize.w - (sectionMargins.left + sectionMargins.right);
|
|
79722
|
+
const contentHeight = sectionPageSize.h - (sectionMargins.top + sectionMargins.bottom);
|
|
79723
|
+
if (contentWidth <= 0 || contentHeight <= 0) continue;
|
|
79724
|
+
const columnWidth = computeColumnWidth(contentWidth, block.columns ?? options.columns);
|
|
79725
|
+
if (columnWidth > measurementWidth) {
|
|
79726
|
+
measurementWidth = columnWidth;
|
|
79727
|
+
}
|
|
79728
|
+
if (contentHeight > measurementHeight) {
|
|
79729
|
+
measurementHeight = contentHeight;
|
|
79730
|
+
}
|
|
79301
79731
|
}
|
|
79302
79732
|
}
|
|
79303
79733
|
return {
|
|
79304
|
-
measurementWidth
|
|
79305
|
-
measurementHeight
|
|
79734
|
+
measurementWidth,
|
|
79735
|
+
measurementHeight
|
|
79306
79736
|
};
|
|
79307
79737
|
}
|
|
79308
79738
|
const serializeHeaderFooterResults = (kind, batch) => {
|
|
@@ -81692,14 +82122,15 @@ function getAtomNodeTypes(schema) {
|
|
|
81692
82122
|
if (!schema) return [];
|
|
81693
82123
|
const types2 = [];
|
|
81694
82124
|
try {
|
|
81695
|
-
schema.nodes
|
|
82125
|
+
for (const name in schema.nodes) {
|
|
81696
82126
|
if (name === "text") {
|
|
81697
|
-
|
|
82127
|
+
continue;
|
|
81698
82128
|
}
|
|
81699
|
-
|
|
82129
|
+
const nodeType = schema.nodes[name];
|
|
82130
|
+
if (nodeType && (nodeType.isAtom || nodeType.isLeaf)) {
|
|
81700
82131
|
types2.push(name);
|
|
81701
82132
|
}
|
|
81702
|
-
}
|
|
82133
|
+
}
|
|
81703
82134
|
} catch {
|
|
81704
82135
|
return [];
|
|
81705
82136
|
}
|
|
@@ -85280,8 +85711,8 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
|
85280
85711
|
}
|
|
85281
85712
|
return void 0;
|
|
85282
85713
|
}
|
|
85283
|
-
const DEFAULT_LIST_HANGING_PX
|
|
85284
|
-
const LIST_MARKER_GAP
|
|
85714
|
+
const DEFAULT_LIST_HANGING_PX = 18;
|
|
85715
|
+
const LIST_MARKER_GAP = 8;
|
|
85285
85716
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
85286
85717
|
const DEFAULT_DECIMAL_PATTERN = "%1.";
|
|
85287
85718
|
const ASCII_UPPERCASE_A = 65;
|
|
@@ -85692,7 +86123,7 @@ function computeWordParagraphLayout(input) {
|
|
|
85692
86123
|
let markerBoxWidthPx;
|
|
85693
86124
|
let markerX;
|
|
85694
86125
|
if (hasFirstLineIndent) {
|
|
85695
|
-
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP
|
|
86126
|
+
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP : DEFAULT_LIST_HANGING_PX;
|
|
85696
86127
|
markerX = indentLeftPx + (firstLinePx ?? 0);
|
|
85697
86128
|
layout.textStartPx = markerX + markerBoxWidthPx;
|
|
85698
86129
|
layout.hangingPx = 0;
|
|
@@ -85792,12 +86223,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
|
|
|
85792
86223
|
let markerBox = Math.max(hangingPxRaw || 0, 0);
|
|
85793
86224
|
if (markerBox <= 0) {
|
|
85794
86225
|
if (glyphWidthPx != null && glyphWidthPx > 0) {
|
|
85795
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86226
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85796
86227
|
} else {
|
|
85797
|
-
markerBox = DEFAULT_LIST_HANGING_PX
|
|
86228
|
+
markerBox = DEFAULT_LIST_HANGING_PX;
|
|
85798
86229
|
}
|
|
85799
|
-
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP
|
|
85800
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86230
|
+
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP > markerBox) {
|
|
86231
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85801
86232
|
}
|
|
85802
86233
|
return markerBox;
|
|
85803
86234
|
};
|
|
@@ -85817,7 +86248,7 @@ const buildMarkerLayout = ({
|
|
|
85817
86248
|
textStartX: textStartPx,
|
|
85818
86249
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
85819
86250
|
// Gutter is the small gap between marker and text, not the full marker box width
|
|
85820
|
-
gutterWidthPx: LIST_MARKER_GAP
|
|
86251
|
+
gutterWidthPx: LIST_MARKER_GAP,
|
|
85821
86252
|
justification: numbering.lvlJc ?? "left",
|
|
85822
86253
|
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
85823
86254
|
run: markerRun,
|
|
@@ -86509,6 +86940,31 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
86509
86940
|
return null;
|
|
86510
86941
|
}
|
|
86511
86942
|
};
|
|
86943
|
+
const normalizeWordLayoutForIndent = (wordLayout, paragraphIndent) => {
|
|
86944
|
+
const resolvedIndent = wordLayout.resolvedIndent ?? paragraphIndent ?? {};
|
|
86945
|
+
const indentLeft = isFiniteNumber(resolvedIndent.left) ? resolvedIndent.left : 0;
|
|
86946
|
+
const firstLine = isFiniteNumber(resolvedIndent.firstLine) ? resolvedIndent.firstLine : 0;
|
|
86947
|
+
const hanging = isFiniteNumber(resolvedIndent.hanging) ? resolvedIndent.hanging : 0;
|
|
86948
|
+
const shouldFirstLineIndentMode = firstLine > 0 && !hanging;
|
|
86949
|
+
if (wordLayout.firstLineIndentMode === true && !shouldFirstLineIndentMode) {
|
|
86950
|
+
wordLayout.firstLineIndentMode = false;
|
|
86951
|
+
}
|
|
86952
|
+
if (wordLayout.firstLineIndentMode === true) {
|
|
86953
|
+
if (isFiniteNumber(wordLayout.textStartPx)) {
|
|
86954
|
+
if (wordLayout.marker && (!isFiniteNumber(wordLayout.marker.textStartX) || wordLayout.marker.textStartX !== wordLayout.textStartPx)) {
|
|
86955
|
+
wordLayout.marker.textStartX = wordLayout.textStartPx;
|
|
86956
|
+
}
|
|
86957
|
+
} else if (wordLayout.marker && isFiniteNumber(wordLayout.marker.textStartX)) {
|
|
86958
|
+
wordLayout.textStartPx = wordLayout.marker.textStartX;
|
|
86959
|
+
}
|
|
86960
|
+
} else {
|
|
86961
|
+
wordLayout.textStartPx = indentLeft;
|
|
86962
|
+
if (wordLayout.marker) {
|
|
86963
|
+
wordLayout.marker.textStartX = indentLeft;
|
|
86964
|
+
}
|
|
86965
|
+
}
|
|
86966
|
+
return wordLayout;
|
|
86967
|
+
};
|
|
86512
86968
|
const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
|
|
86513
86969
|
const attrs = para.attrs ?? {};
|
|
86514
86970
|
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
@@ -86831,8 +87287,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86831
87287
|
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
86832
87288
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86833
87289
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86834
|
-
const
|
|
86835
|
-
|
|
87290
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87291
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87292
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87293
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87294
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86836
87295
|
wordLayout = {
|
|
86837
87296
|
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
86838
87297
|
firstLineIndentMode: true,
|
|
@@ -86840,10 +87299,13 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86840
87299
|
};
|
|
86841
87300
|
}
|
|
86842
87301
|
}
|
|
86843
|
-
if (wordLayout &&
|
|
87302
|
+
if (wordLayout && !Number.isFinite(wordLayout.textStartPx) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86844
87303
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86845
|
-
const
|
|
86846
|
-
|
|
87304
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87305
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87306
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87307
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87308
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86847
87309
|
wordLayout = {
|
|
86848
87310
|
...wordLayout,
|
|
86849
87311
|
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
@@ -86863,6 +87325,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86863
87325
|
wordLayout.marker.suffix = listRendering.suffix;
|
|
86864
87326
|
}
|
|
86865
87327
|
}
|
|
87328
|
+
wordLayout = normalizeWordLayoutForIndent(wordLayout, paragraphAttrs.indent);
|
|
86866
87329
|
paragraphAttrs.wordLayout = wordLayout;
|
|
86867
87330
|
}
|
|
86868
87331
|
if (enrichedNumberingProps.resolvedLevelIndent) {
|
|
@@ -90979,11 +91442,6 @@ function initHeaderFooterRegistry({
|
|
|
90979
91442
|
cleanups
|
|
90980
91443
|
};
|
|
90981
91444
|
}
|
|
90982
|
-
const LIST_MARKER_GAP = 8;
|
|
90983
|
-
const MIN_MARKER_GUTTER = 24;
|
|
90984
|
-
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
90985
|
-
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
90986
|
-
const DEFAULT_LIST_HANGING_PX = 18;
|
|
90987
91445
|
function calculateRotatedBounds(input) {
|
|
90988
91446
|
const width = Math.max(0, input.width);
|
|
90989
91447
|
const height = Math.max(0, input.height);
|
|
@@ -91247,8 +91705,25 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91247
91705
|
const rawTextStartPx = wordLayout?.textStartPx;
|
|
91248
91706
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
91249
91707
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof rawTextStartPx === "number" && Number.isFinite(rawTextStartPx) ? rawTextStartPx : void 0;
|
|
91250
|
-
|
|
91251
|
-
|
|
91708
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
91709
|
+
wordLayout,
|
|
91710
|
+
indentLeft,
|
|
91711
|
+
firstLine,
|
|
91712
|
+
hanging,
|
|
91713
|
+
(markerText, marker) => {
|
|
91714
|
+
const markerRun = {
|
|
91715
|
+
fontFamily: toCssFontFamily(marker.run?.fontFamily) ?? marker.run?.fontFamily ?? "Arial",
|
|
91716
|
+
fontSize: marker.run?.fontSize ?? 16,
|
|
91717
|
+
bold: marker.run?.bold ?? false,
|
|
91718
|
+
italic: marker.run?.italic ?? false
|
|
91719
|
+
};
|
|
91720
|
+
const { font: markerFont } = buildFontString(markerRun);
|
|
91721
|
+
return measureText(markerText, markerFont, ctx2);
|
|
91722
|
+
}
|
|
91723
|
+
);
|
|
91724
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
91725
|
+
if (typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft) {
|
|
91726
|
+
initialAvailableWidth = Math.max(1, maxWidth - effectiveTextStartPx - indentRight);
|
|
91252
91727
|
} else {
|
|
91253
91728
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
91254
91729
|
}
|
|
@@ -91335,7 +91810,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91335
91810
|
pendingTabAlignment = null;
|
|
91336
91811
|
return startX;
|
|
91337
91812
|
};
|
|
91338
|
-
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
91813
|
+
const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
|
|
91339
91814
|
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
91340
91815
|
const { val } = pendingTabAlignment;
|
|
91341
91816
|
let segmentWidth = 0;
|
|
@@ -91344,11 +91819,11 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91344
91819
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
91345
91820
|
if (idx >= 0) {
|
|
91346
91821
|
const beforeText = segmentText.slice(0, idx);
|
|
91347
|
-
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
91822
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91348
91823
|
}
|
|
91349
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91824
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91350
91825
|
} else if (val === "end" || val === "center") {
|
|
91351
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91826
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91352
91827
|
}
|
|
91353
91828
|
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
91354
91829
|
};
|
|
@@ -91400,8 +91875,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91400
91875
|
const { font } = buildFontString(
|
|
91401
91876
|
lastRun
|
|
91402
91877
|
);
|
|
91403
|
-
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun);
|
|
91404
|
-
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun) : 0;
|
|
91878
|
+
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun, sliceStart);
|
|
91879
|
+
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun, sliceStart) : 0;
|
|
91405
91880
|
const delta = Math.max(0, fullWidth - keptWidth);
|
|
91406
91881
|
lineToTrim.width = roundValue(Math.max(0, lineToTrim.width - delta));
|
|
91407
91882
|
lineToTrim.spaceCount = Math.max(0, lineToTrim.spaceCount - trimCount);
|
|
@@ -91612,7 +92087,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91612
92087
|
continue;
|
|
91613
92088
|
}
|
|
91614
92089
|
if (isFieldAnnotationRun(run2)) {
|
|
91615
|
-
const
|
|
92090
|
+
const rawDisplayText = run2.displayLabel || "";
|
|
92091
|
+
const displayText = applyTextTransform(rawDisplayText, run2);
|
|
91616
92092
|
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;
|
|
91617
92093
|
const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
|
|
91618
92094
|
const fontWeight = run2.bold ? "bold" : "normal";
|
|
@@ -91715,7 +92191,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91715
92191
|
const spacesLength = segment.length;
|
|
91716
92192
|
const spacesStartChar = charPosInRun;
|
|
91717
92193
|
const spacesEndChar = charPosInRun + spacesLength;
|
|
91718
|
-
const spacesWidth = measureRunWidth(segment, font, ctx2, run2);
|
|
92194
|
+
const spacesWidth = measureRunWidth(segment, font, ctx2, run2, spacesStartChar);
|
|
91719
92195
|
if (!currentLine) {
|
|
91720
92196
|
currentLine = {
|
|
91721
92197
|
fromRun: runIndex,
|
|
@@ -91779,7 +92255,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91779
92255
|
}
|
|
91780
92256
|
let segmentStartX;
|
|
91781
92257
|
if (currentLine && pendingTabAlignment) {
|
|
91782
|
-
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
92258
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2, charPosInRun);
|
|
91783
92259
|
if (segmentStartX == null) {
|
|
91784
92260
|
segmentStartX = currentLine.width;
|
|
91785
92261
|
}
|
|
@@ -91789,7 +92265,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91789
92265
|
if (word2 === "") {
|
|
91790
92266
|
const spaceStartChar = charPosInRun;
|
|
91791
92267
|
const spaceEndChar = charPosInRun + 1;
|
|
91792
|
-
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2);
|
|
92268
|
+
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2, spaceStartChar);
|
|
91793
92269
|
if (!currentLine) {
|
|
91794
92270
|
currentLine = {
|
|
91795
92271
|
fromRun: runIndex,
|
|
@@ -91840,12 +92316,12 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91840
92316
|
charPosInRun = spaceEndChar;
|
|
91841
92317
|
continue;
|
|
91842
92318
|
}
|
|
91843
|
-
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2);
|
|
91844
|
-
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91845
|
-
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2) : 0;
|
|
91846
|
-
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91847
92319
|
const wordStartChar = charPosInRun;
|
|
92320
|
+
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2, wordStartChar);
|
|
92321
|
+
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91848
92322
|
const wordEndNoSpace = charPosInRun + word2.length;
|
|
92323
|
+
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) : 0;
|
|
92324
|
+
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91849
92325
|
const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
|
|
91850
92326
|
const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
|
|
91851
92327
|
if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
|
|
@@ -91864,7 +92340,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91864
92340
|
const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
91865
92341
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
91866
92342
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
91867
|
-
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
|
|
92343
|
+
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2, wordStartChar);
|
|
91868
92344
|
let chunkCharOffset = wordStartChar;
|
|
91869
92345
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
91870
92346
|
const chunk = chunks[chunkIndex];
|
|
@@ -91988,7 +92464,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91988
92464
|
if (candidateSpaces > 0) {
|
|
91989
92465
|
const overflow = totalWidthWithWord - availableWidth;
|
|
91990
92466
|
if (overflow > 0) {
|
|
91991
|
-
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2) || Math.max(1, boundarySpacing);
|
|
92467
|
+
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) || Math.max(1, boundarySpacing);
|
|
91992
92468
|
const perSpaceCompression = overflow / candidateSpaces;
|
|
91993
92469
|
const maxPerSpaceCompression = baseSpaceWidth * 0.25;
|
|
91994
92470
|
if (perSpaceCompression <= maxPerSpaceCompression) {
|
|
@@ -92163,8 +92639,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
92163
92639
|
const { font: markerFont } = buildFontString(markerRun);
|
|
92164
92640
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
92165
92641
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92166
|
-
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
92167
|
-
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
|
|
92642
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
92643
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP$1);
|
|
92168
92644
|
markerInfo = {
|
|
92169
92645
|
markerWidth: markerBoxWidth,
|
|
92170
92646
|
markerTextWidth: glyphWidth,
|
|
@@ -92508,7 +92984,7 @@ async function measureListBlock(block, constraints) {
|
|
|
92508
92984
|
markerTextWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92509
92985
|
indentLeft = resolveIndentLeft(item);
|
|
92510
92986
|
const indentHanging = resolveIndentHanging(item);
|
|
92511
|
-
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP, indentHanging);
|
|
92987
|
+
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP$1, indentHanging);
|
|
92512
92988
|
}
|
|
92513
92989
|
const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
|
|
92514
92990
|
const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
|
|
@@ -92534,16 +93010,46 @@ const getPrimaryRun = (paragraph) => {
|
|
|
92534
93010
|
fontSize: 16
|
|
92535
93011
|
};
|
|
92536
93012
|
};
|
|
92537
|
-
const
|
|
93013
|
+
const isWordChar = (char) => {
|
|
93014
|
+
if (!char) return false;
|
|
93015
|
+
const code = char.charCodeAt(0);
|
|
93016
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
93017
|
+
};
|
|
93018
|
+
const capitalizeText = (text, fullText, startOffset) => {
|
|
93019
|
+
if (!text) return text;
|
|
93020
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
93021
|
+
let result = "";
|
|
93022
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
93023
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
93024
|
+
const ch = text[i];
|
|
93025
|
+
result += isWordChar(ch) && !isWordChar(prevChar) ? ch.toUpperCase() : ch;
|
|
93026
|
+
}
|
|
93027
|
+
return result;
|
|
93028
|
+
};
|
|
93029
|
+
const applyTextTransform = (text, run2, startOffset) => {
|
|
93030
|
+
const transform = "textTransform" in run2 ? run2.textTransform : void 0;
|
|
93031
|
+
if (!text || !transform || transform === "none") return text;
|
|
93032
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
93033
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
93034
|
+
if (transform === "capitalize") {
|
|
93035
|
+
const fullText = "text" in run2 && typeof run2.text === "string" ? run2.text : text;
|
|
93036
|
+
return capitalizeText(text, fullText, startOffset);
|
|
93037
|
+
}
|
|
93038
|
+
return text;
|
|
93039
|
+
};
|
|
93040
|
+
const measureRunWidth = (text, font, ctx2, run2, startOffset) => {
|
|
92538
93041
|
const letterSpacing = run2.kind === "text" || run2.kind === void 0 ? run2.letterSpacing || 0 : 0;
|
|
92539
|
-
const
|
|
93042
|
+
const displayText = applyTextTransform(text, run2, startOffset);
|
|
93043
|
+
const width = getMeasuredTextWidth(displayText, font, letterSpacing, ctx2);
|
|
92540
93044
|
return roundValue(width);
|
|
92541
93045
|
};
|
|
92542
|
-
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
93046
|
+
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2, startOffset) => {
|
|
92543
93047
|
const chunks = [];
|
|
93048
|
+
const baseOffset = typeof startOffset === "number" ? startOffset : 0;
|
|
92544
93049
|
if (maxWidth <= 0) {
|
|
92545
|
-
for (
|
|
92546
|
-
const
|
|
93050
|
+
for (let i = 0; i < word2.length; i++) {
|
|
93051
|
+
const char = word2[i];
|
|
93052
|
+
const charWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92547
93053
|
chunks.push({ text: char, width: charWidth });
|
|
92548
93054
|
}
|
|
92549
93055
|
return chunks;
|
|
@@ -92553,11 +93059,11 @@ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
|
92553
93059
|
for (let i = 0; i < word2.length; i++) {
|
|
92554
93060
|
const char = word2[i];
|
|
92555
93061
|
const testChunk = currentChunk + char;
|
|
92556
|
-
const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
|
|
93062
|
+
const testWidth = measureRunWidth(testChunk, font, ctx2, run2, baseOffset);
|
|
92557
93063
|
if (testWidth > maxWidth && currentChunk.length > 0) {
|
|
92558
93064
|
chunks.push({ text: currentChunk, width: currentWidth });
|
|
92559
93065
|
currentChunk = char;
|
|
92560
|
-
currentWidth = measureRunWidth(char, font, ctx2, run2);
|
|
93066
|
+
currentWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92561
93067
|
} else {
|
|
92562
93068
|
currentChunk = testChunk;
|
|
92563
93069
|
currentWidth = testWidth;
|
|
@@ -92611,7 +93117,8 @@ const measureDropCap = (ctx2, descriptor, spacing) => {
|
|
|
92611
93117
|
italic: run2.italic
|
|
92612
93118
|
});
|
|
92613
93119
|
ctx2.font = font;
|
|
92614
|
-
const
|
|
93120
|
+
const displayText = applyTextTransform(run2.text, run2);
|
|
93121
|
+
const metrics = ctx2.measureText(displayText);
|
|
92615
93122
|
const advanceWidth = metrics.width;
|
|
92616
93123
|
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
92617
93124
|
const textWidth = Math.max(advanceWidth, paintedWidth);
|
|
@@ -92637,7 +93144,7 @@ const resolveIndentHanging = (item) => {
|
|
|
92637
93144
|
if (indentHanging > 0) {
|
|
92638
93145
|
return indentHanging;
|
|
92639
93146
|
}
|
|
92640
|
-
return DEFAULT_LIST_HANGING_PX;
|
|
93147
|
+
return DEFAULT_LIST_HANGING_PX$1;
|
|
92641
93148
|
};
|
|
92642
93149
|
const buildTabStopsPx = (indent, tabs, tabIntervalTwips) => {
|
|
92643
93150
|
const paragraphIndentTwips = {
|