@harbour-enterprises/superdoc 2.0.0-next.2 → 2.0.0-next.3
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-4xn9rggA.es.js} +1 -1
- package/dist/chunks/{PdfViewer-CWO98Qls.cjs → PdfViewer-C6tuSJXA.cjs} +1 -1
- package/dist/chunks/{index-s9GUR_Gc.es.js → index-CSZ7bAL7.es.js} +3 -3
- package/dist/chunks/{index-BY-3Vl72.cjs → index-k0xTe_8v.cjs} +3 -3
- package/dist/chunks/{index-BqPa6D4q-Dulj8zfc.cjs → index-lLnrqNSJ-CMJxa5vJ.cjs} +1 -1
- package/dist/chunks/{index-BqPa6D4q-8U4x8RP6.es.js → index-lLnrqNSJ-DoACeFqL.es.js} +1 -1
- package/dist/chunks/{super-editor.es-CT28vUbx.es.js → super-editor.es-B1DZfUz0.es.js} +537 -130
- package/dist/chunks/{super-editor.es-BM-ulSRj.cjs → super-editor.es-BY4paJvP.cjs} +537 -130
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-CDlAWcRu.js → converter-Bd6dIe0l.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-B2VXuf8h.js → docx-zipper-Dzdi5pfi.js} +1 -1
- package/dist/super-editor/chunks/{editor-B4Q_tNET.js → editor-C3sjGwAb.js} +538 -131
- package/dist/super-editor/chunks/{index-BqPa6D4q.js → index-lLnrqNSJ.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-BD-lDCLr.js → toolbar-Bn20lflQ.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 +539 -132
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -42427,7 +42427,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42427
42427
|
static getStoredSuperdocVersion(docx) {
|
|
42428
42428
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42429
42429
|
}
|
|
42430
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.
|
|
42430
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.3") {
|
|
42431
42431
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42432
42432
|
}
|
|
42433
42433
|
/**
|
|
@@ -60508,7 +60508,7 @@ const isHeadless = (editor) => {
|
|
|
60508
60508
|
const shouldSkipNodeView = (editor) => {
|
|
60509
60509
|
return isHeadless(editor);
|
|
60510
60510
|
};
|
|
60511
|
-
const summaryVersion = "2.0.0-next.
|
|
60511
|
+
const summaryVersion = "2.0.0-next.3";
|
|
60512
60512
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
60513
60513
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
60514
60514
|
function mapAttributes(attrs) {
|
|
@@ -61297,7 +61297,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
61297
61297
|
{ default: remarkStringify },
|
|
61298
61298
|
{ default: remarkGfm }
|
|
61299
61299
|
] = await Promise.all([
|
|
61300
|
-
Promise.resolve().then(() => require("./index-
|
|
61300
|
+
Promise.resolve().then(() => require("./index-lLnrqNSJ-CMJxa5vJ.cjs")),
|
|
61301
61301
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
61302
61302
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
61303
61303
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -61502,7 +61502,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
61502
61502
|
* Process collaboration migrations
|
|
61503
61503
|
*/
|
|
61504
61504
|
processCollaborationMigrations() {
|
|
61505
|
-
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.
|
|
61505
|
+
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.3");
|
|
61506
61506
|
if (!this.options.ydoc) return;
|
|
61507
61507
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
61508
61508
|
let docVersion = metaMap.get("version");
|
|
@@ -68754,7 +68754,7 @@ function isMinimalWordLayout(value) {
|
|
|
68754
68754
|
return true;
|
|
68755
68755
|
}
|
|
68756
68756
|
const LIST_MARKER_GAP$2 = 8;
|
|
68757
|
-
const DEFAULT_TAB_INTERVAL_PX$
|
|
68757
|
+
const DEFAULT_TAB_INTERVAL_PX$2 = 48;
|
|
68758
68758
|
const DEFAULT_PAGE_HEIGHT_PX = 1056;
|
|
68759
68759
|
const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
|
|
68760
68760
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
@@ -69681,6 +69681,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69681
69681
|
const block = lookup2.block;
|
|
69682
69682
|
const measure = lookup2.measure;
|
|
69683
69683
|
const wordLayout = isMinimalWordLayout(block.attrs?.wordLayout) ? block.attrs.wordLayout : void 0;
|
|
69684
|
+
const alignment2 = block.attrs?.alignment;
|
|
69684
69685
|
const fragmentEl = this.doc.createElement("div");
|
|
69685
69686
|
fragmentEl.classList.add(CLASS_NAMES$1.fragment);
|
|
69686
69687
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
@@ -69759,7 +69760,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69759
69760
|
const textStart = paraIndentLeft + firstLine;
|
|
69760
69761
|
tabWidth = textStart - currentPos;
|
|
69761
69762
|
if (tabWidth <= 0) {
|
|
69762
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
69763
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
69763
69764
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
69764
69765
|
tabWidth = LIST_MARKER_GAP$2;
|
|
69765
69766
|
}
|
|
@@ -69786,6 +69787,21 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69786
69787
|
let availableWidthOverride = line.maxWidth != null ? Math.min(line.maxWidth, fallbackAvailableWidth) : fallbackAvailableWidth;
|
|
69787
69788
|
if (index2 === 0 && listFirstLineMarkerTabWidth != null) {
|
|
69788
69789
|
availableWidthOverride = fragment.width - listFirstLineMarkerTabWidth - Math.max(0, paraIndentRight);
|
|
69790
|
+
if (alignment2 === "justify" || alignment2 === "both") {
|
|
69791
|
+
console.log(
|
|
69792
|
+
"[justify-debug][painter-firstline-available]",
|
|
69793
|
+
JSON.stringify({
|
|
69794
|
+
blockId: block.id,
|
|
69795
|
+
fragmentWidth: fragment.width,
|
|
69796
|
+
markerTabWidth: listFirstLineMarkerTabWidth,
|
|
69797
|
+
paraIndentRight,
|
|
69798
|
+
availableWidthOverride,
|
|
69799
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
69800
|
+
lineWidth: line.width,
|
|
69801
|
+
lineNaturalWidth: line.naturalWidth ?? null
|
|
69802
|
+
})
|
|
69803
|
+
);
|
|
69804
|
+
}
|
|
69789
69805
|
}
|
|
69790
69806
|
const isLastLineOfFragment = index2 === lines.length - 1;
|
|
69791
69807
|
const isLastLineOfParagraph = isLastLineOfFragment && !fragment.continuesOnNext;
|
|
@@ -69911,7 +69927,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69911
69927
|
const textStart = paraIndentLeft + firstLine;
|
|
69912
69928
|
tabWidth = textStart - currentPos;
|
|
69913
69929
|
if (tabWidth <= 0) {
|
|
69914
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
69930
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
69915
69931
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
69916
69932
|
tabWidth = LIST_MARKER_GAP$2;
|
|
69917
69933
|
}
|
|
@@ -71445,6 +71461,23 @@ const _DomPainter = class _DomPainter2 {
|
|
|
71445
71461
|
if (spacingPerSpace !== 0) {
|
|
71446
71462
|
el.style.wordSpacing = `${spacingPerSpace}px`;
|
|
71447
71463
|
}
|
|
71464
|
+
if (justifyShouldApply && spacingPerSpace < 0) {
|
|
71465
|
+
console.log(
|
|
71466
|
+
"[justify-debug][painter-wordspacing-negative]",
|
|
71467
|
+
JSON.stringify({
|
|
71468
|
+
blockId: block.id,
|
|
71469
|
+
lineIndex: lineIndex ?? null,
|
|
71470
|
+
alignment: alignment2 ?? null,
|
|
71471
|
+
availableWidth,
|
|
71472
|
+
lineWidth,
|
|
71473
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
71474
|
+
lineNaturalWidth: line.naturalWidth ?? null,
|
|
71475
|
+
spaceCount,
|
|
71476
|
+
hasExplicitPositioning: Boolean(hasExplicitPositioning),
|
|
71477
|
+
skipJustify: Boolean(skipJustify)
|
|
71478
|
+
})
|
|
71479
|
+
);
|
|
71480
|
+
}
|
|
71448
71481
|
if (hasExplicitPositioning && line.segments) {
|
|
71449
71482
|
const paraIndent = block.attrs?.indent;
|
|
71450
71483
|
const indentLeft = paraIndent?.left ?? 0;
|
|
@@ -73638,6 +73671,28 @@ let measurementCtx = null;
|
|
|
73638
73671
|
const TAB_CHAR_LENGTH = 1;
|
|
73639
73672
|
const SPACE_CHARS = SPACE_CHARS$1;
|
|
73640
73673
|
const isTabRun$1 = (run2) => run2?.kind === "tab";
|
|
73674
|
+
const isWordChar$3 = (char) => {
|
|
73675
|
+
if (!char) return false;
|
|
73676
|
+
const code = char.charCodeAt(0);
|
|
73677
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
73678
|
+
};
|
|
73679
|
+
const capitalizeText$2 = (text) => {
|
|
73680
|
+
if (!text) return text;
|
|
73681
|
+
let result = "";
|
|
73682
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
73683
|
+
const prevChar = i > 0 ? text[i - 1] : "";
|
|
73684
|
+
const ch = text[i];
|
|
73685
|
+
result += isWordChar$3(ch) && !isWordChar$3(prevChar) ? ch.toUpperCase() : ch;
|
|
73686
|
+
}
|
|
73687
|
+
return result;
|
|
73688
|
+
};
|
|
73689
|
+
const applyTextTransform$2 = (text, transform) => {
|
|
73690
|
+
if (!text || !transform || transform === "none") return text;
|
|
73691
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
73692
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
73693
|
+
if (transform === "capitalize") return capitalizeText$2(text);
|
|
73694
|
+
return text;
|
|
73695
|
+
};
|
|
73641
73696
|
function getMeasurementContext() {
|
|
73642
73697
|
if (measurementCtx) return measurementCtx;
|
|
73643
73698
|
if (typeof document === "undefined") {
|
|
@@ -73813,17 +73868,18 @@ function measureCharacterX(block, line, charOffset, availableWidthOverride, alig
|
|
|
73813
73868
|
}
|
|
73814
73869
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73815
73870
|
const runLength = text.length;
|
|
73871
|
+
const displayText = applyTextTransform$2(text, run2.textTransform);
|
|
73816
73872
|
if (currentCharOffset + runLength >= charOffset) {
|
|
73817
73873
|
const offsetInRun = charOffset - currentCharOffset;
|
|
73818
73874
|
ctx2.font = getRunFontString(run2);
|
|
73819
|
-
const textUpToTarget =
|
|
73875
|
+
const textUpToTarget = displayText.slice(0, offsetInRun);
|
|
73820
73876
|
const measured2 = ctx2.measureText(textUpToTarget);
|
|
73821
73877
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
|
|
73822
|
-
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(
|
|
73878
|
+
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(text.slice(0, offsetInRun)) : 0;
|
|
73823
73879
|
return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73824
73880
|
}
|
|
73825
73881
|
ctx2.font = getRunFontString(run2);
|
|
73826
|
-
const measured = ctx2.measureText(
|
|
73882
|
+
const measured = ctx2.measureText(displayText);
|
|
73827
73883
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73828
73884
|
const spacesInRun = justify.extraPerSpace !== 0 ? countSpaces(text) : 0;
|
|
73829
73885
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -73862,8 +73918,9 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
73862
73918
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
73863
73919
|
}
|
|
73864
73920
|
const text = run2.text ?? "";
|
|
73865
|
-
const
|
|
73866
|
-
const
|
|
73921
|
+
const displayText = applyTextTransform$2(text, run2.textTransform);
|
|
73922
|
+
const displaySegmentText = displayText.slice(segment.fromChar, segment.toChar);
|
|
73923
|
+
const textUpToTarget = displaySegmentText.slice(0, offsetInSegment);
|
|
73867
73924
|
ctx2.font = getRunFontString(run2);
|
|
73868
73925
|
const measured = ctx2.measureText(textUpToTarget);
|
|
73869
73926
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInSegment, segmentChars);
|
|
@@ -73959,12 +74016,13 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73959
74016
|
}
|
|
73960
74017
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73961
74018
|
const runLength = text.length;
|
|
74019
|
+
const displayText = applyTextTransform$2(text, run2.textTransform);
|
|
73962
74020
|
if (runLength === 0) continue;
|
|
73963
74021
|
ctx2.font = getRunFontString(run2);
|
|
73964
74022
|
for (let i = 0; i <= runLength; i++) {
|
|
73965
|
-
const textUpToChar =
|
|
74023
|
+
const textUpToChar = displayText.slice(0, i);
|
|
73966
74024
|
const measured2 = ctx2.measureText(textUpToChar);
|
|
73967
|
-
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(
|
|
74025
|
+
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text.slice(0, i)) : 0;
|
|
73968
74026
|
const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73969
74027
|
if (charX >= safeX) {
|
|
73970
74028
|
if (i === 0) {
|
|
@@ -73974,7 +74032,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73974
74032
|
pmPosition: pmPosition3
|
|
73975
74033
|
};
|
|
73976
74034
|
}
|
|
73977
|
-
const prevText =
|
|
74035
|
+
const prevText = displayText.slice(0, i - 1);
|
|
73978
74036
|
const prevMeasured = ctx2.measureText(prevText);
|
|
73979
74037
|
const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run2, i - 1, runLength);
|
|
73980
74038
|
const distToPrev = Math.abs(safeX - prevX);
|
|
@@ -73987,7 +74045,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73987
74045
|
};
|
|
73988
74046
|
}
|
|
73989
74047
|
}
|
|
73990
|
-
const measured = ctx2.measureText(
|
|
74048
|
+
const measured = ctx2.measureText(displayText);
|
|
73991
74049
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73992
74050
|
const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
|
|
73993
74051
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -74418,6 +74476,83 @@ function findCharIndexAtX(textNode, container, targetX) {
|
|
|
74418
74476
|
}
|
|
74419
74477
|
return index2;
|
|
74420
74478
|
}
|
|
74479
|
+
const LIST_MARKER_GAP$1 = 8;
|
|
74480
|
+
const MIN_MARKER_GUTTER = 24;
|
|
74481
|
+
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
74482
|
+
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
74483
|
+
const DEFAULT_LIST_HANGING_PX$1 = 18;
|
|
74484
|
+
const SPACE_SUFFIX_GAP_PX = 4;
|
|
74485
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
74486
|
+
function resolveListTextStartPx(wordLayout, indentLeft, firstLine, hanging, measureMarkerText) {
|
|
74487
|
+
const marker = wordLayout?.marker;
|
|
74488
|
+
if (!marker) {
|
|
74489
|
+
const textStartPx = wordLayout?.firstLineIndentMode === true && typeof wordLayout.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
74490
|
+
return textStartPx;
|
|
74491
|
+
}
|
|
74492
|
+
const markerBoxWidth = typeof marker.markerBoxWidthPx === "number" && Number.isFinite(marker.markerBoxWidthPx) ? marker.markerBoxWidthPx : 0;
|
|
74493
|
+
let markerTextWidth = typeof marker.glyphWidthPx === "number" && Number.isFinite(marker.glyphWidthPx) ? marker.glyphWidthPx : void 0;
|
|
74494
|
+
if (markerTextWidth == null && marker.markerText) {
|
|
74495
|
+
markerTextWidth = measureMarkerText(marker.markerText, marker);
|
|
74496
|
+
}
|
|
74497
|
+
if (!Number.isFinite(markerTextWidth) || markerTextWidth < 0) {
|
|
74498
|
+
markerTextWidth = markerBoxWidth;
|
|
74499
|
+
}
|
|
74500
|
+
markerTextWidth = Math.max(0, markerTextWidth);
|
|
74501
|
+
let markerStartPos;
|
|
74502
|
+
if (wordLayout?.firstLineIndentMode === true && Number.isFinite(marker.markerX)) {
|
|
74503
|
+
markerStartPos = marker.markerX;
|
|
74504
|
+
} else {
|
|
74505
|
+
markerStartPos = indentLeft - hanging + firstLine;
|
|
74506
|
+
}
|
|
74507
|
+
if (!Number.isFinite(markerStartPos)) {
|
|
74508
|
+
markerStartPos = 0;
|
|
74509
|
+
}
|
|
74510
|
+
const currentPos = markerStartPos + markerTextWidth;
|
|
74511
|
+
const suffix2 = marker.suffix ?? "tab";
|
|
74512
|
+
if (suffix2 === "space") {
|
|
74513
|
+
return markerStartPos + markerTextWidth + SPACE_SUFFIX_GAP_PX;
|
|
74514
|
+
}
|
|
74515
|
+
if (suffix2 === "nothing") {
|
|
74516
|
+
return markerStartPos + markerTextWidth;
|
|
74517
|
+
}
|
|
74518
|
+
const markerJustification = marker.justification ?? "left";
|
|
74519
|
+
if (markerJustification !== "left") {
|
|
74520
|
+
const gutterWidth = typeof marker.gutterWidthPx === "number" && Number.isFinite(marker.gutterWidthPx) && marker.gutterWidthPx > 0 ? marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
74521
|
+
return markerStartPos + markerTextWidth + Math.max(gutterWidth, LIST_MARKER_GAP$1);
|
|
74522
|
+
}
|
|
74523
|
+
if (wordLayout?.firstLineIndentMode === true) {
|
|
74524
|
+
let targetTabStop;
|
|
74525
|
+
if (Array.isArray(wordLayout.tabsPx)) {
|
|
74526
|
+
for (const tab of wordLayout.tabsPx) {
|
|
74527
|
+
if (typeof tab === "number" && tab > currentPos) {
|
|
74528
|
+
targetTabStop = tab;
|
|
74529
|
+
break;
|
|
74530
|
+
}
|
|
74531
|
+
}
|
|
74532
|
+
}
|
|
74533
|
+
const textStartTarget = typeof marker.textStartX === "number" && Number.isFinite(marker.textStartX) ? marker.textStartX : wordLayout.textStartPx;
|
|
74534
|
+
let tabWidth2;
|
|
74535
|
+
if (targetTabStop !== void 0) {
|
|
74536
|
+
tabWidth2 = targetTabStop - currentPos;
|
|
74537
|
+
} else if (textStartTarget !== void 0 && Number.isFinite(textStartTarget) && textStartTarget > currentPos) {
|
|
74538
|
+
tabWidth2 = textStartTarget - currentPos;
|
|
74539
|
+
} else {
|
|
74540
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74541
|
+
}
|
|
74542
|
+
if (tabWidth2 < LIST_MARKER_GAP$1) {
|
|
74543
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74544
|
+
}
|
|
74545
|
+
return markerStartPos + markerTextWidth + tabWidth2;
|
|
74546
|
+
}
|
|
74547
|
+
const textStart = indentLeft + firstLine;
|
|
74548
|
+
let tabWidth = textStart - currentPos;
|
|
74549
|
+
if (tabWidth <= 0) {
|
|
74550
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
74551
|
+
} else if (tabWidth < LIST_MARKER_GAP$1) {
|
|
74552
|
+
tabWidth = LIST_MARKER_GAP$1;
|
|
74553
|
+
}
|
|
74554
|
+
return markerStartPos + markerTextWidth + tabWidth;
|
|
74555
|
+
}
|
|
74421
74556
|
function getWordLayoutConfig(block) {
|
|
74422
74557
|
if (!block || block.kind !== "paragraph") {
|
|
74423
74558
|
return void 0;
|
|
@@ -74450,9 +74585,16 @@ function calculateTextStartIndent(params2) {
|
|
|
74450
74585
|
const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
|
|
74451
74586
|
let indentAdjust = paraIndentLeft;
|
|
74452
74587
|
if (isListItem2 && isFirstLine && isFirstLineIndentMode) {
|
|
74588
|
+
const resolvedTextStart = resolveListTextStartPx(
|
|
74589
|
+
wordLayout,
|
|
74590
|
+
paraIndentLeft,
|
|
74591
|
+
Math.max(firstLineIndent, 0),
|
|
74592
|
+
Math.max(hangingIndent, 0),
|
|
74593
|
+
() => markerWidth
|
|
74594
|
+
// Use provided markerWidth since we don't have canvas access here
|
|
74595
|
+
);
|
|
74453
74596
|
const textStartFallback = paraIndentLeft + Math.max(firstLineIndent, 0) + markerWidth;
|
|
74454
|
-
|
|
74455
|
-
indentAdjust = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : textStartFallback;
|
|
74597
|
+
indentAdjust = typeof resolvedTextStart === "number" && Number.isFinite(resolvedTextStart) ? resolvedTextStart : textStartFallback;
|
|
74456
74598
|
} else if (isFirstLine && !isListItem2) {
|
|
74457
74599
|
indentAdjust += firstLineOffset;
|
|
74458
74600
|
}
|
|
@@ -74608,7 +74750,10 @@ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, opt
|
|
|
74608
74750
|
}
|
|
74609
74751
|
function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
74610
74752
|
const zones = [];
|
|
74611
|
-
|
|
74753
|
+
let currentColumns = columns;
|
|
74754
|
+
let currentMargins = margins;
|
|
74755
|
+
let currentPageWidth = pageWidth;
|
|
74756
|
+
let marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74612
74757
|
return {
|
|
74613
74758
|
registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
74614
74759
|
if (!drawingBlock.anchor?.isAnchored) {
|
|
@@ -74621,7 +74766,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74621
74766
|
}
|
|
74622
74767
|
const objectWidth = measure.width ?? 0;
|
|
74623
74768
|
const objectHeight = measure.height ?? 0;
|
|
74624
|
-
const x2 = computeAnchorX(anchor, columnIndex,
|
|
74769
|
+
const x2 = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
|
|
74625
74770
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74626
74771
|
const zone = {
|
|
74627
74772
|
imageBlockId: drawingBlock.id,
|
|
@@ -74655,7 +74800,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74655
74800
|
}
|
|
74656
74801
|
const tableWidth = measure.totalWidth ?? 0;
|
|
74657
74802
|
const tableHeight = measure.totalHeight ?? 0;
|
|
74658
|
-
const x2 = computeTableAnchorX(anchor, columnIndex,
|
|
74803
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
|
|
74659
74804
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74660
74805
|
const zone = {
|
|
74661
74806
|
imageBlockId: tableBlock.id,
|
|
@@ -74703,7 +74848,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74703
74848
|
}
|
|
74704
74849
|
const leftFloats = [];
|
|
74705
74850
|
const rightFloats = [];
|
|
74706
|
-
const columnOrigin = marginLeft + columnIndex * (
|
|
74851
|
+
const columnOrigin = marginLeft + columnIndex * (currentColumns.width + currentColumns.gap);
|
|
74707
74852
|
const columnCenter = columnOrigin + baseWidth / 2;
|
|
74708
74853
|
for (const zone of wrappingZones) {
|
|
74709
74854
|
if (zone.wrapMode === "left") {
|
|
@@ -74742,6 +74887,22 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74742
74887
|
},
|
|
74743
74888
|
clear() {
|
|
74744
74889
|
zones.length = 0;
|
|
74890
|
+
},
|
|
74891
|
+
/**
|
|
74892
|
+
* Update layout context used for positioning and wrapping (columns, margins, page width).
|
|
74893
|
+
* This method should be called when the layout configuration changes (e.g., section breaks,
|
|
74894
|
+
* column changes, page size changes) to ensure floating objects are positioned and wrapped
|
|
74895
|
+
* correctly relative to the new layout boundaries.
|
|
74896
|
+
*
|
|
74897
|
+
* @param nextColumns - Column layout configuration (width, gap, count)
|
|
74898
|
+
* @param nextMargins - Optional page margins (left, right) in pixels
|
|
74899
|
+
* @param nextPageWidth - Optional total page width in pixels
|
|
74900
|
+
*/
|
|
74901
|
+
setLayoutContext(nextColumns, nextMargins, nextPageWidth) {
|
|
74902
|
+
currentColumns = nextColumns;
|
|
74903
|
+
currentMargins = nextMargins;
|
|
74904
|
+
currentPageWidth = nextPageWidth;
|
|
74905
|
+
marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74745
74906
|
}
|
|
74746
74907
|
};
|
|
74747
74908
|
}
|
|
@@ -74841,7 +75002,14 @@ function computeNextSectionPropsAtBreak(blocks) {
|
|
|
74841
75002
|
const props = {};
|
|
74842
75003
|
if (source.kind !== "sectionBreak") return props;
|
|
74843
75004
|
if (source.margins) {
|
|
74844
|
-
props.margins = {
|
|
75005
|
+
props.margins = {
|
|
75006
|
+
header: source.margins.header,
|
|
75007
|
+
footer: source.margins.footer,
|
|
75008
|
+
top: source.margins.top,
|
|
75009
|
+
right: source.margins.right,
|
|
75010
|
+
bottom: source.margins.bottom,
|
|
75011
|
+
left: source.margins.left
|
|
75012
|
+
};
|
|
74845
75013
|
}
|
|
74846
75014
|
if (source.pageSize) {
|
|
74847
75015
|
props.pageSize = { w: source.pageSize.w, h: source.pageSize.h };
|
|
@@ -74889,20 +75057,36 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74889
75057
|
next.activeOrientation = block.orientation;
|
|
74890
75058
|
next.pendingOrientation = null;
|
|
74891
75059
|
}
|
|
75060
|
+
const headerDistance = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
75061
|
+
const footerDistance = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
75062
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
75063
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
74892
75064
|
if (block.margins?.header !== void 0) {
|
|
74893
|
-
const headerDistance = Math.max(0, block.margins.header);
|
|
74894
75065
|
next.activeHeaderDistance = headerDistance;
|
|
74895
75066
|
next.pendingHeaderDistance = headerDistance;
|
|
74896
|
-
next.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
|
|
74897
|
-
next.pendingTopMargin = next.activeTopMargin;
|
|
74898
75067
|
}
|
|
74899
75068
|
if (block.margins?.footer !== void 0) {
|
|
74900
|
-
const footerDistance = Math.max(0, block.margins.footer);
|
|
74901
75069
|
next.activeFooterDistance = footerDistance;
|
|
74902
75070
|
next.pendingFooterDistance = footerDistance;
|
|
74903
|
-
|
|
75071
|
+
}
|
|
75072
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
75073
|
+
next.activeTopMargin = calcRequiredTopMargin(headerDistance, sectionTop);
|
|
75074
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
75075
|
+
}
|
|
75076
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
75077
|
+
next.activeBottomMargin = calcRequiredBottomMargin(footerDistance, sectionBottom);
|
|
74904
75078
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
74905
75079
|
}
|
|
75080
|
+
if (block.margins?.left !== void 0) {
|
|
75081
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
75082
|
+
next.activeLeftMargin = leftMargin;
|
|
75083
|
+
next.pendingLeftMargin = leftMargin;
|
|
75084
|
+
}
|
|
75085
|
+
if (block.margins?.right !== void 0) {
|
|
75086
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
75087
|
+
next.activeRightMargin = rightMargin;
|
|
75088
|
+
next.pendingRightMargin = rightMargin;
|
|
75089
|
+
}
|
|
74906
75090
|
if (block.columns) {
|
|
74907
75091
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
74908
75092
|
next.pendingColumns = null;
|
|
@@ -74911,26 +75095,42 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74911
75095
|
}
|
|
74912
75096
|
const headerPx = block.margins?.header;
|
|
74913
75097
|
const footerPx = block.margins?.footer;
|
|
75098
|
+
const topPx = block.margins?.top;
|
|
75099
|
+
const bottomPx = block.margins?.bottom;
|
|
74914
75100
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
74915
75101
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
75102
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
75103
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
74916
75104
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
74917
75105
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
74918
|
-
if (typeof headerPx === "number") {
|
|
74919
|
-
const newHeaderDist = Math.max(0, headerPx);
|
|
75106
|
+
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
75107
|
+
const newHeaderDist = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
75108
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
74920
75109
|
next.pendingHeaderDistance = newHeaderDist;
|
|
74921
|
-
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist,
|
|
75110
|
+
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, sectionTop);
|
|
74922
75111
|
} else {
|
|
74923
75112
|
next.pendingTopMargin = nextTop;
|
|
74924
75113
|
next.pendingHeaderDistance = nextHeader;
|
|
74925
75114
|
}
|
|
74926
|
-
if (typeof footerPx === "number") {
|
|
74927
|
-
const newFooterDist = Math.max(0, footerPx);
|
|
75115
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
75116
|
+
const newFooterDist = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
75117
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
74928
75118
|
next.pendingFooterDistance = newFooterDist;
|
|
74929
|
-
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist,
|
|
75119
|
+
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, sectionBottom);
|
|
74930
75120
|
} else {
|
|
74931
75121
|
next.pendingBottomMargin = nextBottom;
|
|
74932
75122
|
next.pendingFooterDistance = nextFooter;
|
|
74933
75123
|
}
|
|
75124
|
+
if (typeof block.margins?.left === "number") {
|
|
75125
|
+
next.pendingLeftMargin = Math.max(0, block.margins.left);
|
|
75126
|
+
} else {
|
|
75127
|
+
next.pendingLeftMargin = nextLeft;
|
|
75128
|
+
}
|
|
75129
|
+
if (typeof block.margins?.right === "number") {
|
|
75130
|
+
next.pendingRightMargin = Math.max(0, block.margins.right);
|
|
75131
|
+
} else {
|
|
75132
|
+
next.pendingRightMargin = nextRight;
|
|
75133
|
+
}
|
|
74934
75134
|
if (block.pageSize) {
|
|
74935
75135
|
next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
74936
75136
|
}
|
|
@@ -74990,6 +75190,12 @@ function applyPendingToActive(state2) {
|
|
|
74990
75190
|
if (next.pendingBottomMargin != null) {
|
|
74991
75191
|
next.activeBottomMargin = next.pendingBottomMargin;
|
|
74992
75192
|
}
|
|
75193
|
+
if (next.pendingLeftMargin != null) {
|
|
75194
|
+
next.activeLeftMargin = next.pendingLeftMargin;
|
|
75195
|
+
}
|
|
75196
|
+
if (next.pendingRightMargin != null) {
|
|
75197
|
+
next.activeRightMargin = next.pendingRightMargin;
|
|
75198
|
+
}
|
|
74993
75199
|
if (next.pendingHeaderDistance != null) {
|
|
74994
75200
|
next.activeHeaderDistance = next.pendingHeaderDistance;
|
|
74995
75201
|
}
|
|
@@ -75007,6 +75213,8 @@ function applyPendingToActive(state2) {
|
|
|
75007
75213
|
}
|
|
75008
75214
|
next.pendingTopMargin = null;
|
|
75009
75215
|
next.pendingBottomMargin = null;
|
|
75216
|
+
next.pendingLeftMargin = null;
|
|
75217
|
+
next.pendingRightMargin = null;
|
|
75010
75218
|
next.pendingHeaderDistance = null;
|
|
75011
75219
|
next.pendingFooterDistance = null;
|
|
75012
75220
|
next.pendingPageSize = null;
|
|
@@ -75235,7 +75443,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75235
75443
|
if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
|
|
75236
75444
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75237
75445
|
const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
|
|
75238
|
-
|
|
75446
|
+
const newLines = normalizeLines(newMeasure);
|
|
75447
|
+
lines = newLines;
|
|
75239
75448
|
didRemeasureForColumnWidth = true;
|
|
75240
75449
|
}
|
|
75241
75450
|
let fromLine = 0;
|
|
@@ -75317,7 +75526,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75317
75526
|
if (narrowestRemeasureWidth < remeasureWidth) {
|
|
75318
75527
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75319
75528
|
const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
|
|
75320
|
-
|
|
75529
|
+
const newLines = normalizeLines(newMeasure);
|
|
75530
|
+
lines = newLines;
|
|
75321
75531
|
didRemeasureForFloats = true;
|
|
75322
75532
|
}
|
|
75323
75533
|
}
|
|
@@ -76474,8 +76684,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76474
76684
|
header: options.margins?.header ?? options.margins?.top ?? DEFAULT_MARGINS$2.top,
|
|
76475
76685
|
footer: options.margins?.footer ?? options.margins?.bottom ?? DEFAULT_MARGINS$2.bottom
|
|
76476
76686
|
};
|
|
76477
|
-
const
|
|
76478
|
-
if (
|
|
76687
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
76688
|
+
if (baseContentWidth <= 0) {
|
|
76479
76689
|
throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
|
|
76480
76690
|
}
|
|
76481
76691
|
const validateContentHeight = (height) => {
|
|
@@ -76505,8 +76715,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76505
76715
|
const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
|
|
76506
76716
|
let activeTopMargin = effectiveTopMargin;
|
|
76507
76717
|
let activeBottomMargin = effectiveBottomMargin;
|
|
76718
|
+
let activeLeftMargin = margins.left;
|
|
76719
|
+
let activeRightMargin = margins.right;
|
|
76508
76720
|
let pendingTopMargin = null;
|
|
76509
76721
|
let pendingBottomMargin = null;
|
|
76722
|
+
let pendingLeftMargin = null;
|
|
76723
|
+
let pendingRightMargin = null;
|
|
76510
76724
|
let activeHeaderDistance = margins.header ?? margins.top;
|
|
76511
76725
|
let pendingHeaderDistance = null;
|
|
76512
76726
|
let activeFooterDistance = margins.footer ?? margins.bottom;
|
|
@@ -76519,10 +76733,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76519
76733
|
let pendingOrientation = null;
|
|
76520
76734
|
let activeVAlign = null;
|
|
76521
76735
|
let pendingVAlign = null;
|
|
76736
|
+
const paginatorMargins = { left: activeLeftMargin, right: activeRightMargin };
|
|
76522
76737
|
const floatManager = createFloatingObjectManager(
|
|
76523
|
-
normalizeColumns(activeColumns,
|
|
76524
|
-
{ left:
|
|
76525
|
-
|
|
76738
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76739
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76740
|
+
activePageSize.w
|
|
76526
76741
|
);
|
|
76527
76742
|
const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks);
|
|
76528
76743
|
const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
|
|
@@ -76539,22 +76754,38 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76539
76754
|
next.activeOrientation = block.orientation;
|
|
76540
76755
|
next.pendingOrientation = null;
|
|
76541
76756
|
}
|
|
76757
|
+
const headerDistance2 = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
76758
|
+
const footerDistance2 = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
76759
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
76760
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
76542
76761
|
if (block.margins?.header !== void 0) {
|
|
76543
|
-
|
|
76544
|
-
next.
|
|
76545
|
-
next.pendingHeaderDistance = headerDist;
|
|
76546
|
-
const requiredTop = maxHeaderContentHeight > 0 ? headerDist + maxHeaderContentHeight : headerDist;
|
|
76547
|
-
next.activeTopMargin = Math.max(baseMargins.top, requiredTop);
|
|
76548
|
-
next.pendingTopMargin = next.activeTopMargin;
|
|
76762
|
+
next.activeHeaderDistance = headerDistance2;
|
|
76763
|
+
next.pendingHeaderDistance = headerDistance2;
|
|
76549
76764
|
}
|
|
76550
76765
|
if (block.margins?.footer !== void 0) {
|
|
76551
|
-
const footerDistance2 = Math.max(0, block.margins.footer);
|
|
76552
76766
|
next.activeFooterDistance = footerDistance2;
|
|
76553
76767
|
next.pendingFooterDistance = footerDistance2;
|
|
76768
|
+
}
|
|
76769
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
76770
|
+
const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : headerDistance2;
|
|
76771
|
+
next.activeTopMargin = Math.max(sectionTop, requiredTop);
|
|
76772
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
76773
|
+
}
|
|
76774
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
76554
76775
|
const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
|
|
76555
|
-
next.activeBottomMargin = Math.max(
|
|
76776
|
+
next.activeBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76556
76777
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
76557
76778
|
}
|
|
76779
|
+
if (block.margins?.left !== void 0) {
|
|
76780
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
76781
|
+
next.activeLeftMargin = leftMargin;
|
|
76782
|
+
next.pendingLeftMargin = leftMargin;
|
|
76783
|
+
}
|
|
76784
|
+
if (block.margins?.right !== void 0) {
|
|
76785
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
76786
|
+
next.activeRightMargin = rightMargin;
|
|
76787
|
+
next.pendingRightMargin = rightMargin;
|
|
76788
|
+
}
|
|
76558
76789
|
if (block.columns) {
|
|
76559
76790
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
76560
76791
|
next.pendingColumns = null;
|
|
@@ -76583,27 +76814,35 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76583
76814
|
const headerPx = block.margins?.header;
|
|
76584
76815
|
const footerPx = block.margins?.footer;
|
|
76585
76816
|
const topPx = block.margins?.top;
|
|
76817
|
+
const bottomPx = block.margins?.bottom;
|
|
76818
|
+
const leftPx = block.margins?.left;
|
|
76819
|
+
const rightPx = block.margins?.right;
|
|
76586
76820
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
76587
76821
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
76822
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
76823
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
76588
76824
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
76589
76825
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
76590
76826
|
next.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
76591
76827
|
next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
76592
76828
|
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
76593
|
-
const sectionTop = topPx
|
|
76829
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
76594
76830
|
const sectionHeader = next.pendingHeaderDistance;
|
|
76595
76831
|
const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
|
|
76596
76832
|
next.pendingTopMargin = Math.max(sectionTop, requiredTop);
|
|
76597
76833
|
} else {
|
|
76598
76834
|
next.pendingTopMargin = nextTop;
|
|
76599
76835
|
}
|
|
76600
|
-
if (typeof footerPx === "number") {
|
|
76836
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
76601
76837
|
const sectionFooter = next.pendingFooterDistance;
|
|
76838
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
76602
76839
|
const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
|
|
76603
|
-
next.pendingBottomMargin = Math.max(
|
|
76840
|
+
next.pendingBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76604
76841
|
} else {
|
|
76605
76842
|
next.pendingBottomMargin = nextBottom;
|
|
76606
76843
|
}
|
|
76844
|
+
next.pendingLeftMargin = typeof leftPx === "number" ? Math.max(0, leftPx) : nextLeft;
|
|
76845
|
+
next.pendingRightMargin = typeof rightPx === "number" ? Math.max(0, rightPx) : nextRight;
|
|
76607
76846
|
if (block.pageSize) next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
76608
76847
|
if (block.orientation) next.pendingOrientation = block.orientation;
|
|
76609
76848
|
const sectionType = block.type ?? "continuous";
|
|
@@ -76688,7 +76927,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76688
76927
|
let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
|
|
76689
76928
|
let pendingSectionIndex = null;
|
|
76690
76929
|
const paginator = createPaginator({
|
|
76691
|
-
margins:
|
|
76930
|
+
margins: paginatorMargins,
|
|
76692
76931
|
getActiveTopMargin: () => activeTopMargin,
|
|
76693
76932
|
getActiveBottomMargin: () => activeBottomMargin,
|
|
76694
76933
|
getActiveHeaderDistance: () => activeHeaderDistance,
|
|
@@ -76703,8 +76942,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76703
76942
|
const applied = applyPendingToActive({
|
|
76704
76943
|
activeTopMargin,
|
|
76705
76944
|
activeBottomMargin,
|
|
76945
|
+
activeLeftMargin,
|
|
76946
|
+
activeRightMargin,
|
|
76706
76947
|
pendingTopMargin,
|
|
76707
76948
|
pendingBottomMargin,
|
|
76949
|
+
pendingLeftMargin,
|
|
76950
|
+
pendingRightMargin,
|
|
76708
76951
|
activeHeaderDistance,
|
|
76709
76952
|
activeFooterDistance,
|
|
76710
76953
|
pendingHeaderDistance,
|
|
@@ -76719,8 +76962,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76719
76962
|
});
|
|
76720
76963
|
activeTopMargin = applied.activeTopMargin;
|
|
76721
76964
|
activeBottomMargin = applied.activeBottomMargin;
|
|
76965
|
+
activeLeftMargin = applied.activeLeftMargin;
|
|
76966
|
+
activeRightMargin = applied.activeRightMargin;
|
|
76722
76967
|
pendingTopMargin = applied.pendingTopMargin;
|
|
76723
76968
|
pendingBottomMargin = applied.pendingBottomMargin;
|
|
76969
|
+
pendingLeftMargin = applied.pendingLeftMargin;
|
|
76970
|
+
pendingRightMargin = applied.pendingRightMargin;
|
|
76724
76971
|
activeHeaderDistance = applied.activeHeaderDistance;
|
|
76725
76972
|
activeFooterDistance = applied.activeFooterDistance;
|
|
76726
76973
|
pendingHeaderDistance = applied.pendingHeaderDistance;
|
|
@@ -76732,6 +76979,14 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76732
76979
|
activeOrientation = applied.activeOrientation;
|
|
76733
76980
|
pendingOrientation = applied.pendingOrientation;
|
|
76734
76981
|
cachedColumnsState.state = null;
|
|
76982
|
+
paginatorMargins.left = activeLeftMargin;
|
|
76983
|
+
paginatorMargins.right = activeRightMargin;
|
|
76984
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
76985
|
+
floatManager.setLayoutContext(
|
|
76986
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
76987
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76988
|
+
activePageSize.w
|
|
76989
|
+
);
|
|
76735
76990
|
if (pendingNumbering) {
|
|
76736
76991
|
if (pendingNumbering.format) activeNumberFormat = pendingNumbering.format;
|
|
76737
76992
|
if (typeof pendingNumbering.start === "number" && Number.isFinite(pendingNumbering.start)) {
|
|
@@ -76776,7 +77031,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76776
77031
|
const getActiveColumnsForState = paginator.getActiveColumnsForState;
|
|
76777
77032
|
let cachedColumnsState = { state: null, constraintIndex: -2, contentWidth: -1, colsConfig: null, normalized: null };
|
|
76778
77033
|
const getCurrentColumns = () => {
|
|
76779
|
-
const currentContentWidth = activePageSize.w - (
|
|
77034
|
+
const currentContentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
76780
77035
|
const state2 = states[states.length - 1] ?? null;
|
|
76781
77036
|
const colsConfig = state2 ? getActiveColumnsForState(state2) : activeColumns;
|
|
76782
77037
|
const constraintIndex = state2 ? state2.activeConstraintIndex : -1;
|
|
@@ -76809,6 +77064,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76809
77064
|
layoutLog(` Current page: ${state2.page.number}, cursorY: ${state2.cursorY}`);
|
|
76810
77065
|
activeColumns = newColumns;
|
|
76811
77066
|
cachedColumnsState.state = null;
|
|
77067
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77068
|
+
floatManager.setLayoutContext(
|
|
77069
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
77070
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
77071
|
+
activePageSize.w
|
|
77072
|
+
);
|
|
76812
77073
|
};
|
|
76813
77074
|
const anchoredByParagraph = collectAnchoredDrawings(blocks, measures);
|
|
76814
77075
|
const anchoredTablesByParagraph = collectAnchoredTables(blocks, measures);
|
|
@@ -76840,10 +77101,10 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76840
77101
|
if (alignV === "top") {
|
|
76841
77102
|
anchorY = offsetV;
|
|
76842
77103
|
} else if (alignV === "bottom") {
|
|
76843
|
-
const pageHeight = contentBottom + margins
|
|
77104
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76844
77105
|
anchorY = pageHeight - imageHeight + offsetV;
|
|
76845
77106
|
} else if (alignV === "center") {
|
|
76846
|
-
const pageHeight = contentBottom + margins
|
|
77107
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76847
77108
|
anchorY = (pageHeight - imageHeight) / 2 + offsetV;
|
|
76848
77109
|
} else {
|
|
76849
77110
|
anchorY = offsetV;
|
|
@@ -76854,11 +77115,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76854
77115
|
const anchorX = entry.block.anchor ? computeAnchorX(
|
|
76855
77116
|
entry.block.anchor,
|
|
76856
77117
|
state2.columnIndex,
|
|
76857
|
-
normalizeColumns(activeColumns,
|
|
77118
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76858
77119
|
entry.measure.width,
|
|
76859
|
-
{ left:
|
|
77120
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76860
77121
|
activePageSize.w
|
|
76861
|
-
) :
|
|
77122
|
+
) : activeLeftMargin;
|
|
76862
77123
|
floatManager.registerDrawing(entry.block, entry.measure, anchorY, state2.columnIndex, state2.page.number);
|
|
76863
77124
|
preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state2.page.number });
|
|
76864
77125
|
}
|
|
@@ -76896,8 +77157,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76896
77157
|
const sectionState = {
|
|
76897
77158
|
activeTopMargin,
|
|
76898
77159
|
activeBottomMargin,
|
|
77160
|
+
activeLeftMargin,
|
|
77161
|
+
activeRightMargin,
|
|
76899
77162
|
pendingTopMargin,
|
|
76900
77163
|
pendingBottomMargin,
|
|
77164
|
+
pendingLeftMargin,
|
|
77165
|
+
pendingRightMargin,
|
|
76901
77166
|
activeHeaderDistance,
|
|
76902
77167
|
activeFooterDistance,
|
|
76903
77168
|
pendingHeaderDistance,
|
|
@@ -76931,8 +77196,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76931
77196
|
layoutLog(`[Layout] ========== END SECTION BREAK ==========`);
|
|
76932
77197
|
activeTopMargin = updatedState.activeTopMargin;
|
|
76933
77198
|
activeBottomMargin = updatedState.activeBottomMargin;
|
|
77199
|
+
activeLeftMargin = updatedState.activeLeftMargin;
|
|
77200
|
+
activeRightMargin = updatedState.activeRightMargin;
|
|
76934
77201
|
pendingTopMargin = updatedState.pendingTopMargin;
|
|
76935
77202
|
pendingBottomMargin = updatedState.pendingBottomMargin;
|
|
77203
|
+
pendingLeftMargin = updatedState.pendingLeftMargin;
|
|
77204
|
+
pendingRightMargin = updatedState.pendingRightMargin;
|
|
76936
77205
|
activeHeaderDistance = updatedState.activeHeaderDistance;
|
|
76937
77206
|
activeFooterDistance = updatedState.activeFooterDistance;
|
|
76938
77207
|
pendingHeaderDistance = updatedState.pendingHeaderDistance;
|
|
@@ -77070,8 +77339,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77070
77339
|
pageMargins: {
|
|
77071
77340
|
top: activeTopMargin,
|
|
77072
77341
|
bottom: activeBottomMargin,
|
|
77073
|
-
left:
|
|
77074
|
-
right:
|
|
77342
|
+
left: activeLeftMargin,
|
|
77343
|
+
right: activeRightMargin
|
|
77075
77344
|
},
|
|
77076
77345
|
columns: getCurrentColumns(),
|
|
77077
77346
|
placedAnchoredIds
|
|
@@ -77093,9 +77362,9 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77093
77362
|
const cols = getCurrentColumns();
|
|
77094
77363
|
let maxWidth;
|
|
77095
77364
|
if (relativeFrom === "page") {
|
|
77096
|
-
maxWidth = cols.count === 1 ? activePageSize.w -
|
|
77365
|
+
maxWidth = cols.count === 1 ? activePageSize.w - (activeLeftMargin + activeRightMargin) : activePageSize.w;
|
|
77097
77366
|
} else if (relativeFrom === "margin") {
|
|
77098
|
-
maxWidth = activePageSize.w -
|
|
77367
|
+
maxWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77099
77368
|
} else {
|
|
77100
77369
|
maxWidth = cols.width;
|
|
77101
77370
|
}
|
|
@@ -78282,11 +78551,11 @@ function findWordBoundaries(blocks, pos) {
|
|
|
78282
78551
|
if (text.length === 0) return null;
|
|
78283
78552
|
const clampedPos = Math.max(0, Math.min(localPos, text.length));
|
|
78284
78553
|
let wordStart = clampedPos;
|
|
78285
|
-
while (wordStart > 0 && isWordChar(text[wordStart - 1])) {
|
|
78554
|
+
while (wordStart > 0 && isWordChar$2(text[wordStart - 1])) {
|
|
78286
78555
|
wordStart--;
|
|
78287
78556
|
}
|
|
78288
78557
|
let wordEnd = clampedPos;
|
|
78289
|
-
while (wordEnd < text.length && isWordChar(text[wordEnd])) {
|
|
78558
|
+
while (wordEnd < text.length && isWordChar$2(text[wordEnd])) {
|
|
78290
78559
|
wordEnd++;
|
|
78291
78560
|
}
|
|
78292
78561
|
if (wordStart === wordEnd) {
|
|
@@ -78349,7 +78618,7 @@ function findBlockAtPosition(blocks, pos) {
|
|
|
78349
78618
|
}
|
|
78350
78619
|
return null;
|
|
78351
78620
|
}
|
|
78352
|
-
function isWordChar(char) {
|
|
78621
|
+
function isWordChar$2(char) {
|
|
78353
78622
|
return /[\p{L}\p{N}_]/u.test(char);
|
|
78354
78623
|
}
|
|
78355
78624
|
function isWhitespace(char) {
|
|
@@ -78384,6 +78653,29 @@ function fontString(run2) {
|
|
|
78384
78653
|
function runText(run2) {
|
|
78385
78654
|
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
78386
78655
|
}
|
|
78656
|
+
const isWordChar$1 = (char) => {
|
|
78657
|
+
if (!char) return false;
|
|
78658
|
+
const code = char.charCodeAt(0);
|
|
78659
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
78660
|
+
};
|
|
78661
|
+
const capitalizeText$1 = (text, fullText, startOffset) => {
|
|
78662
|
+
if (!text) return text;
|
|
78663
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
78664
|
+
let result = "";
|
|
78665
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
78666
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
78667
|
+
const ch = text[i];
|
|
78668
|
+
result += isWordChar$1(ch) && !isWordChar$1(prevChar) ? ch.toUpperCase() : ch;
|
|
78669
|
+
}
|
|
78670
|
+
return result;
|
|
78671
|
+
};
|
|
78672
|
+
const applyTextTransform$1 = (text, transform, fullText, startOffset) => {
|
|
78673
|
+
if (!text || !transform || transform === "none") return text;
|
|
78674
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
78675
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
78676
|
+
if (transform === "capitalize") return capitalizeText$1(text, fullText, startOffset);
|
|
78677
|
+
return text;
|
|
78678
|
+
};
|
|
78387
78679
|
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
78388
78680
|
const TWIPS_PER_INCH$4 = 1440;
|
|
78389
78681
|
const PX_PER_INCH$3 = 96;
|
|
@@ -78392,6 +78684,13 @@ const TAB_EPSILON$1 = 0.1;
|
|
|
78392
78684
|
const WIDTH_FUDGE_PX = 0.5;
|
|
78393
78685
|
const twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$1;
|
|
78394
78686
|
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
78687
|
+
const markerFontString = (run2) => {
|
|
78688
|
+
const size2 = run2?.fontSize ?? 16;
|
|
78689
|
+
const family = run2?.fontFamily ?? "Arial";
|
|
78690
|
+
const italic = run2?.italic ? "italic " : "";
|
|
78691
|
+
const bold = run2?.bold ? "bold " : "";
|
|
78692
|
+
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
78693
|
+
};
|
|
78395
78694
|
const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
|
|
78396
78695
|
const paragraphIndentTwips = {
|
|
78397
78696
|
left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
|
|
@@ -78422,7 +78721,8 @@ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
|
|
|
78422
78721
|
};
|
|
78423
78722
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
78424
78723
|
const context = getCtx();
|
|
78425
|
-
const
|
|
78724
|
+
const fullText = runText(run2);
|
|
78725
|
+
const text = applyTextTransform$1(fullText.slice(fromChar, toChar), run2.textTransform, fullText, fromChar);
|
|
78426
78726
|
if (!context) {
|
|
78427
78727
|
const textRun = isTextRun$2(run2) ? run2 : null;
|
|
78428
78728
|
const size2 = textRun?.fontSize ?? 16;
|
|
@@ -78468,8 +78768,21 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
78468
78768
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
78469
78769
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
78470
78770
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
78471
|
-
const
|
|
78472
|
-
|
|
78771
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
78772
|
+
wordLayout,
|
|
78773
|
+
indentLeft,
|
|
78774
|
+
indentFirstLine,
|
|
78775
|
+
indentHanging,
|
|
78776
|
+
(markerText, marker) => {
|
|
78777
|
+
const context = getCtx();
|
|
78778
|
+
if (!context) return 0;
|
|
78779
|
+
context.font = markerFontString(marker.run);
|
|
78780
|
+
return context.measureText(markerText).width;
|
|
78781
|
+
}
|
|
78782
|
+
);
|
|
78783
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
78784
|
+
const treatAsHanging = !wordLayout?.marker && effectiveTextStartPx && indentLeft === 0 && indentHanging === 0;
|
|
78785
|
+
const firstLineWidth = typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - effectiveTextStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
78473
78786
|
const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
78474
78787
|
let currentRun = 0;
|
|
78475
78788
|
let currentChar = 0;
|
|
@@ -79009,7 +79322,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
79009
79322
|
if (dirty.deletedBlockIds.length > 0) {
|
|
79010
79323
|
measureCache.invalidate(dirty.deletedBlockIds);
|
|
79011
79324
|
}
|
|
79012
|
-
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options);
|
|
79325
|
+
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options, nextBlocks);
|
|
79013
79326
|
if (measurementWidth <= 0 || measurementHeight <= 0) {
|
|
79014
79327
|
throw new Error("incrementalLayout: invalid measurement constraints resolved from options");
|
|
79015
79328
|
}
|
|
@@ -79278,7 +79591,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
79278
79591
|
const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
|
|
79279
79592
|
const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
79280
79593
|
const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
|
|
79281
|
-
function resolveMeasurementConstraints(options) {
|
|
79594
|
+
function resolveMeasurementConstraints(options, blocks) {
|
|
79282
79595
|
const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
|
|
79283
79596
|
const margins = {
|
|
79284
79597
|
top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
|
|
@@ -79286,23 +79599,41 @@ function resolveMeasurementConstraints(options) {
|
|
|
79286
79599
|
bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
|
|
79287
79600
|
left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
|
|
79288
79601
|
};
|
|
79289
|
-
const
|
|
79290
|
-
const
|
|
79291
|
-
const
|
|
79292
|
-
|
|
79602
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
79603
|
+
const baseContentHeight = pageSize.h - (margins.top + margins.bottom);
|
|
79604
|
+
const computeColumnWidth = (contentWidth, columns) => {
|
|
79605
|
+
if (!columns || columns.count <= 1) return contentWidth;
|
|
79293
79606
|
const gap = Math.max(0, columns.gap ?? 0);
|
|
79294
79607
|
const totalGap = gap * (columns.count - 1);
|
|
79295
|
-
|
|
79296
|
-
|
|
79297
|
-
|
|
79298
|
-
|
|
79299
|
-
|
|
79608
|
+
return (contentWidth - totalGap) / columns.count;
|
|
79609
|
+
};
|
|
79610
|
+
let measurementWidth = computeColumnWidth(baseContentWidth, options.columns);
|
|
79611
|
+
let measurementHeight = baseContentHeight;
|
|
79612
|
+
if (blocks && blocks.length > 0) {
|
|
79613
|
+
for (const block of blocks) {
|
|
79614
|
+
if (block.kind !== "sectionBreak") continue;
|
|
79615
|
+
const sectionPageSize = block.pageSize ?? pageSize;
|
|
79616
|
+
const sectionMargins = {
|
|
79617
|
+
top: normalizeMargin(block.margins?.top, margins.top),
|
|
79618
|
+
right: normalizeMargin(block.margins?.right, margins.right),
|
|
79619
|
+
bottom: normalizeMargin(block.margins?.bottom, margins.bottom),
|
|
79620
|
+
left: normalizeMargin(block.margins?.left, margins.left)
|
|
79300
79621
|
};
|
|
79622
|
+
const contentWidth = sectionPageSize.w - (sectionMargins.left + sectionMargins.right);
|
|
79623
|
+
const contentHeight = sectionPageSize.h - (sectionMargins.top + sectionMargins.bottom);
|
|
79624
|
+
if (contentWidth <= 0 || contentHeight <= 0) continue;
|
|
79625
|
+
const columnWidth = computeColumnWidth(contentWidth, block.columns ?? options.columns);
|
|
79626
|
+
if (columnWidth > measurementWidth) {
|
|
79627
|
+
measurementWidth = columnWidth;
|
|
79628
|
+
}
|
|
79629
|
+
if (contentHeight > measurementHeight) {
|
|
79630
|
+
measurementHeight = contentHeight;
|
|
79631
|
+
}
|
|
79301
79632
|
}
|
|
79302
79633
|
}
|
|
79303
79634
|
return {
|
|
79304
|
-
measurementWidth
|
|
79305
|
-
measurementHeight
|
|
79635
|
+
measurementWidth,
|
|
79636
|
+
measurementHeight
|
|
79306
79637
|
};
|
|
79307
79638
|
}
|
|
79308
79639
|
const serializeHeaderFooterResults = (kind, batch) => {
|
|
@@ -85280,8 +85611,8 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
|
85280
85611
|
}
|
|
85281
85612
|
return void 0;
|
|
85282
85613
|
}
|
|
85283
|
-
const DEFAULT_LIST_HANGING_PX
|
|
85284
|
-
const LIST_MARKER_GAP
|
|
85614
|
+
const DEFAULT_LIST_HANGING_PX = 18;
|
|
85615
|
+
const LIST_MARKER_GAP = 8;
|
|
85285
85616
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
85286
85617
|
const DEFAULT_DECIMAL_PATTERN = "%1.";
|
|
85287
85618
|
const ASCII_UPPERCASE_A = 65;
|
|
@@ -85692,7 +86023,7 @@ function computeWordParagraphLayout(input) {
|
|
|
85692
86023
|
let markerBoxWidthPx;
|
|
85693
86024
|
let markerX;
|
|
85694
86025
|
if (hasFirstLineIndent) {
|
|
85695
|
-
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP
|
|
86026
|
+
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP : DEFAULT_LIST_HANGING_PX;
|
|
85696
86027
|
markerX = indentLeftPx + (firstLinePx ?? 0);
|
|
85697
86028
|
layout.textStartPx = markerX + markerBoxWidthPx;
|
|
85698
86029
|
layout.hangingPx = 0;
|
|
@@ -85792,12 +86123,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
|
|
|
85792
86123
|
let markerBox = Math.max(hangingPxRaw || 0, 0);
|
|
85793
86124
|
if (markerBox <= 0) {
|
|
85794
86125
|
if (glyphWidthPx != null && glyphWidthPx > 0) {
|
|
85795
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86126
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85796
86127
|
} else {
|
|
85797
|
-
markerBox = DEFAULT_LIST_HANGING_PX
|
|
86128
|
+
markerBox = DEFAULT_LIST_HANGING_PX;
|
|
85798
86129
|
}
|
|
85799
|
-
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP
|
|
85800
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86130
|
+
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP > markerBox) {
|
|
86131
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85801
86132
|
}
|
|
85802
86133
|
return markerBox;
|
|
85803
86134
|
};
|
|
@@ -85817,7 +86148,7 @@ const buildMarkerLayout = ({
|
|
|
85817
86148
|
textStartX: textStartPx,
|
|
85818
86149
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
85819
86150
|
// Gutter is the small gap between marker and text, not the full marker box width
|
|
85820
|
-
gutterWidthPx: LIST_MARKER_GAP
|
|
86151
|
+
gutterWidthPx: LIST_MARKER_GAP,
|
|
85821
86152
|
justification: numbering.lvlJc ?? "left",
|
|
85822
86153
|
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
85823
86154
|
run: markerRun,
|
|
@@ -86509,6 +86840,31 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
86509
86840
|
return null;
|
|
86510
86841
|
}
|
|
86511
86842
|
};
|
|
86843
|
+
const normalizeWordLayoutForIndent = (wordLayout, paragraphIndent) => {
|
|
86844
|
+
const resolvedIndent = wordLayout.resolvedIndent ?? paragraphIndent ?? {};
|
|
86845
|
+
const indentLeft = isFiniteNumber(resolvedIndent.left) ? resolvedIndent.left : 0;
|
|
86846
|
+
const firstLine = isFiniteNumber(resolvedIndent.firstLine) ? resolvedIndent.firstLine : 0;
|
|
86847
|
+
const hanging = isFiniteNumber(resolvedIndent.hanging) ? resolvedIndent.hanging : 0;
|
|
86848
|
+
const shouldFirstLineIndentMode = firstLine > 0 && !hanging;
|
|
86849
|
+
if (wordLayout.firstLineIndentMode === true && !shouldFirstLineIndentMode) {
|
|
86850
|
+
wordLayout.firstLineIndentMode = false;
|
|
86851
|
+
}
|
|
86852
|
+
if (wordLayout.firstLineIndentMode === true) {
|
|
86853
|
+
if (isFiniteNumber(wordLayout.textStartPx)) {
|
|
86854
|
+
if (wordLayout.marker && (!isFiniteNumber(wordLayout.marker.textStartX) || wordLayout.marker.textStartX !== wordLayout.textStartPx)) {
|
|
86855
|
+
wordLayout.marker.textStartX = wordLayout.textStartPx;
|
|
86856
|
+
}
|
|
86857
|
+
} else if (wordLayout.marker && isFiniteNumber(wordLayout.marker.textStartX)) {
|
|
86858
|
+
wordLayout.textStartPx = wordLayout.marker.textStartX;
|
|
86859
|
+
}
|
|
86860
|
+
} else {
|
|
86861
|
+
wordLayout.textStartPx = indentLeft;
|
|
86862
|
+
if (wordLayout.marker) {
|
|
86863
|
+
wordLayout.marker.textStartX = indentLeft;
|
|
86864
|
+
}
|
|
86865
|
+
}
|
|
86866
|
+
return wordLayout;
|
|
86867
|
+
};
|
|
86512
86868
|
const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
|
|
86513
86869
|
const attrs = para.attrs ?? {};
|
|
86514
86870
|
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
@@ -86831,8 +87187,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86831
87187
|
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
86832
87188
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86833
87189
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86834
|
-
const
|
|
86835
|
-
|
|
87190
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87191
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87192
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87193
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87194
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86836
87195
|
wordLayout = {
|
|
86837
87196
|
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
86838
87197
|
firstLineIndentMode: true,
|
|
@@ -86840,10 +87199,13 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86840
87199
|
};
|
|
86841
87200
|
}
|
|
86842
87201
|
}
|
|
86843
|
-
if (wordLayout &&
|
|
87202
|
+
if (wordLayout && !Number.isFinite(wordLayout.textStartPx) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86844
87203
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86845
|
-
const
|
|
86846
|
-
|
|
87204
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87205
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87206
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87207
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87208
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86847
87209
|
wordLayout = {
|
|
86848
87210
|
...wordLayout,
|
|
86849
87211
|
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
@@ -86863,6 +87225,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86863
87225
|
wordLayout.marker.suffix = listRendering.suffix;
|
|
86864
87226
|
}
|
|
86865
87227
|
}
|
|
87228
|
+
wordLayout = normalizeWordLayoutForIndent(wordLayout, paragraphAttrs.indent);
|
|
86866
87229
|
paragraphAttrs.wordLayout = wordLayout;
|
|
86867
87230
|
}
|
|
86868
87231
|
if (enrichedNumberingProps.resolvedLevelIndent) {
|
|
@@ -90979,11 +91342,6 @@ function initHeaderFooterRegistry({
|
|
|
90979
91342
|
cleanups
|
|
90980
91343
|
};
|
|
90981
91344
|
}
|
|
90982
|
-
const LIST_MARKER_GAP = 8;
|
|
90983
|
-
const MIN_MARKER_GUTTER = 24;
|
|
90984
|
-
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
90985
|
-
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
90986
|
-
const DEFAULT_LIST_HANGING_PX = 18;
|
|
90987
91345
|
function calculateRotatedBounds(input) {
|
|
90988
91346
|
const width = Math.max(0, input.width);
|
|
90989
91347
|
const height = Math.max(0, input.height);
|
|
@@ -91247,8 +91605,25 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91247
91605
|
const rawTextStartPx = wordLayout?.textStartPx;
|
|
91248
91606
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
91249
91607
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof rawTextStartPx === "number" && Number.isFinite(rawTextStartPx) ? rawTextStartPx : void 0;
|
|
91250
|
-
|
|
91251
|
-
|
|
91608
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
91609
|
+
wordLayout,
|
|
91610
|
+
indentLeft,
|
|
91611
|
+
firstLine,
|
|
91612
|
+
hanging,
|
|
91613
|
+
(markerText, marker) => {
|
|
91614
|
+
const markerRun = {
|
|
91615
|
+
fontFamily: toCssFontFamily(marker.run?.fontFamily) ?? marker.run?.fontFamily ?? "Arial",
|
|
91616
|
+
fontSize: marker.run?.fontSize ?? 16,
|
|
91617
|
+
bold: marker.run?.bold ?? false,
|
|
91618
|
+
italic: marker.run?.italic ?? false
|
|
91619
|
+
};
|
|
91620
|
+
const { font: markerFont } = buildFontString(markerRun);
|
|
91621
|
+
return measureText(markerText, markerFont, ctx2);
|
|
91622
|
+
}
|
|
91623
|
+
);
|
|
91624
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
91625
|
+
if (typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft) {
|
|
91626
|
+
initialAvailableWidth = Math.max(1, maxWidth - effectiveTextStartPx - indentRight);
|
|
91252
91627
|
} else {
|
|
91253
91628
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
91254
91629
|
}
|
|
@@ -91335,7 +91710,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91335
91710
|
pendingTabAlignment = null;
|
|
91336
91711
|
return startX;
|
|
91337
91712
|
};
|
|
91338
|
-
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
91713
|
+
const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
|
|
91339
91714
|
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
91340
91715
|
const { val } = pendingTabAlignment;
|
|
91341
91716
|
let segmentWidth = 0;
|
|
@@ -91344,11 +91719,11 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91344
91719
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
91345
91720
|
if (idx >= 0) {
|
|
91346
91721
|
const beforeText = segmentText.slice(0, idx);
|
|
91347
|
-
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
91722
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91348
91723
|
}
|
|
91349
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91724
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91350
91725
|
} else if (val === "end" || val === "center") {
|
|
91351
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91726
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91352
91727
|
}
|
|
91353
91728
|
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
91354
91729
|
};
|
|
@@ -91400,8 +91775,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91400
91775
|
const { font } = buildFontString(
|
|
91401
91776
|
lastRun
|
|
91402
91777
|
);
|
|
91403
|
-
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun);
|
|
91404
|
-
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun) : 0;
|
|
91778
|
+
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun, sliceStart);
|
|
91779
|
+
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun, sliceStart) : 0;
|
|
91405
91780
|
const delta = Math.max(0, fullWidth - keptWidth);
|
|
91406
91781
|
lineToTrim.width = roundValue(Math.max(0, lineToTrim.width - delta));
|
|
91407
91782
|
lineToTrim.spaceCount = Math.max(0, lineToTrim.spaceCount - trimCount);
|
|
@@ -91612,7 +91987,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91612
91987
|
continue;
|
|
91613
91988
|
}
|
|
91614
91989
|
if (isFieldAnnotationRun(run2)) {
|
|
91615
|
-
const
|
|
91990
|
+
const rawDisplayText = run2.displayLabel || "";
|
|
91991
|
+
const displayText = applyTextTransform(rawDisplayText, run2);
|
|
91616
91992
|
const annotationFontSize = typeof run2.fontSize === "number" ? run2.fontSize : typeof run2.fontSize === "string" ? parseFloat(run2.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE : DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
|
|
91617
91993
|
const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
|
|
91618
91994
|
const fontWeight = run2.bold ? "bold" : "normal";
|
|
@@ -91715,7 +92091,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91715
92091
|
const spacesLength = segment.length;
|
|
91716
92092
|
const spacesStartChar = charPosInRun;
|
|
91717
92093
|
const spacesEndChar = charPosInRun + spacesLength;
|
|
91718
|
-
const spacesWidth = measureRunWidth(segment, font, ctx2, run2);
|
|
92094
|
+
const spacesWidth = measureRunWidth(segment, font, ctx2, run2, spacesStartChar);
|
|
91719
92095
|
if (!currentLine) {
|
|
91720
92096
|
currentLine = {
|
|
91721
92097
|
fromRun: runIndex,
|
|
@@ -91779,7 +92155,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91779
92155
|
}
|
|
91780
92156
|
let segmentStartX;
|
|
91781
92157
|
if (currentLine && pendingTabAlignment) {
|
|
91782
|
-
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
92158
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2, charPosInRun);
|
|
91783
92159
|
if (segmentStartX == null) {
|
|
91784
92160
|
segmentStartX = currentLine.width;
|
|
91785
92161
|
}
|
|
@@ -91789,7 +92165,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91789
92165
|
if (word2 === "") {
|
|
91790
92166
|
const spaceStartChar = charPosInRun;
|
|
91791
92167
|
const spaceEndChar = charPosInRun + 1;
|
|
91792
|
-
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2);
|
|
92168
|
+
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2, spaceStartChar);
|
|
91793
92169
|
if (!currentLine) {
|
|
91794
92170
|
currentLine = {
|
|
91795
92171
|
fromRun: runIndex,
|
|
@@ -91840,12 +92216,12 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91840
92216
|
charPosInRun = spaceEndChar;
|
|
91841
92217
|
continue;
|
|
91842
92218
|
}
|
|
91843
|
-
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2);
|
|
91844
|
-
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91845
|
-
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2) : 0;
|
|
91846
|
-
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91847
92219
|
const wordStartChar = charPosInRun;
|
|
92220
|
+
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2, wordStartChar);
|
|
92221
|
+
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91848
92222
|
const wordEndNoSpace = charPosInRun + word2.length;
|
|
92223
|
+
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) : 0;
|
|
92224
|
+
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91849
92225
|
const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
|
|
91850
92226
|
const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
|
|
91851
92227
|
if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
|
|
@@ -91864,7 +92240,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91864
92240
|
const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
91865
92241
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
91866
92242
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
91867
|
-
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
|
|
92243
|
+
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2, wordStartChar);
|
|
91868
92244
|
let chunkCharOffset = wordStartChar;
|
|
91869
92245
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
91870
92246
|
const chunk = chunks[chunkIndex];
|
|
@@ -91988,7 +92364,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91988
92364
|
if (candidateSpaces > 0) {
|
|
91989
92365
|
const overflow = totalWidthWithWord - availableWidth;
|
|
91990
92366
|
if (overflow > 0) {
|
|
91991
|
-
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2) || Math.max(1, boundarySpacing);
|
|
92367
|
+
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) || Math.max(1, boundarySpacing);
|
|
91992
92368
|
const perSpaceCompression = overflow / candidateSpaces;
|
|
91993
92369
|
const maxPerSpaceCompression = baseSpaceWidth * 0.25;
|
|
91994
92370
|
if (perSpaceCompression <= maxPerSpaceCompression) {
|
|
@@ -92163,8 +92539,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
92163
92539
|
const { font: markerFont } = buildFontString(markerRun);
|
|
92164
92540
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
92165
92541
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92166
|
-
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
92167
|
-
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
|
|
92542
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
92543
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP$1);
|
|
92168
92544
|
markerInfo = {
|
|
92169
92545
|
markerWidth: markerBoxWidth,
|
|
92170
92546
|
markerTextWidth: glyphWidth,
|
|
@@ -92508,7 +92884,7 @@ async function measureListBlock(block, constraints) {
|
|
|
92508
92884
|
markerTextWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92509
92885
|
indentLeft = resolveIndentLeft(item);
|
|
92510
92886
|
const indentHanging = resolveIndentHanging(item);
|
|
92511
|
-
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP, indentHanging);
|
|
92887
|
+
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP$1, indentHanging);
|
|
92512
92888
|
}
|
|
92513
92889
|
const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
|
|
92514
92890
|
const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
|
|
@@ -92534,16 +92910,46 @@ const getPrimaryRun = (paragraph) => {
|
|
|
92534
92910
|
fontSize: 16
|
|
92535
92911
|
};
|
|
92536
92912
|
};
|
|
92537
|
-
const
|
|
92913
|
+
const isWordChar = (char) => {
|
|
92914
|
+
if (!char) return false;
|
|
92915
|
+
const code = char.charCodeAt(0);
|
|
92916
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
92917
|
+
};
|
|
92918
|
+
const capitalizeText = (text, fullText, startOffset) => {
|
|
92919
|
+
if (!text) return text;
|
|
92920
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
92921
|
+
let result = "";
|
|
92922
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
92923
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
92924
|
+
const ch = text[i];
|
|
92925
|
+
result += isWordChar(ch) && !isWordChar(prevChar) ? ch.toUpperCase() : ch;
|
|
92926
|
+
}
|
|
92927
|
+
return result;
|
|
92928
|
+
};
|
|
92929
|
+
const applyTextTransform = (text, run2, startOffset) => {
|
|
92930
|
+
const transform = run2.textTransform;
|
|
92931
|
+
if (!text || !transform || transform === "none") return text;
|
|
92932
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
92933
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
92934
|
+
if (transform === "capitalize") {
|
|
92935
|
+
const fullText = "text" in run2 && typeof run2.text === "string" ? run2.text : text;
|
|
92936
|
+
return capitalizeText(text, fullText, startOffset);
|
|
92937
|
+
}
|
|
92938
|
+
return text;
|
|
92939
|
+
};
|
|
92940
|
+
const measureRunWidth = (text, font, ctx2, run2, startOffset) => {
|
|
92538
92941
|
const letterSpacing = run2.kind === "text" || run2.kind === void 0 ? run2.letterSpacing || 0 : 0;
|
|
92539
|
-
const
|
|
92942
|
+
const displayText = applyTextTransform(text, run2, startOffset);
|
|
92943
|
+
const width = getMeasuredTextWidth(displayText, font, letterSpacing, ctx2);
|
|
92540
92944
|
return roundValue(width);
|
|
92541
92945
|
};
|
|
92542
|
-
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
92946
|
+
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2, startOffset) => {
|
|
92543
92947
|
const chunks = [];
|
|
92948
|
+
const baseOffset = typeof startOffset === "number" ? startOffset : 0;
|
|
92544
92949
|
if (maxWidth <= 0) {
|
|
92545
|
-
for (
|
|
92546
|
-
const
|
|
92950
|
+
for (let i = 0; i < word2.length; i++) {
|
|
92951
|
+
const char = word2[i];
|
|
92952
|
+
const charWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92547
92953
|
chunks.push({ text: char, width: charWidth });
|
|
92548
92954
|
}
|
|
92549
92955
|
return chunks;
|
|
@@ -92553,11 +92959,11 @@ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
|
92553
92959
|
for (let i = 0; i < word2.length; i++) {
|
|
92554
92960
|
const char = word2[i];
|
|
92555
92961
|
const testChunk = currentChunk + char;
|
|
92556
|
-
const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
|
|
92962
|
+
const testWidth = measureRunWidth(testChunk, font, ctx2, run2, baseOffset);
|
|
92557
92963
|
if (testWidth > maxWidth && currentChunk.length > 0) {
|
|
92558
92964
|
chunks.push({ text: currentChunk, width: currentWidth });
|
|
92559
92965
|
currentChunk = char;
|
|
92560
|
-
currentWidth = measureRunWidth(char, font, ctx2, run2);
|
|
92966
|
+
currentWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92561
92967
|
} else {
|
|
92562
92968
|
currentChunk = testChunk;
|
|
92563
92969
|
currentWidth = testWidth;
|
|
@@ -92611,7 +93017,8 @@ const measureDropCap = (ctx2, descriptor, spacing) => {
|
|
|
92611
93017
|
italic: run2.italic
|
|
92612
93018
|
});
|
|
92613
93019
|
ctx2.font = font;
|
|
92614
|
-
const
|
|
93020
|
+
const displayText = applyTextTransform(run2.text, run2);
|
|
93021
|
+
const metrics = ctx2.measureText(displayText);
|
|
92615
93022
|
const advanceWidth = metrics.width;
|
|
92616
93023
|
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
92617
93024
|
const textWidth = Math.max(advanceWidth, paintedWidth);
|
|
@@ -92637,7 +93044,7 @@ const resolveIndentHanging = (item) => {
|
|
|
92637
93044
|
if (indentHanging > 0) {
|
|
92638
93045
|
return indentHanging;
|
|
92639
93046
|
}
|
|
92640
|
-
return DEFAULT_LIST_HANGING_PX;
|
|
93047
|
+
return DEFAULT_LIST_HANGING_PX$1;
|
|
92641
93048
|
};
|
|
92642
93049
|
const buildTabStopsPx = (indent, tabs, tabIntervalTwips) => {
|
|
92643
93050
|
const paragraphIndentTwips = {
|