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
|
@@ -42410,7 +42410,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42410
42410
|
static getStoredSuperdocVersion(docx) {
|
|
42411
42411
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42412
42412
|
}
|
|
42413
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.
|
|
42413
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.4") {
|
|
42414
42414
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42415
42415
|
}
|
|
42416
42416
|
/**
|
|
@@ -60491,7 +60491,7 @@ const isHeadless = (editor) => {
|
|
|
60491
60491
|
const shouldSkipNodeView = (editor) => {
|
|
60492
60492
|
return isHeadless(editor);
|
|
60493
60493
|
};
|
|
60494
|
-
const summaryVersion = "2.0.0-next.
|
|
60494
|
+
const summaryVersion = "2.0.0-next.4";
|
|
60495
60495
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
60496
60496
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
60497
60497
|
function mapAttributes(attrs) {
|
|
@@ -61280,7 +61280,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
61280
61280
|
{ default: remarkStringify },
|
|
61281
61281
|
{ default: remarkGfm }
|
|
61282
61282
|
] = await Promise.all([
|
|
61283
|
-
import("./index-
|
|
61283
|
+
import("./index-YoL4XmHs-DnigArXx.es.js"),
|
|
61284
61284
|
import("./index-DRCvimau-Cw339678.es.js"),
|
|
61285
61285
|
import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
|
|
61286
61286
|
import("./index-D_sWOSiG-DE96TaT5.es.js"),
|
|
@@ -61485,7 +61485,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
61485
61485
|
* Process collaboration migrations
|
|
61486
61486
|
*/
|
|
61487
61487
|
processCollaborationMigrations() {
|
|
61488
|
-
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.
|
|
61488
|
+
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.4");
|
|
61489
61489
|
if (!this.options.ydoc) return;
|
|
61490
61490
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
61491
61491
|
let docVersion = metaMap.get("version");
|
|
@@ -68737,7 +68737,7 @@ function isMinimalWordLayout(value) {
|
|
|
68737
68737
|
return true;
|
|
68738
68738
|
}
|
|
68739
68739
|
const LIST_MARKER_GAP$2 = 8;
|
|
68740
|
-
const DEFAULT_TAB_INTERVAL_PX$
|
|
68740
|
+
const DEFAULT_TAB_INTERVAL_PX$2 = 48;
|
|
68741
68741
|
const DEFAULT_PAGE_HEIGHT_PX = 1056;
|
|
68742
68742
|
const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
|
|
68743
68743
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
@@ -69664,6 +69664,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69664
69664
|
const block = lookup2.block;
|
|
69665
69665
|
const measure = lookup2.measure;
|
|
69666
69666
|
const wordLayout = isMinimalWordLayout(block.attrs?.wordLayout) ? block.attrs.wordLayout : void 0;
|
|
69667
|
+
const alignment2 = block.attrs?.alignment;
|
|
69667
69668
|
const fragmentEl = this.doc.createElement("div");
|
|
69668
69669
|
fragmentEl.classList.add(CLASS_NAMES$1.fragment);
|
|
69669
69670
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
@@ -69742,7 +69743,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69742
69743
|
const textStart = paraIndentLeft + firstLine;
|
|
69743
69744
|
tabWidth = textStart - currentPos;
|
|
69744
69745
|
if (tabWidth <= 0) {
|
|
69745
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
69746
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
69746
69747
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
69747
69748
|
tabWidth = LIST_MARKER_GAP$2;
|
|
69748
69749
|
}
|
|
@@ -69769,6 +69770,21 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69769
69770
|
let availableWidthOverride = line.maxWidth != null ? Math.min(line.maxWidth, fallbackAvailableWidth) : fallbackAvailableWidth;
|
|
69770
69771
|
if (index2 === 0 && listFirstLineMarkerTabWidth != null) {
|
|
69771
69772
|
availableWidthOverride = fragment.width - listFirstLineMarkerTabWidth - Math.max(0, paraIndentRight);
|
|
69773
|
+
if (alignment2 === "justify" || alignment2 === "both") {
|
|
69774
|
+
console.log(
|
|
69775
|
+
"[justify-debug][painter-firstline-available]",
|
|
69776
|
+
JSON.stringify({
|
|
69777
|
+
blockId: block.id,
|
|
69778
|
+
fragmentWidth: fragment.width,
|
|
69779
|
+
markerTabWidth: listFirstLineMarkerTabWidth,
|
|
69780
|
+
paraIndentRight,
|
|
69781
|
+
availableWidthOverride,
|
|
69782
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
69783
|
+
lineWidth: line.width,
|
|
69784
|
+
lineNaturalWidth: line.naturalWidth ?? null
|
|
69785
|
+
})
|
|
69786
|
+
);
|
|
69787
|
+
}
|
|
69772
69788
|
}
|
|
69773
69789
|
const isLastLineOfFragment = index2 === lines.length - 1;
|
|
69774
69790
|
const isLastLineOfParagraph = isLastLineOfFragment && !fragment.continuesOnNext;
|
|
@@ -69894,7 +69910,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69894
69910
|
const textStart = paraIndentLeft + firstLine;
|
|
69895
69911
|
tabWidth = textStart - currentPos;
|
|
69896
69912
|
if (tabWidth <= 0) {
|
|
69897
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
69913
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
69898
69914
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
69899
69915
|
tabWidth = LIST_MARKER_GAP$2;
|
|
69900
69916
|
}
|
|
@@ -71428,6 +71444,23 @@ const _DomPainter = class _DomPainter2 {
|
|
|
71428
71444
|
if (spacingPerSpace !== 0) {
|
|
71429
71445
|
el.style.wordSpacing = `${spacingPerSpace}px`;
|
|
71430
71446
|
}
|
|
71447
|
+
if (justifyShouldApply && spacingPerSpace < 0) {
|
|
71448
|
+
console.log(
|
|
71449
|
+
"[justify-debug][painter-wordspacing-negative]",
|
|
71450
|
+
JSON.stringify({
|
|
71451
|
+
blockId: block.id,
|
|
71452
|
+
lineIndex: lineIndex ?? null,
|
|
71453
|
+
alignment: alignment2 ?? null,
|
|
71454
|
+
availableWidth,
|
|
71455
|
+
lineWidth,
|
|
71456
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
71457
|
+
lineNaturalWidth: line.naturalWidth ?? null,
|
|
71458
|
+
spaceCount,
|
|
71459
|
+
hasExplicitPositioning: Boolean(hasExplicitPositioning),
|
|
71460
|
+
skipJustify: Boolean(skipJustify)
|
|
71461
|
+
})
|
|
71462
|
+
);
|
|
71463
|
+
}
|
|
71431
71464
|
if (hasExplicitPositioning && line.segments) {
|
|
71432
71465
|
const paraIndent = block.attrs?.indent;
|
|
71433
71466
|
const indentLeft = paraIndent?.left ?? 0;
|
|
@@ -73621,6 +73654,28 @@ let measurementCtx = null;
|
|
|
73621
73654
|
const TAB_CHAR_LENGTH = 1;
|
|
73622
73655
|
const SPACE_CHARS = SPACE_CHARS$1;
|
|
73623
73656
|
const isTabRun$1 = (run2) => run2?.kind === "tab";
|
|
73657
|
+
const isWordChar$3 = (char) => {
|
|
73658
|
+
if (!char) return false;
|
|
73659
|
+
const code = char.charCodeAt(0);
|
|
73660
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
73661
|
+
};
|
|
73662
|
+
const capitalizeText$2 = (text) => {
|
|
73663
|
+
if (!text) return text;
|
|
73664
|
+
let result = "";
|
|
73665
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
73666
|
+
const prevChar = i > 0 ? text[i - 1] : "";
|
|
73667
|
+
const ch = text[i];
|
|
73668
|
+
result += isWordChar$3(ch) && !isWordChar$3(prevChar) ? ch.toUpperCase() : ch;
|
|
73669
|
+
}
|
|
73670
|
+
return result;
|
|
73671
|
+
};
|
|
73672
|
+
const applyTextTransform$2 = (text, transform) => {
|
|
73673
|
+
if (!text || !transform || transform === "none") return text;
|
|
73674
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
73675
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
73676
|
+
if (transform === "capitalize") return capitalizeText$2(text);
|
|
73677
|
+
return text;
|
|
73678
|
+
};
|
|
73624
73679
|
function getMeasurementContext() {
|
|
73625
73680
|
if (measurementCtx) return measurementCtx;
|
|
73626
73681
|
if (typeof document === "undefined") {
|
|
@@ -73796,17 +73851,19 @@ function measureCharacterX(block, line, charOffset, availableWidthOverride, alig
|
|
|
73796
73851
|
}
|
|
73797
73852
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73798
73853
|
const runLength = text.length;
|
|
73854
|
+
const transform = isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? void 0 : run2.textTransform;
|
|
73855
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73799
73856
|
if (currentCharOffset + runLength >= charOffset) {
|
|
73800
73857
|
const offsetInRun = charOffset - currentCharOffset;
|
|
73801
73858
|
ctx2.font = getRunFontString(run2);
|
|
73802
|
-
const textUpToTarget =
|
|
73859
|
+
const textUpToTarget = displayText.slice(0, offsetInRun);
|
|
73803
73860
|
const measured2 = ctx2.measureText(textUpToTarget);
|
|
73804
73861
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
|
|
73805
|
-
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(
|
|
73862
|
+
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(text.slice(0, offsetInRun)) : 0;
|
|
73806
73863
|
return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73807
73864
|
}
|
|
73808
73865
|
ctx2.font = getRunFontString(run2);
|
|
73809
|
-
const measured = ctx2.measureText(
|
|
73866
|
+
const measured = ctx2.measureText(displayText);
|
|
73810
73867
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73811
73868
|
const spacesInRun = justify.extraPerSpace !== 0 ? countSpaces(text) : 0;
|
|
73812
73869
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -73845,8 +73902,10 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
73845
73902
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
73846
73903
|
}
|
|
73847
73904
|
const text = run2.text ?? "";
|
|
73848
|
-
const
|
|
73849
|
-
const
|
|
73905
|
+
const transform = "textTransform" in run2 ? run2.textTransform : void 0;
|
|
73906
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73907
|
+
const displaySegmentText = displayText.slice(segment.fromChar, segment.toChar);
|
|
73908
|
+
const textUpToTarget = displaySegmentText.slice(0, offsetInSegment);
|
|
73850
73909
|
ctx2.font = getRunFontString(run2);
|
|
73851
73910
|
const measured = ctx2.measureText(textUpToTarget);
|
|
73852
73911
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInSegment, segmentChars);
|
|
@@ -73942,12 +74001,14 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73942
74001
|
}
|
|
73943
74002
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73944
74003
|
const runLength = text.length;
|
|
74004
|
+
const transform = isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? void 0 : run2.textTransform;
|
|
74005
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73945
74006
|
if (runLength === 0) continue;
|
|
73946
74007
|
ctx2.font = getRunFontString(run2);
|
|
73947
74008
|
for (let i = 0; i <= runLength; i++) {
|
|
73948
|
-
const textUpToChar =
|
|
74009
|
+
const textUpToChar = displayText.slice(0, i);
|
|
73949
74010
|
const measured2 = ctx2.measureText(textUpToChar);
|
|
73950
|
-
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(
|
|
74011
|
+
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text.slice(0, i)) : 0;
|
|
73951
74012
|
const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73952
74013
|
if (charX >= safeX) {
|
|
73953
74014
|
if (i === 0) {
|
|
@@ -73957,7 +74018,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73957
74018
|
pmPosition: pmPosition3
|
|
73958
74019
|
};
|
|
73959
74020
|
}
|
|
73960
|
-
const prevText =
|
|
74021
|
+
const prevText = displayText.slice(0, i - 1);
|
|
73961
74022
|
const prevMeasured = ctx2.measureText(prevText);
|
|
73962
74023
|
const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run2, i - 1, runLength);
|
|
73963
74024
|
const distToPrev = Math.abs(safeX - prevX);
|
|
@@ -73970,7 +74031,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73970
74031
|
};
|
|
73971
74032
|
}
|
|
73972
74033
|
}
|
|
73973
|
-
const measured = ctx2.measureText(
|
|
74034
|
+
const measured = ctx2.measureText(displayText);
|
|
73974
74035
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73975
74036
|
const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
|
|
73976
74037
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -74401,6 +74462,83 @@ function findCharIndexAtX(textNode, container, targetX) {
|
|
|
74401
74462
|
}
|
|
74402
74463
|
return index2;
|
|
74403
74464
|
}
|
|
74465
|
+
const LIST_MARKER_GAP$1 = 8;
|
|
74466
|
+
const MIN_MARKER_GUTTER = 24;
|
|
74467
|
+
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
74468
|
+
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
74469
|
+
const DEFAULT_LIST_HANGING_PX$1 = 18;
|
|
74470
|
+
const SPACE_SUFFIX_GAP_PX = 4;
|
|
74471
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
74472
|
+
function resolveListTextStartPx(wordLayout, indentLeft, firstLine, hanging, measureMarkerText) {
|
|
74473
|
+
const marker = wordLayout?.marker;
|
|
74474
|
+
if (!marker) {
|
|
74475
|
+
const textStartPx = wordLayout?.firstLineIndentMode === true && typeof wordLayout.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
74476
|
+
return textStartPx;
|
|
74477
|
+
}
|
|
74478
|
+
const markerBoxWidth = typeof marker.markerBoxWidthPx === "number" && Number.isFinite(marker.markerBoxWidthPx) ? marker.markerBoxWidthPx : 0;
|
|
74479
|
+
let markerTextWidth = typeof marker.glyphWidthPx === "number" && Number.isFinite(marker.glyphWidthPx) ? marker.glyphWidthPx : void 0;
|
|
74480
|
+
if (markerTextWidth == null && marker.markerText) {
|
|
74481
|
+
markerTextWidth = measureMarkerText(marker.markerText, marker);
|
|
74482
|
+
}
|
|
74483
|
+
if (!Number.isFinite(markerTextWidth) || markerTextWidth !== void 0 && markerTextWidth < 0) {
|
|
74484
|
+
markerTextWidth = markerBoxWidth;
|
|
74485
|
+
}
|
|
74486
|
+
const finalMarkerTextWidth = Math.max(0, markerTextWidth ?? 0);
|
|
74487
|
+
let markerStartPos;
|
|
74488
|
+
if (wordLayout?.firstLineIndentMode === true && typeof marker.markerX === "number" && Number.isFinite(marker.markerX)) {
|
|
74489
|
+
markerStartPos = marker.markerX;
|
|
74490
|
+
} else {
|
|
74491
|
+
markerStartPos = indentLeft - hanging + firstLine;
|
|
74492
|
+
}
|
|
74493
|
+
if (!Number.isFinite(markerStartPos)) {
|
|
74494
|
+
markerStartPos = 0;
|
|
74495
|
+
}
|
|
74496
|
+
const currentPos = markerStartPos + finalMarkerTextWidth;
|
|
74497
|
+
const suffix2 = marker.suffix ?? "tab";
|
|
74498
|
+
if (suffix2 === "space") {
|
|
74499
|
+
return markerStartPos + finalMarkerTextWidth + SPACE_SUFFIX_GAP_PX;
|
|
74500
|
+
}
|
|
74501
|
+
if (suffix2 === "nothing") {
|
|
74502
|
+
return markerStartPos + finalMarkerTextWidth;
|
|
74503
|
+
}
|
|
74504
|
+
const markerJustification = marker.justification ?? "left";
|
|
74505
|
+
if (markerJustification !== "left") {
|
|
74506
|
+
const gutterWidth = typeof marker.gutterWidthPx === "number" && Number.isFinite(marker.gutterWidthPx) && marker.gutterWidthPx > 0 ? marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
74507
|
+
return markerStartPos + finalMarkerTextWidth + Math.max(gutterWidth, LIST_MARKER_GAP$1);
|
|
74508
|
+
}
|
|
74509
|
+
if (wordLayout?.firstLineIndentMode === true) {
|
|
74510
|
+
let targetTabStop;
|
|
74511
|
+
if (Array.isArray(wordLayout.tabsPx)) {
|
|
74512
|
+
for (const tab of wordLayout.tabsPx) {
|
|
74513
|
+
if (typeof tab === "number" && tab > currentPos) {
|
|
74514
|
+
targetTabStop = tab;
|
|
74515
|
+
break;
|
|
74516
|
+
}
|
|
74517
|
+
}
|
|
74518
|
+
}
|
|
74519
|
+
const textStartTarget = typeof marker.textStartX === "number" && Number.isFinite(marker.textStartX) ? marker.textStartX : wordLayout.textStartPx;
|
|
74520
|
+
let tabWidth2;
|
|
74521
|
+
if (targetTabStop !== void 0) {
|
|
74522
|
+
tabWidth2 = targetTabStop - currentPos;
|
|
74523
|
+
} else if (textStartTarget !== void 0 && Number.isFinite(textStartTarget) && textStartTarget > currentPos) {
|
|
74524
|
+
tabWidth2 = textStartTarget - currentPos;
|
|
74525
|
+
} else {
|
|
74526
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74527
|
+
}
|
|
74528
|
+
if (tabWidth2 < LIST_MARKER_GAP$1) {
|
|
74529
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74530
|
+
}
|
|
74531
|
+
return markerStartPos + finalMarkerTextWidth + tabWidth2;
|
|
74532
|
+
}
|
|
74533
|
+
const textStart = indentLeft + firstLine;
|
|
74534
|
+
let tabWidth = textStart - currentPos;
|
|
74535
|
+
if (tabWidth <= 0) {
|
|
74536
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
74537
|
+
} else if (tabWidth < LIST_MARKER_GAP$1) {
|
|
74538
|
+
tabWidth = LIST_MARKER_GAP$1;
|
|
74539
|
+
}
|
|
74540
|
+
return markerStartPos + finalMarkerTextWidth + tabWidth;
|
|
74541
|
+
}
|
|
74404
74542
|
function getWordLayoutConfig(block) {
|
|
74405
74543
|
if (!block || block.kind !== "paragraph") {
|
|
74406
74544
|
return void 0;
|
|
@@ -74433,9 +74571,16 @@ function calculateTextStartIndent(params2) {
|
|
|
74433
74571
|
const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
|
|
74434
74572
|
let indentAdjust = paraIndentLeft;
|
|
74435
74573
|
if (isListItem2 && isFirstLine && isFirstLineIndentMode) {
|
|
74574
|
+
const resolvedTextStart = resolveListTextStartPx(
|
|
74575
|
+
wordLayout,
|
|
74576
|
+
paraIndentLeft,
|
|
74577
|
+
Math.max(firstLineIndent, 0),
|
|
74578
|
+
Math.max(hangingIndent, 0),
|
|
74579
|
+
() => markerWidth
|
|
74580
|
+
// Use provided markerWidth since we don't have canvas access here
|
|
74581
|
+
);
|
|
74436
74582
|
const textStartFallback = paraIndentLeft + Math.max(firstLineIndent, 0) + markerWidth;
|
|
74437
|
-
|
|
74438
|
-
indentAdjust = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : textStartFallback;
|
|
74583
|
+
indentAdjust = typeof resolvedTextStart === "number" && Number.isFinite(resolvedTextStart) ? resolvedTextStart : textStartFallback;
|
|
74439
74584
|
} else if (isFirstLine && !isListItem2) {
|
|
74440
74585
|
indentAdjust += firstLineOffset;
|
|
74441
74586
|
}
|
|
@@ -74591,7 +74736,10 @@ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, opt
|
|
|
74591
74736
|
}
|
|
74592
74737
|
function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
74593
74738
|
const zones = [];
|
|
74594
|
-
|
|
74739
|
+
let currentColumns = columns;
|
|
74740
|
+
let currentMargins = margins;
|
|
74741
|
+
let currentPageWidth = pageWidth;
|
|
74742
|
+
let marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74595
74743
|
return {
|
|
74596
74744
|
registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
74597
74745
|
if (!drawingBlock.anchor?.isAnchored) {
|
|
@@ -74604,7 +74752,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74604
74752
|
}
|
|
74605
74753
|
const objectWidth = measure.width ?? 0;
|
|
74606
74754
|
const objectHeight = measure.height ?? 0;
|
|
74607
|
-
const x2 = computeAnchorX(anchor, columnIndex,
|
|
74755
|
+
const x2 = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
|
|
74608
74756
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74609
74757
|
const zone = {
|
|
74610
74758
|
imageBlockId: drawingBlock.id,
|
|
@@ -74638,7 +74786,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74638
74786
|
}
|
|
74639
74787
|
const tableWidth = measure.totalWidth ?? 0;
|
|
74640
74788
|
const tableHeight = measure.totalHeight ?? 0;
|
|
74641
|
-
const x2 = computeTableAnchorX(anchor, columnIndex,
|
|
74789
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
|
|
74642
74790
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74643
74791
|
const zone = {
|
|
74644
74792
|
imageBlockId: tableBlock.id,
|
|
@@ -74686,7 +74834,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74686
74834
|
}
|
|
74687
74835
|
const leftFloats = [];
|
|
74688
74836
|
const rightFloats = [];
|
|
74689
|
-
const columnOrigin = marginLeft + columnIndex * (
|
|
74837
|
+
const columnOrigin = marginLeft + columnIndex * (currentColumns.width + currentColumns.gap);
|
|
74690
74838
|
const columnCenter = columnOrigin + baseWidth / 2;
|
|
74691
74839
|
for (const zone of wrappingZones) {
|
|
74692
74840
|
if (zone.wrapMode === "left") {
|
|
@@ -74725,6 +74873,22 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74725
74873
|
},
|
|
74726
74874
|
clear() {
|
|
74727
74875
|
zones.length = 0;
|
|
74876
|
+
},
|
|
74877
|
+
/**
|
|
74878
|
+
* Update layout context used for positioning and wrapping (columns, margins, page width).
|
|
74879
|
+
* This method should be called when the layout configuration changes (e.g., section breaks,
|
|
74880
|
+
* column changes, page size changes) to ensure floating objects are positioned and wrapped
|
|
74881
|
+
* correctly relative to the new layout boundaries.
|
|
74882
|
+
*
|
|
74883
|
+
* @param nextColumns - Column layout configuration (width, gap, count)
|
|
74884
|
+
* @param nextMargins - Optional page margins (left, right) in pixels
|
|
74885
|
+
* @param nextPageWidth - Optional total page width in pixels
|
|
74886
|
+
*/
|
|
74887
|
+
setLayoutContext(nextColumns, nextMargins, nextPageWidth) {
|
|
74888
|
+
currentColumns = nextColumns;
|
|
74889
|
+
currentMargins = nextMargins;
|
|
74890
|
+
currentPageWidth = nextPageWidth;
|
|
74891
|
+
marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74728
74892
|
}
|
|
74729
74893
|
};
|
|
74730
74894
|
}
|
|
@@ -74824,7 +74988,14 @@ function computeNextSectionPropsAtBreak(blocks) {
|
|
|
74824
74988
|
const props = {};
|
|
74825
74989
|
if (source.kind !== "sectionBreak") return props;
|
|
74826
74990
|
if (source.margins) {
|
|
74827
|
-
props.margins = {
|
|
74991
|
+
props.margins = {
|
|
74992
|
+
header: source.margins.header,
|
|
74993
|
+
footer: source.margins.footer,
|
|
74994
|
+
top: source.margins.top,
|
|
74995
|
+
right: source.margins.right,
|
|
74996
|
+
bottom: source.margins.bottom,
|
|
74997
|
+
left: source.margins.left
|
|
74998
|
+
};
|
|
74828
74999
|
}
|
|
74829
75000
|
if (source.pageSize) {
|
|
74830
75001
|
props.pageSize = { w: source.pageSize.w, h: source.pageSize.h };
|
|
@@ -74872,20 +75043,36 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74872
75043
|
next.activeOrientation = block.orientation;
|
|
74873
75044
|
next.pendingOrientation = null;
|
|
74874
75045
|
}
|
|
75046
|
+
const headerDistance = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
75047
|
+
const footerDistance = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
75048
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
75049
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
74875
75050
|
if (block.margins?.header !== void 0) {
|
|
74876
|
-
const headerDistance = Math.max(0, block.margins.header);
|
|
74877
75051
|
next.activeHeaderDistance = headerDistance;
|
|
74878
75052
|
next.pendingHeaderDistance = headerDistance;
|
|
74879
|
-
next.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
|
|
74880
|
-
next.pendingTopMargin = next.activeTopMargin;
|
|
74881
75053
|
}
|
|
74882
75054
|
if (block.margins?.footer !== void 0) {
|
|
74883
|
-
const footerDistance = Math.max(0, block.margins.footer);
|
|
74884
75055
|
next.activeFooterDistance = footerDistance;
|
|
74885
75056
|
next.pendingFooterDistance = footerDistance;
|
|
74886
|
-
|
|
75057
|
+
}
|
|
75058
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
75059
|
+
next.activeTopMargin = calcRequiredTopMargin(headerDistance, sectionTop);
|
|
75060
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
75061
|
+
}
|
|
75062
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
75063
|
+
next.activeBottomMargin = calcRequiredBottomMargin(footerDistance, sectionBottom);
|
|
74887
75064
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
74888
75065
|
}
|
|
75066
|
+
if (block.margins?.left !== void 0) {
|
|
75067
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
75068
|
+
next.activeLeftMargin = leftMargin;
|
|
75069
|
+
next.pendingLeftMargin = leftMargin;
|
|
75070
|
+
}
|
|
75071
|
+
if (block.margins?.right !== void 0) {
|
|
75072
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
75073
|
+
next.activeRightMargin = rightMargin;
|
|
75074
|
+
next.pendingRightMargin = rightMargin;
|
|
75075
|
+
}
|
|
74889
75076
|
if (block.columns) {
|
|
74890
75077
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
74891
75078
|
next.pendingColumns = null;
|
|
@@ -74894,26 +75081,42 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74894
75081
|
}
|
|
74895
75082
|
const headerPx = block.margins?.header;
|
|
74896
75083
|
const footerPx = block.margins?.footer;
|
|
75084
|
+
const topPx = block.margins?.top;
|
|
75085
|
+
const bottomPx = block.margins?.bottom;
|
|
74897
75086
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
74898
75087
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
75088
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
75089
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
74899
75090
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
74900
75091
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
74901
|
-
if (typeof headerPx === "number") {
|
|
74902
|
-
const newHeaderDist = Math.max(0, headerPx);
|
|
75092
|
+
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
75093
|
+
const newHeaderDist = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
75094
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
74903
75095
|
next.pendingHeaderDistance = newHeaderDist;
|
|
74904
|
-
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist,
|
|
75096
|
+
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, sectionTop);
|
|
74905
75097
|
} else {
|
|
74906
75098
|
next.pendingTopMargin = nextTop;
|
|
74907
75099
|
next.pendingHeaderDistance = nextHeader;
|
|
74908
75100
|
}
|
|
74909
|
-
if (typeof footerPx === "number") {
|
|
74910
|
-
const newFooterDist = Math.max(0, footerPx);
|
|
75101
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
75102
|
+
const newFooterDist = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
75103
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
74911
75104
|
next.pendingFooterDistance = newFooterDist;
|
|
74912
|
-
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist,
|
|
75105
|
+
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, sectionBottom);
|
|
74913
75106
|
} else {
|
|
74914
75107
|
next.pendingBottomMargin = nextBottom;
|
|
74915
75108
|
next.pendingFooterDistance = nextFooter;
|
|
74916
75109
|
}
|
|
75110
|
+
if (typeof block.margins?.left === "number") {
|
|
75111
|
+
next.pendingLeftMargin = Math.max(0, block.margins.left);
|
|
75112
|
+
} else {
|
|
75113
|
+
next.pendingLeftMargin = nextLeft;
|
|
75114
|
+
}
|
|
75115
|
+
if (typeof block.margins?.right === "number") {
|
|
75116
|
+
next.pendingRightMargin = Math.max(0, block.margins.right);
|
|
75117
|
+
} else {
|
|
75118
|
+
next.pendingRightMargin = nextRight;
|
|
75119
|
+
}
|
|
74917
75120
|
if (block.pageSize) {
|
|
74918
75121
|
next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
74919
75122
|
}
|
|
@@ -74973,6 +75176,12 @@ function applyPendingToActive(state2) {
|
|
|
74973
75176
|
if (next.pendingBottomMargin != null) {
|
|
74974
75177
|
next.activeBottomMargin = next.pendingBottomMargin;
|
|
74975
75178
|
}
|
|
75179
|
+
if (next.pendingLeftMargin != null) {
|
|
75180
|
+
next.activeLeftMargin = next.pendingLeftMargin;
|
|
75181
|
+
}
|
|
75182
|
+
if (next.pendingRightMargin != null) {
|
|
75183
|
+
next.activeRightMargin = next.pendingRightMargin;
|
|
75184
|
+
}
|
|
74976
75185
|
if (next.pendingHeaderDistance != null) {
|
|
74977
75186
|
next.activeHeaderDistance = next.pendingHeaderDistance;
|
|
74978
75187
|
}
|
|
@@ -74990,6 +75199,8 @@ function applyPendingToActive(state2) {
|
|
|
74990
75199
|
}
|
|
74991
75200
|
next.pendingTopMargin = null;
|
|
74992
75201
|
next.pendingBottomMargin = null;
|
|
75202
|
+
next.pendingLeftMargin = null;
|
|
75203
|
+
next.pendingRightMargin = null;
|
|
74993
75204
|
next.pendingHeaderDistance = null;
|
|
74994
75205
|
next.pendingFooterDistance = null;
|
|
74995
75206
|
next.pendingPageSize = null;
|
|
@@ -75218,7 +75429,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75218
75429
|
if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
|
|
75219
75430
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75220
75431
|
const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
|
|
75221
|
-
|
|
75432
|
+
const newLines = normalizeLines(newMeasure);
|
|
75433
|
+
lines = newLines;
|
|
75222
75434
|
didRemeasureForColumnWidth = true;
|
|
75223
75435
|
}
|
|
75224
75436
|
let fromLine = 0;
|
|
@@ -75300,7 +75512,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75300
75512
|
if (narrowestRemeasureWidth < remeasureWidth) {
|
|
75301
75513
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75302
75514
|
const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
|
|
75303
|
-
|
|
75515
|
+
const newLines = normalizeLines(newMeasure);
|
|
75516
|
+
lines = newLines;
|
|
75304
75517
|
didRemeasureForFloats = true;
|
|
75305
75518
|
}
|
|
75306
75519
|
}
|
|
@@ -75644,6 +75857,94 @@ function getCellPadding(cellIdx, blockRow) {
|
|
|
75644
75857
|
function getCellTotalLines(cell) {
|
|
75645
75858
|
return getCellLines(cell).length;
|
|
75646
75859
|
}
|
|
75860
|
+
function mergePmRange(target, range2) {
|
|
75861
|
+
if (typeof range2.pmStart === "number") {
|
|
75862
|
+
target.pmStart = target.pmStart == null ? range2.pmStart : Math.min(target.pmStart, range2.pmStart);
|
|
75863
|
+
}
|
|
75864
|
+
if (typeof range2.pmEnd === "number") {
|
|
75865
|
+
target.pmEnd = target.pmEnd == null ? range2.pmEnd : Math.max(target.pmEnd, range2.pmEnd);
|
|
75866
|
+
}
|
|
75867
|
+
}
|
|
75868
|
+
function computeCellPmRange(cell, cellMeasure, fromLine, toLine) {
|
|
75869
|
+
const range2 = {};
|
|
75870
|
+
if (!cell || !cellMeasure) return range2;
|
|
75871
|
+
const cellBlocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
|
|
75872
|
+
const blockMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
|
|
75873
|
+
const maxBlocks = Math.min(cellBlocks.length, blockMeasures.length);
|
|
75874
|
+
let cumulativeLineCount = 0;
|
|
75875
|
+
for (let i = 0; i < maxBlocks; i++) {
|
|
75876
|
+
const block = cellBlocks[i];
|
|
75877
|
+
const blockMeasure = blockMeasures[i];
|
|
75878
|
+
if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
|
|
75879
|
+
const paraMeasure = blockMeasure;
|
|
75880
|
+
const lines = paraMeasure.lines;
|
|
75881
|
+
const blockLineCount = lines?.length ?? 0;
|
|
75882
|
+
const blockStartGlobal = cumulativeLineCount;
|
|
75883
|
+
const blockEndGlobal = cumulativeLineCount + blockLineCount;
|
|
75884
|
+
const localFrom = Math.max(fromLine, blockStartGlobal) - blockStartGlobal;
|
|
75885
|
+
const localTo = Math.min(toLine, blockEndGlobal) - blockStartGlobal;
|
|
75886
|
+
if (lines && lines.length > 0 && localFrom < localTo) {
|
|
75887
|
+
mergePmRange(range2, computeFragmentPmRange(block, lines, localFrom, localTo));
|
|
75888
|
+
} else {
|
|
75889
|
+
mergePmRange(range2, extractBlockPmRange(block));
|
|
75890
|
+
}
|
|
75891
|
+
cumulativeLineCount += blockLineCount;
|
|
75892
|
+
continue;
|
|
75893
|
+
}
|
|
75894
|
+
mergePmRange(range2, extractBlockPmRange(block));
|
|
75895
|
+
}
|
|
75896
|
+
return range2;
|
|
75897
|
+
}
|
|
75898
|
+
function computeTableFragmentPmRange(block, measure, fromRow, toRow, partialRow) {
|
|
75899
|
+
const range2 = {};
|
|
75900
|
+
for (let rowIndex = fromRow; rowIndex < toRow; rowIndex++) {
|
|
75901
|
+
const row = block.rows[rowIndex];
|
|
75902
|
+
const rowMeasure = measure.rows[rowIndex];
|
|
75903
|
+
if (!row || !rowMeasure) continue;
|
|
75904
|
+
const isPartial = partialRow?.rowIndex === rowIndex;
|
|
75905
|
+
const cellCount = Math.min(row.cells.length, rowMeasure.cells.length);
|
|
75906
|
+
for (let cellIndex = 0; cellIndex < cellCount; cellIndex++) {
|
|
75907
|
+
const cell = row.cells[cellIndex];
|
|
75908
|
+
const cellMeasure = rowMeasure.cells[cellIndex];
|
|
75909
|
+
if (!cell || !cellMeasure) continue;
|
|
75910
|
+
const totalLines = getCellTotalLines(cellMeasure);
|
|
75911
|
+
let fromLine = 0;
|
|
75912
|
+
let toLine = totalLines;
|
|
75913
|
+
if (isPartial) {
|
|
75914
|
+
const hasValidFromLineByCell = partialRow?.fromLineByCell && cellIndex < partialRow.fromLineByCell.length;
|
|
75915
|
+
const hasValidToLineByCell = partialRow?.toLineByCell && cellIndex < partialRow.toLineByCell.length;
|
|
75916
|
+
if (hasValidFromLineByCell) {
|
|
75917
|
+
const rawFrom = partialRow.fromLineByCell[cellIndex];
|
|
75918
|
+
if (typeof rawFrom === "number" && rawFrom >= 0) {
|
|
75919
|
+
fromLine = rawFrom;
|
|
75920
|
+
}
|
|
75921
|
+
}
|
|
75922
|
+
if (hasValidToLineByCell) {
|
|
75923
|
+
const rawTo = partialRow.toLineByCell[cellIndex];
|
|
75924
|
+
if (typeof rawTo === "number") {
|
|
75925
|
+
toLine = rawTo === -1 ? totalLines : rawTo;
|
|
75926
|
+
}
|
|
75927
|
+
}
|
|
75928
|
+
}
|
|
75929
|
+
fromLine = Math.max(0, Math.min(fromLine, totalLines));
|
|
75930
|
+
toLine = Math.max(0, Math.min(toLine, totalLines));
|
|
75931
|
+
if (toLine < fromLine) {
|
|
75932
|
+
toLine = fromLine;
|
|
75933
|
+
}
|
|
75934
|
+
mergePmRange(range2, computeCellPmRange(cell, cellMeasure, fromLine, toLine));
|
|
75935
|
+
}
|
|
75936
|
+
}
|
|
75937
|
+
return range2;
|
|
75938
|
+
}
|
|
75939
|
+
function applyTableFragmentPmRange(fragment, block, measure) {
|
|
75940
|
+
const range2 = computeTableFragmentPmRange(block, measure, fragment.fromRow, fragment.toRow, fragment.partialRow);
|
|
75941
|
+
if (range2.pmStart != null) {
|
|
75942
|
+
fragment.pmStart = range2.pmStart;
|
|
75943
|
+
}
|
|
75944
|
+
if (range2.pmEnd != null) {
|
|
75945
|
+
fragment.pmEnd = range2.pmEnd;
|
|
75946
|
+
}
|
|
75947
|
+
}
|
|
75647
75948
|
function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLineByCell) {
|
|
75648
75949
|
const row = measure.rows[rowIndex];
|
|
75649
75950
|
if (!row) {
|
|
@@ -75788,6 +76089,7 @@ function layoutMonolithicTable(context) {
|
|
|
75788
76089
|
height,
|
|
75789
76090
|
metadata
|
|
75790
76091
|
};
|
|
76092
|
+
applyTableFragmentPmRange(fragment, context.block, context.measure);
|
|
75791
76093
|
state2.page.fragments.push(fragment);
|
|
75792
76094
|
state2.cursorY += height;
|
|
75793
76095
|
}
|
|
@@ -75866,6 +76168,7 @@ function layoutTableBlock({
|
|
|
75866
76168
|
height,
|
|
75867
76169
|
metadata
|
|
75868
76170
|
};
|
|
76171
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
75869
76172
|
state2.page.fragments.push(fragment);
|
|
75870
76173
|
state2.cursorY += height;
|
|
75871
76174
|
return;
|
|
@@ -75929,6 +76232,7 @@ function layoutTableBlock({
|
|
|
75929
76232
|
partialRow: continuationPartialRow,
|
|
75930
76233
|
metadata: generateFragmentMetadata(measure)
|
|
75931
76234
|
};
|
|
76235
|
+
applyTableFragmentPmRange(fragment2, block, measure);
|
|
75932
76236
|
state2.page.fragments.push(fragment2);
|
|
75933
76237
|
state2.cursorY += fragmentHeight2;
|
|
75934
76238
|
}
|
|
@@ -75973,6 +76277,7 @@ function layoutTableBlock({
|
|
|
75973
76277
|
partialRow: forcedPartialRow,
|
|
75974
76278
|
metadata: generateFragmentMetadata(measure)
|
|
75975
76279
|
};
|
|
76280
|
+
applyTableFragmentPmRange(fragment2, block, measure);
|
|
75976
76281
|
state2.page.fragments.push(fragment2);
|
|
75977
76282
|
state2.cursorY += fragmentHeight2;
|
|
75978
76283
|
pendingPartialRow = forcedPartialRow;
|
|
@@ -76008,6 +76313,7 @@ function layoutTableBlock({
|
|
|
76008
76313
|
partialRow: partialRow || void 0,
|
|
76009
76314
|
metadata: generateFragmentMetadata(measure)
|
|
76010
76315
|
};
|
|
76316
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
76011
76317
|
state2.page.fragments.push(fragment);
|
|
76012
76318
|
state2.cursorY += fragmentHeight;
|
|
76013
76319
|
if (partialRow && !partialRow.isLastPart) {
|
|
@@ -76025,7 +76331,7 @@ function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
|
76025
76331
|
columnBoundaries: generateColumnBoundaries(measure),
|
|
76026
76332
|
coordinateSystem: "fragment"
|
|
76027
76333
|
};
|
|
76028
|
-
|
|
76334
|
+
const fragment = {
|
|
76029
76335
|
kind: "table",
|
|
76030
76336
|
blockId: block.id,
|
|
76031
76337
|
fromRow: 0,
|
|
@@ -76036,6 +76342,8 @@ function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
|
76036
76342
|
height: measure.totalHeight ?? 0,
|
|
76037
76343
|
metadata
|
|
76038
76344
|
};
|
|
76345
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
76346
|
+
return fragment;
|
|
76039
76347
|
}
|
|
76040
76348
|
function isPageRelativeAnchor(block) {
|
|
76041
76349
|
const vRelativeFrom = block.anchor?.vRelativeFrom;
|
|
@@ -76457,8 +76765,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76457
76765
|
header: options.margins?.header ?? options.margins?.top ?? DEFAULT_MARGINS$2.top,
|
|
76458
76766
|
footer: options.margins?.footer ?? options.margins?.bottom ?? DEFAULT_MARGINS$2.bottom
|
|
76459
76767
|
};
|
|
76460
|
-
const
|
|
76461
|
-
if (
|
|
76768
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
76769
|
+
if (baseContentWidth <= 0) {
|
|
76462
76770
|
throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
|
|
76463
76771
|
}
|
|
76464
76772
|
const validateContentHeight = (height) => {
|
|
@@ -76488,8 +76796,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76488
76796
|
const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
|
|
76489
76797
|
let activeTopMargin = effectiveTopMargin;
|
|
76490
76798
|
let activeBottomMargin = effectiveBottomMargin;
|
|
76799
|
+
let activeLeftMargin = margins.left;
|
|
76800
|
+
let activeRightMargin = margins.right;
|
|
76491
76801
|
let pendingTopMargin = null;
|
|
76492
76802
|
let pendingBottomMargin = null;
|
|
76803
|
+
let pendingLeftMargin = null;
|
|
76804
|
+
let pendingRightMargin = null;
|
|
76493
76805
|
let activeHeaderDistance = margins.header ?? margins.top;
|
|
76494
76806
|
let pendingHeaderDistance = null;
|
|
76495
76807
|
let activeFooterDistance = margins.footer ?? margins.bottom;
|
|
@@ -76502,10 +76814,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76502
76814
|
let pendingOrientation = null;
|
|
76503
76815
|
let activeVAlign = null;
|
|
76504
76816
|
let pendingVAlign = null;
|
|
76817
|
+
const paginatorMargins = { left: activeLeftMargin, right: activeRightMargin };
|
|
76505
76818
|
const floatManager = createFloatingObjectManager(
|
|
76506
|
-
normalizeColumns(activeColumns,
|
|
76507
|
-
{ left:
|
|
76508
|
-
|
|
76819
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76820
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76821
|
+
activePageSize.w
|
|
76509
76822
|
);
|
|
76510
76823
|
const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks);
|
|
76511
76824
|
const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
|
|
@@ -76522,22 +76835,38 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76522
76835
|
next.activeOrientation = block.orientation;
|
|
76523
76836
|
next.pendingOrientation = null;
|
|
76524
76837
|
}
|
|
76838
|
+
const headerDistance2 = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
76839
|
+
const footerDistance2 = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
76840
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
76841
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
76525
76842
|
if (block.margins?.header !== void 0) {
|
|
76526
|
-
|
|
76527
|
-
next.
|
|
76528
|
-
next.pendingHeaderDistance = headerDist;
|
|
76529
|
-
const requiredTop = maxHeaderContentHeight > 0 ? headerDist + maxHeaderContentHeight : headerDist;
|
|
76530
|
-
next.activeTopMargin = Math.max(baseMargins.top, requiredTop);
|
|
76531
|
-
next.pendingTopMargin = next.activeTopMargin;
|
|
76843
|
+
next.activeHeaderDistance = headerDistance2;
|
|
76844
|
+
next.pendingHeaderDistance = headerDistance2;
|
|
76532
76845
|
}
|
|
76533
76846
|
if (block.margins?.footer !== void 0) {
|
|
76534
|
-
const footerDistance2 = Math.max(0, block.margins.footer);
|
|
76535
76847
|
next.activeFooterDistance = footerDistance2;
|
|
76536
76848
|
next.pendingFooterDistance = footerDistance2;
|
|
76849
|
+
}
|
|
76850
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
76851
|
+
const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : headerDistance2;
|
|
76852
|
+
next.activeTopMargin = Math.max(sectionTop, requiredTop);
|
|
76853
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
76854
|
+
}
|
|
76855
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
76537
76856
|
const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
|
|
76538
|
-
next.activeBottomMargin = Math.max(
|
|
76857
|
+
next.activeBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76539
76858
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
76540
76859
|
}
|
|
76860
|
+
if (block.margins?.left !== void 0) {
|
|
76861
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
76862
|
+
next.activeLeftMargin = leftMargin;
|
|
76863
|
+
next.pendingLeftMargin = leftMargin;
|
|
76864
|
+
}
|
|
76865
|
+
if (block.margins?.right !== void 0) {
|
|
76866
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
76867
|
+
next.activeRightMargin = rightMargin;
|
|
76868
|
+
next.pendingRightMargin = rightMargin;
|
|
76869
|
+
}
|
|
76541
76870
|
if (block.columns) {
|
|
76542
76871
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
76543
76872
|
next.pendingColumns = null;
|
|
@@ -76566,27 +76895,35 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76566
76895
|
const headerPx = block.margins?.header;
|
|
76567
76896
|
const footerPx = block.margins?.footer;
|
|
76568
76897
|
const topPx = block.margins?.top;
|
|
76898
|
+
const bottomPx = block.margins?.bottom;
|
|
76899
|
+
const leftPx = block.margins?.left;
|
|
76900
|
+
const rightPx = block.margins?.right;
|
|
76569
76901
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
76570
76902
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
76903
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
76904
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
76571
76905
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
76572
76906
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
76573
76907
|
next.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
76574
76908
|
next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
76575
76909
|
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
76576
|
-
const sectionTop = topPx
|
|
76910
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
76577
76911
|
const sectionHeader = next.pendingHeaderDistance;
|
|
76578
76912
|
const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
|
|
76579
76913
|
next.pendingTopMargin = Math.max(sectionTop, requiredTop);
|
|
76580
76914
|
} else {
|
|
76581
76915
|
next.pendingTopMargin = nextTop;
|
|
76582
76916
|
}
|
|
76583
|
-
if (typeof footerPx === "number") {
|
|
76917
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
76584
76918
|
const sectionFooter = next.pendingFooterDistance;
|
|
76919
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
76585
76920
|
const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
|
|
76586
|
-
next.pendingBottomMargin = Math.max(
|
|
76921
|
+
next.pendingBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76587
76922
|
} else {
|
|
76588
76923
|
next.pendingBottomMargin = nextBottom;
|
|
76589
76924
|
}
|
|
76925
|
+
next.pendingLeftMargin = typeof leftPx === "number" ? Math.max(0, leftPx) : nextLeft;
|
|
76926
|
+
next.pendingRightMargin = typeof rightPx === "number" ? Math.max(0, rightPx) : nextRight;
|
|
76590
76927
|
if (block.pageSize) next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
76591
76928
|
if (block.orientation) next.pendingOrientation = block.orientation;
|
|
76592
76929
|
const sectionType = block.type ?? "continuous";
|
|
@@ -76671,7 +77008,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76671
77008
|
let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
|
|
76672
77009
|
let pendingSectionIndex = null;
|
|
76673
77010
|
const paginator = createPaginator({
|
|
76674
|
-
margins:
|
|
77011
|
+
margins: paginatorMargins,
|
|
76675
77012
|
getActiveTopMargin: () => activeTopMargin,
|
|
76676
77013
|
getActiveBottomMargin: () => activeBottomMargin,
|
|
76677
77014
|
getActiveHeaderDistance: () => activeHeaderDistance,
|
|
@@ -76686,8 +77023,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76686
77023
|
const applied = applyPendingToActive({
|
|
76687
77024
|
activeTopMargin,
|
|
76688
77025
|
activeBottomMargin,
|
|
77026
|
+
activeLeftMargin,
|
|
77027
|
+
activeRightMargin,
|
|
76689
77028
|
pendingTopMargin,
|
|
76690
77029
|
pendingBottomMargin,
|
|
77030
|
+
pendingLeftMargin,
|
|
77031
|
+
pendingRightMargin,
|
|
76691
77032
|
activeHeaderDistance,
|
|
76692
77033
|
activeFooterDistance,
|
|
76693
77034
|
pendingHeaderDistance,
|
|
@@ -76702,8 +77043,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76702
77043
|
});
|
|
76703
77044
|
activeTopMargin = applied.activeTopMargin;
|
|
76704
77045
|
activeBottomMargin = applied.activeBottomMargin;
|
|
77046
|
+
activeLeftMargin = applied.activeLeftMargin;
|
|
77047
|
+
activeRightMargin = applied.activeRightMargin;
|
|
76705
77048
|
pendingTopMargin = applied.pendingTopMargin;
|
|
76706
77049
|
pendingBottomMargin = applied.pendingBottomMargin;
|
|
77050
|
+
pendingLeftMargin = applied.pendingLeftMargin;
|
|
77051
|
+
pendingRightMargin = applied.pendingRightMargin;
|
|
76707
77052
|
activeHeaderDistance = applied.activeHeaderDistance;
|
|
76708
77053
|
activeFooterDistance = applied.activeFooterDistance;
|
|
76709
77054
|
pendingHeaderDistance = applied.pendingHeaderDistance;
|
|
@@ -76715,6 +77060,14 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76715
77060
|
activeOrientation = applied.activeOrientation;
|
|
76716
77061
|
pendingOrientation = applied.pendingOrientation;
|
|
76717
77062
|
cachedColumnsState.state = null;
|
|
77063
|
+
paginatorMargins.left = activeLeftMargin;
|
|
77064
|
+
paginatorMargins.right = activeRightMargin;
|
|
77065
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77066
|
+
floatManager.setLayoutContext(
|
|
77067
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
77068
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
77069
|
+
activePageSize.w
|
|
77070
|
+
);
|
|
76718
77071
|
if (pendingNumbering) {
|
|
76719
77072
|
if (pendingNumbering.format) activeNumberFormat = pendingNumbering.format;
|
|
76720
77073
|
if (typeof pendingNumbering.start === "number" && Number.isFinite(pendingNumbering.start)) {
|
|
@@ -76759,7 +77112,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76759
77112
|
const getActiveColumnsForState = paginator.getActiveColumnsForState;
|
|
76760
77113
|
let cachedColumnsState = { state: null, constraintIndex: -2, contentWidth: -1, colsConfig: null, normalized: null };
|
|
76761
77114
|
const getCurrentColumns = () => {
|
|
76762
|
-
const currentContentWidth = activePageSize.w - (
|
|
77115
|
+
const currentContentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
76763
77116
|
const state2 = states[states.length - 1] ?? null;
|
|
76764
77117
|
const colsConfig = state2 ? getActiveColumnsForState(state2) : activeColumns;
|
|
76765
77118
|
const constraintIndex = state2 ? state2.activeConstraintIndex : -1;
|
|
@@ -76792,6 +77145,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76792
77145
|
layoutLog(` Current page: ${state2.page.number}, cursorY: ${state2.cursorY}`);
|
|
76793
77146
|
activeColumns = newColumns;
|
|
76794
77147
|
cachedColumnsState.state = null;
|
|
77148
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77149
|
+
floatManager.setLayoutContext(
|
|
77150
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
77151
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
77152
|
+
activePageSize.w
|
|
77153
|
+
);
|
|
76795
77154
|
};
|
|
76796
77155
|
const anchoredByParagraph = collectAnchoredDrawings(blocks, measures);
|
|
76797
77156
|
const anchoredTablesByParagraph = collectAnchoredTables(blocks, measures);
|
|
@@ -76823,10 +77182,10 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76823
77182
|
if (alignV === "top") {
|
|
76824
77183
|
anchorY = offsetV;
|
|
76825
77184
|
} else if (alignV === "bottom") {
|
|
76826
|
-
const pageHeight = contentBottom + margins
|
|
77185
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76827
77186
|
anchorY = pageHeight - imageHeight + offsetV;
|
|
76828
77187
|
} else if (alignV === "center") {
|
|
76829
|
-
const pageHeight = contentBottom + margins
|
|
77188
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76830
77189
|
anchorY = (pageHeight - imageHeight) / 2 + offsetV;
|
|
76831
77190
|
} else {
|
|
76832
77191
|
anchorY = offsetV;
|
|
@@ -76837,11 +77196,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76837
77196
|
const anchorX = entry.block.anchor ? computeAnchorX(
|
|
76838
77197
|
entry.block.anchor,
|
|
76839
77198
|
state2.columnIndex,
|
|
76840
|
-
normalizeColumns(activeColumns,
|
|
77199
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76841
77200
|
entry.measure.width,
|
|
76842
|
-
{ left:
|
|
77201
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76843
77202
|
activePageSize.w
|
|
76844
|
-
) :
|
|
77203
|
+
) : activeLeftMargin;
|
|
76845
77204
|
floatManager.registerDrawing(entry.block, entry.measure, anchorY, state2.columnIndex, state2.page.number);
|
|
76846
77205
|
preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state2.page.number });
|
|
76847
77206
|
}
|
|
@@ -76879,8 +77238,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76879
77238
|
const sectionState = {
|
|
76880
77239
|
activeTopMargin,
|
|
76881
77240
|
activeBottomMargin,
|
|
77241
|
+
activeLeftMargin,
|
|
77242
|
+
activeRightMargin,
|
|
76882
77243
|
pendingTopMargin,
|
|
76883
77244
|
pendingBottomMargin,
|
|
77245
|
+
pendingLeftMargin,
|
|
77246
|
+
pendingRightMargin,
|
|
76884
77247
|
activeHeaderDistance,
|
|
76885
77248
|
activeFooterDistance,
|
|
76886
77249
|
pendingHeaderDistance,
|
|
@@ -76914,8 +77277,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76914
77277
|
layoutLog(`[Layout] ========== END SECTION BREAK ==========`);
|
|
76915
77278
|
activeTopMargin = updatedState.activeTopMargin;
|
|
76916
77279
|
activeBottomMargin = updatedState.activeBottomMargin;
|
|
77280
|
+
activeLeftMargin = updatedState.activeLeftMargin;
|
|
77281
|
+
activeRightMargin = updatedState.activeRightMargin;
|
|
76917
77282
|
pendingTopMargin = updatedState.pendingTopMargin;
|
|
76918
77283
|
pendingBottomMargin = updatedState.pendingBottomMargin;
|
|
77284
|
+
pendingLeftMargin = updatedState.pendingLeftMargin;
|
|
77285
|
+
pendingRightMargin = updatedState.pendingRightMargin;
|
|
76919
77286
|
activeHeaderDistance = updatedState.activeHeaderDistance;
|
|
76920
77287
|
activeFooterDistance = updatedState.activeFooterDistance;
|
|
76921
77288
|
pendingHeaderDistance = updatedState.pendingHeaderDistance;
|
|
@@ -77053,8 +77420,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77053
77420
|
pageMargins: {
|
|
77054
77421
|
top: activeTopMargin,
|
|
77055
77422
|
bottom: activeBottomMargin,
|
|
77056
|
-
left:
|
|
77057
|
-
right:
|
|
77423
|
+
left: activeLeftMargin,
|
|
77424
|
+
right: activeRightMargin
|
|
77058
77425
|
},
|
|
77059
77426
|
columns: getCurrentColumns(),
|
|
77060
77427
|
placedAnchoredIds
|
|
@@ -77076,9 +77443,9 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77076
77443
|
const cols = getCurrentColumns();
|
|
77077
77444
|
let maxWidth;
|
|
77078
77445
|
if (relativeFrom === "page") {
|
|
77079
|
-
maxWidth = cols.count === 1 ? activePageSize.w -
|
|
77446
|
+
maxWidth = cols.count === 1 ? activePageSize.w - (activeLeftMargin + activeRightMargin) : activePageSize.w;
|
|
77080
77447
|
} else if (relativeFrom === "margin") {
|
|
77081
|
-
maxWidth = activePageSize.w -
|
|
77448
|
+
maxWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77082
77449
|
} else {
|
|
77083
77450
|
maxWidth = cols.width;
|
|
77084
77451
|
}
|
|
@@ -78265,11 +78632,11 @@ function findWordBoundaries(blocks, pos) {
|
|
|
78265
78632
|
if (text.length === 0) return null;
|
|
78266
78633
|
const clampedPos = Math.max(0, Math.min(localPos, text.length));
|
|
78267
78634
|
let wordStart = clampedPos;
|
|
78268
|
-
while (wordStart > 0 && isWordChar(text[wordStart - 1])) {
|
|
78635
|
+
while (wordStart > 0 && isWordChar$2(text[wordStart - 1])) {
|
|
78269
78636
|
wordStart--;
|
|
78270
78637
|
}
|
|
78271
78638
|
let wordEnd = clampedPos;
|
|
78272
|
-
while (wordEnd < text.length && isWordChar(text[wordEnd])) {
|
|
78639
|
+
while (wordEnd < text.length && isWordChar$2(text[wordEnd])) {
|
|
78273
78640
|
wordEnd++;
|
|
78274
78641
|
}
|
|
78275
78642
|
if (wordStart === wordEnd) {
|
|
@@ -78332,7 +78699,7 @@ function findBlockAtPosition(blocks, pos) {
|
|
|
78332
78699
|
}
|
|
78333
78700
|
return null;
|
|
78334
78701
|
}
|
|
78335
|
-
function isWordChar(char) {
|
|
78702
|
+
function isWordChar$2(char) {
|
|
78336
78703
|
return /[\p{L}\p{N}_]/u.test(char);
|
|
78337
78704
|
}
|
|
78338
78705
|
function isWhitespace(char) {
|
|
@@ -78367,6 +78734,29 @@ function fontString(run2) {
|
|
|
78367
78734
|
function runText(run2) {
|
|
78368
78735
|
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
78369
78736
|
}
|
|
78737
|
+
const isWordChar$1 = (char) => {
|
|
78738
|
+
if (!char) return false;
|
|
78739
|
+
const code = char.charCodeAt(0);
|
|
78740
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
78741
|
+
};
|
|
78742
|
+
const capitalizeText$1 = (text, fullText, startOffset) => {
|
|
78743
|
+
if (!text) return text;
|
|
78744
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
78745
|
+
let result = "";
|
|
78746
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
78747
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
78748
|
+
const ch = text[i];
|
|
78749
|
+
result += isWordChar$1(ch) && !isWordChar$1(prevChar) ? ch.toUpperCase() : ch;
|
|
78750
|
+
}
|
|
78751
|
+
return result;
|
|
78752
|
+
};
|
|
78753
|
+
const applyTextTransform$1 = (text, transform, fullText, startOffset) => {
|
|
78754
|
+
if (!text || !transform || transform === "none") return text;
|
|
78755
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
78756
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
78757
|
+
if (transform === "capitalize") return capitalizeText$1(text, fullText, startOffset);
|
|
78758
|
+
return text;
|
|
78759
|
+
};
|
|
78370
78760
|
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
78371
78761
|
const TWIPS_PER_INCH$4 = 1440;
|
|
78372
78762
|
const PX_PER_INCH$3 = 96;
|
|
@@ -78375,6 +78765,13 @@ const TAB_EPSILON$1 = 0.1;
|
|
|
78375
78765
|
const WIDTH_FUDGE_PX = 0.5;
|
|
78376
78766
|
const twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$1;
|
|
78377
78767
|
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
78768
|
+
const markerFontString = (run2) => {
|
|
78769
|
+
const size2 = run2?.fontSize ?? 16;
|
|
78770
|
+
const family = run2?.fontFamily ?? "Arial";
|
|
78771
|
+
const italic = run2?.italic ? "italic " : "";
|
|
78772
|
+
const bold = run2?.bold ? "bold " : "";
|
|
78773
|
+
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
78774
|
+
};
|
|
78378
78775
|
const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
|
|
78379
78776
|
const paragraphIndentTwips = {
|
|
78380
78777
|
left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
|
|
@@ -78405,7 +78802,9 @@ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
|
|
|
78405
78802
|
};
|
|
78406
78803
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
78407
78804
|
const context = getCtx();
|
|
78408
|
-
const
|
|
78805
|
+
const fullText = runText(run2);
|
|
78806
|
+
const transform = isTextRun$2(run2) ? run2.textTransform : void 0;
|
|
78807
|
+
const text = applyTextTransform$1(fullText.slice(fromChar, toChar), transform, fullText, fromChar);
|
|
78409
78808
|
if (!context) {
|
|
78410
78809
|
const textRun = isTextRun$2(run2) ? run2 : null;
|
|
78411
78810
|
const size2 = textRun?.fontSize ?? 16;
|
|
@@ -78451,8 +78850,21 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
78451
78850
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
78452
78851
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
78453
78852
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
78454
|
-
const
|
|
78455
|
-
|
|
78853
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
78854
|
+
wordLayout,
|
|
78855
|
+
indentLeft,
|
|
78856
|
+
indentFirstLine,
|
|
78857
|
+
indentHanging,
|
|
78858
|
+
(markerText, marker) => {
|
|
78859
|
+
const context = getCtx();
|
|
78860
|
+
if (!context) return 0;
|
|
78861
|
+
context.font = markerFontString(marker.run);
|
|
78862
|
+
return context.measureText(markerText).width;
|
|
78863
|
+
}
|
|
78864
|
+
);
|
|
78865
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
78866
|
+
const treatAsHanging = !wordLayout?.marker && effectiveTextStartPx && indentLeft === 0 && indentHanging === 0;
|
|
78867
|
+
const firstLineWidth = typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - effectiveTextStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
78456
78868
|
const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
78457
78869
|
let currentRun = 0;
|
|
78458
78870
|
let currentChar = 0;
|
|
@@ -78992,7 +79404,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
78992
79404
|
if (dirty.deletedBlockIds.length > 0) {
|
|
78993
79405
|
measureCache.invalidate(dirty.deletedBlockIds);
|
|
78994
79406
|
}
|
|
78995
|
-
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options);
|
|
79407
|
+
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options, nextBlocks);
|
|
78996
79408
|
if (measurementWidth <= 0 || measurementHeight <= 0) {
|
|
78997
79409
|
throw new Error("incrementalLayout: invalid measurement constraints resolved from options");
|
|
78998
79410
|
}
|
|
@@ -79261,7 +79673,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
79261
79673
|
const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
|
|
79262
79674
|
const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
79263
79675
|
const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
|
|
79264
|
-
function resolveMeasurementConstraints(options) {
|
|
79676
|
+
function resolveMeasurementConstraints(options, blocks) {
|
|
79265
79677
|
const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
|
|
79266
79678
|
const margins = {
|
|
79267
79679
|
top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
|
|
@@ -79269,23 +79681,41 @@ function resolveMeasurementConstraints(options) {
|
|
|
79269
79681
|
bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
|
|
79270
79682
|
left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
|
|
79271
79683
|
};
|
|
79272
|
-
const
|
|
79273
|
-
const
|
|
79274
|
-
const
|
|
79275
|
-
|
|
79684
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
79685
|
+
const baseContentHeight = pageSize.h - (margins.top + margins.bottom);
|
|
79686
|
+
const computeColumnWidth = (contentWidth, columns) => {
|
|
79687
|
+
if (!columns || columns.count <= 1) return contentWidth;
|
|
79276
79688
|
const gap = Math.max(0, columns.gap ?? 0);
|
|
79277
79689
|
const totalGap = gap * (columns.count - 1);
|
|
79278
|
-
|
|
79279
|
-
|
|
79280
|
-
|
|
79281
|
-
|
|
79282
|
-
|
|
79690
|
+
return (contentWidth - totalGap) / columns.count;
|
|
79691
|
+
};
|
|
79692
|
+
let measurementWidth = computeColumnWidth(baseContentWidth, options.columns);
|
|
79693
|
+
let measurementHeight = baseContentHeight;
|
|
79694
|
+
if (blocks && blocks.length > 0) {
|
|
79695
|
+
for (const block of blocks) {
|
|
79696
|
+
if (block.kind !== "sectionBreak") continue;
|
|
79697
|
+
const sectionPageSize = block.pageSize ?? pageSize;
|
|
79698
|
+
const sectionMargins = {
|
|
79699
|
+
top: normalizeMargin(block.margins?.top, margins.top),
|
|
79700
|
+
right: normalizeMargin(block.margins?.right, margins.right),
|
|
79701
|
+
bottom: normalizeMargin(block.margins?.bottom, margins.bottom),
|
|
79702
|
+
left: normalizeMargin(block.margins?.left, margins.left)
|
|
79283
79703
|
};
|
|
79704
|
+
const contentWidth = sectionPageSize.w - (sectionMargins.left + sectionMargins.right);
|
|
79705
|
+
const contentHeight = sectionPageSize.h - (sectionMargins.top + sectionMargins.bottom);
|
|
79706
|
+
if (contentWidth <= 0 || contentHeight <= 0) continue;
|
|
79707
|
+
const columnWidth = computeColumnWidth(contentWidth, block.columns ?? options.columns);
|
|
79708
|
+
if (columnWidth > measurementWidth) {
|
|
79709
|
+
measurementWidth = columnWidth;
|
|
79710
|
+
}
|
|
79711
|
+
if (contentHeight > measurementHeight) {
|
|
79712
|
+
measurementHeight = contentHeight;
|
|
79713
|
+
}
|
|
79284
79714
|
}
|
|
79285
79715
|
}
|
|
79286
79716
|
return {
|
|
79287
|
-
measurementWidth
|
|
79288
|
-
measurementHeight
|
|
79717
|
+
measurementWidth,
|
|
79718
|
+
measurementHeight
|
|
79289
79719
|
};
|
|
79290
79720
|
}
|
|
79291
79721
|
const serializeHeaderFooterResults = (kind, batch) => {
|
|
@@ -81675,14 +82105,15 @@ function getAtomNodeTypes(schema) {
|
|
|
81675
82105
|
if (!schema) return [];
|
|
81676
82106
|
const types2 = [];
|
|
81677
82107
|
try {
|
|
81678
|
-
schema.nodes
|
|
82108
|
+
for (const name in schema.nodes) {
|
|
81679
82109
|
if (name === "text") {
|
|
81680
|
-
|
|
82110
|
+
continue;
|
|
81681
82111
|
}
|
|
81682
|
-
|
|
82112
|
+
const nodeType = schema.nodes[name];
|
|
82113
|
+
if (nodeType && (nodeType.isAtom || nodeType.isLeaf)) {
|
|
81683
82114
|
types2.push(name);
|
|
81684
82115
|
}
|
|
81685
|
-
}
|
|
82116
|
+
}
|
|
81686
82117
|
} catch {
|
|
81687
82118
|
return [];
|
|
81688
82119
|
}
|
|
@@ -85263,8 +85694,8 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
|
85263
85694
|
}
|
|
85264
85695
|
return void 0;
|
|
85265
85696
|
}
|
|
85266
|
-
const DEFAULT_LIST_HANGING_PX
|
|
85267
|
-
const LIST_MARKER_GAP
|
|
85697
|
+
const DEFAULT_LIST_HANGING_PX = 18;
|
|
85698
|
+
const LIST_MARKER_GAP = 8;
|
|
85268
85699
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
85269
85700
|
const DEFAULT_DECIMAL_PATTERN = "%1.";
|
|
85270
85701
|
const ASCII_UPPERCASE_A = 65;
|
|
@@ -85675,7 +86106,7 @@ function computeWordParagraphLayout(input) {
|
|
|
85675
86106
|
let markerBoxWidthPx;
|
|
85676
86107
|
let markerX;
|
|
85677
86108
|
if (hasFirstLineIndent) {
|
|
85678
|
-
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP
|
|
86109
|
+
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP : DEFAULT_LIST_HANGING_PX;
|
|
85679
86110
|
markerX = indentLeftPx + (firstLinePx ?? 0);
|
|
85680
86111
|
layout.textStartPx = markerX + markerBoxWidthPx;
|
|
85681
86112
|
layout.hangingPx = 0;
|
|
@@ -85775,12 +86206,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
|
|
|
85775
86206
|
let markerBox = Math.max(hangingPxRaw || 0, 0);
|
|
85776
86207
|
if (markerBox <= 0) {
|
|
85777
86208
|
if (glyphWidthPx != null && glyphWidthPx > 0) {
|
|
85778
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86209
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85779
86210
|
} else {
|
|
85780
|
-
markerBox = DEFAULT_LIST_HANGING_PX
|
|
86211
|
+
markerBox = DEFAULT_LIST_HANGING_PX;
|
|
85781
86212
|
}
|
|
85782
|
-
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP
|
|
85783
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86213
|
+
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP > markerBox) {
|
|
86214
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85784
86215
|
}
|
|
85785
86216
|
return markerBox;
|
|
85786
86217
|
};
|
|
@@ -85800,7 +86231,7 @@ const buildMarkerLayout = ({
|
|
|
85800
86231
|
textStartX: textStartPx,
|
|
85801
86232
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
85802
86233
|
// Gutter is the small gap between marker and text, not the full marker box width
|
|
85803
|
-
gutterWidthPx: LIST_MARKER_GAP
|
|
86234
|
+
gutterWidthPx: LIST_MARKER_GAP,
|
|
85804
86235
|
justification: numbering.lvlJc ?? "left",
|
|
85805
86236
|
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
85806
86237
|
run: markerRun,
|
|
@@ -86492,6 +86923,31 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
86492
86923
|
return null;
|
|
86493
86924
|
}
|
|
86494
86925
|
};
|
|
86926
|
+
const normalizeWordLayoutForIndent = (wordLayout, paragraphIndent) => {
|
|
86927
|
+
const resolvedIndent = wordLayout.resolvedIndent ?? paragraphIndent ?? {};
|
|
86928
|
+
const indentLeft = isFiniteNumber(resolvedIndent.left) ? resolvedIndent.left : 0;
|
|
86929
|
+
const firstLine = isFiniteNumber(resolvedIndent.firstLine) ? resolvedIndent.firstLine : 0;
|
|
86930
|
+
const hanging = isFiniteNumber(resolvedIndent.hanging) ? resolvedIndent.hanging : 0;
|
|
86931
|
+
const shouldFirstLineIndentMode = firstLine > 0 && !hanging;
|
|
86932
|
+
if (wordLayout.firstLineIndentMode === true && !shouldFirstLineIndentMode) {
|
|
86933
|
+
wordLayout.firstLineIndentMode = false;
|
|
86934
|
+
}
|
|
86935
|
+
if (wordLayout.firstLineIndentMode === true) {
|
|
86936
|
+
if (isFiniteNumber(wordLayout.textStartPx)) {
|
|
86937
|
+
if (wordLayout.marker && (!isFiniteNumber(wordLayout.marker.textStartX) || wordLayout.marker.textStartX !== wordLayout.textStartPx)) {
|
|
86938
|
+
wordLayout.marker.textStartX = wordLayout.textStartPx;
|
|
86939
|
+
}
|
|
86940
|
+
} else if (wordLayout.marker && isFiniteNumber(wordLayout.marker.textStartX)) {
|
|
86941
|
+
wordLayout.textStartPx = wordLayout.marker.textStartX;
|
|
86942
|
+
}
|
|
86943
|
+
} else {
|
|
86944
|
+
wordLayout.textStartPx = indentLeft;
|
|
86945
|
+
if (wordLayout.marker) {
|
|
86946
|
+
wordLayout.marker.textStartX = indentLeft;
|
|
86947
|
+
}
|
|
86948
|
+
}
|
|
86949
|
+
return wordLayout;
|
|
86950
|
+
};
|
|
86495
86951
|
const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
|
|
86496
86952
|
const attrs = para.attrs ?? {};
|
|
86497
86953
|
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
@@ -86814,8 +87270,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86814
87270
|
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
86815
87271
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86816
87272
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86817
|
-
const
|
|
86818
|
-
|
|
87273
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87274
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87275
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87276
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87277
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86819
87278
|
wordLayout = {
|
|
86820
87279
|
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
86821
87280
|
firstLineIndentMode: true,
|
|
@@ -86823,10 +87282,13 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86823
87282
|
};
|
|
86824
87283
|
}
|
|
86825
87284
|
}
|
|
86826
|
-
if (wordLayout &&
|
|
87285
|
+
if (wordLayout && !Number.isFinite(wordLayout.textStartPx) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86827
87286
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86828
|
-
const
|
|
86829
|
-
|
|
87287
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87288
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87289
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87290
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87291
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86830
87292
|
wordLayout = {
|
|
86831
87293
|
...wordLayout,
|
|
86832
87294
|
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
@@ -86846,6 +87308,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86846
87308
|
wordLayout.marker.suffix = listRendering.suffix;
|
|
86847
87309
|
}
|
|
86848
87310
|
}
|
|
87311
|
+
wordLayout = normalizeWordLayoutForIndent(wordLayout, paragraphAttrs.indent);
|
|
86849
87312
|
paragraphAttrs.wordLayout = wordLayout;
|
|
86850
87313
|
}
|
|
86851
87314
|
if (enrichedNumberingProps.resolvedLevelIndent) {
|
|
@@ -90962,11 +91425,6 @@ function initHeaderFooterRegistry({
|
|
|
90962
91425
|
cleanups
|
|
90963
91426
|
};
|
|
90964
91427
|
}
|
|
90965
|
-
const LIST_MARKER_GAP = 8;
|
|
90966
|
-
const MIN_MARKER_GUTTER = 24;
|
|
90967
|
-
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
90968
|
-
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
90969
|
-
const DEFAULT_LIST_HANGING_PX = 18;
|
|
90970
91428
|
function calculateRotatedBounds(input) {
|
|
90971
91429
|
const width = Math.max(0, input.width);
|
|
90972
91430
|
const height = Math.max(0, input.height);
|
|
@@ -91230,8 +91688,25 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91230
91688
|
const rawTextStartPx = wordLayout?.textStartPx;
|
|
91231
91689
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
91232
91690
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof rawTextStartPx === "number" && Number.isFinite(rawTextStartPx) ? rawTextStartPx : void 0;
|
|
91233
|
-
|
|
91234
|
-
|
|
91691
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
91692
|
+
wordLayout,
|
|
91693
|
+
indentLeft,
|
|
91694
|
+
firstLine,
|
|
91695
|
+
hanging,
|
|
91696
|
+
(markerText, marker) => {
|
|
91697
|
+
const markerRun = {
|
|
91698
|
+
fontFamily: toCssFontFamily(marker.run?.fontFamily) ?? marker.run?.fontFamily ?? "Arial",
|
|
91699
|
+
fontSize: marker.run?.fontSize ?? 16,
|
|
91700
|
+
bold: marker.run?.bold ?? false,
|
|
91701
|
+
italic: marker.run?.italic ?? false
|
|
91702
|
+
};
|
|
91703
|
+
const { font: markerFont } = buildFontString(markerRun);
|
|
91704
|
+
return measureText(markerText, markerFont, ctx2);
|
|
91705
|
+
}
|
|
91706
|
+
);
|
|
91707
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
91708
|
+
if (typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft) {
|
|
91709
|
+
initialAvailableWidth = Math.max(1, maxWidth - effectiveTextStartPx - indentRight);
|
|
91235
91710
|
} else {
|
|
91236
91711
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
91237
91712
|
}
|
|
@@ -91318,7 +91793,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91318
91793
|
pendingTabAlignment = null;
|
|
91319
91794
|
return startX;
|
|
91320
91795
|
};
|
|
91321
|
-
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
91796
|
+
const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
|
|
91322
91797
|
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
91323
91798
|
const { val } = pendingTabAlignment;
|
|
91324
91799
|
let segmentWidth = 0;
|
|
@@ -91327,11 +91802,11 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91327
91802
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
91328
91803
|
if (idx >= 0) {
|
|
91329
91804
|
const beforeText = segmentText.slice(0, idx);
|
|
91330
|
-
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
91805
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91331
91806
|
}
|
|
91332
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91807
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91333
91808
|
} else if (val === "end" || val === "center") {
|
|
91334
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91809
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91335
91810
|
}
|
|
91336
91811
|
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
91337
91812
|
};
|
|
@@ -91383,8 +91858,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91383
91858
|
const { font } = buildFontString(
|
|
91384
91859
|
lastRun
|
|
91385
91860
|
);
|
|
91386
|
-
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun);
|
|
91387
|
-
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun) : 0;
|
|
91861
|
+
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun, sliceStart);
|
|
91862
|
+
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun, sliceStart) : 0;
|
|
91388
91863
|
const delta = Math.max(0, fullWidth - keptWidth);
|
|
91389
91864
|
lineToTrim.width = roundValue(Math.max(0, lineToTrim.width - delta));
|
|
91390
91865
|
lineToTrim.spaceCount = Math.max(0, lineToTrim.spaceCount - trimCount);
|
|
@@ -91595,7 +92070,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91595
92070
|
continue;
|
|
91596
92071
|
}
|
|
91597
92072
|
if (isFieldAnnotationRun(run2)) {
|
|
91598
|
-
const
|
|
92073
|
+
const rawDisplayText = run2.displayLabel || "";
|
|
92074
|
+
const displayText = applyTextTransform(rawDisplayText, run2);
|
|
91599
92075
|
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;
|
|
91600
92076
|
const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
|
|
91601
92077
|
const fontWeight = run2.bold ? "bold" : "normal";
|
|
@@ -91698,7 +92174,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91698
92174
|
const spacesLength = segment.length;
|
|
91699
92175
|
const spacesStartChar = charPosInRun;
|
|
91700
92176
|
const spacesEndChar = charPosInRun + spacesLength;
|
|
91701
|
-
const spacesWidth = measureRunWidth(segment, font, ctx2, run2);
|
|
92177
|
+
const spacesWidth = measureRunWidth(segment, font, ctx2, run2, spacesStartChar);
|
|
91702
92178
|
if (!currentLine) {
|
|
91703
92179
|
currentLine = {
|
|
91704
92180
|
fromRun: runIndex,
|
|
@@ -91762,7 +92238,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91762
92238
|
}
|
|
91763
92239
|
let segmentStartX;
|
|
91764
92240
|
if (currentLine && pendingTabAlignment) {
|
|
91765
|
-
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
92241
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2, charPosInRun);
|
|
91766
92242
|
if (segmentStartX == null) {
|
|
91767
92243
|
segmentStartX = currentLine.width;
|
|
91768
92244
|
}
|
|
@@ -91772,7 +92248,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91772
92248
|
if (word2 === "") {
|
|
91773
92249
|
const spaceStartChar = charPosInRun;
|
|
91774
92250
|
const spaceEndChar = charPosInRun + 1;
|
|
91775
|
-
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2);
|
|
92251
|
+
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2, spaceStartChar);
|
|
91776
92252
|
if (!currentLine) {
|
|
91777
92253
|
currentLine = {
|
|
91778
92254
|
fromRun: runIndex,
|
|
@@ -91823,12 +92299,12 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91823
92299
|
charPosInRun = spaceEndChar;
|
|
91824
92300
|
continue;
|
|
91825
92301
|
}
|
|
91826
|
-
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2);
|
|
91827
|
-
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91828
|
-
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2) : 0;
|
|
91829
|
-
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91830
92302
|
const wordStartChar = charPosInRun;
|
|
92303
|
+
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2, wordStartChar);
|
|
92304
|
+
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91831
92305
|
const wordEndNoSpace = charPosInRun + word2.length;
|
|
92306
|
+
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) : 0;
|
|
92307
|
+
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91832
92308
|
const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
|
|
91833
92309
|
const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
|
|
91834
92310
|
if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
|
|
@@ -91847,7 +92323,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91847
92323
|
const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
91848
92324
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
91849
92325
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
91850
|
-
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
|
|
92326
|
+
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2, wordStartChar);
|
|
91851
92327
|
let chunkCharOffset = wordStartChar;
|
|
91852
92328
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
91853
92329
|
const chunk = chunks[chunkIndex];
|
|
@@ -91971,7 +92447,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91971
92447
|
if (candidateSpaces > 0) {
|
|
91972
92448
|
const overflow = totalWidthWithWord - availableWidth;
|
|
91973
92449
|
if (overflow > 0) {
|
|
91974
|
-
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2) || Math.max(1, boundarySpacing);
|
|
92450
|
+
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) || Math.max(1, boundarySpacing);
|
|
91975
92451
|
const perSpaceCompression = overflow / candidateSpaces;
|
|
91976
92452
|
const maxPerSpaceCompression = baseSpaceWidth * 0.25;
|
|
91977
92453
|
if (perSpaceCompression <= maxPerSpaceCompression) {
|
|
@@ -92146,8 +92622,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
92146
92622
|
const { font: markerFont } = buildFontString(markerRun);
|
|
92147
92623
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
92148
92624
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92149
|
-
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
92150
|
-
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
|
|
92625
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
92626
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP$1);
|
|
92151
92627
|
markerInfo = {
|
|
92152
92628
|
markerWidth: markerBoxWidth,
|
|
92153
92629
|
markerTextWidth: glyphWidth,
|
|
@@ -92491,7 +92967,7 @@ async function measureListBlock(block, constraints) {
|
|
|
92491
92967
|
markerTextWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92492
92968
|
indentLeft = resolveIndentLeft(item);
|
|
92493
92969
|
const indentHanging = resolveIndentHanging(item);
|
|
92494
|
-
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP, indentHanging);
|
|
92970
|
+
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP$1, indentHanging);
|
|
92495
92971
|
}
|
|
92496
92972
|
const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
|
|
92497
92973
|
const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
|
|
@@ -92517,16 +92993,46 @@ const getPrimaryRun = (paragraph) => {
|
|
|
92517
92993
|
fontSize: 16
|
|
92518
92994
|
};
|
|
92519
92995
|
};
|
|
92520
|
-
const
|
|
92996
|
+
const isWordChar = (char) => {
|
|
92997
|
+
if (!char) return false;
|
|
92998
|
+
const code = char.charCodeAt(0);
|
|
92999
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
93000
|
+
};
|
|
93001
|
+
const capitalizeText = (text, fullText, startOffset) => {
|
|
93002
|
+
if (!text) return text;
|
|
93003
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
93004
|
+
let result = "";
|
|
93005
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
93006
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
93007
|
+
const ch = text[i];
|
|
93008
|
+
result += isWordChar(ch) && !isWordChar(prevChar) ? ch.toUpperCase() : ch;
|
|
93009
|
+
}
|
|
93010
|
+
return result;
|
|
93011
|
+
};
|
|
93012
|
+
const applyTextTransform = (text, run2, startOffset) => {
|
|
93013
|
+
const transform = "textTransform" in run2 ? run2.textTransform : void 0;
|
|
93014
|
+
if (!text || !transform || transform === "none") return text;
|
|
93015
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
93016
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
93017
|
+
if (transform === "capitalize") {
|
|
93018
|
+
const fullText = "text" in run2 && typeof run2.text === "string" ? run2.text : text;
|
|
93019
|
+
return capitalizeText(text, fullText, startOffset);
|
|
93020
|
+
}
|
|
93021
|
+
return text;
|
|
93022
|
+
};
|
|
93023
|
+
const measureRunWidth = (text, font, ctx2, run2, startOffset) => {
|
|
92521
93024
|
const letterSpacing = run2.kind === "text" || run2.kind === void 0 ? run2.letterSpacing || 0 : 0;
|
|
92522
|
-
const
|
|
93025
|
+
const displayText = applyTextTransform(text, run2, startOffset);
|
|
93026
|
+
const width = getMeasuredTextWidth(displayText, font, letterSpacing, ctx2);
|
|
92523
93027
|
return roundValue(width);
|
|
92524
93028
|
};
|
|
92525
|
-
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
93029
|
+
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2, startOffset) => {
|
|
92526
93030
|
const chunks = [];
|
|
93031
|
+
const baseOffset = typeof startOffset === "number" ? startOffset : 0;
|
|
92527
93032
|
if (maxWidth <= 0) {
|
|
92528
|
-
for (
|
|
92529
|
-
const
|
|
93033
|
+
for (let i = 0; i < word2.length; i++) {
|
|
93034
|
+
const char = word2[i];
|
|
93035
|
+
const charWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92530
93036
|
chunks.push({ text: char, width: charWidth });
|
|
92531
93037
|
}
|
|
92532
93038
|
return chunks;
|
|
@@ -92536,11 +93042,11 @@ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
|
92536
93042
|
for (let i = 0; i < word2.length; i++) {
|
|
92537
93043
|
const char = word2[i];
|
|
92538
93044
|
const testChunk = currentChunk + char;
|
|
92539
|
-
const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
|
|
93045
|
+
const testWidth = measureRunWidth(testChunk, font, ctx2, run2, baseOffset);
|
|
92540
93046
|
if (testWidth > maxWidth && currentChunk.length > 0) {
|
|
92541
93047
|
chunks.push({ text: currentChunk, width: currentWidth });
|
|
92542
93048
|
currentChunk = char;
|
|
92543
|
-
currentWidth = measureRunWidth(char, font, ctx2, run2);
|
|
93049
|
+
currentWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92544
93050
|
} else {
|
|
92545
93051
|
currentChunk = testChunk;
|
|
92546
93052
|
currentWidth = testWidth;
|
|
@@ -92594,7 +93100,8 @@ const measureDropCap = (ctx2, descriptor, spacing) => {
|
|
|
92594
93100
|
italic: run2.italic
|
|
92595
93101
|
});
|
|
92596
93102
|
ctx2.font = font;
|
|
92597
|
-
const
|
|
93103
|
+
const displayText = applyTextTransform(run2.text, run2);
|
|
93104
|
+
const metrics = ctx2.measureText(displayText);
|
|
92598
93105
|
const advanceWidth = metrics.width;
|
|
92599
93106
|
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
92600
93107
|
const textWidth = Math.max(advanceWidth, paintedWidth);
|
|
@@ -92620,7 +93127,7 @@ const resolveIndentHanging = (item) => {
|
|
|
92620
93127
|
if (indentHanging > 0) {
|
|
92621
93128
|
return indentHanging;
|
|
92622
93129
|
}
|
|
92623
|
-
return DEFAULT_LIST_HANGING_PX;
|
|
93130
|
+
return DEFAULT_LIST_HANGING_PX$1;
|
|
92624
93131
|
};
|
|
92625
93132
|
const buildTabStopsPx = (indent, tabs, tabIntervalTwips) => {
|
|
92626
93133
|
const paragraphIndentTwips = {
|