@harbour-enterprises/superdoc 1.0.0-beta.95 → 1.0.0-beta.97
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-DC5ZtOHL.es.js → PdfViewer-BHcBfUWj.es.js} +1 -1
- package/dist/chunks/{PdfViewer--l9mxuw6.cjs → PdfViewer-YvkZg201.cjs} +1 -1
- package/dist/chunks/{index-DA6_gKCn.cjs → index-DZ_AI-HW.cjs} +3 -3
- package/dist/chunks/{index-D_AIVJix.es.js → index-DeQfFbTb.es.js} +3 -3
- package/dist/chunks/{index-DJD7xO_i-CVT8OSh8.cjs → index-Pvlqsxge-IH3eauKE.cjs} +1 -1
- package/dist/chunks/{index-DJD7xO_i-DlZGZmeW.es.js → index-Pvlqsxge-vW641SZt.es.js} +1 -1
- package/dist/chunks/{super-editor.es-DLfNMkAR.cjs → super-editor.es-BP3PKkwh.cjs} +244 -91
- package/dist/chunks/{super-editor.es-L0F8-awY.es.js → super-editor.es-BinyZw4F.es.js} +244 -91
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-CAiO-oW4.js → converter-BEVM5t3i.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-DRP7HhmI.js → docx-zipper-vETk3IMG.js} +1 -1
- package/dist/super-editor/chunks/{editor-D5oQ83xJ.js → editor-B8k1bwD_.js} +245 -92
- package/dist/super-editor/chunks/{index-DJD7xO_i.js → index-Pvlqsxge.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-ax2sbcF_.js → toolbar-j1GSUGWU.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 +254 -101
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -42404,7 +42404,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42404
42404
|
static getStoredSuperdocVersion(docx) {
|
|
42405
42405
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42406
42406
|
}
|
|
42407
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
42407
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.97") {
|
|
42408
42408
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42409
42409
|
}
|
|
42410
42410
|
/**
|
|
@@ -59622,7 +59622,7 @@ const isHeadless = (editor) => {
|
|
|
59622
59622
|
const shouldSkipNodeView = (editor) => {
|
|
59623
59623
|
return isHeadless(editor);
|
|
59624
59624
|
};
|
|
59625
|
-
const summaryVersion = "1.0.0-beta.
|
|
59625
|
+
const summaryVersion = "1.0.0-beta.97";
|
|
59626
59626
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
59627
59627
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
59628
59628
|
function mapAttributes(attrs) {
|
|
@@ -60411,7 +60411,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60411
60411
|
{ default: remarkStringify },
|
|
60412
60412
|
{ default: remarkGfm }
|
|
60413
60413
|
] = await Promise.all([
|
|
60414
|
-
import("./index-
|
|
60414
|
+
import("./index-Pvlqsxge-vW641SZt.es.js"),
|
|
60415
60415
|
import("./index-DRCvimau-Cw339678.es.js"),
|
|
60416
60416
|
import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
|
|
60417
60417
|
import("./index-D_sWOSiG-DE96TaT5.es.js"),
|
|
@@ -60616,7 +60616,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60616
60616
|
* Process collaboration migrations
|
|
60617
60617
|
*/
|
|
60618
60618
|
processCollaborationMigrations() {
|
|
60619
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
60619
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.97");
|
|
60620
60620
|
if (!this.options.ydoc) return;
|
|
60621
60621
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
60622
60622
|
let docVersion = metaMap.get("version");
|
|
@@ -62940,12 +62940,12 @@ var SectionType = /* @__PURE__ */ ((SectionType2) => {
|
|
|
62940
62940
|
})(SectionType || {});
|
|
62941
62941
|
const DEFAULT_PARAGRAPH_SECTION_TYPE = "nextPage";
|
|
62942
62942
|
const DEFAULT_BODY_SECTION_TYPE = "continuous";
|
|
62943
|
-
const TWIPS_PER_INCH$
|
|
62944
|
-
const PX_PER_INCH$
|
|
62943
|
+
const TWIPS_PER_INCH$4 = 1440;
|
|
62944
|
+
const PX_PER_INCH$3 = 96;
|
|
62945
62945
|
const DEFAULT_COLUMN_GAP_INCHES = 0.5;
|
|
62946
62946
|
function twipsToPixels$1(twips) {
|
|
62947
62947
|
const n = Number(twips);
|
|
62948
|
-
return Number.isFinite(n) ? n / TWIPS_PER_INCH$
|
|
62948
|
+
return Number.isFinite(n) ? n / TWIPS_PER_INCH$4 * PX_PER_INCH$3 : void 0;
|
|
62949
62949
|
}
|
|
62950
62950
|
function parseColumnCount(rawValue) {
|
|
62951
62951
|
if (rawValue == null) return 1;
|
|
@@ -62955,7 +62955,7 @@ function parseColumnCount(rawValue) {
|
|
|
62955
62955
|
function parseColumnGap(gapTwips) {
|
|
62956
62956
|
if (gapTwips == null) return DEFAULT_COLUMN_GAP_INCHES;
|
|
62957
62957
|
const gap = Number(gapTwips);
|
|
62958
|
-
return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$
|
|
62958
|
+
return Number.isFinite(gap) ? gap / TWIPS_PER_INCH$4 : DEFAULT_COLUMN_GAP_INCHES;
|
|
62959
62959
|
}
|
|
62960
62960
|
function extractNormalizedMargins(attrs) {
|
|
62961
62961
|
const sectionMargins = attrs.sectionMargins;
|
|
@@ -63039,7 +63039,7 @@ function extractColumns(elements) {
|
|
|
63039
63039
|
const gapInches = parseColumnGap(cols.attributes["w:space"]);
|
|
63040
63040
|
return {
|
|
63041
63041
|
count,
|
|
63042
|
-
gap: gapInches * PX_PER_INCH$
|
|
63042
|
+
gap: gapInches * PX_PER_INCH$3
|
|
63043
63043
|
};
|
|
63044
63044
|
}
|
|
63045
63045
|
function extractVerticalAlign(elements) {
|
|
@@ -63275,8 +63275,8 @@ function analyzeSectionRanges(doc2, bodySectPr) {
|
|
|
63275
63275
|
}
|
|
63276
63276
|
return ranges;
|
|
63277
63277
|
}
|
|
63278
|
-
const TWIPS_PER_INCH$
|
|
63279
|
-
const PX_PER_INCH$
|
|
63278
|
+
const TWIPS_PER_INCH$3 = 1440;
|
|
63279
|
+
const PX_PER_INCH$2 = 96;
|
|
63280
63280
|
const PX_PER_PT = 96 / 72;
|
|
63281
63281
|
SectionType.NEXT_PAGE;
|
|
63282
63282
|
SectionType.CONTINUOUS;
|
|
@@ -63415,7 +63415,7 @@ const applyTrackedChangesModeToRuns = (runs, config2, hyperlinkConfig, applyMark
|
|
|
63415
63415
|
}
|
|
63416
63416
|
return filtered;
|
|
63417
63417
|
};
|
|
63418
|
-
const twipsToPx$
|
|
63418
|
+
const twipsToPx$2 = (value) => value / TWIPS_PER_INCH$3 * PX_PER_INCH$2;
|
|
63419
63419
|
const ptToPx = (pt) => {
|
|
63420
63420
|
if (pt == null || !Number.isFinite(pt)) return void 0;
|
|
63421
63421
|
return pt * PX_PER_PT;
|
|
@@ -64925,8 +64925,8 @@ const normalizeParagraphSpacing = (value) => {
|
|
|
64925
64925
|
const beforeAutospacing = toBooleanFlag(source.beforeAutospacing ?? source.beforeAutoSpacing);
|
|
64926
64926
|
const afterAutospacing = toBooleanFlag(source.afterAutospacing ?? source.afterAutoSpacing);
|
|
64927
64927
|
const contextualSpacing = toBooleanFlag(source.contextualSpacing);
|
|
64928
|
-
const before = beforeRaw != null ? twipsToPx$
|
|
64929
|
-
const after = afterRaw != null ? twipsToPx$
|
|
64928
|
+
const before = beforeRaw != null ? twipsToPx$2(beforeRaw) : pickNumber(source.lineSpaceBefore);
|
|
64929
|
+
const after = afterRaw != null ? twipsToPx$2(afterRaw) : pickNumber(source.lineSpaceAfter);
|
|
64930
64930
|
const line = normalizeLineValue(lineRaw, lineRule);
|
|
64931
64931
|
if (before != null) spacing.before = before;
|
|
64932
64932
|
if (after != null) spacing.after = after;
|
|
@@ -64956,9 +64956,9 @@ const normalizeLineValue = (value, lineRule) => {
|
|
|
64956
64956
|
if (value > 0 && value <= MAX_AUTO_LINE_MULTIPLIER) {
|
|
64957
64957
|
return value;
|
|
64958
64958
|
}
|
|
64959
|
-
return twipsToPx$
|
|
64959
|
+
return twipsToPx$2(value);
|
|
64960
64960
|
}
|
|
64961
|
-
return twipsToPx$
|
|
64961
|
+
return twipsToPx$2(value);
|
|
64962
64962
|
};
|
|
64963
64963
|
const normalizeLineRule = (value) => {
|
|
64964
64964
|
if (value === "auto" || value === "exact" || value === "atLeast") {
|
|
@@ -64995,7 +64995,7 @@ const normalizeParagraphIndent = (value) => {
|
|
|
64995
64995
|
if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
|
|
64996
64996
|
return num;
|
|
64997
64997
|
}
|
|
64998
|
-
return twipsToPx$
|
|
64998
|
+
return twipsToPx$2(Number(num));
|
|
64999
64999
|
};
|
|
65000
65000
|
const left2 = convert(pickNumber(source.left));
|
|
65001
65001
|
const right2 = convert(pickNumber(source.right));
|
|
@@ -65575,9 +65575,9 @@ const buildFontCss = (run2) => {
|
|
|
65575
65575
|
const family = run2.fontFamily ?? "Times New Roman";
|
|
65576
65576
|
return `${style2}${weight}${size2} ${family}`;
|
|
65577
65577
|
};
|
|
65578
|
-
const TWIPS_PER_INCH$
|
|
65578
|
+
const TWIPS_PER_INCH$2 = 1440;
|
|
65579
65579
|
const PIXELS_PER_INCH = 96;
|
|
65580
|
-
const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$
|
|
65580
|
+
const TWIPS_PER_PIXEL = Math.round(TWIPS_PER_INCH$2 / PIXELS_PER_INCH);
|
|
65581
65581
|
const PIXELS_PER_TWIP = 1 / TWIPS_PER_PIXEL;
|
|
65582
65582
|
const toFiniteNumber = (value) => {
|
|
65583
65583
|
if (value == null) return null;
|
|
@@ -66601,7 +66601,7 @@ const extractMarkerRun = (lvl) => {
|
|
|
66601
66601
|
}
|
|
66602
66602
|
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
66603
66603
|
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
66604
|
-
run2.letterSpacing = twipsToPx$
|
|
66604
|
+
run2.letterSpacing = twipsToPx$2(spacingTwips);
|
|
66605
66605
|
}
|
|
66606
66606
|
return Object.keys(run2).length ? run2 : void 0;
|
|
66607
66607
|
};
|
|
@@ -66676,6 +66676,13 @@ const isTruthy = (value) => {
|
|
|
66676
66676
|
}
|
|
66677
66677
|
return false;
|
|
66678
66678
|
};
|
|
66679
|
+
const safeGetProperty = (obj, key2) => {
|
|
66680
|
+
if (!obj || typeof obj !== "object") {
|
|
66681
|
+
return void 0;
|
|
66682
|
+
}
|
|
66683
|
+
const record = obj;
|
|
66684
|
+
return record[key2];
|
|
66685
|
+
};
|
|
66679
66686
|
const isExplicitFalse = (value) => {
|
|
66680
66687
|
if (value === false || value === 0) return true;
|
|
66681
66688
|
if (typeof value === "string") {
|
|
@@ -66818,10 +66825,19 @@ const buildNumberingPath = (numId, ilvl, counterValue, listCounterContext) => {
|
|
|
66818
66825
|
const convertIndentTwipsToPx = (indent) => {
|
|
66819
66826
|
if (!indent) return void 0;
|
|
66820
66827
|
const result = {};
|
|
66821
|
-
|
|
66822
|
-
|
|
66823
|
-
|
|
66824
|
-
|
|
66828
|
+
const toNum = (v2) => {
|
|
66829
|
+
if (typeof v2 === "string" && v2.trim() !== "" && isFinite(Number(v2))) return Number(v2);
|
|
66830
|
+
if (isFiniteNumber(v2)) return Number(v2);
|
|
66831
|
+
return void 0;
|
|
66832
|
+
};
|
|
66833
|
+
const left2 = toNum(indent.left);
|
|
66834
|
+
const right2 = toNum(indent.right);
|
|
66835
|
+
const firstLine = toNum(indent.firstLine);
|
|
66836
|
+
const hanging = toNum(indent.hanging);
|
|
66837
|
+
if (left2 != null) result.left = twipsToPx$2(left2);
|
|
66838
|
+
if (right2 != null) result.right = twipsToPx$2(right2);
|
|
66839
|
+
if (firstLine != null) result.firstLine = twipsToPx$2(firstLine);
|
|
66840
|
+
if (hanging != null) result.hanging = twipsToPx$2(hanging);
|
|
66825
66841
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
66826
66842
|
};
|
|
66827
66843
|
const toAdapterNumberingProps = (value) => {
|
|
@@ -66846,7 +66862,7 @@ const toResolvedTabStops = (tabs) => {
|
|
|
66846
66862
|
if (!stop || typeof stop.pos !== "number") continue;
|
|
66847
66863
|
const alignment2 = normalizeResolvedTabAlignment(stop.val);
|
|
66848
66864
|
if (!alignment2) continue;
|
|
66849
|
-
const position = twipsToPx$
|
|
66865
|
+
const position = twipsToPx$2(stop.pos);
|
|
66850
66866
|
if (!Number.isFinite(position)) continue;
|
|
66851
66867
|
const resolvedStop = {
|
|
66852
66868
|
position,
|
|
@@ -67168,8 +67184,9 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
67168
67184
|
paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
|
|
67169
67185
|
}
|
|
67170
67186
|
}
|
|
67171
|
-
|
|
67172
|
-
|
|
67187
|
+
const contextualSpacingValue = normalizedSpacing?.contextualSpacing ?? safeGetProperty(paragraphProps, "contextualSpacing") ?? safeGetProperty(attrs, "contextualSpacing");
|
|
67188
|
+
if (contextualSpacingValue != null) {
|
|
67189
|
+
paragraphAttrs.contextualSpacing = isTruthy(contextualSpacingValue);
|
|
67173
67190
|
}
|
|
67174
67191
|
const hasExplicitIndent = Boolean(normalizedIndent);
|
|
67175
67192
|
const hasNumberingIndent = Boolean(computed2.numbering?.indent?.left || computed2.numbering?.indent?.hanging);
|
|
@@ -67221,7 +67238,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
67221
67238
|
paragraphAttrs.tabs = normalizedTabs;
|
|
67222
67239
|
}
|
|
67223
67240
|
}
|
|
67224
|
-
const
|
|
67241
|
+
const asString2 = (value) => {
|
|
67225
67242
|
return typeof value === "string" ? value : void 0;
|
|
67226
67243
|
};
|
|
67227
67244
|
const normalizeFramePr = (value) => {
|
|
@@ -67244,7 +67261,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
67244
67261
|
};
|
|
67245
67262
|
const framePr = normalizeFramePr(attrs.framePr) ?? normalizeFramePr(attrs.paragraphProperties?.framePr) ?? extractFramePrFromElements(attrs.paragraphProperties);
|
|
67246
67263
|
if (framePr) {
|
|
67247
|
-
const rawXAlign =
|
|
67264
|
+
const rawXAlign = asString2(framePr["w:xAlign"] ?? framePr.xAlign);
|
|
67248
67265
|
const xAlign = typeof rawXAlign === "string" ? rawXAlign.toLowerCase() : void 0;
|
|
67249
67266
|
if (xAlign === "left" || xAlign === "right" || xAlign === "center") {
|
|
67250
67267
|
paragraphAttrs.floatAlignment = xAlign;
|
|
@@ -67254,7 +67271,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
67254
67271
|
paragraphAttrs.dropCap = dropCap;
|
|
67255
67272
|
const dropCapMode = typeof dropCap === "string" ? dropCap.toLowerCase() : "drop";
|
|
67256
67273
|
const linesValue = pickNumber(framePr["w:lines"] ?? framePr.lines);
|
|
67257
|
-
const wrapValue =
|
|
67274
|
+
const wrapValue = asString2(framePr["w:wrap"] ?? framePr.wrap);
|
|
67258
67275
|
const dropCapRunInfo = extractDropCapRunFromParagraph(para);
|
|
67259
67276
|
if (dropCapRunInfo) {
|
|
67260
67277
|
const descriptor = {
|
|
@@ -67272,23 +67289,23 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
67272
67289
|
}
|
|
67273
67290
|
}
|
|
67274
67291
|
const frame = {};
|
|
67275
|
-
const wrap2 =
|
|
67292
|
+
const wrap2 = asString2(framePr["w:wrap"] ?? framePr.wrap);
|
|
67276
67293
|
if (wrap2) frame.wrap = wrap2;
|
|
67277
67294
|
if (xAlign) {
|
|
67278
67295
|
frame.xAlign = xAlign;
|
|
67279
67296
|
}
|
|
67280
|
-
const rawYAlign =
|
|
67297
|
+
const rawYAlign = asString2(framePr["w:yAlign"] ?? framePr.yAlign);
|
|
67281
67298
|
if (rawYAlign) {
|
|
67282
67299
|
frame.yAlign = rawYAlign;
|
|
67283
67300
|
}
|
|
67284
|
-
const hAnchor =
|
|
67301
|
+
const hAnchor = asString2(framePr["w:hAnchor"] ?? framePr.hAnchor);
|
|
67285
67302
|
if (hAnchor) frame.hAnchor = hAnchor;
|
|
67286
|
-
const vAnchor =
|
|
67303
|
+
const vAnchor = asString2(framePr["w:vAnchor"] ?? framePr.vAnchor);
|
|
67287
67304
|
if (vAnchor) frame.vAnchor = vAnchor;
|
|
67288
67305
|
const xTwips = pickNumber(framePr["w:x"] ?? framePr.x);
|
|
67289
|
-
if (xTwips != null) frame.x = twipsToPx$
|
|
67306
|
+
if (xTwips != null) frame.x = twipsToPx$2(xTwips);
|
|
67290
67307
|
const yTwips = pickNumber(framePr["w:y"] ?? framePr.y);
|
|
67291
|
-
if (yTwips != null) frame.y = twipsToPx$
|
|
67308
|
+
if (yTwips != null) frame.y = twipsToPx$2(yTwips);
|
|
67292
67309
|
if (Object.keys(frame).length > 0) {
|
|
67293
67310
|
paragraphAttrs.frame = frame;
|
|
67294
67311
|
}
|
|
@@ -67376,7 +67393,29 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
|
|
|
67376
67393
|
}
|
|
67377
67394
|
}
|
|
67378
67395
|
}
|
|
67379
|
-
|
|
67396
|
+
let wordLayout = computeWordLayoutForParagraph(paragraphAttrs, enrichedNumberingProps, styleContext);
|
|
67397
|
+
if (!wordLayout && enrichedNumberingProps.resolvedLevelIndent) {
|
|
67398
|
+
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
67399
|
+
const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
|
|
67400
|
+
if (firstLinePx > 0) {
|
|
67401
|
+
wordLayout = {
|
|
67402
|
+
// Treat as first-line-indent mode: text starts after the marker+firstLine offset.
|
|
67403
|
+
firstLineIndentMode: true,
|
|
67404
|
+
textStartPx: firstLinePx
|
|
67405
|
+
};
|
|
67406
|
+
}
|
|
67407
|
+
}
|
|
67408
|
+
if (wordLayout && (!wordLayout.textStartPx || !Number.isFinite(wordLayout.textStartPx)) && enrichedNumberingProps.resolvedLevelIndent) {
|
|
67409
|
+
const resolvedIndentPx = convertIndentTwipsToPx(enrichedNumberingProps.resolvedLevelIndent);
|
|
67410
|
+
const firstLinePx = resolvedIndentPx?.firstLine ?? 0;
|
|
67411
|
+
if (firstLinePx > 0) {
|
|
67412
|
+
wordLayout = {
|
|
67413
|
+
...wordLayout,
|
|
67414
|
+
firstLineIndentMode: wordLayout.firstLineIndentMode ?? true,
|
|
67415
|
+
textStartPx: firstLinePx
|
|
67416
|
+
};
|
|
67417
|
+
}
|
|
67418
|
+
}
|
|
67380
67419
|
if (wordLayout) {
|
|
67381
67420
|
if (wordLayout.marker) {
|
|
67382
67421
|
if (listRendering?.markerText) {
|
|
@@ -69287,7 +69326,7 @@ const measurementToPx = (value) => {
|
|
|
69287
69326
|
const entry = value;
|
|
69288
69327
|
if (typeof entry.value !== "number") return void 0;
|
|
69289
69328
|
if (!entry.type || entry.type === "px" || entry.type === "pixel") return entry.value;
|
|
69290
|
-
if (entry.type === "dxa") return twipsToPx$
|
|
69329
|
+
if (entry.type === "dxa") return twipsToPx$2(entry.value);
|
|
69291
69330
|
return void 0;
|
|
69292
69331
|
};
|
|
69293
69332
|
const normalizeTableWidth = (value) => {
|
|
@@ -69299,7 +69338,7 @@ const normalizeTableWidth = (value) => {
|
|
|
69299
69338
|
return { width: raw, type: measurement.type ?? "px" };
|
|
69300
69339
|
}
|
|
69301
69340
|
if (measurement.type === "dxa") {
|
|
69302
|
-
return { width: twipsToPx$
|
|
69341
|
+
return { width: twipsToPx$2(raw), type: "px" };
|
|
69303
69342
|
}
|
|
69304
69343
|
return { width: raw, type: measurement.type };
|
|
69305
69344
|
};
|
|
@@ -69327,13 +69366,13 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
|
|
|
69327
69366
|
const line = parseIntSafe$1(attrs["w:line"]);
|
|
69328
69367
|
const rawLineRule = attrs["w:lineRule"];
|
|
69329
69368
|
const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
|
|
69330
|
-
if (before != null) spacing.before = twipsToPx$
|
|
69331
|
-
if (after != null) spacing.after = twipsToPx$
|
|
69369
|
+
if (before != null) spacing.before = twipsToPx$2(before);
|
|
69370
|
+
if (after != null) spacing.after = twipsToPx$2(after);
|
|
69332
69371
|
if (line != null) {
|
|
69333
69372
|
if (lineRule === "auto") {
|
|
69334
69373
|
spacing.line = line / 240;
|
|
69335
69374
|
} else {
|
|
69336
|
-
spacing.line = twipsToPx$
|
|
69375
|
+
spacing.line = twipsToPx$2(line);
|
|
69337
69376
|
}
|
|
69338
69377
|
}
|
|
69339
69378
|
if (lineRule) spacing.lineRule = lineRule;
|
|
@@ -69359,7 +69398,7 @@ const normalizeRowHeight = (rowProps) => {
|
|
|
69359
69398
|
if (rawValue == null) return void 0;
|
|
69360
69399
|
const rawRule = heightObj.rule ?? heightObj.hRule;
|
|
69361
69400
|
const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
|
|
69362
|
-
const valuePx = twipsToPx$
|
|
69401
|
+
const valuePx = twipsToPx$2(rawValue);
|
|
69363
69402
|
return {
|
|
69364
69403
|
value: valuePx,
|
|
69365
69404
|
rule
|
|
@@ -69609,10 +69648,10 @@ function extractFloatingTableAnchorWrap(node) {
|
|
|
69609
69648
|
anchor.alignV = floatingProps.tblpYSpec;
|
|
69610
69649
|
}
|
|
69611
69650
|
if (floatingProps.tblpX !== void 0) {
|
|
69612
|
-
anchor.offsetH = twipsToPx$
|
|
69651
|
+
anchor.offsetH = twipsToPx$2(floatingProps.tblpX);
|
|
69613
69652
|
}
|
|
69614
69653
|
if (floatingProps.tblpY !== void 0) {
|
|
69615
|
-
anchor.offsetV = twipsToPx$
|
|
69654
|
+
anchor.offsetV = twipsToPx$2(floatingProps.tblpY);
|
|
69616
69655
|
}
|
|
69617
69656
|
const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
|
|
69618
69657
|
const wrap2 = {
|
|
@@ -69623,16 +69662,16 @@ function extractFloatingTableAnchorWrap(node) {
|
|
|
69623
69662
|
};
|
|
69624
69663
|
if (hasDistances) {
|
|
69625
69664
|
if (floatingProps.topFromText !== void 0) {
|
|
69626
|
-
wrap2.distTop = twipsToPx$
|
|
69665
|
+
wrap2.distTop = twipsToPx$2(floatingProps.topFromText);
|
|
69627
69666
|
}
|
|
69628
69667
|
if (floatingProps.bottomFromText !== void 0) {
|
|
69629
|
-
wrap2.distBottom = twipsToPx$
|
|
69668
|
+
wrap2.distBottom = twipsToPx$2(floatingProps.bottomFromText);
|
|
69630
69669
|
}
|
|
69631
69670
|
if (floatingProps.leftFromText !== void 0) {
|
|
69632
|
-
wrap2.distLeft = twipsToPx$
|
|
69671
|
+
wrap2.distLeft = twipsToPx$2(floatingProps.leftFromText);
|
|
69633
69672
|
}
|
|
69634
69673
|
if (floatingProps.rightFromText !== void 0) {
|
|
69635
|
-
wrap2.distRight = twipsToPx$
|
|
69674
|
+
wrap2.distRight = twipsToPx$2(floatingProps.rightFromText);
|
|
69636
69675
|
}
|
|
69637
69676
|
}
|
|
69638
69677
|
return { anchor, wrap: wrap2 };
|
|
@@ -76805,7 +76844,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76805
76844
|
}
|
|
76806
76845
|
const runsForLine = sliceRunsForLine(block, line);
|
|
76807
76846
|
const trackedConfig = this.resolveTrackedChangesConfig(block);
|
|
76808
|
-
|
|
76847
|
+
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);
|
|
76809
76848
|
if (runsForLine.length === 0) {
|
|
76810
76849
|
const span = this.doc.createElement("span");
|
|
76811
76850
|
span.innerHTML = " ";
|
|
@@ -76852,19 +76891,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76852
76891
|
});
|
|
76853
76892
|
}
|
|
76854
76893
|
const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
76855
|
-
|
|
76856
|
-
const shouldJustify = !skipJustify && effectiveAlignment === "justify" && !hasExplicitPositioning;
|
|
76857
|
-
if (shouldJustify) {
|
|
76858
|
-
const spaceCount = textSlices.reduce(
|
|
76859
|
-
(sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
|
|
76860
|
-
0
|
|
76861
|
-
);
|
|
76862
|
-
const slack = availableWidth - line.width;
|
|
76863
|
-
if (spaceCount > 0 && slack !== 0) {
|
|
76864
|
-
const spacingPerSpace = slack / spaceCount;
|
|
76865
|
-
el.style.wordSpacing = `${spacingPerSpace}px`;
|
|
76866
|
-
}
|
|
76867
|
-
}
|
|
76894
|
+
availableWidthOverride ?? line.maxWidth ?? line.width;
|
|
76868
76895
|
if (hasExplicitPositioning && line.segments) {
|
|
76869
76896
|
const paraIndent = block.attrs?.indent;
|
|
76870
76897
|
const indentLeft = paraIndent?.left ?? 0;
|
|
@@ -79027,6 +79054,32 @@ const extractBlockPmRange = (block) => {
|
|
|
79027
79054
|
pmEnd: end2 ?? (start2 != null ? start2 + 1 : void 0)
|
|
79028
79055
|
};
|
|
79029
79056
|
};
|
|
79057
|
+
const getParagraphAttrs = (block) => {
|
|
79058
|
+
if (!block.attrs || typeof block.attrs !== "object") {
|
|
79059
|
+
return void 0;
|
|
79060
|
+
}
|
|
79061
|
+
return block.attrs;
|
|
79062
|
+
};
|
|
79063
|
+
const asString = (value) => {
|
|
79064
|
+
return typeof value === "string" ? value : void 0;
|
|
79065
|
+
};
|
|
79066
|
+
const asBoolean = (value) => {
|
|
79067
|
+
if (value === true || value === 1) return true;
|
|
79068
|
+
if (typeof value === "string") {
|
|
79069
|
+
const normalized = value.toLowerCase();
|
|
79070
|
+
return normalized === "true" || normalized === "1" || normalized === "on";
|
|
79071
|
+
}
|
|
79072
|
+
return false;
|
|
79073
|
+
};
|
|
79074
|
+
const asSafeNumber = (value) => {
|
|
79075
|
+
if (typeof value !== "number") {
|
|
79076
|
+
return 0;
|
|
79077
|
+
}
|
|
79078
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
79079
|
+
return 0;
|
|
79080
|
+
}
|
|
79081
|
+
return value;
|
|
79082
|
+
};
|
|
79030
79083
|
function calculateFirstLineIndent(block, measure) {
|
|
79031
79084
|
const wordLayout = block.attrs?.wordLayout;
|
|
79032
79085
|
if (!wordLayout?.firstLineIndentMode) {
|
|
@@ -79044,7 +79097,8 @@ function calculateFirstLineIndent(block, measure) {
|
|
|
79044
79097
|
function layoutParagraphBlock(ctx2, anchors) {
|
|
79045
79098
|
const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx2;
|
|
79046
79099
|
const remeasureParagraph2 = ctx2.remeasureParagraph;
|
|
79047
|
-
const
|
|
79100
|
+
const blockAttrs = getParagraphAttrs(block);
|
|
79101
|
+
const frame = blockAttrs?.frame;
|
|
79048
79102
|
if (anchors?.anchoredDrawings?.length) {
|
|
79049
79103
|
for (const entry of anchors.anchoredDrawings) {
|
|
79050
79104
|
if (anchors.placedAnchoredIds.has(entry.block.id)) continue;
|
|
@@ -79169,9 +79223,10 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
79169
79223
|
didRemeasureForColumnWidth = true;
|
|
79170
79224
|
}
|
|
79171
79225
|
let fromLine = 0;
|
|
79172
|
-
const
|
|
79173
|
-
const
|
|
79174
|
-
const
|
|
79226
|
+
const attrs = getParagraphAttrs(block);
|
|
79227
|
+
const spacing = attrs?.spacing ?? {};
|
|
79228
|
+
const styleId = asString(attrs?.styleId);
|
|
79229
|
+
const contextualSpacing = asBoolean(attrs?.contextualSpacing);
|
|
79175
79230
|
let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
|
|
79176
79231
|
const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
|
|
79177
79232
|
let appliedSpacingBefore = spacingBefore === 0;
|
|
@@ -79252,14 +79307,13 @@ function layoutParagraphBlock(ctx2, anchors) {
|
|
|
79252
79307
|
while (fromLine < lines.length) {
|
|
79253
79308
|
let state2 = ensurePage();
|
|
79254
79309
|
if (state2.trailingSpacing == null) state2.trailingSpacing = 0;
|
|
79255
|
-
if (contextualSpacing) {
|
|
79256
|
-
const prevStyle = state2.lastParagraphStyleId;
|
|
79257
|
-
if (styleId && prevStyle && prevStyle === styleId) {
|
|
79258
|
-
spacingBefore = 0;
|
|
79259
|
-
}
|
|
79260
|
-
}
|
|
79261
79310
|
if (contextualSpacing && state2.lastParagraphStyleId && styleId && state2.lastParagraphStyleId === styleId) {
|
|
79262
79311
|
spacingBefore = 0;
|
|
79312
|
+
const prevTrailing = asSafeNumber(state2.trailingSpacing);
|
|
79313
|
+
if (prevTrailing > 0) {
|
|
79314
|
+
state2.cursorY -= prevTrailing;
|
|
79315
|
+
state2.trailingSpacing = 0;
|
|
79316
|
+
}
|
|
79263
79317
|
}
|
|
79264
79318
|
if (!appliedSpacingBefore && spacingBefore > 0) {
|
|
79265
79319
|
while (!appliedSpacingBefore) {
|
|
@@ -82159,7 +82213,13 @@ function getCtx() {
|
|
|
82159
82213
|
return ctx$1;
|
|
82160
82214
|
}
|
|
82161
82215
|
function isTextRun(run2) {
|
|
82162
|
-
|
|
82216
|
+
if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
|
|
82217
|
+
return false;
|
|
82218
|
+
}
|
|
82219
|
+
if ("src" in run2) {
|
|
82220
|
+
return false;
|
|
82221
|
+
}
|
|
82222
|
+
return true;
|
|
82163
82223
|
}
|
|
82164
82224
|
function fontString(run2) {
|
|
82165
82225
|
const textRun = isTextRun(run2) ? run2 : null;
|
|
@@ -82172,6 +82232,42 @@ function fontString(run2) {
|
|
|
82172
82232
|
function runText(run2) {
|
|
82173
82233
|
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
82174
82234
|
}
|
|
82235
|
+
const DEFAULT_TAB_INTERVAL_TWIPS$1 = 720;
|
|
82236
|
+
const TWIPS_PER_INCH$1 = 1440;
|
|
82237
|
+
const PX_PER_INCH$1 = 96;
|
|
82238
|
+
const TWIPS_PER_PX$1 = TWIPS_PER_INCH$1 / PX_PER_INCH$1;
|
|
82239
|
+
const TAB_EPSILON$1 = 0.1;
|
|
82240
|
+
const WIDTH_FUDGE_PX = 0.5;
|
|
82241
|
+
const twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$1;
|
|
82242
|
+
const pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$1);
|
|
82243
|
+
const buildTabStopsPx$1 = (indent, tabs, tabIntervalTwips) => {
|
|
82244
|
+
const paragraphIndentTwips = {
|
|
82245
|
+
left: pxToTwips$1(Math.max(0, indent?.left ?? 0)),
|
|
82246
|
+
right: pxToTwips$1(Math.max(0, indent?.right ?? 0)),
|
|
82247
|
+
firstLine: pxToTwips$1(Math.max(0, indent?.firstLine ?? 0)),
|
|
82248
|
+
hanging: pxToTwips$1(Math.max(0, indent?.hanging ?? 0))
|
|
82249
|
+
};
|
|
82250
|
+
const stops = computeTabStops$1({
|
|
82251
|
+
explicitStops: tabs ?? [],
|
|
82252
|
+
defaultTabInterval: tabIntervalTwips ?? DEFAULT_TAB_INTERVAL_TWIPS$1,
|
|
82253
|
+
paragraphIndent: paragraphIndentTwips
|
|
82254
|
+
});
|
|
82255
|
+
return stops.map((stop) => ({
|
|
82256
|
+
pos: twipsToPx$1(stop.pos),
|
|
82257
|
+
val: stop.val,
|
|
82258
|
+
leader: stop.leader
|
|
82259
|
+
}));
|
|
82260
|
+
};
|
|
82261
|
+
const getNextTabStopPx$1 = (currentX, tabStops, startIndex) => {
|
|
82262
|
+
let index2 = startIndex;
|
|
82263
|
+
while (index2 < tabStops.length && tabStops[index2].pos <= currentX + TAB_EPSILON$1) {
|
|
82264
|
+
index2 += 1;
|
|
82265
|
+
}
|
|
82266
|
+
if (index2 < tabStops.length) {
|
|
82267
|
+
return { target: tabStops[index2].pos, nextIndex: index2 + 1 };
|
|
82268
|
+
}
|
|
82269
|
+
return { target: currentX + twipsToPx$1(DEFAULT_TAB_INTERVAL_TWIPS$1), nextIndex: index2 };
|
|
82270
|
+
};
|
|
82175
82271
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
82176
82272
|
const context = getCtx();
|
|
82177
82273
|
const text = runText(run2).slice(fromChar, toChar);
|
|
@@ -82195,13 +82291,38 @@ function lineHeightForRuns(runs, fromRun, toRun) {
|
|
|
82195
82291
|
return maxSize2 * 1.2;
|
|
82196
82292
|
}
|
|
82197
82293
|
function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
82294
|
+
if (!Number.isFinite(maxWidth) || maxWidth <= 0) {
|
|
82295
|
+
throw new Error(`remeasureParagraph: maxWidth must be a positive number, got ${maxWidth}`);
|
|
82296
|
+
}
|
|
82297
|
+
if (!Number.isFinite(firstLineIndent)) {
|
|
82298
|
+
throw new Error(`remeasureParagraph: firstLineIndent must be a finite number, got ${firstLineIndent}`);
|
|
82299
|
+
}
|
|
82300
|
+
if (!block) {
|
|
82301
|
+
throw new Error("remeasureParagraph: block must be defined");
|
|
82302
|
+
}
|
|
82303
|
+
if (!Array.isArray(block.runs)) {
|
|
82304
|
+
throw new Error(`remeasureParagraph: block.runs must be an array, got ${typeof block.runs}`);
|
|
82305
|
+
}
|
|
82198
82306
|
const runs = block.runs ?? [];
|
|
82199
82307
|
const lines = [];
|
|
82308
|
+
const attrs = block.attrs;
|
|
82309
|
+
const indent = attrs?.indent;
|
|
82310
|
+
const wordLayout = attrs?.wordLayout;
|
|
82311
|
+
const indentLeft = Math.max(0, indent?.left ?? 0);
|
|
82312
|
+
const indentRight = Math.max(0, indent?.right ?? 0);
|
|
82313
|
+
const indentFirstLine = Math.max(0, indent?.firstLine ?? 0);
|
|
82314
|
+
const indentHanging = Math.max(0, indent?.hanging ?? 0);
|
|
82315
|
+
const rawFirstLineOffset = Math.max(0, firstLineIndent || indentFirstLine - indentHanging);
|
|
82316
|
+
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
82317
|
+
const textStartPx = wordLayout?.textStartPx;
|
|
82318
|
+
const treatAsHanging = textStartPx && indentLeft === 0 && indentHanging === 0;
|
|
82319
|
+
const firstLineWidth = typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging ? Math.max(1, maxWidth - textStartPx - indentRight) : Math.max(1, contentWidth - rawFirstLineOffset);
|
|
82320
|
+
const tabStops = buildTabStopsPx$1(indent, attrs?.tabs, attrs?.tabIntervalTwips);
|
|
82200
82321
|
let currentRun = 0;
|
|
82201
82322
|
let currentChar = 0;
|
|
82202
82323
|
while (currentRun < runs.length) {
|
|
82203
82324
|
const isFirstLine = lines.length === 0;
|
|
82204
|
-
const effectiveMaxWidth = isFirstLine ?
|
|
82325
|
+
const effectiveMaxWidth = Math.max(1, isFirstLine ? firstLineWidth : contentWidth);
|
|
82205
82326
|
const startRun = currentRun;
|
|
82206
82327
|
const startChar = currentChar;
|
|
82207
82328
|
let width = 0;
|
|
@@ -82209,13 +82330,26 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
82209
82330
|
let lastBreakChar = -1;
|
|
82210
82331
|
let endRun = currentRun;
|
|
82211
82332
|
let endChar = currentChar;
|
|
82333
|
+
let tabStopCursor = 0;
|
|
82334
|
+
let didBreakInThisLine = false;
|
|
82212
82335
|
for (let r2 = currentRun; r2 < runs.length; r2 += 1) {
|
|
82213
82336
|
const run2 = runs[r2];
|
|
82337
|
+
if (run2.kind === "tab") {
|
|
82338
|
+
const { target, nextIndex } = getNextTabStopPx$1(width, tabStops, tabStopCursor);
|
|
82339
|
+
const tabAdvance = Math.max(0, target - width);
|
|
82340
|
+
width += tabAdvance;
|
|
82341
|
+
tabStopCursor = nextIndex;
|
|
82342
|
+
endRun = r2;
|
|
82343
|
+
endChar = 1;
|
|
82344
|
+
lastBreakRun = r2;
|
|
82345
|
+
lastBreakChar = 1;
|
|
82346
|
+
continue;
|
|
82347
|
+
}
|
|
82214
82348
|
const text = runText(run2);
|
|
82215
82349
|
const start2 = r2 === currentRun ? currentChar : 0;
|
|
82216
82350
|
for (let c2 = start2; c2 < text.length; c2 += 1) {
|
|
82217
82351
|
const w2 = measureRunSliceWidth(run2, c2, c2 + 1);
|
|
82218
|
-
if (width + w2 > effectiveMaxWidth && width > 0) {
|
|
82352
|
+
if (width + w2 > effectiveMaxWidth - WIDTH_FUDGE_PX && width > 0) {
|
|
82219
82353
|
if (lastBreakRun >= 0) {
|
|
82220
82354
|
endRun = lastBreakRun;
|
|
82221
82355
|
endChar = lastBreakChar;
|
|
@@ -82223,6 +82357,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
82223
82357
|
endRun = r2;
|
|
82224
82358
|
endChar = c2;
|
|
82225
82359
|
}
|
|
82360
|
+
didBreakInThisLine = true;
|
|
82226
82361
|
break;
|
|
82227
82362
|
}
|
|
82228
82363
|
width += w2;
|
|
@@ -82234,9 +82369,7 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
82234
82369
|
lastBreakChar = c2 + 1;
|
|
82235
82370
|
}
|
|
82236
82371
|
}
|
|
82237
|
-
if (
|
|
82238
|
-
break;
|
|
82239
|
-
}
|
|
82372
|
+
if (didBreakInThisLine) break;
|
|
82240
82373
|
}
|
|
82241
82374
|
if (startRun === endRun && startChar === endChar) {
|
|
82242
82375
|
endRun = startRun;
|
|
@@ -82250,11 +82383,15 @@ function remeasureParagraph(block, maxWidth, firstLineIndent = 0) {
|
|
|
82250
82383
|
width,
|
|
82251
82384
|
ascent: 0,
|
|
82252
82385
|
descent: 0,
|
|
82253
|
-
lineHeight: lineHeightForRuns(runs, startRun, endRun)
|
|
82386
|
+
lineHeight: lineHeightForRuns(runs, startRun, endRun),
|
|
82387
|
+
maxWidth: effectiveMaxWidth
|
|
82254
82388
|
};
|
|
82255
82389
|
lines.push(line);
|
|
82256
82390
|
currentRun = endRun;
|
|
82257
82391
|
currentChar = endChar;
|
|
82392
|
+
if (currentRun >= runs.length) {
|
|
82393
|
+
break;
|
|
82394
|
+
}
|
|
82258
82395
|
if (currentChar >= runText(runs[currentRun]).length) {
|
|
82259
82396
|
currentRun += 1;
|
|
82260
82397
|
currentChar = 0;
|
|
@@ -84467,7 +84604,7 @@ async function measureBlock(block, constraints) {
|
|
|
84467
84604
|
async function measureParagraphBlock(block, maxWidth) {
|
|
84468
84605
|
const ctx2 = getCanvasContext();
|
|
84469
84606
|
const wordLayout = block.attrs?.wordLayout;
|
|
84470
|
-
const
|
|
84607
|
+
const WIDTH_FUDGE_PX2 = 0.5;
|
|
84471
84608
|
const lines = [];
|
|
84472
84609
|
const indent = block.attrs?.indent;
|
|
84473
84610
|
const spacing = block.attrs?.spacing;
|
|
@@ -84483,7 +84620,8 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
84483
84620
|
const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
|
|
84484
84621
|
let initialAvailableWidth;
|
|
84485
84622
|
const textStartPx = wordLayout?.textStartPx;
|
|
84486
|
-
|
|
84623
|
+
const treatAsHanging = isWordLayoutList && indentLeft === 0 && hanging === 0 && typeof textStartPx === "number";
|
|
84624
|
+
if (typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging) {
|
|
84487
84625
|
initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
|
|
84488
84626
|
} else {
|
|
84489
84627
|
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
|
|
@@ -84530,6 +84668,21 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
84530
84668
|
totalHeight: metrics.lineHeight
|
|
84531
84669
|
};
|
|
84532
84670
|
}
|
|
84671
|
+
const isListLike = Boolean(block.attrs?.numId || wordLayout?.marker);
|
|
84672
|
+
if (isListLike) {
|
|
84673
|
+
console.log(
|
|
84674
|
+
"[measureParagraph][list]",
|
|
84675
|
+
JSON.stringify({
|
|
84676
|
+
blockId: block.id,
|
|
84677
|
+
maxWidth,
|
|
84678
|
+
indentLeft,
|
|
84679
|
+
indentRight,
|
|
84680
|
+
textStartPx: textStartPx ?? null,
|
|
84681
|
+
firstLineOffset: firstLineOffset ?? null,
|
|
84682
|
+
initialAvailableWidth
|
|
84683
|
+
})
|
|
84684
|
+
);
|
|
84685
|
+
}
|
|
84533
84686
|
let currentLine = null;
|
|
84534
84687
|
const getEffectiveWidth = (baseWidth) => {
|
|
84535
84688
|
if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
|
|
@@ -84937,7 +85090,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
84937
85090
|
};
|
|
84938
85091
|
} else {
|
|
84939
85092
|
const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
|
|
84940
|
-
if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth -
|
|
85093
|
+
if (currentLine.width + boundarySpacing + spacesWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
|
|
84941
85094
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
|
|
84942
85095
|
const { spaceCount: _sc, ...lineBase } = currentLine;
|
|
84943
85096
|
const completedLine = {
|
|
@@ -85003,7 +85156,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85003
85156
|
};
|
|
85004
85157
|
} else {
|
|
85005
85158
|
const boundarySpacing2 = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
|
|
85006
|
-
if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth -
|
|
85159
|
+
if (currentLine.width + boundarySpacing2 + singleSpaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2 && currentLine.width > 0) {
|
|
85007
85160
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
|
|
85008
85161
|
const { spaceCount: _sc, ...lineBase } = currentLine;
|
|
85009
85162
|
const completedLine = { ...lineBase, ...metrics };
|
|
@@ -85061,7 +85214,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85061
85214
|
const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
|
|
85062
85215
|
const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
|
|
85063
85216
|
const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
|
|
85064
|
-
const chunks = breakWordIntoChunks(word, chunkWidth -
|
|
85217
|
+
const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX2, font, ctx2, run2);
|
|
85065
85218
|
let chunkCharOffset = wordStartChar;
|
|
85066
85219
|
for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
|
|
85067
85220
|
const chunk = chunks[chunkIndex];
|
|
@@ -85083,7 +85236,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85083
85236
|
});
|
|
85084
85237
|
if (isLastChunk) {
|
|
85085
85238
|
const ls = run2.letterSpacing ?? 0;
|
|
85086
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
85239
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85087
85240
|
currentLine.toChar = wordEndWithSpace;
|
|
85088
85241
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
85089
85242
|
charPosInRun = wordEndWithSpace;
|
|
@@ -85115,7 +85268,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85115
85268
|
spaceCount: 0
|
|
85116
85269
|
};
|
|
85117
85270
|
const ls = run2.letterSpacing ?? 0;
|
|
85118
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
85271
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85119
85272
|
currentLine.toChar = wordEndWithSpace;
|
|
85120
85273
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
85121
85274
|
charPosInRun = wordEndWithSpace;
|
|
@@ -85157,7 +85310,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85157
85310
|
spaceCount: 0
|
|
85158
85311
|
};
|
|
85159
85312
|
const ls = run2.letterSpacing ?? 0;
|
|
85160
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
85313
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85161
85314
|
currentLine.toChar = wordEndWithSpace;
|
|
85162
85315
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
85163
85316
|
charPosInRun = wordEndWithSpace;
|
|
@@ -85172,7 +85325,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85172
85325
|
const justifyAlignment = block.attrs?.alignment === "justify";
|
|
85173
85326
|
const totalWidthWithWord = currentLine.width + boundarySpacing + wordCommitWidth + // Safe cast: only TextRuns produce word segments from split(), other run types are handled earlier
|
|
85174
85327
|
(isLastWord ? 0 : run2.letterSpacing ?? 0);
|
|
85175
|
-
const availableWidth = currentLine.maxWidth -
|
|
85328
|
+
const availableWidth = currentLine.maxWidth - WIDTH_FUDGE_PX2;
|
|
85176
85329
|
let shouldBreak = currentLine.width + boundarySpacing + wordOnlyWidth > availableWidth && currentLine.width > 0 && !isTocEntry;
|
|
85177
85330
|
let compressedWidth = null;
|
|
85178
85331
|
if (shouldBreak && justifyAlignment) {
|
|
@@ -85217,7 +85370,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85217
85370
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
|
|
85218
85371
|
spaceCount: 0
|
|
85219
85372
|
};
|
|
85220
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth -
|
|
85373
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85221
85374
|
currentLine.toChar = wordEndWithSpace;
|
|
85222
85375
|
currentLine.width = roundValue(currentLine.width + spaceWidth + (run2.letterSpacing ?? 0));
|
|
85223
85376
|
charPosInRun = wordEndWithSpace;
|
|
@@ -85227,7 +85380,7 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
85227
85380
|
}
|
|
85228
85381
|
} else {
|
|
85229
85382
|
currentLine.toRun = runIndex;
|
|
85230
|
-
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth -
|
|
85383
|
+
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX2) {
|
|
85231
85384
|
currentLine.toChar = wordEndNoSpace;
|
|
85232
85385
|
currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
|
|
85233
85386
|
currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
|