@harbour-enterprises/superdoc 2.0.0-next.1 → 2.0.0-next.11
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-BDQHgDVD.es.js → PdfViewer-CKia_BiV.es.js} +1 -1
- package/dist/chunks/{PdfViewer-Cun5Zr8u.cjs → PdfViewer-CqLaaynu.cjs} +1 -1
- package/dist/chunks/{index-if-EH8uU.cjs → index-B6y8QUV4.cjs} +3 -3
- package/dist/chunks/{index-Dq6vXk74-Vm-euNb7.cjs → index-Bym7r582-C-HNFdqE.cjs} +1 -1
- package/dist/chunks/{index-Dq6vXk74-CQD7nLbH.es.js → index-Bym7r582-C74MxNIS.es.js} +1 -1
- package/dist/chunks/{index-CGAmeAEK.es.js → index-CI_4oB5b.es.js} +3 -3
- package/dist/chunks/{super-editor.es-CwNpXZzP.cjs → super-editor.es-cwkDFZH7.cjs} +781 -158
- package/dist/chunks/{super-editor.es-DyaHVXrq.es.js → super-editor.es-d52fdTl1.es.js} +781 -158
- package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +6 -6
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BtoNJWI9.js → converter-BdRh3O4f.js} +45 -3
- package/dist/super-editor/chunks/{docx-zipper-CLkDdGOr.js → docx-zipper-Bn6DCl5u.js} +1 -1
- package/dist/super-editor/chunks/{editor-COH8793Z.js → editor-015kcgto.js} +734 -170
- package/dist/super-editor/chunks/{index-Dq6vXk74.js → index-Bym7r582.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-Ca-BPuJ2.js → toolbar-CoU_nhyU.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/style.css +6 -6
- package/dist/super-editor/super-editor.es.js +41 -17
- 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 +783 -160
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -39216,11 +39216,15 @@ const encode$1 = (params2, encodedAttrs = {}) => {
|
|
|
39216
39216
|
}
|
|
39217
39217
|
if (elements.length === 1) {
|
|
39218
39218
|
text = elements[0].text;
|
|
39219
|
-
const
|
|
39219
|
+
const docXmlSpace = params2.converter?.documentAttributes?.["xml:space"];
|
|
39220
|
+
const xmlSpace = encodedAttrs.xmlSpace ?? attributes?.["xml:space"] ?? elements[0]?.attributes?.["xml:space"] ?? docXmlSpace;
|
|
39220
39221
|
if (xmlSpace !== "preserve" && typeof text === "string") {
|
|
39221
39222
|
text = text.replace(/^[ \t\n\r]+/, "").replace(/[ \t\n\r]+$/, "");
|
|
39222
39223
|
}
|
|
39223
39224
|
text = text.replace(/\[\[sdspace\]\]/g, "");
|
|
39225
|
+
if (xmlSpace !== "preserve" && typeof text === "string" && !text.trim()) {
|
|
39226
|
+
return null;
|
|
39227
|
+
}
|
|
39224
39228
|
} else if (!elements.length && encodedAttrs.xmlSpace === "preserve") {
|
|
39225
39229
|
text = " ";
|
|
39226
39230
|
} else return null;
|
|
@@ -42203,8 +42207,46 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42203
42207
|
this.declaration = this.initialJSON?.declaration;
|
|
42204
42208
|
this.resolveDocumentGuid();
|
|
42205
42209
|
}
|
|
42210
|
+
/**
|
|
42211
|
+
* Parses XML content into JSON format while preserving whitespace-only text runs.
|
|
42212
|
+
*
|
|
42213
|
+
* This method wraps xml-js's xml2json parser with additional preprocessing to prevent
|
|
42214
|
+
* the parser from dropping whitespace-only content in <w:t> and <w:delText> elements.
|
|
42215
|
+
* This is critical for correctly handling documents that rely on document-level
|
|
42216
|
+
* xml:space="preserve" rather than per-element attributes, which is common in
|
|
42217
|
+
* PDF-to-DOCX converted documents.
|
|
42218
|
+
*
|
|
42219
|
+
* The whitespace preservation strategy:
|
|
42220
|
+
* 1. Before parsing, wraps whitespace-only content with [[sdspace]] placeholders
|
|
42221
|
+
* 2. xml-js parser preserves the placeholder-wrapped text
|
|
42222
|
+
* 3. During text node processing (t-translator.js), placeholders are removed
|
|
42223
|
+
*
|
|
42224
|
+
* @param {string} xml - The XML string to parse
|
|
42225
|
+
* @returns {Object} The parsed JSON representation of the XML document
|
|
42226
|
+
*
|
|
42227
|
+
* @example
|
|
42228
|
+
* // Handles whitespace-only text runs
|
|
42229
|
+
* const xml = '<w:t> </w:t>';
|
|
42230
|
+
* const result = parseXmlToJson(xml);
|
|
42231
|
+
* // Result preserves the space: { elements: [{ text: '[[sdspace]] [[sdspace]]' }] }
|
|
42232
|
+
*
|
|
42233
|
+
* @example
|
|
42234
|
+
* // Handles elements with attributes
|
|
42235
|
+
* const xml = '<w:t xml:space="preserve"> text </w:t>';
|
|
42236
|
+
* const result = parseXmlToJson(xml);
|
|
42237
|
+
* // Preserves content and attributes
|
|
42238
|
+
*
|
|
42239
|
+
* @example
|
|
42240
|
+
* // Handles both w:t and w:delText elements
|
|
42241
|
+
* const xml = '<w:delText> </w:delText>';
|
|
42242
|
+
* const result = parseXmlToJson(xml);
|
|
42243
|
+
* // Preserves whitespace in deleted text
|
|
42244
|
+
*/
|
|
42206
42245
|
parseXmlToJson(xml) {
|
|
42207
|
-
const newXml = xml.replace(
|
|
42246
|
+
const newXml = xml.replace(
|
|
42247
|
+
/(<w:(?:t|delText)(?:\s[^>]*)?>)(\s+)(<\/w:(?:t|delText)>)/g,
|
|
42248
|
+
"$1[[sdspace]]$2[[sdspace]]$3"
|
|
42249
|
+
);
|
|
42208
42250
|
return JSON.parse(xmljs.xml2json(newXml, null, 2));
|
|
42209
42251
|
}
|
|
42210
42252
|
/**
|
|
@@ -42427,7 +42469,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42427
42469
|
static getStoredSuperdocVersion(docx) {
|
|
42428
42470
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42429
42471
|
}
|
|
42430
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.
|
|
42472
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "2.0.0-next.11") {
|
|
42431
42473
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42432
42474
|
}
|
|
42433
42475
|
/**
|
|
@@ -60508,7 +60550,7 @@ const isHeadless = (editor) => {
|
|
|
60508
60550
|
const shouldSkipNodeView = (editor) => {
|
|
60509
60551
|
return isHeadless(editor);
|
|
60510
60552
|
};
|
|
60511
|
-
const summaryVersion = "2.0.0-next.
|
|
60553
|
+
const summaryVersion = "2.0.0-next.11";
|
|
60512
60554
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
60513
60555
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
60514
60556
|
function mapAttributes(attrs) {
|
|
@@ -61297,7 +61339,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
61297
61339
|
{ default: remarkStringify },
|
|
61298
61340
|
{ default: remarkGfm }
|
|
61299
61341
|
] = await Promise.all([
|
|
61300
|
-
Promise.resolve().then(() => require("./index-
|
|
61342
|
+
Promise.resolve().then(() => require("./index-Bym7r582-C-HNFdqE.cjs")),
|
|
61301
61343
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
61302
61344
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
61303
61345
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -61502,7 +61544,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
61502
61544
|
* Process collaboration migrations
|
|
61503
61545
|
*/
|
|
61504
61546
|
processCollaborationMigrations() {
|
|
61505
|
-
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.
|
|
61547
|
+
console.debug("[checkVersionMigrations] Current editor version", "2.0.0-next.11");
|
|
61506
61548
|
if (!this.options.ydoc) return;
|
|
61507
61549
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
61508
61550
|
let docVersion = metaMap.get("version");
|
|
@@ -68754,7 +68796,7 @@ function isMinimalWordLayout(value) {
|
|
|
68754
68796
|
return true;
|
|
68755
68797
|
}
|
|
68756
68798
|
const LIST_MARKER_GAP$2 = 8;
|
|
68757
|
-
const DEFAULT_TAB_INTERVAL_PX$
|
|
68799
|
+
const DEFAULT_TAB_INTERVAL_PX$2 = 48;
|
|
68758
68800
|
const DEFAULT_PAGE_HEIGHT_PX = 1056;
|
|
68759
68801
|
const DEFAULT_VIRTUALIZED_PAGE_GAP$1 = 72;
|
|
68760
68802
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
@@ -69681,6 +69723,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69681
69723
|
const block = lookup2.block;
|
|
69682
69724
|
const measure = lookup2.measure;
|
|
69683
69725
|
const wordLayout = isMinimalWordLayout(block.attrs?.wordLayout) ? block.attrs.wordLayout : void 0;
|
|
69726
|
+
const alignment2 = block.attrs?.alignment;
|
|
69684
69727
|
const fragmentEl = this.doc.createElement("div");
|
|
69685
69728
|
fragmentEl.classList.add(CLASS_NAMES$1.fragment);
|
|
69686
69729
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
@@ -69759,7 +69802,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69759
69802
|
const textStart = paraIndentLeft + firstLine;
|
|
69760
69803
|
tabWidth = textStart - currentPos;
|
|
69761
69804
|
if (tabWidth <= 0) {
|
|
69762
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
69805
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
69763
69806
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
69764
69807
|
tabWidth = LIST_MARKER_GAP$2;
|
|
69765
69808
|
}
|
|
@@ -69786,6 +69829,21 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69786
69829
|
let availableWidthOverride = line.maxWidth != null ? Math.min(line.maxWidth, fallbackAvailableWidth) : fallbackAvailableWidth;
|
|
69787
69830
|
if (index2 === 0 && listFirstLineMarkerTabWidth != null) {
|
|
69788
69831
|
availableWidthOverride = fragment.width - listFirstLineMarkerTabWidth - Math.max(0, paraIndentRight);
|
|
69832
|
+
if (alignment2 === "justify" || alignment2 === "both") {
|
|
69833
|
+
console.log(
|
|
69834
|
+
"[justify-debug][painter-firstline-available]",
|
|
69835
|
+
JSON.stringify({
|
|
69836
|
+
blockId: block.id,
|
|
69837
|
+
fragmentWidth: fragment.width,
|
|
69838
|
+
markerTabWidth: listFirstLineMarkerTabWidth,
|
|
69839
|
+
paraIndentRight,
|
|
69840
|
+
availableWidthOverride,
|
|
69841
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
69842
|
+
lineWidth: line.width,
|
|
69843
|
+
lineNaturalWidth: line.naturalWidth ?? null
|
|
69844
|
+
})
|
|
69845
|
+
);
|
|
69846
|
+
}
|
|
69789
69847
|
}
|
|
69790
69848
|
const isLastLineOfFragment = index2 === lines.length - 1;
|
|
69791
69849
|
const isLastLineOfParagraph = isLastLineOfFragment && !fragment.continuesOnNext;
|
|
@@ -69911,7 +69969,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
69911
69969
|
const textStart = paraIndentLeft + firstLine;
|
|
69912
69970
|
tabWidth = textStart - currentPos;
|
|
69913
69971
|
if (tabWidth <= 0) {
|
|
69914
|
-
tabWidth = DEFAULT_TAB_INTERVAL_PX$
|
|
69972
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$2 - currentPos % DEFAULT_TAB_INTERVAL_PX$2;
|
|
69915
69973
|
} else if (tabWidth < LIST_MARKER_GAP$2) {
|
|
69916
69974
|
tabWidth = LIST_MARKER_GAP$2;
|
|
69917
69975
|
}
|
|
@@ -71445,6 +71503,23 @@ const _DomPainter = class _DomPainter2 {
|
|
|
71445
71503
|
if (spacingPerSpace !== 0) {
|
|
71446
71504
|
el.style.wordSpacing = `${spacingPerSpace}px`;
|
|
71447
71505
|
}
|
|
71506
|
+
if (justifyShouldApply && spacingPerSpace < 0) {
|
|
71507
|
+
console.log(
|
|
71508
|
+
"[justify-debug][painter-wordspacing-negative]",
|
|
71509
|
+
JSON.stringify({
|
|
71510
|
+
blockId: block.id,
|
|
71511
|
+
lineIndex: lineIndex ?? null,
|
|
71512
|
+
alignment: alignment2 ?? null,
|
|
71513
|
+
availableWidth,
|
|
71514
|
+
lineWidth,
|
|
71515
|
+
lineMaxWidth: line.maxWidth ?? null,
|
|
71516
|
+
lineNaturalWidth: line.naturalWidth ?? null,
|
|
71517
|
+
spaceCount,
|
|
71518
|
+
hasExplicitPositioning: Boolean(hasExplicitPositioning),
|
|
71519
|
+
skipJustify: Boolean(skipJustify)
|
|
71520
|
+
})
|
|
71521
|
+
);
|
|
71522
|
+
}
|
|
71448
71523
|
if (hasExplicitPositioning && line.segments) {
|
|
71449
71524
|
const paraIndent = block.attrs?.indent;
|
|
71450
71525
|
const indentLeft = paraIndent?.left ?? 0;
|
|
@@ -73638,6 +73713,28 @@ let measurementCtx = null;
|
|
|
73638
73713
|
const TAB_CHAR_LENGTH = 1;
|
|
73639
73714
|
const SPACE_CHARS = SPACE_CHARS$1;
|
|
73640
73715
|
const isTabRun$1 = (run2) => run2?.kind === "tab";
|
|
73716
|
+
const isWordChar$3 = (char) => {
|
|
73717
|
+
if (!char) return false;
|
|
73718
|
+
const code = char.charCodeAt(0);
|
|
73719
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
73720
|
+
};
|
|
73721
|
+
const capitalizeText$2 = (text) => {
|
|
73722
|
+
if (!text) return text;
|
|
73723
|
+
let result = "";
|
|
73724
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
73725
|
+
const prevChar = i > 0 ? text[i - 1] : "";
|
|
73726
|
+
const ch = text[i];
|
|
73727
|
+
result += isWordChar$3(ch) && !isWordChar$3(prevChar) ? ch.toUpperCase() : ch;
|
|
73728
|
+
}
|
|
73729
|
+
return result;
|
|
73730
|
+
};
|
|
73731
|
+
const applyTextTransform$2 = (text, transform) => {
|
|
73732
|
+
if (!text || !transform || transform === "none") return text;
|
|
73733
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
73734
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
73735
|
+
if (transform === "capitalize") return capitalizeText$2(text);
|
|
73736
|
+
return text;
|
|
73737
|
+
};
|
|
73641
73738
|
function getMeasurementContext() {
|
|
73642
73739
|
if (measurementCtx) return measurementCtx;
|
|
73643
73740
|
if (typeof document === "undefined") {
|
|
@@ -73813,17 +73910,19 @@ function measureCharacterX(block, line, charOffset, availableWidthOverride, alig
|
|
|
73813
73910
|
}
|
|
73814
73911
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73815
73912
|
const runLength = text.length;
|
|
73913
|
+
const transform = isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? void 0 : run2.textTransform;
|
|
73914
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73816
73915
|
if (currentCharOffset + runLength >= charOffset) {
|
|
73817
73916
|
const offsetInRun = charOffset - currentCharOffset;
|
|
73818
73917
|
ctx2.font = getRunFontString(run2);
|
|
73819
|
-
const textUpToTarget =
|
|
73918
|
+
const textUpToTarget = displayText.slice(0, offsetInRun);
|
|
73820
73919
|
const measured2 = ctx2.measureText(textUpToTarget);
|
|
73821
73920
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
|
|
73822
|
-
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(
|
|
73921
|
+
const spacesInPortion = justify.extraPerSpace !== 0 ? countSpaces(text.slice(0, offsetInRun)) : 0;
|
|
73823
73922
|
return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73824
73923
|
}
|
|
73825
73924
|
ctx2.font = getRunFontString(run2);
|
|
73826
|
-
const measured = ctx2.measureText(
|
|
73925
|
+
const measured = ctx2.measureText(displayText);
|
|
73827
73926
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73828
73927
|
const spacesInRun = justify.extraPerSpace !== 0 ? countSpaces(text) : 0;
|
|
73829
73928
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -73862,8 +73961,10 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
73862
73961
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
73863
73962
|
}
|
|
73864
73963
|
const text = run2.text ?? "";
|
|
73865
|
-
const
|
|
73866
|
-
const
|
|
73964
|
+
const transform = "textTransform" in run2 ? run2.textTransform : void 0;
|
|
73965
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73966
|
+
const displaySegmentText = displayText.slice(segment.fromChar, segment.toChar);
|
|
73967
|
+
const textUpToTarget = displaySegmentText.slice(0, offsetInSegment);
|
|
73867
73968
|
ctx2.font = getRunFontString(run2);
|
|
73868
73969
|
const measured = ctx2.measureText(textUpToTarget);
|
|
73869
73970
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInSegment, segmentChars);
|
|
@@ -73959,12 +74060,14 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73959
74060
|
}
|
|
73960
74061
|
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73961
74062
|
const runLength = text.length;
|
|
74063
|
+
const transform = isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? void 0 : run2.textTransform;
|
|
74064
|
+
const displayText = applyTextTransform$2(text, transform);
|
|
73962
74065
|
if (runLength === 0) continue;
|
|
73963
74066
|
ctx2.font = getRunFontString(run2);
|
|
73964
74067
|
for (let i = 0; i <= runLength; i++) {
|
|
73965
|
-
const textUpToChar =
|
|
74068
|
+
const textUpToChar = displayText.slice(0, i);
|
|
73966
74069
|
const measured2 = ctx2.measureText(textUpToChar);
|
|
73967
|
-
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(
|
|
74070
|
+
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(text.slice(0, i)) : 0;
|
|
73968
74071
|
const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
73969
74072
|
if (charX >= safeX) {
|
|
73970
74073
|
if (i === 0) {
|
|
@@ -73974,7 +74077,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73974
74077
|
pmPosition: pmPosition3
|
|
73975
74078
|
};
|
|
73976
74079
|
}
|
|
73977
|
-
const prevText =
|
|
74080
|
+
const prevText = displayText.slice(0, i - 1);
|
|
73978
74081
|
const prevMeasured = ctx2.measureText(prevText);
|
|
73979
74082
|
const prevX = currentX + prevMeasured.width + computeLetterSpacingWidth(run2, i - 1, runLength);
|
|
73980
74083
|
const distToPrev = Math.abs(safeX - prevX);
|
|
@@ -73987,7 +74090,7 @@ function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride, alig
|
|
|
73987
74090
|
};
|
|
73988
74091
|
}
|
|
73989
74092
|
}
|
|
73990
|
-
const measured = ctx2.measureText(
|
|
74093
|
+
const measured = ctx2.measureText(displayText);
|
|
73991
74094
|
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
73992
74095
|
const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
|
|
73993
74096
|
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
@@ -74418,6 +74521,83 @@ function findCharIndexAtX(textNode, container, targetX) {
|
|
|
74418
74521
|
}
|
|
74419
74522
|
return index2;
|
|
74420
74523
|
}
|
|
74524
|
+
const LIST_MARKER_GAP$1 = 8;
|
|
74525
|
+
const MIN_MARKER_GUTTER = 24;
|
|
74526
|
+
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
74527
|
+
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
74528
|
+
const DEFAULT_LIST_HANGING_PX$1 = 18;
|
|
74529
|
+
const SPACE_SUFFIX_GAP_PX = 4;
|
|
74530
|
+
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
74531
|
+
function resolveListTextStartPx(wordLayout, indentLeft, firstLine, hanging, measureMarkerText) {
|
|
74532
|
+
const marker = wordLayout?.marker;
|
|
74533
|
+
if (!marker) {
|
|
74534
|
+
const textStartPx = wordLayout?.firstLineIndentMode === true && typeof wordLayout.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
74535
|
+
return textStartPx;
|
|
74536
|
+
}
|
|
74537
|
+
const markerBoxWidth = typeof marker.markerBoxWidthPx === "number" && Number.isFinite(marker.markerBoxWidthPx) ? marker.markerBoxWidthPx : 0;
|
|
74538
|
+
let markerTextWidth = typeof marker.glyphWidthPx === "number" && Number.isFinite(marker.glyphWidthPx) ? marker.glyphWidthPx : void 0;
|
|
74539
|
+
if (markerTextWidth == null && marker.markerText) {
|
|
74540
|
+
markerTextWidth = measureMarkerText(marker.markerText, marker);
|
|
74541
|
+
}
|
|
74542
|
+
if (!Number.isFinite(markerTextWidth) || markerTextWidth !== void 0 && markerTextWidth < 0) {
|
|
74543
|
+
markerTextWidth = markerBoxWidth;
|
|
74544
|
+
}
|
|
74545
|
+
const finalMarkerTextWidth = Math.max(0, markerTextWidth ?? 0);
|
|
74546
|
+
let markerStartPos;
|
|
74547
|
+
if (wordLayout?.firstLineIndentMode === true && typeof marker.markerX === "number" && Number.isFinite(marker.markerX)) {
|
|
74548
|
+
markerStartPos = marker.markerX;
|
|
74549
|
+
} else {
|
|
74550
|
+
markerStartPos = indentLeft - hanging + firstLine;
|
|
74551
|
+
}
|
|
74552
|
+
if (!Number.isFinite(markerStartPos)) {
|
|
74553
|
+
markerStartPos = 0;
|
|
74554
|
+
}
|
|
74555
|
+
const currentPos = markerStartPos + finalMarkerTextWidth;
|
|
74556
|
+
const suffix2 = marker.suffix ?? "tab";
|
|
74557
|
+
if (suffix2 === "space") {
|
|
74558
|
+
return markerStartPos + finalMarkerTextWidth + SPACE_SUFFIX_GAP_PX;
|
|
74559
|
+
}
|
|
74560
|
+
if (suffix2 === "nothing") {
|
|
74561
|
+
return markerStartPos + finalMarkerTextWidth;
|
|
74562
|
+
}
|
|
74563
|
+
const markerJustification = marker.justification ?? "left";
|
|
74564
|
+
if (markerJustification !== "left") {
|
|
74565
|
+
const gutterWidth = typeof marker.gutterWidthPx === "number" && Number.isFinite(marker.gutterWidthPx) && marker.gutterWidthPx > 0 ? marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
74566
|
+
return markerStartPos + finalMarkerTextWidth + Math.max(gutterWidth, LIST_MARKER_GAP$1);
|
|
74567
|
+
}
|
|
74568
|
+
if (wordLayout?.firstLineIndentMode === true) {
|
|
74569
|
+
let targetTabStop;
|
|
74570
|
+
if (Array.isArray(wordLayout.tabsPx)) {
|
|
74571
|
+
for (const tab of wordLayout.tabsPx) {
|
|
74572
|
+
if (typeof tab === "number" && tab > currentPos) {
|
|
74573
|
+
targetTabStop = tab;
|
|
74574
|
+
break;
|
|
74575
|
+
}
|
|
74576
|
+
}
|
|
74577
|
+
}
|
|
74578
|
+
const textStartTarget = typeof marker.textStartX === "number" && Number.isFinite(marker.textStartX) ? marker.textStartX : wordLayout.textStartPx;
|
|
74579
|
+
let tabWidth2;
|
|
74580
|
+
if (targetTabStop !== void 0) {
|
|
74581
|
+
tabWidth2 = targetTabStop - currentPos;
|
|
74582
|
+
} else if (textStartTarget !== void 0 && Number.isFinite(textStartTarget) && textStartTarget > currentPos) {
|
|
74583
|
+
tabWidth2 = textStartTarget - currentPos;
|
|
74584
|
+
} else {
|
|
74585
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74586
|
+
}
|
|
74587
|
+
if (tabWidth2 < LIST_MARKER_GAP$1) {
|
|
74588
|
+
tabWidth2 = LIST_MARKER_GAP$1;
|
|
74589
|
+
}
|
|
74590
|
+
return markerStartPos + finalMarkerTextWidth + tabWidth2;
|
|
74591
|
+
}
|
|
74592
|
+
const textStart = indentLeft + firstLine;
|
|
74593
|
+
let tabWidth = textStart - currentPos;
|
|
74594
|
+
if (tabWidth <= 0) {
|
|
74595
|
+
tabWidth = DEFAULT_TAB_INTERVAL_PX$1 - currentPos % DEFAULT_TAB_INTERVAL_PX$1;
|
|
74596
|
+
} else if (tabWidth < LIST_MARKER_GAP$1) {
|
|
74597
|
+
tabWidth = LIST_MARKER_GAP$1;
|
|
74598
|
+
}
|
|
74599
|
+
return markerStartPos + finalMarkerTextWidth + tabWidth;
|
|
74600
|
+
}
|
|
74421
74601
|
function getWordLayoutConfig(block) {
|
|
74422
74602
|
if (!block || block.kind !== "paragraph") {
|
|
74423
74603
|
return void 0;
|
|
@@ -74450,9 +74630,16 @@ function calculateTextStartIndent(params2) {
|
|
|
74450
74630
|
const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
|
|
74451
74631
|
let indentAdjust = paraIndentLeft;
|
|
74452
74632
|
if (isListItem2 && isFirstLine && isFirstLineIndentMode) {
|
|
74633
|
+
const resolvedTextStart = resolveListTextStartPx(
|
|
74634
|
+
wordLayout,
|
|
74635
|
+
paraIndentLeft,
|
|
74636
|
+
Math.max(firstLineIndent, 0),
|
|
74637
|
+
Math.max(hangingIndent, 0),
|
|
74638
|
+
() => markerWidth
|
|
74639
|
+
// Use provided markerWidth since we don't have canvas access here
|
|
74640
|
+
);
|
|
74453
74641
|
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;
|
|
74642
|
+
indentAdjust = typeof resolvedTextStart === "number" && Number.isFinite(resolvedTextStart) ? resolvedTextStart : textStartFallback;
|
|
74456
74643
|
} else if (isFirstLine && !isListItem2) {
|
|
74457
74644
|
indentAdjust += firstLineOffset;
|
|
74458
74645
|
}
|
|
@@ -74608,7 +74795,10 @@ function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, opt
|
|
|
74608
74795
|
}
|
|
74609
74796
|
function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
74610
74797
|
const zones = [];
|
|
74611
|
-
|
|
74798
|
+
let currentColumns = columns;
|
|
74799
|
+
let currentMargins = margins;
|
|
74800
|
+
let currentPageWidth = pageWidth;
|
|
74801
|
+
let marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74612
74802
|
return {
|
|
74613
74803
|
registerDrawing(drawingBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
74614
74804
|
if (!drawingBlock.anchor?.isAnchored) {
|
|
@@ -74621,7 +74811,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74621
74811
|
}
|
|
74622
74812
|
const objectWidth = measure.width ?? 0;
|
|
74623
74813
|
const objectHeight = measure.height ?? 0;
|
|
74624
|
-
const x2 = computeAnchorX(anchor, columnIndex,
|
|
74814
|
+
const x2 = computeAnchorX(anchor, columnIndex, currentColumns, objectWidth, currentMargins, currentPageWidth);
|
|
74625
74815
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74626
74816
|
const zone = {
|
|
74627
74817
|
imageBlockId: drawingBlock.id,
|
|
@@ -74655,7 +74845,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74655
74845
|
}
|
|
74656
74846
|
const tableWidth = measure.totalWidth ?? 0;
|
|
74657
74847
|
const tableHeight = measure.totalHeight ?? 0;
|
|
74658
|
-
const x2 = computeTableAnchorX(anchor, columnIndex,
|
|
74848
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, currentColumns, tableWidth, currentMargins, currentPageWidth);
|
|
74659
74849
|
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
74660
74850
|
const zone = {
|
|
74661
74851
|
imageBlockId: tableBlock.id,
|
|
@@ -74703,7 +74893,7 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74703
74893
|
}
|
|
74704
74894
|
const leftFloats = [];
|
|
74705
74895
|
const rightFloats = [];
|
|
74706
|
-
const columnOrigin = marginLeft + columnIndex * (
|
|
74896
|
+
const columnOrigin = marginLeft + columnIndex * (currentColumns.width + currentColumns.gap);
|
|
74707
74897
|
const columnCenter = columnOrigin + baseWidth / 2;
|
|
74708
74898
|
for (const zone of wrappingZones) {
|
|
74709
74899
|
if (zone.wrapMode === "left") {
|
|
@@ -74742,6 +74932,22 @@ function createFloatingObjectManager(columns, margins, pageWidth) {
|
|
|
74742
74932
|
},
|
|
74743
74933
|
clear() {
|
|
74744
74934
|
zones.length = 0;
|
|
74935
|
+
},
|
|
74936
|
+
/**
|
|
74937
|
+
* Update layout context used for positioning and wrapping (columns, margins, page width).
|
|
74938
|
+
* This method should be called when the layout configuration changes (e.g., section breaks,
|
|
74939
|
+
* column changes, page size changes) to ensure floating objects are positioned and wrapped
|
|
74940
|
+
* correctly relative to the new layout boundaries.
|
|
74941
|
+
*
|
|
74942
|
+
* @param nextColumns - Column layout configuration (width, gap, count)
|
|
74943
|
+
* @param nextMargins - Optional page margins (left, right) in pixels
|
|
74944
|
+
* @param nextPageWidth - Optional total page width in pixels
|
|
74945
|
+
*/
|
|
74946
|
+
setLayoutContext(nextColumns, nextMargins, nextPageWidth) {
|
|
74947
|
+
currentColumns = nextColumns;
|
|
74948
|
+
currentMargins = nextMargins;
|
|
74949
|
+
currentPageWidth = nextPageWidth;
|
|
74950
|
+
marginLeft = Math.max(0, currentMargins?.left ?? 0);
|
|
74745
74951
|
}
|
|
74746
74952
|
};
|
|
74747
74953
|
}
|
|
@@ -74841,7 +75047,14 @@ function computeNextSectionPropsAtBreak(blocks) {
|
|
|
74841
75047
|
const props = {};
|
|
74842
75048
|
if (source.kind !== "sectionBreak") return props;
|
|
74843
75049
|
if (source.margins) {
|
|
74844
|
-
props.margins = {
|
|
75050
|
+
props.margins = {
|
|
75051
|
+
header: source.margins.header,
|
|
75052
|
+
footer: source.margins.footer,
|
|
75053
|
+
top: source.margins.top,
|
|
75054
|
+
right: source.margins.right,
|
|
75055
|
+
bottom: source.margins.bottom,
|
|
75056
|
+
left: source.margins.left
|
|
75057
|
+
};
|
|
74845
75058
|
}
|
|
74846
75059
|
if (source.pageSize) {
|
|
74847
75060
|
props.pageSize = { w: source.pageSize.w, h: source.pageSize.h };
|
|
@@ -74889,20 +75102,36 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74889
75102
|
next.activeOrientation = block.orientation;
|
|
74890
75103
|
next.pendingOrientation = null;
|
|
74891
75104
|
}
|
|
75105
|
+
const headerDistance = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
75106
|
+
const footerDistance = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
75107
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
75108
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
74892
75109
|
if (block.margins?.header !== void 0) {
|
|
74893
|
-
const headerDistance = Math.max(0, block.margins.header);
|
|
74894
75110
|
next.activeHeaderDistance = headerDistance;
|
|
74895
75111
|
next.pendingHeaderDistance = headerDistance;
|
|
74896
|
-
next.activeTopMargin = calcRequiredTopMargin(headerDistance, baseMargins.top);
|
|
74897
|
-
next.pendingTopMargin = next.activeTopMargin;
|
|
74898
75112
|
}
|
|
74899
75113
|
if (block.margins?.footer !== void 0) {
|
|
74900
|
-
const footerDistance = Math.max(0, block.margins.footer);
|
|
74901
75114
|
next.activeFooterDistance = footerDistance;
|
|
74902
75115
|
next.pendingFooterDistance = footerDistance;
|
|
74903
|
-
|
|
75116
|
+
}
|
|
75117
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
75118
|
+
next.activeTopMargin = calcRequiredTopMargin(headerDistance, sectionTop);
|
|
75119
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
75120
|
+
}
|
|
75121
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
75122
|
+
next.activeBottomMargin = calcRequiredBottomMargin(footerDistance, sectionBottom);
|
|
74904
75123
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
74905
75124
|
}
|
|
75125
|
+
if (block.margins?.left !== void 0) {
|
|
75126
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
75127
|
+
next.activeLeftMargin = leftMargin;
|
|
75128
|
+
next.pendingLeftMargin = leftMargin;
|
|
75129
|
+
}
|
|
75130
|
+
if (block.margins?.right !== void 0) {
|
|
75131
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
75132
|
+
next.activeRightMargin = rightMargin;
|
|
75133
|
+
next.pendingRightMargin = rightMargin;
|
|
75134
|
+
}
|
|
74906
75135
|
if (block.columns) {
|
|
74907
75136
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
74908
75137
|
next.pendingColumns = null;
|
|
@@ -74911,26 +75140,42 @@ function scheduleSectionBreak(block, state2, baseMargins, maxHeaderContentHeight
|
|
|
74911
75140
|
}
|
|
74912
75141
|
const headerPx = block.margins?.header;
|
|
74913
75142
|
const footerPx = block.margins?.footer;
|
|
75143
|
+
const topPx = block.margins?.top;
|
|
75144
|
+
const bottomPx = block.margins?.bottom;
|
|
74914
75145
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
74915
75146
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
75147
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
75148
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
74916
75149
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
74917
75150
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
74918
|
-
if (typeof headerPx === "number") {
|
|
74919
|
-
const newHeaderDist = Math.max(0, headerPx);
|
|
75151
|
+
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
75152
|
+
const newHeaderDist = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
75153
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
74920
75154
|
next.pendingHeaderDistance = newHeaderDist;
|
|
74921
|
-
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist,
|
|
75155
|
+
next.pendingTopMargin = calcRequiredTopMargin(newHeaderDist, sectionTop);
|
|
74922
75156
|
} else {
|
|
74923
75157
|
next.pendingTopMargin = nextTop;
|
|
74924
75158
|
next.pendingHeaderDistance = nextHeader;
|
|
74925
75159
|
}
|
|
74926
|
-
if (typeof footerPx === "number") {
|
|
74927
|
-
const newFooterDist = Math.max(0, footerPx);
|
|
75160
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
75161
|
+
const newFooterDist = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
75162
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
74928
75163
|
next.pendingFooterDistance = newFooterDist;
|
|
74929
|
-
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist,
|
|
75164
|
+
next.pendingBottomMargin = calcRequiredBottomMargin(newFooterDist, sectionBottom);
|
|
74930
75165
|
} else {
|
|
74931
75166
|
next.pendingBottomMargin = nextBottom;
|
|
74932
75167
|
next.pendingFooterDistance = nextFooter;
|
|
74933
75168
|
}
|
|
75169
|
+
if (typeof block.margins?.left === "number") {
|
|
75170
|
+
next.pendingLeftMargin = Math.max(0, block.margins.left);
|
|
75171
|
+
} else {
|
|
75172
|
+
next.pendingLeftMargin = nextLeft;
|
|
75173
|
+
}
|
|
75174
|
+
if (typeof block.margins?.right === "number") {
|
|
75175
|
+
next.pendingRightMargin = Math.max(0, block.margins.right);
|
|
75176
|
+
} else {
|
|
75177
|
+
next.pendingRightMargin = nextRight;
|
|
75178
|
+
}
|
|
74934
75179
|
if (block.pageSize) {
|
|
74935
75180
|
next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
74936
75181
|
}
|
|
@@ -74990,6 +75235,12 @@ function applyPendingToActive(state2) {
|
|
|
74990
75235
|
if (next.pendingBottomMargin != null) {
|
|
74991
75236
|
next.activeBottomMargin = next.pendingBottomMargin;
|
|
74992
75237
|
}
|
|
75238
|
+
if (next.pendingLeftMargin != null) {
|
|
75239
|
+
next.activeLeftMargin = next.pendingLeftMargin;
|
|
75240
|
+
}
|
|
75241
|
+
if (next.pendingRightMargin != null) {
|
|
75242
|
+
next.activeRightMargin = next.pendingRightMargin;
|
|
75243
|
+
}
|
|
74993
75244
|
if (next.pendingHeaderDistance != null) {
|
|
74994
75245
|
next.activeHeaderDistance = next.pendingHeaderDistance;
|
|
74995
75246
|
}
|
|
@@ -75007,6 +75258,8 @@ function applyPendingToActive(state2) {
|
|
|
75007
75258
|
}
|
|
75008
75259
|
next.pendingTopMargin = null;
|
|
75009
75260
|
next.pendingBottomMargin = null;
|
|
75261
|
+
next.pendingLeftMargin = null;
|
|
75262
|
+
next.pendingRightMargin = null;
|
|
75010
75263
|
next.pendingHeaderDistance = null;
|
|
75011
75264
|
next.pendingFooterDistance = null;
|
|
75012
75265
|
next.pendingPageSize = null;
|
|
@@ -75235,7 +75488,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75235
75488
|
if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
|
|
75236
75489
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75237
75490
|
const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
|
|
75238
|
-
|
|
75491
|
+
const newLines = normalizeLines(newMeasure);
|
|
75492
|
+
lines = newLines;
|
|
75239
75493
|
didRemeasureForColumnWidth = true;
|
|
75240
75494
|
}
|
|
75241
75495
|
let fromLine = 0;
|
|
@@ -75317,7 +75571,8 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
75317
75571
|
if (narrowestRemeasureWidth < remeasureWidth) {
|
|
75318
75572
|
const firstLineIndent = calculateFirstLineIndent(block, measure);
|
|
75319
75573
|
const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
|
|
75320
|
-
|
|
75574
|
+
const newLines = normalizeLines(newMeasure);
|
|
75575
|
+
lines = newLines;
|
|
75321
75576
|
didRemeasureForFloats = true;
|
|
75322
75577
|
}
|
|
75323
75578
|
}
|
|
@@ -75661,6 +75916,94 @@ function getCellPadding(cellIdx, blockRow) {
|
|
|
75661
75916
|
function getCellTotalLines(cell) {
|
|
75662
75917
|
return getCellLines(cell).length;
|
|
75663
75918
|
}
|
|
75919
|
+
function mergePmRange(target, range2) {
|
|
75920
|
+
if (typeof range2.pmStart === "number") {
|
|
75921
|
+
target.pmStart = target.pmStart == null ? range2.pmStart : Math.min(target.pmStart, range2.pmStart);
|
|
75922
|
+
}
|
|
75923
|
+
if (typeof range2.pmEnd === "number") {
|
|
75924
|
+
target.pmEnd = target.pmEnd == null ? range2.pmEnd : Math.max(target.pmEnd, range2.pmEnd);
|
|
75925
|
+
}
|
|
75926
|
+
}
|
|
75927
|
+
function computeCellPmRange(cell, cellMeasure, fromLine, toLine) {
|
|
75928
|
+
const range2 = {};
|
|
75929
|
+
if (!cell || !cellMeasure) return range2;
|
|
75930
|
+
const cellBlocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
|
|
75931
|
+
const blockMeasures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
|
|
75932
|
+
const maxBlocks = Math.min(cellBlocks.length, blockMeasures.length);
|
|
75933
|
+
let cumulativeLineCount = 0;
|
|
75934
|
+
for (let i = 0; i < maxBlocks; i++) {
|
|
75935
|
+
const block = cellBlocks[i];
|
|
75936
|
+
const blockMeasure = blockMeasures[i];
|
|
75937
|
+
if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
|
|
75938
|
+
const paraMeasure = blockMeasure;
|
|
75939
|
+
const lines = paraMeasure.lines;
|
|
75940
|
+
const blockLineCount = lines?.length ?? 0;
|
|
75941
|
+
const blockStartGlobal = cumulativeLineCount;
|
|
75942
|
+
const blockEndGlobal = cumulativeLineCount + blockLineCount;
|
|
75943
|
+
const localFrom = Math.max(fromLine, blockStartGlobal) - blockStartGlobal;
|
|
75944
|
+
const localTo = Math.min(toLine, blockEndGlobal) - blockStartGlobal;
|
|
75945
|
+
if (lines && lines.length > 0 && localFrom < localTo) {
|
|
75946
|
+
mergePmRange(range2, computeFragmentPmRange(block, lines, localFrom, localTo));
|
|
75947
|
+
} else {
|
|
75948
|
+
mergePmRange(range2, extractBlockPmRange(block));
|
|
75949
|
+
}
|
|
75950
|
+
cumulativeLineCount += blockLineCount;
|
|
75951
|
+
continue;
|
|
75952
|
+
}
|
|
75953
|
+
mergePmRange(range2, extractBlockPmRange(block));
|
|
75954
|
+
}
|
|
75955
|
+
return range2;
|
|
75956
|
+
}
|
|
75957
|
+
function computeTableFragmentPmRange(block, measure, fromRow, toRow, partialRow) {
|
|
75958
|
+
const range2 = {};
|
|
75959
|
+
for (let rowIndex = fromRow; rowIndex < toRow; rowIndex++) {
|
|
75960
|
+
const row = block.rows[rowIndex];
|
|
75961
|
+
const rowMeasure = measure.rows[rowIndex];
|
|
75962
|
+
if (!row || !rowMeasure) continue;
|
|
75963
|
+
const isPartial = partialRow?.rowIndex === rowIndex;
|
|
75964
|
+
const cellCount = Math.min(row.cells.length, rowMeasure.cells.length);
|
|
75965
|
+
for (let cellIndex = 0; cellIndex < cellCount; cellIndex++) {
|
|
75966
|
+
const cell = row.cells[cellIndex];
|
|
75967
|
+
const cellMeasure = rowMeasure.cells[cellIndex];
|
|
75968
|
+
if (!cell || !cellMeasure) continue;
|
|
75969
|
+
const totalLines = getCellTotalLines(cellMeasure);
|
|
75970
|
+
let fromLine = 0;
|
|
75971
|
+
let toLine = totalLines;
|
|
75972
|
+
if (isPartial) {
|
|
75973
|
+
const hasValidFromLineByCell = partialRow?.fromLineByCell && cellIndex < partialRow.fromLineByCell.length;
|
|
75974
|
+
const hasValidToLineByCell = partialRow?.toLineByCell && cellIndex < partialRow.toLineByCell.length;
|
|
75975
|
+
if (hasValidFromLineByCell) {
|
|
75976
|
+
const rawFrom = partialRow.fromLineByCell[cellIndex];
|
|
75977
|
+
if (typeof rawFrom === "number" && rawFrom >= 0) {
|
|
75978
|
+
fromLine = rawFrom;
|
|
75979
|
+
}
|
|
75980
|
+
}
|
|
75981
|
+
if (hasValidToLineByCell) {
|
|
75982
|
+
const rawTo = partialRow.toLineByCell[cellIndex];
|
|
75983
|
+
if (typeof rawTo === "number") {
|
|
75984
|
+
toLine = rawTo === -1 ? totalLines : rawTo;
|
|
75985
|
+
}
|
|
75986
|
+
}
|
|
75987
|
+
}
|
|
75988
|
+
fromLine = Math.max(0, Math.min(fromLine, totalLines));
|
|
75989
|
+
toLine = Math.max(0, Math.min(toLine, totalLines));
|
|
75990
|
+
if (toLine < fromLine) {
|
|
75991
|
+
toLine = fromLine;
|
|
75992
|
+
}
|
|
75993
|
+
mergePmRange(range2, computeCellPmRange(cell, cellMeasure, fromLine, toLine));
|
|
75994
|
+
}
|
|
75995
|
+
}
|
|
75996
|
+
return range2;
|
|
75997
|
+
}
|
|
75998
|
+
function applyTableFragmentPmRange(fragment, block, measure) {
|
|
75999
|
+
const range2 = computeTableFragmentPmRange(block, measure, fragment.fromRow, fragment.toRow, fragment.partialRow);
|
|
76000
|
+
if (range2.pmStart != null) {
|
|
76001
|
+
fragment.pmStart = range2.pmStart;
|
|
76002
|
+
}
|
|
76003
|
+
if (range2.pmEnd != null) {
|
|
76004
|
+
fragment.pmEnd = range2.pmEnd;
|
|
76005
|
+
}
|
|
76006
|
+
}
|
|
75664
76007
|
function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLineByCell) {
|
|
75665
76008
|
const row = measure.rows[rowIndex];
|
|
75666
76009
|
if (!row) {
|
|
@@ -75805,6 +76148,7 @@ function layoutMonolithicTable(context) {
|
|
|
75805
76148
|
height,
|
|
75806
76149
|
metadata
|
|
75807
76150
|
};
|
|
76151
|
+
applyTableFragmentPmRange(fragment, context.block, context.measure);
|
|
75808
76152
|
state2.page.fragments.push(fragment);
|
|
75809
76153
|
state2.cursorY += height;
|
|
75810
76154
|
}
|
|
@@ -75883,6 +76227,7 @@ function layoutTableBlock({
|
|
|
75883
76227
|
height,
|
|
75884
76228
|
metadata
|
|
75885
76229
|
};
|
|
76230
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
75886
76231
|
state2.page.fragments.push(fragment);
|
|
75887
76232
|
state2.cursorY += height;
|
|
75888
76233
|
return;
|
|
@@ -75946,6 +76291,7 @@ function layoutTableBlock({
|
|
|
75946
76291
|
partialRow: continuationPartialRow,
|
|
75947
76292
|
metadata: generateFragmentMetadata(measure)
|
|
75948
76293
|
};
|
|
76294
|
+
applyTableFragmentPmRange(fragment2, block, measure);
|
|
75949
76295
|
state2.page.fragments.push(fragment2);
|
|
75950
76296
|
state2.cursorY += fragmentHeight2;
|
|
75951
76297
|
}
|
|
@@ -75990,6 +76336,7 @@ function layoutTableBlock({
|
|
|
75990
76336
|
partialRow: forcedPartialRow,
|
|
75991
76337
|
metadata: generateFragmentMetadata(measure)
|
|
75992
76338
|
};
|
|
76339
|
+
applyTableFragmentPmRange(fragment2, block, measure);
|
|
75993
76340
|
state2.page.fragments.push(fragment2);
|
|
75994
76341
|
state2.cursorY += fragmentHeight2;
|
|
75995
76342
|
pendingPartialRow = forcedPartialRow;
|
|
@@ -76025,6 +76372,7 @@ function layoutTableBlock({
|
|
|
76025
76372
|
partialRow: partialRow || void 0,
|
|
76026
76373
|
metadata: generateFragmentMetadata(measure)
|
|
76027
76374
|
};
|
|
76375
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
76028
76376
|
state2.page.fragments.push(fragment);
|
|
76029
76377
|
state2.cursorY += fragmentHeight;
|
|
76030
76378
|
if (partialRow && !partialRow.isLastPart) {
|
|
@@ -76042,7 +76390,7 @@ function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
|
76042
76390
|
columnBoundaries: generateColumnBoundaries(measure),
|
|
76043
76391
|
coordinateSystem: "fragment"
|
|
76044
76392
|
};
|
|
76045
|
-
|
|
76393
|
+
const fragment = {
|
|
76046
76394
|
kind: "table",
|
|
76047
76395
|
blockId: block.id,
|
|
76048
76396
|
fromRow: 0,
|
|
@@ -76053,6 +76401,8 @@ function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
|
76053
76401
|
height: measure.totalHeight ?? 0,
|
|
76054
76402
|
metadata
|
|
76055
76403
|
};
|
|
76404
|
+
applyTableFragmentPmRange(fragment, block, measure);
|
|
76405
|
+
return fragment;
|
|
76056
76406
|
}
|
|
76057
76407
|
function isPageRelativeAnchor(block) {
|
|
76058
76408
|
const vRelativeFrom = block.anchor?.vRelativeFrom;
|
|
@@ -76474,8 +76824,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76474
76824
|
header: options.margins?.header ?? options.margins?.top ?? DEFAULT_MARGINS$2.top,
|
|
76475
76825
|
footer: options.margins?.footer ?? options.margins?.bottom ?? DEFAULT_MARGINS$2.bottom
|
|
76476
76826
|
};
|
|
76477
|
-
const
|
|
76478
|
-
if (
|
|
76827
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
76828
|
+
if (baseContentWidth <= 0) {
|
|
76479
76829
|
throw new Error("layoutDocument: pageSize and margins yield non-positive content area");
|
|
76480
76830
|
}
|
|
76481
76831
|
const validateContentHeight = (height) => {
|
|
@@ -76505,8 +76855,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76505
76855
|
const effectiveBottomMargin = maxFooterContentHeight > 0 ? Math.max(margins.bottom, footerDistance + maxFooterContentHeight) : margins.bottom;
|
|
76506
76856
|
let activeTopMargin = effectiveTopMargin;
|
|
76507
76857
|
let activeBottomMargin = effectiveBottomMargin;
|
|
76858
|
+
let activeLeftMargin = margins.left;
|
|
76859
|
+
let activeRightMargin = margins.right;
|
|
76508
76860
|
let pendingTopMargin = null;
|
|
76509
76861
|
let pendingBottomMargin = null;
|
|
76862
|
+
let pendingLeftMargin = null;
|
|
76863
|
+
let pendingRightMargin = null;
|
|
76510
76864
|
let activeHeaderDistance = margins.header ?? margins.top;
|
|
76511
76865
|
let pendingHeaderDistance = null;
|
|
76512
76866
|
let activeFooterDistance = margins.footer ?? margins.bottom;
|
|
@@ -76519,10 +76873,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76519
76873
|
let pendingOrientation = null;
|
|
76520
76874
|
let activeVAlign = null;
|
|
76521
76875
|
let pendingVAlign = null;
|
|
76876
|
+
const paginatorMargins = { left: activeLeftMargin, right: activeRightMargin };
|
|
76522
76877
|
const floatManager = createFloatingObjectManager(
|
|
76523
|
-
normalizeColumns(activeColumns,
|
|
76524
|
-
{ left:
|
|
76525
|
-
|
|
76878
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76879
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76880
|
+
activePageSize.w
|
|
76526
76881
|
);
|
|
76527
76882
|
const nextSectionPropsAtBreak = computeNextSectionPropsAtBreak(blocks);
|
|
76528
76883
|
const scheduleSectionBreakCompat = (block, state2, baseMargins) => {
|
|
@@ -76539,22 +76894,38 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76539
76894
|
next.activeOrientation = block.orientation;
|
|
76540
76895
|
next.pendingOrientation = null;
|
|
76541
76896
|
}
|
|
76897
|
+
const headerDistance2 = typeof block.margins?.header === "number" ? Math.max(0, block.margins.header) : next.activeHeaderDistance;
|
|
76898
|
+
const footerDistance2 = typeof block.margins?.footer === "number" ? Math.max(0, block.margins.footer) : next.activeFooterDistance;
|
|
76899
|
+
const sectionTop = typeof block.margins?.top === "number" ? Math.max(0, block.margins.top) : baseMargins.top;
|
|
76900
|
+
const sectionBottom = typeof block.margins?.bottom === "number" ? Math.max(0, block.margins.bottom) : baseMargins.bottom;
|
|
76542
76901
|
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;
|
|
76902
|
+
next.activeHeaderDistance = headerDistance2;
|
|
76903
|
+
next.pendingHeaderDistance = headerDistance2;
|
|
76549
76904
|
}
|
|
76550
76905
|
if (block.margins?.footer !== void 0) {
|
|
76551
|
-
const footerDistance2 = Math.max(0, block.margins.footer);
|
|
76552
76906
|
next.activeFooterDistance = footerDistance2;
|
|
76553
76907
|
next.pendingFooterDistance = footerDistance2;
|
|
76908
|
+
}
|
|
76909
|
+
if (block.margins?.top !== void 0 || block.margins?.header !== void 0) {
|
|
76910
|
+
const requiredTop = maxHeaderContentHeight > 0 ? headerDistance2 + maxHeaderContentHeight : headerDistance2;
|
|
76911
|
+
next.activeTopMargin = Math.max(sectionTop, requiredTop);
|
|
76912
|
+
next.pendingTopMargin = next.activeTopMargin;
|
|
76913
|
+
}
|
|
76914
|
+
if (block.margins?.bottom !== void 0 || block.margins?.footer !== void 0) {
|
|
76554
76915
|
const requiredBottom = maxFooterContentHeight > 0 ? footerDistance2 + maxFooterContentHeight : footerDistance2;
|
|
76555
|
-
next.activeBottomMargin = Math.max(
|
|
76916
|
+
next.activeBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76556
76917
|
next.pendingBottomMargin = next.activeBottomMargin;
|
|
76557
76918
|
}
|
|
76919
|
+
if (block.margins?.left !== void 0) {
|
|
76920
|
+
const leftMargin = Math.max(0, block.margins.left);
|
|
76921
|
+
next.activeLeftMargin = leftMargin;
|
|
76922
|
+
next.pendingLeftMargin = leftMargin;
|
|
76923
|
+
}
|
|
76924
|
+
if (block.margins?.right !== void 0) {
|
|
76925
|
+
const rightMargin = Math.max(0, block.margins.right);
|
|
76926
|
+
next.activeRightMargin = rightMargin;
|
|
76927
|
+
next.pendingRightMargin = rightMargin;
|
|
76928
|
+
}
|
|
76558
76929
|
if (block.columns) {
|
|
76559
76930
|
next.activeColumns = { count: block.columns.count, gap: block.columns.gap };
|
|
76560
76931
|
next.pendingColumns = null;
|
|
@@ -76583,27 +76954,35 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76583
76954
|
const headerPx = block.margins?.header;
|
|
76584
76955
|
const footerPx = block.margins?.footer;
|
|
76585
76956
|
const topPx = block.margins?.top;
|
|
76957
|
+
const bottomPx = block.margins?.bottom;
|
|
76958
|
+
const leftPx = block.margins?.left;
|
|
76959
|
+
const rightPx = block.margins?.right;
|
|
76586
76960
|
const nextTop = next.pendingTopMargin ?? next.activeTopMargin;
|
|
76587
76961
|
const nextBottom = next.pendingBottomMargin ?? next.activeBottomMargin;
|
|
76962
|
+
const nextLeft = next.pendingLeftMargin ?? next.activeLeftMargin;
|
|
76963
|
+
const nextRight = next.pendingRightMargin ?? next.activeRightMargin;
|
|
76588
76964
|
const nextHeader = next.pendingHeaderDistance ?? next.activeHeaderDistance;
|
|
76589
76965
|
const nextFooter = next.pendingFooterDistance ?? next.activeFooterDistance;
|
|
76590
76966
|
next.pendingHeaderDistance = typeof headerPx === "number" ? Math.max(0, headerPx) : nextHeader;
|
|
76591
76967
|
next.pendingFooterDistance = typeof footerPx === "number" ? Math.max(0, footerPx) : nextFooter;
|
|
76592
76968
|
if (typeof headerPx === "number" || typeof topPx === "number") {
|
|
76593
|
-
const sectionTop = topPx
|
|
76969
|
+
const sectionTop = typeof topPx === "number" ? Math.max(0, topPx) : baseMargins.top;
|
|
76594
76970
|
const sectionHeader = next.pendingHeaderDistance;
|
|
76595
76971
|
const requiredTop = maxHeaderContentHeight > 0 ? sectionHeader + maxHeaderContentHeight : sectionHeader;
|
|
76596
76972
|
next.pendingTopMargin = Math.max(sectionTop, requiredTop);
|
|
76597
76973
|
} else {
|
|
76598
76974
|
next.pendingTopMargin = nextTop;
|
|
76599
76975
|
}
|
|
76600
|
-
if (typeof footerPx === "number") {
|
|
76976
|
+
if (typeof footerPx === "number" || typeof bottomPx === "number") {
|
|
76601
76977
|
const sectionFooter = next.pendingFooterDistance;
|
|
76978
|
+
const sectionBottom = typeof bottomPx === "number" ? Math.max(0, bottomPx) : baseMargins.bottom;
|
|
76602
76979
|
const requiredBottom = maxFooterContentHeight > 0 ? sectionFooter + maxFooterContentHeight : sectionFooter;
|
|
76603
|
-
next.pendingBottomMargin = Math.max(
|
|
76980
|
+
next.pendingBottomMargin = Math.max(sectionBottom, requiredBottom);
|
|
76604
76981
|
} else {
|
|
76605
76982
|
next.pendingBottomMargin = nextBottom;
|
|
76606
76983
|
}
|
|
76984
|
+
next.pendingLeftMargin = typeof leftPx === "number" ? Math.max(0, leftPx) : nextLeft;
|
|
76985
|
+
next.pendingRightMargin = typeof rightPx === "number" ? Math.max(0, rightPx) : nextRight;
|
|
76607
76986
|
if (block.pageSize) next.pendingPageSize = { w: block.pageSize.w, h: block.pageSize.h };
|
|
76608
76987
|
if (block.orientation) next.pendingOrientation = block.orientation;
|
|
76609
76988
|
const sectionType = block.type ?? "continuous";
|
|
@@ -76688,7 +77067,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76688
77067
|
let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
|
|
76689
77068
|
let pendingSectionIndex = null;
|
|
76690
77069
|
const paginator = createPaginator({
|
|
76691
|
-
margins:
|
|
77070
|
+
margins: paginatorMargins,
|
|
76692
77071
|
getActiveTopMargin: () => activeTopMargin,
|
|
76693
77072
|
getActiveBottomMargin: () => activeBottomMargin,
|
|
76694
77073
|
getActiveHeaderDistance: () => activeHeaderDistance,
|
|
@@ -76703,8 +77082,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76703
77082
|
const applied = applyPendingToActive({
|
|
76704
77083
|
activeTopMargin,
|
|
76705
77084
|
activeBottomMargin,
|
|
77085
|
+
activeLeftMargin,
|
|
77086
|
+
activeRightMargin,
|
|
76706
77087
|
pendingTopMargin,
|
|
76707
77088
|
pendingBottomMargin,
|
|
77089
|
+
pendingLeftMargin,
|
|
77090
|
+
pendingRightMargin,
|
|
76708
77091
|
activeHeaderDistance,
|
|
76709
77092
|
activeFooterDistance,
|
|
76710
77093
|
pendingHeaderDistance,
|
|
@@ -76719,8 +77102,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76719
77102
|
});
|
|
76720
77103
|
activeTopMargin = applied.activeTopMargin;
|
|
76721
77104
|
activeBottomMargin = applied.activeBottomMargin;
|
|
77105
|
+
activeLeftMargin = applied.activeLeftMargin;
|
|
77106
|
+
activeRightMargin = applied.activeRightMargin;
|
|
76722
77107
|
pendingTopMargin = applied.pendingTopMargin;
|
|
76723
77108
|
pendingBottomMargin = applied.pendingBottomMargin;
|
|
77109
|
+
pendingLeftMargin = applied.pendingLeftMargin;
|
|
77110
|
+
pendingRightMargin = applied.pendingRightMargin;
|
|
76724
77111
|
activeHeaderDistance = applied.activeHeaderDistance;
|
|
76725
77112
|
activeFooterDistance = applied.activeFooterDistance;
|
|
76726
77113
|
pendingHeaderDistance = applied.pendingHeaderDistance;
|
|
@@ -76732,6 +77119,14 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76732
77119
|
activeOrientation = applied.activeOrientation;
|
|
76733
77120
|
pendingOrientation = applied.pendingOrientation;
|
|
76734
77121
|
cachedColumnsState.state = null;
|
|
77122
|
+
paginatorMargins.left = activeLeftMargin;
|
|
77123
|
+
paginatorMargins.right = activeRightMargin;
|
|
77124
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77125
|
+
floatManager.setLayoutContext(
|
|
77126
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
77127
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
77128
|
+
activePageSize.w
|
|
77129
|
+
);
|
|
76735
77130
|
if (pendingNumbering) {
|
|
76736
77131
|
if (pendingNumbering.format) activeNumberFormat = pendingNumbering.format;
|
|
76737
77132
|
if (typeof pendingNumbering.start === "number" && Number.isFinite(pendingNumbering.start)) {
|
|
@@ -76776,7 +77171,7 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76776
77171
|
const getActiveColumnsForState = paginator.getActiveColumnsForState;
|
|
76777
77172
|
let cachedColumnsState = { state: null, constraintIndex: -2, contentWidth: -1, colsConfig: null, normalized: null };
|
|
76778
77173
|
const getCurrentColumns = () => {
|
|
76779
|
-
const currentContentWidth = activePageSize.w - (
|
|
77174
|
+
const currentContentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
76780
77175
|
const state2 = states[states.length - 1] ?? null;
|
|
76781
77176
|
const colsConfig = state2 ? getActiveColumnsForState(state2) : activeColumns;
|
|
76782
77177
|
const constraintIndex = state2 ? state2.activeConstraintIndex : -1;
|
|
@@ -76809,6 +77204,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76809
77204
|
layoutLog(` Current page: ${state2.page.number}, cursorY: ${state2.cursorY}`);
|
|
76810
77205
|
activeColumns = newColumns;
|
|
76811
77206
|
cachedColumnsState.state = null;
|
|
77207
|
+
const contentWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77208
|
+
floatManager.setLayoutContext(
|
|
77209
|
+
normalizeColumns(activeColumns, contentWidth),
|
|
77210
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
77211
|
+
activePageSize.w
|
|
77212
|
+
);
|
|
76812
77213
|
};
|
|
76813
77214
|
const anchoredByParagraph = collectAnchoredDrawings(blocks, measures);
|
|
76814
77215
|
const anchoredTablesByParagraph = collectAnchoredTables(blocks, measures);
|
|
@@ -76840,10 +77241,10 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76840
77241
|
if (alignV === "top") {
|
|
76841
77242
|
anchorY = offsetV;
|
|
76842
77243
|
} else if (alignV === "bottom") {
|
|
76843
|
-
const pageHeight = contentBottom + margins
|
|
77244
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76844
77245
|
anchorY = pageHeight - imageHeight + offsetV;
|
|
76845
77246
|
} else if (alignV === "center") {
|
|
76846
|
-
const pageHeight = contentBottom + margins
|
|
77247
|
+
const pageHeight = contentBottom + (state2.page.margins?.bottom ?? activeBottomMargin);
|
|
76847
77248
|
anchorY = (pageHeight - imageHeight) / 2 + offsetV;
|
|
76848
77249
|
} else {
|
|
76849
77250
|
anchorY = offsetV;
|
|
@@ -76854,11 +77255,11 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76854
77255
|
const anchorX = entry.block.anchor ? computeAnchorX(
|
|
76855
77256
|
entry.block.anchor,
|
|
76856
77257
|
state2.columnIndex,
|
|
76857
|
-
normalizeColumns(activeColumns,
|
|
77258
|
+
normalizeColumns(activeColumns, activePageSize.w - (activeLeftMargin + activeRightMargin)),
|
|
76858
77259
|
entry.measure.width,
|
|
76859
|
-
{ left:
|
|
77260
|
+
{ left: activeLeftMargin, right: activeRightMargin },
|
|
76860
77261
|
activePageSize.w
|
|
76861
|
-
) :
|
|
77262
|
+
) : activeLeftMargin;
|
|
76862
77263
|
floatManager.registerDrawing(entry.block, entry.measure, anchorY, state2.columnIndex, state2.page.number);
|
|
76863
77264
|
preRegisteredPositions.set(entry.block.id, { anchorX, anchorY, pageNumber: state2.page.number });
|
|
76864
77265
|
}
|
|
@@ -76896,8 +77297,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76896
77297
|
const sectionState = {
|
|
76897
77298
|
activeTopMargin,
|
|
76898
77299
|
activeBottomMargin,
|
|
77300
|
+
activeLeftMargin,
|
|
77301
|
+
activeRightMargin,
|
|
76899
77302
|
pendingTopMargin,
|
|
76900
77303
|
pendingBottomMargin,
|
|
77304
|
+
pendingLeftMargin,
|
|
77305
|
+
pendingRightMargin,
|
|
76901
77306
|
activeHeaderDistance,
|
|
76902
77307
|
activeFooterDistance,
|
|
76903
77308
|
pendingHeaderDistance,
|
|
@@ -76931,8 +77336,12 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
76931
77336
|
layoutLog(`[Layout] ========== END SECTION BREAK ==========`);
|
|
76932
77337
|
activeTopMargin = updatedState.activeTopMargin;
|
|
76933
77338
|
activeBottomMargin = updatedState.activeBottomMargin;
|
|
77339
|
+
activeLeftMargin = updatedState.activeLeftMargin;
|
|
77340
|
+
activeRightMargin = updatedState.activeRightMargin;
|
|
76934
77341
|
pendingTopMargin = updatedState.pendingTopMargin;
|
|
76935
77342
|
pendingBottomMargin = updatedState.pendingBottomMargin;
|
|
77343
|
+
pendingLeftMargin = updatedState.pendingLeftMargin;
|
|
77344
|
+
pendingRightMargin = updatedState.pendingRightMargin;
|
|
76936
77345
|
activeHeaderDistance = updatedState.activeHeaderDistance;
|
|
76937
77346
|
activeFooterDistance = updatedState.activeFooterDistance;
|
|
76938
77347
|
pendingHeaderDistance = updatedState.pendingHeaderDistance;
|
|
@@ -77070,8 +77479,8 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77070
77479
|
pageMargins: {
|
|
77071
77480
|
top: activeTopMargin,
|
|
77072
77481
|
bottom: activeBottomMargin,
|
|
77073
|
-
left:
|
|
77074
|
-
right:
|
|
77482
|
+
left: activeLeftMargin,
|
|
77483
|
+
right: activeRightMargin
|
|
77075
77484
|
},
|
|
77076
77485
|
columns: getCurrentColumns(),
|
|
77077
77486
|
placedAnchoredIds
|
|
@@ -77093,9 +77502,9 @@ function layoutDocument(blocks, measures, options = {}) {
|
|
|
77093
77502
|
const cols = getCurrentColumns();
|
|
77094
77503
|
let maxWidth;
|
|
77095
77504
|
if (relativeFrom === "page") {
|
|
77096
|
-
maxWidth = cols.count === 1 ? activePageSize.w -
|
|
77505
|
+
maxWidth = cols.count === 1 ? activePageSize.w - (activeLeftMargin + activeRightMargin) : activePageSize.w;
|
|
77097
77506
|
} else if (relativeFrom === "margin") {
|
|
77098
|
-
maxWidth = activePageSize.w -
|
|
77507
|
+
maxWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
77099
77508
|
} else {
|
|
77100
77509
|
maxWidth = cols.width;
|
|
77101
77510
|
}
|
|
@@ -77255,6 +77664,9 @@ function layoutHeaderFooter(blocks, measures, constraints) {
|
|
|
77255
77664
|
if (!Number.isFinite(height) || height <= 0) {
|
|
77256
77665
|
throw new Error("layoutHeaderFooter: height must be positive");
|
|
77257
77666
|
}
|
|
77667
|
+
const maxBehindDocOverflow = Math.max(192, height * 4);
|
|
77668
|
+
const minBehindDocY = -maxBehindDocOverflow;
|
|
77669
|
+
const maxBehindDocY = height + maxBehindDocOverflow;
|
|
77258
77670
|
const marginLeft = constraints.margins?.left ?? 0;
|
|
77259
77671
|
const transformedBlocks = marginLeft > 0 ? blocks.map((block) => {
|
|
77260
77672
|
const hasPageRelativeAnchor = (block.kind === "image" || block.kind === "drawing") && block.anchor?.hRelativeFrom === "page" && block.anchor.offsetH != null;
|
|
@@ -77285,6 +77697,18 @@ function layoutHeaderFooter(blocks, measures, constraints) {
|
|
|
77285
77697
|
if (idx == null) continue;
|
|
77286
77698
|
const block = blocks[idx];
|
|
77287
77699
|
const measure = measures[idx];
|
|
77700
|
+
const isAnchoredFragment = (fragment.kind === "image" || fragment.kind === "drawing") && fragment.isAnchored === true;
|
|
77701
|
+
if (isAnchoredFragment) {
|
|
77702
|
+
if (block.kind !== "image" && block.kind !== "drawing") {
|
|
77703
|
+
throw new Error(
|
|
77704
|
+
`Type mismatch: fragment kind is ${fragment.kind} but block kind is ${block.kind} for block ${block.id}`
|
|
77705
|
+
);
|
|
77706
|
+
}
|
|
77707
|
+
const anchoredBlock = block;
|
|
77708
|
+
if (anchoredBlock.anchor?.behindDoc && (fragment.y < minBehindDocY || fragment.y > maxBehindDocY)) {
|
|
77709
|
+
continue;
|
|
77710
|
+
}
|
|
77711
|
+
}
|
|
77288
77712
|
if (fragment.y < minY) minY = fragment.y;
|
|
77289
77713
|
let bottom2 = fragment.y;
|
|
77290
77714
|
if (fragment.kind === "para" && measure?.kind === "paragraph") {
|
|
@@ -78282,11 +78706,11 @@ function findWordBoundaries(blocks, pos) {
|
|
|
78282
78706
|
if (text.length === 0) return null;
|
|
78283
78707
|
const clampedPos = Math.max(0, Math.min(localPos, text.length));
|
|
78284
78708
|
let wordStart = clampedPos;
|
|
78285
|
-
while (wordStart > 0 && isWordChar(text[wordStart - 1])) {
|
|
78709
|
+
while (wordStart > 0 && isWordChar$2(text[wordStart - 1])) {
|
|
78286
78710
|
wordStart--;
|
|
78287
78711
|
}
|
|
78288
78712
|
let wordEnd = clampedPos;
|
|
78289
|
-
while (wordEnd < text.length && isWordChar(text[wordEnd])) {
|
|
78713
|
+
while (wordEnd < text.length && isWordChar$2(text[wordEnd])) {
|
|
78290
78714
|
wordEnd++;
|
|
78291
78715
|
}
|
|
78292
78716
|
if (wordStart === wordEnd) {
|
|
@@ -78349,7 +78773,7 @@ function findBlockAtPosition(blocks, pos) {
|
|
|
78349
78773
|
}
|
|
78350
78774
|
return null;
|
|
78351
78775
|
}
|
|
78352
|
-
function isWordChar(char) {
|
|
78776
|
+
function isWordChar$2(char) {
|
|
78353
78777
|
return /[\p{L}\p{N}_]/u.test(char);
|
|
78354
78778
|
}
|
|
78355
78779
|
function isWhitespace(char) {
|
|
@@ -78384,6 +78808,29 @@ function fontString(run2) {
|
|
|
78384
78808
|
function runText(run2) {
|
|
78385
78809
|
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
78386
78810
|
}
|
|
78811
|
+
const isWordChar$1 = (char) => {
|
|
78812
|
+
if (!char) return false;
|
|
78813
|
+
const code = char.charCodeAt(0);
|
|
78814
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
78815
|
+
};
|
|
78816
|
+
const capitalizeText$1 = (text, fullText, startOffset) => {
|
|
78817
|
+
if (!text) return text;
|
|
78818
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
78819
|
+
let result = "";
|
|
78820
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
78821
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
78822
|
+
const ch = text[i];
|
|
78823
|
+
result += isWordChar$1(ch) && !isWordChar$1(prevChar) ? ch.toUpperCase() : ch;
|
|
78824
|
+
}
|
|
78825
|
+
return result;
|
|
78826
|
+
};
|
|
78827
|
+
const applyTextTransform$1 = (text, transform, fullText, startOffset) => {
|
|
78828
|
+
if (!text || !transform || transform === "none") return text;
|
|
78829
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
78830
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
78831
|
+
if (transform === "capitalize") return capitalizeText$1(text, fullText, startOffset);
|
|
78832
|
+
return text;
|
|
78833
|
+
};
|
|
78387
78834
|
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
78388
78835
|
const TWIPS_PER_INCH$4 = 1440;
|
|
78389
78836
|
const PX_PER_INCH$3 = 96;
|
|
@@ -78392,6 +78839,13 @@ const TAB_EPSILON$1 = 0.1;
|
|
|
78392
78839
|
const WIDTH_FUDGE_PX = 0.5;
|
|
78393
78840
|
const twipsToPx$2 = (twips) => twips / TWIPS_PER_PX$1;
|
|
78394
78841
|
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
78842
|
+
const markerFontString = (run2) => {
|
|
78843
|
+
const size2 = run2?.fontSize ?? 16;
|
|
78844
|
+
const family = run2?.fontFamily ?? "Arial";
|
|
78845
|
+
const italic = run2?.italic ? "italic " : "";
|
|
78846
|
+
const bold = run2?.bold ? "bold " : "";
|
|
78847
|
+
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
78848
|
+
};
|
|
78395
78849
|
const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
|
|
78396
78850
|
const paragraphIndentTwips = {
|
|
78397
78851
|
left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
|
|
@@ -78422,7 +78876,9 @@ const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
|
|
|
78422
78876
|
};
|
|
78423
78877
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
78424
78878
|
const context = getCtx();
|
|
78425
|
-
const
|
|
78879
|
+
const fullText = runText(run2);
|
|
78880
|
+
const transform = isTextRun$2(run2) ? run2.textTransform : void 0;
|
|
78881
|
+
const text = applyTextTransform$1(fullText.slice(fromChar, toChar), transform, fullText, fromChar);
|
|
78426
78882
|
if (!context) {
|
|
78427
78883
|
const textRun = isTextRun$2(run2) ? run2 : null;
|
|
78428
78884
|
const size2 = textRun?.fontSize ?? 16;
|
|
@@ -78468,8 +78924,21 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
78468
78924
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
78469
78925
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
78470
78926
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof wordLayout?.textStartPx === "number" && Number.isFinite(wordLayout.textStartPx) ? wordLayout.textStartPx : void 0;
|
|
78471
|
-
const
|
|
78472
|
-
|
|
78927
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
78928
|
+
wordLayout,
|
|
78929
|
+
indentLeft,
|
|
78930
|
+
indentFirstLine,
|
|
78931
|
+
indentHanging,
|
|
78932
|
+
(markerText, marker) => {
|
|
78933
|
+
const context = getCtx();
|
|
78934
|
+
if (!context) return 0;
|
|
78935
|
+
context.font = markerFontString(marker.run);
|
|
78936
|
+
return context.measureText(markerText).width;
|
|
78937
|
+
}
|
|
78938
|
+
);
|
|
78939
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
78940
|
+
const treatAsHanging = !wordLayout?.marker && effectiveTextStartPx && indentLeft === 0 && indentHanging === 0;
|
|
78941
|
+
const firstLineWidth = typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - effectiveTextStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
78473
78942
|
const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
78474
78943
|
let currentRun = 0;
|
|
78475
78944
|
let currentChar = 0;
|
|
@@ -79009,7 +79478,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
79009
79478
|
if (dirty.deletedBlockIds.length > 0) {
|
|
79010
79479
|
measureCache.invalidate(dirty.deletedBlockIds);
|
|
79011
79480
|
}
|
|
79012
|
-
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options);
|
|
79481
|
+
const { measurementWidth, measurementHeight } = resolveMeasurementConstraints(options, nextBlocks);
|
|
79013
79482
|
if (measurementWidth <= 0 || measurementHeight <= 0) {
|
|
79014
79483
|
throw new Error("incrementalLayout: invalid measurement constraints resolved from options");
|
|
79015
79484
|
}
|
|
@@ -79278,7 +79747,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
79278
79747
|
const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
|
|
79279
79748
|
const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
79280
79749
|
const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
|
|
79281
|
-
function resolveMeasurementConstraints(options) {
|
|
79750
|
+
function resolveMeasurementConstraints(options, blocks) {
|
|
79282
79751
|
const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
|
|
79283
79752
|
const margins = {
|
|
79284
79753
|
top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
|
|
@@ -79286,23 +79755,41 @@ function resolveMeasurementConstraints(options) {
|
|
|
79286
79755
|
bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
|
|
79287
79756
|
left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
|
|
79288
79757
|
};
|
|
79289
|
-
const
|
|
79290
|
-
const
|
|
79291
|
-
const
|
|
79292
|
-
|
|
79758
|
+
const baseContentWidth = pageSize.w - (margins.left + margins.right);
|
|
79759
|
+
const baseContentHeight = pageSize.h - (margins.top + margins.bottom);
|
|
79760
|
+
const computeColumnWidth = (contentWidth, columns) => {
|
|
79761
|
+
if (!columns || columns.count <= 1) return contentWidth;
|
|
79293
79762
|
const gap = Math.max(0, columns.gap ?? 0);
|
|
79294
79763
|
const totalGap = gap * (columns.count - 1);
|
|
79295
|
-
|
|
79296
|
-
|
|
79297
|
-
|
|
79298
|
-
|
|
79299
|
-
|
|
79764
|
+
return (contentWidth - totalGap) / columns.count;
|
|
79765
|
+
};
|
|
79766
|
+
let measurementWidth = computeColumnWidth(baseContentWidth, options.columns);
|
|
79767
|
+
let measurementHeight = baseContentHeight;
|
|
79768
|
+
if (blocks && blocks.length > 0) {
|
|
79769
|
+
for (const block of blocks) {
|
|
79770
|
+
if (block.kind !== "sectionBreak") continue;
|
|
79771
|
+
const sectionPageSize = block.pageSize ?? pageSize;
|
|
79772
|
+
const sectionMargins = {
|
|
79773
|
+
top: normalizeMargin(block.margins?.top, margins.top),
|
|
79774
|
+
right: normalizeMargin(block.margins?.right, margins.right),
|
|
79775
|
+
bottom: normalizeMargin(block.margins?.bottom, margins.bottom),
|
|
79776
|
+
left: normalizeMargin(block.margins?.left, margins.left)
|
|
79300
79777
|
};
|
|
79778
|
+
const contentWidth = sectionPageSize.w - (sectionMargins.left + sectionMargins.right);
|
|
79779
|
+
const contentHeight = sectionPageSize.h - (sectionMargins.top + sectionMargins.bottom);
|
|
79780
|
+
if (contentWidth <= 0 || contentHeight <= 0) continue;
|
|
79781
|
+
const columnWidth = computeColumnWidth(contentWidth, block.columns ?? options.columns);
|
|
79782
|
+
if (columnWidth > measurementWidth) {
|
|
79783
|
+
measurementWidth = columnWidth;
|
|
79784
|
+
}
|
|
79785
|
+
if (contentHeight > measurementHeight) {
|
|
79786
|
+
measurementHeight = contentHeight;
|
|
79787
|
+
}
|
|
79301
79788
|
}
|
|
79302
79789
|
}
|
|
79303
79790
|
return {
|
|
79304
|
-
measurementWidth
|
|
79305
|
-
measurementHeight
|
|
79791
|
+
measurementWidth,
|
|
79792
|
+
measurementHeight
|
|
79306
79793
|
};
|
|
79307
79794
|
}
|
|
79308
79795
|
const serializeHeaderFooterResults = (kind, batch) => {
|
|
@@ -81369,6 +81856,7 @@ function isInRegisteredSurface(event) {
|
|
|
81369
81856
|
}
|
|
81370
81857
|
return false;
|
|
81371
81858
|
}
|
|
81859
|
+
const SLASH_MENU_HANDLED_FLAG = "__sdHandledBySlashMenu";
|
|
81372
81860
|
class PresentationInputBridge {
|
|
81373
81861
|
/**
|
|
81374
81862
|
* Creates a new PresentationInputBridge that forwards user input events from the visible layout
|
|
@@ -81582,6 +82070,10 @@ forwardCompositionEvent_fn = function(event) {
|
|
|
81582
82070
|
__privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
|
|
81583
82071
|
};
|
|
81584
82072
|
forwardContextMenu_fn = function(event) {
|
|
82073
|
+
const handledBySlashMenu = Boolean(event[SLASH_MENU_HANDLED_FLAG]);
|
|
82074
|
+
if (handledBySlashMenu) {
|
|
82075
|
+
return;
|
|
82076
|
+
}
|
|
81585
82077
|
if (!__privateGet$1(this, _isEditable).call(this)) {
|
|
81586
82078
|
return;
|
|
81587
82079
|
}
|
|
@@ -81687,14 +82179,15 @@ function getAtomNodeTypes(schema) {
|
|
|
81687
82179
|
if (!schema) return [];
|
|
81688
82180
|
const types2 = [];
|
|
81689
82181
|
try {
|
|
81690
|
-
schema.nodes
|
|
82182
|
+
for (const name in schema.nodes) {
|
|
81691
82183
|
if (name === "text") {
|
|
81692
|
-
|
|
82184
|
+
continue;
|
|
81693
82185
|
}
|
|
81694
|
-
|
|
82186
|
+
const nodeType = schema.nodes[name];
|
|
82187
|
+
if (nodeType && (nodeType.isAtom || nodeType.isLeaf)) {
|
|
81695
82188
|
types2.push(name);
|
|
81696
82189
|
}
|
|
81697
|
-
}
|
|
82190
|
+
}
|
|
81698
82191
|
} catch {
|
|
81699
82192
|
return [];
|
|
81700
82193
|
}
|
|
@@ -83097,6 +83590,7 @@ function shouldRequirePageBoundary(current, next) {
|
|
|
83097
83590
|
function hasIntrinsicBoundarySignals(_2) {
|
|
83098
83591
|
return false;
|
|
83099
83592
|
}
|
|
83593
|
+
const DEFAULT_HEADER_FOOTER_MARGIN_PX = 0;
|
|
83100
83594
|
function shouldIgnoreSectionBreak(paragraph, index2, total, hasBodySectPr) {
|
|
83101
83595
|
const paragraphAttrs = paragraph.attrs ?? {};
|
|
83102
83596
|
const paragraphProperties = paragraphAttrs?.paragraphProperties;
|
|
@@ -83137,14 +83631,15 @@ function buildSectionRangesFromParagraphs(paragraphs, hasBodySectPr) {
|
|
|
83137
83631
|
const sectionData = extractSectionData(item.node);
|
|
83138
83632
|
if (!sectionData) return;
|
|
83139
83633
|
const sectPr = getSectPrFromNode(item.node);
|
|
83634
|
+
const hasAnyMargin = sectionData.headerPx != null || sectionData.footerPx != null || sectionData.topPx != null || sectionData.rightPx != null || sectionData.bottomPx != null || sectionData.leftPx != null;
|
|
83140
83635
|
const range2 = {
|
|
83141
83636
|
sectionIndex: idx,
|
|
83142
83637
|
startParagraphIndex: currentStart,
|
|
83143
83638
|
endParagraphIndex: item.index,
|
|
83144
83639
|
sectPr,
|
|
83145
|
-
margins:
|
|
83146
|
-
header: sectionData.headerPx ??
|
|
83147
|
-
footer: sectionData.footerPx ??
|
|
83640
|
+
margins: hasAnyMargin ? {
|
|
83641
|
+
header: sectionData.headerPx ?? DEFAULT_HEADER_FOOTER_MARGIN_PX,
|
|
83642
|
+
footer: sectionData.footerPx ?? DEFAULT_HEADER_FOOTER_MARGIN_PX,
|
|
83148
83643
|
top: sectionData.topPx,
|
|
83149
83644
|
right: sectionData.rightPx,
|
|
83150
83645
|
bottom: sectionData.bottomPx,
|
|
@@ -83186,14 +83681,15 @@ function createFinalSectionFromBodySectPr(bodySectPr, currentStart, totalParagra
|
|
|
83186
83681
|
};
|
|
83187
83682
|
const bodySectionData = extractSectionData(tempNode);
|
|
83188
83683
|
if (!bodySectionData) return null;
|
|
83684
|
+
const hasAnyMargin = bodySectionData.headerPx != null || bodySectionData.footerPx != null || bodySectionData.topPx != null || bodySectionData.rightPx != null || bodySectionData.bottomPx != null || bodySectionData.leftPx != null;
|
|
83189
83685
|
return {
|
|
83190
83686
|
sectionIndex,
|
|
83191
83687
|
startParagraphIndex: currentStart,
|
|
83192
83688
|
endParagraphIndex: totalParagraphs - 1,
|
|
83193
83689
|
sectPr: bodySectPr,
|
|
83194
|
-
margins:
|
|
83195
|
-
header: bodySectionData.headerPx ??
|
|
83196
|
-
footer: bodySectionData.footerPx ??
|
|
83690
|
+
margins: hasAnyMargin ? {
|
|
83691
|
+
header: bodySectionData.headerPx ?? DEFAULT_HEADER_FOOTER_MARGIN_PX,
|
|
83692
|
+
footer: bodySectionData.footerPx ?? DEFAULT_HEADER_FOOTER_MARGIN_PX,
|
|
83197
83693
|
top: bodySectionData.topPx,
|
|
83198
83694
|
right: bodySectionData.rightPx,
|
|
83199
83695
|
bottom: bodySectionData.bottomPx,
|
|
@@ -84177,11 +84673,27 @@ const collectTrackedChangeFromMarks = (marks) => {
|
|
|
84177
84673
|
}, void 0);
|
|
84178
84674
|
};
|
|
84179
84675
|
const normalizeUnderlineStyle = (value) => {
|
|
84180
|
-
if (value ===
|
|
84181
|
-
return
|
|
84676
|
+
if (value === void 0 || value === null) {
|
|
84677
|
+
return "single";
|
|
84182
84678
|
}
|
|
84183
|
-
if (
|
|
84184
|
-
return value;
|
|
84679
|
+
if (typeof value === "boolean") {
|
|
84680
|
+
return value ? "single" : void 0;
|
|
84681
|
+
}
|
|
84682
|
+
if (typeof value === "number") {
|
|
84683
|
+
return value === 0 ? void 0 : "single";
|
|
84684
|
+
}
|
|
84685
|
+
if (typeof value === "string") {
|
|
84686
|
+
const normalized = value.trim().toLowerCase();
|
|
84687
|
+
if (!normalized) {
|
|
84688
|
+
return "single";
|
|
84689
|
+
}
|
|
84690
|
+
if (normalized === "none" || normalized === "0" || normalized === "false" || normalized === "off") {
|
|
84691
|
+
return void 0;
|
|
84692
|
+
}
|
|
84693
|
+
if (normalized === "double" || normalized === "dotted" || normalized === "dashed" || normalized === "wavy") {
|
|
84694
|
+
return normalized;
|
|
84695
|
+
}
|
|
84696
|
+
return "single";
|
|
84185
84697
|
}
|
|
84186
84698
|
return "single";
|
|
84187
84699
|
};
|
|
@@ -84333,13 +84845,16 @@ const applyMarksToRun = (run2, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG
|
|
|
84333
84845
|
break;
|
|
84334
84846
|
}
|
|
84335
84847
|
case "underline": {
|
|
84336
|
-
const
|
|
84848
|
+
const underlineValue = mark.attrs?.underlineType ?? mark.attrs?.value ?? mark.attrs?.underline ?? mark.attrs?.style;
|
|
84849
|
+
const style2 = normalizeUnderlineStyle(underlineValue);
|
|
84337
84850
|
if (style2) {
|
|
84338
84851
|
const underlineColor = resolveColorFromAttributes(mark.attrs ?? {}, themeColors);
|
|
84339
84852
|
run2.underline = {
|
|
84340
84853
|
style: style2,
|
|
84341
84854
|
color: underlineColor ?? run2.underline?.color
|
|
84342
84855
|
};
|
|
84856
|
+
} else if (underlineValue !== void 0 && underlineValue !== null) {
|
|
84857
|
+
delete run2.underline;
|
|
84343
84858
|
}
|
|
84344
84859
|
break;
|
|
84345
84860
|
}
|
|
@@ -85275,8 +85790,8 @@ function buildSdtCacheKey(nodeType, attrs, explicitKey) {
|
|
|
85275
85790
|
}
|
|
85276
85791
|
return void 0;
|
|
85277
85792
|
}
|
|
85278
|
-
const DEFAULT_LIST_HANGING_PX
|
|
85279
|
-
const LIST_MARKER_GAP
|
|
85793
|
+
const DEFAULT_LIST_HANGING_PX = 18;
|
|
85794
|
+
const LIST_MARKER_GAP = 8;
|
|
85280
85795
|
const DEFAULT_BULLET_GLYPH = "•";
|
|
85281
85796
|
const DEFAULT_DECIMAL_PATTERN = "%1.";
|
|
85282
85797
|
const ASCII_UPPERCASE_A = 65;
|
|
@@ -85687,7 +86202,7 @@ function computeWordParagraphLayout(input) {
|
|
|
85687
86202
|
let markerBoxWidthPx;
|
|
85688
86203
|
let markerX;
|
|
85689
86204
|
if (hasFirstLineIndent) {
|
|
85690
|
-
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP
|
|
86205
|
+
markerBoxWidthPx = glyphWidthPx != null && glyphWidthPx > 0 ? glyphWidthPx + LIST_MARKER_GAP : DEFAULT_LIST_HANGING_PX;
|
|
85691
86206
|
markerX = indentLeftPx + (firstLinePx ?? 0);
|
|
85692
86207
|
layout.textStartPx = markerX + markerBoxWidthPx;
|
|
85693
86208
|
layout.hangingPx = 0;
|
|
@@ -85787,12 +86302,12 @@ const resolveMarkerBoxWidth = (hangingPxRaw, glyphWidthPx) => {
|
|
|
85787
86302
|
let markerBox = Math.max(hangingPxRaw || 0, 0);
|
|
85788
86303
|
if (markerBox <= 0) {
|
|
85789
86304
|
if (glyphWidthPx != null && glyphWidthPx > 0) {
|
|
85790
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86305
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85791
86306
|
} else {
|
|
85792
|
-
markerBox = DEFAULT_LIST_HANGING_PX
|
|
86307
|
+
markerBox = DEFAULT_LIST_HANGING_PX;
|
|
85793
86308
|
}
|
|
85794
|
-
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP
|
|
85795
|
-
markerBox = glyphWidthPx + LIST_MARKER_GAP
|
|
86309
|
+
} else if (glyphWidthPx != null && glyphWidthPx + LIST_MARKER_GAP > markerBox) {
|
|
86310
|
+
markerBox = glyphWidthPx + LIST_MARKER_GAP;
|
|
85796
86311
|
}
|
|
85797
86312
|
return markerBox;
|
|
85798
86313
|
};
|
|
@@ -85812,7 +86327,7 @@ const buildMarkerLayout = ({
|
|
|
85812
86327
|
textStartX: textStartPx,
|
|
85813
86328
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
85814
86329
|
// Gutter is the small gap between marker and text, not the full marker box width
|
|
85815
|
-
gutterWidthPx: LIST_MARKER_GAP
|
|
86330
|
+
gutterWidthPx: LIST_MARKER_GAP,
|
|
85816
86331
|
justification: numbering.lvlJc ?? "left",
|
|
85817
86332
|
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
85818
86333
|
run: markerRun,
|
|
@@ -85902,7 +86417,10 @@ const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
|
85902
86417
|
tabStops: cloneIfObject(resolvedExtended.tabStops),
|
|
85903
86418
|
keepLines: resolvedExtended.keepLines,
|
|
85904
86419
|
keepNext: resolvedExtended.keepNext,
|
|
85905
|
-
numberingProperties: cloneIfObject(resolvedAsRecord.numberingProperties)
|
|
86420
|
+
numberingProperties: cloneIfObject(resolvedAsRecord.numberingProperties),
|
|
86421
|
+
// Extract contextualSpacing from style resolution - this is a sibling to spacing in OOXML,
|
|
86422
|
+
// not nested within it. When true, suppresses spacing between paragraphs of the same style.
|
|
86423
|
+
contextualSpacing: resolvedExtended.contextualSpacing
|
|
85906
86424
|
};
|
|
85907
86425
|
return hydrated;
|
|
85908
86426
|
};
|
|
@@ -86504,6 +87022,31 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
86504
87022
|
return null;
|
|
86505
87023
|
}
|
|
86506
87024
|
};
|
|
87025
|
+
const normalizeWordLayoutForIndent = (wordLayout, paragraphIndent) => {
|
|
87026
|
+
const resolvedIndent = wordLayout.resolvedIndent ?? paragraphIndent ?? {};
|
|
87027
|
+
const indentLeft = isFiniteNumber(resolvedIndent.left) ? resolvedIndent.left : 0;
|
|
87028
|
+
const firstLine = isFiniteNumber(resolvedIndent.firstLine) ? resolvedIndent.firstLine : 0;
|
|
87029
|
+
const hanging = isFiniteNumber(resolvedIndent.hanging) ? resolvedIndent.hanging : 0;
|
|
87030
|
+
const shouldFirstLineIndentMode = firstLine > 0 && !hanging;
|
|
87031
|
+
if (wordLayout.firstLineIndentMode === true && !shouldFirstLineIndentMode) {
|
|
87032
|
+
wordLayout.firstLineIndentMode = false;
|
|
87033
|
+
}
|
|
87034
|
+
if (wordLayout.firstLineIndentMode === true) {
|
|
87035
|
+
if (isFiniteNumber(wordLayout.textStartPx)) {
|
|
87036
|
+
if (wordLayout.marker && (!isFiniteNumber(wordLayout.marker.textStartX) || wordLayout.marker.textStartX !== wordLayout.textStartPx)) {
|
|
87037
|
+
wordLayout.marker.textStartX = wordLayout.textStartPx;
|
|
87038
|
+
}
|
|
87039
|
+
} else if (wordLayout.marker && isFiniteNumber(wordLayout.marker.textStartX)) {
|
|
87040
|
+
wordLayout.textStartPx = wordLayout.marker.textStartX;
|
|
87041
|
+
}
|
|
87042
|
+
} else {
|
|
87043
|
+
wordLayout.textStartPx = indentLeft;
|
|
87044
|
+
if (wordLayout.marker) {
|
|
87045
|
+
wordLayout.marker.textStartX = indentLeft;
|
|
87046
|
+
}
|
|
87047
|
+
}
|
|
87048
|
+
return wordLayout;
|
|
87049
|
+
};
|
|
86507
87050
|
const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
|
|
86508
87051
|
const attrs = para.attrs ?? {};
|
|
86509
87052
|
const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
|
|
@@ -86612,7 +87155,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86612
87155
|
paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
|
|
86613
87156
|
}
|
|
86614
87157
|
}
|
|
86615
|
-
const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing");
|
|
87158
|
+
const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing") ?? hydrated?.contextualSpacing;
|
|
86616
87159
|
if (contextualSpacingValue != null) {
|
|
86617
87160
|
paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
|
|
86618
87161
|
}
|
|
@@ -86826,8 +87369,11 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86826
87369
|
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
86827
87370
|
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86828
87371
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86829
|
-
const
|
|
86830
|
-
|
|
87372
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87373
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87374
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87375
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87376
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86831
87377
|
wordLayout = {
|
|
86832
87378
|
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
86833
87379
|
firstLineIndentMode: true,
|
|
@@ -86835,10 +87381,13 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86835
87381
|
};
|
|
86836
87382
|
}
|
|
86837
87383
|
}
|
|
86838
|
-
if (wordLayout &&
|
|
87384
|
+
if (wordLayout && !Number.isFinite(wordLayout.textStartPx) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
86839
87385
|
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
86840
|
-
const
|
|
86841
|
-
|
|
87386
|
+
const baseIndent = resolvedIndentPx ?? enrichedNumberingProps.resolvedLevelIndent;
|
|
87387
|
+
const mergedIndent = { ...baseIndent, ...paragraphAttrs.indent ?? {} };
|
|
87388
|
+
const firstLinePx = isFiniteNumber(mergedIndent.firstLine) ? mergedIndent.firstLine : 0;
|
|
87389
|
+
const hangingPx = isFiniteNumber(mergedIndent.hanging) ? mergedIndent.hanging : 0;
|
|
87390
|
+
if (firstLinePx > 0 && !hangingPx) {
|
|
86842
87391
|
wordLayout = {
|
|
86843
87392
|
...wordLayout,
|
|
86844
87393
|
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
@@ -86858,6 +87407,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
86858
87407
|
wordLayout.marker.suffix = listRendering.suffix;
|
|
86859
87408
|
}
|
|
86860
87409
|
}
|
|
87410
|
+
wordLayout = normalizeWordLayoutForIndent(wordLayout, paragraphAttrs.indent);
|
|
86861
87411
|
paragraphAttrs.wordLayout = wordLayout;
|
|
86862
87412
|
}
|
|
86863
87413
|
if (enrichedNumberingProps.resolvedLevelIndent) {
|
|
@@ -90974,11 +91524,6 @@ function initHeaderFooterRegistry({
|
|
|
90974
91524
|
cleanups
|
|
90975
91525
|
};
|
|
90976
91526
|
}
|
|
90977
|
-
const LIST_MARKER_GAP = 8;
|
|
90978
|
-
const MIN_MARKER_GUTTER = 24;
|
|
90979
|
-
const DEFAULT_LIST_INDENT_BASE_PX = 24;
|
|
90980
|
-
const DEFAULT_LIST_INDENT_STEP_PX = 24;
|
|
90981
|
-
const DEFAULT_LIST_HANGING_PX = 18;
|
|
90982
91527
|
function calculateRotatedBounds(input) {
|
|
90983
91528
|
const width = Math.max(0, input.width);
|
|
90984
91529
|
const height = Math.max(0, input.height);
|
|
@@ -91148,7 +91693,7 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
|
|
|
91148
91693
|
return Math.max(advanceWidth, paintedWidth);
|
|
91149
91694
|
}
|
|
91150
91695
|
const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
|
|
91151
|
-
const
|
|
91696
|
+
const WORD_SINGLE_LINE_SPACING_MULTIPLIER = 1.15;
|
|
91152
91697
|
function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
|
|
91153
91698
|
let ascent;
|
|
91154
91699
|
let descent;
|
|
@@ -91161,7 +91706,7 @@ function calculateTypographyMetrics(fontSize2, spacing, fontInfo) {
|
|
|
91161
91706
|
ascent = roundValue(fontSize2 * 0.8);
|
|
91162
91707
|
descent = roundValue(fontSize2 * 0.2);
|
|
91163
91708
|
}
|
|
91164
|
-
const baseLineHeight = Math.max(ascent + descent
|
|
91709
|
+
const baseLineHeight = Math.max(fontSize2 * WORD_SINGLE_LINE_SPACING_MULTIPLIER, ascent + descent, MIN_SINGLE_LINE_PX);
|
|
91165
91710
|
const lineHeight2 = roundValue(resolveLineHeight(spacing, baseLineHeight));
|
|
91166
91711
|
return {
|
|
91167
91712
|
ascent,
|
|
@@ -91242,8 +91787,25 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91242
91787
|
const rawTextStartPx = wordLayout?.textStartPx;
|
|
91243
91788
|
const markerTextStartX = wordLayout?.marker?.textStartX;
|
|
91244
91789
|
const textStartPx = typeof markerTextStartX === "number" && Number.isFinite(markerTextStartX) ? markerTextStartX : typeof rawTextStartPx === "number" && Number.isFinite(rawTextStartPx) ? rawTextStartPx : void 0;
|
|
91245
|
-
|
|
91246
|
-
|
|
91790
|
+
const resolvedTextStartPx = resolveListTextStartPx(
|
|
91791
|
+
wordLayout,
|
|
91792
|
+
indentLeft,
|
|
91793
|
+
firstLine,
|
|
91794
|
+
hanging,
|
|
91795
|
+
(markerText, marker) => {
|
|
91796
|
+
const markerRun = {
|
|
91797
|
+
fontFamily: toCssFontFamily(marker.run?.fontFamily) ?? marker.run?.fontFamily ?? "Arial",
|
|
91798
|
+
fontSize: marker.run?.fontSize ?? 16,
|
|
91799
|
+
bold: marker.run?.bold ?? false,
|
|
91800
|
+
italic: marker.run?.italic ?? false
|
|
91801
|
+
};
|
|
91802
|
+
const { font: markerFont } = buildFontString(markerRun);
|
|
91803
|
+
return measureText(markerText, markerFont, ctx2);
|
|
91804
|
+
}
|
|
91805
|
+
);
|
|
91806
|
+
const effectiveTextStartPx = resolvedTextStartPx ?? textStartPx;
|
|
91807
|
+
if (typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft) {
|
|
91808
|
+
initialAvailableWidth = Math.max(1, maxWidth - effectiveTextStartPx - indentRight);
|
|
91247
91809
|
} else {
|
|
91248
91810
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
91249
91811
|
}
|
|
@@ -91330,7 +91892,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91330
91892
|
pendingTabAlignment = null;
|
|
91331
91893
|
return startX;
|
|
91332
91894
|
};
|
|
91333
|
-
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
91895
|
+
const alignSegmentAtTab = (segmentText, font, runContext, segmentStartChar) => {
|
|
91334
91896
|
if (!pendingTabAlignment || !currentLine) return void 0;
|
|
91335
91897
|
const { val } = pendingTabAlignment;
|
|
91336
91898
|
let segmentWidth = 0;
|
|
@@ -91339,11 +91901,11 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91339
91901
|
const idx = segmentText.indexOf(decimalSeparator);
|
|
91340
91902
|
if (idx >= 0) {
|
|
91341
91903
|
const beforeText = segmentText.slice(0, idx);
|
|
91342
|
-
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext) : 0;
|
|
91904
|
+
beforeDecimalWidth = beforeText.length > 0 ? measureRunWidth(beforeText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91343
91905
|
}
|
|
91344
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91906
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91345
91907
|
} else if (val === "end" || val === "center") {
|
|
91346
|
-
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext) : 0;
|
|
91908
|
+
segmentWidth = segmentText.length > 0 ? measureRunWidth(segmentText, font, ctx2, runContext, segmentStartChar) : 0;
|
|
91347
91909
|
}
|
|
91348
91910
|
return alignPendingTabForWidth(segmentWidth, beforeDecimalWidth);
|
|
91349
91911
|
};
|
|
@@ -91395,8 +91957,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91395
91957
|
const { font } = buildFontString(
|
|
91396
91958
|
lastRun
|
|
91397
91959
|
);
|
|
91398
|
-
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun);
|
|
91399
|
-
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun) : 0;
|
|
91960
|
+
const fullWidth = measureRunWidth(sliceText, font, ctx2, lastRun, sliceStart);
|
|
91961
|
+
const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx2, lastRun, sliceStart) : 0;
|
|
91400
91962
|
const delta = Math.max(0, fullWidth - keptWidth);
|
|
91401
91963
|
lineToTrim.width = roundValue(Math.max(0, lineToTrim.width - delta));
|
|
91402
91964
|
lineToTrim.spaceCount = Math.max(0, lineToTrim.spaceCount - trimCount);
|
|
@@ -91607,7 +92169,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91607
92169
|
continue;
|
|
91608
92170
|
}
|
|
91609
92171
|
if (isFieldAnnotationRun(run2)) {
|
|
91610
|
-
const
|
|
92172
|
+
const rawDisplayText = run2.displayLabel || "";
|
|
92173
|
+
const displayText = applyTextTransform(rawDisplayText, run2);
|
|
91611
92174
|
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;
|
|
91612
92175
|
const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
|
|
91613
92176
|
const fontWeight = run2.bold ? "bold" : "normal";
|
|
@@ -91710,7 +92273,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91710
92273
|
const spacesLength = segment.length;
|
|
91711
92274
|
const spacesStartChar = charPosInRun;
|
|
91712
92275
|
const spacesEndChar = charPosInRun + spacesLength;
|
|
91713
|
-
const spacesWidth = measureRunWidth(segment, font, ctx2, run2);
|
|
92276
|
+
const spacesWidth = measureRunWidth(segment, font, ctx2, run2, spacesStartChar);
|
|
91714
92277
|
if (!currentLine) {
|
|
91715
92278
|
currentLine = {
|
|
91716
92279
|
fromRun: runIndex,
|
|
@@ -91774,7 +92337,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91774
92337
|
}
|
|
91775
92338
|
let segmentStartX;
|
|
91776
92339
|
if (currentLine && pendingTabAlignment) {
|
|
91777
|
-
segmentStartX = alignSegmentAtTab(segment, font, run2);
|
|
92340
|
+
segmentStartX = alignSegmentAtTab(segment, font, run2, charPosInRun);
|
|
91778
92341
|
if (segmentStartX == null) {
|
|
91779
92342
|
segmentStartX = currentLine.width;
|
|
91780
92343
|
}
|
|
@@ -91784,7 +92347,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91784
92347
|
if (word2 === "") {
|
|
91785
92348
|
const spaceStartChar = charPosInRun;
|
|
91786
92349
|
const spaceEndChar = charPosInRun + 1;
|
|
91787
|
-
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2);
|
|
92350
|
+
const singleSpaceWidth = measureRunWidth(" ", font, ctx2, run2, spaceStartChar);
|
|
91788
92351
|
if (!currentLine) {
|
|
91789
92352
|
currentLine = {
|
|
91790
92353
|
fromRun: runIndex,
|
|
@@ -91835,12 +92398,12 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91835
92398
|
charPosInRun = spaceEndChar;
|
|
91836
92399
|
continue;
|
|
91837
92400
|
}
|
|
91838
|
-
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2);
|
|
91839
|
-
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91840
|
-
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2) : 0;
|
|
91841
|
-
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91842
92401
|
const wordStartChar = charPosInRun;
|
|
92402
|
+
const wordOnlyWidth = measureRunWidth(word2, font, ctx2, run2, wordStartChar);
|
|
92403
|
+
const shouldIncludeDelimiterSpace = wordIndex < lastNonEmptyWordIndex;
|
|
91843
92404
|
const wordEndNoSpace = charPosInRun + word2.length;
|
|
92405
|
+
const spaceWidth = shouldIncludeDelimiterSpace ? measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) : 0;
|
|
92406
|
+
const wordCommitWidth = wordOnlyWidth + spaceWidth;
|
|
91844
92407
|
const wordEndWithSpace = wordEndNoSpace + (shouldIncludeDelimiterSpace ? 1 : 0);
|
|
91845
92408
|
const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
|
|
91846
92409
|
if (wordOnlyWidth > effectiveMaxWidth && word2.length > 1) {
|
|
@@ -91859,7 +92422,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91859
92422
|
const hasTabOnlyLine = currentLine && currentLine.segments && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
91860
92423
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
91861
92424
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
91862
|
-
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
|
|
92425
|
+
const chunks = breakWordIntoChunks(word2, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2, wordStartChar);
|
|
91863
92426
|
let chunkCharOffset = wordStartChar;
|
|
91864
92427
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
91865
92428
|
const chunk = chunks[chunkIndex];
|
|
@@ -91983,7 +92546,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
91983
92546
|
if (candidateSpaces > 0) {
|
|
91984
92547
|
const overflow = totalWidthWithWord - availableWidth;
|
|
91985
92548
|
if (overflow > 0) {
|
|
91986
|
-
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2) || Math.max(1, boundarySpacing);
|
|
92549
|
+
const baseSpaceWidth = spaceWidth || measureRunWidth(" ", font, ctx2, run2, wordEndNoSpace) || Math.max(1, boundarySpacing);
|
|
91987
92550
|
const perSpaceCompression = overflow / candidateSpaces;
|
|
91988
92551
|
const maxPerSpaceCompression = baseSpaceWidth * 0.25;
|
|
91989
92552
|
if (perSpaceCompression <= maxPerSpaceCompression) {
|
|
@@ -92158,8 +92721,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
92158
92721
|
const { font: markerFont } = buildFontString(markerRun);
|
|
92159
92722
|
const markerText = wordLayout.marker.markerText ?? "";
|
|
92160
92723
|
const glyphWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92161
|
-
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP;
|
|
92162
|
-
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP);
|
|
92724
|
+
const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : LIST_MARKER_GAP$1;
|
|
92725
|
+
const markerBoxWidth = Math.max(wordLayout.marker.markerBoxWidthPx ?? 0, glyphWidth + LIST_MARKER_GAP$1);
|
|
92163
92726
|
markerInfo = {
|
|
92164
92727
|
markerWidth: markerBoxWidth,
|
|
92165
92728
|
markerTextWidth: glyphWidth,
|
|
@@ -92503,7 +93066,7 @@ async function measureListBlock(block, constraints) {
|
|
|
92503
93066
|
markerTextWidth = markerText ? measureText(markerText, markerFont, ctx2) : 0;
|
|
92504
93067
|
indentLeft = resolveIndentLeft(item);
|
|
92505
93068
|
const indentHanging = resolveIndentHanging(item);
|
|
92506
|
-
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP, indentHanging);
|
|
93069
|
+
markerWidth = Math.max(MIN_MARKER_GUTTER, markerTextWidth + LIST_MARKER_GAP$1, indentHanging);
|
|
92507
93070
|
}
|
|
92508
93071
|
const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
|
|
92509
93072
|
const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
|
|
@@ -92529,16 +93092,46 @@ const getPrimaryRun = (paragraph) => {
|
|
|
92529
93092
|
fontSize: 16
|
|
92530
93093
|
};
|
|
92531
93094
|
};
|
|
92532
|
-
const
|
|
93095
|
+
const isWordChar = (char) => {
|
|
93096
|
+
if (!char) return false;
|
|
93097
|
+
const code = char.charCodeAt(0);
|
|
93098
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "'";
|
|
93099
|
+
};
|
|
93100
|
+
const capitalizeText = (text, fullText, startOffset) => {
|
|
93101
|
+
if (!text) return text;
|
|
93102
|
+
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
93103
|
+
let result = "";
|
|
93104
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
93105
|
+
const prevChar = hasFullText ? startOffset + i > 0 ? fullText[startOffset + i - 1] : "" : i > 0 ? text[i - 1] : "";
|
|
93106
|
+
const ch = text[i];
|
|
93107
|
+
result += isWordChar(ch) && !isWordChar(prevChar) ? ch.toUpperCase() : ch;
|
|
93108
|
+
}
|
|
93109
|
+
return result;
|
|
93110
|
+
};
|
|
93111
|
+
const applyTextTransform = (text, run2, startOffset) => {
|
|
93112
|
+
const transform = "textTransform" in run2 ? run2.textTransform : void 0;
|
|
93113
|
+
if (!text || !transform || transform === "none") return text;
|
|
93114
|
+
if (transform === "uppercase") return text.toUpperCase();
|
|
93115
|
+
if (transform === "lowercase") return text.toLowerCase();
|
|
93116
|
+
if (transform === "capitalize") {
|
|
93117
|
+
const fullText = "text" in run2 && typeof run2.text === "string" ? run2.text : text;
|
|
93118
|
+
return capitalizeText(text, fullText, startOffset);
|
|
93119
|
+
}
|
|
93120
|
+
return text;
|
|
93121
|
+
};
|
|
93122
|
+
const measureRunWidth = (text, font, ctx2, run2, startOffset) => {
|
|
92533
93123
|
const letterSpacing = run2.kind === "text" || run2.kind === void 0 ? run2.letterSpacing || 0 : 0;
|
|
92534
|
-
const
|
|
93124
|
+
const displayText = applyTextTransform(text, run2, startOffset);
|
|
93125
|
+
const width = getMeasuredTextWidth(displayText, font, letterSpacing, ctx2);
|
|
92535
93126
|
return roundValue(width);
|
|
92536
93127
|
};
|
|
92537
|
-
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
93128
|
+
const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2, startOffset) => {
|
|
92538
93129
|
const chunks = [];
|
|
93130
|
+
const baseOffset = typeof startOffset === "number" ? startOffset : 0;
|
|
92539
93131
|
if (maxWidth <= 0) {
|
|
92540
|
-
for (
|
|
92541
|
-
const
|
|
93132
|
+
for (let i = 0; i < word2.length; i++) {
|
|
93133
|
+
const char = word2[i];
|
|
93134
|
+
const charWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92542
93135
|
chunks.push({ text: char, width: charWidth });
|
|
92543
93136
|
}
|
|
92544
93137
|
return chunks;
|
|
@@ -92548,11 +93141,11 @@ const breakWordIntoChunks = (word2, maxWidth, font, ctx2, run2) => {
|
|
|
92548
93141
|
for (let i = 0; i < word2.length; i++) {
|
|
92549
93142
|
const char = word2[i];
|
|
92550
93143
|
const testChunk = currentChunk + char;
|
|
92551
|
-
const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
|
|
93144
|
+
const testWidth = measureRunWidth(testChunk, font, ctx2, run2, baseOffset);
|
|
92552
93145
|
if (testWidth > maxWidth && currentChunk.length > 0) {
|
|
92553
93146
|
chunks.push({ text: currentChunk, width: currentWidth });
|
|
92554
93147
|
currentChunk = char;
|
|
92555
|
-
currentWidth = measureRunWidth(char, font, ctx2, run2);
|
|
93148
|
+
currentWidth = measureRunWidth(char, font, ctx2, run2, baseOffset + i);
|
|
92556
93149
|
} else {
|
|
92557
93150
|
currentChunk = testChunk;
|
|
92558
93151
|
currentWidth = testWidth;
|
|
@@ -92606,12 +93199,13 @@ const measureDropCap = (ctx2, descriptor, spacing) => {
|
|
|
92606
93199
|
italic: run2.italic
|
|
92607
93200
|
});
|
|
92608
93201
|
ctx2.font = font;
|
|
92609
|
-
const
|
|
93202
|
+
const displayText = applyTextTransform(run2.text, run2);
|
|
93203
|
+
const metrics = ctx2.measureText(displayText);
|
|
92610
93204
|
const advanceWidth = metrics.width;
|
|
92611
93205
|
const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
|
|
92612
93206
|
const textWidth = Math.max(advanceWidth, paintedWidth);
|
|
92613
93207
|
const width = roundValue(textWidth + DROP_CAP_PADDING_PX);
|
|
92614
|
-
const baseLineHeight = resolveLineHeight(spacing, run2.fontSize *
|
|
93208
|
+
const baseLineHeight = resolveLineHeight(spacing, run2.fontSize * WORD_SINGLE_LINE_SPACING_MULTIPLIER);
|
|
92615
93209
|
const height = roundValue(baseLineHeight * lines);
|
|
92616
93210
|
return {
|
|
92617
93211
|
width,
|
|
@@ -92632,7 +93226,7 @@ const resolveIndentHanging = (item) => {
|
|
|
92632
93226
|
if (indentHanging > 0) {
|
|
92633
93227
|
return indentHanging;
|
|
92634
93228
|
}
|
|
92635
|
-
return DEFAULT_LIST_HANGING_PX;
|
|
93229
|
+
return DEFAULT_LIST_HANGING_PX$1;
|
|
92636
93230
|
};
|
|
92637
93231
|
const buildTabStopsPx = (indent, tabs, tabIntervalTwips) => {
|
|
92638
93232
|
const paragraphIndentTwips = {
|
|
@@ -92838,6 +93432,9 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
92838
93432
|
if (event.button !== 0) {
|
|
92839
93433
|
return;
|
|
92840
93434
|
}
|
|
93435
|
+
if (event.ctrlKey && navigator.platform.includes("Mac")) {
|
|
93436
|
+
return;
|
|
93437
|
+
}
|
|
92841
93438
|
__privateSet(this, _pendingMarginClick, null);
|
|
92842
93439
|
const target = event.target;
|
|
92843
93440
|
if (target?.closest?.(".superdoc-ruler-handle") != null) {
|
|
@@ -98247,6 +98844,8 @@ const SlashMenu = Extension.create({
|
|
|
98247
98844
|
const cbRect = containingBlock.getBoundingClientRect();
|
|
98248
98845
|
left2 -= cbRect.left;
|
|
98249
98846
|
top2 -= cbRect.top;
|
|
98847
|
+
left2 += containingBlock.scrollLeft || 0;
|
|
98848
|
+
top2 += containingBlock.scrollTop || 0;
|
|
98250
98849
|
} catch (error) {
|
|
98251
98850
|
console.warn("SlashMenu: Failed to adjust for containing block", error);
|
|
98252
98851
|
}
|
|
@@ -129585,7 +130184,7 @@ const _sfc_main$8 = {
|
|
|
129585
130184
|
if (open) {
|
|
129586
130185
|
vue.nextTick(() => {
|
|
129587
130186
|
if (searchInput.value) {
|
|
129588
|
-
searchInput.value.focus();
|
|
130187
|
+
searchInput.value.focus({ preventScroll: true });
|
|
129589
130188
|
}
|
|
129590
130189
|
});
|
|
129591
130190
|
}
|
|
@@ -129690,15 +130289,31 @@ const _sfc_main$8 = {
|
|
|
129690
130289
|
};
|
|
129691
130290
|
const handleGlobalOutsideClick = (event) => {
|
|
129692
130291
|
if (isOpen.value && menuRef.value && !menuRef.value.contains(event.target)) {
|
|
129693
|
-
|
|
130292
|
+
const isCtrlClickOnMac = event.ctrlKey && isMacOS();
|
|
130293
|
+
const isLeftClick = event.button === 0 && !isCtrlClickOnMac;
|
|
130294
|
+
if (isLeftClick) {
|
|
130295
|
+
moveCursorToMouseEvent(event, props.editor);
|
|
130296
|
+
}
|
|
129694
130297
|
closeMenu({ restoreCursor: false });
|
|
129695
130298
|
}
|
|
129696
130299
|
};
|
|
129697
|
-
const
|
|
130300
|
+
const shouldHandleContextMenu = (event) => {
|
|
129698
130301
|
const readOnly = !props.editor?.isEditable;
|
|
129699
130302
|
const contextMenuDisabled = props.editor?.options?.disableContextMenu;
|
|
129700
130303
|
const bypass = shouldBypassContextMenu(event);
|
|
129701
|
-
|
|
130304
|
+
return !readOnly && !contextMenuDisabled && !bypass;
|
|
130305
|
+
};
|
|
130306
|
+
const handleRightClickCapture = (event) => {
|
|
130307
|
+
try {
|
|
130308
|
+
if (shouldHandleContextMenu(event)) {
|
|
130309
|
+
event[SLASH_MENU_HANDLED_FLAG] = true;
|
|
130310
|
+
}
|
|
130311
|
+
} catch (error) {
|
|
130312
|
+
console.warn("[SlashMenu] Error in capture phase context menu handler:", error);
|
|
130313
|
+
}
|
|
130314
|
+
};
|
|
130315
|
+
const handleRightClick = async (event) => {
|
|
130316
|
+
if (!shouldHandleContextMenu(event)) {
|
|
129702
130317
|
return;
|
|
129703
130318
|
}
|
|
129704
130319
|
event.preventDefault();
|
|
@@ -129809,6 +130424,7 @@ const _sfc_main$8 = {
|
|
|
129809
130424
|
props.editor.on("slashMenu:open", slashMenuOpenHandler);
|
|
129810
130425
|
contextMenuTarget = getEditorSurfaceElement(props.editor);
|
|
129811
130426
|
if (contextMenuTarget) {
|
|
130427
|
+
contextMenuTarget.addEventListener("contextmenu", handleRightClickCapture, true);
|
|
129812
130428
|
contextMenuTarget.addEventListener("contextmenu", handleRightClick);
|
|
129813
130429
|
}
|
|
129814
130430
|
slashMenuCloseHandler = () => {
|
|
@@ -129832,6 +130448,7 @@ const _sfc_main$8 = {
|
|
|
129832
130448
|
props.editor.off("slashMenu:close", slashMenuCloseHandler);
|
|
129833
130449
|
}
|
|
129834
130450
|
props.editor.off("update", handleEditorUpdate);
|
|
130451
|
+
contextMenuTarget?.removeEventListener("contextmenu", handleRightClickCapture, true);
|
|
129835
130452
|
contextMenuTarget?.removeEventListener("contextmenu", handleRightClick);
|
|
129836
130453
|
} catch (error) {
|
|
129837
130454
|
console.warn("[SlashMenu] Error during cleanup:", error);
|
|
@@ -131798,6 +132415,12 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
131798
132415
|
if (props.options?.suppressSkeletonLoader || !props.options?.collaborationProvider) editorReady.value = true;
|
|
131799
132416
|
});
|
|
131800
132417
|
const handleMarginClick = (event) => {
|
|
132418
|
+
if (event.button !== 0) {
|
|
132419
|
+
return;
|
|
132420
|
+
}
|
|
132421
|
+
if (event.ctrlKey && isMacOS()) {
|
|
132422
|
+
return;
|
|
132423
|
+
}
|
|
131801
132424
|
if (event.target.classList.contains("ProseMirror")) return;
|
|
131802
132425
|
onMarginClickCursorChange(event, activeEditor.value);
|
|
131803
132426
|
};
|
|
@@ -131936,7 +132559,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
131936
132559
|
};
|
|
131937
132560
|
}
|
|
131938
132561
|
});
|
|
131939
|
-
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
132562
|
+
const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-c9a3c876"]]);
|
|
131940
132563
|
const _hoisted_1 = ["innerHTML"];
|
|
131941
132564
|
const _sfc_main = {
|
|
131942
132565
|
__name: "SuperInput",
|