@harbour-enterprises/superdoc 1.0.0-beta.96 → 1.0.0-beta.98
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-Cdp1WJ9e.es.js → PdfViewer-1_KffD-j.es.js} +1 -1
- package/dist/chunks/{PdfViewer-BGTfnD4T.cjs → PdfViewer-D1Ot32kX.cjs} +1 -1
- package/dist/chunks/{index-BV9YtiyI.es.js → index-CP2_WwLA.es.js} +3 -3
- package/dist/chunks/{index-C-IS20yQ.cjs → index-CUO7gEi8.cjs} +3 -3
- package/dist/chunks/{index-lfdM_gm7-_EQjLyqH.es.js → index-Dg_sTYZK-D20z8mus.es.js} +1 -1
- package/dist/chunks/{index-lfdM_gm7-qtx-V4oF.cjs → index-Dg_sTYZK-DYDzxoXL.cjs} +1 -1
- package/dist/chunks/{super-editor.es-De2XS3A1.es.js → super-editor.es-3dJOUw65.es.js} +281 -201
- package/dist/chunks/{super-editor.es-D2zn943K.cjs → super-editor.es-DN_dgBH0.cjs} +281 -201
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-B29ATZFC.js → converter-Oj-eTB79.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-BPktKUBx.js → docx-zipper-Dl188zQ3.js} +1 -1
- package/dist/super-editor/chunks/{editor-BRHMYtPA.js → editor-DBXoaaWP.js} +282 -202
- package/dist/super-editor/chunks/{index-lfdM_gm7.js → index-Dg_sTYZK.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-CB2cJCLh.js → toolbar-PlGGj0Ew.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +283 -203
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -42421,7 +42421,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42421
42421
|
static getStoredSuperdocVersion(docx) {
|
|
42422
42422
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42423
42423
|
}
|
|
42424
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
42424
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.98") {
|
|
42425
42425
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42426
42426
|
}
|
|
42427
42427
|
/**
|
|
@@ -59639,7 +59639,7 @@ const isHeadless = (editor) => {
|
|
|
59639
59639
|
const shouldSkipNodeView = (editor) => {
|
|
59640
59640
|
return isHeadless(editor);
|
|
59641
59641
|
};
|
|
59642
|
-
const summaryVersion = "1.0.0-beta.
|
|
59642
|
+
const summaryVersion = "1.0.0-beta.98";
|
|
59643
59643
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
59644
59644
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
59645
59645
|
function mapAttributes(attrs) {
|
|
@@ -60428,7 +60428,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60428
60428
|
{ default: remarkStringify },
|
|
60429
60429
|
{ default: remarkGfm }
|
|
60430
60430
|
] = await Promise.all([
|
|
60431
|
-
Promise.resolve().then(() => require("./index-
|
|
60431
|
+
Promise.resolve().then(() => require("./index-Dg_sTYZK-DYDzxoXL.cjs")),
|
|
60432
60432
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
60433
60433
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
60434
60434
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -60633,7 +60633,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60633
60633
|
* Process collaboration migrations
|
|
60634
60634
|
*/
|
|
60635
60635
|
processCollaborationMigrations() {
|
|
60636
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
60636
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.98");
|
|
60637
60637
|
if (!this.options.ydoc) return;
|
|
60638
60638
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
60639
60639
|
let docVersion = metaMap.get("version");
|
|
@@ -62957,12 +62957,12 @@ var SectionType = /* @__PURE__ */ ((SectionType2) => {
|
|
|
62957
62957
|
})(SectionType || {});
|
|
62958
62958
|
const DEFAULT_PARAGRAPH_SECTION_TYPE = "nextPage";
|
|
62959
62959
|
const DEFAULT_BODY_SECTION_TYPE = "continuous";
|
|
62960
|
-
const TWIPS_PER_INCH$
|
|
62961
|
-
const PX_PER_INCH$
|
|
62960
|
+
const TWIPS_PER_INCH$4 = 1440;
|
|
62961
|
+
const PX_PER_INCH$3 = 96;
|
|
62962
62962
|
const DEFAULT_COLUMN_GAP_INCHES = 0.5;
|
|
62963
62963
|
function twipsToPixels$1(twips) {
|
|
62964
62964
|
const n = Number(twips);
|
|
62965
|
-
return Number.isFinite(n) ? n / TWIPS_PER_INCH$
|
|
62965
|
+
return Number.isFinite(n) ? n / TWIPS_PER_INCH$4 * PX_PER_INCH$3 : void 0;
|
|
62966
62966
|
}
|
|
62967
62967
|
function parseColumnCount(rawValue) {
|
|
62968
62968
|
if (rawValue == null) return 1;
|
|
@@ -62972,7 +62972,7 @@ function parseColumnCount(rawValue) {
|
|
|
62972
62972
|
function parseColumnGap(gapTwips) {
|
|
62973
62973
|
if (gapTwips == null) return DEFAULT_COLUMN_GAP_INCHES;
|
|
62974
62974
|
const gap = Number(gapTwips);
|
|
62975
|
-
return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$
|
|
62975
|
+
return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$4 : DEFAULT_COLUMN_GAP_INCHES;
|
|
62976
62976
|
}
|
|
62977
62977
|
function extractNormalizedMargins(attrs) {
|
|
62978
62978
|
const sectionMargins = attrs.sectionMargins;
|
|
@@ -63011,14 +63011,15 @@ function extractPageSizeAndOrientation(elements) {
|
|
|
63011
63011
|
return { pageSizePx, orientation };
|
|
63012
63012
|
}
|
|
63013
63013
|
function extractFallbackMargins(elements, currentHeader, currentFooter) {
|
|
63014
|
-
if (currentHeader !== void 0 && currentFooter !== void 0) {
|
|
63015
|
-
return { headerPx: currentHeader, footerPx: currentFooter };
|
|
63016
|
-
}
|
|
63017
63014
|
const pgMar = elements.find((el) => el?.name === "w:pgMar");
|
|
63018
63015
|
const a = pgMar?.attributes || {};
|
|
63019
63016
|
return {
|
|
63020
63017
|
headerPx: currentHeader ?? (a["w:header"] != null ? twipsToPixels$1(a["w:header"]) : void 0),
|
|
63021
|
-
footerPx: currentFooter ?? (a["w:footer"] != null ? twipsToPixels$1(a["w:footer"]) : void 0)
|
|
63018
|
+
footerPx: currentFooter ?? (a["w:footer"] != null ? twipsToPixels$1(a["w:footer"]) : void 0),
|
|
63019
|
+
topPx: a["w:top"] != null ? twipsToPixels$1(a["w:top"]) : void 0,
|
|
63020
|
+
rightPx: a["w:right"] != null ? twipsToPixels$1(a["w:right"]) : void 0,
|
|
63021
|
+
bottomPx: a["w:bottom"] != null ? twipsToPixels$1(a["w:bottom"]) : void 0,
|
|
63022
|
+
leftPx: a["w:left"] != null ? twipsToPixels$1(a["w:left"]) : void 0
|
|
63022
63023
|
};
|
|
63023
63024
|
}
|
|
63024
63025
|
function extractHeaderFooterRefs(elements, refName) {
|
|
@@ -63056,7 +63057,7 @@ function extractColumns(elements) {
|
|
|
63056
63057
|
const gapInches = parseColumnGap(cols.attributes["w:space"]);
|
|
63057
63058
|
return {
|
|
63058
63059
|
count,
|
|
63059
|
-
gap: gapInches * PX_PER_INCH$
|
|
63060
|
+
gap: gapInches * PX_PER_INCH$3
|
|
63060
63061
|
};
|
|
63061
63062
|
}
|
|
63062
63063
|
function extractVerticalAlign(elements) {
|
|
@@ -63079,7 +63080,10 @@ function extractSectionData(para) {
|
|
|
63079
63080
|
const type2 = extractSectionType(sectPrElements);
|
|
63080
63081
|
const { pageSizePx, orientation } = extractPageSizeAndOrientation(sectPrElements);
|
|
63081
63082
|
const titlePg = sectPrElements.some((el) => el?.name === "w:titlePg");
|
|
63082
|
-
|
|
63083
|
+
const fallbackMargins = extractFallbackMargins(sectPrElements, headerPx, footerPx);
|
|
63084
|
+
headerPx = fallbackMargins.headerPx;
|
|
63085
|
+
footerPx = fallbackMargins.footerPx;
|
|
63086
|
+
const { topPx, rightPx, bottomPx, leftPx } = fallbackMargins;
|
|
63083
63087
|
const headerRefs = extractHeaderFooterRefs(sectPrElements, "w:headerReference");
|
|
63084
63088
|
const footerRefs = extractHeaderFooterRefs(sectPrElements, "w:footerReference");
|
|
63085
63089
|
const numbering = extractPageNumbering(sectPrElements);
|
|
@@ -63088,6 +63092,10 @@ function extractSectionData(para) {
|
|
|
63088
63092
|
return {
|
|
63089
63093
|
headerPx,
|
|
63090
63094
|
footerPx,
|
|
63095
|
+
topPx,
|
|
63096
|
+
rightPx,
|
|
63097
|
+
bottomPx,
|
|
63098
|
+
leftPx,
|
|
63091
63099
|
type: type2,
|
|
63092
63100
|
pageSizePx,
|
|
63093
63101
|
orientation,
|
|
@@ -63199,7 +63207,14 @@ function buildSectionRangesFromParagraphs(paragraphs, hasBodySectPr) {
|
|
|
63199
63207
|
startParagraphIndex: currentStart,
|
|
63200
63208
|
endParagraphIndex: item.index,
|
|
63201
63209
|
sectPr,
|
|
63202
|
-
margins: sectionData.headerPx != null || sectionData.footerPx != null ? {
|
|
63210
|
+
margins: sectionData.headerPx != null || sectionData.footerPx != null ? {
|
|
63211
|
+
header: sectionData.headerPx ?? 0,
|
|
63212
|
+
footer: sectionData.footerPx ?? 0,
|
|
63213
|
+
top: sectionData.topPx,
|
|
63214
|
+
right: sectionData.rightPx,
|
|
63215
|
+
bottom: sectionData.bottomPx,
|
|
63216
|
+
left: sectionData.leftPx
|
|
63217
|
+
} : null,
|
|
63203
63218
|
pageSize: sectionData.pageSizePx ?? null,
|
|
63204
63219
|
orientation: sectionData.orientation ?? null,
|
|
63205
63220
|
columns: sectionData.columnsPx ?? null,
|
|
@@ -63241,7 +63256,14 @@ function createFinalSectionFromBodySectPr(bodySectPr, currentStart, totalParagra
|
|
|
63241
63256
|
startParagraphIndex: currentStart,
|
|
63242
63257
|
endParagraphIndex: totalParagraphs - 1,
|
|
63243
63258
|
sectPr: bodySectPr,
|
|
63244
|
-
margins: bodySectionData.headerPx != null || bodySectionData.footerPx != null ? {
|
|
63259
|
+
margins: bodySectionData.headerPx != null || bodySectionData.footerPx != null ? {
|
|
63260
|
+
header: bodySectionData.headerPx ?? 0,
|
|
63261
|
+
footer: bodySectionData.footerPx ?? 0,
|
|
63262
|
+
top: bodySectionData.topPx,
|
|
63263
|
+
right: bodySectionData.rightPx,
|
|
63264
|
+
bottom: bodySectionData.bottomPx,
|
|
63265
|
+
left: bodySectionData.leftPx
|
|
63266
|
+
} : null,
|
|
63245
63267
|
pageSize: bodySectionData.pageSizePx ?? null,
|
|
63246
63268
|
orientation: bodySectionData.orientation ?? null,
|
|
63247
63269
|
columns: bodySectionData.columnsPx ?? null,
|
|
@@ -63292,8 +63314,8 @@ function analyzeSectionRanges(doc2, bodySectPr) {
|
|
|
63292
63314
|
}
|
|
63293
63315
|
return ranges;
|
|
63294
63316
|
}
|
|
63295
|
-
const TWIPS_PER_INCH$
|
|
63296
|
-
const PX_PER_INCH$
|
|
63317
|
+
const TWIPS_PER_INCH$3 = 1440;
|
|
63318
|
+
const PX_PER_INCH$2 = 96;
|
|
63297
63319
|
const PX_PER_PT = 96 / 72;
|
|
63298
63320
|
SectionType.NEXT_PAGE;
|
|
63299
63321
|
SectionType.CONTINUOUS;
|
|
@@ -63432,7 +63454,7 @@ const applyTrackedChangesModeToRuns = (runs, config2, hyperlinkConfig, applyMark
|
|
|
63432
63454
|
}
|
|
63433
63455
|
return filtered;
|
|
63434
63456
|
};
|
|
63435
|
-
const twipsToPx$
|
|
63457
|
+
const twipsToPx$2 = (value) => value / TWIPS_PER_INCH$3 * PX_PER_INCH$2;
|
|
63436
63458
|
const ptToPx = (pt) => {
|
|
63437
63459
|
if (pt == null || !Number.isFinite(pt)) return void 0;
|
|
63438
63460
|
return pt * PX_PER_PT;
|
|
@@ -64942,8 +64964,8 @@ const normalizeParagraphSpacing = (value) => {
|
|
|
64942
64964
|
const beforeAutospacing = toBooleanFlag(source.beforeAutospacing ?? source.beforeAutoSpacing);
|
|
64943
64965
|
const afterAutospacing = toBooleanFlag(source.afterAutospacing ?? source.afterAutoSpacing);
|
|
64944
64966
|
const contextualSpacing = toBooleanFlag(source.contextualSpacing);
|
|
64945
|
-
const before = beforeRaw != null ? twipsToPx$
|
|
64946
|
-
const after = afterRaw != null ? twipsToPx$
|
|
64967
|
+
const before = beforeRaw != null ? twipsToPx$2(beforeRaw) : pickNumber(source.lineSpaceBefore);
|
|
64968
|
+
const after = afterRaw != null ? twipsToPx$2(afterRaw) : pickNumber(source.lineSpaceAfter);
|
|
64947
64969
|
const line = normalizeLineValue(lineRaw, lineRule);
|
|
64948
64970
|
if (before != null) spacing.before = before;
|
|
64949
64971
|
if (after != null) spacing.after = after;
|
|
@@ -64973,9 +64995,9 @@ const normalizeLineValue = (value, lineRule) => {
|
|
|
64973
64995
|
if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
|
|
64974
64996
|
return value;
|
|
64975
64997
|
}
|
|
64976
|
-
return twipsToPx$
|
|
64998
|
+
return twipsToPx$2(value);
|
|
64977
64999
|
}
|
|
64978
|
-
return twipsToPx$
|
|
65000
|
+
return twipsToPx$2(value);
|
|
64979
65001
|
};
|
|
64980
65002
|
const normalizeLineRule = (value) => {
|
|
64981
65003
|
if (value === "auto" || value === "exact" || value === "atLeast") {
|
|
@@ -65012,7 +65034,7 @@ const normalizeParagraphIndent = (value) => {
|
|
|
65012
65034
|
if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
|
|
65013
65035
|
return num;
|
|
65014
65036
|
}
|
|
65015
|
-
return twipsToPx$
|
|
65037
|
+
return twipsToPx$2(Number(num));
|
|
65016
65038
|
};
|
|
65017
65039
|
const left2 = convert(pickNumber(source.left));
|
|
65018
65040
|
const right2 = convert(pickNumber(source.right));
|
|
@@ -65592,9 +65614,9 @@ const buildFontCss = (run2) => {
|
|
|
65592
65614
|
const family = run2.fontFamily ?? "Times New Roman";
|
|
65593
65615
|
return `${style2}${weight}${size2} ${family}`;
|
|
65594
65616
|
};
|
|
65595
|
-
const TWIPS_PER_INCH$
|
|
65617
|
+
const TWIPS_PER_INCH$2 = 1440;
|
|
65596
65618
|
const PIXELS_PER_INCH = 96;
|
|
65597
|
-
const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$
|
|
65619
|
+
const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$2 / PIXELS_PER_INCH);
|
|
65598
65620
|
const PIXELS_PER_TWIP = 1 / TWIPS_PER_PIXEL;
|
|
65599
65621
|
const toFiniteNumber = (value) => {
|
|
65600
65622
|
if (value == null) return null;
|
|
@@ -66618,7 +66640,7 @@ const extractMarkerRun = (lvl) => {
|
|
|
66618
66640
|
}
|
|
66619
66641
|
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
66620
66642
|
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
66621
|
-
run2.letterSpacing = twipsToPx$
|
|
66643
|
+
run2.letterSpacing = twipsToPx$2(spacingTwips);
|
|
66622
66644
|
}
|
|
66623
66645
|
return Object.keys(run2).length ? run2 : void 0;
|
|
66624
66646
|
};
|
|
@@ -66842,10 +66864,19 @@ const buildNumberingPath = (numId, ilvl, counterValue, listCounterContext) => {
|
|
|
66842
66864
|
const convertIndentTwipsToPx = (indent) => {
|
|
66843
66865
|
if (!indent) return void 0;
|
|
66844
66866
|
const result = {};
|
|
66845
|
-
|
|
66846
|
-
|
|
66847
|
-
|
|
66848
|
-
|
|
66867
|
+
const toNum = (v2) => {
|
|
66868
|
+
if (typeof v2 === "string" && v2.trim() !== "" && isFinite(Number(v2))) return Number(v2);
|
|
66869
|
+
if (isFiniteNumber(v2)) return Number(v2);
|
|
66870
|
+
return void 0;
|
|
66871
|
+
};
|
|
66872
|
+
const left2 = toNum(indent.left);
|
|
66873
|
+
const right2 = toNum(indent.right);
|
|
66874
|
+
const firstLine = toNum(indent.firstLine);
|
|
66875
|
+
const hanging = toNum(indent.hanging);
|
|
66876
|
+
if (left2 != null) result.left = twipsToPx$2(left2);
|
|
66877
|
+
if (right2 != null) result.right = twipsToPx$2(right2);
|
|
66878
|
+
if (firstLine != null) result.firstLine = twipsToPx$2(firstLine);
|
|
66879
|
+
if (hanging != null) result.hanging = twipsToPx$2(hanging);
|
|
66849
66880
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
66850
66881
|
};
|
|
66851
66882
|
const toAdapterNumberingProps = (value) => {
|
|
@@ -66870,7 +66901,7 @@ const toResolvedTabStops = (tabs) => {
|
|
|
66870
66901
|
if (!stop || typeof stop.pos !== "number") continue;
|
|
66871
66902
|
const alignment2 = normalizeResolvedTabAlignment(stop.val);
|
|
66872
66903
|
if (!alignment2) continue;
|
|
66873
|
-
const position = twipsToPx$
|
|
66904
|
+
const position = twipsToPx$2(stop.pos);
|
|
66874
66905
|
if (!Number.isFinite(position)) continue;
|
|
66875
66906
|
const resolvedStop = {
|
|
66876
66907
|
position,
|
|
@@ -67311,9 +67342,9 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
67311
67342
|
const vAnchor = asString2(framePr["w:vAnchor"] ?? framePr.vAnchor);
|
|
67312
67343
|
if (vAnchor) frame.vAnchor = vAnchor;
|
|
67313
67344
|
const xTwips = pickNumber(framePr["w:x"] ?? framePr.x);
|
|
67314
|
-
if (xTwips != null) frame.x = twipsToPx$
|
|
67345
|
+
if (xTwips != null) frame.x = twipsToPx$2(xTwips);
|
|
67315
67346
|
const yTwips = pickNumber(framePr["w:y"] ?? framePr.y);
|
|
67316
|
-
if (yTwips != null) frame.y = twipsToPx$
|
|
67347
|
+
if (yTwips != null) frame.y = twipsToPx$2(yTwips);
|
|
67317
67348
|
if (Object.keys(frame).length > 0) {
|
|
67318
67349
|
paragraphAttrs.frame = frame;
|
|
67319
67350
|
}
|
|
@@ -67401,7 +67432,29 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
67401
67432
|
}
|
|
67402
67433
|
}
|
|
67403
67434
|
}
|
|
67404
|
-
|
|
67435
|
+
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
67436
|
+
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
67437
|
+
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
67438
|
+
const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
|
|
67439
|
+
if (firstLinePx > 0) {
|
|
67440
|
+
wordLayout = {
|
|
67441
|
+
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
67442
|
+
firstLineIndentMode: true,
|
|
67443
|
+
textStartPx: firstLinePx
|
|
67444
|
+
};
|
|
67445
|
+
}
|
|
67446
|
+
}
|
|
67447
|
+
if (wordLayout && (!wordLayout.textStartPx || !Number.isFinite(wordLayout.textStartPx)) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
67448
|
+
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
67449
|
+
const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
|
|
67450
|
+
if (firstLinePx > 0) {
|
|
67451
|
+
wordLayout = {
|
|
67452
|
+
...wordLayout,
|
|
67453
|
+
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
67454
|
+
textStartPx: firstLinePx
|
|
67455
|
+
};
|
|
67456
|
+
}
|
|
67457
|
+
}
|
|
67405
67458
|
if (wordLayout) {
|
|
67406
67459
|
if (wordLayout.marker) {
|
|
67407
67460
|
if (listRendering?.markerText) {
|
|
@@ -69312,7 +69365,7 @@ const measurementToPx = (value) => {
|
|
|
69312
69365
|
const entry = value;
|
|
69313
69366
|
if (typeof entry.value !== "number") return void 0;
|
|
69314
69367
|
if (!entry.type || entry.type === "px" || entry.type === "pixel") return entry.value;
|
|
69315
|
-
if (entry.type === "dxa") return twipsToPx$
|
|
69368
|
+
if (entry.type === "dxa") return twipsToPx$2(entry.value);
|
|
69316
69369
|
return void 0;
|
|
69317
69370
|
};
|
|
69318
69371
|
const normalizeTableWidth = (value) => {
|
|
@@ -69324,7 +69377,7 @@ const normalizeTableWidth = (value) => {
|
|
|
69324
69377
|
return { width: raw, type: measurement.type ?? "px" };
|
|
69325
69378
|
}
|
|
69326
69379
|
if (measurement.type === "dxa") {
|
|
69327
|
-
return { width: twipsToPx$
|
|
69380
|
+
return { width: twipsToPx$2(raw), type: "px" };
|
|
69328
69381
|
}
|
|
69329
69382
|
return { width: raw, type: measurement.type };
|
|
69330
69383
|
};
|
|
@@ -69352,13 +69405,13 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
|
|
|
69352
69405
|
const line = parseIntSafe$1(attrs["w:line"]);
|
|
69353
69406
|
const rawLineRule = attrs["w:lineRule"];
|
|
69354
69407
|
const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
|
|
69355
|
-
if (before != null) spacing.before = twipsToPx$
|
|
69356
|
-
if (after != null) spacing.after = twipsToPx$
|
|
69408
|
+
if (before != null) spacing.before = twipsToPx$2(before);
|
|
69409
|
+
if (after != null) spacing.after = twipsToPx$2(after);
|
|
69357
69410
|
if (line != null) {
|
|
69358
69411
|
if (lineRule === "auto") {
|
|
69359
69412
|
spacing.line = line / 240;
|
|
69360
69413
|
} else {
|
|
69361
|
-
spacing.line = twipsToPx$
|
|
69414
|
+
spacing.line = twipsToPx$2(line);
|
|
69362
69415
|
}
|
|
69363
69416
|
}
|
|
69364
69417
|
if (lineRule) spacing.lineRule = lineRule;
|
|
@@ -69384,7 +69437,7 @@ const normalizeRowHeight = (rowProps) => {
|
|
|
69384
69437
|
if (rawValue == null) return void 0;
|
|
69385
69438
|
const rawRule = heightObj.rule ?? heightObj.hRule;
|
|
69386
69439
|
const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
|
|
69387
|
-
const valuePx = twipsToPx$
|
|
69440
|
+
const valuePx = twipsToPx$2(rawValue);
|
|
69388
69441
|
return {
|
|
69389
69442
|
value: valuePx,
|
|
69390
69443
|
rule
|
|
@@ -69489,41 +69542,6 @@ const parseTableCell = (args) => {
|
|
|
69489
69542
|
}
|
|
69490
69543
|
}
|
|
69491
69544
|
}
|
|
69492
|
-
try {
|
|
69493
|
-
const blockSummaries = blocks.map((b2) => {
|
|
69494
|
-
if (b2.kind === "paragraph") {
|
|
69495
|
-
const runs = b2.runs ?? [];
|
|
69496
|
-
const attrs = b2.attrs ?? {};
|
|
69497
|
-
return {
|
|
69498
|
-
kind: "paragraph",
|
|
69499
|
-
runKinds: runs.map((r2) => r2.kind ?? "text"),
|
|
69500
|
-
runCount: runs.length,
|
|
69501
|
-
runPreview: runs.map((r2) => {
|
|
69502
|
-
const kind = r2.kind ?? "text";
|
|
69503
|
-
if (kind === "image") {
|
|
69504
|
-
const img = r2;
|
|
69505
|
-
return { kind, src: img.src, width: img.width, height: img.height };
|
|
69506
|
-
}
|
|
69507
|
-
return { kind };
|
|
69508
|
-
}),
|
|
69509
|
-
hasNumbering: Boolean(attrs.numberingProperties),
|
|
69510
|
-
markerText: attrs.wordLayout?.marker?.markerText
|
|
69511
|
-
};
|
|
69512
|
-
}
|
|
69513
|
-
return { kind: b2.kind };
|
|
69514
|
-
});
|
|
69515
|
-
console.log(
|
|
69516
|
-
"[tableNodeToBlock.parseTableCell] cell contents",
|
|
69517
|
-
JSON.stringify({
|
|
69518
|
-
cellIndex,
|
|
69519
|
-
rowIndex,
|
|
69520
|
-
cellIdPreview: `cell-${rowIndex}-${cellIndex}`,
|
|
69521
|
-
childTypes: cellNode.content.map((c2) => c2?.type),
|
|
69522
|
-
blocks: blockSummaries
|
|
69523
|
-
})
|
|
69524
|
-
);
|
|
69525
|
-
} catch {
|
|
69526
|
-
}
|
|
69527
69545
|
if (blocks.length === 0) {
|
|
69528
69546
|
return null;
|
|
69529
69547
|
}
|
|
@@ -69634,10 +69652,10 @@ function extractFloatingTableAnchorWrap(node) {
|
|
|
69634
69652
|
anchor.alignV = floatingProps.tblpYSpec;
|
|
69635
69653
|
}
|
|
69636
69654
|
if (floatingProps.tblpX !== void 0) {
|
|
69637
|
-
anchor.offsetH = twipsToPx$
|
|
69655
|
+
anchor.offsetH = twipsToPx$2(floatingProps.tblpX);
|
|
69638
69656
|
}
|
|
69639
69657
|
if (floatingProps.tblpY !== void 0) {
|
|
69640
|
-
anchor.offsetV = twipsToPx$
|
|
69658
|
+
anchor.offsetV = twipsToPx$2(floatingProps.tblpY);
|
|
69641
69659
|
}
|
|
69642
69660
|
const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
|
|
69643
69661
|
const wrap2 = {
|
|
@@ -69648,16 +69666,16 @@ function extractFloatingTableAnchorWrap(node) {
|
|
|
69648
69666
|
};
|
|
69649
69667
|
if (hasDistances) {
|
|
69650
69668
|
if (floatingProps.topFromText !== void 0) {
|
|
69651
|
-
wrap2.distTop = twipsToPx$
|
|
69669
|
+
wrap2.distTop = twipsToPx$2(floatingProps.topFromText);
|
|
69652
69670
|
}
|
|
69653
69671
|
if (floatingProps.bottomFromText !== void 0) {
|
|
69654
|
-
wrap2.distBottom = twipsToPx$
|
|
69672
|
+
wrap2.distBottom = twipsToPx$2(floatingProps.bottomFromText);
|
|
69655
69673
|
}
|
|
69656
69674
|
if (floatingProps.leftFromText !== void 0) {
|
|
69657
|
-
wrap2.distLeft = twipsToPx$
|
|
69675
|
+
wrap2.distLeft = twipsToPx$2(floatingProps.leftFromText);
|
|
69658
69676
|
}
|
|
69659
69677
|
if (floatingProps.rightFromText !== void 0) {
|
|
69660
|
-
wrap2.distRight = twipsToPx$
|
|
69678
|
+
wrap2.distRight = twipsToPx$2(floatingProps.rightFromText);
|
|
69661
69679
|
}
|
|
69662
69680
|
}
|
|
69663
69681
|
return { anchor, wrap: wrap2 };
|
|
@@ -73388,20 +73406,6 @@ const renderTableCell = (deps) => {
|
|
|
73388
73406
|
}
|
|
73389
73407
|
const cellBlocks = cell?.blocks ?? (cell?.paragraph ? [cell.paragraph] : []);
|
|
73390
73408
|
const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
|
|
73391
|
-
try {
|
|
73392
|
-
console.log(
|
|
73393
|
-
"[DomPainter.renderTableCell] cell render input",
|
|
73394
|
-
JSON.stringify({
|
|
73395
|
-
cellId: cell?.id,
|
|
73396
|
-
blockKinds: cellBlocks.map((b2) => b2.kind),
|
|
73397
|
-
measureKinds: blockMeasures.map((m2) => m2.kind),
|
|
73398
|
-
width: cellMeasure?.width,
|
|
73399
|
-
height: cellMeasure?.height,
|
|
73400
|
-
rowHeight
|
|
73401
|
-
})
|
|
73402
|
-
);
|
|
73403
|
-
} catch {
|
|
73404
|
-
}
|
|
73405
73409
|
if (cellBlocks.length > 0 && blockMeasures.length > 0) {
|
|
73406
73410
|
const content = doc2.createElement("div");
|
|
73407
73411
|
content.style.position = "relative";
|
|
@@ -73434,15 +73438,6 @@ const renderTableCell = (deps) => {
|
|
|
73434
73438
|
const blockMeasure = blockMeasures[i];
|
|
73435
73439
|
const block = cellBlocks[i];
|
|
73436
73440
|
if (blockMeasure.kind === "image" && block?.kind === "image") {
|
|
73437
|
-
console.log(
|
|
73438
|
-
"[DomPainter.renderTableCell] rendering image block in cell",
|
|
73439
|
-
JSON.stringify({
|
|
73440
|
-
cellId: cell?.id,
|
|
73441
|
-
blockId: block.id,
|
|
73442
|
-
width: blockMeasure.width,
|
|
73443
|
-
height: blockMeasure.height
|
|
73444
|
-
})
|
|
73445
|
-
);
|
|
73446
73441
|
const imageWrapper = doc2.createElement("div");
|
|
73447
73442
|
imageWrapper.style.position = "relative";
|
|
73448
73443
|
imageWrapper.style.width = `${blockMeasure.width}px`;
|
|
@@ -73465,16 +73460,6 @@ const renderTableCell = (deps) => {
|
|
|
73465
73460
|
continue;
|
|
73466
73461
|
}
|
|
73467
73462
|
if (blockMeasure.kind === "drawing" && block?.kind === "drawing") {
|
|
73468
|
-
console.log(
|
|
73469
|
-
"[DomPainter.renderTableCell] rendering drawing block in cell",
|
|
73470
|
-
JSON.stringify({
|
|
73471
|
-
cellId: cell?.id,
|
|
73472
|
-
blockId: block.id,
|
|
73473
|
-
drawingKind: block.drawingKind,
|
|
73474
|
-
width: blockMeasure.width,
|
|
73475
|
-
height: blockMeasure.height
|
|
73476
|
-
})
|
|
73477
|
-
);
|
|
73478
73463
|
const drawingWrapper = doc2.createElement("div");
|
|
73479
73464
|
drawingWrapper.style.position = "relative";
|
|
73480
73465
|
drawingWrapper.style.width = `${blockMeasure.width}px`;
|
|
@@ -73517,20 +73502,6 @@ const renderTableCell = (deps) => {
|
|
|
73517
73502
|
continue;
|
|
73518
73503
|
}
|
|
73519
73504
|
if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
|
|
73520
|
-
try {
|
|
73521
|
-
const runKinds = (block.runs ?? []).map((r2) => r2.kind ?? "text");
|
|
73522
|
-
const imageRuns = (block.runs ?? []).filter((r2) => r2.kind === "image").map((r2) => ({ src: r2.src }));
|
|
73523
|
-
console.log(
|
|
73524
|
-
"[DomPainter.renderTableCell] rendering paragraph block in cell",
|
|
73525
|
-
JSON.stringify({
|
|
73526
|
-
cellId: cell?.id,
|
|
73527
|
-
blockId: block.id,
|
|
73528
|
-
runKinds,
|
|
73529
|
-
imageRuns
|
|
73530
|
-
})
|
|
73531
|
-
);
|
|
73532
|
-
} catch {
|
|
73533
|
-
}
|
|
73534
73505
|
const paragraphMeasure = blockMeasure;
|
|
73535
73506
|
const lines = paragraphMeasure.lines;
|
|
73536
73507
|
const blockLineCount = lines?.length || 0;
|
|
@@ -75345,7 +75316,9 @@ const _DomPainter = class _DomPainter2 {
|
|
|
75345
75316
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
75346
75317
|
const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
75347
75318
|
const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
|
|
75348
|
-
const
|
|
75319
|
+
const paraIndentForOverflow = block.attrs?.indent;
|
|
75320
|
+
const hasNegativeIndent = (paraIndentForOverflow?.left ?? 0) < 0 || (paraIndentForOverflow?.right ?? 0) < 0;
|
|
75321
|
+
const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer || hasNegativeIndent ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
|
|
75349
75322
|
applyStyles$2(fragmentEl, styles);
|
|
75350
75323
|
this.applyFragmentFrame(fragmentEl, fragment, context.section);
|
|
75351
75324
|
if (isTocEntry) {
|
|
@@ -75374,6 +75347,8 @@ const _DomPainter = class _DomPainter2 {
|
|
|
75374
75347
|
}
|
|
75375
75348
|
if (fragmentEl.style.paddingLeft) fragmentEl.style.removeProperty("padding-left");
|
|
75376
75349
|
if (fragmentEl.style.paddingRight) fragmentEl.style.removeProperty("padding-right");
|
|
75350
|
+
if (fragmentEl.style.marginLeft) fragmentEl.style.removeProperty("margin-left");
|
|
75351
|
+
if (fragmentEl.style.marginRight) fragmentEl.style.removeProperty("margin-right");
|
|
75377
75352
|
if (fragmentEl.style.textIndent) fragmentEl.style.removeProperty("text-indent");
|
|
75378
75353
|
const paraIndent = block.attrs?.indent;
|
|
75379
75354
|
const paraIndentLeft = paraIndent?.left ?? 0;
|
|
@@ -75402,16 +75377,22 @@ const _DomPainter = class _DomPainter2 {
|
|
|
75402
75377
|
if (!isListFirstLine) {
|
|
75403
75378
|
if (hasExplicitSegmentPositioning) {
|
|
75404
75379
|
if (isFirstLine && firstLineOffset !== 0) {
|
|
75405
|
-
const
|
|
75406
|
-
|
|
75380
|
+
const effectiveLeftIndent = paraIndentLeft < 0 ? 0 : paraIndentLeft;
|
|
75381
|
+
const adjustedPadding = effectiveLeftIndent + firstLineOffset;
|
|
75382
|
+
if (adjustedPadding > 0) {
|
|
75383
|
+
lineEl.style.paddingLeft = `${adjustedPadding}px`;
|
|
75384
|
+
}
|
|
75407
75385
|
}
|
|
75408
|
-
} else if (paraIndentLeft) {
|
|
75386
|
+
} else if (paraIndentLeft && paraIndentLeft > 0) {
|
|
75409
75387
|
lineEl.style.paddingLeft = `${paraIndentLeft}px`;
|
|
75388
|
+
} else if (!isFirstLine && paraIndent?.hanging && paraIndent.hanging > 0) {
|
|
75389
|
+
lineEl.style.paddingLeft = `${paraIndent.hanging}px`;
|
|
75410
75390
|
}
|
|
75411
75391
|
}
|
|
75412
|
-
if (paraIndentRight) {
|
|
75392
|
+
if (paraIndentRight && paraIndentRight > 0) {
|
|
75413
75393
|
lineEl.style.paddingRight = `${paraIndentRight}px`;
|
|
75414
75394
|
}
|
|
75395
|
+
const hasNegativeLeftIndent = paraIndentLeft != null && paraIndentLeft < 0;
|
|
75415
75396
|
if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
|
|
75416
75397
|
if (!hasExplicitSegmentPositioning) {
|
|
75417
75398
|
lineEl.style.textIndent = `${firstLineOffset}px`;
|
|
@@ -76830,7 +76811,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76830
76811
|
}
|
|
76831
76812
|
const runsForLine = sliceRunsForLine(block, line);
|
|
76832
76813
|
const trackedConfig = this.resolveTrackedChangesConfig(block);
|
|
76833
|
-
|
|
76814
|
+
runsForLine.length > 0 ? runsForLine.filter((r2) => (r2.kind === "text" || r2.kind === void 0) && "text" in r2 && r2.text != null).map((r2) => r2.text) : gatherTextSlicesForLine(block, line);
|
|
76834
76815
|
if (runsForLine.length === 0) {
|
|
76835
76816
|
const span = this.doc.createElement("span");
|
|
76836
76817
|
span.innerHTML = " ";
|
|
@@ -76877,19 +76858,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76877
76858
|
});
|
|
76878
76859
|
}
|
|
76879
76860
|
const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
76880
|
-
|
|
76881
|
-
const shouldJustify = !skipJustify && effectiveAlignment === "justify" && !hasExplicitPositioning;
|
|
76882
|
-
if (shouldJustify) {
|
|
76883
|
-
const spaceCount = textSlices.reduce(
|
|
76884
|
-
(sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
|
|
76885
|
-
0
|
|
76886
|
-
);
|
|
76887
|
-
const slack = availableWidth - line.width;
|
|
76888
|
-
if (spaceCount > 0 && slack !== 0) {
|
|
76889
|
-
const spacingPerSpace = slack / spaceCount;
|
|
76890
|
-
el.style.wordSpacing = `${spacingPerSpace}px`;
|
|
76891
|
-
}
|
|
76892
|
-
}
|
|
76861
|
+
availableWidthOverride ?? line.maxWidth ?? line.width;
|
|
76893
76862
|
if (hasExplicitPositioning && line.segments) {
|
|
76894
76863
|
const paraIndent = block.attrs?.indent;
|
|
76895
76864
|
const indentLeft = paraIndent?.left ?? 0;
|
|
@@ -77708,15 +77677,18 @@ const applyParagraphBlockStyles = (element, attrs) => {
|
|
|
77708
77677
|
}
|
|
77709
77678
|
const indent = attrs.indent;
|
|
77710
77679
|
if (indent) {
|
|
77711
|
-
if (indent.left) {
|
|
77680
|
+
if (indent.left && indent.left > 0) {
|
|
77712
77681
|
element.style.paddingLeft = `${indent.left}px`;
|
|
77713
77682
|
}
|
|
77714
|
-
if (indent.right) {
|
|
77683
|
+
if (indent.right && indent.right > 0) {
|
|
77715
77684
|
element.style.paddingRight = `${indent.right}px`;
|
|
77716
77685
|
}
|
|
77717
|
-
const
|
|
77718
|
-
if (
|
|
77719
|
-
|
|
77686
|
+
const hasNegativeLeftIndent = indent.left != null && indent.left < 0;
|
|
77687
|
+
if (!hasNegativeLeftIndent) {
|
|
77688
|
+
const textIndent = (indent.firstLine ?? 0) - (indent.hanging ?? 0);
|
|
77689
|
+
if (textIndent) {
|
|
77690
|
+
element.style.textIndent = `${textIndent}px`;
|
|
77691
|
+
}
|
|
77720
77692
|
}
|
|
77721
77693
|
}
|
|
77722
77694
|
applyParagraphBorderStyles(element, attrs.borders);
|
|
@@ -79078,20 +79050,6 @@ const asSafeNumber = (value) => {
|
|
|
79078
79050
|
}
|
|
79079
79051
|
return value;
|
|
79080
79052
|
};
|
|
79081
|
-
function calculateFirstLineIndent(block, measure) {
|
|
79082
|
-
const wordLayout = block.attrs?.wordLayout;
|
|
79083
|
-
if (!wordLayout?.firstLineIndentMode) {
|
|
79084
|
-
return 0;
|
|
79085
|
-
}
|
|
79086
|
-
if (!wordLayout.marker || !measure.marker) {
|
|
79087
|
-
return 0;
|
|
79088
|
-
}
|
|
79089
|
-
const markerWidthRaw = measure.marker.markerWidth ?? wordLayout.marker.markerBoxWidthPx ?? 0;
|
|
79090
|
-
const markerWidth = Number.isFinite(markerWidthRaw) && markerWidthRaw >= 0 ? markerWidthRaw : 0;
|
|
79091
|
-
const gutterWidthRaw = measure.marker.gutterWidth ?? 0;
|
|
79092
|
-
const gutterWidth = Number.isFinite(gutterWidthRaw) && gutterWidthRaw >= 0 ? gutterWidthRaw : 0;
|
|
79093
|
-
return markerWidth + gutterWidth;
|
|
79094
|
-
}
|
|
79095
79053
|
function layoutParagraphBlock(ctx2, anchors) {
|
|
79096
79054
|
const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx2;
|
|
79097
79055
|
const remeasureParagraph2 = ctx2.remeasureParagraph;
|
|
@@ -79213,10 +79171,25 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
79213
79171
|
}
|
|
79214
79172
|
let lines = normalizeLines(measure);
|
|
79215
79173
|
const measurementWidth = lines[0]?.maxWidth;
|
|
79174
|
+
const paraIndent = block.attrs?.indent;
|
|
79175
|
+
const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
|
|
79176
|
+
const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
|
|
79177
|
+
const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
|
|
79178
|
+
const negativeRightIndent = indentRight < 0 ? indentRight : 0;
|
|
79179
|
+
const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
|
|
79216
79180
|
let didRemeasureForColumnWidth = false;
|
|
79217
|
-
if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth >
|
|
79218
|
-
|
|
79219
|
-
const
|
|
79181
|
+
if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
|
|
79182
|
+
let firstLineIndent = 0;
|
|
79183
|
+
const wordLayout = block.attrs?.wordLayout;
|
|
79184
|
+
if (wordLayout?.marker && measure.marker) {
|
|
79185
|
+
const markerJustification = wordLayout.marker.justification ?? "left";
|
|
79186
|
+
if (markerJustification === "left") {
|
|
79187
|
+
const markerWidth = measure.marker.markerWidth ?? 0;
|
|
79188
|
+
const gutterWidth = measure.marker.gutterWidth ?? wordLayout.marker.gutterWidthPx ?? 0;
|
|
79189
|
+
firstLineIndent = markerWidth + gutterWidth;
|
|
79190
|
+
}
|
|
79191
|
+
}
|
|
79192
|
+
const newMeasure = remeasureParagraph2(block, remeasureWidth, firstLineIndent);
|
|
79220
79193
|
lines = normalizeLines(newMeasure);
|
|
79221
79194
|
didRemeasureForColumnWidth = true;
|
|
79222
79195
|
}
|
|
@@ -79295,9 +79268,19 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
79295
79268
|
}
|
|
79296
79269
|
tempY += lineHeight2;
|
|
79297
79270
|
}
|
|
79298
|
-
|
|
79299
|
-
|
|
79300
|
-
|
|
79271
|
+
const narrowestRemeasureWidth = Math.max(1, narrowestWidth - indentLeft - indentRight);
|
|
79272
|
+
if (narrowestRemeasureWidth < remeasureWidth) {
|
|
79273
|
+
let firstLineIndent = 0;
|
|
79274
|
+
const wordLayout = block.attrs?.wordLayout;
|
|
79275
|
+
if (wordLayout?.marker && measure.marker) {
|
|
79276
|
+
const markerJustification = wordLayout.marker.justification ?? "left";
|
|
79277
|
+
if (markerJustification === "left") {
|
|
79278
|
+
const markerWidth = measure.marker.markerWidth ?? 0;
|
|
79279
|
+
const gutterWidth = measure.marker.gutterWidth ?? wordLayout.marker.gutterWidthPx ?? 0;
|
|
79280
|
+
firstLineIndent = markerWidth + gutterWidth;
|
|
79281
|
+
}
|
|
79282
|
+
}
|
|
79283
|
+
const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
|
|
79301
79284
|
lines = normalizeLines(newMeasure);
|
|
79302
79285
|
didRemeasureForFloats = true;
|
|
79303
79286
|
}
|
|
@@ -79351,14 +79334,16 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
79351
79334
|
}
|
|
79352
79335
|
const slice2 = sliceLines(lines, fromLine, state2.contentBottom - state2.cursorY);
|
|
79353
79336
|
const fragmentHeight = slice2.height;
|
|
79337
|
+
const adjustedX = columnX(state2.columnIndex) + offsetX + negativeLeftIndent;
|
|
79338
|
+
const adjustedWidth = effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
|
|
79354
79339
|
const fragment = {
|
|
79355
79340
|
kind: "para",
|
|
79356
79341
|
blockId: block.id,
|
|
79357
79342
|
fromLine,
|
|
79358
79343
|
toLine: slice2.toLine,
|
|
79359
|
-
x:
|
|
79344
|
+
x: adjustedX,
|
|
79360
79345
|
y: state2.cursorY,
|
|
79361
|
-
width:
|
|
79346
|
+
width: adjustedWidth,
|
|
79362
79347
|
...computeFragmentPmRange(block, lines, fromLine, slice2.toLine)
|
|
79363
79348
|
};
|
|
79364
79349
|
if (didRemeasureForColumnWidth) {
|
|
@@ -82211,7 +82196,13 @@ function getCtx() {
|
|
|
82211
82196
|
return ctx$1;
|
|
82212
82197
|
}
|
|
82213
82198
|
function isTextRun(run2) {
|
|
82214
|
-
|
|
82199
|
+
if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
|
|
82200
|
+
return false;
|
|
82201
|
+
}
|
|
82202
|
+
if ("src" in run2) {
|
|
82203
|
+
return false;
|
|
82204
|
+
}
|
|
82205
|
+
return true;
|
|
82215
82206
|
}
|
|
82216
82207
|
function fontString(run2) {
|
|
82217
82208
|
const textRun = isTextRun(run2) ? run2 : null;
|
|
@@ -82224,6 +82215,42 @@ function fontString(run2) {
|
|
|
82224
82215
|
function runText(run2) {
|
|
82225
82216
|
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
82226
82217
|
}
|
|
82218
|
+
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
82219
|
+
const TWIPS_PER_INCH$1 = 1440;
|
|
82220
|
+
const PX_PER_INCH$1 = 96;
|
|
82221
|
+
const TWIPS_PER_PX$1 = TWIPS_PER_INCH$1 / PX_PER_INCH$1;
|
|
82222
|
+
const TAB_EPSILON$1 = 0.1;
|
|
82223
|
+
const WIDTH_FUDGE_PX = 0.5;
|
|
82224
|
+
const twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$1;
|
|
82225
|
+
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
82226
|
+
const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
|
|
82227
|
+
const paragraphIndentTwips = {
|
|
82228
|
+
left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
|
|
82229
|
+
right: pxToTwips$1(Math.max(0, indent?.right ?? 0)),
|
|
82230
|
+
firstLine: pxToTwips$1(Math.max(0, indent?.firstLine ?? 0)),
|
|
82231
|
+
hanging: pxToTwips$1(Math.max(0, indent?.hanging ?? 0))
|
|
82232
|
+
};
|
|
82233
|
+
const stops = computeTabStops$1({
|
|
82234
|
+
explicitStops: tabs ?? [],
|
|
82235
|
+
defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$1,
|
|
82236
|
+
paragraphIndent: paragraphIndentTwips
|
|
82237
|
+
});
|
|
82238
|
+
return stops.map((stop) => ({
|
|
82239
|
+
pos: twipsToPx$1(stop.pos),
|
|
82240
|
+
val: stop.val,
|
|
82241
|
+
leader: stop.leader
|
|
82242
|
+
}));
|
|
82243
|
+
};
|
|
82244
|
+
const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
|
|
82245
|
+
let index2 = startIndex;
|
|
82246
|
+
while (index2 < tabStops.length && tabStops[index2].pos <= currentX + TAB_EPSILON$1) {
|
|
82247
|
+
index2 += 1;
|
|
82248
|
+
}
|
|
82249
|
+
if (index2 < tabStops.length) {
|
|
82250
|
+
return { target: tabStops[index2].pos, nextIndex: index2 + 1 };
|
|
82251
|
+
}
|
|
82252
|
+
return { target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$1), nextIndex: index2 };
|
|
82253
|
+
};
|
|
82227
82254
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
82228
82255
|
const context = getCtx();
|
|
82229
82256
|
const text = runText(run2).slice(fromChar, toChar);
|
|
@@ -82247,13 +82274,38 @@ function lineHeightForRuns(runs, fromRun, toRun) {
|
|
|
82247
82274
|
return maxSize2 * 1.2;
|
|
82248
82275
|
}
|
|
82249
82276
|
function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
82277
|
+
if (!Number.isFinite(maxWidth) || maxWidth <= 0) {
|
|
82278
|
+
throw new Error(`remeasureParagraph: maxWidth must be a positive number, got ${maxWidth}`);
|
|
82279
|
+
}
|
|
82280
|
+
if (!Number.isFinite(firstLineIndent)) {
|
|
82281
|
+
throw new Error(`remeasureParagraph: firstLineIndent must be a finite number, got ${firstLineIndent}`);
|
|
82282
|
+
}
|
|
82283
|
+
if (!block) {
|
|
82284
|
+
throw new Error("remeasureParagraph: block must be defined");
|
|
82285
|
+
}
|
|
82286
|
+
if (!Array.isArray(block.runs)) {
|
|
82287
|
+
throw new Error(`remeasureParagraph: block.runs must be an array, got ${typeof block.runs}`);
|
|
82288
|
+
}
|
|
82250
82289
|
const runs = block.runs ?? [];
|
|
82251
82290
|
const lines = [];
|
|
82291
|
+
const attrs = block.attrs;
|
|
82292
|
+
const indent = attrs?.indent;
|
|
82293
|
+
const wordLayout = attrs?.wordLayout;
|
|
82294
|
+
const indentLeft = Math.max(0, indent?.left ?? 0);
|
|
82295
|
+
const indentRight = Math.max(0, indent?.right ?? 0);
|
|
82296
|
+
const indentFirstLine = Math.max(0, indent?.firstLine ?? 0);
|
|
82297
|
+
const indentHanging = Math.max(0, indent?.hanging ?? 0);
|
|
82298
|
+
const rawFirstLineOffset = Math.max(0, firstLineIndent || indentFirstLine - indentHanging);
|
|
82299
|
+
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
82300
|
+
const textStartPx = wordLayout?.textStartPx;
|
|
82301
|
+
const treatAsHanging = textStartPx && indentLeft === 0 && indentHanging === 0;
|
|
82302
|
+
const firstLineWidth = typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - textStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
82303
|
+
const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
82252
82304
|
let currentRun = 0;
|
|
82253
82305
|
let currentChar = 0;
|
|
82254
82306
|
while (currentRun < runs.length) {
|
|
82255
82307
|
const isFirstLine = lines.length === 0;
|
|
82256
|
-
const effectiveMaxWidth = isFirstLine ?
|
|
82308
|
+
const effectiveMaxWidth = Math.max(1, isFirstLine ? firstLineWidth : contentWidth);
|
|
82257
82309
|
const startRun = currentRun;
|
|
82258
82310
|
const startChar = currentChar;
|
|
82259
82311
|
let width = 0;
|
|
@@ -82261,13 +82313,26 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
82261
82313
|
let lastBreakChar = -1;
|
|
82262
82314
|
let endRun = currentRun;
|
|
82263
82315
|
let endChar = currentChar;
|
|
82316
|
+
let tabStopCursor = 0;
|
|
82317
|
+
let didBreakInThisLine = false;
|
|
82264
82318
|
for (let r2 = currentRun; r2 < runs.length; r2 += 1) {
|
|
82265
82319
|
const run2 = runs[r2];
|
|
82320
|
+
if (run2.kind === "tab") {
|
|
82321
|
+
const { target, nextIndex } = getNextTabStopPx$1(width, tabStops, tabStopCursor);
|
|
82322
|
+
const tabAdvance = Math.max(0, target - width);
|
|
82323
|
+
width += tabAdvance;
|
|
82324
|
+
tabStopCursor = nextIndex;
|
|
82325
|
+
endRun = r2;
|
|
82326
|
+
endChar = 1;
|
|
82327
|
+
lastBreakRun = r2;
|
|
82328
|
+
lastBreakChar = 1;
|
|
82329
|
+
continue;
|
|
82330
|
+
}
|
|
82266
82331
|
const text = runText(run2);
|
|
82267
82332
|
const start2 = r2 === currentRun ? currentChar : 0;
|
|
82268
82333
|
for (let c2 = start2; c2 < text.length; c2 += 1) {
|
|
82269
82334
|
const w2 = measureRunSliceWidth(run2, c2, c2 + 1);
|
|
82270
|
-
if (width + w2 > effectiveMaxWidth && width > 0) {
|
|
82335
|
+
if (width + w2 > effectiveMaxWidth - WIDTH_FUDGE_PX && width > 0) {
|
|
82271
82336
|
if (lastBreakRun >= 0) {
|
|
82272
82337
|
endRun = lastBreakRun;
|
|
82273
82338
|
endChar = lastBreakChar;
|
|
@@ -82275,6 +82340,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
82275
82340
|
endRun = r2;
|
|
82276
82341
|
endChar = c2;
|
|
82277
82342
|
}
|
|
82343
|
+
didBreakInThisLine = true;
|
|
82278
82344
|
break;
|
|
82279
82345
|
}
|
|
82280
82346
|
width += w2;
|
|
@@ -82286,9 +82352,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
82286
82352
|
lastBreakChar = c2 + 1;
|
|
82287
82353
|
}
|
|
82288
82354
|
}
|
|
82289
|
-
if (
|
|
82290
|
-
break;
|
|
82291
|
-
}
|
|
82355
|
+
if (didBreakInThisLine) break;
|
|
82292
82356
|
}
|
|
82293
82357
|
if (startRun === endRun && startChar === endChar) {
|
|
82294
82358
|
endRun = startRun;
|
|
@@ -82302,11 +82366,15 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
82302
82366
|
width,
|
|
82303
82367
|
ascent: 0,
|
|
82304
82368
|
descent: 0,
|
|
82305
|
-
lineHeight: lineHeightForRuns(runs, startRun, endRun)
|
|
82369
|
+
lineHeight: lineHeightForRuns(runs, startRun, endRun),
|
|
82370
|
+
maxWidth: effectiveMaxWidth
|
|
82306
82371
|
};
|
|
82307
82372
|
lines.push(line);
|
|
82308
82373
|
currentRun = endRun;
|
|
82309
82374
|
currentChar = endChar;
|
|
82375
|
+
if (currentRun >= runs.length) {
|
|
82376
|
+
break;
|
|
82377
|
+
}
|
|
82310
82378
|
if (currentChar >= runText(runs[currentRun]).length) {
|
|
82311
82379
|
currentRun += 1;
|
|
82312
82380
|
currentChar = 0;
|
|
@@ -82983,9 +83051,15 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
82983
83051
|
}
|
|
82984
83052
|
const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
|
|
82985
83053
|
const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
83054
|
+
const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
|
|
82986
83055
|
function resolveMeasurementConstraints(options) {
|
|
82987
83056
|
const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
|
|
82988
|
-
const margins =
|
|
83057
|
+
const margins = {
|
|
83058
|
+
top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
|
|
83059
|
+
right: normalizeMargin(options.margins?.right, DEFAULT_MARGINS$1.right),
|
|
83060
|
+
bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
|
|
83061
|
+
left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
|
|
83062
|
+
};
|
|
82989
83063
|
const contentWidth = pageSize.w - (margins.left + margins.right);
|
|
82990
83064
|
const contentHeight = pageSize.h - (margins.top + margins.bottom);
|
|
82991
83065
|
const columns = options.columns;
|
|
@@ -84519,12 +84593,12 @@ async function measureBlock(block, constraints) {
|
|
|
84519
84593
|
async function measureParagraphBlock(block, maxWidth) {
|
|
84520
84594
|
const ctx2 = getCanvasContext();
|
|
84521
84595
|
const wordLayout = block.attrs?.wordLayout;
|
|
84522
|
-
const
|
|
84596
|
+
const WIDTH_FUDGE_PX2 = 0.5;
|
|
84523
84597
|
const lines = [];
|
|
84524
84598
|
const indent = block.attrs?.indent;
|
|
84525
84599
|
const spacing = block.attrs?.spacing;
|
|
84526
|
-
const indentLeft =
|
|
84527
|
-
const indentRight =
|
|
84600
|
+
const indentLeft = sanitizeIndent(indent?.left);
|
|
84601
|
+
const indentRight = sanitizeIndent(indent?.right);
|
|
84528
84602
|
const firstLine = indent?.firstLine ?? 0;
|
|
84529
84603
|
const hanging = indent?.hanging ?? 0;
|
|
84530
84604
|
const isWordLayoutList = Boolean(wordLayout?.marker);
|
|
@@ -84533,6 +84607,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
84533
84607
|
const clampedFirstLineOffset = Math.max(0, rawFirstLineOffset);
|
|
84534
84608
|
const firstLineOffset = isWordLayoutList ? 0 : clampedFirstLineOffset;
|
|
84535
84609
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
84610
|
+
const bodyContentWidth = contentWidth;
|
|
84536
84611
|
let initialAvailableWidth;
|
|
84537
84612
|
const textStartPx = wordLayout?.textStartPx;
|
|
84538
84613
|
if (typeof textStartPx === "number" && textStartPx > indentLeft) {
|
|
@@ -84727,7 +84802,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
84727
84802
|
lines.push(emptyLine);
|
|
84728
84803
|
}
|
|
84729
84804
|
const hadPreviousLine = lines.length > 0;
|
|
84730
|
-
const nextLineMaxWidth = hadPreviousLine ? getEffectiveWidth(
|
|
84805
|
+
const nextLineMaxWidth = hadPreviousLine ? getEffectiveWidth(bodyContentWidth) : getEffectiveWidth(initialAvailableWidth);
|
|
84731
84806
|
currentLine = {
|
|
84732
84807
|
fromRun: runIndex,
|
|
84733
84808
|
fromChar: 0,
|
|
@@ -84838,7 +84913,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
84838
84913
|
toChar: 1,
|
|
84839
84914
|
width: imageWidth,
|
|
84840
84915
|
maxFontSize: imageHeight,
|
|
84841
|
-
maxWidth: getEffectiveWidth(
|
|
84916
|
+
maxWidth: getEffectiveWidth(bodyContentWidth),
|
|
84842
84917
|
spaceCount: 0,
|
|
84843
84918
|
segments: [
|
|
84844
84919
|
{
|
|
@@ -84927,7 +85002,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
84927
85002
|
toChar: 1,
|
|
84928
85003
|
width: annotationWidth,
|
|
84929
85004
|
maxFontSize: annotationHeight,
|
|
84930
|
-
maxWidth: getEffectiveWidth(
|
|
85005
|
+
maxWidth: getEffectiveWidth(bodyContentWidth),
|
|
84931
85006
|
spaceCount: 0,
|
|
84932
85007
|
segments: [
|
|
84933
85008
|
{
|
|
@@ -84989,7 +85064,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
84989
85064
|
};
|
|
84990
85065
|
} else {
|
|
84991
85066
|
const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
|
|
84992
|
-
if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth -
|
|
85067
|
+
if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
|
|
84993
85068
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
|
|
84994
85069
|
const { spaceCount: _sc, ...lineBase } = currentLine;
|
|
84995
85070
|
const completedLine = {
|
|
@@ -85009,7 +85084,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85009
85084
|
width: spacesWidth,
|
|
85010
85085
|
maxFontSize: run2.fontSize,
|
|
85011
85086
|
maxFontInfo: getFontInfoFromRun(run2),
|
|
85012
|
-
maxWidth: getEffectiveWidth(
|
|
85087
|
+
maxWidth: getEffectiveWidth(bodyContentWidth),
|
|
85013
85088
|
segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }],
|
|
85014
85089
|
spaceCount: spacesLength
|
|
85015
85090
|
};
|
|
@@ -85055,7 +85130,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85055
85130
|
};
|
|
85056
85131
|
} else {
|
|
85057
85132
|
const boundarySpacing2 = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
|
|
85058
|
-
if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth -
|
|
85133
|
+
if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
|
|
85059
85134
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
|
|
85060
85135
|
const { spaceCount: _sc, ...lineBase } = currentLine;
|
|
85061
85136
|
const completedLine = { ...lineBase, ...metrics };
|
|
@@ -85072,7 +85147,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85072
85147
|
width: singleSpaceWidth,
|
|
85073
85148
|
maxFontSize: run2.fontSize,
|
|
85074
85149
|
maxFontInfo: getFontInfoFromRun(run2),
|
|
85075
|
-
maxWidth: getEffectiveWidth(
|
|
85150
|
+
maxWidth: getEffectiveWidth(bodyContentWidth),
|
|
85076
85151
|
segments: [{ runIndex, fromChar: spaceStartChar, toChar: spaceEndChar, width: singleSpaceWidth }],
|
|
85077
85152
|
spaceCount: 1
|
|
85078
85153
|
};
|
|
@@ -85113,7 +85188,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85113
85188
|
const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
85114
85189
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
85115
85190
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
85116
|
-
const chunks = breakWordIntoChunks(word, chunkWidth -
|
|
85191
|
+
const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
|
|
85117
85192
|
let chunkCharOffset = wordStartChar;
|
|
85118
85193
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
85119
85194
|
const chunk = chunks[chunkIndex];
|
|
@@ -85135,7 +85210,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85135
85210
|
});
|
|
85136
85211
|
if (isLastChunk) {
|
|
85137
85212
|
const ls = run2.letterSpacing ?? 0;
|
|
85138
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
85213
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85139
85214
|
currentLine.toChar = wordEndWithSpace;
|
|
85140
85215
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
85141
85216
|
charPosInRun = wordEndWithSpace;
|
|
@@ -85167,7 +85242,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85167
85242
|
spaceCount: 0
|
|
85168
85243
|
};
|
|
85169
85244
|
const ls = run2.letterSpacing ?? 0;
|
|
85170
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
85245
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85171
85246
|
currentLine.toChar = wordEndWithSpace;
|
|
85172
85247
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
85173
85248
|
charPosInRun = wordEndWithSpace;
|
|
@@ -85209,7 +85284,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85209
85284
|
spaceCount: 0
|
|
85210
85285
|
};
|
|
85211
85286
|
const ls = run2.letterSpacing ?? 0;
|
|
85212
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
85287
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85213
85288
|
currentLine.toChar = wordEndWithSpace;
|
|
85214
85289
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
85215
85290
|
charPosInRun = wordEndWithSpace;
|
|
@@ -85224,7 +85299,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85224
85299
|
const justifyAlignment = block.attrs?.alignment === "justify";
|
|
85225
85300
|
const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
|
|
85226
85301
|
(isLastWord ? 0 : run2.letterSpacing ?? 0);
|
|
85227
|
-
const availableWidth = currentLine.maxWidth -
|
|
85302
|
+
const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX2;
|
|
85228
85303
|
let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
|
|
85229
85304
|
let compressedWidth = null;
|
|
85230
85305
|
if (shouldBreak && justifyAlignment) {
|
|
@@ -85265,11 +85340,11 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85265
85340
|
width: wordOnlyWidth,
|
|
85266
85341
|
maxFontSize: run2.fontSize,
|
|
85267
85342
|
maxFontInfo: getFontInfoFromRun(run2),
|
|
85268
|
-
maxWidth: getEffectiveWidth(
|
|
85343
|
+
maxWidth: getEffectiveWidth(bodyContentWidth),
|
|
85269
85344
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
|
|
85270
85345
|
spaceCount: 0
|
|
85271
85346
|
};
|
|
85272
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
85347
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85273
85348
|
currentLine.toChar = wordEndWithSpace;
|
|
85274
85349
|
currentLine.width = roundValue(currentLine.width + spaceWidth + (run2.letterSpacing ?? 0));
|
|
85275
85350
|
charPosInRun = wordEndWithSpace;
|
|
@@ -85279,7 +85354,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85279
85354
|
}
|
|
85280
85355
|
} else {
|
|
85281
85356
|
currentLine.toRun = runIndex;
|
|
85282
|
-
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth -
|
|
85357
|
+
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85283
85358
|
currentLine.toChar = wordEndNoSpace;
|
|
85284
85359
|
currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
|
|
85285
85360
|
currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
|
|
@@ -85830,6 +85905,7 @@ const resolveLineHeight = (spacing, baseLineHeight) => {
|
|
|
85830
85905
|
return Math.max(baseLineHeight, raw);
|
|
85831
85906
|
};
|
|
85832
85907
|
const sanitizePositive = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
85908
|
+
const sanitizeIndent = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
85833
85909
|
const sanitizeDecimalSeparator = (value) => {
|
|
85834
85910
|
if (value === ",") return ",";
|
|
85835
85911
|
return DEFAULT_DECIMAL_SEPARATOR;
|
|
@@ -90378,6 +90454,10 @@ resolveLayoutOptions_fn = function(blocks, sectionMetadata) {
|
|
|
90378
90454
|
const pageSize = firstSection?.pageSize ?? defaults.pageSize;
|
|
90379
90455
|
const margins = {
|
|
90380
90456
|
...defaults.margins,
|
|
90457
|
+
...firstSection?.margins?.top != null ? { top: firstSection.margins.top } : {},
|
|
90458
|
+
...firstSection?.margins?.right != null ? { right: firstSection.margins.right } : {},
|
|
90459
|
+
...firstSection?.margins?.bottom != null ? { bottom: firstSection.margins.bottom } : {},
|
|
90460
|
+
...firstSection?.margins?.left != null ? { left: firstSection.margins.left } : {},
|
|
90381
90461
|
...firstSection?.margins?.header != null ? { header: firstSection.margins.header } : {},
|
|
90382
90462
|
...firstSection?.margins?.footer != null ? { footer: firstSection.margins.footer } : {}
|
|
90383
90463
|
};
|