superdoc 1.0.0-beta.15 → 1.0.0-beta.16
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-DltPlBWC.cjs → PdfViewer-93eWvs8z.cjs} +1 -1
- package/dist/chunks/{PdfViewer-CjlHzt9e.es.js → PdfViewer-ODeuH1gb.es.js} +1 -1
- package/dist/chunks/{index-qg0AxQJC.es.js → index-DW5_UKLM.es.js} +3 -3
- package/dist/chunks/{index-Bds7gW4r-Pk_xAuWe.es.js → index-DexFffM7-Cbdy0Zy6.es.js} +1 -1
- package/dist/chunks/{index-Bds7gW4r-JPDW6c39.cjs → index-DexFffM7-XZD_g6eY.cjs} +1 -1
- package/dist/chunks/{index-BZnlco_f.cjs → index-RquHXtgI.cjs} +3 -3
- package/dist/chunks/{super-editor.es-CuAhqbzW.cjs → super-editor.es-BLKWkx5G.cjs} +1223 -131
- package/dist/chunks/{super-editor.es-CQTkj_nb.es.js → super-editor.es-Dg5uoFkw.es.js} +1223 -131
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-qMoZOGGn.js → converter-C_R_BK8X.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-QKiyORxV.js → docx-zipper-BvQAYmi1.js} +1 -1
- package/dist/super-editor/chunks/{editor-D8ZdjC2V.js → editor-DFFvalb1.js} +1224 -132
- package/dist/super-editor/chunks/{index-Bds7gW4r.js → index-DexFffM7.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-Spi7vpev.js → toolbar-DLPfegtw.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 +1225 -133
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -36267,7 +36267,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
36267
36267
|
static getStoredSuperdocVersion(docx) {
|
|
36268
36268
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
36269
36269
|
}
|
|
36270
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
36270
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.16") {
|
|
36271
36271
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
36272
36272
|
}
|
|
36273
36273
|
/**
|
|
@@ -60852,7 +60852,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
60852
60852
|
const shouldSkipNodeView = (editor) => {
|
|
60853
60853
|
return isHeadless(editor);
|
|
60854
60854
|
};
|
|
60855
|
-
const summaryVersion = "1.0.0-beta.
|
|
60855
|
+
const summaryVersion = "1.0.0-beta.16";
|
|
60856
60856
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
60857
60857
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
60858
60858
|
function mapAttributes(attrs) {
|
|
@@ -61631,7 +61631,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61631
61631
|
{ default: remarkStringify2 },
|
|
61632
61632
|
{ default: remarkGfm2 }
|
|
61633
61633
|
] = await Promise.all([
|
|
61634
|
-
Promise.resolve().then(() =>
|
|
61634
|
+
Promise.resolve().then(() => indexDexFffM7),
|
|
61635
61635
|
Promise.resolve().then(() => indexDRCvimau),
|
|
61636
61636
|
Promise.resolve().then(() => indexC_x_N6Uh),
|
|
61637
61637
|
Promise.resolve().then(() => indexD_sWOSiG),
|
|
@@ -61836,7 +61836,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61836
61836
|
* Process collaboration migrations
|
|
61837
61837
|
*/
|
|
61838
61838
|
processCollaborationMigrations() {
|
|
61839
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
61839
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.16");
|
|
61840
61840
|
if (!this.options.ydoc) return;
|
|
61841
61841
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
61842
61842
|
let docVersion = metaMap.get("version");
|
|
@@ -62911,7 +62911,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
62911
62911
|
const normalized = value.trim().toLowerCase();
|
|
62912
62912
|
return normalized || void 0;
|
|
62913
62913
|
};
|
|
62914
|
-
const normalizeColor = (value) => {
|
|
62914
|
+
const normalizeColor$1 = (value) => {
|
|
62915
62915
|
if (typeof value !== "string") return void 0;
|
|
62916
62916
|
const trimmed = value.trim();
|
|
62917
62917
|
if (!trimmed || trimmed === "auto" || trimmed === "none") return void 0;
|
|
@@ -63551,14 +63551,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
63551
63551
|
const resolveColorFromAttributes = (attrs, themeColors) => {
|
|
63552
63552
|
if (!attrs) return void 0;
|
|
63553
63553
|
if (typeof attrs.color === "string") {
|
|
63554
|
-
const normalized = normalizeColor(attrs.color);
|
|
63554
|
+
const normalized = normalizeColor$1(attrs.color);
|
|
63555
63555
|
if (normalized) {
|
|
63556
63556
|
return normalized;
|
|
63557
63557
|
}
|
|
63558
63558
|
}
|
|
63559
63559
|
const theme = resolveThemeColor(attrs, themeColors);
|
|
63560
63560
|
if (theme) {
|
|
63561
|
-
return normalizeColor(theme);
|
|
63561
|
+
return normalizeColor$1(theme);
|
|
63562
63562
|
}
|
|
63563
63563
|
return void 0;
|
|
63564
63564
|
};
|
|
@@ -63993,13 +63993,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
63993
63993
|
const borderSizeToPx = (size2) => {
|
|
63994
63994
|
if (!isFiniteNumber(size2)) return void 0;
|
|
63995
63995
|
if (size2 <= 0) return 0;
|
|
63996
|
-
|
|
63997
|
-
|
|
63998
|
-
pixelValue = size2;
|
|
63999
|
-
} else {
|
|
64000
|
-
const points = size2 / EIGHTHS_PER_POINT;
|
|
64001
|
-
pixelValue = points * PX_PER_PT;
|
|
64002
|
-
}
|
|
63996
|
+
const points = size2 / EIGHTHS_PER_POINT;
|
|
63997
|
+
const pixelValue = points * PX_PER_PT;
|
|
64003
63998
|
return Math.min(MAX_BORDER_SIZE_PX, Math.max(MIN_BORDER_SIZE_PX, pixelValue));
|
|
64004
63999
|
};
|
|
64005
64000
|
const normalizeColorWithDefault = (color2) => {
|
|
@@ -64138,7 +64133,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64138
64133
|
if (style2 === "none") return void 0;
|
|
64139
64134
|
const width = pickNumber(raw.size);
|
|
64140
64135
|
const widthPx = borderSizeToPx(width);
|
|
64141
|
-
const color2 = normalizeColor(raw.color);
|
|
64136
|
+
const color2 = normalizeColor$1(raw.color);
|
|
64142
64137
|
const space = pickNumber(raw.space);
|
|
64143
64138
|
if (!style2 && widthPx == null && space == null && !color2) {
|
|
64144
64139
|
return void 0;
|
|
@@ -64194,7 +64189,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
64194
64189
|
return Object.keys(shading).length > 0 ? shading : void 0;
|
|
64195
64190
|
};
|
|
64196
64191
|
const normalizeShadingColor = (value) => {
|
|
64197
|
-
const normalized = normalizeColor(value);
|
|
64192
|
+
const normalized = normalizeColor$1(value);
|
|
64198
64193
|
if (!normalized) return void 0;
|
|
64199
64194
|
if (normalized.toLowerCase() === "#auto") {
|
|
64200
64195
|
return void 0;
|
|
@@ -65357,11 +65352,11 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
65357
65352
|
baselineOffsetPx: markerRun.baselineShift ?? 0,
|
|
65358
65353
|
gutterWidthPx: markerBoxWidthPx,
|
|
65359
65354
|
justification: numbering.lvlJc ?? "left",
|
|
65360
|
-
suffix: normalizeSuffix(numbering.suffix) ?? "tab",
|
|
65355
|
+
suffix: normalizeSuffix$1(numbering.suffix) ?? "tab",
|
|
65361
65356
|
run: markerRun,
|
|
65362
65357
|
path: numbering.path
|
|
65363
65358
|
});
|
|
65364
|
-
const normalizeSuffix = (suffix2) => {
|
|
65359
|
+
const normalizeSuffix$1 = (suffix2) => {
|
|
65365
65360
|
if (suffix2 === "tab" || suffix2 === "space" || suffix2 === "nothing") {
|
|
65366
65361
|
return suffix2;
|
|
65367
65362
|
}
|
|
@@ -65815,6 +65810,154 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
65815
65810
|
};
|
|
65816
65811
|
const { resolveSpacingIndent } = Engines;
|
|
65817
65812
|
const DEFAULT_DECIMAL_SEPARATOR$2 = ".";
|
|
65813
|
+
const asOoxmlElement = (value) => {
|
|
65814
|
+
if (!value || typeof value !== "object") return void 0;
|
|
65815
|
+
const element2 = value;
|
|
65816
|
+
if (element2.name == null && element2.attributes == null && element2.elements == null) return void 0;
|
|
65817
|
+
return element2;
|
|
65818
|
+
};
|
|
65819
|
+
const findChild = (parent, name) => {
|
|
65820
|
+
return parent?.elements?.find((child) => child?.name === name);
|
|
65821
|
+
};
|
|
65822
|
+
const getAttribute = (element2, key2) => {
|
|
65823
|
+
if (!element2?.attributes) return void 0;
|
|
65824
|
+
const attrs = element2.attributes;
|
|
65825
|
+
return attrs[key2] ?? attrs[key2.startsWith("w:") ? key2.slice(2) : `w:${key2}`];
|
|
65826
|
+
};
|
|
65827
|
+
const parseNumberAttr = (value) => {
|
|
65828
|
+
if (value == null) return void 0;
|
|
65829
|
+
const num = typeof value === "number" ? value : Number.parseInt(String(value), 10);
|
|
65830
|
+
return Number.isFinite(num) ? num : void 0;
|
|
65831
|
+
};
|
|
65832
|
+
const normalizeNumFmt = (value) => {
|
|
65833
|
+
if (typeof value !== "string") return void 0;
|
|
65834
|
+
switch (value) {
|
|
65835
|
+
case "decimal":
|
|
65836
|
+
return "decimal";
|
|
65837
|
+
case "lowerLetter":
|
|
65838
|
+
return "lowerLetter";
|
|
65839
|
+
case "upperLetter":
|
|
65840
|
+
return "upperLetter";
|
|
65841
|
+
case "lowerRoman":
|
|
65842
|
+
return "lowerRoman";
|
|
65843
|
+
case "upperRoman":
|
|
65844
|
+
return "upperRoman";
|
|
65845
|
+
case "bullet":
|
|
65846
|
+
return "bullet";
|
|
65847
|
+
default:
|
|
65848
|
+
return void 0;
|
|
65849
|
+
}
|
|
65850
|
+
};
|
|
65851
|
+
const normalizeSuffix = (value) => {
|
|
65852
|
+
if (typeof value !== "string") return void 0;
|
|
65853
|
+
if (value === "tab" || value === "space" || value === "nothing") {
|
|
65854
|
+
return value;
|
|
65855
|
+
}
|
|
65856
|
+
return void 0;
|
|
65857
|
+
};
|
|
65858
|
+
const normalizeJustification = (value) => {
|
|
65859
|
+
if (typeof value !== "string") return void 0;
|
|
65860
|
+
if (value === "start") return "left";
|
|
65861
|
+
if (value === "end") return "right";
|
|
65862
|
+
if (value === "left" || value === "center" || value === "right") return value;
|
|
65863
|
+
return void 0;
|
|
65864
|
+
};
|
|
65865
|
+
const extractIndentFromLevel = (lvl) => {
|
|
65866
|
+
const pPr = findChild(lvl, "w:pPr");
|
|
65867
|
+
const ind = findChild(pPr, "w:ind");
|
|
65868
|
+
if (!ind) return void 0;
|
|
65869
|
+
const left2 = parseNumberAttr(getAttribute(ind, "w:left"));
|
|
65870
|
+
const right2 = parseNumberAttr(getAttribute(ind, "w:right"));
|
|
65871
|
+
const firstLine = parseNumberAttr(getAttribute(ind, "w:firstLine"));
|
|
65872
|
+
const hanging = parseNumberAttr(getAttribute(ind, "w:hanging"));
|
|
65873
|
+
const indent2 = {};
|
|
65874
|
+
if (left2 != null) indent2.left = left2;
|
|
65875
|
+
if (right2 != null) indent2.right = right2;
|
|
65876
|
+
if (firstLine != null) indent2.firstLine = firstLine;
|
|
65877
|
+
if (hanging != null) indent2.hanging = hanging;
|
|
65878
|
+
return Object.keys(indent2).length ? indent2 : void 0;
|
|
65879
|
+
};
|
|
65880
|
+
const normalizeColor = (value) => {
|
|
65881
|
+
if (typeof value !== "string") return void 0;
|
|
65882
|
+
const trimmed = value.trim();
|
|
65883
|
+
if (!trimmed || trimmed.toLowerCase() === "auto") return void 0;
|
|
65884
|
+
const upper = trimmed.startsWith("#") ? trimmed.slice(1) : trimmed;
|
|
65885
|
+
return `#${upper.toUpperCase()}`;
|
|
65886
|
+
};
|
|
65887
|
+
const extractMarkerRun = (lvl) => {
|
|
65888
|
+
const rPr = findChild(lvl, "w:rPr");
|
|
65889
|
+
if (!rPr) return void 0;
|
|
65890
|
+
const run2 = {};
|
|
65891
|
+
const rFonts = findChild(rPr, "w:rFonts");
|
|
65892
|
+
const font = getAttribute(rFonts, "w:ascii") ?? getAttribute(rFonts, "w:hAnsi") ?? getAttribute(rFonts, "w:eastAsia");
|
|
65893
|
+
if (typeof font === "string" && font.trim()) {
|
|
65894
|
+
run2.fontFamily = font;
|
|
65895
|
+
}
|
|
65896
|
+
const sz = parseNumberAttr(getAttribute(findChild(rPr, "w:sz"), "w:val")) ?? parseNumberAttr(getAttribute(findChild(rPr, "w:szCs"), "w:val"));
|
|
65897
|
+
if (sz != null) {
|
|
65898
|
+
run2.fontSize = sz / 2;
|
|
65899
|
+
}
|
|
65900
|
+
const color2 = normalizeColor(getAttribute(findChild(rPr, "w:color"), "w:val"));
|
|
65901
|
+
if (color2) run2.color = color2;
|
|
65902
|
+
if (findChild(rPr, "w:b")) run2.bold = true;
|
|
65903
|
+
if (findChild(rPr, "w:i")) run2.italic = true;
|
|
65904
|
+
const spacingTwips = parseNumberAttr(getAttribute(findChild(rPr, "w:spacing"), "w:val"));
|
|
65905
|
+
if (spacingTwips != null && Number.isFinite(spacingTwips)) {
|
|
65906
|
+
run2.letterSpacing = twipsToPx$1(spacingTwips);
|
|
65907
|
+
}
|
|
65908
|
+
return Object.keys(run2).length ? run2 : void 0;
|
|
65909
|
+
};
|
|
65910
|
+
const findNumFmtElement = (lvl) => {
|
|
65911
|
+
if (!lvl) return void 0;
|
|
65912
|
+
const direct = findChild(lvl, "w:numFmt");
|
|
65913
|
+
if (direct) return direct;
|
|
65914
|
+
const alternate = findChild(lvl, "mc:AlternateContent");
|
|
65915
|
+
const choice = findChild(alternate, "mc:Choice");
|
|
65916
|
+
if (choice) {
|
|
65917
|
+
return findChild(choice, "w:numFmt");
|
|
65918
|
+
}
|
|
65919
|
+
return void 0;
|
|
65920
|
+
};
|
|
65921
|
+
const resolveNumberingFromContext = (numId, ilvl, numbering) => {
|
|
65922
|
+
const definitions = numbering?.definitions;
|
|
65923
|
+
const abstracts = numbering?.abstracts;
|
|
65924
|
+
if (!definitions || !abstracts) return void 0;
|
|
65925
|
+
const numDef = asOoxmlElement(definitions[String(numId)]);
|
|
65926
|
+
if (!numDef) return void 0;
|
|
65927
|
+
const abstractId = getAttribute(findChild(numDef, "w:abstractNumId"), "w:val");
|
|
65928
|
+
if (abstractId == null) return void 0;
|
|
65929
|
+
const abstract = asOoxmlElement(abstracts[String(abstractId)]);
|
|
65930
|
+
if (!abstract) return void 0;
|
|
65931
|
+
let levelDef = abstract.elements?.find(
|
|
65932
|
+
(el) => el?.name === "w:lvl" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
|
|
65933
|
+
);
|
|
65934
|
+
const override = numDef.elements?.find(
|
|
65935
|
+
(el) => el?.name === "w:lvlOverride" && parseNumberAttr(el.attributes?.["w:ilvl"]) === ilvl
|
|
65936
|
+
);
|
|
65937
|
+
const overrideLvl = findChild(override, "w:lvl");
|
|
65938
|
+
if (overrideLvl) {
|
|
65939
|
+
levelDef = overrideLvl;
|
|
65940
|
+
}
|
|
65941
|
+
const startOverride = parseNumberAttr(getAttribute(findChild(override, "w:startOverride"), "w:val"));
|
|
65942
|
+
if (!levelDef) return void 0;
|
|
65943
|
+
const numFmtEl = findNumFmtElement(levelDef);
|
|
65944
|
+
const lvlText = getAttribute(findChild(levelDef, "w:lvlText"), "w:val");
|
|
65945
|
+
const start2 = startOverride ?? parseNumberAttr(getAttribute(findChild(levelDef, "w:start"), "w:val"));
|
|
65946
|
+
const suffix2 = normalizeSuffix(getAttribute(findChild(levelDef, "w:suff"), "w:val"));
|
|
65947
|
+
const lvlJc = normalizeJustification(getAttribute(findChild(levelDef, "w:lvlJc"), "w:val"));
|
|
65948
|
+
const indent2 = extractIndentFromLevel(levelDef);
|
|
65949
|
+
const markerRun = extractMarkerRun(levelDef);
|
|
65950
|
+
const numFmt = normalizeNumFmt(getAttribute(numFmtEl, "w:val"));
|
|
65951
|
+
return {
|
|
65952
|
+
format: numFmt,
|
|
65953
|
+
lvlText,
|
|
65954
|
+
start: start2,
|
|
65955
|
+
suffix: suffix2,
|
|
65956
|
+
lvlJc,
|
|
65957
|
+
resolvedLevelIndent: indent2,
|
|
65958
|
+
resolvedMarkerRpr: markerRun
|
|
65959
|
+
};
|
|
65960
|
+
};
|
|
65818
65961
|
const isTruthy = (value) => {
|
|
65819
65962
|
if (value === true || value === 1) return true;
|
|
65820
65963
|
if (typeof value === "string") {
|
|
@@ -66447,6 +66590,30 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
66447
66590
|
const ilvl = Number.isFinite(numberingProps.ilvl) ? Math.max(0, Math.floor(Number(numberingProps.ilvl))) : 0;
|
|
66448
66591
|
const listRendering = normalizeListRenderingAttrs(attrs.listRendering);
|
|
66449
66592
|
const numericNumId = typeof numId === "number" ? numId : void 0;
|
|
66593
|
+
const resolvedLevel = resolveNumberingFromContext(numId, ilvl, converterContext?.numbering);
|
|
66594
|
+
if (resolvedLevel) {
|
|
66595
|
+
if (resolvedLevel.format && numberingProps.format == null) {
|
|
66596
|
+
numberingProps.format = resolvedLevel.format;
|
|
66597
|
+
}
|
|
66598
|
+
if (resolvedLevel.lvlText && numberingProps.lvlText == null) {
|
|
66599
|
+
numberingProps.lvlText = resolvedLevel.lvlText;
|
|
66600
|
+
}
|
|
66601
|
+
if (resolvedLevel.start != null && numberingProps.start == null) {
|
|
66602
|
+
numberingProps.start = resolvedLevel.start;
|
|
66603
|
+
}
|
|
66604
|
+
if (resolvedLevel.suffix && numberingProps.suffix == null) {
|
|
66605
|
+
numberingProps.suffix = resolvedLevel.suffix;
|
|
66606
|
+
}
|
|
66607
|
+
if (resolvedLevel.lvlJc && numberingProps.lvlJc == null) {
|
|
66608
|
+
numberingProps.lvlJc = resolvedLevel.lvlJc;
|
|
66609
|
+
}
|
|
66610
|
+
if (resolvedLevel.resolvedLevelIndent && !numberingProps.resolvedLevelIndent) {
|
|
66611
|
+
numberingProps.resolvedLevelIndent = resolvedLevel.resolvedLevelIndent;
|
|
66612
|
+
}
|
|
66613
|
+
if (resolvedLevel.resolvedMarkerRpr && !numberingProps.resolvedMarkerRpr) {
|
|
66614
|
+
numberingProps.resolvedMarkerRpr = resolvedLevel.resolvedMarkerRpr;
|
|
66615
|
+
}
|
|
66616
|
+
}
|
|
66450
66617
|
let counterValue = 1;
|
|
66451
66618
|
if (listCounterContext && typeof numericNumId === "number") {
|
|
66452
66619
|
counterValue = listCounterContext.incrementListCounter(numericNumId, ilvl);
|
|
@@ -67672,41 +67839,45 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
67672
67839
|
}
|
|
67673
67840
|
return;
|
|
67674
67841
|
}
|
|
67675
|
-
if (node2.type === "hardBreak") {
|
|
67676
|
-
flushParagraph();
|
|
67677
|
-
blocks2.push({
|
|
67678
|
-
kind: "pageBreak",
|
|
67679
|
-
id: nextId(),
|
|
67680
|
-
attrs: node2.attrs || {}
|
|
67681
|
-
});
|
|
67682
|
-
return;
|
|
67683
|
-
}
|
|
67684
|
-
if (node2.type === "lineBreak") {
|
|
67842
|
+
if (node2.type === "hardBreak" || node2.type === "lineBreak") {
|
|
67685
67843
|
const attrs = node2.attrs ?? {};
|
|
67686
|
-
|
|
67844
|
+
const breakType = attrs.pageBreakType ?? attrs.lineBreakType ?? "line";
|
|
67845
|
+
if (breakType === "page") {
|
|
67846
|
+
flushParagraph();
|
|
67847
|
+
blocks2.push({
|
|
67848
|
+
kind: "pageBreak",
|
|
67849
|
+
id: nextId(),
|
|
67850
|
+
attrs: node2.attrs || {}
|
|
67851
|
+
});
|
|
67852
|
+
return;
|
|
67853
|
+
}
|
|
67854
|
+
if (breakType === "column") {
|
|
67687
67855
|
flushParagraph();
|
|
67688
67856
|
blocks2.push({
|
|
67689
67857
|
kind: "columnBreak",
|
|
67690
67858
|
id: nextId(),
|
|
67691
67859
|
attrs: node2.attrs || {}
|
|
67692
67860
|
});
|
|
67861
|
+
return;
|
|
67862
|
+
}
|
|
67863
|
+
const lineBreakRun = { kind: "lineBreak", attrs: {} };
|
|
67864
|
+
const lbAttrs = {};
|
|
67865
|
+
if (attrs.lineBreakType) lbAttrs.lineBreakType = String(attrs.lineBreakType);
|
|
67866
|
+
if (attrs.clear) lbAttrs.clear = String(attrs.clear);
|
|
67867
|
+
if (Object.keys(lbAttrs).length > 0) {
|
|
67868
|
+
lineBreakRun.attrs = lbAttrs;
|
|
67693
67869
|
} else {
|
|
67694
|
-
|
|
67695
|
-
|
|
67696
|
-
|
|
67697
|
-
|
|
67698
|
-
|
|
67699
|
-
|
|
67700
|
-
} else {
|
|
67701
|
-
delete lineBreakRun.attrs;
|
|
67702
|
-
}
|
|
67703
|
-
const pos = positions.get(node2);
|
|
67704
|
-
if (pos) {
|
|
67705
|
-
lineBreakRun.pmStart = pos.start;
|
|
67706
|
-
lineBreakRun.pmEnd = pos.end;
|
|
67707
|
-
}
|
|
67708
|
-
currentRuns.push(lineBreakRun);
|
|
67870
|
+
delete lineBreakRun.attrs;
|
|
67871
|
+
}
|
|
67872
|
+
const pos = positions.get(node2);
|
|
67873
|
+
if (pos) {
|
|
67874
|
+
lineBreakRun.pmStart = pos.start;
|
|
67875
|
+
lineBreakRun.pmEnd = pos.end;
|
|
67709
67876
|
}
|
|
67877
|
+
if (activeSdt) {
|
|
67878
|
+
lineBreakRun.sdt = activeSdt;
|
|
67879
|
+
}
|
|
67880
|
+
currentRuns.push(lineBreakRun);
|
|
67710
67881
|
return;
|
|
67711
67882
|
}
|
|
67712
67883
|
};
|
|
@@ -68299,6 +68470,22 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68299
68470
|
};
|
|
68300
68471
|
const isTableRowNode = (node2) => node2.type === "tableRow" || node2.type === "table_row";
|
|
68301
68472
|
const isTableCellNode = (node2) => node2.type === "tableCell" || node2.type === "table_cell" || node2.type === "tableHeader" || node2.type === "table_header";
|
|
68473
|
+
const normalizeRowHeight = (rowProps) => {
|
|
68474
|
+
if (!rowProps || typeof rowProps !== "object") return void 0;
|
|
68475
|
+
const rawRowHeight = rowProps.rowHeight;
|
|
68476
|
+
if (!rawRowHeight || typeof rawRowHeight !== "object") return void 0;
|
|
68477
|
+
const heightObj = rawRowHeight;
|
|
68478
|
+
const rawValue = pickNumber(heightObj.value ?? heightObj.val);
|
|
68479
|
+
if (rawValue == null) return void 0;
|
|
68480
|
+
const rawRule = heightObj.rule ?? heightObj.hRule;
|
|
68481
|
+
const rule = rawRule === "exact" || rawRule === "atLeast" || rawRule === "auto" ? rawRule : "atLeast";
|
|
68482
|
+
const isLikelyTwips = rawValue >= 300 || Math.abs(rawValue % 15) < 1e-6;
|
|
68483
|
+
const valuePx = isLikelyTwips ? twipsToPx$1(rawValue) : rawValue;
|
|
68484
|
+
return {
|
|
68485
|
+
value: valuePx,
|
|
68486
|
+
rule
|
|
68487
|
+
};
|
|
68488
|
+
};
|
|
68302
68489
|
const parseTableCell = (args) => {
|
|
68303
68490
|
const { cellNode, rowIndex, cellIndex, context, defaultCellPadding } = args;
|
|
68304
68491
|
if (!isTableCellNode(cellNode) || !Array.isArray(cellNode.content)) {
|
|
@@ -68336,8 +68523,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68336
68523
|
const padding = extractCellPadding(cellNode.attrs ?? {}) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
|
|
68337
68524
|
if (padding) cellAttrs.padding = padding;
|
|
68338
68525
|
const verticalAlign = cellNode.attrs?.verticalAlign;
|
|
68339
|
-
|
|
68340
|
-
|
|
68526
|
+
const normalizedVerticalAlign = verticalAlign === "middle" ? "center" : verticalAlign === "center" ? "center" : verticalAlign;
|
|
68527
|
+
if (normalizedVerticalAlign === "top" || normalizedVerticalAlign === "center" || normalizedVerticalAlign === "bottom") {
|
|
68528
|
+
cellAttrs.verticalAlign = normalizedVerticalAlign;
|
|
68341
68529
|
}
|
|
68342
68530
|
const background = cellNode.attrs?.background;
|
|
68343
68531
|
if (background && typeof background.color === "string") {
|
|
@@ -68380,15 +68568,89 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68380
68568
|
});
|
|
68381
68569
|
if (cells.length === 0) return null;
|
|
68382
68570
|
const rowProps = rowNode.attrs?.tableRowProperties;
|
|
68571
|
+
const rowHeight = normalizeRowHeight(rowProps);
|
|
68383
68572
|
const attrs = rowProps && typeof rowProps === "object" ? {
|
|
68384
|
-
tableRowProperties: rowProps
|
|
68385
|
-
|
|
68573
|
+
tableRowProperties: rowProps,
|
|
68574
|
+
...rowHeight ? { rowHeight } : {}
|
|
68575
|
+
} : rowHeight ? { rowHeight } : void 0;
|
|
68386
68576
|
return {
|
|
68387
68577
|
id: context.nextBlockId(`row-${rowIndex}`),
|
|
68388
68578
|
cells,
|
|
68389
68579
|
attrs
|
|
68390
68580
|
};
|
|
68391
68581
|
};
|
|
68582
|
+
function extractFloatingTableAnchorWrap(node2) {
|
|
68583
|
+
const tableProperties = node2.attrs?.tableProperties;
|
|
68584
|
+
const floatingProps = tableProperties?.floatingTableProperties;
|
|
68585
|
+
if (!floatingProps) {
|
|
68586
|
+
return {};
|
|
68587
|
+
}
|
|
68588
|
+
const hasPositioning = floatingProps.tblpX !== void 0 || floatingProps.tblpY !== void 0 || floatingProps.tblpXSpec !== void 0 || floatingProps.tblpYSpec !== void 0 || floatingProps.horzAnchor !== void 0 || floatingProps.vertAnchor !== void 0;
|
|
68589
|
+
if (!hasPositioning) {
|
|
68590
|
+
return {};
|
|
68591
|
+
}
|
|
68592
|
+
const mapHorzAnchor = (val) => {
|
|
68593
|
+
switch (val) {
|
|
68594
|
+
case "page":
|
|
68595
|
+
return "page";
|
|
68596
|
+
case "margin":
|
|
68597
|
+
return "margin";
|
|
68598
|
+
case "text":
|
|
68599
|
+
default:
|
|
68600
|
+
return "column";
|
|
68601
|
+
}
|
|
68602
|
+
};
|
|
68603
|
+
const mapVertAnchor = (val) => {
|
|
68604
|
+
switch (val) {
|
|
68605
|
+
case "page":
|
|
68606
|
+
return "page";
|
|
68607
|
+
case "margin":
|
|
68608
|
+
return "margin";
|
|
68609
|
+
case "text":
|
|
68610
|
+
default:
|
|
68611
|
+
return "paragraph";
|
|
68612
|
+
}
|
|
68613
|
+
};
|
|
68614
|
+
const anchor = {
|
|
68615
|
+
isAnchored: true,
|
|
68616
|
+
hRelativeFrom: mapHorzAnchor(floatingProps.horzAnchor),
|
|
68617
|
+
vRelativeFrom: mapVertAnchor(floatingProps.vertAnchor)
|
|
68618
|
+
};
|
|
68619
|
+
if (floatingProps.tblpXSpec) {
|
|
68620
|
+
anchor.alignH = floatingProps.tblpXSpec;
|
|
68621
|
+
}
|
|
68622
|
+
if (floatingProps.tblpYSpec) {
|
|
68623
|
+
anchor.alignV = floatingProps.tblpYSpec;
|
|
68624
|
+
}
|
|
68625
|
+
if (floatingProps.tblpX !== void 0) {
|
|
68626
|
+
anchor.offsetH = twipsToPx$1(floatingProps.tblpX);
|
|
68627
|
+
}
|
|
68628
|
+
if (floatingProps.tblpY !== void 0) {
|
|
68629
|
+
anchor.offsetV = twipsToPx$1(floatingProps.tblpY);
|
|
68630
|
+
}
|
|
68631
|
+
const hasDistances = floatingProps.leftFromText !== void 0 || floatingProps.rightFromText !== void 0 || floatingProps.topFromText !== void 0 || floatingProps.bottomFromText !== void 0;
|
|
68632
|
+
const wrap2 = {
|
|
68633
|
+
type: "Square",
|
|
68634
|
+
// Floating tables with text distances use square wrapping
|
|
68635
|
+
wrapText: "bothSides"
|
|
68636
|
+
// Default to text on both sides
|
|
68637
|
+
};
|
|
68638
|
+
if (hasDistances) {
|
|
68639
|
+
if (floatingProps.topFromText !== void 0) {
|
|
68640
|
+
wrap2.distTop = twipsToPx$1(floatingProps.topFromText);
|
|
68641
|
+
}
|
|
68642
|
+
if (floatingProps.bottomFromText !== void 0) {
|
|
68643
|
+
wrap2.distBottom = twipsToPx$1(floatingProps.bottomFromText);
|
|
68644
|
+
}
|
|
68645
|
+
if (floatingProps.leftFromText !== void 0) {
|
|
68646
|
+
wrap2.distLeft = twipsToPx$1(floatingProps.leftFromText);
|
|
68647
|
+
}
|
|
68648
|
+
if (floatingProps.rightFromText !== void 0) {
|
|
68649
|
+
wrap2.distRight = twipsToPx$1(floatingProps.rightFromText);
|
|
68650
|
+
}
|
|
68651
|
+
}
|
|
68652
|
+
return { anchor, wrap: wrap2 };
|
|
68653
|
+
}
|
|
68392
68654
|
function tableNodeToBlock$1(node2, nextBlockId, positions, defaultFont, defaultSize, _styleContext, trackedChanges, bookmarks, hyperlinkConfig, themeColors, paragraphToFlowBlocks2, converterContext) {
|
|
68393
68655
|
if (!Array.isArray(node2.content) || node2.content.length === 0) return null;
|
|
68394
68656
|
if (!paragraphToFlowBlocks2) return null;
|
|
@@ -68453,6 +68715,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68453
68715
|
if (tableLayout) {
|
|
68454
68716
|
tableAttrs.tableLayout = tableLayout;
|
|
68455
68717
|
}
|
|
68718
|
+
const tableProperties = node2.attrs?.tableProperties;
|
|
68719
|
+
if (tableProperties && typeof tableProperties === "object") {
|
|
68720
|
+
tableAttrs.tableProperties = tableProperties;
|
|
68721
|
+
}
|
|
68456
68722
|
let columnWidths = void 0;
|
|
68457
68723
|
const twipsToPixels2 = (twips) => {
|
|
68458
68724
|
const PIXELS_PER_INCH2 = 96;
|
|
@@ -68496,12 +68762,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68496
68762
|
columnWidths = void 0;
|
|
68497
68763
|
}
|
|
68498
68764
|
}
|
|
68765
|
+
const { anchor, wrap: wrap2 } = extractFloatingTableAnchorWrap(node2);
|
|
68499
68766
|
const tableBlock = {
|
|
68500
68767
|
kind: "table",
|
|
68501
68768
|
id: nextBlockId("table"),
|
|
68502
68769
|
rows,
|
|
68503
68770
|
attrs: Object.keys(tableAttrs).length > 0 ? tableAttrs : void 0,
|
|
68504
|
-
columnWidths
|
|
68771
|
+
columnWidths,
|
|
68772
|
+
...anchor ? { anchor } : {},
|
|
68773
|
+
...wrap2 ? { wrap: wrap2 } : {}
|
|
68505
68774
|
};
|
|
68506
68775
|
return tableBlock;
|
|
68507
68776
|
}
|
|
@@ -68837,7 +69106,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68837
69106
|
return measurementCtx;
|
|
68838
69107
|
}
|
|
68839
69108
|
function getRunFontString(run2) {
|
|
68840
|
-
if (run2.kind === "tab" || run2.kind === "lineBreak" || "src" in run2) {
|
|
69109
|
+
if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
|
|
68841
69110
|
return "normal normal 16px Arial";
|
|
68842
69111
|
}
|
|
68843
69112
|
const style2 = run2.italic ? "italic" : "normal";
|
|
@@ -68864,6 +69133,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68864
69133
|
result.push(run2);
|
|
68865
69134
|
continue;
|
|
68866
69135
|
}
|
|
69136
|
+
if (run2.kind === "break") {
|
|
69137
|
+
result.push(run2);
|
|
69138
|
+
continue;
|
|
69139
|
+
}
|
|
68867
69140
|
const text2 = run2.text ?? "";
|
|
68868
69141
|
const isFirstRun = runIndex === line.fromRun;
|
|
68869
69142
|
const isLastRun = runIndex === line.toRun;
|
|
@@ -68897,7 +69170,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68897
69170
|
1,
|
|
68898
69171
|
runs22.reduce((sum, run2) => {
|
|
68899
69172
|
if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
|
|
68900
|
-
if ("src" in run2 || run2.kind === "lineBreak") return sum;
|
|
69173
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
|
|
68901
69174
|
return sum + (run2.text ?? "").length;
|
|
68902
69175
|
}, 0)
|
|
68903
69176
|
);
|
|
@@ -68918,7 +69191,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68918
69191
|
currentCharOffset += runLength2;
|
|
68919
69192
|
continue;
|
|
68920
69193
|
}
|
|
68921
|
-
const text2 = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
69194
|
+
const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
68922
69195
|
const runLength = text2.length;
|
|
68923
69196
|
if (currentCharOffset + runLength >= charOffset) {
|
|
68924
69197
|
const offsetInRun = charOffset - currentCharOffset;
|
|
@@ -68961,7 +69234,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68961
69234
|
if (isTabRun$1(run2)) {
|
|
68962
69235
|
return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
|
|
68963
69236
|
}
|
|
68964
|
-
if ("src" in run2 || run2.kind === "lineBreak") {
|
|
69237
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
68965
69238
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
68966
69239
|
}
|
|
68967
69240
|
const text2 = run2.text ?? "";
|
|
@@ -68984,7 +69257,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
68984
69257
|
1,
|
|
68985
69258
|
runs22.reduce((sum, run2) => {
|
|
68986
69259
|
if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
|
|
68987
|
-
if ("src" in run2 || run2.kind === "lineBreak") return sum;
|
|
69260
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") return sum;
|
|
68988
69261
|
return sum + (run2.text ?? "").length;
|
|
68989
69262
|
}, 0)
|
|
68990
69263
|
);
|
|
@@ -69019,7 +69292,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69019
69292
|
currentCharOffset += TAB_CHAR_LENGTH;
|
|
69020
69293
|
continue;
|
|
69021
69294
|
}
|
|
69022
|
-
const text2 = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
69295
|
+
const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
69023
69296
|
const runLength = text2.length;
|
|
69024
69297
|
if (runLength === 0) continue;
|
|
69025
69298
|
ctx2.font = getRunFontString(run2);
|
|
@@ -69452,6 +69725,40 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69452
69725
|
};
|
|
69453
69726
|
zones.push(zone);
|
|
69454
69727
|
},
|
|
69728
|
+
registerTable(tableBlock, measure, anchorY, columnIndex, pageNumber) {
|
|
69729
|
+
if (!tableBlock.anchor?.isAnchored) {
|
|
69730
|
+
return;
|
|
69731
|
+
}
|
|
69732
|
+
const { wrap: wrap2, anchor } = tableBlock;
|
|
69733
|
+
const wrapType = wrap2?.type ?? "None";
|
|
69734
|
+
if (wrapType === "None") {
|
|
69735
|
+
return;
|
|
69736
|
+
}
|
|
69737
|
+
const tableWidth = measure.totalWidth ?? 0;
|
|
69738
|
+
const tableHeight = measure.totalHeight ?? 0;
|
|
69739
|
+
const x2 = computeTableAnchorX(anchor, columnIndex, columns, tableWidth, margins, pageWidth);
|
|
69740
|
+
const y2 = anchorY + (anchor.offsetV ?? 0);
|
|
69741
|
+
const zone = {
|
|
69742
|
+
imageBlockId: tableBlock.id,
|
|
69743
|
+
// Reusing imageBlockId field for table id
|
|
69744
|
+
pageNumber,
|
|
69745
|
+
columnIndex,
|
|
69746
|
+
bounds: {
|
|
69747
|
+
x: x2,
|
|
69748
|
+
y: y2,
|
|
69749
|
+
width: tableWidth,
|
|
69750
|
+
height: tableHeight
|
|
69751
|
+
},
|
|
69752
|
+
distances: {
|
|
69753
|
+
top: wrap2?.distTop ?? 0,
|
|
69754
|
+
bottom: wrap2?.distBottom ?? 0,
|
|
69755
|
+
left: wrap2?.distLeft ?? 0,
|
|
69756
|
+
right: wrap2?.distRight ?? 0
|
|
69757
|
+
},
|
|
69758
|
+
wrapMode: computeTableWrapMode(wrap2)
|
|
69759
|
+
};
|
|
69760
|
+
zones.push(zone);
|
|
69761
|
+
},
|
|
69455
69762
|
getExclusionsForLine(lineY, lineHeight2, columnIndex, pageNumber) {
|
|
69456
69763
|
const result = zones.filter((zone) => {
|
|
69457
69764
|
if (zone.pageNumber !== pageNumber || zone.columnIndex !== columnIndex) {
|
|
@@ -69559,6 +69866,49 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
69559
69866
|
if (wrapText === "largest") return "largest";
|
|
69560
69867
|
return "both";
|
|
69561
69868
|
}
|
|
69869
|
+
function computeTableAnchorX(anchor, columnIndex, columns, tableWidth, margins, pageWidth) {
|
|
69870
|
+
const alignH = anchor.alignH ?? "left";
|
|
69871
|
+
const offsetH = anchor.offsetH ?? 0;
|
|
69872
|
+
const marginLeft = Math.max(0, margins?.left ?? 0);
|
|
69873
|
+
const marginRight = Math.max(0, margins?.right ?? 0);
|
|
69874
|
+
const contentWidth = pageWidth != null ? Math.max(1, pageWidth - (marginLeft + marginRight)) : columns.width;
|
|
69875
|
+
const contentLeft = marginLeft;
|
|
69876
|
+
const columnLeft = contentLeft + columnIndex * (columns.width + columns.gap);
|
|
69877
|
+
const relativeFrom = anchor.hRelativeFrom ?? "column";
|
|
69878
|
+
let baseX;
|
|
69879
|
+
let availableWidth;
|
|
69880
|
+
if (relativeFrom === "page") {
|
|
69881
|
+
if (columns.count === 1) {
|
|
69882
|
+
baseX = contentLeft;
|
|
69883
|
+
availableWidth = contentWidth;
|
|
69884
|
+
} else {
|
|
69885
|
+
baseX = 0;
|
|
69886
|
+
availableWidth = pageWidth != null ? pageWidth : contentWidth;
|
|
69887
|
+
}
|
|
69888
|
+
} else if (relativeFrom === "margin") {
|
|
69889
|
+
baseX = contentLeft;
|
|
69890
|
+
availableWidth = contentWidth;
|
|
69891
|
+
} else {
|
|
69892
|
+
baseX = columnLeft;
|
|
69893
|
+
availableWidth = columns.width;
|
|
69894
|
+
}
|
|
69895
|
+
let effectiveAlignH = alignH;
|
|
69896
|
+
if (alignH === "inside") effectiveAlignH = "left";
|
|
69897
|
+
if (alignH === "outside") effectiveAlignH = "right";
|
|
69898
|
+
const result = effectiveAlignH === "left" ? baseX + offsetH : effectiveAlignH === "right" ? baseX + availableWidth - tableWidth - offsetH : effectiveAlignH === "center" ? baseX + (availableWidth - tableWidth) / 2 + offsetH : baseX;
|
|
69899
|
+
return result;
|
|
69900
|
+
}
|
|
69901
|
+
function computeTableWrapMode(wrap2) {
|
|
69902
|
+
if (!wrap2) return "none";
|
|
69903
|
+
if (wrap2.type === "None") {
|
|
69904
|
+
return "none";
|
|
69905
|
+
}
|
|
69906
|
+
const wrapText = wrap2.wrapText ?? "bothSides";
|
|
69907
|
+
if (wrapText === "left") return "right";
|
|
69908
|
+
if (wrapText === "right") return "left";
|
|
69909
|
+
if (wrapText === "largest") return "largest";
|
|
69910
|
+
return "both";
|
|
69911
|
+
}
|
|
69562
69912
|
function computeNextSectionPropsAtBreak(blocks2) {
|
|
69563
69913
|
const nextSectionPropsAtBreak = /* @__PURE__ */ new Map();
|
|
69564
69914
|
const docxBreakIndexes = [];
|
|
@@ -70255,6 +70605,206 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70255
70605
|
}
|
|
70256
70606
|
return boundaries;
|
|
70257
70607
|
}
|
|
70608
|
+
function countHeaderRows(block) {
|
|
70609
|
+
let count = 0;
|
|
70610
|
+
for (let i2 = 0; i2 < block.rows.length; i2++) {
|
|
70611
|
+
const row2 = block.rows[i2];
|
|
70612
|
+
const repeatHeader = row2.attrs?.tableRowProperties?.repeatHeader;
|
|
70613
|
+
if (repeatHeader === true) {
|
|
70614
|
+
count++;
|
|
70615
|
+
} else {
|
|
70616
|
+
break;
|
|
70617
|
+
}
|
|
70618
|
+
}
|
|
70619
|
+
return count;
|
|
70620
|
+
}
|
|
70621
|
+
function sumRowHeights(rows, fromRow, toRow) {
|
|
70622
|
+
let total = 0;
|
|
70623
|
+
for (let i2 = fromRow; i2 < toRow && i2 < rows.length; i2++) {
|
|
70624
|
+
total += rows[i2].height;
|
|
70625
|
+
}
|
|
70626
|
+
return total;
|
|
70627
|
+
}
|
|
70628
|
+
function calculateFragmentHeight(fragment, measure, _headerCount) {
|
|
70629
|
+
let height = 0;
|
|
70630
|
+
if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0) {
|
|
70631
|
+
height += sumRowHeights(measure.rows, 0, fragment.repeatHeaderCount);
|
|
70632
|
+
}
|
|
70633
|
+
height += sumRowHeights(measure.rows, fragment.fromRow, fragment.toRow);
|
|
70634
|
+
return height;
|
|
70635
|
+
}
|
|
70636
|
+
const MIN_PARTIAL_ROW_HEIGHT = 20;
|
|
70637
|
+
function getCellLines(cell2) {
|
|
70638
|
+
if (cell2.blocks && cell2.blocks.length > 0) {
|
|
70639
|
+
const allLines = [];
|
|
70640
|
+
for (const block of cell2.blocks) {
|
|
70641
|
+
if (block.kind === "paragraph") {
|
|
70642
|
+
if (block.kind === "paragraph" && "lines" in block) {
|
|
70643
|
+
const paraBlock = block;
|
|
70644
|
+
if (paraBlock.lines) {
|
|
70645
|
+
allLines.push(...paraBlock.lines);
|
|
70646
|
+
}
|
|
70647
|
+
}
|
|
70648
|
+
}
|
|
70649
|
+
}
|
|
70650
|
+
return allLines;
|
|
70651
|
+
}
|
|
70652
|
+
if (cell2.paragraph?.lines) {
|
|
70653
|
+
return cell2.paragraph.lines;
|
|
70654
|
+
}
|
|
70655
|
+
return [];
|
|
70656
|
+
}
|
|
70657
|
+
function getCellPadding(cellIdx, blockRow) {
|
|
70658
|
+
const padding = blockRow?.cells?.[cellIdx]?.attrs?.padding ?? {};
|
|
70659
|
+
return {
|
|
70660
|
+
top: padding.top ?? 2,
|
|
70661
|
+
bottom: padding.bottom ?? 2,
|
|
70662
|
+
left: padding.left ?? 4,
|
|
70663
|
+
right: padding.right ?? 4
|
|
70664
|
+
};
|
|
70665
|
+
}
|
|
70666
|
+
function getCellTotalLines(cell2) {
|
|
70667
|
+
return getCellLines(cell2).length;
|
|
70668
|
+
}
|
|
70669
|
+
function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLineByCell) {
|
|
70670
|
+
const row2 = measure.rows[rowIndex];
|
|
70671
|
+
if (!row2) {
|
|
70672
|
+
throw new Error(`Invalid rowIndex ${rowIndex}: measure.rows has ${measure.rows.length} rows`);
|
|
70673
|
+
}
|
|
70674
|
+
const cellCount = row2.cells.length;
|
|
70675
|
+
const startLines = fromLineByCell || new Array(cellCount).fill(0);
|
|
70676
|
+
const toLineByCell = [];
|
|
70677
|
+
const heightByCell = [];
|
|
70678
|
+
const cellPaddings = row2.cells.map((_2, idx) => getCellPadding(idx, blockRow));
|
|
70679
|
+
for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
|
70680
|
+
const cell2 = row2.cells[cellIdx];
|
|
70681
|
+
const startLine = startLines[cellIdx] || 0;
|
|
70682
|
+
const cellPadding = cellPaddings[cellIdx];
|
|
70683
|
+
const availableForLines = Math.max(0, availableHeight - (cellPadding.top + cellPadding.bottom));
|
|
70684
|
+
const lines = getCellLines(cell2);
|
|
70685
|
+
let cumulativeHeight = 0;
|
|
70686
|
+
let cutLine = startLine;
|
|
70687
|
+
for (let i2 = startLine; i2 < lines.length; i2++) {
|
|
70688
|
+
const lineHeight2 = lines[i2].lineHeight || 0;
|
|
70689
|
+
if (cumulativeHeight + lineHeight2 > availableForLines) {
|
|
70690
|
+
break;
|
|
70691
|
+
}
|
|
70692
|
+
cumulativeHeight += lineHeight2;
|
|
70693
|
+
cutLine = i2 + 1;
|
|
70694
|
+
}
|
|
70695
|
+
toLineByCell.push(cutLine);
|
|
70696
|
+
heightByCell.push(cumulativeHeight);
|
|
70697
|
+
}
|
|
70698
|
+
const positiveHeights = heightByCell.filter((h2) => h2 > 0);
|
|
70699
|
+
const minHeight = positiveHeights.length > 0 ? Math.min(...positiveHeights) : 0;
|
|
70700
|
+
let actualPartialHeight = 0;
|
|
70701
|
+
let maxPaddingTotal = 0;
|
|
70702
|
+
for (let cellIdx = 0; cellIdx < cellCount; cellIdx++) {
|
|
70703
|
+
const cell2 = row2.cells[cellIdx];
|
|
70704
|
+
const startLine = startLines[cellIdx] || 0;
|
|
70705
|
+
const lines = getCellLines(cell2);
|
|
70706
|
+
const cellPadding = cellPaddings[cellIdx];
|
|
70707
|
+
const paddingTotal = cellPadding.top + cellPadding.bottom;
|
|
70708
|
+
maxPaddingTotal = Math.max(maxPaddingTotal, paddingTotal);
|
|
70709
|
+
let cumulativeHeight = 0;
|
|
70710
|
+
let cutLine = startLine;
|
|
70711
|
+
for (let i2 = startLine; i2 < lines.length; i2++) {
|
|
70712
|
+
const lineHeight2 = lines[i2].lineHeight || 0;
|
|
70713
|
+
if (cumulativeHeight + lineHeight2 > minHeight) {
|
|
70714
|
+
break;
|
|
70715
|
+
}
|
|
70716
|
+
cumulativeHeight += lineHeight2;
|
|
70717
|
+
cutLine = i2 + 1;
|
|
70718
|
+
}
|
|
70719
|
+
toLineByCell[cellIdx] = cutLine;
|
|
70720
|
+
actualPartialHeight = Math.max(actualPartialHeight, cumulativeHeight + paddingTotal);
|
|
70721
|
+
}
|
|
70722
|
+
const madeProgress = toLineByCell.some((cutLine, idx) => cutLine > (startLines[idx] || 0));
|
|
70723
|
+
const isFirstPart = startLines.every((l) => l === 0);
|
|
70724
|
+
const allCellsExhausted = toLineByCell.every((cutLine, idx) => {
|
|
70725
|
+
const totalLines = getCellTotalLines(row2.cells[idx]);
|
|
70726
|
+
return cutLine >= totalLines;
|
|
70727
|
+
});
|
|
70728
|
+
const isLastPart = allCellsExhausted || !madeProgress;
|
|
70729
|
+
if (actualPartialHeight === 0 && isFirstPart) {
|
|
70730
|
+
actualPartialHeight = maxPaddingTotal;
|
|
70731
|
+
}
|
|
70732
|
+
return {
|
|
70733
|
+
rowIndex,
|
|
70734
|
+
fromLineByCell: startLines,
|
|
70735
|
+
toLineByCell,
|
|
70736
|
+
isFirstPart,
|
|
70737
|
+
isLastPart,
|
|
70738
|
+
partialHeight: actualPartialHeight
|
|
70739
|
+
};
|
|
70740
|
+
}
|
|
70741
|
+
function findSplitPoint(block, measure, startRow, availableHeight, fullPageHeight, _pendingPartialRow) {
|
|
70742
|
+
let accumulatedHeight = 0;
|
|
70743
|
+
let lastFitRow = startRow;
|
|
70744
|
+
for (let i2 = startRow; i2 < block.rows.length; i2++) {
|
|
70745
|
+
const row2 = block.rows[i2];
|
|
70746
|
+
const rowHeight = measure.rows[i2]?.height || 0;
|
|
70747
|
+
const cantSplit = row2.attrs?.tableRowProperties?.cantSplit === true;
|
|
70748
|
+
if (accumulatedHeight + rowHeight <= availableHeight) {
|
|
70749
|
+
accumulatedHeight += rowHeight;
|
|
70750
|
+
lastFitRow = i2 + 1;
|
|
70751
|
+
} else {
|
|
70752
|
+
const remainingHeight = availableHeight - accumulatedHeight;
|
|
70753
|
+
if (fullPageHeight && rowHeight > fullPageHeight) {
|
|
70754
|
+
const partialRow = computePartialRow(i2, block.rows[i2], measure, remainingHeight);
|
|
70755
|
+
return { endRow: i2 + 1, partialRow };
|
|
70756
|
+
}
|
|
70757
|
+
if (cantSplit) {
|
|
70758
|
+
if (lastFitRow === startRow) {
|
|
70759
|
+
return { endRow: startRow, partialRow: null };
|
|
70760
|
+
}
|
|
70761
|
+
return { endRow: lastFitRow, partialRow: null };
|
|
70762
|
+
}
|
|
70763
|
+
if (remainingHeight >= MIN_PARTIAL_ROW_HEIGHT) {
|
|
70764
|
+
const partialRow = computePartialRow(i2, block.rows[i2], measure, remainingHeight);
|
|
70765
|
+
const hasContent = partialRow.toLineByCell.some(
|
|
70766
|
+
(cutLine, idx) => cutLine > (partialRow.fromLineByCell[idx] || 0)
|
|
70767
|
+
);
|
|
70768
|
+
if (hasContent) {
|
|
70769
|
+
return { endRow: i2 + 1, partialRow };
|
|
70770
|
+
}
|
|
70771
|
+
}
|
|
70772
|
+
return { endRow: lastFitRow, partialRow: null };
|
|
70773
|
+
}
|
|
70774
|
+
}
|
|
70775
|
+
return { endRow: block.rows.length, partialRow: null };
|
|
70776
|
+
}
|
|
70777
|
+
function generateFragmentMetadata(measure, _fromRow, _toRow, _repeatHeaderCount) {
|
|
70778
|
+
return {
|
|
70779
|
+
columnBoundaries: generateColumnBoundaries(measure),
|
|
70780
|
+
coordinateSystem: "fragment"
|
|
70781
|
+
};
|
|
70782
|
+
}
|
|
70783
|
+
function layoutMonolithicTable(context) {
|
|
70784
|
+
let state2 = context.ensurePage();
|
|
70785
|
+
if (state2.cursorY + context.measure.totalHeight > state2.contentBottom && state2.page.fragments.length > 0) {
|
|
70786
|
+
state2 = context.advanceColumn(state2);
|
|
70787
|
+
}
|
|
70788
|
+
state2 = context.ensurePage();
|
|
70789
|
+
const height = Math.min(context.measure.totalHeight, state2.contentBottom - state2.cursorY);
|
|
70790
|
+
const metadata = {
|
|
70791
|
+
columnBoundaries: generateColumnBoundaries(context.measure),
|
|
70792
|
+
coordinateSystem: "fragment"
|
|
70793
|
+
};
|
|
70794
|
+
const fragment = {
|
|
70795
|
+
kind: "table",
|
|
70796
|
+
blockId: context.block.id,
|
|
70797
|
+
fromRow: 0,
|
|
70798
|
+
toRow: context.block.rows.length,
|
|
70799
|
+
x: context.columnX(state2.columnIndex),
|
|
70800
|
+
y: state2.cursorY,
|
|
70801
|
+
width: Math.min(context.columnWidth, context.measure.totalWidth || context.columnWidth),
|
|
70802
|
+
height,
|
|
70803
|
+
metadata
|
|
70804
|
+
};
|
|
70805
|
+
state2.page.fragments.push(fragment);
|
|
70806
|
+
state2.cursorY += height;
|
|
70807
|
+
}
|
|
70258
70808
|
function layoutTableBlock({
|
|
70259
70809
|
block,
|
|
70260
70810
|
measure,
|
|
@@ -70263,30 +70813,176 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70263
70813
|
advanceColumn,
|
|
70264
70814
|
columnX
|
|
70265
70815
|
}) {
|
|
70816
|
+
if (block.anchor?.isAnchored) {
|
|
70817
|
+
return;
|
|
70818
|
+
}
|
|
70819
|
+
const tableProps = block.attrs?.tableProperties;
|
|
70820
|
+
const floatingProps = tableProps?.floatingTableProperties;
|
|
70821
|
+
if (floatingProps && Object.keys(floatingProps).length > 0) {
|
|
70822
|
+
layoutMonolithicTable({ block, measure, columnWidth, ensurePage, advanceColumn, columnX });
|
|
70823
|
+
return;
|
|
70824
|
+
}
|
|
70825
|
+
const headerCount = countHeaderRows(block);
|
|
70826
|
+
const headerHeight = headerCount > 0 ? sumRowHeights(measure.rows, 0, headerCount) : 0;
|
|
70266
70827
|
let state2 = ensurePage();
|
|
70267
|
-
|
|
70268
|
-
|
|
70828
|
+
let currentRow = 0;
|
|
70829
|
+
let isTableContinuation = false;
|
|
70830
|
+
let pendingPartialRow = null;
|
|
70831
|
+
while (currentRow < block.rows.length || pendingPartialRow !== null) {
|
|
70832
|
+
state2 = ensurePage();
|
|
70833
|
+
const availableHeight = state2.contentBottom - state2.cursorY;
|
|
70834
|
+
let repeatHeaderCount = 0;
|
|
70835
|
+
if (currentRow === 0 && !pendingPartialRow) {
|
|
70836
|
+
repeatHeaderCount = 0;
|
|
70837
|
+
} else {
|
|
70838
|
+
if (headerCount > 0 && headerHeight <= availableHeight) {
|
|
70839
|
+
repeatHeaderCount = headerCount;
|
|
70840
|
+
} else if (headerCount > 0 && headerHeight > availableHeight) {
|
|
70841
|
+
repeatHeaderCount = 0;
|
|
70842
|
+
}
|
|
70843
|
+
}
|
|
70844
|
+
const availableForBody = repeatHeaderCount > 0 ? availableHeight - headerHeight : availableHeight;
|
|
70845
|
+
const fullPageHeight = state2.contentBottom;
|
|
70846
|
+
if (pendingPartialRow !== null) {
|
|
70847
|
+
const rowIndex = pendingPartialRow.rowIndex;
|
|
70848
|
+
const fromLineByCell = pendingPartialRow.toLineByCell;
|
|
70849
|
+
const continuationPartialRow = computePartialRow(
|
|
70850
|
+
rowIndex,
|
|
70851
|
+
block.rows[rowIndex],
|
|
70852
|
+
measure,
|
|
70853
|
+
availableForBody,
|
|
70854
|
+
fromLineByCell
|
|
70855
|
+
);
|
|
70856
|
+
const madeProgress = continuationPartialRow.toLineByCell.some(
|
|
70857
|
+
(toLine, idx) => toLine > (fromLineByCell[idx] || 0)
|
|
70858
|
+
);
|
|
70859
|
+
const hasRemainingLinesAfterContinuation = continuationPartialRow.toLineByCell.some(
|
|
70860
|
+
(toLine, idx) => {
|
|
70861
|
+
const totalLines = getCellTotalLines(measure.rows[rowIndex].cells[idx]);
|
|
70862
|
+
return toLine < totalLines;
|
|
70863
|
+
}
|
|
70864
|
+
);
|
|
70865
|
+
const hadRemainingLinesBefore = fromLineByCell.some((fromLine, idx) => {
|
|
70866
|
+
const totalLines = getCellTotalLines(measure.rows[rowIndex].cells[idx]);
|
|
70867
|
+
return fromLine < totalLines;
|
|
70868
|
+
});
|
|
70869
|
+
const fragmentHeight2 = continuationPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
70870
|
+
if (fragmentHeight2 > 0) {
|
|
70871
|
+
const fragment2 = {
|
|
70872
|
+
kind: "table",
|
|
70873
|
+
blockId: block.id,
|
|
70874
|
+
fromRow: rowIndex,
|
|
70875
|
+
toRow: rowIndex + 1,
|
|
70876
|
+
x: columnX(state2.columnIndex),
|
|
70877
|
+
y: state2.cursorY,
|
|
70878
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
70879
|
+
height: fragmentHeight2,
|
|
70880
|
+
continuesFromPrev: true,
|
|
70881
|
+
continuesOnNext: hasRemainingLinesAfterContinuation || rowIndex + 1 < block.rows.length,
|
|
70882
|
+
repeatHeaderCount,
|
|
70883
|
+
partialRow: continuationPartialRow,
|
|
70884
|
+
metadata: generateFragmentMetadata(measure)
|
|
70885
|
+
};
|
|
70886
|
+
state2.page.fragments.push(fragment2);
|
|
70887
|
+
state2.cursorY += fragmentHeight2;
|
|
70888
|
+
}
|
|
70889
|
+
const rowComplete = !hasRemainingLinesAfterContinuation;
|
|
70890
|
+
if (rowComplete) {
|
|
70891
|
+
currentRow = rowIndex + 1;
|
|
70892
|
+
pendingPartialRow = null;
|
|
70893
|
+
} else if (!madeProgress && hadRemainingLinesBefore) {
|
|
70894
|
+
state2 = advanceColumn(state2);
|
|
70895
|
+
} else {
|
|
70896
|
+
state2 = advanceColumn(state2);
|
|
70897
|
+
pendingPartialRow = continuationPartialRow;
|
|
70898
|
+
}
|
|
70899
|
+
isTableContinuation = true;
|
|
70900
|
+
continue;
|
|
70901
|
+
}
|
|
70902
|
+
const bodyStartRow = currentRow;
|
|
70903
|
+
const { endRow, partialRow } = findSplitPoint(block, measure, bodyStartRow, availableForBody, fullPageHeight);
|
|
70904
|
+
if (endRow === bodyStartRow && partialRow === null && state2.page.fragments.length > 0) {
|
|
70905
|
+
state2 = advanceColumn(state2);
|
|
70906
|
+
continue;
|
|
70907
|
+
}
|
|
70908
|
+
if (endRow === bodyStartRow && partialRow === null) {
|
|
70909
|
+
const forcedPartialRow = computePartialRow(bodyStartRow, block.rows[bodyStartRow], measure, availableForBody);
|
|
70910
|
+
const forcedEndRow = bodyStartRow + 1;
|
|
70911
|
+
const fragmentHeight2 = forcedPartialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
70912
|
+
const fragment2 = {
|
|
70913
|
+
kind: "table",
|
|
70914
|
+
blockId: block.id,
|
|
70915
|
+
fromRow: bodyStartRow,
|
|
70916
|
+
toRow: forcedEndRow,
|
|
70917
|
+
x: columnX(state2.columnIndex),
|
|
70918
|
+
y: state2.cursorY,
|
|
70919
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
70920
|
+
height: fragmentHeight2,
|
|
70921
|
+
continuesFromPrev: isTableContinuation,
|
|
70922
|
+
continuesOnNext: !forcedPartialRow.isLastPart || forcedEndRow < block.rows.length,
|
|
70923
|
+
repeatHeaderCount,
|
|
70924
|
+
partialRow: forcedPartialRow,
|
|
70925
|
+
metadata: generateFragmentMetadata(measure)
|
|
70926
|
+
};
|
|
70927
|
+
state2.page.fragments.push(fragment2);
|
|
70928
|
+
state2.cursorY += fragmentHeight2;
|
|
70929
|
+
pendingPartialRow = forcedPartialRow;
|
|
70930
|
+
isTableContinuation = true;
|
|
70931
|
+
continue;
|
|
70932
|
+
}
|
|
70933
|
+
let fragmentHeight;
|
|
70934
|
+
if (partialRow) {
|
|
70935
|
+
const fullRowsHeight = sumRowHeights(measure.rows, bodyStartRow, endRow - 1);
|
|
70936
|
+
fragmentHeight = fullRowsHeight + partialRow.partialHeight + (repeatHeaderCount > 0 ? headerHeight : 0);
|
|
70937
|
+
} else {
|
|
70938
|
+
fragmentHeight = calculateFragmentHeight(
|
|
70939
|
+
{ fromRow: bodyStartRow, toRow: endRow, repeatHeaderCount },
|
|
70940
|
+
measure
|
|
70941
|
+
);
|
|
70942
|
+
}
|
|
70943
|
+
const fragment = {
|
|
70944
|
+
kind: "table",
|
|
70945
|
+
blockId: block.id,
|
|
70946
|
+
fromRow: bodyStartRow,
|
|
70947
|
+
toRow: endRow,
|
|
70948
|
+
x: columnX(state2.columnIndex),
|
|
70949
|
+
y: state2.cursorY,
|
|
70950
|
+
width: Math.min(columnWidth, measure.totalWidth || columnWidth),
|
|
70951
|
+
height: fragmentHeight,
|
|
70952
|
+
continuesFromPrev: isTableContinuation,
|
|
70953
|
+
continuesOnNext: endRow < block.rows.length || (partialRow ? !partialRow.isLastPart : false),
|
|
70954
|
+
repeatHeaderCount,
|
|
70955
|
+
partialRow: partialRow || void 0,
|
|
70956
|
+
metadata: generateFragmentMetadata(measure)
|
|
70957
|
+
};
|
|
70958
|
+
state2.page.fragments.push(fragment);
|
|
70959
|
+
state2.cursorY += fragmentHeight;
|
|
70960
|
+
if (partialRow && !partialRow.isLastPart) {
|
|
70961
|
+
pendingPartialRow = partialRow;
|
|
70962
|
+
currentRow = partialRow.rowIndex;
|
|
70963
|
+
} else {
|
|
70964
|
+
currentRow = endRow;
|
|
70965
|
+
pendingPartialRow = null;
|
|
70966
|
+
}
|
|
70967
|
+
isTableContinuation = true;
|
|
70269
70968
|
}
|
|
70270
|
-
|
|
70271
|
-
|
|
70969
|
+
}
|
|
70970
|
+
function createAnchoredTableFragment(block, measure, x2, y2) {
|
|
70272
70971
|
const metadata = {
|
|
70273
70972
|
columnBoundaries: generateColumnBoundaries(measure),
|
|
70274
70973
|
coordinateSystem: "fragment"
|
|
70275
|
-
// rowBoundaries omitted - not needed for column resize, reduces DOM overhead
|
|
70276
70974
|
};
|
|
70277
|
-
|
|
70975
|
+
return {
|
|
70278
70976
|
kind: "table",
|
|
70279
70977
|
blockId: block.id,
|
|
70280
70978
|
fromRow: 0,
|
|
70281
70979
|
toRow: block.rows.length,
|
|
70282
|
-
x:
|
|
70283
|
-
y:
|
|
70284
|
-
width:
|
|
70285
|
-
height,
|
|
70980
|
+
x: x2,
|
|
70981
|
+
y: y2,
|
|
70982
|
+
width: measure.totalWidth ?? 0,
|
|
70983
|
+
height: measure.totalHeight ?? 0,
|
|
70286
70984
|
metadata
|
|
70287
70985
|
};
|
|
70288
|
-
state2.page.fragments.push(fragment);
|
|
70289
|
-
state2.cursorY += height;
|
|
70290
70986
|
}
|
|
70291
70987
|
function isPageRelativeAnchor(block) {
|
|
70292
70988
|
const vRelativeFrom = block.anchor?.vRelativeFrom;
|
|
@@ -70313,9 +71009,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70313
71009
|
function collectAnchoredDrawings(blocks2, measures) {
|
|
70314
71010
|
const map2 = /* @__PURE__ */ new Map();
|
|
70315
71011
|
const len2 = Math.min(blocks2.length, measures.length);
|
|
70316
|
-
for (let i2 = 0; i2 < len2; i2 += 1) {
|
|
70317
|
-
if (blocks2[i2].kind === "paragraph") ;
|
|
70318
|
-
}
|
|
70319
71012
|
const nearestPrevParagraph = (fromIndex) => {
|
|
70320
71013
|
for (let i2 = fromIndex - 1; i2 >= 0; i2 -= 1) {
|
|
70321
71014
|
if (blocks2[i2].kind === "paragraph") return i2;
|
|
@@ -70351,6 +71044,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70351
71044
|
}
|
|
70352
71045
|
return map2;
|
|
70353
71046
|
}
|
|
71047
|
+
function collectAnchoredTables(blocks2, measures) {
|
|
71048
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
71049
|
+
const nearestPrevParagraph = (fromIndex) => {
|
|
71050
|
+
for (let i2 = fromIndex - 1; i2 >= 0; i2 -= 1) {
|
|
71051
|
+
if (blocks2[i2].kind === "paragraph") return i2;
|
|
71052
|
+
}
|
|
71053
|
+
return null;
|
|
71054
|
+
};
|
|
71055
|
+
const nearestNextParagraph = (fromIndex) => {
|
|
71056
|
+
for (let i2 = fromIndex + 1; i2 < blocks2.length; i2 += 1) {
|
|
71057
|
+
if (blocks2[i2].kind === "paragraph") return i2;
|
|
71058
|
+
}
|
|
71059
|
+
return null;
|
|
71060
|
+
};
|
|
71061
|
+
for (let i2 = 0; i2 < blocks2.length; i2 += 1) {
|
|
71062
|
+
const block = blocks2[i2];
|
|
71063
|
+
const measure = measures[i2];
|
|
71064
|
+
if (block.kind !== "table" || measure?.kind !== "table") continue;
|
|
71065
|
+
const tableBlock = block;
|
|
71066
|
+
const tableMeasure = measure;
|
|
71067
|
+
if (!tableBlock.anchor?.isAnchored) continue;
|
|
71068
|
+
let anchorParaIndex = nearestPrevParagraph(i2);
|
|
71069
|
+
if (anchorParaIndex == null) anchorParaIndex = nearestNextParagraph(i2);
|
|
71070
|
+
if (anchorParaIndex == null) continue;
|
|
71071
|
+
const list2 = map2.get(anchorParaIndex) ?? [];
|
|
71072
|
+
list2.push({ block: tableBlock, measure: tableMeasure });
|
|
71073
|
+
map2.set(anchorParaIndex, list2);
|
|
71074
|
+
}
|
|
71075
|
+
return map2;
|
|
71076
|
+
}
|
|
70354
71077
|
function createPaginator(opts) {
|
|
70355
71078
|
const states = [];
|
|
70356
71079
|
const pages = [];
|
|
@@ -70936,7 +71659,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
70936
71659
|
cachedColumnsState.state = null;
|
|
70937
71660
|
};
|
|
70938
71661
|
const anchoredByParagraph = collectAnchoredDrawings(blocks2, measures);
|
|
71662
|
+
const anchoredTablesByParagraph = collectAnchoredTables(blocks2, measures);
|
|
70939
71663
|
const placedAnchoredIds = /* @__PURE__ */ new Set();
|
|
71664
|
+
const placedAnchoredTableIds = /* @__PURE__ */ new Set();
|
|
70940
71665
|
const preRegisteredAnchors = collectPreRegisteredAnchors(blocks2, measures);
|
|
70941
71666
|
const preRegisteredPositions = /* @__PURE__ */ new Map();
|
|
70942
71667
|
for (const entry of preRegisteredAnchors) {
|
|
@@ -71114,6 +71839,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71114
71839
|
}
|
|
71115
71840
|
}
|
|
71116
71841
|
const anchorsForPara = anchoredByParagraph.get(index2);
|
|
71842
|
+
const tablesForPara = anchoredTablesByParagraph.get(index2);
|
|
71843
|
+
if (tablesForPara) {
|
|
71844
|
+
const state2 = paginator.ensurePage();
|
|
71845
|
+
for (const { block: tableBlock, measure: tableMeasure } of tablesForPara) {
|
|
71846
|
+
if (placedAnchoredTableIds.has(tableBlock.id)) continue;
|
|
71847
|
+
floatManager.registerTable(tableBlock, tableMeasure, state2.cursorY, state2.columnIndex, state2.page.number);
|
|
71848
|
+
const anchorX = tableBlock.anchor?.offsetH ?? columnX(state2.columnIndex);
|
|
71849
|
+
const anchorY = state2.cursorY + (tableBlock.anchor?.offsetV ?? 0);
|
|
71850
|
+
const tableFragment = createAnchoredTableFragment(tableBlock, tableMeasure, anchorX, anchorY);
|
|
71851
|
+
state2.page.fragments.push(tableFragment);
|
|
71852
|
+
placedAnchoredTableIds.add(tableBlock.id);
|
|
71853
|
+
}
|
|
71854
|
+
}
|
|
71117
71855
|
layoutParagraphBlock(
|
|
71118
71856
|
{
|
|
71119
71857
|
block,
|
|
@@ -71385,7 +72123,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
71385
72123
|
const trackedMode = block.attrs && "trackedChangesMode" in block.attrs && block.attrs.trackedChangesMode || "review";
|
|
71386
72124
|
const trackedEnabled = resolveTrackedChangesEnabled(block.attrs, true);
|
|
71387
72125
|
const runsHash = block.runs.map((run2) => {
|
|
71388
|
-
const text2 = normalizeText(
|
|
72126
|
+
const text2 = normalizeText(
|
|
72127
|
+
"src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
|
|
72128
|
+
);
|
|
71389
72129
|
const bold = "bold" in run2 ? run2.bold : false;
|
|
71390
72130
|
const italic = "italic" in run2 ? run2.italic : false;
|
|
71391
72131
|
const color2 = "color" in run2 ? run2.color : void 0;
|
|
@@ -72045,7 +72785,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72045
72785
|
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
72046
72786
|
}
|
|
72047
72787
|
function runText(run2) {
|
|
72048
|
-
return "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
72788
|
+
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
72049
72789
|
}
|
|
72050
72790
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
72051
72791
|
const context = getCtx();
|
|
@@ -72207,7 +72947,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72207
72947
|
for (let i2 = 0; i2 < a2.runs.length; i2 += 1) {
|
|
72208
72948
|
const runA = a2.runs[i2];
|
|
72209
72949
|
const runB = b2.runs[i2];
|
|
72210
|
-
if (("src" in runA || runA.kind === "lineBreak" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
|
|
72950
|
+
if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
|
|
72211
72951
|
return false;
|
|
72212
72952
|
}
|
|
72213
72953
|
}
|
|
@@ -72327,7 +73067,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
72327
73067
|
parts.push(block.id);
|
|
72328
73068
|
if (block.kind === "paragraph") {
|
|
72329
73069
|
for (const run2 of block.runs) {
|
|
72330
|
-
if (!("src" in run2) && run2.kind !== "lineBreak") {
|
|
73070
|
+
if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
|
|
72331
73071
|
parts.push(run2.text ?? "");
|
|
72332
73072
|
}
|
|
72333
73073
|
if ("bold" in run2 && run2.bold) parts.push("b");
|
|
@@ -73298,7 +74038,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
73298
74038
|
for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
|
|
73299
74039
|
const run2 = block.runs[runIndex];
|
|
73300
74040
|
if (!run2) continue;
|
|
73301
|
-
const text2 = "src" in run2 || run2.kind === "lineBreak" ? "" : run2.text ?? "";
|
|
74041
|
+
const text2 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
73302
74042
|
const runLength = text2.length;
|
|
73303
74043
|
const runPmStart = run2.pmStart ?? null;
|
|
73304
74044
|
const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
|
|
@@ -75906,7 +76646,20 @@ ${l}
|
|
|
75906
76646
|
};
|
|
75907
76647
|
};
|
|
75908
76648
|
const renderTableCell = (deps) => {
|
|
75909
|
-
const {
|
|
76649
|
+
const {
|
|
76650
|
+
doc: doc2,
|
|
76651
|
+
x: x2,
|
|
76652
|
+
y: y2,
|
|
76653
|
+
rowHeight,
|
|
76654
|
+
cellMeasure,
|
|
76655
|
+
cell: cell2,
|
|
76656
|
+
borders,
|
|
76657
|
+
renderLine,
|
|
76658
|
+
context,
|
|
76659
|
+
applySdtDataset,
|
|
76660
|
+
fromLine,
|
|
76661
|
+
toLine
|
|
76662
|
+
} = deps;
|
|
75910
76663
|
const cellEl = doc2.createElement("div");
|
|
75911
76664
|
cellEl.style.position = "absolute";
|
|
75912
76665
|
cellEl.style.left = `${x2}px`;
|
|
@@ -75914,6 +76667,7 @@ ${l}
|
|
|
75914
76667
|
cellEl.style.width = `${cellMeasure.width}px`;
|
|
75915
76668
|
cellEl.style.height = `${rowHeight}px`;
|
|
75916
76669
|
cellEl.style.boxSizing = "border-box";
|
|
76670
|
+
cellEl.style.overflow = "hidden";
|
|
75917
76671
|
if (borders) {
|
|
75918
76672
|
applyCellBorders(cellEl, borders);
|
|
75919
76673
|
}
|
|
@@ -75927,36 +76681,87 @@ ${l}
|
|
|
75927
76681
|
}
|
|
75928
76682
|
let contentElement;
|
|
75929
76683
|
const attrs = cell2?.attrs;
|
|
75930
|
-
const padding = attrs?.padding || { top: 2, left: 4, right: 4 };
|
|
76684
|
+
const padding = attrs?.padding || { top: 2, left: 4, right: 4, bottom: 2 };
|
|
75931
76685
|
const paddingLeft = padding.left ?? 4;
|
|
75932
76686
|
const paddingTop = padding.top ?? 2;
|
|
75933
76687
|
const paddingRight = padding.right ?? 4;
|
|
76688
|
+
const paddingBottom = padding.bottom ?? 2;
|
|
75934
76689
|
const cellBlocks = cell2?.blocks ?? (cell2?.paragraph ? [cell2.paragraph] : []);
|
|
75935
|
-
const blockMeasures = cellMeasure
|
|
76690
|
+
const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
|
|
75936
76691
|
if (cellBlocks.length > 0 && blockMeasures.length > 0) {
|
|
75937
76692
|
const content2 = doc2.createElement("div");
|
|
75938
76693
|
content2.style.position = "absolute";
|
|
75939
76694
|
content2.style.left = `${x2 + paddingLeft}px`;
|
|
75940
76695
|
content2.style.top = `${y2 + paddingTop}px`;
|
|
75941
|
-
|
|
75942
|
-
|
|
76696
|
+
const contentWidth = Math.max(0, cellMeasure.width - paddingLeft - paddingRight);
|
|
76697
|
+
const contentHeight = Math.max(0, rowHeight - paddingTop - paddingBottom);
|
|
76698
|
+
content2.style.width = `${contentWidth + 1}px`;
|
|
76699
|
+
content2.style.height = `${contentHeight}px`;
|
|
76700
|
+
content2.style.display = "flex";
|
|
76701
|
+
content2.style.flexDirection = "column";
|
|
76702
|
+
content2.style.overflowX = "visible";
|
|
76703
|
+
content2.style.overflowY = "hidden";
|
|
76704
|
+
if (cell2?.attrs?.verticalAlign === "center") {
|
|
76705
|
+
content2.style.justifyContent = "center";
|
|
76706
|
+
} else if (cell2?.attrs?.verticalAlign === "bottom") {
|
|
76707
|
+
content2.style.justifyContent = "flex-end";
|
|
76708
|
+
} else {
|
|
76709
|
+
content2.style.justifyContent = "flex-start";
|
|
76710
|
+
}
|
|
76711
|
+
const blockLineCounts = [];
|
|
76712
|
+
for (let i2 = 0; i2 < Math.min(blockMeasures.length, cellBlocks.length); i2++) {
|
|
76713
|
+
const bm = blockMeasures[i2];
|
|
76714
|
+
if (bm.kind === "paragraph") {
|
|
76715
|
+
blockLineCounts.push(bm.lines?.length || 0);
|
|
76716
|
+
} else {
|
|
76717
|
+
blockLineCounts.push(0);
|
|
76718
|
+
}
|
|
76719
|
+
}
|
|
76720
|
+
const totalLines = blockLineCounts.reduce((a2, b2) => a2 + b2, 0);
|
|
76721
|
+
const globalFromLine = fromLine ?? 0;
|
|
76722
|
+
const globalToLine = toLine === -1 || toLine === void 0 ? totalLines : toLine;
|
|
76723
|
+
let cumulativeLineCount = 0;
|
|
75943
76724
|
for (let i2 = 0; i2 < Math.min(blockMeasures.length, cellBlocks.length); i2++) {
|
|
75944
76725
|
const blockMeasure = blockMeasures[i2];
|
|
75945
76726
|
const block = cellBlocks[i2];
|
|
75946
76727
|
if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
|
|
76728
|
+
const lines = blockMeasure.lines;
|
|
76729
|
+
const blockLineCount = lines?.length || 0;
|
|
76730
|
+
const blockStartGlobal = cumulativeLineCount;
|
|
76731
|
+
const blockEndGlobal = cumulativeLineCount + blockLineCount;
|
|
76732
|
+
if (blockEndGlobal <= globalFromLine) {
|
|
76733
|
+
cumulativeLineCount += blockLineCount;
|
|
76734
|
+
continue;
|
|
76735
|
+
}
|
|
76736
|
+
if (blockStartGlobal >= globalToLine) {
|
|
76737
|
+
cumulativeLineCount += blockLineCount;
|
|
76738
|
+
continue;
|
|
76739
|
+
}
|
|
76740
|
+
const localStartLine = Math.max(0, globalFromLine - blockStartGlobal);
|
|
76741
|
+
const localEndLine = Math.min(blockLineCount, globalToLine - blockStartGlobal);
|
|
75947
76742
|
const paraWrapper = doc2.createElement("div");
|
|
75948
|
-
paraWrapper.style.position = "
|
|
75949
|
-
paraWrapper.style.top = `${blockY}px`;
|
|
76743
|
+
paraWrapper.style.position = "relative";
|
|
75950
76744
|
paraWrapper.style.left = "0";
|
|
75951
76745
|
paraWrapper.style.width = "100%";
|
|
75952
76746
|
applySdtDataset(paraWrapper, block.attrs?.sdt);
|
|
75953
|
-
|
|
75954
|
-
lines.
|
|
76747
|
+
let renderedHeight = 0;
|
|
76748
|
+
for (let lineIdx = localStartLine; lineIdx < localEndLine && lineIdx < lines.length; lineIdx++) {
|
|
76749
|
+
const line = lines[lineIdx];
|
|
75955
76750
|
const lineEl = renderLine(block, line, { ...context, section: "body" });
|
|
75956
76751
|
paraWrapper.appendChild(lineEl);
|
|
75957
|
-
|
|
76752
|
+
renderedHeight += line.lineHeight;
|
|
76753
|
+
}
|
|
76754
|
+
const renderedEntireBlock = localStartLine === 0 && localEndLine >= blockLineCount;
|
|
76755
|
+
if (renderedEntireBlock && blockMeasure.totalHeight && blockMeasure.totalHeight > renderedHeight) {
|
|
76756
|
+
renderedHeight = blockMeasure.totalHeight;
|
|
76757
|
+
}
|
|
75958
76758
|
content2.appendChild(paraWrapper);
|
|
75959
|
-
|
|
76759
|
+
if (renderedHeight > 0) {
|
|
76760
|
+
paraWrapper.style.height = `${renderedHeight}px`;
|
|
76761
|
+
}
|
|
76762
|
+
cumulativeLineCount += blockLineCount;
|
|
76763
|
+
} else {
|
|
76764
|
+
cumulativeLineCount += 0;
|
|
75960
76765
|
}
|
|
75961
76766
|
}
|
|
75962
76767
|
contentElement = content2;
|
|
@@ -75977,7 +76782,10 @@ ${l}
|
|
|
75977
76782
|
allRowHeights,
|
|
75978
76783
|
context,
|
|
75979
76784
|
renderLine,
|
|
75980
|
-
applySdtDataset
|
|
76785
|
+
applySdtDataset,
|
|
76786
|
+
continuesFromPrev,
|
|
76787
|
+
continuesOnNext,
|
|
76788
|
+
partialRow
|
|
75981
76789
|
} = deps;
|
|
75982
76790
|
const calculateXPosition = (gridColumnStart) => {
|
|
75983
76791
|
let x2 = 0;
|
|
@@ -76010,25 +76818,57 @@ ${l}
|
|
|
76010
76818
|
const isLastRow = rowIndex === totalRows - 1;
|
|
76011
76819
|
const isFirstCol = gridColIndex === 0;
|
|
76012
76820
|
const isLastCol = gridColIndex === totalCols - 1;
|
|
76821
|
+
const treatAsFirstRow = isFirstRow || continuesFromPrev;
|
|
76822
|
+
const treatAsLastRow = isLastRow || continuesOnNext;
|
|
76013
76823
|
resolvedBorders = {
|
|
76014
|
-
// For top: use cell's if defined, otherwise use table's top for first row
|
|
76015
|
-
top: cellBordersAttr.top ?? borderValueToSpec(
|
|
76016
|
-
// For bottom: use cell's if defined, otherwise use table's bottom for last row
|
|
76017
|
-
bottom: cellBordersAttr.bottom ?? borderValueToSpec(
|
|
76824
|
+
// For top: use cell's if defined, otherwise use table's top border for first row OR continuation
|
|
76825
|
+
top: cellBordersAttr.top ?? borderValueToSpec(treatAsFirstRow ? tableBorders.top : tableBorders.insideH),
|
|
76826
|
+
// For bottom: use cell's if defined, otherwise use table's bottom border for last row OR before continuation
|
|
76827
|
+
bottom: cellBordersAttr.bottom ?? borderValueToSpec(treatAsLastRow ? tableBorders.bottom : void 0),
|
|
76018
76828
|
// For left: use cell's if defined, otherwise use table's left for first col
|
|
76019
76829
|
left: cellBordersAttr.left ?? borderValueToSpec(isFirstCol ? tableBorders.left : tableBorders.insideV),
|
|
76020
76830
|
// For right: use cell's if defined, otherwise use table's right for last col only
|
|
76021
76831
|
right: cellBordersAttr.right ?? borderValueToSpec(isLastCol ? tableBorders.right : void 0)
|
|
76022
76832
|
};
|
|
76023
76833
|
} else if (hasExplicitBorders) {
|
|
76024
|
-
resolvedBorders =
|
|
76834
|
+
resolvedBorders = {
|
|
76835
|
+
top: cellBordersAttr.top,
|
|
76836
|
+
bottom: cellBordersAttr.bottom,
|
|
76837
|
+
left: cellBordersAttr.left,
|
|
76838
|
+
right: cellBordersAttr.right
|
|
76839
|
+
};
|
|
76025
76840
|
} else if (tableBorders) {
|
|
76026
|
-
|
|
76841
|
+
const isFirstRow = rowIndex === 0;
|
|
76842
|
+
const isLastRow = rowIndex === totalRows - 1;
|
|
76843
|
+
const treatAsFirstRow = isFirstRow || continuesFromPrev;
|
|
76844
|
+
const treatAsLastRow = isLastRow || continuesOnNext;
|
|
76845
|
+
const baseBorders = resolveTableCellBorders(tableBorders, rowIndex, gridColIndex, totalRows, totalCols);
|
|
76846
|
+
if (baseBorders) {
|
|
76847
|
+
resolvedBorders = {
|
|
76848
|
+
// If this is a continuation (continuesFromPrev), use table's top border
|
|
76849
|
+
top: treatAsFirstRow ? borderValueToSpec(tableBorders.top) : baseBorders.top,
|
|
76850
|
+
// If this continues on next (continuesOnNext), use table's bottom border
|
|
76851
|
+
bottom: treatAsLastRow ? borderValueToSpec(tableBorders.bottom) : baseBorders.bottom,
|
|
76852
|
+
left: baseBorders.left,
|
|
76853
|
+
right: baseBorders.right
|
|
76854
|
+
};
|
|
76855
|
+
} else {
|
|
76856
|
+
resolvedBorders = void 0;
|
|
76857
|
+
}
|
|
76027
76858
|
} else {
|
|
76028
76859
|
resolvedBorders = void 0;
|
|
76029
76860
|
}
|
|
76030
76861
|
const rowSpan = cellMeasure.rowSpan ?? 1;
|
|
76031
|
-
|
|
76862
|
+
let cellHeight;
|
|
76863
|
+
if (partialRow) {
|
|
76864
|
+
cellHeight = partialRow.partialHeight;
|
|
76865
|
+
} else if (rowSpan > 1) {
|
|
76866
|
+
cellHeight = calculateRowspanHeight(rowIndex, rowSpan);
|
|
76867
|
+
} else {
|
|
76868
|
+
cellHeight = rowMeasure.height;
|
|
76869
|
+
}
|
|
76870
|
+
const fromLine = partialRow?.fromLineByCell?.[cellIndex];
|
|
76871
|
+
const toLine = partialRow?.toLineByCell?.[cellIndex];
|
|
76032
76872
|
const { cellElement, contentElement } = renderTableCell({
|
|
76033
76873
|
doc: doc2,
|
|
76034
76874
|
x: x2,
|
|
@@ -76039,7 +76879,9 @@ ${l}
|
|
|
76039
76879
|
borders: resolvedBorders,
|
|
76040
76880
|
renderLine,
|
|
76041
76881
|
context,
|
|
76042
|
-
applySdtDataset
|
|
76882
|
+
applySdtDataset,
|
|
76883
|
+
fromLine,
|
|
76884
|
+
toLine
|
|
76043
76885
|
});
|
|
76044
76886
|
container.appendChild(cellElement);
|
|
76045
76887
|
if (contentElement) {
|
|
@@ -76153,11 +76995,46 @@ ${l}
|
|
|
76153
76995
|
if (borderCollapse === "separate" && block.attrs?.cellSpacing) {
|
|
76154
76996
|
container.style.borderSpacing = `${block.attrs.cellSpacing}px`;
|
|
76155
76997
|
}
|
|
76156
|
-
const allRowHeights = measure.rows.map((r2) =>
|
|
76998
|
+
const allRowHeights = measure.rows.map((r2, idx) => {
|
|
76999
|
+
if (fragment.partialRow && fragment.partialRow.rowIndex === idx) {
|
|
77000
|
+
return fragment.partialRow.partialHeight;
|
|
77001
|
+
}
|
|
77002
|
+
return r2?.height ?? 0;
|
|
77003
|
+
});
|
|
76157
77004
|
let y2 = 0;
|
|
77005
|
+
if (fragment.repeatHeaderCount && fragment.repeatHeaderCount > 0) {
|
|
77006
|
+
for (let r2 = 0; r2 < fragment.repeatHeaderCount; r2 += 1) {
|
|
77007
|
+
const rowMeasure = measure.rows[r2];
|
|
77008
|
+
if (!rowMeasure) break;
|
|
77009
|
+
renderTableRow({
|
|
77010
|
+
doc: doc2,
|
|
77011
|
+
container,
|
|
77012
|
+
rowIndex: r2,
|
|
77013
|
+
y: y2,
|
|
77014
|
+
rowMeasure,
|
|
77015
|
+
row: block.rows[r2],
|
|
77016
|
+
totalRows: block.rows.length,
|
|
77017
|
+
tableBorders,
|
|
77018
|
+
columnWidths: measure.columnWidths,
|
|
77019
|
+
allRowHeights,
|
|
77020
|
+
context,
|
|
77021
|
+
renderLine,
|
|
77022
|
+
applySdtDataset,
|
|
77023
|
+
// Headers are always rendered as-is (no border suppression)
|
|
77024
|
+
continuesFromPrev: false,
|
|
77025
|
+
continuesOnNext: false
|
|
77026
|
+
});
|
|
77027
|
+
y2 += rowMeasure.height;
|
|
77028
|
+
}
|
|
77029
|
+
}
|
|
76158
77030
|
for (let r2 = fragment.fromRow; r2 < fragment.toRow; r2 += 1) {
|
|
76159
77031
|
const rowMeasure = measure.rows[r2];
|
|
76160
77032
|
if (!rowMeasure) break;
|
|
77033
|
+
const isFirstRenderedBodyRow = r2 === fragment.fromRow;
|
|
77034
|
+
const isLastRenderedBodyRow = r2 === fragment.toRow - 1;
|
|
77035
|
+
const isPartialRow = fragment.partialRow && fragment.partialRow.rowIndex === r2;
|
|
77036
|
+
const partialRowData = isPartialRow ? fragment.partialRow : void 0;
|
|
77037
|
+
const actualRowHeight = partialRowData ? partialRowData.partialHeight : rowMeasure.height;
|
|
76161
77038
|
renderTableRow({
|
|
76162
77039
|
doc: doc2,
|
|
76163
77040
|
container,
|
|
@@ -76171,9 +77048,15 @@ ${l}
|
|
|
76171
77048
|
allRowHeights,
|
|
76172
77049
|
context,
|
|
76173
77050
|
renderLine,
|
|
76174
|
-
applySdtDataset
|
|
77051
|
+
applySdtDataset,
|
|
77052
|
+
// Draw top border if table continues from previous fragment (MS Word behavior)
|
|
77053
|
+
continuesFromPrev: isFirstRenderedBodyRow && fragment.continuesFromPrev === true,
|
|
77054
|
+
// Draw bottom border if table continues on next fragment (MS Word behavior)
|
|
77055
|
+
continuesOnNext: isLastRenderedBodyRow && fragment.continuesOnNext === true,
|
|
77056
|
+
// Pass partial row data for mid-row splits
|
|
77057
|
+
partialRow: partialRowData
|
|
76175
77058
|
});
|
|
76176
|
-
y2 +=
|
|
77059
|
+
y2 += actualRowHeight;
|
|
76177
77060
|
}
|
|
76178
77061
|
return container;
|
|
76179
77062
|
};
|
|
@@ -77961,6 +78844,12 @@ ${l}
|
|
|
77961
78844
|
isLineBreakRun(run2) {
|
|
77962
78845
|
return run2.kind === "lineBreak";
|
|
77963
78846
|
}
|
|
78847
|
+
/**
|
|
78848
|
+
* Type guard to check if a run is a break run.
|
|
78849
|
+
*/
|
|
78850
|
+
isBreakRun(run2) {
|
|
78851
|
+
return run2.kind === "break";
|
|
78852
|
+
}
|
|
77964
78853
|
renderRun(run2, context, trackedConfig) {
|
|
77965
78854
|
if (this.isImageRun(run2)) {
|
|
77966
78855
|
return this.renderImageRun(run2);
|
|
@@ -77968,7 +78857,10 @@ ${l}
|
|
|
77968
78857
|
if (this.isLineBreakRun(run2)) {
|
|
77969
78858
|
return null;
|
|
77970
78859
|
}
|
|
77971
|
-
if (
|
|
78860
|
+
if (this.isBreakRun(run2)) {
|
|
78861
|
+
return null;
|
|
78862
|
+
}
|
|
78863
|
+
if (!("text" in run2) || !run2.text || !this.doc) {
|
|
77972
78864
|
return null;
|
|
77973
78865
|
}
|
|
77974
78866
|
const linkData = this.extractLinkData(run2);
|
|
@@ -78109,6 +79001,12 @@ ${l}
|
|
|
78109
79001
|
if (styleId) {
|
|
78110
79002
|
el.setAttribute("styleid", styleId);
|
|
78111
79003
|
}
|
|
79004
|
+
const alignment2 = block.attrs?.alignment;
|
|
79005
|
+
if (alignment2 === "center" || alignment2 === "right" || alignment2 === "justify") {
|
|
79006
|
+
el.style.textAlign = alignment2 === "justify" ? "justify" : alignment2;
|
|
79007
|
+
} else {
|
|
79008
|
+
el.style.textAlign = "left";
|
|
79009
|
+
}
|
|
78112
79010
|
const lineRange = computeLinePmRange(block, line);
|
|
78113
79011
|
if (lineRange.pmStart != null) {
|
|
78114
79012
|
el.dataset.pmStart = String(lineRange.pmStart);
|
|
@@ -78226,10 +79124,16 @@ ${l}
|
|
|
78226
79124
|
if (this.isLineBreakRun(baseRun)) {
|
|
78227
79125
|
continue;
|
|
78228
79126
|
}
|
|
79127
|
+
if (this.isBreakRun(baseRun)) {
|
|
79128
|
+
continue;
|
|
79129
|
+
}
|
|
78229
79130
|
const runSegments = segmentsByRun.get(runIndex);
|
|
78230
79131
|
if (!runSegments || runSegments.length === 0) {
|
|
78231
79132
|
continue;
|
|
78232
79133
|
}
|
|
79134
|
+
if (!("text" in baseRun)) {
|
|
79135
|
+
continue;
|
|
79136
|
+
}
|
|
78233
79137
|
const baseText = baseRun.text ?? "";
|
|
78234
79138
|
const runPmStart = baseRun.pmStart ?? null;
|
|
78235
79139
|
const fallbackPmEnd = runPmStart != null && baseRun.pmEnd == null ? runPmStart + baseText.length : baseRun.pmEnd ?? null;
|
|
@@ -78548,7 +79452,12 @@ ${l}
|
|
|
78548
79452
|
if (fragment.kind === "drawing") {
|
|
78549
79453
|
return `drawing:${fragment.blockId}:${fragment.x}:${fragment.y}`;
|
|
78550
79454
|
}
|
|
78551
|
-
|
|
79455
|
+
if (fragment.kind === "table") {
|
|
79456
|
+
const partialKey = fragment.partialRow ? `:${fragment.partialRow.fromLineByCell.join(",")}-${fragment.partialRow.toLineByCell.join(",")}` : "";
|
|
79457
|
+
return `table:${fragment.blockId}:${fragment.fromRow}:${fragment.toRow}${partialKey}`;
|
|
79458
|
+
}
|
|
79459
|
+
const _exhaustiveCheck = fragment;
|
|
79460
|
+
return _exhaustiveCheck;
|
|
78552
79461
|
};
|
|
78553
79462
|
const fragmentSignature = (fragment, lookup2) => {
|
|
78554
79463
|
const base2 = lookup2.get(fragment.blockId)?.version ?? "missing";
|
|
@@ -78590,6 +79499,20 @@ ${l}
|
|
|
78590
79499
|
fragment.zIndex ?? ""
|
|
78591
79500
|
].join("|");
|
|
78592
79501
|
}
|
|
79502
|
+
if (fragment.kind === "table") {
|
|
79503
|
+
const partialSig = fragment.partialRow ? `${fragment.partialRow.fromLineByCell.join(",")}-${fragment.partialRow.toLineByCell.join(",")}-${fragment.partialRow.partialHeight}` : "";
|
|
79504
|
+
return [
|
|
79505
|
+
base2,
|
|
79506
|
+
fragment.fromRow,
|
|
79507
|
+
fragment.toRow,
|
|
79508
|
+
fragment.width,
|
|
79509
|
+
fragment.height,
|
|
79510
|
+
fragment.continuesFromPrev ? 1 : 0,
|
|
79511
|
+
fragment.continuesOnNext ? 1 : 0,
|
|
79512
|
+
fragment.repeatHeaderCount ?? 0,
|
|
79513
|
+
partialSig
|
|
79514
|
+
].join("|");
|
|
79515
|
+
}
|
|
78593
79516
|
return base2;
|
|
78594
79517
|
};
|
|
78595
79518
|
const deriveBlockVersion = (block) => {
|
|
@@ -78735,7 +79658,7 @@ ${l}
|
|
|
78735
79658
|
return block.id;
|
|
78736
79659
|
};
|
|
78737
79660
|
const applyRunStyles = (element2, run2, isLink = false) => {
|
|
78738
|
-
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak") {
|
|
79661
|
+
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
78739
79662
|
return;
|
|
78740
79663
|
}
|
|
78741
79664
|
element2.style.fontFamily = run2.fontFamily;
|
|
@@ -78869,6 +79792,17 @@ ${l}
|
|
|
78869
79792
|
result.push(run2);
|
|
78870
79793
|
continue;
|
|
78871
79794
|
}
|
|
79795
|
+
if (run2.kind === "break") {
|
|
79796
|
+
result.push(run2);
|
|
79797
|
+
continue;
|
|
79798
|
+
}
|
|
79799
|
+
if (run2.kind === "tab") {
|
|
79800
|
+
result.push(run2);
|
|
79801
|
+
continue;
|
|
79802
|
+
}
|
|
79803
|
+
if (!("text" in run2)) {
|
|
79804
|
+
continue;
|
|
79805
|
+
}
|
|
78872
79806
|
const text2 = run2.text ?? "";
|
|
78873
79807
|
const isFirstRun = runIndex === line.fromRun;
|
|
78874
79808
|
const isLastRun = runIndex === line.toRun;
|
|
@@ -78882,20 +79816,14 @@ ${l}
|
|
|
78882
79816
|
if (!slice2) continue;
|
|
78883
79817
|
const pmSliceStart = runPmStart != null ? runPmStart + start2 : void 0;
|
|
78884
79818
|
const pmSliceEnd = runPmStart != null ? runPmStart + end2 : fallbackPmEnd ?? void 0;
|
|
78885
|
-
|
|
78886
|
-
|
|
78887
|
-
|
|
78888
|
-
|
|
78889
|
-
|
|
78890
|
-
|
|
78891
|
-
|
|
78892
|
-
|
|
78893
|
-
pmStart: pmSliceStart,
|
|
78894
|
-
pmEnd: pmSliceEnd,
|
|
78895
|
-
comments: run2.comments ? [...run2.comments] : void 0
|
|
78896
|
-
};
|
|
78897
|
-
result.push(sliced);
|
|
78898
|
-
}
|
|
79819
|
+
const sliced = {
|
|
79820
|
+
...run2,
|
|
79821
|
+
text: slice2,
|
|
79822
|
+
pmStart: pmSliceStart,
|
|
79823
|
+
pmEnd: pmSliceEnd,
|
|
79824
|
+
comments: run2.comments ? [...run2.comments] : void 0
|
|
79825
|
+
};
|
|
79826
|
+
result.push(sliced);
|
|
78899
79827
|
} else {
|
|
78900
79828
|
result.push(run2);
|
|
78901
79829
|
}
|
|
@@ -78938,6 +79866,39 @@ ${l}
|
|
|
78938
79866
|
}
|
|
78939
79867
|
continue;
|
|
78940
79868
|
}
|
|
79869
|
+
if (run2.kind === "break") {
|
|
79870
|
+
const runPmStart2 = run2.pmStart ?? null;
|
|
79871
|
+
const runPmEnd = run2.pmEnd ?? null;
|
|
79872
|
+
if (runPmStart2 == null || runPmEnd == null) {
|
|
79873
|
+
continue;
|
|
79874
|
+
}
|
|
79875
|
+
if (pmStart == null) {
|
|
79876
|
+
pmStart = runPmStart2;
|
|
79877
|
+
}
|
|
79878
|
+
pmEnd = runPmEnd;
|
|
79879
|
+
if (runIndex === line.toRun) {
|
|
79880
|
+
break;
|
|
79881
|
+
}
|
|
79882
|
+
continue;
|
|
79883
|
+
}
|
|
79884
|
+
if (run2.kind === "tab") {
|
|
79885
|
+
const runPmStart2 = run2.pmStart ?? null;
|
|
79886
|
+
const runPmEnd = run2.pmEnd ?? null;
|
|
79887
|
+
if (runPmStart2 == null || runPmEnd == null) {
|
|
79888
|
+
continue;
|
|
79889
|
+
}
|
|
79890
|
+
if (pmStart == null) {
|
|
79891
|
+
pmStart = runPmStart2;
|
|
79892
|
+
}
|
|
79893
|
+
pmEnd = runPmEnd;
|
|
79894
|
+
if (runIndex === line.toRun) {
|
|
79895
|
+
break;
|
|
79896
|
+
}
|
|
79897
|
+
continue;
|
|
79898
|
+
}
|
|
79899
|
+
if (!("text" in run2)) {
|
|
79900
|
+
continue;
|
|
79901
|
+
}
|
|
78941
79902
|
const text2 = run2.text ?? "";
|
|
78942
79903
|
const runLength = text2.length;
|
|
78943
79904
|
const runPmStart = run2.pmStart ?? null;
|
|
@@ -78979,6 +79940,12 @@ ${l}
|
|
|
78979
79940
|
if (run2.kind === "lineBreak") {
|
|
78980
79941
|
return "";
|
|
78981
79942
|
}
|
|
79943
|
+
if (run2.kind === "break") {
|
|
79944
|
+
return "";
|
|
79945
|
+
}
|
|
79946
|
+
if (!("text" in run2)) {
|
|
79947
|
+
return "";
|
|
79948
|
+
}
|
|
78982
79949
|
if (!runToken) {
|
|
78983
79950
|
return run2.text ?? "";
|
|
78984
79951
|
}
|
|
@@ -79176,6 +80143,7 @@ ${l}
|
|
|
79176
80143
|
async function measureParagraphBlock(block, maxWidth) {
|
|
79177
80144
|
const ctx2 = getCanvasContext();
|
|
79178
80145
|
const wordLayout = block.attrs?.wordLayout;
|
|
80146
|
+
const WIDTH_FUDGE_PX = 0.5;
|
|
79179
80147
|
const lines = [];
|
|
79180
80148
|
const indent2 = block.attrs?.indent;
|
|
79181
80149
|
const spacing = block.attrs?.spacing;
|
|
@@ -79270,8 +80238,67 @@ ${l}
|
|
|
79270
80238
|
lastAppliedTabAlign = { target, val };
|
|
79271
80239
|
pendingTabAlignment = null;
|
|
79272
80240
|
};
|
|
79273
|
-
|
|
79274
|
-
|
|
80241
|
+
const runsToProcess = [];
|
|
80242
|
+
for (const run2 of block.runs) {
|
|
80243
|
+
if (run2.text && typeof run2.text === "string" && run2.text.includes("\n")) {
|
|
80244
|
+
const textRun = run2;
|
|
80245
|
+
const segments = textRun.text.split("\n");
|
|
80246
|
+
let cursor = textRun.pmStart ?? 0;
|
|
80247
|
+
segments.forEach((seg, idx) => {
|
|
80248
|
+
runsToProcess.push({
|
|
80249
|
+
...textRun,
|
|
80250
|
+
text: seg,
|
|
80251
|
+
pmStart: cursor,
|
|
80252
|
+
pmEnd: cursor + seg.length
|
|
80253
|
+
});
|
|
80254
|
+
cursor += seg.length;
|
|
80255
|
+
if (idx !== segments.length - 1) {
|
|
80256
|
+
runsToProcess.push({
|
|
80257
|
+
kind: "break",
|
|
80258
|
+
breakType: "line",
|
|
80259
|
+
pmStart: cursor,
|
|
80260
|
+
pmEnd: cursor + 1,
|
|
80261
|
+
sdt: run2.sdt
|
|
80262
|
+
});
|
|
80263
|
+
cursor += 1;
|
|
80264
|
+
}
|
|
80265
|
+
});
|
|
80266
|
+
} else {
|
|
80267
|
+
runsToProcess.push(run2);
|
|
80268
|
+
}
|
|
80269
|
+
}
|
|
80270
|
+
for (let runIndex = 0; runIndex < runsToProcess.length; runIndex++) {
|
|
80271
|
+
const run2 = runsToProcess[runIndex];
|
|
80272
|
+
if (run2.kind === "break") {
|
|
80273
|
+
if (currentLine) {
|
|
80274
|
+
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
80275
|
+
const completedLine = { ...currentLine, ...metrics };
|
|
80276
|
+
addBarTabsToLine(completedLine);
|
|
80277
|
+
lines.push(completedLine);
|
|
80278
|
+
currentLine = null;
|
|
80279
|
+
} else {
|
|
80280
|
+
const textRunWithSize = block.runs.find(
|
|
80281
|
+
(r2) => r2.kind !== "tab" && r2.kind !== "lineBreak" && r2.kind !== "break" && !("src" in r2) && "fontSize" in r2
|
|
80282
|
+
);
|
|
80283
|
+
const fallbackSize = textRunWithSize?.fontSize ?? 12;
|
|
80284
|
+
const metrics = calculateTypographyMetrics(fallbackSize, spacing);
|
|
80285
|
+
const emptyLine = {
|
|
80286
|
+
fromRun: runIndex,
|
|
80287
|
+
fromChar: 0,
|
|
80288
|
+
toRun: runIndex,
|
|
80289
|
+
toChar: 0,
|
|
80290
|
+
width: 0,
|
|
80291
|
+
segments: [],
|
|
80292
|
+
...metrics
|
|
80293
|
+
};
|
|
80294
|
+
addBarTabsToLine(emptyLine);
|
|
80295
|
+
lines.push(emptyLine);
|
|
80296
|
+
}
|
|
80297
|
+
tabStopCursor = 0;
|
|
80298
|
+
pendingTabAlignment = null;
|
|
80299
|
+
lastAppliedTabAlign = null;
|
|
80300
|
+
continue;
|
|
80301
|
+
}
|
|
79275
80302
|
if (isLineBreakRun(run2)) {
|
|
79276
80303
|
if (currentLine) {
|
|
79277
80304
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
@@ -79422,6 +80449,9 @@ ${l}
|
|
|
79422
80449
|
}
|
|
79423
80450
|
continue;
|
|
79424
80451
|
}
|
|
80452
|
+
if (!("text" in run2) || !("fontSize" in run2)) {
|
|
80453
|
+
continue;
|
|
80454
|
+
}
|
|
79425
80455
|
lastFontSize = run2.fontSize;
|
|
79426
80456
|
const { font } = buildFontString(run2);
|
|
79427
80457
|
const tabSegments = run2.text.split(" ");
|
|
@@ -79461,18 +80491,18 @@ ${l}
|
|
|
79461
80491
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
|
|
79462
80492
|
};
|
|
79463
80493
|
const ls = run2.letterSpacing ?? 0;
|
|
79464
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth) {
|
|
80494
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
79465
80495
|
currentLine.toChar = wordEndWithSpace;
|
|
79466
80496
|
currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
|
|
79467
80497
|
charPosInRun = wordEndWithSpace;
|
|
79468
80498
|
} else {
|
|
79469
|
-
charPosInRun =
|
|
80499
|
+
charPosInRun = wordEndWithSpace;
|
|
79470
80500
|
}
|
|
79471
80501
|
continue;
|
|
79472
80502
|
}
|
|
79473
80503
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
79474
80504
|
const boundarySpacing = currentLine.width > 0 ? run2.letterSpacing ?? 0 : 0;
|
|
79475
|
-
if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth && currentLine.width > 0 && !isTocEntry) {
|
|
80505
|
+
if (currentLine.width + boundarySpacing + wordOnlyWidth > currentLine.maxWidth - WIDTH_FUDGE_PX && currentLine.width > 0 && !isTocEntry) {
|
|
79476
80506
|
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing);
|
|
79477
80507
|
const completedLine = {
|
|
79478
80508
|
...currentLine,
|
|
@@ -79492,16 +80522,16 @@ ${l}
|
|
|
79492
80522
|
maxWidth: getEffectiveWidth(contentWidth),
|
|
79493
80523
|
segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }]
|
|
79494
80524
|
};
|
|
79495
|
-
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth) {
|
|
80525
|
+
if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
79496
80526
|
currentLine.toChar = wordEndWithSpace;
|
|
79497
80527
|
currentLine.width = roundValue(currentLine.width + spaceWidth + (run2.letterSpacing ?? 0));
|
|
79498
80528
|
charPosInRun = wordEndWithSpace;
|
|
79499
80529
|
} else {
|
|
79500
|
-
charPosInRun =
|
|
80530
|
+
charPosInRun = wordEndWithSpace;
|
|
79501
80531
|
}
|
|
79502
80532
|
} else {
|
|
79503
80533
|
currentLine.toRun = runIndex;
|
|
79504
|
-
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth) {
|
|
80534
|
+
if (!isLastWord && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX) {
|
|
79505
80535
|
currentLine.toChar = wordEndNoSpace;
|
|
79506
80536
|
currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
|
|
79507
80537
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
|
|
@@ -79627,6 +80657,34 @@ ${l}
|
|
|
79627
80657
|
async function measureTableBlock(block, constraints) {
|
|
79628
80658
|
const maxWidth = typeof constraints === "number" ? constraints : constraints.maxWidth;
|
|
79629
80659
|
let columnWidths;
|
|
80660
|
+
const scaleColumnWidths = (widths, targetWidth) => {
|
|
80661
|
+
const totalWidth2 = widths.reduce((a2, b2) => a2 + b2, 0);
|
|
80662
|
+
if (totalWidth2 <= targetWidth || widths.length === 0) return widths;
|
|
80663
|
+
const scale = targetWidth / totalWidth2;
|
|
80664
|
+
const scaled = widths.map((w2) => Math.max(1, Math.round(w2 * scale)));
|
|
80665
|
+
const sum = scaled.reduce((a2, b2) => a2 + b2, 0);
|
|
80666
|
+
if (sum !== targetWidth) {
|
|
80667
|
+
const adjust = (delta) => {
|
|
80668
|
+
let idx = 0;
|
|
80669
|
+
const direction = delta > 0 ? 1 : -1;
|
|
80670
|
+
delta = Math.abs(delta);
|
|
80671
|
+
while (delta > 0 && scaled.length > 0) {
|
|
80672
|
+
const i2 = idx % scaled.length;
|
|
80673
|
+
if (direction > 0) {
|
|
80674
|
+
scaled[i2] += 1;
|
|
80675
|
+
delta -= 1;
|
|
80676
|
+
} else if (scaled[i2] > 1) {
|
|
80677
|
+
scaled[i2] -= 1;
|
|
80678
|
+
delta -= 1;
|
|
80679
|
+
}
|
|
80680
|
+
idx += 1;
|
|
80681
|
+
if (idx > scaled.length * 2 && delta > 0) break;
|
|
80682
|
+
}
|
|
80683
|
+
};
|
|
80684
|
+
adjust(targetWidth - sum);
|
|
80685
|
+
}
|
|
80686
|
+
return scaled;
|
|
80687
|
+
};
|
|
79630
80688
|
const maxCellCount = Math.max(1, Math.max(...block.rows.map((r2) => r2.cells.length)));
|
|
79631
80689
|
if (block.columnWidths && block.columnWidths.length > 0) {
|
|
79632
80690
|
columnWidths = [...block.columnWidths];
|
|
@@ -79635,8 +80693,7 @@ ${l}
|
|
|
79635
80693
|
if (hasExplicitWidth || hasFixedLayout) {
|
|
79636
80694
|
const totalWidth2 = columnWidths.reduce((a2, b2) => a2 + b2, 0);
|
|
79637
80695
|
if (totalWidth2 > maxWidth) {
|
|
79638
|
-
|
|
79639
|
-
columnWidths = columnWidths.map((w2) => Math.max(1, Math.floor(w2 * scale)));
|
|
80696
|
+
columnWidths = scaleColumnWidths(columnWidths, maxWidth);
|
|
79640
80697
|
}
|
|
79641
80698
|
} else {
|
|
79642
80699
|
if (columnWidths.length < maxCellCount) {
|
|
@@ -79650,8 +80707,7 @@ ${l}
|
|
|
79650
80707
|
}
|
|
79651
80708
|
const totalWidth2 = columnWidths.reduce((a2, b2) => a2 + b2, 0);
|
|
79652
80709
|
if (totalWidth2 > maxWidth) {
|
|
79653
|
-
|
|
79654
|
-
columnWidths = columnWidths.map((w2) => Math.max(1, Math.floor(w2 * scale)));
|
|
80710
|
+
columnWidths = scaleColumnWidths(columnWidths, maxWidth);
|
|
79655
80711
|
}
|
|
79656
80712
|
}
|
|
79657
80713
|
} else {
|
|
@@ -79668,6 +80724,8 @@ ${l}
|
|
|
79668
80724
|
};
|
|
79669
80725
|
const rowspanTracker = new Array(gridColumnCount).fill(0);
|
|
79670
80726
|
const rows = [];
|
|
80727
|
+
const rowBaseHeights = new Array(block.rows.length).fill(0);
|
|
80728
|
+
const spanConstraints = [];
|
|
79671
80729
|
for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex++) {
|
|
79672
80730
|
const row2 = block.rows[rowIndex];
|
|
79673
80731
|
const cellMeasures = [];
|
|
@@ -79714,6 +80772,11 @@ ${l}
|
|
|
79714
80772
|
colSpan: colspan,
|
|
79715
80773
|
rowSpan: rowspan
|
|
79716
80774
|
});
|
|
80775
|
+
if (rowspan === 1) {
|
|
80776
|
+
rowBaseHeights[rowIndex] = Math.max(rowBaseHeights[rowIndex], totalCellHeight);
|
|
80777
|
+
} else {
|
|
80778
|
+
spanConstraints.push({ startRow: rowIndex, rowSpan: rowspan, requiredHeight: totalCellHeight });
|
|
80779
|
+
}
|
|
79717
80780
|
gridColIndex += colspan;
|
|
79718
80781
|
}
|
|
79719
80782
|
for (let col = gridColIndex; col < gridColumnCount; col++) {
|
|
@@ -79721,10 +80784,39 @@ ${l}
|
|
|
79721
80784
|
rowspanTracker[col]--;
|
|
79722
80785
|
}
|
|
79723
80786
|
}
|
|
79724
|
-
|
|
79725
|
-
|
|
80787
|
+
rows.push({ cells: cellMeasures, height: 0 });
|
|
80788
|
+
}
|
|
80789
|
+
const rowHeights = [...rowBaseHeights];
|
|
80790
|
+
for (const constraint of spanConstraints) {
|
|
80791
|
+
const { startRow, rowSpan, requiredHeight } = constraint;
|
|
80792
|
+
if (rowSpan <= 0) continue;
|
|
80793
|
+
let currentHeight = 0;
|
|
80794
|
+
for (let i2 = 0; i2 < rowSpan && startRow + i2 < rowHeights.length; i2++) {
|
|
80795
|
+
currentHeight += rowHeights[startRow + i2];
|
|
80796
|
+
}
|
|
80797
|
+
if (currentHeight < requiredHeight) {
|
|
80798
|
+
const spanLength = Math.min(rowSpan, rowHeights.length - startRow);
|
|
80799
|
+
const increment2 = spanLength > 0 ? (requiredHeight - currentHeight) / spanLength : 0;
|
|
80800
|
+
for (let i2 = 0; i2 < spanLength; i2++) {
|
|
80801
|
+
rowHeights[startRow + i2] += increment2;
|
|
80802
|
+
}
|
|
80803
|
+
}
|
|
79726
80804
|
}
|
|
79727
|
-
|
|
80805
|
+
block.rows.forEach((row2, index2) => {
|
|
80806
|
+
const spec = row2.attrs?.rowHeight;
|
|
80807
|
+
if (spec?.value != null && Number.isFinite(spec.value)) {
|
|
80808
|
+
const rule = spec.rule ?? "atLeast";
|
|
80809
|
+
if (rule === "exact") {
|
|
80810
|
+
rowHeights[index2] = spec.value;
|
|
80811
|
+
} else {
|
|
80812
|
+
rowHeights[index2] = Math.max(rowHeights[index2], spec.value);
|
|
80813
|
+
}
|
|
80814
|
+
}
|
|
80815
|
+
});
|
|
80816
|
+
for (let i2 = 0; i2 < rows.length; i2++) {
|
|
80817
|
+
rows[i2].height = Math.max(0, rowHeights[i2]);
|
|
80818
|
+
}
|
|
80819
|
+
const totalHeight = rowHeights.reduce((sum, h2) => sum + h2, 0);
|
|
79728
80820
|
const totalWidth = columnWidths.reduce((a2, b2) => a2 + b2, 0);
|
|
79729
80821
|
return {
|
|
79730
80822
|
kind: "table",
|
|
@@ -79930,7 +81022,7 @@ ${l}
|
|
|
79930
81022
|
if (spacing.lineRule === "atLeast") {
|
|
79931
81023
|
return Math.max(baseLineHeight, raw);
|
|
79932
81024
|
}
|
|
79933
|
-
return raw;
|
|
81025
|
+
return Math.max(baseLineHeight, raw);
|
|
79934
81026
|
};
|
|
79935
81027
|
const sanitizePositive = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
79936
81028
|
const sanitizeDecimalSeparator = (value) => {
|
|
@@ -137036,7 +138128,7 @@ ${style2}
|
|
|
137036
138128
|
this.config.colors = shuffleArray(this.config.colors);
|
|
137037
138129
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
137038
138130
|
this.colorIndex = 0;
|
|
137039
|
-
this.version = "1.0.0-beta.
|
|
138131
|
+
this.version = "1.0.0-beta.16";
|
|
137040
138132
|
this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
|
|
137041
138133
|
this.superdocId = config2.superdocId || v4();
|
|
137042
138134
|
this.colors = this.config.colors;
|
|
@@ -139479,7 +140571,7 @@ ${style2}
|
|
|
139479
140571
|
value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
|
|
139480
140572
|
);
|
|
139481
140573
|
}
|
|
139482
|
-
const
|
|
140574
|
+
const indexDexFffM7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
139483
140575
|
__proto__: null,
|
|
139484
140576
|
unified
|
|
139485
140577
|
}, Symbol.toStringTag, { value: "Module" }));
|