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
|
@@ -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.3") {
|
|
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.3";
|
|
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-lLnrqNSJ-DoACeFqL.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.3");
|
|
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,18 @@ 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 displayText = applyTextTransform$2(text, run2.textTransform);
|
|
73799
73855
|
if (currentCharOffset + runLength >= charOffset) {
|
|
73800
73856
|
const offsetInRun = charOffset - currentCharOffset;
|
|
73801
73857
|
ctx2.font = getRunFontString(run2);
|
|
73802
|
-
const textUpToTarget =
|
|
73858
|
+
const textUpToTarget = displayText.slice(0, offsetInRun);
|
|
73803
73859
|
const measured2 = ctx2.measureText(textUpToTarget);
|
|
73804
73860
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
|
|
73805
|
-
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(
|
|
73861
|
+
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(text.slice(0, offsetInRun)) : 0;
|
|
73806
73862
|
return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73807
73863
|
}
|
|
73808
73864
|
ctx2.font = getRunFontString(run2);
|
|
73809
|
-
const measured = ctx2.measureText(
|
|
73865
|
+
const measured = ctx2.measureText(displayText);
|
|
73810
73866
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73811
73867
|
const spacesInRun = justify.extraPerSpace !== 0 ? countSpaces(text) : 0;
|
|
73812
73868
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -73845,8 +73901,9 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
73845
73901
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
73846
73902
|
}
|
|
73847
73903
|
const text = run2.text ?? "";
|
|
73848
|
-
const
|
|
73849
|
-
const
|
|
73904
|
+
const displayText = applyTextTransform$2(text, run2.textTransform);
|
|
73905
|
+
const displaySegmentText = displayText.slice(segment.fromChar, segment.toChar);
|
|
73906
|
+
const textUpToTarget = displaySegmentText.slice(0, offsetInSegment);
|
|
73850
73907
|
ctx2.font = getRunFontString(run2);
|
|
73851
73908
|
const measured = ctx2.measureText(textUpToTarget);
|
|
73852
73909
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInSegment, segmentChars);
|
|
@@ -73942,12 +73999,13 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73942
73999
|
}
|
|
73943
74000
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73944
74001
|
const runLength = text.length;
|
|
74002
|
+
const displayText = applyTextTransform$2(text, run2.textTransform);
|
|
73945
74003
|
if (runLength === 0) continue;
|
|
73946
74004
|
ctx2.font = getRunFontString(run2);
|
|
73947
74005
|
for (let i = 0; i <= runLength; i++) {
|
|
73948
|
-
const textUpToChar =
|
|
74006
|
+
const textUpToChar = displayText.slice(0, i);
|
|
73949
74007
|
const measured2 = ctx2.measureText(textUpToChar);
|
|
73950
|
-
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(
|
|
74008
|
+
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text.slice(0, i)) : 0;
|
|
73951
74009
|
const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73952
74010
|
if (charX >= safeX) {
|
|
73953
74011
|
if (i === 0) {
|
|
@@ -73957,7 +74015,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73957
74015
|
pmPosition: pmPosition3
|
|
73958
74016
|
};
|
|
73959
74017
|
}
|
|
73960
|
-
const prevText =
|
|
74018
|
+
const prevText = displayText.slice(0, i - 1);
|
|
73961
74019
|
const prevMeasured = ctx2.measureText(prevText);
|
|
73962
74020
|
const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run2, i - 1, runLength);
|
|
73963
74021
|
const distToPrev = Math.abs(safeX - prevX);
|
|
@@ -73970,7 +74028,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73970
74028
|
};
|
|
73971
74029
|
}
|
|
73972
74030
|
}
|
|
73973
|
-
const measured = ctx2.measureText(
|
|
74031
|
+
const measured = ctx2.measureText(displayText);
|
|
73974
74032
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73975
74033
|
const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
|
|
73976
74034
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -74401,6 +74459,83 @@ function findCharIndexAtX(textNode, container, targetX) {
|
|
|
74401
74459
|
}
|
|
74402
74460
|
return index2;
|
|
74403
74461
|
}
|
|
74462
|
+
const LIST_MARKER_GAP$1 = 8;
|
|
74463
|
+
const MIN_MARKER_GUTTER = 24;
|
|
74464
|
+
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
74465
|
+
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
74466
|
+
const DEFAULT_LIST_HANGING_PX$1 = 18;
|
|
74467
|
+
const SPACE_SUFFIX_GAP_PX = 4;
|
|
74468
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
74469
|
+
function resolveListTextStartPx(wordLayout, indentLeft, firstLine, hanging, measureMarkerText) {
|
|
74470
|
+
const marker = wordLayout?.marker;
|
|
74471
|
+
if (!marker) {
|
|
74472
|
+
const textStartPx = wordLayout?.firstLineIndentMode === true && typeof wordLayout.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
74473
|
+
return textStartPx;
|
|
74474
|
+
}
|
|
74475
|
+
const markerBoxWidth = typeof marker.markerBoxWidthPx === "number" && Number.isFinite(marker.markerBoxWidthPx) ? marker.markerBoxWidthPx : 0;
|
|
74476
|
+
let markerTextWidth = typeof marker.glyphWidthPx === "number" && Number.isFinite(marker.glyphWidthPx) ? marker.glyphWidthPx : void 0;
|
|
74477
|
+
if (markerTextWidth == null && marker.markerText) {
|
|
74478
|
+
markerTextWidth = measureMarkerText(marker.markerText, marker);
|
|
74479
|
+
}
|
|
74480
|
+
if (!Number.isFinite(markerTextWidth) || markerTextWidth < 0) {
|
|
74481
|
+
markerTextWidth = markerBoxWidth;
|
|
74482
|
+
}
|
|
74483
|
+
markerTextWidth = Math.max(0, markerTextWidth);
|
|
74484
|
+
let markerStartPos;
|
|
74485
|
+
if (wordLayout?.firstLineIndentMode === true && Number.isFinite(marker.markerX)) {
|
|
74486
|
+
markerStartPos = marker.markerX;
|
|
74487
|
+
} else {
|
|
74488
|
+
markerStartPos = indentLeft - hanging + firstLine;
|
|
74489
|
+
}
|
|
74490
|
+
if (!Number.isFinite(markerStartPos)) {
|
|
74491
|
+
markerStartPos = 0;
|
|
74492
|
+
}
|
|
74493
|
+
const currentPos = markerStartPos + markerTextWidth;
|
|
74494
|
+
const suffix2 = marker.suffix ?? "tab";
|
|
74495
|
+
if (suffix2 === "space") {
|
|
74496
|
+
return markerStartPos + markerTextWidth + SPACE_SUFFIX_GAP_PX;
|
|
74497
|
+
}
|
|
74498
|
+
if (suffix2 === "nothing") {
|
|
74499
|
+
return markerStartPos + markerTextWidth;
|
|
74500
|
+
}
|
|
74501
|
+
const markerJustification = marker.justification ?? "left";
|
|
74502
|
+
if (markerJustification !== "left") {
|
|
74503
|
+
const gutterWidth = typeof marker.gutterWidthPx === "number" && Number.isFinite(marker.gutterWidthPx) && marker.gutterWidthPx > 0 ? marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
74504
|
+
return markerStartPos + markerTextWidth + Math.max(gutterWidth, LIST_MARKER_GAP$1);
|
|
74505
|
+
}
|
|
74506
|
+
if (wordLayout?.firstLineIndentMode === true) {
|
|
74507
|
+
let targetTabStop;
|
|
74508
|
+
if (Array.isArray(wordLayout.tabsPx)) {
|
|
74509
|
+
for (const tab of wordLayout.tabsPx) {
|
|
74510
|
+
if (typeof tab === "number" && tab > currentPos) {
|
|
74511
|
+
targetTabStop = tab;
|
|
74512
|
+
break;
|
|
74513
|
+
}
|
|
74514
|
+
}
|
|
74515
|
+
}
|
|
74516
|
+
const textStartTarget = typeof marker.textStartX === "number" && Number.isFinite(marker.textStartX) ? marker.textStartX : wordLayout.textStartPx;
|
|
74517
|
+
let tabWidth2;
|
|
74518
|
+
if (targetTabStop !== void 0) {
|
|
74519
|
+
tabWidth2 = targetTabStop - currentPos;
|
|
74520
|
+
} else if (textStartTarget !== void 0 && Number.isFinite(textStartTarget) && textStartTarget > currentPos) {
|
|
74521
|
+
tabWidth2 = textStartTarget - currentPos;
|
|
74522
|
+
} else {
|
|
74523
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74524
|
+
}
|
|
74525
|
+
if (tabWidth2 < LIST_MARKER_GAP$1) {
|
|
74526
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74527
|
+
}
|
|
74528
|
+
return markerStartPos + markerTextWidth + tabWidth2;
|
|
74529
|
+
}
|
|
74530
|
+
const textStart = indentLeft + firstLine;
|
|
74531
|
+
let tabWidth = textStart - currentPos;
|
|
74532
|
+
if (tabWidth <= 0) {
|
|
74533
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
74534
|
+
} else if (tabWidth < LIST_MARKER_GAP$1) {
|
|
74535
|
+
tabWidth = LIST_MARKER_GAP$1;
|
|
74536
|
+
}
|
|
74537
|
+
return markerStartPos + markerTextWidth + tabWidth;
|
|
74538
|
+
}
|
|
74404
74539
|
function getWordLayoutConfig(block) {
|
|
74405
74540
|
if (!block || block.kind !== "paragraph") {
|
|
74406
74541
|
return void 0;
|
|
@@ -74433,9 +74568,16 @@ function calculateTextStartIndent(params2) {
|
|
|
74433
74568
|
const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
|
|
74434
74569
|
let indentAdjust = paraIndentLeft;
|
|
74435
74570
|
if (isListItem2 && isFirstLine && isFirstLineIndentMode) {
|
|
74571
|
+
const resolvedTextStart = resolveListTextStartPx(
|
|
74572
|
+
wordLayout,
|
|
74573
|
+
paraIndentLeft,
|
|
74574
|
+
Math.max(firstLineIndent, 0),
|
|
74575
|
+
Math.max(hangingIndent, 0),
|
|
74576
|
+
() => markerWidth
|
|
74577
|
+
// Use provided markerWidth since we don't have canvas access here
|
|
74578
|
+
);
|
|
74436
74579
|
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;
|
|
74580
|
+
indentAdjust = typeof resolvedTextStart === "number" && Number.isFinite(resolvedTextStart) ? resolvedTextStart : textStartFallback;
|
|
74439
74581
|
} else if (isFirstLine && !isListItem2) {
|
|
74440
74582
|
indentAdjust += firstLineOffset;
|
|
74441
74583
|
}
|
|
@@ -74591,7 +74733,10 @@ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, opt
|
|
|
74591
74733
|
}
|
|
74592
74734
|
function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
74593
74735
|
const zones = [];
|
|
74594
|
-
|
|
74736
|
+
let currentColumns = columns;
|
|
74737
|
+
let currentMargins = margins;
|
|
74738
|
+
let currentPageWidth = pageWidth;
|
|
74739
|
+
let marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74595
74740
|
return {
|
|
74596
74741
|
registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
74597
74742
|
if (!drawingBlock.anchor?.isAnchored) {
|
|
@@ -74604,7 +74749,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74604
74749
|
}
|
|
74605
74750
|
const objectWidth = measure.width ?? 0;
|
|
74606
74751
|
const objectHeight = measure.height ?? 0;
|
|
74607
|
-
const x2 = computeAnchorX(anchor, columnIndex,
|
|
74752
|
+
const x2 = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
|
|
74608
74753
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74609
74754
|
const zone = {
|
|
74610
74755
|
imageBlockId: drawingBlock.id,
|
|
@@ -74638,7 +74783,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74638
74783
|
}
|
|
74639
74784
|
const tableWidth = measure.totalWidth ?? 0;
|
|
74640
74785
|
const tableHeight = measure.totalHeight ?? 0;
|
|
74641
|
-
const x2 = computeTableAnchorX(anchor, columnIndex,
|
|
74786
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
|
|
74642
74787
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74643
74788
|
const zone = {
|
|
74644
74789
|
imageBlockId: tableBlock.id,
|
|
@@ -74686,7 +74831,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74686
74831
|
}
|
|
74687
74832
|
const leftFloats = [];
|
|
74688
74833
|
const rightFloats = [];
|
|
74689
|
-
const columnOrigin = marginLeft + columnIndex * (
|
|
74834
|
+
const columnOrigin = marginLeft + columnIndex * (currentColumns.width + currentColumns.gap);
|
|
74690
74835
|
const columnCenter = columnOrigin + baseWidth / 2;
|
|
74691
74836
|
for (const zone of wrappingZones) {
|
|
74692
74837
|
if (zone.wrapMode === "left") {
|
|
@@ -74725,6 +74870,22 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74725
74870
|
},
|
|
74726
74871
|
clear() {
|
|
74727
74872
|
zones.length = 0;
|
|
74873
|
+
},
|
|
74874
|
+
/**
|
|
74875
|
+
* Update layout context used for positioning and wrapping (columns, margins, page width).
|
|
74876
|
+
* This method should be called when the layout configuration changes (e.g., section breaks,
|
|
74877
|
+
* column changes, page size changes) to ensure floating objects are positioned and wrapped
|
|
74878
|
+
* correctly relative to the new layout boundaries.
|
|
74879
|
+
*
|
|
74880
|
+
* @param nextColumns - Column layout configuration (width, gap, count)
|
|
74881
|
+
* @param nextMargins - Optional page margins (left, right) in pixels
|
|
74882
|
+
* @param nextPageWidth - Optional total page width in pixels
|
|
74883
|
+
*/
|
|
74884
|
+
setLayoutContext(nextColumns, nextMargins, nextPageWidth) {
|
|
74885
|
+
currentColumns = nextColumns;
|
|
74886
|
+
currentMargins = nextMargins;
|
|
74887
|
+
currentPageWidth = nextPageWidth;
|
|
74888
|
+
marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74728
74889
|
}
|
|
74729
74890
|
};
|
|
74730
74891
|
}
|
|
@@ -74824,7 +74985,14 @@ function computeNextSectionPropsAtBreak(blocks) {
|
|
|
74824
74985
|
const props = {};
|
|
74825
74986
|
if (source.kind !== "sectionBreak") return props;
|
|
74826
74987
|
if (source.margins) {
|
|
74827
|
-
props.margins = {
|
|
74988
|
+
props.margins = {
|
|
74989
|
+
header: source.margins.header,
|
|
74990
|
+
footer: source.margins.footer,
|
|
74991
|
+
top: source.margins.top,
|
|
74992
|
+
right: source.margins.right,
|
|
74993
|
+
bottom: source.margins.bottom,
|
|
74994
|
+
left: source.margins.left
|
|
74995
|
+
};
|
|
74828
74996
|
}
|
|
74829
74997
|
if (source.pageSize) {
|
|
74830
74998
|
props.pageSize = { w: source.pageSize.w, h: source.pageSize.h };
|
|
@@ -74872,20 +75040,36 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74872
75040
|
next.activeOrientation = block.orientation;
|
|
74873
75041
|
next.pendingOrientation = null;
|
|
74874
75042
|
}
|
|
75043
|
+
const headerDistance = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
75044
|
+
const footerDistance = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
75045
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
75046
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
74875
75047
|
if (block.margins?.header !== void 0) {
|
|
74876
|
-
const headerDistance = Math.max(0, block.margins.header);
|
|
74877
75048
|
next.activeHeaderDistance = headerDistance;
|
|
74878
75049
|
next.pendingHeaderDistance = headerDistance;
|
|
74879
|
-
next.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
|
|
74880
|
-
next.pendingTopMargin = next.activeTopMargin;
|
|
74881
75050
|
}
|
|
74882
75051
|
if (block.margins?.footer !== void 0) {
|
|
74883
|
-
const footerDistance = Math.max(0, block.margins.footer);
|
|
74884
75052
|
next.activeFooterDistance = footerDistance;
|
|
74885
75053
|
next.pendingFooterDistance = footerDistance;
|
|
74886
|
-
|
|
75054
|
+
}
|
|
75055
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
75056
|
+
next.activeTopMargin = calcRequiredTopMargin(headerDistance, sectionTop);
|
|
75057
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
75058
|
+
}
|
|
75059
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
75060
|
+
next.activeBottomMargin = calcRequiredBottomMargin(footerDistance, sectionBottom);
|
|
74887
75061
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
74888
75062
|
}
|
|
75063
|
+
if (block.margins?.left !== void 0) {
|
|
75064
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
75065
|
+
next.activeLeftMargin = leftMargin;
|
|
75066
|
+
next.pendingLeftMargin = leftMargin;
|
|
75067
|
+
}
|
|
75068
|
+
if (block.margins?.right !== void 0) {
|
|
75069
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
75070
|
+
next.activeRightMargin = rightMargin;
|
|
75071
|
+
next.pendingRightMargin = rightMargin;
|
|
75072
|
+
}
|
|
74889
75073
|
if (block.columns) {
|
|
74890
75074
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
74891
75075
|
next.pendingColumns = null;
|
|
@@ -74894,26 +75078,42 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74894
75078
|
}
|
|
74895
75079
|
const headerPx = block.margins?.header;
|
|
74896
75080
|
const footerPx = block.margins?.footer;
|
|
75081
|
+
const topPx = block.margins?.top;
|
|
75082
|
+
const bottomPx = block.margins?.bottom;
|
|
74897
75083
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
74898
75084
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
75085
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
75086
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
74899
75087
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
74900
75088
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
74901
|
-
if (typeof headerPx === "number") {
|
|
74902
|
-
const newHeaderDist = Math.max(0, headerPx);
|
|
75089
|
+
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
75090
|
+
const newHeaderDist = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
75091
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
74903
75092
|
next.pendingHeaderDistance = newHeaderDist;
|
|
74904
|
-
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist,
|
|
75093
|
+
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, sectionTop);
|
|
74905
75094
|
} else {
|
|
74906
75095
|
next.pendingTopMargin = nextTop;
|
|
74907
75096
|
next.pendingHeaderDistance = nextHeader;
|
|
74908
75097
|
}
|
|
74909
|
-
if (typeof footerPx === "number") {
|
|
74910
|
-
const newFooterDist = Math.max(0, footerPx);
|
|
75098
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
75099
|
+
const newFooterDist = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
75100
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
74911
75101
|
next.pendingFooterDistance = newFooterDist;
|
|
74912
|
-
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist,
|
|
75102
|
+
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, sectionBottom);
|
|
74913
75103
|
} else {
|
|
74914
75104
|
next.pendingBottomMargin = nextBottom;
|
|
74915
75105
|
next.pendingFooterDistance = nextFooter;
|
|
74916
75106
|
}
|
|
75107
|
+
if (typeof block.margins?.left === "number") {
|
|
75108
|
+
next.pendingLeftMargin = Math.max(0, block.margins.left);
|
|
75109
|
+
} else {
|
|
75110
|
+
next.pendingLeftMargin = nextLeft;
|
|
75111
|
+
}
|
|
75112
|
+
if (typeof block.margins?.right === "number") {
|
|
75113
|
+
next.pendingRightMargin = Math.max(0, block.margins.right);
|
|
75114
|
+
} else {
|
|
75115
|
+
next.pendingRightMargin = nextRight;
|
|
75116
|
+
}
|
|
74917
75117
|
if (block.pageSize) {
|
|
74918
75118
|
next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
74919
75119
|
}
|
|
@@ -74973,6 +75173,12 @@ function applyPendingToActive(state2) {
|
|
|
74973
75173
|
if (next.pendingBottomMargin != null) {
|
|
74974
75174
|
next.activeBottomMargin = next.pendingBottomMargin;
|
|
74975
75175
|
}
|
|
75176
|
+
if (next.pendingLeftMargin != null) {
|
|
75177
|
+
next.activeLeftMargin = next.pendingLeftMargin;
|
|
75178
|
+
}
|
|
75179
|
+
if (next.pendingRightMargin != null) {
|
|
75180
|
+
next.activeRightMargin = next.pendingRightMargin;
|
|
75181
|
+
}
|
|
74976
75182
|
if (next.pendingHeaderDistance != null) {
|
|
74977
75183
|
next.activeHeaderDistance = next.pendingHeaderDistance;
|
|
74978
75184
|
}
|
|
@@ -74990,6 +75196,8 @@ function applyPendingToActive(state2) {
|
|
|
74990
75196
|
}
|
|
74991
75197
|
next.pendingTopMargin = null;
|
|
74992
75198
|
next.pendingBottomMargin = null;
|
|
75199
|
+
next.pendingLeftMargin = null;
|
|
75200
|
+
next.pendingRightMargin = null;
|
|
74993
75201
|
next.pendingHeaderDistance = null;
|
|
74994
75202
|
next.pendingFooterDistance = null;
|
|
74995
75203
|
next.pendingPageSize = null;
|
|
@@ -75218,7 +75426,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75218
75426
|
if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
|
|
75219
75427
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75220
75428
|
const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
|
|
75221
|
-
|
|
75429
|
+
const newLines = normalizeLines(newMeasure);
|
|
75430
|
+
lines = newLines;
|
|
75222
75431
|
didRemeasureForColumnWidth = true;
|
|
75223
75432
|
}
|
|
75224
75433
|
let fromLine = 0;
|
|
@@ -75300,7 +75509,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75300
75509
|
if (narrowestRemeasureWidth < remeasureWidth) {
|
|
75301
75510
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75302
75511
|
const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
|
|
75303
|
-
|
|
75512
|
+
const newLines = normalizeLines(newMeasure);
|
|
75513
|
+
lines = newLines;
|
|
75304
75514
|
didRemeasureForFloats = true;
|
|
75305
75515
|
}
|
|
75306
75516
|
}
|
|
@@ -76457,8 +76667,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76457
76667
|
header: options.margins?.header ?? options.margins?.top ?? DEFAULT_MARGINS$2.top,
|
|
76458
76668
|
footer: options.margins?.footer ?? options.margins?.bottom ?? DEFAULT_MARGINS$2.bottom
|
|
76459
76669
|
};
|
|
76460
|
-
const
|
|
76461
|
-
if (
|
|
76670
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
76671
|
+
if (baseContentWidth <= 0) {
|
|
76462
76672
|
throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
|
|
76463
76673
|
}
|
|
76464
76674
|
const validateContentHeight = (height) => {
|
|
@@ -76488,8 +76698,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76488
76698
|
const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
|
|
76489
76699
|
let activeTopMargin = effectiveTopMargin;
|
|
76490
76700
|
let activeBottomMargin = effectiveBottomMargin;
|
|
76701
|
+
let activeLeftMargin = margins.left;
|
|
76702
|
+
let activeRightMargin = margins.right;
|
|
76491
76703
|
let pendingTopMargin = null;
|
|
76492
76704
|
let pendingBottomMargin = null;
|
|
76705
|
+
let pendingLeftMargin = null;
|
|
76706
|
+
let pendingRightMargin = null;
|
|
76493
76707
|
let activeHeaderDistance = margins.header ?? margins.top;
|
|
76494
76708
|
let pendingHeaderDistance = null;
|
|
76495
76709
|
let activeFooterDistance = margins.footer ?? margins.bottom;
|
|
@@ -76502,10 +76716,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76502
76716
|
let pendingOrientation = null;
|
|
76503
76717
|
let activeVAlign = null;
|
|
76504
76718
|
let pendingVAlign = null;
|
|
76719
|
+
const paginatorMargins = { left: activeLeftMargin, right: activeRightMargin };
|
|
76505
76720
|
const floatManager = createFloatingObjectManager(
|
|
76506
|
-
normalizeColumns(activeColumns,
|
|
76507
|
-
{ left:
|
|
76508
|
-
|
|
76721
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76722
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76723
|
+
activePageSize.w
|
|
76509
76724
|
);
|
|
76510
76725
|
const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks);
|
|
76511
76726
|
const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
|
|
@@ -76522,22 +76737,38 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76522
76737
|
next.activeOrientation = block.orientation;
|
|
76523
76738
|
next.pendingOrientation = null;
|
|
76524
76739
|
}
|
|
76740
|
+
const headerDistance2 = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
76741
|
+
const footerDistance2 = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
76742
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
76743
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
76525
76744
|
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;
|
|
76745
|
+
next.activeHeaderDistance = headerDistance2;
|
|
76746
|
+
next.pendingHeaderDistance = headerDistance2;
|
|
76532
76747
|
}
|
|
76533
76748
|
if (block.margins?.footer !== void 0) {
|
|
76534
|
-
const footerDistance2 = Math.max(0, block.margins.footer);
|
|
76535
76749
|
next.activeFooterDistance = footerDistance2;
|
|
76536
76750
|
next.pendingFooterDistance = footerDistance2;
|
|
76751
|
+
}
|
|
76752
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
76753
|
+
const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : headerDistance2;
|
|
76754
|
+
next.activeTopMargin = Math.max(sectionTop, requiredTop);
|
|
76755
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
76756
|
+
}
|
|
76757
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
76537
76758
|
const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
|
|
76538
|
-
next.activeBottomMargin = Math.max(
|
|
76759
|
+
next.activeBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76539
76760
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
76540
76761
|
}
|
|
76762
|
+
if (block.margins?.left !== void 0) {
|
|
76763
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
76764
|
+
next.activeLeftMargin = leftMargin;
|
|
76765
|
+
next.pendingLeftMargin = leftMargin;
|
|
76766
|
+
}
|
|
76767
|
+
if (block.margins?.right !== void 0) {
|
|
76768
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
76769
|
+
next.activeRightMargin = rightMargin;
|
|
76770
|
+
next.pendingRightMargin = rightMargin;
|
|
76771
|
+
}
|
|
76541
76772
|
if (block.columns) {
|
|
76542
76773
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
76543
76774
|
next.pendingColumns = null;
|
|
@@ -76566,27 +76797,35 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76566
76797
|
const headerPx = block.margins?.header;
|
|
76567
76798
|
const footerPx = block.margins?.footer;
|
|
76568
76799
|
const topPx = block.margins?.top;
|
|
76800
|
+
const bottomPx = block.margins?.bottom;
|
|
76801
|
+
const leftPx = block.margins?.left;
|
|
76802
|
+
const rightPx = block.margins?.right;
|
|
76569
76803
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
76570
76804
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
76805
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
76806
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
76571
76807
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
76572
76808
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
76573
76809
|
next.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
76574
76810
|
next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
76575
76811
|
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
76576
|
-
const sectionTop = topPx
|
|
76812
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
76577
76813
|
const sectionHeader = next.pendingHeaderDistance;
|
|
76578
76814
|
const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
|
|
76579
76815
|
next.pendingTopMargin = Math.max(sectionTop, requiredTop);
|
|
76580
76816
|
} else {
|
|
76581
76817
|
next.pendingTopMargin = nextTop;
|
|
76582
76818
|
}
|
|
76583
|
-
if (typeof footerPx === "number") {
|
|
76819
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
76584
76820
|
const sectionFooter = next.pendingFooterDistance;
|
|
76821
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
76585
76822
|
const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
|
|
76586
|
-
next.pendingBottomMargin = Math.max(
|
|
76823
|
+
next.pendingBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76587
76824
|
} else {
|
|
76588
76825
|
next.pendingBottomMargin = nextBottom;
|
|
76589
76826
|
}
|
|
76827
|
+
next.pendingLeftMargin = typeof leftPx === "number" ? Math.max(0, leftPx) : nextLeft;
|
|
76828
|
+
next.pendingRightMargin = typeof rightPx === "number" ? Math.max(0, rightPx) : nextRight;
|
|
76590
76829
|
if (block.pageSize) next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
76591
76830
|
if (block.orientation) next.pendingOrientation = block.orientation;
|
|
76592
76831
|
const sectionType = block.type ?? "continuous";
|
|
@@ -76671,7 +76910,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76671
76910
|
let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
|
|
76672
76911
|
let pendingSectionIndex = null;
|
|
76673
76912
|
const paginator = createPaginator({
|
|
76674
|
-
margins:
|
|
76913
|
+
margins: paginatorMargins,
|
|
76675
76914
|
getActiveTopMargin: () => activeTopMargin,
|
|
76676
76915
|
getActiveBottomMargin: () => activeBottomMargin,
|
|
76677
76916
|
getActiveHeaderDistance: () => activeHeaderDistance,
|
|
@@ -76686,8 +76925,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76686
76925
|
const applied = applyPendingToActive({
|
|
76687
76926
|
activeTopMargin,
|
|
76688
76927
|
activeBottomMargin,
|
|
76928
|
+
activeLeftMargin,
|
|
76929
|
+
activeRightMargin,
|
|
76689
76930
|
pendingTopMargin,
|
|
76690
76931
|
pendingBottomMargin,
|
|
76932
|
+
pendingLeftMargin,
|
|
76933
|
+
pendingRightMargin,
|
|
76691
76934
|
activeHeaderDistance,
|
|
76692
76935
|
activeFooterDistance,
|
|
76693
76936
|
pendingHeaderDistance,
|
|
@@ -76702,8 +76945,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76702
76945
|
});
|
|
76703
76946
|
activeTopMargin = applied.activeTopMargin;
|
|
76704
76947
|
activeBottomMargin = applied.activeBottomMargin;
|
|
76948
|
+
activeLeftMargin = applied.activeLeftMargin;
|
|
76949
|
+
activeRightMargin = applied.activeRightMargin;
|
|
76705
76950
|
pendingTopMargin = applied.pendingTopMargin;
|
|
76706
76951
|
pendingBottomMargin = applied.pendingBottomMargin;
|
|
76952
|
+
pendingLeftMargin = applied.pendingLeftMargin;
|
|
76953
|
+
pendingRightMargin = applied.pendingRightMargin;
|
|
76707
76954
|
activeHeaderDistance = applied.activeHeaderDistance;
|
|
76708
76955
|
activeFooterDistance = applied.activeFooterDistance;
|
|
76709
76956
|
pendingHeaderDistance = applied.pendingHeaderDistance;
|
|
@@ -76715,6 +76962,14 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76715
76962
|
activeOrientation = applied.activeOrientation;
|
|
76716
76963
|
pendingOrientation = applied.pendingOrientation;
|
|
76717
76964
|
cachedColumnsState.state = null;
|
|
76965
|
+
paginatorMargins.left = activeLeftMargin;
|
|
76966
|
+
paginatorMargins.right = activeRightMargin;
|
|
76967
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
76968
|
+
floatManager.setLayoutContext(
|
|
76969
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
76970
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76971
|
+
activePageSize.w
|
|
76972
|
+
);
|
|
76718
76973
|
if (pendingNumbering) {
|
|
76719
76974
|
if (pendingNumbering.format) activeNumberFormat = pendingNumbering.format;
|
|
76720
76975
|
if (typeof pendingNumbering.start === "number" && Number.isFinite(pendingNumbering.start)) {
|
|
@@ -76759,7 +77014,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76759
77014
|
const getActiveColumnsForState = paginator.getActiveColumnsForState;
|
|
76760
77015
|
let cachedColumnsState = { state: null, constraintIndex: -2, contentWidth: -1, colsConfig: null, normalized: null };
|
|
76761
77016
|
const getCurrentColumns = () => {
|
|
76762
|
-
const currentContentWidth = activePageSize.w - (
|
|
77017
|
+
const currentContentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
76763
77018
|
const state2 = states[states.length - 1] ?? null;
|
|
76764
77019
|
const colsConfig = state2 ? getActiveColumnsForState(state2) : activeColumns;
|
|
76765
77020
|
const constraintIndex = state2 ? state2.activeConstraintIndex : -1;
|
|
@@ -76792,6 +77047,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76792
77047
|
layoutLog(` Current page: ${state2.page.number}, cursorY: ${state2.cursorY}`);
|
|
76793
77048
|
activeColumns = newColumns;
|
|
76794
77049
|
cachedColumnsState.state = null;
|
|
77050
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77051
|
+
floatManager.setLayoutContext(
|
|
77052
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
77053
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
77054
|
+
activePageSize.w
|
|
77055
|
+
);
|
|
76795
77056
|
};
|
|
76796
77057
|
const anchoredByParagraph = collectAnchoredDrawings(blocks, measures);
|
|
76797
77058
|
const anchoredTablesByParagraph = collectAnchoredTables(blocks, measures);
|
|
@@ -76823,10 +77084,10 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76823
77084
|
if (alignV === "top") {
|
|
76824
77085
|
anchorY = offsetV;
|
|
76825
77086
|
} else if (alignV === "bottom") {
|
|
76826
|
-
const pageHeight = contentBottom + margins
|
|
77087
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76827
77088
|
anchorY = pageHeight - imageHeight + offsetV;
|
|
76828
77089
|
} else if (alignV === "center") {
|
|
76829
|
-
const pageHeight = contentBottom + margins
|
|
77090
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76830
77091
|
anchorY = (pageHeight - imageHeight) / 2 + offsetV;
|
|
76831
77092
|
} else {
|
|
76832
77093
|
anchorY = offsetV;
|
|
@@ -76837,11 +77098,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76837
77098
|
const anchorX = entry.block.anchor ? computeAnchorX(
|
|
76838
77099
|
entry.block.anchor,
|
|
76839
77100
|
state2.columnIndex,
|
|
76840
|
-
normalizeColumns(activeColumns,
|
|
77101
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76841
77102
|
entry.measure.width,
|
|
76842
|
-
{ left:
|
|
77103
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76843
77104
|
activePageSize.w
|
|
76844
|
-
) :
|
|
77105
|
+
) : activeLeftMargin;
|
|
76845
77106
|
floatManager.registerDrawing(entry.block, entry.measure, anchorY, state2.columnIndex, state2.page.number);
|
|
76846
77107
|
preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state2.page.number });
|
|
76847
77108
|
}
|
|
@@ -76879,8 +77140,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76879
77140
|
const sectionState = {
|
|
76880
77141
|
activeTopMargin,
|
|
76881
77142
|
activeBottomMargin,
|
|
77143
|
+
activeLeftMargin,
|
|
77144
|
+
activeRightMargin,
|
|
76882
77145
|
pendingTopMargin,
|
|
76883
77146
|
pendingBottomMargin,
|
|
77147
|
+
pendingLeftMargin,
|
|
77148
|
+
pendingRightMargin,
|
|
76884
77149
|
activeHeaderDistance,
|
|
76885
77150
|
activeFooterDistance,
|
|
76886
77151
|
pendingHeaderDistance,
|
|
@@ -76914,8 +77179,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76914
77179
|
layoutLog(`[Layout] ========== END SECTION BREAK ==========`);
|
|
76915
77180
|
activeTopMargin = updatedState.activeTopMargin;
|
|
76916
77181
|
activeBottomMargin = updatedState.activeBottomMargin;
|
|
77182
|
+
activeLeftMargin = updatedState.activeLeftMargin;
|
|
77183
|
+
activeRightMargin = updatedState.activeRightMargin;
|
|
76917
77184
|
pendingTopMargin = updatedState.pendingTopMargin;
|
|
76918
77185
|
pendingBottomMargin = updatedState.pendingBottomMargin;
|
|
77186
|
+
pendingLeftMargin = updatedState.pendingLeftMargin;
|
|
77187
|
+
pendingRightMargin = updatedState.pendingRightMargin;
|
|
76919
77188
|
activeHeaderDistance = updatedState.activeHeaderDistance;
|
|
76920
77189
|
activeFooterDistance = updatedState.activeFooterDistance;
|
|
76921
77190
|
pendingHeaderDistance = updatedState.pendingHeaderDistance;
|
|
@@ -77053,8 +77322,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77053
77322
|
pageMargins: {
|
|
77054
77323
|
top: activeTopMargin,
|
|
77055
77324
|
bottom: activeBottomMargin,
|
|
77056
|
-
left:
|
|
77057
|
-
right:
|
|
77325
|
+
left: activeLeftMargin,
|
|
77326
|
+
right: activeRightMargin
|
|
77058
77327
|
},
|
|
77059
77328
|
columns: getCurrentColumns(),
|
|
77060
77329
|
placedAnchoredIds
|
|
@@ -77076,9 +77345,9 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77076
77345
|
const cols = getCurrentColumns();
|
|
77077
77346
|
let maxWidth;
|
|
77078
77347
|
if (relativeFrom === "page") {
|
|
77079
|
-
maxWidth = cols.count === 1 ? activePageSize.w -
|
|
77348
|
+
maxWidth = cols.count === 1 ? activePageSize.w - (activeLeftMargin + activeRightMargin) : activePageSize.w;
|
|
77080
77349
|
} else if (relativeFrom === "margin") {
|
|
77081
|
-
maxWidth = activePageSize.w -
|
|
77350
|
+
maxWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77082
77351
|
} else {
|
|
77083
77352
|
maxWidth = cols.width;
|
|
77084
77353
|
}
|
|
@@ -78265,11 +78534,11 @@ function findWordBoundaries(blocks, pos) {
|
|
|
78265
78534
|
if (text.length === 0) return null;
|
|
78266
78535
|
const clampedPos = Math.max(0, Math.min(localPos, text.length));
|
|
78267
78536
|
let wordStart = clampedPos;
|
|
78268
|
-
while (wordStart > 0 && isWordChar(text[wordStart - 1])) {
|
|
78537
|
+
while (wordStart > 0 && isWordChar$2(text[wordStart - 1])) {
|
|
78269
78538
|
wordStart--;
|
|
78270
78539
|
}
|
|
78271
78540
|
let wordEnd = clampedPos;
|
|
78272
|
-
while (wordEnd < text.length && isWordChar(text[wordEnd])) {
|
|
78541
|
+
while (wordEnd < text.length && isWordChar$2(text[wordEnd])) {
|
|
78273
78542
|
wordEnd++;
|
|
78274
78543
|
}
|
|
78275
78544
|
if (wordStart === wordEnd) {
|
|
@@ -78332,7 +78601,7 @@ function findBlockAtPosition(blocks, pos) {
|
|
|
78332
78601
|
}
|
|
78333
78602
|
return null;
|
|
78334
78603
|
}
|
|
78335
|
-
function isWordChar(char) {
|
|
78604
|
+
function isWordChar$2(char) {
|
|
78336
78605
|
return /[\p{L}\p{N}_]/u.test(char);
|
|
78337
78606
|
}
|
|
78338
78607
|
function isWhitespace(char) {
|
|
@@ -78367,6 +78636,29 @@ function fontString(run2) {
|
|
|
78367
78636
|
function runText(run2) {
|
|
78368
78637
|
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
78369
78638
|
}
|
|
78639
|
+
const isWordChar$1 = (char) => {
|
|
78640
|
+
if (!char) return false;
|
|
78641
|
+
const code = char.charCodeAt(0);
|
|
78642
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
78643
|
+
};
|
|
78644
|
+
const capitalizeText$1 = (text, fullText, startOffset) => {
|
|
78645
|
+
if (!text) return text;
|
|
78646
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
78647
|
+
let result = "";
|
|
78648
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
78649
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
78650
|
+
const ch = text[i];
|
|
78651
|
+
result += isWordChar$1(ch) && !isWordChar$1(prevChar) ? ch.toUpperCase() : ch;
|
|
78652
|
+
}
|
|
78653
|
+
return result;
|
|
78654
|
+
};
|
|
78655
|
+
const applyTextTransform$1 = (text, transform, fullText, startOffset) => {
|
|
78656
|
+
if (!text || !transform || transform === "none") return text;
|
|
78657
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
78658
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
78659
|
+
if (transform === "capitalize") return capitalizeText$1(text, fullText, startOffset);
|
|
78660
|
+
return text;
|
|
78661
|
+
};
|
|
78370
78662
|
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
78371
78663
|
const TWIPS_PER_INCH$4 = 1440;
|
|
78372
78664
|
const PX_PER_INCH$3 = 96;
|
|
@@ -78375,6 +78667,13 @@ const TAB_EPSILON$1 = 0.1;
|
|
|
78375
78667
|
const WIDTH_FUDGE_PX = 0.5;
|
|
78376
78668
|
const twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$1;
|
|
78377
78669
|
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
78670
|
+
const markerFontString = (run2) => {
|
|
78671
|
+
const size2 = run2?.fontSize ?? 16;
|
|
78672
|
+
const family = run2?.fontFamily ?? "Arial";
|
|
78673
|
+
const italic = run2?.italic ? "italic " : "";
|
|
78674
|
+
const bold = run2?.bold ? "bold " : "";
|
|
78675
|
+
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
78676
|
+
};
|
|
78378
78677
|
const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
|
|
78379
78678
|
const paragraphIndentTwips = {
|
|
78380
78679
|
left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
|
|
@@ -78405,7 +78704,8 @@ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
|
|
|
78405
78704
|
};
|
|
78406
78705
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
78407
78706
|
const context = getCtx();
|
|
78408
|
-
const
|
|
78707
|
+
const fullText = runText(run2);
|
|
78708
|
+
const text = applyTextTransform$1(fullText.slice(fromChar, toChar), run2.textTransform, fullText, fromChar);
|
|
78409
78709
|
if (!context) {
|
|
78410
78710
|
const textRun = isTextRun$2(run2) ? run2 : null;
|
|
78411
78711
|
const size2 = textRun?.fontSize ?? 16;
|
|
@@ -78451,8 +78751,21 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
78451
78751
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
78452
78752
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
78453
78753
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
78454
|
-
const
|
|
78455
|
-
|
|
78754
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
78755
|
+
wordLayout,
|
|
78756
|
+
indentLeft,
|
|
78757
|
+
indentFirstLine,
|
|
78758
|
+
indentHanging,
|
|
78759
|
+
(markerText, marker) => {
|
|
78760
|
+
const context = getCtx();
|
|
78761
|
+
if (!context) return 0;
|
|
78762
|
+
context.font = markerFontString(marker.run);
|
|
78763
|
+
return context.measureText(markerText).width;
|
|
78764
|
+
}
|
|
78765
|
+
);
|
|
78766
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
78767
|
+
const treatAsHanging = !wordLayout?.marker && effectiveTextStartPx && indentLeft === 0 && indentHanging === 0;
|
|
78768
|
+
const firstLineWidth = typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - effectiveTextStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
78456
78769
|
const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
78457
78770
|
let currentRun = 0;
|
|
78458
78771
|
let currentChar = 0;
|
|
@@ -78992,7 +79305,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
78992
79305
|
if (dirty.deletedBlockIds.length > 0) {
|
|
78993
79306
|
measureCache.invalidate(dirty.deletedBlockIds);
|
|
78994
79307
|
}
|
|
78995
|
-
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options);
|
|
79308
|
+
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options, nextBlocks);
|
|
78996
79309
|
if (measurementWidth <= 0 || measurementHeight <= 0) {
|
|
78997
79310
|
throw new Error("incrementalLayout: invalid measurement constraints resolved from options");
|
|
78998
79311
|
}
|
|
@@ -79261,7 +79574,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
79261
79574
|
const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
|
|
79262
79575
|
const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
79263
79576
|
const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
|
|
79264
|
-
function resolveMeasurementConstraints(options) {
|
|
79577
|
+
function resolveMeasurementConstraints(options, blocks) {
|
|
79265
79578
|
const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
|
|
79266
79579
|
const margins = {
|
|
79267
79580
|
top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
|
|
@@ -79269,23 +79582,41 @@ function resolveMeasurementConstraints(options) {
|
|
|
79269
79582
|
bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
|
|
79270
79583
|
left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
|
|
79271
79584
|
};
|
|
79272
|
-
const
|
|
79273
|
-
const
|
|
79274
|
-
const
|
|
79275
|
-
|
|
79585
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
79586
|
+
const baseContentHeight = pageSize.h - (margins.top + margins.bottom);
|
|
79587
|
+
const computeColumnWidth = (contentWidth, columns) => {
|
|
79588
|
+
if (!columns || columns.count <= 1) return contentWidth;
|
|
79276
79589
|
const gap = Math.max(0, columns.gap ?? 0);
|
|
79277
79590
|
const totalGap = gap * (columns.count - 1);
|
|
79278
|
-
|
|
79279
|
-
|
|
79280
|
-
|
|
79281
|
-
|
|
79282
|
-
|
|
79591
|
+
return (contentWidth - totalGap) / columns.count;
|
|
79592
|
+
};
|
|
79593
|
+
let measurementWidth = computeColumnWidth(baseContentWidth, options.columns);
|
|
79594
|
+
let measurementHeight = baseContentHeight;
|
|
79595
|
+
if (blocks && blocks.length > 0) {
|
|
79596
|
+
for (const block of blocks) {
|
|
79597
|
+
if (block.kind !== "sectionBreak") continue;
|
|
79598
|
+
const sectionPageSize = block.pageSize ?? pageSize;
|
|
79599
|
+
const sectionMargins = {
|
|
79600
|
+
top: normalizeMargin(block.margins?.top, margins.top),
|
|
79601
|
+
right: normalizeMargin(block.margins?.right, margins.right),
|
|
79602
|
+
bottom: normalizeMargin(block.margins?.bottom, margins.bottom),
|
|
79603
|
+
left: normalizeMargin(block.margins?.left, margins.left)
|
|
79283
79604
|
};
|
|
79605
|
+
const contentWidth = sectionPageSize.w - (sectionMargins.left + sectionMargins.right);
|
|
79606
|
+
const contentHeight = sectionPageSize.h - (sectionMargins.top + sectionMargins.bottom);
|
|
79607
|
+
if (contentWidth <= 0 || contentHeight <= 0) continue;
|
|
79608
|
+
const columnWidth = computeColumnWidth(contentWidth, block.columns ?? options.columns);
|
|
79609
|
+
if (columnWidth > measurementWidth) {
|
|
79610
|
+
measurementWidth = columnWidth;
|
|
79611
|
+
}
|
|
79612
|
+
if (contentHeight > measurementHeight) {
|
|
79613
|
+
measurementHeight = contentHeight;
|
|
79614
|
+
}
|
|
79284
79615
|
}
|
|
79285
79616
|
}
|
|
79286
79617
|
return {
|
|
79287
|
-
measurementWidth
|
|
79288
|
-
measurementHeight
|
|
79618
|
+
measurementWidth,
|
|
79619
|
+
measurementHeight
|
|
79289
79620
|
};
|
|
79290
79621
|
}
|
|
79291
79622
|
const serializeHeaderFooterResults = (kind, batch) => {
|
|
@@ -85263,8 +85594,8 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
|
85263
85594
|
}
|
|
85264
85595
|
return void 0;
|
|
85265
85596
|
}
|
|
85266
|
-
const DEFAULT_LIST_HANGING_PX
|
|
85267
|
-
const LIST_MARKER_GAP
|
|
85597
|
+
const DEFAULT_LIST_HANGING_PX = 18;
|
|
85598
|
+
const LIST_MARKER_GAP = 8;
|
|
85268
85599
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
85269
85600
|
const DEFAULT_DECIMAL_PATTERN = "%1.";
|
|
85270
85601
|
const ASCII_UPPERCASE_A = 65;
|
|
@@ -85675,7 +86006,7 @@ function computeWordParagraphLayout(input) {
|
|
|
85675
86006
|
let markerBoxWidthPx;
|
|
85676
86007
|
let markerX;
|
|
85677
86008
|
if (hasFirstLineIndent) {
|
|
85678
|
-
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP
|
|
86009
|
+
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP : DEFAULT_LIST_HANGING_PX;
|
|
85679
86010
|
markerX = indentLeftPx + (firstLinePx ?? 0);
|
|
85680
86011
|
layout.textStartPx = markerX + markerBoxWidthPx;
|
|
85681
86012
|
layout.hangingPx = 0;
|
|
@@ -85775,12 +86106,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
|
|
|
85775
86106
|
let markerBox = Math.max(hangingPxRaw || 0, 0);
|
|
85776
86107
|
if (markerBox <= 0) {
|
|
85777
86108
|
if (glyphWidthPx != null && glyphWidthPx > 0) {
|
|
85778
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86109
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85779
86110
|
} else {
|
|
85780
|
-
markerBox = DEFAULT_LIST_HANGING_PX
|
|
86111
|
+
markerBox = DEFAULT_LIST_HANGING_PX;
|
|
85781
86112
|
}
|
|
85782
|
-
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP
|
|
85783
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86113
|
+
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP > markerBox) {
|
|
86114
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85784
86115
|
}
|
|
85785
86116
|
return markerBox;
|
|
85786
86117
|
};
|
|
@@ -85800,7 +86131,7 @@ const buildMarkerLayout = ({
|
|
|
85800
86131
|
textStartX: textStartPx,
|
|
85801
86132
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
85802
86133
|
// Gutter is the small gap between marker and text, not the full marker box width
|
|
85803
|
-
gutterWidthPx: LIST_MARKER_GAP
|
|
86134
|
+
gutterWidthPx: LIST_MARKER_GAP,
|
|
85804
86135
|
justification: numbering.lvlJc ?? "left",
|
|
85805
86136
|
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
85806
86137
|
run: markerRun,
|
|
@@ -86492,6 +86823,31 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
86492
86823
|
return null;
|
|
86493
86824
|
}
|
|
86494
86825
|
};
|
|
86826
|
+
const normalizeWordLayoutForIndent = (wordLayout, paragraphIndent) => {
|
|
86827
|
+
const resolvedIndent = wordLayout.resolvedIndent ?? paragraphIndent ?? {};
|
|
86828
|
+
const indentLeft = isFiniteNumber(resolvedIndent.left) ? resolvedIndent.left : 0;
|
|
86829
|
+
const firstLine = isFiniteNumber(resolvedIndent.firstLine) ? resolvedIndent.firstLine : 0;
|
|
86830
|
+
const hanging = isFiniteNumber(resolvedIndent.hanging) ? resolvedIndent.hanging : 0;
|
|
86831
|
+
const shouldFirstLineIndentMode = firstLine > 0 && !hanging;
|
|
86832
|
+
if (wordLayout.firstLineIndentMode === true && !shouldFirstLineIndentMode) {
|
|
86833
|
+
wordLayout.firstLineIndentMode = false;
|
|
86834
|
+
}
|
|
86835
|
+
if (wordLayout.firstLineIndentMode === true) {
|
|
86836
|
+
if (isFiniteNumber(wordLayout.textStartPx)) {
|
|
86837
|
+
if (wordLayout.marker && (!isFiniteNumber(wordLayout.marker.textStartX) || wordLayout.marker.textStartX !== wordLayout.textStartPx)) {
|
|
86838
|
+
wordLayout.marker.textStartX = wordLayout.textStartPx;
|
|
86839
|
+
}
|
|
86840
|
+
} else if (wordLayout.marker && isFiniteNumber(wordLayout.marker.textStartX)) {
|
|
86841
|
+
wordLayout.textStartPx = wordLayout.marker.textStartX;
|
|
86842
|
+
}
|
|
86843
|
+
} else {
|
|
86844
|
+
wordLayout.textStartPx = indentLeft;
|
|
86845
|
+
if (wordLayout.marker) {
|
|
86846
|
+
wordLayout.marker.textStartX = indentLeft;
|
|
86847
|
+
}
|
|
86848
|
+
}
|
|
86849
|
+
return wordLayout;
|
|
86850
|
+
};
|
|
86495
86851
|
const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
|
|
86496
86852
|
const attrs = para.attrs ?? {};
|
|
86497
86853
|
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
@@ -86814,8 +87170,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86814
87170
|
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
86815
87171
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86816
87172
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86817
|
-
const
|
|
86818
|
-
|
|
87173
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87174
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87175
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87176
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87177
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86819
87178
|
wordLayout = {
|
|
86820
87179
|
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
86821
87180
|
firstLineIndentMode: true,
|
|
@@ -86823,10 +87182,13 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86823
87182
|
};
|
|
86824
87183
|
}
|
|
86825
87184
|
}
|
|
86826
|
-
if (wordLayout &&
|
|
87185
|
+
if (wordLayout && !Number.isFinite(wordLayout.textStartPx) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86827
87186
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86828
|
-
const
|
|
86829
|
-
|
|
87187
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87188
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87189
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87190
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87191
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86830
87192
|
wordLayout = {
|
|
86831
87193
|
...wordLayout,
|
|
86832
87194
|
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
@@ -86846,6 +87208,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86846
87208
|
wordLayout.marker.suffix = listRendering.suffix;
|
|
86847
87209
|
}
|
|
86848
87210
|
}
|
|
87211
|
+
wordLayout = normalizeWordLayoutForIndent(wordLayout, paragraphAttrs.indent);
|
|
86849
87212
|
paragraphAttrs.wordLayout = wordLayout;
|
|
86850
87213
|
}
|
|
86851
87214
|
if (enrichedNumberingProps.resolvedLevelIndent) {
|
|
@@ -90962,11 +91325,6 @@ function initHeaderFooterRegistry({
|
|
|
90962
91325
|
cleanups
|
|
90963
91326
|
};
|
|
90964
91327
|
}
|
|
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
91328
|
function calculateRotatedBounds(input) {
|
|
90971
91329
|
const width = Math.max(0, input.width);
|
|
90972
91330
|
const height = Math.max(0, input.height);
|
|
@@ -91230,8 +91588,25 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91230
91588
|
const rawTextStartPx = wordLayout?.textStartPx;
|
|
91231
91589
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
91232
91590
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof rawTextStartPx === "number" && Number.isFinite(rawTextStartPx) ? rawTextStartPx : void 0;
|
|
91233
|
-
|
|
91234
|
-
|
|
91591
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
91592
|
+
wordLayout,
|
|
91593
|
+
indentLeft,
|
|
91594
|
+
firstLine,
|
|
91595
|
+
hanging,
|
|
91596
|
+
(markerText, marker) => {
|
|
91597
|
+
const markerRun = {
|
|
91598
|
+
fontFamily: toCssFontFamily(marker.run?.fontFamily) ?? marker.run?.fontFamily ?? "Arial",
|
|
91599
|
+
fontSize: marker.run?.fontSize ?? 16,
|
|
91600
|
+
bold: marker.run?.bold ?? false,
|
|
91601
|
+
italic: marker.run?.italic ?? false
|
|
91602
|
+
};
|
|
91603
|
+
const { font: markerFont } = buildFontString(markerRun);
|
|
91604
|
+
return measureText(markerText, markerFont, ctx2);
|
|
91605
|
+
}
|
|
91606
|
+
);
|
|
91607
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
91608
|
+
if (typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft) {
|
|
91609
|
+
initialAvailableWidth = Math.max(1, maxWidth - effectiveTextStartPx - indentRight);
|
|
91235
91610
|
} else {
|
|
91236
91611
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
91237
91612
|
}
|
|
@@ -91318,7 +91693,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91318
91693
|
pendingTabAlignment = null;
|
|
91319
91694
|
return startX;
|
|
91320
91695
|
};
|
|
91321
|
-
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
91696
|
+
const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
|
|
91322
91697
|
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
91323
91698
|
const { val } = pendingTabAlignment;
|
|
91324
91699
|
let segmentWidth = 0;
|
|
@@ -91327,11 +91702,11 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91327
91702
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
91328
91703
|
if (idx >= 0) {
|
|
91329
91704
|
const beforeText = segmentText.slice(0, idx);
|
|
91330
|
-
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
91705
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91331
91706
|
}
|
|
91332
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91707
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91333
91708
|
} else if (val === "end" || val === "center") {
|
|
91334
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91709
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91335
91710
|
}
|
|
91336
91711
|
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
91337
91712
|
};
|
|
@@ -91383,8 +91758,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91383
91758
|
const { font } = buildFontString(
|
|
91384
91759
|
lastRun
|
|
91385
91760
|
);
|
|
91386
|
-
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun);
|
|
91387
|
-
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun) : 0;
|
|
91761
|
+
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun, sliceStart);
|
|
91762
|
+
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun, sliceStart) : 0;
|
|
91388
91763
|
const delta = Math.max(0, fullWidth - keptWidth);
|
|
91389
91764
|
lineToTrim.width = roundValue(Math.max(0, lineToTrim.width - delta));
|
|
91390
91765
|
lineToTrim.spaceCount = Math.max(0, lineToTrim.spaceCount - trimCount);
|
|
@@ -91595,7 +91970,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91595
91970
|
continue;
|
|
91596
91971
|
}
|
|
91597
91972
|
if (isFieldAnnotationRun(run2)) {
|
|
91598
|
-
const
|
|
91973
|
+
const rawDisplayText = run2.displayLabel || "";
|
|
91974
|
+
const displayText = applyTextTransform(rawDisplayText, run2);
|
|
91599
91975
|
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
91976
|
const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
|
|
91601
91977
|
const fontWeight = run2.bold ? "bold" : "normal";
|
|
@@ -91698,7 +92074,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91698
92074
|
const spacesLength = segment.length;
|
|
91699
92075
|
const spacesStartChar = charPosInRun;
|
|
91700
92076
|
const spacesEndChar = charPosInRun + spacesLength;
|
|
91701
|
-
const spacesWidth = measureRunWidth(segment, font, ctx2, run2);
|
|
92077
|
+
const spacesWidth = measureRunWidth(segment, font, ctx2, run2, spacesStartChar);
|
|
91702
92078
|
if (!currentLine) {
|
|
91703
92079
|
currentLine = {
|
|
91704
92080
|
fromRun: runIndex,
|
|
@@ -91762,7 +92138,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91762
92138
|
}
|
|
91763
92139
|
let segmentStartX;
|
|
91764
92140
|
if (currentLine && pendingTabAlignment) {
|
|
91765
|
-
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
92141
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2, charPosInRun);
|
|
91766
92142
|
if (segmentStartX == null) {
|
|
91767
92143
|
segmentStartX = currentLine.width;
|
|
91768
92144
|
}
|
|
@@ -91772,7 +92148,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91772
92148
|
if (word2 === "") {
|
|
91773
92149
|
const spaceStartChar = charPosInRun;
|
|
91774
92150
|
const spaceEndChar = charPosInRun + 1;
|
|
91775
|
-
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2);
|
|
92151
|
+
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2, spaceStartChar);
|
|
91776
92152
|
if (!currentLine) {
|
|
91777
92153
|
currentLine = {
|
|
91778
92154
|
fromRun: runIndex,
|
|
@@ -91823,12 +92199,12 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91823
92199
|
charPosInRun = spaceEndChar;
|
|
91824
92200
|
continue;
|
|
91825
92201
|
}
|
|
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
92202
|
const wordStartChar = charPosInRun;
|
|
92203
|
+
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2, wordStartChar);
|
|
92204
|
+
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91831
92205
|
const wordEndNoSpace = charPosInRun + word2.length;
|
|
92206
|
+
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) : 0;
|
|
92207
|
+
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91832
92208
|
const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
|
|
91833
92209
|
const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
|
|
91834
92210
|
if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
|
|
@@ -91847,7 +92223,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91847
92223
|
const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
91848
92224
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
91849
92225
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
91850
|
-
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
|
|
92226
|
+
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2, wordStartChar);
|
|
91851
92227
|
let chunkCharOffset = wordStartChar;
|
|
91852
92228
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
91853
92229
|
const chunk = chunks[chunkIndex];
|
|
@@ -91971,7 +92347,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91971
92347
|
if (candidateSpaces > 0) {
|
|
91972
92348
|
const overflow = totalWidthWithWord - availableWidth;
|
|
91973
92349
|
if (overflow > 0) {
|
|
91974
|
-
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2) || Math.max(1, boundarySpacing);
|
|
92350
|
+
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) || Math.max(1, boundarySpacing);
|
|
91975
92351
|
const perSpaceCompression = overflow / candidateSpaces;
|
|
91976
92352
|
const maxPerSpaceCompression = baseSpaceWidth * 0.25;
|
|
91977
92353
|
if (perSpaceCompression <= maxPerSpaceCompression) {
|
|
@@ -92146,8 +92522,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
92146
92522
|
const { font: markerFont } = buildFontString(markerRun);
|
|
92147
92523
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
92148
92524
|
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);
|
|
92525
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
92526
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP$1);
|
|
92151
92527
|
markerInfo = {
|
|
92152
92528
|
markerWidth: markerBoxWidth,
|
|
92153
92529
|
markerTextWidth: glyphWidth,
|
|
@@ -92491,7 +92867,7 @@ async function measureListBlock(block, constraints) {
|
|
|
92491
92867
|
markerTextWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92492
92868
|
indentLeft = resolveIndentLeft(item);
|
|
92493
92869
|
const indentHanging = resolveIndentHanging(item);
|
|
92494
|
-
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP, indentHanging);
|
|
92870
|
+
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP$1, indentHanging);
|
|
92495
92871
|
}
|
|
92496
92872
|
const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
|
|
92497
92873
|
const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
|
|
@@ -92517,16 +92893,46 @@ const getPrimaryRun = (paragraph) => {
|
|
|
92517
92893
|
fontSize: 16
|
|
92518
92894
|
};
|
|
92519
92895
|
};
|
|
92520
|
-
const
|
|
92896
|
+
const isWordChar = (char) => {
|
|
92897
|
+
if (!char) return false;
|
|
92898
|
+
const code = char.charCodeAt(0);
|
|
92899
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
92900
|
+
};
|
|
92901
|
+
const capitalizeText = (text, fullText, startOffset) => {
|
|
92902
|
+
if (!text) return text;
|
|
92903
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
92904
|
+
let result = "";
|
|
92905
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
92906
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
92907
|
+
const ch = text[i];
|
|
92908
|
+
result += isWordChar(ch) && !isWordChar(prevChar) ? ch.toUpperCase() : ch;
|
|
92909
|
+
}
|
|
92910
|
+
return result;
|
|
92911
|
+
};
|
|
92912
|
+
const applyTextTransform = (text, run2, startOffset) => {
|
|
92913
|
+
const transform = run2.textTransform;
|
|
92914
|
+
if (!text || !transform || transform === "none") return text;
|
|
92915
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
92916
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
92917
|
+
if (transform === "capitalize") {
|
|
92918
|
+
const fullText = "text" in run2 && typeof run2.text === "string" ? run2.text : text;
|
|
92919
|
+
return capitalizeText(text, fullText, startOffset);
|
|
92920
|
+
}
|
|
92921
|
+
return text;
|
|
92922
|
+
};
|
|
92923
|
+
const measureRunWidth = (text, font, ctx2, run2, startOffset) => {
|
|
92521
92924
|
const letterSpacing = run2.kind === "text" || run2.kind === void 0 ? run2.letterSpacing || 0 : 0;
|
|
92522
|
-
const
|
|
92925
|
+
const displayText = applyTextTransform(text, run2, startOffset);
|
|
92926
|
+
const width = getMeasuredTextWidth(displayText, font, letterSpacing, ctx2);
|
|
92523
92927
|
return roundValue(width);
|
|
92524
92928
|
};
|
|
92525
|
-
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
92929
|
+
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2, startOffset) => {
|
|
92526
92930
|
const chunks = [];
|
|
92931
|
+
const baseOffset = typeof startOffset === "number" ? startOffset : 0;
|
|
92527
92932
|
if (maxWidth <= 0) {
|
|
92528
|
-
for (
|
|
92529
|
-
const
|
|
92933
|
+
for (let i = 0; i < word2.length; i++) {
|
|
92934
|
+
const char = word2[i];
|
|
92935
|
+
const charWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92530
92936
|
chunks.push({ text: char, width: charWidth });
|
|
92531
92937
|
}
|
|
92532
92938
|
return chunks;
|
|
@@ -92536,11 +92942,11 @@ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
|
92536
92942
|
for (let i = 0; i < word2.length; i++) {
|
|
92537
92943
|
const char = word2[i];
|
|
92538
92944
|
const testChunk = currentChunk + char;
|
|
92539
|
-
const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
|
|
92945
|
+
const testWidth = measureRunWidth(testChunk, font, ctx2, run2, baseOffset);
|
|
92540
92946
|
if (testWidth > maxWidth && currentChunk.length > 0) {
|
|
92541
92947
|
chunks.push({ text: currentChunk, width: currentWidth });
|
|
92542
92948
|
currentChunk = char;
|
|
92543
|
-
currentWidth = measureRunWidth(char, font, ctx2, run2);
|
|
92949
|
+
currentWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92544
92950
|
} else {
|
|
92545
92951
|
currentChunk = testChunk;
|
|
92546
92952
|
currentWidth = testWidth;
|
|
@@ -92594,7 +93000,8 @@ const measureDropCap = (ctx2, descriptor, spacing) => {
|
|
|
92594
93000
|
italic: run2.italic
|
|
92595
93001
|
});
|
|
92596
93002
|
ctx2.font = font;
|
|
92597
|
-
const
|
|
93003
|
+
const displayText = applyTextTransform(run2.text, run2);
|
|
93004
|
+
const metrics = ctx2.measureText(displayText);
|
|
92598
93005
|
const advanceWidth = metrics.width;
|
|
92599
93006
|
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
92600
93007
|
const textWidth = Math.max(advanceWidth, paintedWidth);
|
|
@@ -92620,7 +93027,7 @@ const resolveIndentHanging = (item) => {
|
|
|
92620
93027
|
if (indentHanging > 0) {
|
|
92621
93028
|
return indentHanging;
|
|
92622
93029
|
}
|
|
92623
|
-
return DEFAULT_LIST_HANGING_PX;
|
|
93030
|
+
return DEFAULT_LIST_HANGING_PX$1;
|
|
92624
93031
|
};
|
|
92625
93032
|
const buildTabStopsPx = (indent, tabs, tabIntervalTwips) => {
|
|
92626
93033
|
const paragraphIndentTwips = {
|