@superdoc-dev/mcp 0.3.0-next.17 → 0.3.0-next.19
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/index.js +2074 -326
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -51837,7 +51837,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
|
|
|
51837
51837
|
emptyOptions2 = {};
|
|
51838
51838
|
});
|
|
51839
51839
|
|
|
51840
|
-
// ../../packages/superdoc/dist/chunks/SuperConverter-
|
|
51840
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-Dchjy0My.es.js
|
|
51841
51841
|
function getExtensionConfigField(extension$1, field, context = { name: "" }) {
|
|
51842
51842
|
const fieldValue = extension$1.config[field];
|
|
51843
51843
|
if (typeof fieldValue === "function")
|
|
@@ -100334,18 +100334,78 @@ var isRegExp = (value) => {
|
|
|
100334
100334
|
return twipsToPixels(resolveContentWidthTwips() * percent / 100);
|
|
100335
100335
|
}
|
|
100336
100336
|
return null;
|
|
100337
|
+
}, getRawRowGridMetadata = (row) => {
|
|
100338
|
+
const trPr = row?.elements?.find((element) => element.name === "w:trPr");
|
|
100339
|
+
const getChild = (name) => trPr?.elements?.find((element) => element.name === name);
|
|
100340
|
+
const parseCount = (name) => {
|
|
100341
|
+
const rawValue = getChild(name)?.attributes?.["w:val"];
|
|
100342
|
+
const value = typeof rawValue === "number" ? rawValue : Number.parseInt(rawValue || "0", 10);
|
|
100343
|
+
return Number.isFinite(value) && value > 0 ? value : 0;
|
|
100344
|
+
};
|
|
100345
|
+
const parseMeasurement = (name) => {
|
|
100346
|
+
const node2 = getChild(name);
|
|
100347
|
+
if (!node2?.attributes)
|
|
100348
|
+
return null;
|
|
100349
|
+
const rawValue = node2.attributes["w:w"];
|
|
100350
|
+
const value = typeof rawValue === "number" ? rawValue : Number.parseInt(rawValue || "", 10);
|
|
100351
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
100352
|
+
return null;
|
|
100353
|
+
return {
|
|
100354
|
+
value,
|
|
100355
|
+
type: node2.attributes["w:type"] || "dxa"
|
|
100356
|
+
};
|
|
100357
|
+
};
|
|
100358
|
+
return {
|
|
100359
|
+
gridBefore: parseCount("w:gridBefore"),
|
|
100360
|
+
gridAfter: parseCount("w:gridAfter"),
|
|
100361
|
+
wBefore: parseMeasurement("w:wBefore"),
|
|
100362
|
+
wAfter: parseMeasurement("w:wAfter")
|
|
100363
|
+
};
|
|
100337
100364
|
}, countColumnsInRow = (row) => {
|
|
100338
100365
|
if (!row?.elements?.length)
|
|
100339
100366
|
return 0;
|
|
100340
|
-
|
|
100367
|
+
const { gridBefore, gridAfter } = getRawRowGridMetadata(row);
|
|
100368
|
+
return gridBefore + row.elements.reduce((count, element) => {
|
|
100341
100369
|
if (element.name !== "w:tc")
|
|
100342
100370
|
return count;
|
|
100343
100371
|
const gridSpan = element.elements?.find((el) => el.name === "w:tcPr")?.elements?.find((el) => el.name === "w:gridSpan");
|
|
100344
100372
|
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
100345
100373
|
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
100346
|
-
}, 0);
|
|
100347
|
-
}, clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS),
|
|
100348
|
-
|
|
100374
|
+
}, 0) + gridAfter;
|
|
100375
|
+
}, clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS), resolveSkippedColumnSeedWidthsTwips = (measurement, span) => {
|
|
100376
|
+
if (!measurement || !Number.isFinite(span) || span <= 0)
|
|
100377
|
+
return [];
|
|
100378
|
+
const resolvedPx = resolveMeasurementWidthPx(measurement);
|
|
100379
|
+
if (resolvedPx == null || resolvedPx <= 0)
|
|
100380
|
+
return [];
|
|
100381
|
+
const totalTwips = clampColumnWidthTwips(pixelsToTwips(resolvedPx));
|
|
100382
|
+
const baseWidth = Math.floor(totalTwips / span);
|
|
100383
|
+
const remainder = totalTwips - baseWidth * span;
|
|
100384
|
+
return Array.from({ length: span }, (_, index2) => clampColumnWidthTwips(baseWidth + (index2 < remainder ? 1 : 0)));
|
|
100385
|
+
}, buildFallbackColumnWidthTwips = ({ columnCount, totalWidthTwips, rows }) => {
|
|
100386
|
+
const seededWidths = new Array(columnCount).fill(null);
|
|
100387
|
+
for (const row of rows) {
|
|
100388
|
+
const { gridBefore, gridAfter, wBefore, wAfter } = getRawRowGridMetadata(row);
|
|
100389
|
+
if (gridBefore > 0)
|
|
100390
|
+
resolveSkippedColumnSeedWidthsTwips(wBefore, gridBefore).forEach((widthTwips, index2) => {
|
|
100391
|
+
if (index2 < columnCount)
|
|
100392
|
+
seededWidths[index2] = Math.max(seededWidths[index2] ?? 0, widthTwips);
|
|
100393
|
+
});
|
|
100394
|
+
if (gridAfter > 0)
|
|
100395
|
+
resolveSkippedColumnSeedWidthsTwips(wAfter, gridAfter).forEach((widthTwips, index2) => {
|
|
100396
|
+
const targetIndex = columnCount - gridAfter + index2;
|
|
100397
|
+
if (targetIndex >= 0 && targetIndex < columnCount)
|
|
100398
|
+
seededWidths[targetIndex] = Math.max(seededWidths[targetIndex] ?? 0, widthTwips);
|
|
100399
|
+
});
|
|
100400
|
+
}
|
|
100401
|
+
const seededTotalTwips = seededWidths.reduce((sum, widthTwips) => sum + (widthTwips ?? 0), 0);
|
|
100402
|
+
const remainingColumns = seededWidths.filter((widthTwips) => widthTwips == null).length;
|
|
100403
|
+
const minimumRemainingTwips = remainingColumns * MIN_COLUMN_WIDTH_TWIPS;
|
|
100404
|
+
const effectiveTotalTwips = Math.max(totalWidthTwips, seededTotalTwips + minimumRemainingTwips);
|
|
100405
|
+
const defaultRemainingTwips = remainingColumns > 0 ? clampColumnWidthTwips((effectiveTotalTwips - seededTotalTwips) / remainingColumns) : 0;
|
|
100406
|
+
return seededWidths.map((widthTwips) => clampColumnWidthTwips(widthTwips ?? defaultRemainingTwips));
|
|
100407
|
+
}, buildFallbackGridForTable = ({ params, rows, tableWidth, tableWidthMeasurement }) => {
|
|
100408
|
+
const columnCount = rows.reduce((max, row) => Math.max(max, countColumnsInRow(row)), 0);
|
|
100349
100409
|
if (!columnCount)
|
|
100350
100410
|
return null;
|
|
100351
100411
|
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(params);
|
|
@@ -100360,11 +100420,15 @@ var isRegExp = (value) => {
|
|
|
100360
100420
|
totalWidthPx = tableWidth.width;
|
|
100361
100421
|
if (totalWidthPx == null)
|
|
100362
100422
|
totalWidthPx = twipsToPixels(DEFAULT_CONTENT_WIDTH_TWIPS);
|
|
100363
|
-
const
|
|
100364
|
-
const
|
|
100423
|
+
const minimumColumnWidthTwips = clampColumnWidthTwips(pixelsToTwips(minimumColumnWidthPx));
|
|
100424
|
+
const fallbackColumnWidthTwips = buildFallbackColumnWidthTwips({
|
|
100425
|
+
columnCount,
|
|
100426
|
+
totalWidthTwips: Math.max(clampColumnWidthTwips(pixelsToTwips(totalWidthPx)), minimumColumnWidthTwips * columnCount),
|
|
100427
|
+
rows
|
|
100428
|
+
});
|
|
100365
100429
|
return {
|
|
100366
|
-
grid:
|
|
100367
|
-
columnWidths:
|
|
100430
|
+
grid: fallbackColumnWidthTwips.map((columnWidthTwips) => ({ col: clampColumnWidthTwips(columnWidthTwips) })),
|
|
100431
|
+
columnWidths: fallbackColumnWidthTwips.map((columnWidthTwips) => twipsToPixels(columnWidthTwips))
|
|
100368
100432
|
};
|
|
100369
100433
|
}, translator$69, XML_NODE_NAME$26 = "w:tblGrid", SD_ATTR_KEY$2 = "grid", cellMinWidth, encode$43 = (params) => {
|
|
100370
100434
|
const { nodes } = params;
|
|
@@ -104234,7 +104298,7 @@ var isRegExp = (value) => {
|
|
|
104234
104298
|
state.kern = kernNode.attributes["w:val"];
|
|
104235
104299
|
}
|
|
104236
104300
|
}, SuperConverter;
|
|
104237
|
-
var
|
|
104301
|
+
var init_SuperConverter_Dchjy0My_es = __esm(() => {
|
|
104238
104302
|
init_rolldown_runtime_Bg48TavK_es();
|
|
104239
104303
|
init_jszip_C49i9kUs_es();
|
|
104240
104304
|
init_xml_js_CqGKpaft_es();
|
|
@@ -141829,7 +141893,7 @@ var init_SuperConverter_BTy5lByv_es = __esm(() => {
|
|
|
141829
141893
|
};
|
|
141830
141894
|
});
|
|
141831
141895
|
|
|
141832
|
-
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-
|
|
141896
|
+
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-CEcVKzGV.es.js
|
|
141833
141897
|
function parseSizeUnit(val = "0") {
|
|
141834
141898
|
const length = val.toString() || "0";
|
|
141835
141899
|
const value = Number.parseFloat(length);
|
|
@@ -144465,8 +144529,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
|
|
|
144465
144529
|
}
|
|
144466
144530
|
};
|
|
144467
144531
|
};
|
|
144468
|
-
var
|
|
144469
|
-
|
|
144532
|
+
var init_create_headless_toolbar_CEcVKzGV_es = __esm(() => {
|
|
144533
|
+
init_SuperConverter_Dchjy0My_es();
|
|
144470
144534
|
init_constants_DrU4EASo_es();
|
|
144471
144535
|
init_dist_B8HfvhaK_es();
|
|
144472
144536
|
CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
|
|
@@ -198675,7 +198739,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
|
|
|
198675
198739
|
init_remark_gfm_BhnWr3yf_es();
|
|
198676
198740
|
});
|
|
198677
198741
|
|
|
198678
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
198742
|
+
// ../../packages/superdoc/dist/chunks/src-DAF1K-X-.es.js
|
|
198679
198743
|
function deleteProps(obj, propOrProps) {
|
|
198680
198744
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
198681
198745
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -198930,7 +198994,7 @@ function getCellSpacingPx(cellSpacing) {
|
|
|
198930
198994
|
const v = cellSpacing.value;
|
|
198931
198995
|
if (typeof v !== "number" || !Number.isFinite(v))
|
|
198932
198996
|
return 0;
|
|
198933
|
-
const asPx = (cellSpacing.type ?? "").toLowerCase() === "dxa" && v >= 20 ? v / TWIPS_PER_PX$
|
|
198997
|
+
const asPx = (cellSpacing.type ?? "").toLowerCase() === "dxa" && v >= 20 ? v / TWIPS_PER_PX$3 : v;
|
|
198934
198998
|
return Math.max(0, asPx);
|
|
198935
198999
|
}
|
|
198936
199000
|
function coerceRelativeHeight(raw) {
|
|
@@ -200514,6 +200578,7 @@ function createStructuredContentSelectPlugin(editor) {
|
|
|
200514
200578
|
return false;
|
|
200515
200579
|
const { state } = view;
|
|
200516
200580
|
const { selection } = state;
|
|
200581
|
+
const isEditableSlotText = (text5) => text5.replace(/\u200B/g, "").length === 0;
|
|
200517
200582
|
const resolveBoundaryExit = ($pos) => {
|
|
200518
200583
|
for (let depth = $pos.depth;depth > 0; depth -= 1) {
|
|
200519
200584
|
const node2 = $pos.node(depth);
|
|
@@ -200525,9 +200590,13 @@ function createStructuredContentSelectPlugin(editor) {
|
|
|
200525
200590
|
const beforePos = nodePos;
|
|
200526
200591
|
const afterPos = nodePos + node2.nodeSize;
|
|
200527
200592
|
if (selection.empty) {
|
|
200528
|
-
|
|
200593
|
+
const trailingSlice = state.doc.textBetween(selection.from, contentTo, "", INLINE_LEAF_TEXT);
|
|
200594
|
+
const leadingSlice = state.doc.textBetween(contentFrom, selection.from, "", INLINE_LEAF_TEXT);
|
|
200595
|
+
const onlyTrailingEditableSlots = trailingSlice.length > 0 && isEditableSlotText(trailingSlice);
|
|
200596
|
+
const onlyLeadingEditableSlots = leadingSlice.length > 0 && isEditableSlotText(leadingSlice);
|
|
200597
|
+
if (event.key === "ArrowRight" && (selection.from >= contentTo - 1 || onlyTrailingEditableSlots))
|
|
200529
200598
|
return afterPos;
|
|
200530
|
-
if (event.key === "ArrowLeft" && selection.from <= contentFrom + 1)
|
|
200599
|
+
if (event.key === "ArrowLeft" && (selection.from <= contentFrom + 1 || onlyLeadingEditableSlots))
|
|
200531
200600
|
return beforePos;
|
|
200532
200601
|
return null;
|
|
200533
200602
|
}
|
|
@@ -226115,29 +226184,12 @@ function toTableFailure(code7, message, details) {
|
|
|
226115
226184
|
}
|
|
226116
226185
|
};
|
|
226117
226186
|
}
|
|
226118
|
-
function createSeparatorParagraph(schema) {
|
|
226119
|
-
const paragraphType = schema.nodes.paragraph;
|
|
226120
|
-
if (!paragraphType)
|
|
226121
|
-
return null;
|
|
226122
|
-
const separatorAttrs = {
|
|
226123
|
-
sdBlockId: v4_default(),
|
|
226124
|
-
paraId: generateDocxHexId()
|
|
226125
|
-
};
|
|
226126
|
-
return paragraphType.createAndFill(separatorAttrs) ?? paragraphType.createAndFill();
|
|
226127
|
-
}
|
|
226128
|
-
function buildTableSuccess(tableAddress, trackedChangeRefs) {
|
|
226129
|
-
return {
|
|
226130
|
-
success: true,
|
|
226131
|
-
table: tableAddress,
|
|
226132
|
-
trackedChangeRefs
|
|
226133
|
-
};
|
|
226134
|
-
}
|
|
226135
226187
|
function syncExtractedTableAttrs(tp) {
|
|
226136
226188
|
const extracted = {};
|
|
226137
226189
|
extracted.tableStyleId = tp.tableStyleId ?? null;
|
|
226138
226190
|
extracted.justification = tp.justification ?? null;
|
|
226139
226191
|
extracted.tableLayout = tp.tableLayout ?? null;
|
|
226140
|
-
extracted.borders = convertTableBordersToPixelUnits(tp.borders) ??
|
|
226192
|
+
extracted.borders = convertTableBordersToPixelUnits(tp.borders) ?? {};
|
|
226141
226193
|
const indent2 = tp.tableIndent;
|
|
226142
226194
|
if (indent2?.value != null)
|
|
226143
226195
|
extracted.tableIndent = {
|
|
@@ -226149,7 +226201,7 @@ function syncExtractedTableAttrs(tp) {
|
|
|
226149
226201
|
const spacing = tp.tableCellSpacing;
|
|
226150
226202
|
if (spacing?.value != null) {
|
|
226151
226203
|
extracted.tableCellSpacing = {
|
|
226152
|
-
|
|
226204
|
+
value: twipsToPixels(spacing.value),
|
|
226153
226205
|
type: spacing.type ?? "dxa"
|
|
226154
226206
|
};
|
|
226155
226207
|
extracted.borderCollapse = "separate";
|
|
@@ -226157,23 +226209,23 @@ function syncExtractedTableAttrs(tp) {
|
|
|
226157
226209
|
extracted.tableCellSpacing = null;
|
|
226158
226210
|
extracted.borderCollapse = null;
|
|
226159
226211
|
}
|
|
226160
|
-
const
|
|
226161
|
-
if (
|
|
226162
|
-
if (
|
|
226212
|
+
const width = tp.tableWidth;
|
|
226213
|
+
if (width)
|
|
226214
|
+
if (width.type === "pct" && typeof width.value === "number")
|
|
226163
226215
|
extracted.tableWidth = {
|
|
226164
|
-
value:
|
|
226216
|
+
value: width.value,
|
|
226165
226217
|
type: "pct"
|
|
226166
226218
|
};
|
|
226167
|
-
else if (
|
|
226219
|
+
else if (width.type === "auto")
|
|
226168
226220
|
extracted.tableWidth = {
|
|
226169
226221
|
width: 0,
|
|
226170
226222
|
type: "auto"
|
|
226171
226223
|
};
|
|
226172
|
-
else if (
|
|
226173
|
-
const widthPx = twipsToPixels(
|
|
226224
|
+
else if (width.value != null) {
|
|
226225
|
+
const widthPx = twipsToPixels(width.value);
|
|
226174
226226
|
extracted.tableWidth = widthPx != null ? {
|
|
226175
226227
|
width: widthPx,
|
|
226176
|
-
type:
|
|
226228
|
+
type: width.type
|
|
226177
226229
|
} : null;
|
|
226178
226230
|
} else
|
|
226179
226231
|
extracted.tableWidth = null;
|
|
@@ -226188,6 +226240,95 @@ function convertTableBordersToPixelUnits(value) {
|
|
|
226188
226240
|
mapBorderSizes(clone2, eighthPointsToPixels);
|
|
226189
226241
|
return Object.keys(clone2).length > 0 ? clone2 : undefined;
|
|
226190
226242
|
}
|
|
226243
|
+
function buildWidthAuthoringTableAttrs(currentAttrs, attrOverrides = {}, tablePropertyOverrides = {}) {
|
|
226244
|
+
const currentTableProps = currentAttrs.tableProperties ?? {};
|
|
226245
|
+
const nextTableWidth = resolveWidthAuthoringTableWidth(currentAttrs, attrOverrides, tablePropertyOverrides);
|
|
226246
|
+
const updatedTableProps = {
|
|
226247
|
+
...currentTableProps,
|
|
226248
|
+
...tablePropertyOverrides,
|
|
226249
|
+
tableLayout: "fixed"
|
|
226250
|
+
};
|
|
226251
|
+
if (nextTableWidth)
|
|
226252
|
+
updatedTableProps.tableWidth = nextTableWidth;
|
|
226253
|
+
else
|
|
226254
|
+
delete updatedTableProps.tableWidth;
|
|
226255
|
+
return {
|
|
226256
|
+
...currentAttrs,
|
|
226257
|
+
tableProperties: updatedTableProps,
|
|
226258
|
+
...attrOverrides,
|
|
226259
|
+
...syncExtractedTableAttrs(updatedTableProps),
|
|
226260
|
+
userEdited: true
|
|
226261
|
+
};
|
|
226262
|
+
}
|
|
226263
|
+
function resolveWidthAuthoringTableWidth(currentAttrs, attrOverrides, tablePropertyOverrides) {
|
|
226264
|
+
const explicitOverride = normalizeTableWidthMeasurement(tablePropertyOverrides.tableWidth);
|
|
226265
|
+
if (explicitOverride)
|
|
226266
|
+
return explicitOverride;
|
|
226267
|
+
const gridWidth = sumGridColumnTwips(attrOverrides.grid ?? currentAttrs.grid);
|
|
226268
|
+
if (gridWidth != null)
|
|
226269
|
+
return {
|
|
226270
|
+
value: gridWidth,
|
|
226271
|
+
type: "dxa"
|
|
226272
|
+
};
|
|
226273
|
+
return null;
|
|
226274
|
+
}
|
|
226275
|
+
function sumGridColumnTwips(grid) {
|
|
226276
|
+
const columns = normalizeGridColumns$1(grid);
|
|
226277
|
+
if (!columns || columns.length === 0)
|
|
226278
|
+
return null;
|
|
226279
|
+
const total = columns.reduce((sum, column) => sum + column.col, 0);
|
|
226280
|
+
return total > 0 ? total : null;
|
|
226281
|
+
}
|
|
226282
|
+
function normalizeGridColumns$1(grid) {
|
|
226283
|
+
if (Array.isArray(grid)) {
|
|
226284
|
+
const columns = grid.map((width) => normalizeGridWidth$1(width)).filter((width) => width != null);
|
|
226285
|
+
return columns.length > 0 ? columns : null;
|
|
226286
|
+
}
|
|
226287
|
+
if (grid && typeof grid === "object") {
|
|
226288
|
+
const rawColWidths = grid.colWidths;
|
|
226289
|
+
if (Array.isArray(rawColWidths)) {
|
|
226290
|
+
const columns = rawColWidths.map((width) => normalizeGridWidth$1(width)).filter((width) => width != null);
|
|
226291
|
+
return columns.length > 0 ? columns : null;
|
|
226292
|
+
}
|
|
226293
|
+
}
|
|
226294
|
+
return null;
|
|
226295
|
+
}
|
|
226296
|
+
function normalizeGridWidth$1(width) {
|
|
226297
|
+
if (typeof width === "number" && Number.isFinite(width) && width > 0)
|
|
226298
|
+
return { col: Math.round(width) };
|
|
226299
|
+
const value = width?.col;
|
|
226300
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0)
|
|
226301
|
+
return { col: Math.round(value) };
|
|
226302
|
+
return null;
|
|
226303
|
+
}
|
|
226304
|
+
function normalizeTableWidthMeasurement(width) {
|
|
226305
|
+
if (!width || typeof width !== "object")
|
|
226306
|
+
return null;
|
|
226307
|
+
const value = width.value;
|
|
226308
|
+
if (width.type !== "dxa" || typeof value !== "number" || !Number.isFinite(value) || value <= 0)
|
|
226309
|
+
return null;
|
|
226310
|
+
return {
|
|
226311
|
+
value: Math.round(value),
|
|
226312
|
+
type: "dxa"
|
|
226313
|
+
};
|
|
226314
|
+
}
|
|
226315
|
+
function createSeparatorParagraph(schema) {
|
|
226316
|
+
const paragraphType = schema.nodes.paragraph;
|
|
226317
|
+
if (!paragraphType)
|
|
226318
|
+
return null;
|
|
226319
|
+
const separatorAttrs = {
|
|
226320
|
+
sdBlockId: v4_default(),
|
|
226321
|
+
paraId: generateDocxHexId()
|
|
226322
|
+
};
|
|
226323
|
+
return paragraphType.createAndFill(separatorAttrs) ?? paragraphType.createAndFill();
|
|
226324
|
+
}
|
|
226325
|
+
function buildTableSuccess(tableAddress, trackedChangeRefs) {
|
|
226326
|
+
return {
|
|
226327
|
+
success: true,
|
|
226328
|
+
table: tableAddress,
|
|
226329
|
+
trackedChangeRefs
|
|
226330
|
+
};
|
|
226331
|
+
}
|
|
226191
226332
|
function normalizeGridWidth(width) {
|
|
226192
226333
|
if (typeof width === "number" && Number.isFinite(width))
|
|
226193
226334
|
return { col: Math.round(width) };
|
|
@@ -226250,6 +226391,30 @@ function removeGridColumnWidth(grid, deleteIndex) {
|
|
|
226250
226391
|
columns: colWidths
|
|
226251
226392
|
});
|
|
226252
226393
|
}
|
|
226394
|
+
function buildFirstRowCellWidthProps(attrs, cellStartCol, colspan, colwidth, gridColumns) {
|
|
226395
|
+
const currentCellProps = attrs.tableCellProperties && typeof attrs.tableCellProperties === "object" ? attrs.tableCellProperties : {};
|
|
226396
|
+
const spanTwips = resolveSpanWidthTwips(cellStartCol, colspan, colwidth, gridColumns);
|
|
226397
|
+
if (spanTwips == null)
|
|
226398
|
+
return Object.keys(currentCellProps).length > 0 ? currentCellProps : undefined;
|
|
226399
|
+
return {
|
|
226400
|
+
...currentCellProps,
|
|
226401
|
+
cellWidth: {
|
|
226402
|
+
value: spanTwips,
|
|
226403
|
+
type: "dxa"
|
|
226404
|
+
}
|
|
226405
|
+
};
|
|
226406
|
+
}
|
|
226407
|
+
function resolveSpanWidthTwips(cellStartCol, colspan, colwidth, gridColumns) {
|
|
226408
|
+
const boundedSpan = Math.max(1, colspan);
|
|
226409
|
+
if (Array.isArray(gridColumns) && cellStartCol >= 0 && cellStartCol + boundedSpan <= gridColumns.length) {
|
|
226410
|
+
const gridSpanTwips = gridColumns.slice(cellStartCol, cellStartCol + boundedSpan).reduce((sum, column) => sum + normalizeGridWidth(column).col, 0);
|
|
226411
|
+
if (gridSpanTwips > 0)
|
|
226412
|
+
return gridSpanTwips;
|
|
226413
|
+
}
|
|
226414
|
+
const spanWidthPx = colwidth.slice(0, boundedSpan).reduce((sum, width) => sum + (Number.isFinite(width) ? width : 0), 0);
|
|
226415
|
+
if (spanWidthPx > 0)
|
|
226416
|
+
return Math.round(spanWidthPx * PIXELS_TO_TWIPS);
|
|
226417
|
+
}
|
|
226253
226418
|
function normalizeCellAttrsForSingleCell(attrs) {
|
|
226254
226419
|
const currentColwidth = Array.isArray(attrs.colwidth) ? attrs.colwidth : null;
|
|
226255
226420
|
const tableCellProperties = { ...attrs.tableCellProperties ?? {} };
|
|
@@ -227127,8 +227292,13 @@ function tablesSetColumnWidthAdapter(editor, input2, options) {
|
|
|
227127
227292
|
const tablePos = table2.candidate.pos;
|
|
227128
227293
|
const tableStart = tablePos + 1;
|
|
227129
227294
|
const tableNode = table2.candidate.node;
|
|
227295
|
+
const tableAttrs = tableNode.attrs;
|
|
227130
227296
|
const map$12 = TableMap.get(tableNode);
|
|
227131
227297
|
const widthPx = Math.round(input2.widthPt * (96 / 72));
|
|
227298
|
+
const normalizedGrid = normalizeGridColumns(tableAttrs.grid);
|
|
227299
|
+
const nextGridColumns = normalizedGrid?.columns.slice();
|
|
227300
|
+
if (nextGridColumns && columnIndex < nextGridColumns.length)
|
|
227301
|
+
nextGridColumns[columnIndex] = { col: Math.round(input2.widthPt * POINTS_TO_TWIPS) };
|
|
227132
227302
|
const processed = /* @__PURE__ */ new Set;
|
|
227133
227303
|
for (let row2 = 0;row2 < map$12.height; row2++) {
|
|
227134
227304
|
const index2 = row2 * map$12.width + columnIndex;
|
|
@@ -227142,29 +227312,31 @@ function tablesSetColumnWidthAdapter(editor, input2, options) {
|
|
|
227142
227312
|
const attrs = cell2.attrs;
|
|
227143
227313
|
const colspan = attrs.colspan || 1;
|
|
227144
227314
|
const colwidth = attrs.colwidth?.slice() ?? [];
|
|
227145
|
-
const
|
|
227315
|
+
const cellStartCol = map$12.colCount(pos);
|
|
227316
|
+
const withinCol = columnIndex - cellStartCol;
|
|
227146
227317
|
while (colwidth.length < colspan)
|
|
227147
227318
|
colwidth.push(0);
|
|
227148
227319
|
colwidth[withinCol] = widthPx;
|
|
227149
|
-
|
|
227320
|
+
const nextAttrs = {
|
|
227150
227321
|
...attrs,
|
|
227151
227322
|
colwidth
|
|
227152
|
-
}
|
|
227323
|
+
};
|
|
227324
|
+
if (row2 === 0) {
|
|
227325
|
+
const nextCellProps = buildFirstRowCellWidthProps(attrs, cellStartCol, colspan, colwidth, nextGridColumns);
|
|
227326
|
+
if (nextCellProps)
|
|
227327
|
+
nextAttrs.tableCellProperties = nextCellProps;
|
|
227328
|
+
else
|
|
227329
|
+
delete nextAttrs.tableCellProperties;
|
|
227330
|
+
}
|
|
227331
|
+
tr.setNodeMarkup(tableStart + pos, null, nextAttrs);
|
|
227153
227332
|
}
|
|
227154
|
-
const
|
|
227155
|
-
|
|
227156
|
-
|
|
227157
|
-
|
|
227158
|
-
|
|
227159
|
-
tr.setNodeMarkup(tablePos, null, {
|
|
227160
|
-
...tableAttrs,
|
|
227161
|
-
grid: serializeGridColumns(tableAttrs.grid, {
|
|
227162
|
-
...normalizedGrid,
|
|
227163
|
-
columns: newColumns
|
|
227164
|
-
}),
|
|
227165
|
-
userEdited: true
|
|
227333
|
+
const tableAttrUpdates = {};
|
|
227334
|
+
if (normalizedGrid && nextGridColumns)
|
|
227335
|
+
tableAttrUpdates.grid = serializeGridColumns(tableAttrs.grid, {
|
|
227336
|
+
...normalizedGrid,
|
|
227337
|
+
columns: nextGridColumns
|
|
227166
227338
|
});
|
|
227167
|
-
|
|
227339
|
+
tr.setNodeMarkup(tablePos, null, buildWidthAuthoringTableAttrs(tableAttrs, tableAttrUpdates));
|
|
227168
227340
|
applyDirectMutationMeta(tr);
|
|
227169
227341
|
editor.dispatch(tr);
|
|
227170
227342
|
clearIndexCache(editor);
|
|
@@ -227188,7 +227360,10 @@ function tablesDistributeColumnsAdapter(editor, input2, options) {
|
|
|
227188
227360
|
const tablePos = candidate.pos;
|
|
227189
227361
|
const tableStart = tablePos + 1;
|
|
227190
227362
|
const tableNode = candidate.node;
|
|
227363
|
+
const tableAttrs = tableNode.attrs;
|
|
227191
227364
|
const map$12 = TableMap.get(tableNode);
|
|
227365
|
+
const normalizedGrid = normalizeGridColumns(tableAttrs.grid);
|
|
227366
|
+
const nextGridColumns = normalizedGrid?.columns.slice();
|
|
227192
227367
|
const rangeStart = input2.columnRange?.start ?? 0;
|
|
227193
227368
|
const rangeEnd = input2.columnRange?.end ?? map$12.width - 1;
|
|
227194
227369
|
const rangeWidth = rangeEnd - rangeStart + 1;
|
|
@@ -227204,6 +227379,12 @@ function tablesDistributeColumnsAdapter(editor, input2, options) {
|
|
|
227204
227379
|
totalWidth += colwidth?.[withinCol] ?? 100;
|
|
227205
227380
|
}
|
|
227206
227381
|
const evenWidth = Math.round(totalWidth / rangeWidth);
|
|
227382
|
+
if (nextGridColumns) {
|
|
227383
|
+
const evenWidthTwips = Math.max(1, Math.round(evenWidth * PIXELS_TO_TWIPS));
|
|
227384
|
+
const maxColumn = Math.min(rangeEnd, nextGridColumns.length - 1);
|
|
227385
|
+
for (let col = Math.max(rangeStart, 0);col <= maxColumn; col++)
|
|
227386
|
+
nextGridColumns[col] = { col: evenWidthTwips };
|
|
227387
|
+
}
|
|
227207
227388
|
const processed = /* @__PURE__ */ new Set;
|
|
227208
227389
|
for (let row2 = 0;row2 < map$12.height; row2++)
|
|
227209
227390
|
for (let col = rangeStart;col <= rangeEnd; col++) {
|
|
@@ -227226,29 +227407,26 @@ function tablesDistributeColumnsAdapter(editor, input2, options) {
|
|
|
227226
227407
|
if (absCol >= rangeStart && absCol <= rangeEnd)
|
|
227227
227408
|
newColwidth[c] = evenWidth;
|
|
227228
227409
|
}
|
|
227229
|
-
|
|
227410
|
+
const nextAttrs = {
|
|
227230
227411
|
...attrs,
|
|
227231
227412
|
colwidth: newColwidth
|
|
227232
|
-
}
|
|
227413
|
+
};
|
|
227414
|
+
if (row2 === 0) {
|
|
227415
|
+
const nextCellProps = buildFirstRowCellWidthProps(attrs, cellStartCol, colspan, newColwidth, nextGridColumns);
|
|
227416
|
+
if (nextCellProps)
|
|
227417
|
+
nextAttrs.tableCellProperties = nextCellProps;
|
|
227418
|
+
else
|
|
227419
|
+
delete nextAttrs.tableCellProperties;
|
|
227420
|
+
}
|
|
227421
|
+
tr.setNodeMarkup(tableStart + pos, null, nextAttrs);
|
|
227233
227422
|
}
|
|
227234
|
-
const
|
|
227235
|
-
|
|
227236
|
-
const tableAttrUpdates = {
|
|
227237
|
-
...tableAttrs,
|
|
227238
|
-
userEdited: true
|
|
227239
|
-
};
|
|
227240
|
-
if (normalizedGrid) {
|
|
227241
|
-
const newColumns = normalizedGrid.columns.slice();
|
|
227242
|
-
const evenWidthTwips = Math.max(1, Math.round(evenWidth * PIXELS_TO_TWIPS));
|
|
227243
|
-
const maxColumn = Math.min(rangeEnd, newColumns.length - 1);
|
|
227244
|
-
for (let col = Math.max(rangeStart, 0);col <= maxColumn; col++)
|
|
227245
|
-
newColumns[col] = { col: evenWidthTwips };
|
|
227423
|
+
const tableAttrUpdates = {};
|
|
227424
|
+
if (normalizedGrid && nextGridColumns)
|
|
227246
227425
|
tableAttrUpdates.grid = serializeGridColumns(tableAttrs.grid, {
|
|
227247
227426
|
...normalizedGrid,
|
|
227248
|
-
columns:
|
|
227427
|
+
columns: nextGridColumns
|
|
227249
227428
|
});
|
|
227250
|
-
|
|
227251
|
-
tr.setNodeMarkup(tablePos, null, tableAttrUpdates);
|
|
227429
|
+
tr.setNodeMarkup(tablePos, null, buildWidthAuthoringTableAttrs(tableAttrs, tableAttrUpdates));
|
|
227252
227430
|
applyDirectMutationMeta(tr);
|
|
227253
227431
|
editor.dispatch(tr);
|
|
227254
227432
|
clearIndexCache(editor);
|
|
@@ -227832,6 +228010,10 @@ function tablesSetCellPropertiesAdapter(editor, input2, options) {
|
|
|
227832
228010
|
}
|
|
227833
228011
|
};
|
|
227834
228012
|
tr.setNodeMarkup(cellPos, null, newAttrs);
|
|
228013
|
+
if (input2.preferredWidthPt !== undefined) {
|
|
228014
|
+
const tableAttrs = table2.candidate.node.attrs;
|
|
228015
|
+
tr.setNodeMarkup(table2.candidate.pos, null, buildWidthAuthoringTableAttrs(tableAttrs));
|
|
228016
|
+
}
|
|
227835
228017
|
applyDirectMutationMeta(tr);
|
|
227836
228018
|
editor.dispatch(tr);
|
|
227837
228019
|
clearIndexCache(editor);
|
|
@@ -242363,7 +242545,7 @@ function normalizeFieldAnnotationMetadata(attrs) {
|
|
|
242363
242545
|
borderColor: normalizeColorValue2(attrs.borderColor),
|
|
242364
242546
|
highlighted: toBoolean$2(attrs.highlighted, true),
|
|
242365
242547
|
fontFamily: toNullableString(attrs.fontFamily),
|
|
242366
|
-
fontSize: normalizeFontSize$
|
|
242548
|
+
fontSize: normalizeFontSize$2(attrs.fontSize),
|
|
242367
242549
|
textColor: normalizeColorValue2(attrs.textColor) ?? null,
|
|
242368
242550
|
textHighlight: normalizeColorValue2(attrs.textHighlight) ?? null,
|
|
242369
242551
|
linkUrl: toNullableString(attrs.linkUrl),
|
|
@@ -242457,7 +242639,7 @@ function normalizeColorValue2(value) {
|
|
|
242457
242639
|
return;
|
|
242458
242640
|
return trimmed;
|
|
242459
242641
|
}
|
|
242460
|
-
function normalizeFontSize$
|
|
242642
|
+
function normalizeFontSize$2(value) {
|
|
242461
242643
|
if (value == null)
|
|
242462
242644
|
return null;
|
|
242463
242645
|
if (typeof value === "number")
|
|
@@ -244059,11 +244241,15 @@ function tableNodeToBlock(node2, { nextBlockId, positions, storyKey, trackedChan
|
|
|
244059
244241
|
tableAttrs.tableWidth = hydratedTableStyle.tableWidth;
|
|
244060
244242
|
if (node2.attrs?.tableIndent && typeof node2.attrs.tableIndent === "object")
|
|
244061
244243
|
tableAttrs.tableIndent = { ...node2.attrs.tableIndent };
|
|
244244
|
+
else if (hydratedTableStyle?.tableIndent)
|
|
244245
|
+
tableAttrs.tableIndent = { ...hydratedTableStyle.tableIndent };
|
|
244062
244246
|
if (defaultCellPadding && typeof defaultCellPadding === "object")
|
|
244063
244247
|
tableAttrs.defaultCellPadding = { ...defaultCellPadding };
|
|
244064
244248
|
const tableLayout = node2.attrs?.tableLayout;
|
|
244065
244249
|
if (tableLayout)
|
|
244066
244250
|
tableAttrs.tableLayout = tableLayout;
|
|
244251
|
+
else if (hydratedTableStyle?.tableLayout)
|
|
244252
|
+
tableAttrs.tableLayout = hydratedTableStyle.tableLayout;
|
|
244067
244253
|
const tableProperties = node2.attrs?.tableProperties;
|
|
244068
244254
|
if (tableProperties && typeof tableProperties === "object")
|
|
244069
244255
|
tableAttrs.tableProperties = tableProperties;
|
|
@@ -248982,7 +249168,7 @@ function measureCharacterX(block, line, charOffset, availableWidthOverride, alig
|
|
|
248982
249168
|
}
|
|
248983
249169
|
const text5 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" ? "" : run2.text ?? "";
|
|
248984
249170
|
const runLength = text5.length;
|
|
248985
|
-
const displayText = applyTextTransform$
|
|
249171
|
+
const displayText = applyTextTransform$3(text5, isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" ? undefined : run2.textTransform);
|
|
248986
249172
|
if (currentCharOffset + runLength >= charOffset) {
|
|
248987
249173
|
const offsetInRun = charOffset - currentCharOffset;
|
|
248988
249174
|
ctx$1.font = getRunFontString(run2);
|
|
@@ -249031,7 +249217,7 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx$1) {
|
|
|
249031
249217
|
return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
|
|
249032
249218
|
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math")
|
|
249033
249219
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
249034
|
-
const textUpToTarget = applyTextTransform$
|
|
249220
|
+
const textUpToTarget = applyTextTransform$3(run2.text ?? "", "textTransform" in run2 ? run2.textTransform : undefined).slice(segment.fromChar, segment.toChar).slice(0, offsetInSegment);
|
|
249035
249221
|
ctx$1.font = getRunFontString(run2);
|
|
249036
249222
|
const measured = ctx$1.measureText(textUpToTarget);
|
|
249037
249223
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInSegment, segmentChars);
|
|
@@ -249124,7 +249310,7 @@ function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, align
|
|
|
249124
249310
|
}
|
|
249125
249311
|
const text5 = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" ? "" : run2.text ?? "";
|
|
249126
249312
|
const runLength = text5.length;
|
|
249127
|
-
const displayText = applyTextTransform$
|
|
249313
|
+
const displayText = applyTextTransform$3(text5, isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math" ? undefined : run2.textTransform);
|
|
249128
249314
|
if (runLength === 0)
|
|
249129
249315
|
continue;
|
|
249130
249316
|
ctx$1.font = getRunFontString(run2);
|
|
@@ -249767,7 +249953,7 @@ function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
|
249767
249953
|
const context = getCtx();
|
|
249768
249954
|
const fullText = runText(run2);
|
|
249769
249955
|
const transform2 = isTextRun$3(run2) ? run2.textTransform : undefined;
|
|
249770
|
-
const text5 = applyTextTransform$
|
|
249956
|
+
const text5 = applyTextTransform$2(fullText.slice(fromChar, toChar), transform2, fullText, fromChar);
|
|
249771
249957
|
if (!context) {
|
|
249772
249958
|
const size$1 = (isTextRun$3(run2) ? run2 : null)?.fontSize ?? 16;
|
|
249773
249959
|
return Math.max(1, text5.length * (size$1 * 0.6));
|
|
@@ -253034,7 +253220,7 @@ function areNumberListsEqual(left$1, right$1) {
|
|
|
253034
253220
|
return false;
|
|
253035
253221
|
return true;
|
|
253036
253222
|
}
|
|
253037
|
-
function isWordCharacter(char) {
|
|
253223
|
+
function isWordCharacter$1(char) {
|
|
253038
253224
|
if (!char)
|
|
253039
253225
|
return false;
|
|
253040
253226
|
return WORD_CHARACTER_REGEX.test(char);
|
|
@@ -253117,17 +253303,17 @@ function computeWordSelectionRangeAt(state, pos) {
|
|
|
253117
253303
|
const parentStart = textblockPos.start();
|
|
253118
253304
|
const parentEnd = textblockPos.end();
|
|
253119
253305
|
const sampleEnd = Math.min(pos + 1, parentEnd);
|
|
253120
|
-
if (!isWordCharacter(state.doc.textBetween(pos, sampleEnd, "\x00", "\x00")))
|
|
253306
|
+
if (!isWordCharacter$1(state.doc.textBetween(pos, sampleEnd, "\x00", "\x00")))
|
|
253121
253307
|
return null;
|
|
253122
253308
|
let startPos = pos;
|
|
253123
253309
|
while (startPos > parentStart) {
|
|
253124
|
-
if (!isWordCharacter(state.doc.textBetween(startPos - 1, startPos, "\x00", "\x00")))
|
|
253310
|
+
if (!isWordCharacter$1(state.doc.textBetween(startPos - 1, startPos, "\x00", "\x00")))
|
|
253125
253311
|
break;
|
|
253126
253312
|
startPos -= 1;
|
|
253127
253313
|
}
|
|
253128
253314
|
let endPos = pos;
|
|
253129
253315
|
while (endPos < parentEnd) {
|
|
253130
|
-
if (!isWordCharacter(state.doc.textBetween(endPos, endPos + 1, "\x00", "\x00")))
|
|
253316
|
+
if (!isWordCharacter$1(state.doc.textBetween(endPos, endPos + 1, "\x00", "\x00")))
|
|
253131
253317
|
break;
|
|
253132
253318
|
endPos += 1;
|
|
253133
253319
|
}
|
|
@@ -256398,6 +256584,1369 @@ function getFontMetrics(ctx$1, fontInfo, mode, fonts) {
|
|
|
256398
256584
|
fontMetricsCache.set(key2, result);
|
|
256399
256585
|
return result;
|
|
256400
256586
|
}
|
|
256587
|
+
function computeFixedTableColumnWidths(input2) {
|
|
256588
|
+
const gridColumnCount = Math.max(0, sanitizeColumnCount(input2.gridColumnCount), Array.isArray(input2.preferredColumnWidths) ? input2.preferredColumnWidths.length : 0);
|
|
256589
|
+
const preferredTableWidth = sanitizeOptionalWidth$1(input2.preferredTableWidth);
|
|
256590
|
+
const defaultAddedColumnWidth = resolveDefaultAddedColumnWidth(input2.preferredColumnWidths, preferredTableWidth);
|
|
256591
|
+
const columnWidths = buildInitialGrid(input2.preferredColumnWidths, gridColumnCount, defaultAddedColumnWidth);
|
|
256592
|
+
if (input2.preserveAuthoredGrid === true)
|
|
256593
|
+
return {
|
|
256594
|
+
columnWidths,
|
|
256595
|
+
totalWidth: sumWidths$2(columnWidths),
|
|
256596
|
+
gridColumnCount: columnWidths.length,
|
|
256597
|
+
preferredTableWidth
|
|
256598
|
+
};
|
|
256599
|
+
if (input2.rows.length === 0) {
|
|
256600
|
+
if (preferredTableWidth != null)
|
|
256601
|
+
shrinkToPreferredTableWidth(columnWidths, preferredTableWidth);
|
|
256602
|
+
return {
|
|
256603
|
+
columnWidths,
|
|
256604
|
+
totalWidth: sumWidths$2(columnWidths),
|
|
256605
|
+
gridColumnCount: columnWidths.length,
|
|
256606
|
+
preferredTableWidth
|
|
256607
|
+
};
|
|
256608
|
+
}
|
|
256609
|
+
applyFirstRowRequests(columnWidths, input2.rows[0], defaultAddedColumnWidth);
|
|
256610
|
+
if (preferredTableWidth != null)
|
|
256611
|
+
shrinkToPreferredTableWidth(columnWidths, preferredTableWidth);
|
|
256612
|
+
for (const row2 of input2.rows.slice(1)) {
|
|
256613
|
+
applySubsequentRowRequests(columnWidths, row2, defaultAddedColumnWidth);
|
|
256614
|
+
if (preferredTableWidth != null)
|
|
256615
|
+
shrinkToPreferredTableWidth(columnWidths, preferredTableWidth);
|
|
256616
|
+
}
|
|
256617
|
+
return {
|
|
256618
|
+
columnWidths,
|
|
256619
|
+
totalWidth: sumWidths$2(columnWidths),
|
|
256620
|
+
gridColumnCount: columnWidths.length,
|
|
256621
|
+
preferredTableWidth
|
|
256622
|
+
};
|
|
256623
|
+
}
|
|
256624
|
+
function buildInitialGrid(preferredColumnWidths, gridColumnCount, defaultAddedColumnWidth) {
|
|
256625
|
+
const next2 = preferredColumnWidths.slice(0, gridColumnCount).map((width) => sanitizeNonNegativeWidth(width) ?? 0);
|
|
256626
|
+
while (next2.length < gridColumnCount)
|
|
256627
|
+
next2.push(defaultAddedColumnWidth);
|
|
256628
|
+
return next2;
|
|
256629
|
+
}
|
|
256630
|
+
function applyFirstRowRequests(columnWidths, row2, defaultAddedColumnWidth) {
|
|
256631
|
+
ensureGridWidth(columnWidths, row2.logicalColumnCount, defaultAddedColumnWidth);
|
|
256632
|
+
for (const skippedColumn of row2.skippedColumns)
|
|
256633
|
+
setSkippedColumnWidth(columnWidths, skippedColumn, defaultAddedColumnWidth);
|
|
256634
|
+
for (const cell2 of row2.cells)
|
|
256635
|
+
setCellSpanWidth(columnWidths, cell2, defaultAddedColumnWidth);
|
|
256636
|
+
}
|
|
256637
|
+
function applySubsequentRowRequests(columnWidths, row2, defaultAddedColumnWidth) {
|
|
256638
|
+
ensureGridWidth(columnWidths, row2.logicalColumnCount, defaultAddedColumnWidth);
|
|
256639
|
+
for (const skippedColumn of row2.skippedColumns)
|
|
256640
|
+
growSkippedColumnWidth(columnWidths, skippedColumn, defaultAddedColumnWidth);
|
|
256641
|
+
for (const cell2 of row2.cells)
|
|
256642
|
+
growCellSpanWidth(columnWidths, cell2, defaultAddedColumnWidth);
|
|
256643
|
+
}
|
|
256644
|
+
function setSkippedColumnWidth(columnWidths, skippedColumn, defaultAddedColumnWidth) {
|
|
256645
|
+
const preferredWidth = sanitizeOptionalWidth$1(skippedColumn.preferredWidth);
|
|
256646
|
+
if (preferredWidth == null)
|
|
256647
|
+
return;
|
|
256648
|
+
ensureGridWidth(columnWidths, skippedColumn.columnIndex + 1, defaultAddedColumnWidth);
|
|
256649
|
+
columnWidths[skippedColumn.columnIndex] = preferredWidth;
|
|
256650
|
+
}
|
|
256651
|
+
function growSkippedColumnWidth(columnWidths, skippedColumn, defaultAddedColumnWidth) {
|
|
256652
|
+
const preferredWidth = sanitizeOptionalWidth$1(skippedColumn.preferredWidth);
|
|
256653
|
+
if (preferredWidth == null)
|
|
256654
|
+
return;
|
|
256655
|
+
ensureGridWidth(columnWidths, skippedColumn.columnIndex + 1, defaultAddedColumnWidth);
|
|
256656
|
+
columnWidths[skippedColumn.columnIndex] = Math.max(columnWidths[skippedColumn.columnIndex] ?? 0, preferredWidth);
|
|
256657
|
+
}
|
|
256658
|
+
function setCellSpanWidth(columnWidths, cell2, defaultAddedColumnWidth) {
|
|
256659
|
+
const span = Math.max(1, sanitizeColumnCount(cell2.span));
|
|
256660
|
+
const preferredWidth = sanitizeOptionalWidth$1(cell2.preferredWidth);
|
|
256661
|
+
const endColumn = cell2.startColumn + span;
|
|
256662
|
+
ensureGridWidth(columnWidths, endColumn, defaultAddedColumnWidth);
|
|
256663
|
+
if (preferredWidth == null)
|
|
256664
|
+
return;
|
|
256665
|
+
const currentSpanWidth = sumSpan$1(columnWidths, cell2.startColumn, span);
|
|
256666
|
+
const lastColumnIndex = endColumn - 1;
|
|
256667
|
+
columnWidths[lastColumnIndex] = Math.max(0, (columnWidths[lastColumnIndex] ?? 0) + (preferredWidth - currentSpanWidth));
|
|
256668
|
+
}
|
|
256669
|
+
function growCellSpanWidth(columnWidths, cell2, defaultAddedColumnWidth) {
|
|
256670
|
+
const span = Math.max(1, sanitizeColumnCount(cell2.span));
|
|
256671
|
+
const preferredWidth = sanitizeOptionalWidth$1(cell2.preferredWidth);
|
|
256672
|
+
const endColumn = cell2.startColumn + span;
|
|
256673
|
+
ensureGridWidth(columnWidths, endColumn, defaultAddedColumnWidth);
|
|
256674
|
+
if (preferredWidth == null)
|
|
256675
|
+
return;
|
|
256676
|
+
const deficit = preferredWidth - sumSpan$1(columnWidths, cell2.startColumn, span);
|
|
256677
|
+
if (deficit <= 0)
|
|
256678
|
+
return;
|
|
256679
|
+
const lastColumnIndex = endColumn - 1;
|
|
256680
|
+
columnWidths[lastColumnIndex] = Math.max(0, (columnWidths[lastColumnIndex] ?? 0) + deficit);
|
|
256681
|
+
}
|
|
256682
|
+
function shrinkToPreferredTableWidth(columnWidths, preferredTableWidth) {
|
|
256683
|
+
const totalWidth = sumWidths$2(columnWidths);
|
|
256684
|
+
if (preferredTableWidth <= 0 || totalWidth <= preferredTableWidth || totalWidth <= 0)
|
|
256685
|
+
return;
|
|
256686
|
+
const scale = preferredTableWidth / totalWidth;
|
|
256687
|
+
let consumed = 0;
|
|
256688
|
+
for (let index2 = 0;index2 < columnWidths.length; index2++) {
|
|
256689
|
+
if (index2 === columnWidths.length - 1) {
|
|
256690
|
+
columnWidths[index2] = Math.max(0, preferredTableWidth - consumed);
|
|
256691
|
+
continue;
|
|
256692
|
+
}
|
|
256693
|
+
const scaled = Math.max(0, (columnWidths[index2] ?? 0) * scale);
|
|
256694
|
+
columnWidths[index2] = scaled;
|
|
256695
|
+
consumed += scaled;
|
|
256696
|
+
}
|
|
256697
|
+
}
|
|
256698
|
+
function ensureGridWidth(columnWidths, requiredColumnCount, defaultAddedColumnWidth) {
|
|
256699
|
+
while (columnWidths.length < requiredColumnCount)
|
|
256700
|
+
columnWidths.push(defaultAddedColumnWidth);
|
|
256701
|
+
}
|
|
256702
|
+
function resolveDefaultAddedColumnWidth(preferredColumnWidths, preferredTableWidth) {
|
|
256703
|
+
for (let index2 = preferredColumnWidths.length - 1;index2 >= 0; index2--) {
|
|
256704
|
+
const width = sanitizeNonNegativeWidth(preferredColumnWidths[index2]);
|
|
256705
|
+
if (width != null && width > 0)
|
|
256706
|
+
return width;
|
|
256707
|
+
}
|
|
256708
|
+
const positiveAuthoredWidths = preferredColumnWidths.map((width) => sanitizeNonNegativeWidth(width)).filter((width) => width != null && width > 0);
|
|
256709
|
+
if (positiveAuthoredWidths.length > 0)
|
|
256710
|
+
return sumWidths$2(positiveAuthoredWidths) / positiveAuthoredWidths.length;
|
|
256711
|
+
if (preferredTableWidth != null && preferredTableWidth > 0)
|
|
256712
|
+
return preferredTableWidth;
|
|
256713
|
+
return 1;
|
|
256714
|
+
}
|
|
256715
|
+
function sumSpan$1(columnWidths, startColumn, span) {
|
|
256716
|
+
let total = 0;
|
|
256717
|
+
for (let offset$1 = 0;offset$1 < span; offset$1++)
|
|
256718
|
+
total += columnWidths[startColumn + offset$1] ?? 0;
|
|
256719
|
+
return total;
|
|
256720
|
+
}
|
|
256721
|
+
function sumWidths$2(columnWidths) {
|
|
256722
|
+
return columnWidths.reduce((sum, width) => sum + Math.max(0, width), 0);
|
|
256723
|
+
}
|
|
256724
|
+
function sanitizeColumnCount(value) {
|
|
256725
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0)
|
|
256726
|
+
return 0;
|
|
256727
|
+
return Math.floor(value);
|
|
256728
|
+
}
|
|
256729
|
+
function sanitizeOptionalWidth$1(value) {
|
|
256730
|
+
const width = sanitizeNonNegativeWidth(value);
|
|
256731
|
+
return width == null ? undefined : width;
|
|
256732
|
+
}
|
|
256733
|
+
function sanitizeNonNegativeWidth(value) {
|
|
256734
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
256735
|
+
return;
|
|
256736
|
+
return Math.max(0, value);
|
|
256737
|
+
}
|
|
256738
|
+
function computeAutoFitColumnWidths(input2) {
|
|
256739
|
+
const { workingInput, fixedLayout, rowMetrics, minColumnWidth } = resolveAutoFitContext(input2);
|
|
256740
|
+
if (workingInput.layoutMode === "fixed")
|
|
256741
|
+
return finalizeResult("fixed", fixedLayout.columnWidths, minColumnWidth);
|
|
256742
|
+
const gridColumnCount = fixedLayout.gridColumnCount;
|
|
256743
|
+
if (gridColumnCount === 0)
|
|
256744
|
+
return buildFallbackResult(workingInput.layoutMode, minColumnWidth);
|
|
256745
|
+
const normalizedRows = buildNormalizedRows(workingInput, rowMetrics);
|
|
256746
|
+
const currentWidths = fixedLayout.columnWidths.slice(0, gridColumnCount);
|
|
256747
|
+
const minBounds = new Array(gridColumnCount).fill(0);
|
|
256748
|
+
const maxBounds = new Array(gridColumnCount).fill(0);
|
|
256749
|
+
const preferredOverrides = new Array(gridColumnCount).fill(undefined);
|
|
256750
|
+
const multiSpanCells = [];
|
|
256751
|
+
accumulateBounds({
|
|
256752
|
+
rows: normalizedRows,
|
|
256753
|
+
minBounds,
|
|
256754
|
+
maxBounds,
|
|
256755
|
+
preferredOverrides,
|
|
256756
|
+
multiSpanCells
|
|
256757
|
+
});
|
|
256758
|
+
applyMultiSpanMinimums(minBounds, multiSpanCells);
|
|
256759
|
+
applySingleSpanPreferredOverrides(maxBounds, minBounds, preferredOverrides);
|
|
256760
|
+
applyMultiSpanMaximums(maxBounds, minBounds, multiSpanCells, currentWidths);
|
|
256761
|
+
const triggerCells = collectTriggerCells(currentWidths, multiSpanCells, normalizedRows);
|
|
256762
|
+
const postTriggerGrowableColumns = triggerCells.length > 0 ? collectNonProtectedColumns(triggerCells, gridColumnCount) : undefined;
|
|
256763
|
+
let resolvedWidths = currentWidths.slice();
|
|
256764
|
+
const preferredTableWidth = sanitizeOptionalWidth(workingInput.preferredTableWidth);
|
|
256765
|
+
let targetTableWidth = preferredTableWidth ?? fixedLayout.totalWidth;
|
|
256766
|
+
const maxResolvedTableWidth = preferredTableWidth != null || hasCompleteAuthoredGrid(workingInput) ? Math.max(workingInput.maxTableWidth, targetTableWidth) : workingInput.maxTableWidth;
|
|
256767
|
+
const shouldPreservePreferredGrid = workingInput.preserveAutoGrid === true || workingInput.preserveExplicitAutoGrid === true;
|
|
256768
|
+
if (triggerCells.length > 0) {
|
|
256769
|
+
resolvedWidths = raiseToMinimums(resolvedWidths, minBounds);
|
|
256770
|
+
resolvedWidths = expandTriggersWithinCurrentTable(resolvedWidths, triggerCells, minBounds, maxBounds);
|
|
256771
|
+
resolvedWidths = expandTriggersByGrowingTable(resolvedWidths, triggerCells, maxBounds, maxResolvedTableWidth);
|
|
256772
|
+
targetTableWidth = Math.max(targetTableWidth, sumWidths$1(resolvedWidths));
|
|
256773
|
+
targetTableWidth = Math.min(targetTableWidth, maxResolvedTableWidth);
|
|
256774
|
+
} else {
|
|
256775
|
+
targetTableWidth = Math.min(targetTableWidth, maxResolvedTableWidth);
|
|
256776
|
+
if (!shouldPreservePreferredGrid) {
|
|
256777
|
+
resolvedWidths = redistributeTowardMaximumsWithinCurrentTable(resolvedWidths, minBounds, maxBounds);
|
|
256778
|
+
resolvedWidths = redistributeTowardContentWeightedShape(resolvedWidths, minBounds, maxBounds);
|
|
256779
|
+
}
|
|
256780
|
+
}
|
|
256781
|
+
resolvedWidths = shrinkToTargetWidth(resolvedWidths, targetTableWidth, minBounds);
|
|
256782
|
+
resolvedWidths = growToTargetWidth(resolvedWidths, targetTableWidth, maxBounds, postTriggerGrowableColumns);
|
|
256783
|
+
if (sumWidths$1(resolvedWidths) < targetTableWidth)
|
|
256784
|
+
resolvedWidths = distributeRemainingSlack(resolvedWidths, targetTableWidth, postTriggerGrowableColumns);
|
|
256785
|
+
if (triggerCells.length > 0)
|
|
256786
|
+
resolvedWidths = clampTriggeredSpansToTargets(resolvedWidths, triggerCells, minBounds, maxBounds, currentWidths);
|
|
256787
|
+
if (sumWidths$1(resolvedWidths) > maxResolvedTableWidth)
|
|
256788
|
+
resolvedWidths = shrinkToTargetWidth(resolvedWidths, maxResolvedTableWidth, minBounds);
|
|
256789
|
+
return finalizeResult(workingInput.layoutMode, resolvedWidths, minColumnWidth);
|
|
256790
|
+
}
|
|
256791
|
+
function hasCompleteAuthoredGrid(workingInput) {
|
|
256792
|
+
const authoredColumnCount = workingInput.preferredColumnWidths.length;
|
|
256793
|
+
if (authoredColumnCount === 0)
|
|
256794
|
+
return false;
|
|
256795
|
+
return workingInput.rows.some((row2) => row2.logicalColumnCount >= authoredColumnCount);
|
|
256796
|
+
}
|
|
256797
|
+
function resolveAutoFitContext(input2) {
|
|
256798
|
+
const minColumnWidth = sanitizeWidth(input2.minColumnWidth, DEFAULT_MIN_COLUMN_WIDTH);
|
|
256799
|
+
if (isExplicitInput(input2))
|
|
256800
|
+
return {
|
|
256801
|
+
workingInput: input2.workingInput,
|
|
256802
|
+
fixedLayout: input2.fixedLayout,
|
|
256803
|
+
rowMetrics: input2.contentMetrics.rowMetrics,
|
|
256804
|
+
minColumnWidth
|
|
256805
|
+
};
|
|
256806
|
+
const layoutMode = resolveLayoutMode$1(input2.tableLayout);
|
|
256807
|
+
const normalizedRows = normalizeLegacyRows(input2.rows ?? []);
|
|
256808
|
+
const gridColumnCount = determineGridColumnCount$1(input2.preferredColumnWidths ?? [], normalizedRows);
|
|
256809
|
+
const workingInput = {
|
|
256810
|
+
layoutMode,
|
|
256811
|
+
maxTableWidth: Math.max(minColumnWidth, sanitizeWidth(input2.maxTableWidth, minColumnWidth)),
|
|
256812
|
+
preferredTableWidth: sanitizeOptionalWidth(input2.preferredTableWidth),
|
|
256813
|
+
preferredColumnWidths: (input2.preferredColumnWidths ?? []).map((width) => Math.max(0, width)),
|
|
256814
|
+
gridColumnCount,
|
|
256815
|
+
rows: normalizedRows.map((row2) => ({
|
|
256816
|
+
skippedBefore: row2.skippedColumns.filter((column) => column.columnIndex < firstCellStart(row2)),
|
|
256817
|
+
skippedAfter: row2.skippedColumns.filter((column) => column.columnIndex >= lastCellEnd(row2)),
|
|
256818
|
+
skippedColumns: row2.skippedColumns,
|
|
256819
|
+
cells: row2.cells.map((cell2) => ({
|
|
256820
|
+
cellId: undefined,
|
|
256821
|
+
startColumn: cell2.startColumn,
|
|
256822
|
+
span: cell2.span,
|
|
256823
|
+
preferredWidth: cell2.preferredWidth
|
|
256824
|
+
})),
|
|
256825
|
+
logicalColumnCount: row2.logicalColumnCount
|
|
256826
|
+
}))
|
|
256827
|
+
};
|
|
256828
|
+
return {
|
|
256829
|
+
workingInput,
|
|
256830
|
+
fixedLayout: computeFixedTableColumnWidths(workingInput),
|
|
256831
|
+
rowMetrics: normalizedRows.map((row2, rowIndex) => ({
|
|
256832
|
+
rowIndex,
|
|
256833
|
+
cells: row2.cells.map((cell2) => ({
|
|
256834
|
+
cellIndex: cell2.cellIndex,
|
|
256835
|
+
span: cell2.span,
|
|
256836
|
+
preferredWidth: cell2.preferredWidth,
|
|
256837
|
+
minContentWidth: cell2.minContentWidth,
|
|
256838
|
+
maxContentWidth: cell2.maxContentWidth
|
|
256839
|
+
}))
|
|
256840
|
+
})),
|
|
256841
|
+
minColumnWidth
|
|
256842
|
+
};
|
|
256843
|
+
}
|
|
256844
|
+
function isExplicitInput(input2) {
|
|
256845
|
+
return "workingInput" in input2 && "fixedLayout" in input2 && "contentMetrics" in input2;
|
|
256846
|
+
}
|
|
256847
|
+
function resolveLayoutMode$1(tableLayout) {
|
|
256848
|
+
return tableLayout === "fixed" ? "fixed" : "autofit";
|
|
256849
|
+
}
|
|
256850
|
+
function normalizeLegacyRows(rows) {
|
|
256851
|
+
return rows.map((row2, rowIndex) => {
|
|
256852
|
+
let columnIndex = 0;
|
|
256853
|
+
const skippedColumns = [];
|
|
256854
|
+
const cells = [];
|
|
256855
|
+
for (const skipped of row2.skippedBefore ?? []) {
|
|
256856
|
+
skippedColumns.push(normalizeSkippedColumn(skipped, columnIndex));
|
|
256857
|
+
columnIndex += 1;
|
|
256858
|
+
}
|
|
256859
|
+
for (let cellIndex = 0;cellIndex < (row2.cells ?? []).length; cellIndex++) {
|
|
256860
|
+
const cell2 = row2.cells?.[cellIndex];
|
|
256861
|
+
if (!cell2)
|
|
256862
|
+
continue;
|
|
256863
|
+
const span = Math.max(1, Math.floor(cell2.span ?? 1));
|
|
256864
|
+
cells.push({
|
|
256865
|
+
rowIndex,
|
|
256866
|
+
cellIndex,
|
|
256867
|
+
startColumn: columnIndex,
|
|
256868
|
+
span,
|
|
256869
|
+
preferredWidth: sanitizeOptionalWidth(cell2.preferredWidth),
|
|
256870
|
+
minContentWidth: Math.max(0, cell2.minContentWidth ?? 0),
|
|
256871
|
+
maxContentWidth: Math.max(0, cell2.maxContentWidth ?? cell2.minContentWidth ?? 0)
|
|
256872
|
+
});
|
|
256873
|
+
columnIndex += span;
|
|
256874
|
+
}
|
|
256875
|
+
for (const skipped of row2.skippedAfter ?? []) {
|
|
256876
|
+
skippedColumns.push(normalizeSkippedColumn(skipped, columnIndex));
|
|
256877
|
+
columnIndex += 1;
|
|
256878
|
+
}
|
|
256879
|
+
return {
|
|
256880
|
+
cells,
|
|
256881
|
+
skippedColumns,
|
|
256882
|
+
logicalColumnCount: columnIndex
|
|
256883
|
+
};
|
|
256884
|
+
});
|
|
256885
|
+
}
|
|
256886
|
+
function normalizeSkippedColumn(skipped, columnIndex) {
|
|
256887
|
+
return {
|
|
256888
|
+
columnIndex,
|
|
256889
|
+
preferredWidth: sanitizeOptionalWidth(skipped.preferredWidth),
|
|
256890
|
+
minContentWidth: Math.max(0, skipped.minContentWidth ?? 0),
|
|
256891
|
+
maxContentWidth: Math.max(0, skipped.maxContentWidth ?? skipped.minContentWidth ?? 0)
|
|
256892
|
+
};
|
|
256893
|
+
}
|
|
256894
|
+
function buildNormalizedRows(workingInput, rowMetrics) {
|
|
256895
|
+
return workingInput.rows.map((workingRow, rowIndex) => {
|
|
256896
|
+
const metricsRow = rowMetrics[rowIndex];
|
|
256897
|
+
return {
|
|
256898
|
+
cells: (workingRow.cells ?? []).map((cell2, cellIndex) => {
|
|
256899
|
+
const metrics = metricsRow?.cells[cellIndex];
|
|
256900
|
+
const placedCell = cell2;
|
|
256901
|
+
return {
|
|
256902
|
+
rowIndex,
|
|
256903
|
+
cellIndex: metrics?.cellIndex ?? cellIndex,
|
|
256904
|
+
startColumn: placedCell.startColumn,
|
|
256905
|
+
span: Math.max(1, placedCell.span ?? metrics?.span ?? 1),
|
|
256906
|
+
preferredWidth: sanitizeOptionalWidth(metrics?.preferredWidth ?? placedCell.preferredWidth),
|
|
256907
|
+
minContentWidth: Math.max(0, metrics?.minContentWidth ?? 0),
|
|
256908
|
+
maxContentWidth: Math.max(0, metrics?.maxContentWidth ?? metrics?.minContentWidth ?? 0)
|
|
256909
|
+
};
|
|
256910
|
+
}),
|
|
256911
|
+
skippedColumns: (workingRow.skippedColumns ?? []).map((skipped) => ({
|
|
256912
|
+
columnIndex: skipped.columnIndex,
|
|
256913
|
+
preferredWidth: sanitizeOptionalWidth(skipped.preferredWidth),
|
|
256914
|
+
minContentWidth: Math.max(0, skipped.minContentWidth ?? 0),
|
|
256915
|
+
maxContentWidth: Math.max(0, skipped.maxContentWidth ?? skipped.minContentWidth ?? 0)
|
|
256916
|
+
})),
|
|
256917
|
+
logicalColumnCount: workingRow.logicalColumnCount
|
|
256918
|
+
};
|
|
256919
|
+
});
|
|
256920
|
+
}
|
|
256921
|
+
function accumulateBounds(args$1) {
|
|
256922
|
+
const { rows, minBounds, maxBounds, preferredOverrides, multiSpanCells } = args$1;
|
|
256923
|
+
for (const row2 of rows) {
|
|
256924
|
+
for (const skipped of row2.skippedColumns) {
|
|
256925
|
+
minBounds[skipped.columnIndex] = Math.max(minBounds[skipped.columnIndex], skipped.minContentWidth);
|
|
256926
|
+
maxBounds[skipped.columnIndex] = Math.max(maxBounds[skipped.columnIndex], skipped.maxContentWidth);
|
|
256927
|
+
if (preferredOverrides[skipped.columnIndex] == null && skipped.preferredWidth != null)
|
|
256928
|
+
preferredOverrides[skipped.columnIndex] = skipped.preferredWidth;
|
|
256929
|
+
}
|
|
256930
|
+
for (const cell2 of row2.cells)
|
|
256931
|
+
if (cell2.span === 1) {
|
|
256932
|
+
minBounds[cell2.startColumn] = Math.max(minBounds[cell2.startColumn], cell2.minContentWidth);
|
|
256933
|
+
maxBounds[cell2.startColumn] = Math.max(maxBounds[cell2.startColumn], cell2.maxContentWidth);
|
|
256934
|
+
if (preferredOverrides[cell2.startColumn] == null && cell2.preferredWidth != null)
|
|
256935
|
+
preferredOverrides[cell2.startColumn] = cell2.preferredWidth;
|
|
256936
|
+
} else
|
|
256937
|
+
multiSpanCells.push(cell2);
|
|
256938
|
+
}
|
|
256939
|
+
}
|
|
256940
|
+
function applyMultiSpanMinimums(minBounds, cells) {
|
|
256941
|
+
for (const cell2 of cells)
|
|
256942
|
+
growSpanTotal(minBounds, cell2.startColumn, cell2.span, cell2.minContentWidth);
|
|
256943
|
+
}
|
|
256944
|
+
function applySingleSpanPreferredOverrides(maxBounds, minBounds, preferredOverrides) {
|
|
256945
|
+
for (let index2 = 0;index2 < maxBounds.length; index2++) {
|
|
256946
|
+
const currentMax = Math.max(maxBounds[index2], minBounds[index2]);
|
|
256947
|
+
maxBounds[index2] = preferredOverrides[index2] ?? currentMax;
|
|
256948
|
+
maxBounds[index2] = Math.max(maxBounds[index2], minBounds[index2]);
|
|
256949
|
+
}
|
|
256950
|
+
}
|
|
256951
|
+
function applyMultiSpanMaximums(maxBounds, minBounds, cells, fixedWidths) {
|
|
256952
|
+
for (const cell2 of cells) {
|
|
256953
|
+
const targetTotal = cell2.preferredWidth != null ? Math.max(cell2.preferredWidth, sumSpan(minBounds, cell2.startColumn, cell2.span)) : Math.max(cell2.maxContentWidth, sumSpan(minBounds, cell2.startColumn, cell2.span));
|
|
256954
|
+
setSpanTotal(maxBounds, minBounds, fixedWidths, cell2.startColumn, cell2.span, targetTotal);
|
|
256955
|
+
}
|
|
256956
|
+
}
|
|
256957
|
+
function collectTriggerCells(currentWidths, multiSpanCells, rows) {
|
|
256958
|
+
const triggers = [];
|
|
256959
|
+
for (const row2 of rows)
|
|
256960
|
+
for (const cell2 of row2.cells)
|
|
256961
|
+
if (sumSpan(currentWidths, cell2.startColumn, cell2.span) < cell2.minContentWidth)
|
|
256962
|
+
triggers.push(cell2);
|
|
256963
|
+
for (const cell2 of multiSpanCells)
|
|
256964
|
+
if (sumSpan(currentWidths, cell2.startColumn, cell2.span) < cell2.minContentWidth)
|
|
256965
|
+
triggers.push(cell2);
|
|
256966
|
+
return coalesceEquivalentTriggerCells(dedupeCells(triggers));
|
|
256967
|
+
}
|
|
256968
|
+
function setSpanTotal(widths, minBounds, fixedWidths, startColumn, span, targetTotal) {
|
|
256969
|
+
const currentTotal = sumSpan(widths, startColumn, span);
|
|
256970
|
+
const minTotal = sumSpan(minBounds, startColumn, span);
|
|
256971
|
+
const boundedTarget = Math.max(targetTotal, minTotal);
|
|
256972
|
+
if (currentTotal < boundedTarget) {
|
|
256973
|
+
growSpanTotal(widths, startColumn, span, boundedTarget, fixedWidths);
|
|
256974
|
+
return;
|
|
256975
|
+
}
|
|
256976
|
+
if (currentTotal === boundedTarget)
|
|
256977
|
+
return;
|
|
256978
|
+
const reducibleRanges = collectSpanRanges(widths, minBounds, startColumn, span);
|
|
256979
|
+
const totalReducible = reducibleRanges.reduce((sum, range) => sum + range.amount, 0);
|
|
256980
|
+
if (totalReducible <= 0)
|
|
256981
|
+
return;
|
|
256982
|
+
const reduction = currentTotal - boundedTarget;
|
|
256983
|
+
let applied = 0;
|
|
256984
|
+
for (let rangeIndex = 0;rangeIndex < reducibleRanges.length; rangeIndex++) {
|
|
256985
|
+
const range = reducibleRanges[rangeIndex];
|
|
256986
|
+
const portion = rangeIndex === reducibleRanges.length - 1 ? reduction - applied : reduction * (range.amount / totalReducible);
|
|
256987
|
+
widths[range.index] = Math.max(minBounds[range.index], widths[range.index] - portion);
|
|
256988
|
+
applied += portion;
|
|
256989
|
+
}
|
|
256990
|
+
}
|
|
256991
|
+
function growSpanTotal(widths, startColumn, span, targetTotal, fixedWidths) {
|
|
256992
|
+
const deficit = targetTotal - sumSpan(widths, startColumn, span);
|
|
256993
|
+
if (deficit <= 0)
|
|
256994
|
+
return;
|
|
256995
|
+
const weights = Array.from({ length: span }, (_$1, offset$1) => {
|
|
256996
|
+
const index2 = startColumn + offset$1;
|
|
256997
|
+
return Math.max(fixedWidths?.[index2] ?? 0, widths[index2] ?? 0, 1);
|
|
256998
|
+
});
|
|
256999
|
+
const totalWeight = weights.reduce((sum, weight) => sum + weight, 0);
|
|
257000
|
+
let applied = 0;
|
|
257001
|
+
for (let offset$1 = 0;offset$1 < span; offset$1++) {
|
|
257002
|
+
const index2 = startColumn + offset$1;
|
|
257003
|
+
const increment2 = offset$1 === span - 1 ? deficit - applied : deficit * (weights[offset$1] / totalWeight);
|
|
257004
|
+
widths[index2] = Math.max(0, (widths[index2] ?? 0) + increment2);
|
|
257005
|
+
applied += increment2;
|
|
257006
|
+
}
|
|
257007
|
+
}
|
|
257008
|
+
function shrinkToTargetWidth(widths, targetWidth, minBounds) {
|
|
257009
|
+
const currentTotal = sumWidths$1(widths);
|
|
257010
|
+
if (currentTotal <= targetWidth)
|
|
257011
|
+
return widths;
|
|
257012
|
+
const minTotal = sumWidths$1(minBounds);
|
|
257013
|
+
if (targetWidth <= 0)
|
|
257014
|
+
return widths;
|
|
257015
|
+
if (targetWidth < minTotal)
|
|
257016
|
+
return scaleToTargetWidth(widths, targetWidth);
|
|
257017
|
+
const capacities = widths.map((width, index2) => Math.max(0, width - minBounds[index2]));
|
|
257018
|
+
const totalCapacity = capacities.reduce((sum, capacity) => sum + capacity, 0);
|
|
257019
|
+
if (totalCapacity <= 0)
|
|
257020
|
+
return widths;
|
|
257021
|
+
const excess = currentTotal - targetWidth;
|
|
257022
|
+
return widths.map((width, index2) => {
|
|
257023
|
+
const shrink = excess * (capacities[index2] / totalCapacity);
|
|
257024
|
+
return Math.max(minBounds[index2], width - shrink);
|
|
257025
|
+
});
|
|
257026
|
+
}
|
|
257027
|
+
function growToTargetWidth(widths, targetWidth, maxBounds, growableColumns) {
|
|
257028
|
+
const currentTotal = sumWidths$1(widths);
|
|
257029
|
+
if (currentTotal >= targetWidth)
|
|
257030
|
+
return widths;
|
|
257031
|
+
const ranges = widths.map((width, index2) => growableColumns == null || growableColumns.has(index2) ? Math.max(0, maxBounds[index2] - width) : 0);
|
|
257032
|
+
const totalRange = ranges.reduce((sum, range) => sum + range, 0);
|
|
257033
|
+
if (totalRange <= 0)
|
|
257034
|
+
return widths;
|
|
257035
|
+
const slack = targetWidth - currentTotal;
|
|
257036
|
+
return widths.map((width, index2) => width + slack * (ranges[index2] / totalRange));
|
|
257037
|
+
}
|
|
257038
|
+
function distributeRemainingSlack(widths, targetWidth, growableColumns) {
|
|
257039
|
+
const currentTotal = sumWidths$1(widths);
|
|
257040
|
+
if (currentTotal >= targetWidth)
|
|
257041
|
+
return widths;
|
|
257042
|
+
const basis = widths.reduce((sum, width, index2) => {
|
|
257043
|
+
if (growableColumns != null && !growableColumns.has(index2))
|
|
257044
|
+
return sum;
|
|
257045
|
+
return sum + Math.max(width, 1);
|
|
257046
|
+
}, 0);
|
|
257047
|
+
const slack = targetWidth - currentTotal;
|
|
257048
|
+
if (basis <= 0) {
|
|
257049
|
+
if (growableColumns == null)
|
|
257050
|
+
return widths;
|
|
257051
|
+
const growableIndexes = widths.map((_$1, index2) => index2).filter((index2) => growableColumns.has(index2));
|
|
257052
|
+
if (growableIndexes.length === 0)
|
|
257053
|
+
return widths;
|
|
257054
|
+
const share = slack / growableIndexes.length;
|
|
257055
|
+
return widths.map((width, index2) => growableColumns.has(index2) ? width + share : width);
|
|
257056
|
+
}
|
|
257057
|
+
return widths.map((width, index2) => {
|
|
257058
|
+
if (growableColumns != null && !growableColumns.has(index2))
|
|
257059
|
+
return width;
|
|
257060
|
+
return width + slack * (Math.max(width, 1) / basis);
|
|
257061
|
+
});
|
|
257062
|
+
}
|
|
257063
|
+
function raiseToMinimums(widths, minBounds) {
|
|
257064
|
+
const next2 = widths.slice();
|
|
257065
|
+
const deficits = next2.map((width, index2) => Math.max(0, minBounds[index2] - width));
|
|
257066
|
+
const totalDeficit = deficits.reduce((sum, deficit) => sum + deficit, 0);
|
|
257067
|
+
if (totalDeficit <= 0)
|
|
257068
|
+
return next2;
|
|
257069
|
+
const capacities = next2.map((width, index2) => Math.max(0, width - minBounds[index2]));
|
|
257070
|
+
const totalCapacity = capacities.reduce((sum, capacity) => sum + capacity, 0);
|
|
257071
|
+
const borrowAmount = Math.min(totalDeficit, totalCapacity);
|
|
257072
|
+
if (borrowAmount > 0 && totalCapacity > 0) {
|
|
257073
|
+
let borrowed = 0;
|
|
257074
|
+
for (let index2 = 0;index2 < next2.length; index2++) {
|
|
257075
|
+
const reduction = index2 === next2.length - 1 ? borrowAmount - borrowed : borrowAmount * (capacities[index2] / totalCapacity);
|
|
257076
|
+
next2[index2] = Math.max(minBounds[index2], next2[index2] - reduction);
|
|
257077
|
+
borrowed += reduction;
|
|
257078
|
+
}
|
|
257079
|
+
}
|
|
257080
|
+
for (let index2 = 0;index2 < next2.length; index2++)
|
|
257081
|
+
next2[index2] = Math.max(next2[index2], Math.min(minBounds[index2], widths[index2] + deficits[index2]));
|
|
257082
|
+
return next2;
|
|
257083
|
+
}
|
|
257084
|
+
function redistributeTowardMaximumsWithinCurrentTable(widths, minBounds, maxBounds) {
|
|
257085
|
+
const next2 = widths.slice();
|
|
257086
|
+
for (let iteration = 0;iteration < 8; iteration++) {
|
|
257087
|
+
const receiverHeadrooms = next2.map((width, index2) => Math.max(0, maxBounds[index2] - width));
|
|
257088
|
+
const totalReceiverHeadroom = receiverHeadrooms.reduce((sum, headroom) => sum + headroom, 0);
|
|
257089
|
+
if (totalReceiverHeadroom <= 0.001)
|
|
257090
|
+
break;
|
|
257091
|
+
const donorCapacities = next2.map((width, index2) => receiverHeadrooms[index2] > 0.001 ? 0 : Math.max(0, width - minBounds[index2]));
|
|
257092
|
+
let totalDonorCapacity = donorCapacities.reduce((sum, capacity) => sum + capacity, 0);
|
|
257093
|
+
if (totalDonorCapacity <= 0.001) {
|
|
257094
|
+
for (let index2 = 0;index2 < next2.length; index2++)
|
|
257095
|
+
donorCapacities[index2] = Math.max(0, next2[index2] - minBounds[index2]);
|
|
257096
|
+
totalDonorCapacity = donorCapacities.reduce((sum, capacity) => sum + capacity, 0);
|
|
257097
|
+
}
|
|
257098
|
+
if (totalDonorCapacity <= 0.001)
|
|
257099
|
+
break;
|
|
257100
|
+
const redistribution = Math.min(totalReceiverHeadroom, totalDonorCapacity);
|
|
257101
|
+
shrinkColumnsByCapacity(next2, donorCapacities, minBounds, redistribution);
|
|
257102
|
+
growColumnsByHeadroom(next2, receiverHeadrooms, redistribution);
|
|
257103
|
+
}
|
|
257104
|
+
return next2;
|
|
257105
|
+
}
|
|
257106
|
+
function redistributeTowardContentWeightedShape(widths, minBounds, maxBounds) {
|
|
257107
|
+
const distributableWidth = sumWidths$1(widths) - sumWidths$1(minBounds);
|
|
257108
|
+
if (distributableWidth <= 0.001 || widths.length === 0)
|
|
257109
|
+
return widths;
|
|
257110
|
+
const demandWeights = widths.map((width, index2) => {
|
|
257111
|
+
const demand = Math.max(maxBounds[index2], width, minBounds[index2], 1);
|
|
257112
|
+
return demand * demand;
|
|
257113
|
+
});
|
|
257114
|
+
const totalDemandWeight = demandWeights.reduce((sum, weight) => sum + weight, 0);
|
|
257115
|
+
if (totalDemandWeight <= 0.001)
|
|
257116
|
+
return widths;
|
|
257117
|
+
return widths.map((_$1, index2) => minBounds[index2] + distributableWidth * (demandWeights[index2] / totalDemandWeight));
|
|
257118
|
+
}
|
|
257119
|
+
function expandTriggersWithinCurrentTable(widths, triggerCells, minBounds, maxBounds) {
|
|
257120
|
+
const next2 = widths.slice();
|
|
257121
|
+
const protectedColumns = collectProtectedColumns(triggerCells);
|
|
257122
|
+
for (let iteration = 0;iteration < 8; iteration++) {
|
|
257123
|
+
const totalHeadroom = collectTriggerHeadrooms(next2, triggerCells, maxBounds).reduce((sum, headroom) => sum + headroom, 0);
|
|
257124
|
+
if (totalHeadroom <= 0.001)
|
|
257125
|
+
break;
|
|
257126
|
+
const donorCapacities = next2.map((width, index2) => protectedColumns.has(index2) ? 0 : Math.max(0, width - minBounds[index2]));
|
|
257127
|
+
const totalDonorCapacity = donorCapacities.reduce((sum, capacity) => sum + capacity, 0);
|
|
257128
|
+
if (totalDonorCapacity <= 0.001)
|
|
257129
|
+
break;
|
|
257130
|
+
const borrowedWidth = Math.min(totalHeadroom, totalDonorCapacity);
|
|
257131
|
+
shrinkColumnsByCapacity(next2, donorCapacities, minBounds, borrowedWidth);
|
|
257132
|
+
applyTriggerGrowth(next2, triggerCells, maxBounds, borrowedWidth);
|
|
257133
|
+
}
|
|
257134
|
+
return next2;
|
|
257135
|
+
}
|
|
257136
|
+
function expandTriggersByGrowingTable(widths, triggerCells, maxBounds, maxTableWidth) {
|
|
257137
|
+
const next2 = widths.slice();
|
|
257138
|
+
for (let iteration = 0;iteration < 8; iteration++) {
|
|
257139
|
+
const totalHeadroom = collectTriggerHeadrooms(next2, triggerCells, maxBounds).reduce((sum, headroom) => sum + headroom, 0);
|
|
257140
|
+
if (totalHeadroom <= 0.001)
|
|
257141
|
+
break;
|
|
257142
|
+
const remainingTableGrowth = Math.max(0, maxTableWidth - sumWidths$1(next2));
|
|
257143
|
+
if (remainingTableGrowth <= 0.001)
|
|
257144
|
+
break;
|
|
257145
|
+
applyTriggerGrowth(next2, triggerCells, maxBounds, Math.min(totalHeadroom, remainingTableGrowth));
|
|
257146
|
+
}
|
|
257147
|
+
return next2;
|
|
257148
|
+
}
|
|
257149
|
+
function collectTriggerHeadrooms(widths, triggerCells, maxBounds) {
|
|
257150
|
+
return triggerCells.map((cell2) => {
|
|
257151
|
+
const currentTotal = sumSpan(widths, cell2.startColumn, cell2.span);
|
|
257152
|
+
const targetTotal = resolveTriggerTargetTotal(cell2, maxBounds);
|
|
257153
|
+
return Math.max(0, targetTotal - currentTotal);
|
|
257154
|
+
});
|
|
257155
|
+
}
|
|
257156
|
+
function resolveTriggerTargetTotal(cell2, maxBounds) {
|
|
257157
|
+
if (cell2.span === 1)
|
|
257158
|
+
return maxBounds[cell2.startColumn] ?? cell2.maxContentWidth;
|
|
257159
|
+
return cell2.preferredWidth != null ? Math.max(cell2.preferredWidth, cell2.minContentWidth) : Math.max(cell2.maxContentWidth, cell2.minContentWidth);
|
|
257160
|
+
}
|
|
257161
|
+
function collectProtectedColumns(cells) {
|
|
257162
|
+
const protectedColumns = /* @__PURE__ */ new Set;
|
|
257163
|
+
for (const cell2 of cells)
|
|
257164
|
+
for (let offset$1 = 0;offset$1 < cell2.span; offset$1++)
|
|
257165
|
+
protectedColumns.add(cell2.startColumn + offset$1);
|
|
257166
|
+
return protectedColumns;
|
|
257167
|
+
}
|
|
257168
|
+
function collectNonProtectedColumns(cells, columnCount) {
|
|
257169
|
+
const protectedColumns = collectProtectedColumns(cells);
|
|
257170
|
+
const growableColumns = /* @__PURE__ */ new Set;
|
|
257171
|
+
for (let index2 = 0;index2 < columnCount; index2++)
|
|
257172
|
+
if (!protectedColumns.has(index2))
|
|
257173
|
+
growableColumns.add(index2);
|
|
257174
|
+
return growableColumns;
|
|
257175
|
+
}
|
|
257176
|
+
function shrinkColumnsByCapacity(widths, capacities, minBounds, shrinkAmount) {
|
|
257177
|
+
const totalCapacity = capacities.reduce((sum, capacity) => sum + capacity, 0);
|
|
257178
|
+
if (totalCapacity <= 0 || shrinkAmount <= 0)
|
|
257179
|
+
return;
|
|
257180
|
+
let applied = 0;
|
|
257181
|
+
for (let index2 = 0;index2 < widths.length; index2++) {
|
|
257182
|
+
const reduction = index2 === widths.length - 1 ? shrinkAmount - applied : shrinkAmount * (capacities[index2] / totalCapacity);
|
|
257183
|
+
widths[index2] = Math.max(minBounds[index2], widths[index2] - reduction);
|
|
257184
|
+
applied += reduction;
|
|
257185
|
+
}
|
|
257186
|
+
}
|
|
257187
|
+
function growColumnsByHeadroom(widths, headrooms, growthAmount) {
|
|
257188
|
+
const totalHeadroom = headrooms.reduce((sum, headroom) => sum + headroom, 0);
|
|
257189
|
+
if (totalHeadroom <= 0 || growthAmount <= 0)
|
|
257190
|
+
return;
|
|
257191
|
+
let applied = 0;
|
|
257192
|
+
const activeIndexes = headrooms.map((headroom, index2) => ({
|
|
257193
|
+
headroom,
|
|
257194
|
+
index: index2
|
|
257195
|
+
})).filter((entry) => entry.headroom > 0.001);
|
|
257196
|
+
for (let activeIndex = 0;activeIndex < activeIndexes.length; activeIndex++) {
|
|
257197
|
+
const { index: index2, headroom } = activeIndexes[activeIndex];
|
|
257198
|
+
const growth = activeIndex === activeIndexes.length - 1 ? growthAmount - applied : growthAmount * (headroom / totalHeadroom);
|
|
257199
|
+
widths[index2] += Math.min(headroom, growth);
|
|
257200
|
+
applied += Math.min(headroom, growth);
|
|
257201
|
+
}
|
|
257202
|
+
}
|
|
257203
|
+
function applyTriggerGrowth(widths, triggerCells, maxBounds, growthAmount) {
|
|
257204
|
+
let remainingGrowth = growthAmount;
|
|
257205
|
+
for (let iteration = 0;iteration < 16 && remainingGrowth > 0.001; iteration++) {
|
|
257206
|
+
const headrooms = collectTriggerHeadrooms(widths, triggerCells, maxBounds);
|
|
257207
|
+
const totalHeadroom = headrooms.reduce((sum, headroom) => sum + headroom, 0);
|
|
257208
|
+
if (totalHeadroom <= 0.001)
|
|
257209
|
+
break;
|
|
257210
|
+
const stepGrowth = Math.min(remainingGrowth, totalHeadroom);
|
|
257211
|
+
const activeIndexes = headrooms.map((headroom, index2) => ({
|
|
257212
|
+
headroom,
|
|
257213
|
+
index: index2
|
|
257214
|
+
})).filter((entry) => entry.headroom > 0.001);
|
|
257215
|
+
let appliedThisRound = 0;
|
|
257216
|
+
for (let activeIndex = 0;activeIndex < activeIndexes.length; activeIndex++) {
|
|
257217
|
+
const { index: index2, headroom } = activeIndexes[activeIndex];
|
|
257218
|
+
const cell2 = triggerCells[index2];
|
|
257219
|
+
const proportionalGrowth = activeIndex === activeIndexes.length - 1 ? stepGrowth - appliedThisRound : stepGrowth * (headroom / totalHeadroom);
|
|
257220
|
+
const boundedGrowth = Math.min(headroom, proportionalGrowth);
|
|
257221
|
+
if (boundedGrowth <= 0)
|
|
257222
|
+
continue;
|
|
257223
|
+
growSpanTotal(widths, cell2.startColumn, cell2.span, sumSpan(widths, cell2.startColumn, cell2.span) + boundedGrowth);
|
|
257224
|
+
appliedThisRound += boundedGrowth;
|
|
257225
|
+
}
|
|
257226
|
+
if (appliedThisRound <= 0.001)
|
|
257227
|
+
break;
|
|
257228
|
+
remainingGrowth -= appliedThisRound;
|
|
257229
|
+
}
|
|
257230
|
+
}
|
|
257231
|
+
function clampTriggeredSpansToTargets(widths, triggerCells, minBounds, maxBounds, fixedWidths) {
|
|
257232
|
+
const next2 = widths.slice();
|
|
257233
|
+
for (let iteration = 0;iteration < 8; iteration++) {
|
|
257234
|
+
let changed = false;
|
|
257235
|
+
for (const cell2 of triggerCells) {
|
|
257236
|
+
const currentTotal = sumSpan(next2, cell2.startColumn, cell2.span);
|
|
257237
|
+
const targetTotal = resolveTriggerTargetTotal(cell2, maxBounds);
|
|
257238
|
+
if (currentTotal > targetTotal + 0.001) {
|
|
257239
|
+
setSpanTotal(next2, minBounds, fixedWidths, cell2.startColumn, cell2.span, targetTotal);
|
|
257240
|
+
changed = true;
|
|
257241
|
+
}
|
|
257242
|
+
}
|
|
257243
|
+
if (!changed)
|
|
257244
|
+
break;
|
|
257245
|
+
}
|
|
257246
|
+
return next2;
|
|
257247
|
+
}
|
|
257248
|
+
function collectSpanRanges(widths, minBounds, startColumn, span) {
|
|
257249
|
+
const ranges = [];
|
|
257250
|
+
for (let offset$1 = 0;offset$1 < span; offset$1++) {
|
|
257251
|
+
const index2 = startColumn + offset$1;
|
|
257252
|
+
const amount = Math.max(0, widths[index2] - minBounds[index2]);
|
|
257253
|
+
if (amount > 0)
|
|
257254
|
+
ranges.push({
|
|
257255
|
+
index: index2,
|
|
257256
|
+
amount
|
|
257257
|
+
});
|
|
257258
|
+
}
|
|
257259
|
+
return ranges;
|
|
257260
|
+
}
|
|
257261
|
+
function dedupeCells(cells) {
|
|
257262
|
+
const seen = /* @__PURE__ */ new Set;
|
|
257263
|
+
return cells.filter((cell2) => {
|
|
257264
|
+
const key2 = `${cell2.rowIndex}:${cell2.startColumn}:${cell2.span}:${cell2.cellIndex}`;
|
|
257265
|
+
if (seen.has(key2))
|
|
257266
|
+
return false;
|
|
257267
|
+
seen.add(key2);
|
|
257268
|
+
return true;
|
|
257269
|
+
});
|
|
257270
|
+
}
|
|
257271
|
+
function coalesceEquivalentTriggerCells(cells) {
|
|
257272
|
+
const strongestBySpan = /* @__PURE__ */ new Map;
|
|
257273
|
+
for (const cell2 of cells) {
|
|
257274
|
+
const key2 = `${cell2.startColumn}:${cell2.span}`;
|
|
257275
|
+
const current = strongestBySpan.get(key2);
|
|
257276
|
+
if (!current || resolveTriggerStrength(cell2) > resolveTriggerStrength(current))
|
|
257277
|
+
strongestBySpan.set(key2, cell2);
|
|
257278
|
+
}
|
|
257279
|
+
return [...strongestBySpan.values()];
|
|
257280
|
+
}
|
|
257281
|
+
function resolveTriggerStrength(cell2) {
|
|
257282
|
+
return cell2.preferredWidth != null ? Math.max(cell2.preferredWidth, cell2.minContentWidth) : Math.max(cell2.maxContentWidth, cell2.minContentWidth);
|
|
257283
|
+
}
|
|
257284
|
+
function determineGridColumnCount$1(preferredColumnWidths, rows) {
|
|
257285
|
+
return Math.max(preferredColumnWidths.length, ...rows.map((row2) => row2.logicalColumnCount), 0);
|
|
257286
|
+
}
|
|
257287
|
+
function firstCellStart(row2) {
|
|
257288
|
+
return row2.cells[0]?.startColumn ?? row2.logicalColumnCount;
|
|
257289
|
+
}
|
|
257290
|
+
function lastCellEnd(row2) {
|
|
257291
|
+
const lastCell = row2.cells[row2.cells.length - 1];
|
|
257292
|
+
return lastCell ? lastCell.startColumn + lastCell.span : 0;
|
|
257293
|
+
}
|
|
257294
|
+
function sumSpan(widths, startColumn, span) {
|
|
257295
|
+
let total = 0;
|
|
257296
|
+
for (let offset$1 = 0;offset$1 < span; offset$1++)
|
|
257297
|
+
total += widths[startColumn + offset$1] ?? 0;
|
|
257298
|
+
return total;
|
|
257299
|
+
}
|
|
257300
|
+
function sumWidths$1(widths) {
|
|
257301
|
+
return widths.reduce((sum, width) => sum + Math.max(0, width), 0);
|
|
257302
|
+
}
|
|
257303
|
+
function scaleToTargetWidth(widths, targetWidth) {
|
|
257304
|
+
const currentTotal = sumWidths$1(widths);
|
|
257305
|
+
if (currentTotal <= 0 || targetWidth <= 0)
|
|
257306
|
+
return widths;
|
|
257307
|
+
const scale = targetWidth / currentTotal;
|
|
257308
|
+
return widths.map((width) => Math.max(0, width * scale));
|
|
257309
|
+
}
|
|
257310
|
+
function sanitizeWidth(value, fallback) {
|
|
257311
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
257312
|
+
}
|
|
257313
|
+
function sanitizeOptionalWidth(value) {
|
|
257314
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
257315
|
+
}
|
|
257316
|
+
function buildFallbackResult(layoutMode, minColumnWidth) {
|
|
257317
|
+
return {
|
|
257318
|
+
layoutMode,
|
|
257319
|
+
columnWidths: [minColumnWidth],
|
|
257320
|
+
totalWidth: minColumnWidth,
|
|
257321
|
+
gridColumnCount: 1
|
|
257322
|
+
};
|
|
257323
|
+
}
|
|
257324
|
+
function finalizeResult(layoutMode, widths, minColumnWidth) {
|
|
257325
|
+
if (widths.length === 0)
|
|
257326
|
+
return buildFallbackResult(layoutMode, minColumnWidth);
|
|
257327
|
+
return {
|
|
257328
|
+
layoutMode,
|
|
257329
|
+
columnWidths: widths,
|
|
257330
|
+
totalWidth: sumWidths$1(widths),
|
|
257331
|
+
gridColumnCount: widths.length
|
|
257332
|
+
};
|
|
257333
|
+
}
|
|
257334
|
+
function buildAutoFitWorkingGridInput(block, constraints) {
|
|
257335
|
+
const maxTableWidth = sanitizePositiveNumber(constraints.maxWidth);
|
|
257336
|
+
const layoutMode = resolveLayoutMode(block.attrs?.tableLayout);
|
|
257337
|
+
const preferredTableWidth = resolvePreferredTableWidth(block.attrs?.tableWidth, maxTableWidth);
|
|
257338
|
+
const rawPreferredColumnWidths = normalizePreferredColumnWidths(block.columnWidths);
|
|
257339
|
+
const logicalColumnLimit = resolveTrailingPlaceholderColumnLimit(rawPreferredColumnWidths);
|
|
257340
|
+
let activeRowSpans = [];
|
|
257341
|
+
const rows = block.rows.map((row2) => {
|
|
257342
|
+
const normalized = normalizeRow(row2, preferredTableWidth ?? maxTableWidth, activeRowSpans, logicalColumnLimit);
|
|
257343
|
+
activeRowSpans = normalized.nextActiveRowSpans;
|
|
257344
|
+
return normalized.row;
|
|
257345
|
+
});
|
|
257346
|
+
const preferredColumnWidths = trimTrailingUnoccupiedPlaceholderColumns(rawPreferredColumnWidths, determineGridColumnCount(0, rows));
|
|
257347
|
+
const gridColumnCount = determineGridColumnCount(preferredColumnWidths.length, rows);
|
|
257348
|
+
const preserveAuthoredGrid = shouldPreserveAuthoredGrid({
|
|
257349
|
+
layoutMode,
|
|
257350
|
+
preferredColumnWidths,
|
|
257351
|
+
preferredTableWidth,
|
|
257352
|
+
gridColumnCount
|
|
257353
|
+
});
|
|
257354
|
+
const preserveAutoGrid = shouldPreserveAutoGrid({
|
|
257355
|
+
layoutMode,
|
|
257356
|
+
preferredColumnWidths,
|
|
257357
|
+
preferredTableWidth,
|
|
257358
|
+
gridColumnCount
|
|
257359
|
+
});
|
|
257360
|
+
const preserveExplicitAutoGrid = shouldPreserveExplicitAutoGrid({
|
|
257361
|
+
layoutMode,
|
|
257362
|
+
preferredColumnWidths,
|
|
257363
|
+
preferredTableWidth,
|
|
257364
|
+
gridColumnCount,
|
|
257365
|
+
rows
|
|
257366
|
+
});
|
|
257367
|
+
return {
|
|
257368
|
+
layoutMode,
|
|
257369
|
+
maxTableWidth,
|
|
257370
|
+
...preserveAuthoredGrid ? { preserveAuthoredGrid } : {},
|
|
257371
|
+
...preserveAutoGrid ? { preserveAutoGrid } : {},
|
|
257372
|
+
...preserveExplicitAutoGrid ? { preserveExplicitAutoGrid } : {},
|
|
257373
|
+
preferredTableWidth,
|
|
257374
|
+
preferredColumnWidths,
|
|
257375
|
+
gridColumnCount,
|
|
257376
|
+
rows
|
|
257377
|
+
};
|
|
257378
|
+
}
|
|
257379
|
+
function resolveLayoutMode(tableLayout) {
|
|
257380
|
+
return tableLayout === "fixed" ? "fixed" : "autofit";
|
|
257381
|
+
}
|
|
257382
|
+
function shouldPreserveAuthoredGrid(args$1) {
|
|
257383
|
+
const { layoutMode, preferredColumnWidths, preferredTableWidth, gridColumnCount } = args$1;
|
|
257384
|
+
if (layoutMode !== "fixed")
|
|
257385
|
+
return false;
|
|
257386
|
+
if (preferredTableWidth == null || preferredTableWidth <= 0)
|
|
257387
|
+
return false;
|
|
257388
|
+
if (preferredColumnWidths.length === 0 || preferredColumnWidths.length !== gridColumnCount)
|
|
257389
|
+
return false;
|
|
257390
|
+
const totalPreferredColumnWidth = sumWidths(preferredColumnWidths);
|
|
257391
|
+
return approximatelyEqual(totalPreferredColumnWidth, preferredTableWidth) || isSlightlyUnderPreferredTableWidth(totalPreferredColumnWidth, preferredTableWidth);
|
|
257392
|
+
}
|
|
257393
|
+
function shouldPreserveAutoGrid(args$1) {
|
|
257394
|
+
const { layoutMode, preferredColumnWidths, preferredTableWidth, gridColumnCount } = args$1;
|
|
257395
|
+
if (layoutMode !== "autofit")
|
|
257396
|
+
return false;
|
|
257397
|
+
if (preferredTableWidth != null)
|
|
257398
|
+
return false;
|
|
257399
|
+
if (preferredColumnWidths.length === 0 || preferredColumnWidths.length !== gridColumnCount)
|
|
257400
|
+
return false;
|
|
257401
|
+
if (!hasNonUniformGrid(preferredColumnWidths))
|
|
257402
|
+
return false;
|
|
257403
|
+
return true;
|
|
257404
|
+
}
|
|
257405
|
+
function shouldPreserveExplicitAutoGrid(args$1) {
|
|
257406
|
+
const { layoutMode, preferredColumnWidths, preferredTableWidth, gridColumnCount, rows } = args$1;
|
|
257407
|
+
if (layoutMode !== "autofit")
|
|
257408
|
+
return false;
|
|
257409
|
+
if (preferredTableWidth == null || preferredTableWidth <= 0)
|
|
257410
|
+
return false;
|
|
257411
|
+
if (preferredColumnWidths.length === 0 || preferredColumnWidths.length !== gridColumnCount)
|
|
257412
|
+
return false;
|
|
257413
|
+
if (!hasNonUniformGrid(preferredColumnWidths) && !hasConcreteCellWidthRequest(rows))
|
|
257414
|
+
return false;
|
|
257415
|
+
return approximatelyEqual(sumWidths(preferredColumnWidths), preferredTableWidth);
|
|
257416
|
+
}
|
|
257417
|
+
function hasNonUniformGrid(widths) {
|
|
257418
|
+
if (widths.length <= 1)
|
|
257419
|
+
return true;
|
|
257420
|
+
const firstWidth = widths[0];
|
|
257421
|
+
return widths.some((width) => !approximatelyEqual(width, firstWidth));
|
|
257422
|
+
}
|
|
257423
|
+
function hasConcreteCellWidthRequest(rows) {
|
|
257424
|
+
return rows.some((row2) => row2.cells.some((cell2) => cell2.preferredWidth != null));
|
|
257425
|
+
}
|
|
257426
|
+
function trimTrailingUnoccupiedPlaceholderColumns(widths, occupiedGridColumnCount) {
|
|
257427
|
+
const occupiedCount = Math.max(0, Math.floor(occupiedGridColumnCount));
|
|
257428
|
+
if (occupiedCount <= 0 || widths.length <= occupiedCount)
|
|
257429
|
+
return widths;
|
|
257430
|
+
if (!widths.slice(occupiedCount).every((width) => width <= PLACEHOLDER_COLUMN_MAX_WIDTH))
|
|
257431
|
+
return widths;
|
|
257432
|
+
return widths.slice(0, occupiedCount);
|
|
257433
|
+
}
|
|
257434
|
+
function resolveTrailingPlaceholderColumnLimit(widths) {
|
|
257435
|
+
let trailingPlaceholderCount = 0;
|
|
257436
|
+
for (let index2 = widths.length - 1;index2 >= 0; index2--) {
|
|
257437
|
+
if (widths[index2] > PLACEHOLDER_COLUMN_MAX_WIDTH)
|
|
257438
|
+
break;
|
|
257439
|
+
trailingPlaceholderCount += 1;
|
|
257440
|
+
}
|
|
257441
|
+
if (trailingPlaceholderCount === 0 || trailingPlaceholderCount === widths.length)
|
|
257442
|
+
return;
|
|
257443
|
+
return widths.length - trailingPlaceholderCount;
|
|
257444
|
+
}
|
|
257445
|
+
function normalizePreferredColumnWidths(columnWidths) {
|
|
257446
|
+
if (!Array.isArray(columnWidths))
|
|
257447
|
+
return [];
|
|
257448
|
+
return columnWidths.map((width) => sanitizeNonNegativeNumber(width)).filter((width) => width !== undefined).map((width) => width);
|
|
257449
|
+
}
|
|
257450
|
+
function normalizeRow(row2, percentageBasis, activeRowSpans, logicalColumnLimit) {
|
|
257451
|
+
const rowProps = row2.attrs?.tableRowProperties ?? {};
|
|
257452
|
+
const skippedBeforeCount = sanitizeCount(rowProps.gridBefore);
|
|
257453
|
+
const skippedAfterCount = normalizeSkippedAfterCount(rowProps.gridAfter, rowProps.wAfter, percentageBasis);
|
|
257454
|
+
const cells = Array.isArray(row2.cells) ? row2.cells : [];
|
|
257455
|
+
let columnIndex = advancePastOccupiedColumns(activeRowSpans, 0);
|
|
257456
|
+
const skippedBeforePlacement = buildSkippedColumns(skippedBeforeCount, rowProps.wBefore, percentageBasis, columnIndex, activeRowSpans);
|
|
257457
|
+
columnIndex = skippedBeforePlacement.nextColumnIndex;
|
|
257458
|
+
const normalizedCells = cells.map((cell2) => {
|
|
257459
|
+
columnIndex = advancePastOccupiedColumns(activeRowSpans, columnIndex);
|
|
257460
|
+
const normalizedCell = normalizeCell(cell2, percentageBasis, columnIndex, logicalColumnLimit);
|
|
257461
|
+
columnIndex += normalizedCell.span ?? 1;
|
|
257462
|
+
return normalizedCell;
|
|
257463
|
+
});
|
|
257464
|
+
const skippedAfterPlacement = buildSkippedColumns(skippedAfterCount, rowProps.wAfter, percentageBasis, columnIndex, activeRowSpans);
|
|
257465
|
+
columnIndex = skippedAfterPlacement.nextColumnIndex;
|
|
257466
|
+
const logicalColumnCount = Math.max(columnIndex, resolveOccupiedLogicalColumnCount(activeRowSpans));
|
|
257467
|
+
const nextActiveRowSpans = advanceRowSpans(activeRowSpans);
|
|
257468
|
+
normalizedCells.forEach((cell2, index2) => {
|
|
257469
|
+
const rowSpan = sanitizeCount(cells[index2]?.rowSpan) || 1;
|
|
257470
|
+
if (rowSpan > 1)
|
|
257471
|
+
markRowSpanOccupancy(nextActiveRowSpans, cell2.startColumn, cell2.span ?? 1, rowSpan - 1);
|
|
257472
|
+
});
|
|
257473
|
+
return {
|
|
257474
|
+
row: {
|
|
257475
|
+
skippedBefore: skippedBeforePlacement.columns,
|
|
257476
|
+
cells: normalizedCells,
|
|
257477
|
+
skippedAfter: skippedAfterPlacement.columns,
|
|
257478
|
+
skippedColumns: [...skippedBeforePlacement.columns, ...skippedAfterPlacement.columns],
|
|
257479
|
+
logicalColumnCount
|
|
257480
|
+
},
|
|
257481
|
+
nextActiveRowSpans
|
|
257482
|
+
};
|
|
257483
|
+
}
|
|
257484
|
+
function buildSkippedColumns(count, preferredWidthMeasurement, percentageBasis, startColumnIndex, activeRowSpans) {
|
|
257485
|
+
if (count <= 0)
|
|
257486
|
+
return {
|
|
257487
|
+
columns: [],
|
|
257488
|
+
nextColumnIndex: startColumnIndex
|
|
257489
|
+
};
|
|
257490
|
+
const totalPreferredWidth = resolveMeasurementToPx(preferredWidthMeasurement, percentageBasis);
|
|
257491
|
+
const perColumnPreferredWidth = totalPreferredWidth != null && count > 0 ? Math.max(0, totalPreferredWidth / count) : undefined;
|
|
257492
|
+
const columns = [];
|
|
257493
|
+
let columnIndex = startColumnIndex;
|
|
257494
|
+
for (let index2 = 0;index2 < count; index2++) {
|
|
257495
|
+
columnIndex = advancePastOccupiedColumns(activeRowSpans, columnIndex);
|
|
257496
|
+
columns.push({
|
|
257497
|
+
columnIndex,
|
|
257498
|
+
preferredWidth: perColumnPreferredWidth,
|
|
257499
|
+
minContentWidth: 0,
|
|
257500
|
+
maxContentWidth: 0
|
|
257501
|
+
});
|
|
257502
|
+
columnIndex += 1;
|
|
257503
|
+
}
|
|
257504
|
+
return {
|
|
257505
|
+
columns,
|
|
257506
|
+
nextColumnIndex: columnIndex
|
|
257507
|
+
};
|
|
257508
|
+
}
|
|
257509
|
+
function normalizeSkippedAfterCount(countValue, preferredWidthMeasurement, percentageBasis) {
|
|
257510
|
+
const count = sanitizeCount(countValue);
|
|
257511
|
+
if (count <= 0)
|
|
257512
|
+
return 0;
|
|
257513
|
+
const totalPreferredWidth = resolveMeasurementToPx(preferredWidthMeasurement, percentageBasis);
|
|
257514
|
+
if (totalPreferredWidth != null && totalPreferredWidth <= PLACEHOLDER_COLUMN_MAX_WIDTH * count)
|
|
257515
|
+
return 0;
|
|
257516
|
+
return count;
|
|
257517
|
+
}
|
|
257518
|
+
function normalizeCell(cell2, percentageBasis, startColumn, logicalColumnLimit) {
|
|
257519
|
+
const cellProps = cell2.attrs?.tableCellProperties ?? {};
|
|
257520
|
+
const rawSpan = sanitizeCount(cell2.colSpan) || 1;
|
|
257521
|
+
const span = logicalColumnLimit != null && startColumn < logicalColumnLimit && startColumn + rawSpan > logicalColumnLimit ? Math.max(1, logicalColumnLimit - startColumn) : rawSpan;
|
|
257522
|
+
return {
|
|
257523
|
+
cellId: cell2.id,
|
|
257524
|
+
startColumn,
|
|
257525
|
+
span,
|
|
257526
|
+
preferredWidth: resolveMeasurementToPx(cellProps.cellWidth, percentageBasis)
|
|
257527
|
+
};
|
|
257528
|
+
}
|
|
257529
|
+
function advancePastOccupiedColumns(activeRowSpans, columnIndex) {
|
|
257530
|
+
let nextColumnIndex = columnIndex;
|
|
257531
|
+
while ((activeRowSpans[nextColumnIndex] ?? 0) > 0)
|
|
257532
|
+
nextColumnIndex += 1;
|
|
257533
|
+
return nextColumnIndex;
|
|
257534
|
+
}
|
|
257535
|
+
function resolveOccupiedLogicalColumnCount(activeRowSpans) {
|
|
257536
|
+
for (let index2 = activeRowSpans.length - 1;index2 >= 0; index2--)
|
|
257537
|
+
if ((activeRowSpans[index2] ?? 0) > 0)
|
|
257538
|
+
return index2 + 1;
|
|
257539
|
+
return 0;
|
|
257540
|
+
}
|
|
257541
|
+
function advanceRowSpans(activeRowSpans) {
|
|
257542
|
+
return activeRowSpans.map((remainingRows) => Math.max(0, remainingRows - 1));
|
|
257543
|
+
}
|
|
257544
|
+
function markRowSpanOccupancy(activeRowSpans, startColumn, span, remainingRows) {
|
|
257545
|
+
const boundedSpan = Math.max(1, sanitizeCount(span));
|
|
257546
|
+
for (let offset$1 = 0;offset$1 < boundedSpan; offset$1++) {
|
|
257547
|
+
const columnIndex = startColumn + offset$1;
|
|
257548
|
+
activeRowSpans[columnIndex] = Math.max(activeRowSpans[columnIndex] ?? 0, remainingRows);
|
|
257549
|
+
}
|
|
257550
|
+
}
|
|
257551
|
+
function determineGridColumnCount(preferredColumnCount, rows) {
|
|
257552
|
+
return Math.max(preferredColumnCount, ...rows.map((row2) => {
|
|
257553
|
+
if ("logicalColumnCount" in row2 && typeof row2.logicalColumnCount === "number")
|
|
257554
|
+
return row2.logicalColumnCount;
|
|
257555
|
+
const skippedBefore = row2.skippedBefore?.length ?? 0;
|
|
257556
|
+
const skippedAfter = row2.skippedAfter?.length ?? 0;
|
|
257557
|
+
const cellSpanTotal = (row2.cells ?? []).reduce((sum, cell2) => sum + Math.max(1, cell2.span ?? 1), 0);
|
|
257558
|
+
return skippedBefore + skippedAfter + cellSpanTotal;
|
|
257559
|
+
}), 0);
|
|
257560
|
+
}
|
|
257561
|
+
function resolvePreferredTableWidth(tableWidth, maxWidth) {
|
|
257562
|
+
const resolvedWidth = resolveTableWidthAttr(tableWidth);
|
|
257563
|
+
if (!resolvedWidth)
|
|
257564
|
+
return;
|
|
257565
|
+
if (resolvedWidth.type === "pct")
|
|
257566
|
+
return Math.round(maxWidth * (resolvedWidth.width / OOXML_PCT_DIVISOR));
|
|
257567
|
+
return resolvedWidth.width;
|
|
257568
|
+
}
|
|
257569
|
+
function resolveMeasurementToPx(measurement, percentageBasis) {
|
|
257570
|
+
if (!measurement || typeof measurement !== "object" || !Number.isFinite(measurement.value))
|
|
257571
|
+
return;
|
|
257572
|
+
const value = measurement.value;
|
|
257573
|
+
switch ((measurement.type ?? "dxa").toLowerCase()) {
|
|
257574
|
+
case "dxa":
|
|
257575
|
+
return value / TWIPS_PER_PX$1;
|
|
257576
|
+
case "pct":
|
|
257577
|
+
return Math.round(percentageBasis * (value / OOXML_PCT_DIVISOR));
|
|
257578
|
+
case "px":
|
|
257579
|
+
case "pixel":
|
|
257580
|
+
return value;
|
|
257581
|
+
case "auto":
|
|
257582
|
+
case "nil":
|
|
257583
|
+
return;
|
|
257584
|
+
default:
|
|
257585
|
+
return value;
|
|
257586
|
+
}
|
|
257587
|
+
}
|
|
257588
|
+
function sanitizeCount(value) {
|
|
257589
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
257590
|
+
return 0;
|
|
257591
|
+
return Math.max(0, Math.floor(value));
|
|
257592
|
+
}
|
|
257593
|
+
function sanitizePositiveNumber(value) {
|
|
257594
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0)
|
|
257595
|
+
return 1;
|
|
257596
|
+
return value;
|
|
257597
|
+
}
|
|
257598
|
+
function sanitizeNonNegativeNumber(value) {
|
|
257599
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
|
|
257600
|
+
return;
|
|
257601
|
+
return value;
|
|
257602
|
+
}
|
|
257603
|
+
function sumWidths(widths) {
|
|
257604
|
+
return widths.reduce((sum, width) => sum + Math.max(0, width), 0);
|
|
257605
|
+
}
|
|
257606
|
+
function approximatelyEqual(left$1, right$1) {
|
|
257607
|
+
return Math.abs(left$1 - right$1) <= 0.01;
|
|
257608
|
+
}
|
|
257609
|
+
function isSlightlyUnderPreferredTableWidth(totalColumnWidth, preferredTableWidth) {
|
|
257610
|
+
if (totalColumnWidth <= 0 || totalColumnWidth >= preferredTableWidth)
|
|
257611
|
+
return false;
|
|
257612
|
+
return preferredTableWidth - totalColumnWidth <= preferredTableWidth * 0.05;
|
|
257613
|
+
}
|
|
257614
|
+
function buildTableCellContentMetricsCacheKey(cell2, options) {
|
|
257615
|
+
return stableSerialize({
|
|
257616
|
+
maxWidth: Math.max(1, Math.round(options.maxWidth)),
|
|
257617
|
+
layoutEpoch: options.layoutEpoch ?? null,
|
|
257618
|
+
attrs: cell2.attrs ?? null,
|
|
257619
|
+
paragraph: cell2.paragraph ?? null,
|
|
257620
|
+
blocks: cell2.blocks ?? null
|
|
257621
|
+
});
|
|
257622
|
+
}
|
|
257623
|
+
function buildAutoFitTableResultCacheKey(table2, options) {
|
|
257624
|
+
return stableSerialize({
|
|
257625
|
+
id: table2.id,
|
|
257626
|
+
attrs: table2.attrs ?? null,
|
|
257627
|
+
columnWidths: table2.columnWidths ?? null,
|
|
257628
|
+
rowCount: table2.rows.length,
|
|
257629
|
+
maxWidth: Math.max(1, Math.round(options.maxWidth)),
|
|
257630
|
+
layoutEpoch: options.layoutEpoch ?? null,
|
|
257631
|
+
cellMetricKeys: options.cellMetricKeys,
|
|
257632
|
+
workingGrid: {
|
|
257633
|
+
layoutMode: options.workingInput.layoutMode,
|
|
257634
|
+
gridColumnCount: options.workingInput.gridColumnCount,
|
|
257635
|
+
preserveAuthoredGrid: options.workingInput.preserveAuthoredGrid === true,
|
|
257636
|
+
preserveAutoGrid: options.workingInput.preserveAutoGrid === true,
|
|
257637
|
+
preserveExplicitAutoGrid: options.workingInput.preserveExplicitAutoGrid === true,
|
|
257638
|
+
preferredTableWidth: options.workingInput.preferredTableWidth ?? null,
|
|
257639
|
+
preferredColumnWidths: options.workingInput.preferredColumnWidths,
|
|
257640
|
+
rows: options.workingInput.rows.map((row2) => ({
|
|
257641
|
+
logicalColumnCount: row2.logicalColumnCount,
|
|
257642
|
+
skippedColumns: (row2.skippedColumns ?? []).map((column) => ({
|
|
257643
|
+
columnIndex: column.columnIndex,
|
|
257644
|
+
preferredWidth: column.preferredWidth ?? null
|
|
257645
|
+
})),
|
|
257646
|
+
cells: row2.cells.map((cell2) => ({
|
|
257647
|
+
startColumn: cell2.startColumn,
|
|
257648
|
+
span: cell2.span ?? 1,
|
|
257649
|
+
preferredWidth: cell2.preferredWidth ?? null
|
|
257650
|
+
}))
|
|
257651
|
+
}))
|
|
257652
|
+
},
|
|
257653
|
+
fixedLayout: {
|
|
257654
|
+
columnWidths: options.fixedLayout.columnWidths,
|
|
257655
|
+
totalWidth: options.fixedLayout.totalWidth,
|
|
257656
|
+
gridColumnCount: options.fixedLayout.gridColumnCount,
|
|
257657
|
+
preferredTableWidth: options.fixedLayout.preferredTableWidth ?? null
|
|
257658
|
+
}
|
|
257659
|
+
});
|
|
257660
|
+
}
|
|
257661
|
+
function getCachedAutoFitTableResult(cacheKey) {
|
|
257662
|
+
return autoFitTableResultCache.get(cacheKey);
|
|
257663
|
+
}
|
|
257664
|
+
function setCachedAutoFitTableResult(cacheKey, result) {
|
|
257665
|
+
autoFitTableResultCache.set(cacheKey, result);
|
|
257666
|
+
}
|
|
257667
|
+
async function measureTableCellContentMetrics(cell2, options) {
|
|
257668
|
+
const cacheKey = buildTableCellContentMetricsCacheKey(cell2, options);
|
|
257669
|
+
const cached2 = tableCellMetricsCache.get(cacheKey);
|
|
257670
|
+
if (cached2)
|
|
257671
|
+
return cached2;
|
|
257672
|
+
const horizontalInsets = getHorizontalCellInsets(cell2);
|
|
257673
|
+
const contentBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
|
|
257674
|
+
if (contentBlocks.length === 0) {
|
|
257675
|
+
const emptyMetrics = {
|
|
257676
|
+
minWidthPx: horizontalInsets,
|
|
257677
|
+
maxWidthPx: horizontalInsets
|
|
257678
|
+
};
|
|
257679
|
+
tableCellMetricsCache.set(cacheKey, emptyMetrics);
|
|
257680
|
+
return emptyMetrics;
|
|
257681
|
+
}
|
|
257682
|
+
let minContentWidthPx = 0;
|
|
257683
|
+
let maxContentWidthPx = 0;
|
|
257684
|
+
for (const block of contentBlocks) {
|
|
257685
|
+
const metrics = await measureIntrinsicBlockWidthMetrics(block, options);
|
|
257686
|
+
minContentWidthPx = Math.max(minContentWidthPx, metrics.minWidthPx);
|
|
257687
|
+
maxContentWidthPx = Math.max(maxContentWidthPx, metrics.maxWidthPx);
|
|
257688
|
+
}
|
|
257689
|
+
const result = {
|
|
257690
|
+
minWidthPx: minContentWidthPx + horizontalInsets,
|
|
257691
|
+
maxWidthPx: maxContentWidthPx + horizontalInsets
|
|
257692
|
+
};
|
|
257693
|
+
tableCellMetricsCache.set(cacheKey, result);
|
|
257694
|
+
return result;
|
|
257695
|
+
}
|
|
257696
|
+
async function measureTableAutoFitContentMetrics(table2, workingInput, fixedLayout, measureBlock$1) {
|
|
257697
|
+
const tableMeasurementBasis = Math.max(1, fixedLayout.totalWidth);
|
|
257698
|
+
const cellMetricKeys = [];
|
|
257699
|
+
const rowMetrics = await Promise.all(table2.rows.map(async (row2, rowIndex) => {
|
|
257700
|
+
const normalizedRow = workingInput.rows[rowIndex] ?? {};
|
|
257701
|
+
return {
|
|
257702
|
+
rowIndex,
|
|
257703
|
+
cells: await Promise.all(row2.cells.map(async (cell2, cellIndex) => {
|
|
257704
|
+
const normalizedCell = normalizedRow.cells?.[cellIndex];
|
|
257705
|
+
const span = normalizedCell?.span ?? cell2.colSpan ?? 1;
|
|
257706
|
+
const measurementMaxWidth = resolveAutoFitCellMeasurementMaxWidth(cell2, normalizedCell, span, fixedLayout, tableMeasurementBasis, workingInput.gridColumnCount);
|
|
257707
|
+
cellMetricKeys.push(buildTableCellContentMetricsCacheKey(cell2, { maxWidth: measurementMaxWidth }));
|
|
257708
|
+
const metrics = await measureTableCellContentMetrics(cell2, {
|
|
257709
|
+
maxWidth: measurementMaxWidth,
|
|
257710
|
+
measureBlock: measureBlock$1
|
|
257711
|
+
});
|
|
257712
|
+
return {
|
|
257713
|
+
cellIndex,
|
|
257714
|
+
span,
|
|
257715
|
+
preferredWidth: normalizedCell?.preferredWidth,
|
|
257716
|
+
minContentWidth: metrics.minWidthPx,
|
|
257717
|
+
maxContentWidth: metrics.maxWidthPx
|
|
257718
|
+
};
|
|
257719
|
+
}))
|
|
257720
|
+
};
|
|
257721
|
+
}));
|
|
257722
|
+
return {
|
|
257723
|
+
rowMetrics,
|
|
257724
|
+
rows: rowMetrics.map((rowMetrics$1, rowIndex) => {
|
|
257725
|
+
const normalizedRow = workingInput.rows[rowIndex] ?? {};
|
|
257726
|
+
return {
|
|
257727
|
+
skippedBefore: normalizedRow.skippedBefore ?? [],
|
|
257728
|
+
cells: rowMetrics$1.cells.map((cellMetrics) => ({
|
|
257729
|
+
span: cellMetrics.span,
|
|
257730
|
+
preferredWidth: cellMetrics.preferredWidth,
|
|
257731
|
+
minContentWidth: cellMetrics.minContentWidth,
|
|
257732
|
+
maxContentWidth: cellMetrics.maxContentWidth
|
|
257733
|
+
})),
|
|
257734
|
+
skippedAfter: normalizedRow.skippedAfter ?? []
|
|
257735
|
+
};
|
|
257736
|
+
}),
|
|
257737
|
+
cellMetricKeys
|
|
257738
|
+
};
|
|
257739
|
+
}
|
|
257740
|
+
async function measureIntrinsicBlockWidthMetrics(block, options) {
|
|
257741
|
+
if (block.kind === "paragraph")
|
|
257742
|
+
return measureParagraphIntrinsicWidthMetrics(block, options.measureBlock);
|
|
257743
|
+
if (block.kind === "table")
|
|
257744
|
+
return measureNestedTableIntrinsicWidthMetrics(block, options);
|
|
257745
|
+
const intrinsicWidth = getIntrinsicAtomicBlockWidth(block);
|
|
257746
|
+
return {
|
|
257747
|
+
minWidthPx: intrinsicWidth,
|
|
257748
|
+
maxWidthPx: intrinsicWidth
|
|
257749
|
+
};
|
|
257750
|
+
}
|
|
257751
|
+
async function measureParagraphIntrinsicWidthMetrics(paragraph2, measureBlock$1) {
|
|
257752
|
+
const maxLineWidth = (await measureBlock$1(paragraph2, {
|
|
257753
|
+
maxWidth: NO_WRAP_MAX_WIDTH,
|
|
257754
|
+
maxHeight: Infinity
|
|
257755
|
+
})).lines.reduce((widest, line) => Math.max(widest, line.width), 0);
|
|
257756
|
+
return {
|
|
257757
|
+
minWidthPx: measureParagraphMinTokenWidth(paragraph2),
|
|
257758
|
+
maxWidthPx: maxLineWidth
|
|
257759
|
+
};
|
|
257760
|
+
}
|
|
257761
|
+
async function measureNestedTableIntrinsicWidthMetrics(table2, options) {
|
|
257762
|
+
const nestedMeasure = await options.measureBlock(table2, {
|
|
257763
|
+
maxWidth: Math.max(1, options.maxWidth),
|
|
257764
|
+
maxHeight: Infinity
|
|
257765
|
+
});
|
|
257766
|
+
if (nestedMeasure.kind !== "table")
|
|
257767
|
+
return {
|
|
257768
|
+
minWidthPx: 0,
|
|
257769
|
+
maxWidthPx: 0
|
|
257770
|
+
};
|
|
257771
|
+
return {
|
|
257772
|
+
minWidthPx: nestedMeasure.totalWidth,
|
|
257773
|
+
maxWidthPx: nestedMeasure.totalWidth
|
|
257774
|
+
};
|
|
257775
|
+
}
|
|
257776
|
+
function measureParagraphMinTokenWidth(paragraph2) {
|
|
257777
|
+
let widestToken = 0;
|
|
257778
|
+
let currentTokenWidth = 0;
|
|
257779
|
+
const flushToken = () => {
|
|
257780
|
+
widestToken = Math.max(widestToken, currentTokenWidth);
|
|
257781
|
+
currentTokenWidth = 0;
|
|
257782
|
+
};
|
|
257783
|
+
for (const run2 of paragraph2.runs) {
|
|
257784
|
+
if (isExplicitLineBreakRun(run2)) {
|
|
257785
|
+
flushToken();
|
|
257786
|
+
continue;
|
|
257787
|
+
}
|
|
257788
|
+
if (isTextLikeRun(run2)) {
|
|
257789
|
+
accumulateTextRunMinTokenWidth(run2, (width) => {
|
|
257790
|
+
currentTokenWidth += width;
|
|
257791
|
+
}, flushToken);
|
|
257792
|
+
continue;
|
|
257793
|
+
}
|
|
257794
|
+
flushToken();
|
|
257795
|
+
if (run2.kind === "image") {
|
|
257796
|
+
widestToken = Math.max(widestToken, run2.width ?? 0);
|
|
257797
|
+
continue;
|
|
257798
|
+
}
|
|
257799
|
+
if (run2.kind === "fieldAnnotation") {
|
|
257800
|
+
widestToken = Math.max(widestToken, measureFieldAnnotationWidth(run2));
|
|
257801
|
+
continue;
|
|
257802
|
+
}
|
|
257803
|
+
if (run2.kind === "math")
|
|
257804
|
+
widestToken = Math.max(widestToken, run2.width ?? 0);
|
|
257805
|
+
}
|
|
257806
|
+
flushToken();
|
|
257807
|
+
return widestToken;
|
|
257808
|
+
}
|
|
257809
|
+
function accumulateTextRunMinTokenWidth(run2, appendTokenPiece, flushToken) {
|
|
257810
|
+
const font = buildFontString$1(run2);
|
|
257811
|
+
let cursor = 0;
|
|
257812
|
+
for (const boundary of run2.text.matchAll(TOKEN_BOUNDARY_PATTERN)) {
|
|
257813
|
+
const boundaryStart = boundary.index ?? cursor;
|
|
257814
|
+
if (boundaryStart > cursor)
|
|
257815
|
+
appendTokenPiece(measureTextRunTokenSlice(run2, cursor, boundaryStart, font));
|
|
257816
|
+
flushToken();
|
|
257817
|
+
cursor = boundaryStart + boundary[0].length;
|
|
257818
|
+
}
|
|
257819
|
+
if (cursor < run2.text.length)
|
|
257820
|
+
appendTokenPiece(measureTextRunTokenSlice(run2, cursor, run2.text.length, font));
|
|
257821
|
+
}
|
|
257822
|
+
function measureTextRunTokenSlice(run2, start$1, end$1, font) {
|
|
257823
|
+
return getMeasuredTextWidth(applyTextTransform$1(run2.text.slice(start$1, end$1), run2, start$1), font, getLetterSpacing(run2), getCanvasContext$1());
|
|
257824
|
+
}
|
|
257825
|
+
function getIntrinsicAtomicBlockWidth(block) {
|
|
257826
|
+
if (block.kind === "image")
|
|
257827
|
+
return block.width ?? 0;
|
|
257828
|
+
if (block.drawingKind === "image")
|
|
257829
|
+
return block.width ?? 0;
|
|
257830
|
+
if (block.drawingKind === "shapeGroup")
|
|
257831
|
+
return block.size?.width ?? block.geometry.width;
|
|
257832
|
+
return block.geometry.width;
|
|
257833
|
+
}
|
|
257834
|
+
function resolveAutoFitCellMeasurementMaxWidth(cell2, normalizedCell, span, fixedLayout, tableWidthBasis, gridColumnCount) {
|
|
257835
|
+
const outerWidth = resolveFixedPassCellOuterWidth(normalizedCell, span, fixedLayout) ?? normalizedCell?.preferredWidth ?? Math.max(1, tableWidthBasis * (Math.max(1, span) / Math.max(1, gridColumnCount || span || 1)));
|
|
257836
|
+
const padding = cell2.attrs?.padding ?? DEFAULT_CELL_PADDING$1;
|
|
257837
|
+
const leftPadding = padding.left ?? DEFAULT_CELL_PADDING$1.left;
|
|
257838
|
+
const rightPadding = padding.right ?? DEFAULT_CELL_PADDING$1.right;
|
|
257839
|
+
const leftBorder = getCellBorderWidthPx(cell2.attrs?.borders?.left);
|
|
257840
|
+
const rightBorder = getCellBorderWidthPx(cell2.attrs?.borders?.right);
|
|
257841
|
+
return Math.max(1, outerWidth - leftPadding - rightPadding - leftBorder - rightBorder);
|
|
257842
|
+
}
|
|
257843
|
+
function resolveFixedPassCellOuterWidth(normalizedCell, fallbackSpan, fixedLayout) {
|
|
257844
|
+
if (normalizedCell?.startColumn == null)
|
|
257845
|
+
return;
|
|
257846
|
+
const span = Math.max(1, normalizedCell.span ?? fallbackSpan);
|
|
257847
|
+
let width = 0;
|
|
257848
|
+
for (let offset$1 = 0;offset$1 < span; offset$1++)
|
|
257849
|
+
width += fixedLayout.columnWidths[normalizedCell.startColumn + offset$1] ?? 0;
|
|
257850
|
+
return width > 0 ? width : undefined;
|
|
257851
|
+
}
|
|
257852
|
+
function getHorizontalCellInsets(cell2) {
|
|
257853
|
+
const padding = cell2.attrs?.padding ?? DEFAULT_CELL_PADDING$1;
|
|
257854
|
+
const leftPadding = padding.left ?? DEFAULT_CELL_PADDING$1.left;
|
|
257855
|
+
const rightPadding = padding.right ?? DEFAULT_CELL_PADDING$1.right;
|
|
257856
|
+
const leftBorder = getCellBorderWidthPx(cell2.attrs?.borders?.left);
|
|
257857
|
+
const rightBorder = getCellBorderWidthPx(cell2.attrs?.borders?.right);
|
|
257858
|
+
return leftPadding + rightPadding + leftBorder + rightBorder;
|
|
257859
|
+
}
|
|
257860
|
+
function getCellBorderWidthPx(border) {
|
|
257861
|
+
if (!border || border.style === "none")
|
|
257862
|
+
return 0;
|
|
257863
|
+
const width = typeof border.width === "number" ? border.width : 0;
|
|
257864
|
+
if (border.style === "thick")
|
|
257865
|
+
return Math.max(width * 2, 3);
|
|
257866
|
+
return Math.max(0, width);
|
|
257867
|
+
}
|
|
257868
|
+
function getCanvasContext$1() {
|
|
257869
|
+
if (!canvasContext$1) {
|
|
257870
|
+
canvasContext$1 = document.createElement("canvas").getContext("2d");
|
|
257871
|
+
if (!canvasContext$1)
|
|
257872
|
+
throw new Error("Failed to create canvas context for AutoFit cell measurement.");
|
|
257873
|
+
}
|
|
257874
|
+
return canvasContext$1;
|
|
257875
|
+
}
|
|
257876
|
+
function buildFontString$1(run2) {
|
|
257877
|
+
const parts = [];
|
|
257878
|
+
if (run2.italic)
|
|
257879
|
+
parts.push("italic");
|
|
257880
|
+
if (run2.bold)
|
|
257881
|
+
parts.push("bold");
|
|
257882
|
+
parts.push(`${normalizeFontSize$1(run2.fontSize)}px`);
|
|
257883
|
+
parts.push(toCssFontFamily(normalizeFontFamily$1(run2.fontFamily)) ?? normalizeFontFamily$1(run2.fontFamily));
|
|
257884
|
+
return parts.join(" ");
|
|
257885
|
+
}
|
|
257886
|
+
function applyTextTransform$1(text5, run2, startOffset = 0) {
|
|
257887
|
+
const transform2 = run2.textTransform;
|
|
257888
|
+
if (!text5 || !transform2 || transform2 === "none")
|
|
257889
|
+
return text5;
|
|
257890
|
+
if (transform2 === "uppercase")
|
|
257891
|
+
return text5.toUpperCase();
|
|
257892
|
+
if (transform2 === "lowercase")
|
|
257893
|
+
return text5.toLowerCase();
|
|
257894
|
+
if (transform2 === "capitalize")
|
|
257895
|
+
return capitalizeText$1(text5, run2.text ?? text5, startOffset);
|
|
257896
|
+
return text5;
|
|
257897
|
+
}
|
|
257898
|
+
function capitalizeText$1(text5, fullText, startOffset) {
|
|
257899
|
+
let result = "";
|
|
257900
|
+
for (let index2 = 0;index2 < text5.length; index2++) {
|
|
257901
|
+
const absoluteIndex = startOffset + index2;
|
|
257902
|
+
const currentChar = text5[index2];
|
|
257903
|
+
const previousChar = absoluteIndex > 0 ? fullText[absoluteIndex - 1] : "";
|
|
257904
|
+
result += isWordCharacter(currentChar) && !isWordCharacter(previousChar) ? currentChar.toUpperCase() : currentChar;
|
|
257905
|
+
}
|
|
257906
|
+
return result;
|
|
257907
|
+
}
|
|
257908
|
+
function measureFieldAnnotationWidth(run2) {
|
|
257909
|
+
const fontSize = typeof run2.fontSize === "number" ? run2.fontSize : typeof run2.fontSize === "string" ? parseFloat(run2.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE$1 : DEFAULT_FIELD_ANNOTATION_FONT_SIZE$1;
|
|
257910
|
+
const font = buildFontString$1({
|
|
257911
|
+
fontFamily: normalizeFontFamily$1(run2.fontFamily ?? "Arial"),
|
|
257912
|
+
fontSize,
|
|
257913
|
+
bold: run2.bold,
|
|
257914
|
+
italic: run2.italic
|
|
257915
|
+
});
|
|
257916
|
+
return getMeasuredTextWidth(applyTextTransform$1(run2.displayLabel || "", { text: run2.displayLabel || "" }), font, 0, getCanvasContext$1()) + (run2.highlighted === false ? 0 : FIELD_ANNOTATION_PILL_PADDING$1);
|
|
257917
|
+
}
|
|
257918
|
+
function isExplicitLineBreakRun(run2) {
|
|
257919
|
+
return run2.kind === "lineBreak" || run2.kind === "break" && run2.breakType === "line";
|
|
257920
|
+
}
|
|
257921
|
+
function isTextLikeRun(run2) {
|
|
257922
|
+
return "text" in run2 && typeof run2.text === "string";
|
|
257923
|
+
}
|
|
257924
|
+
function getLetterSpacing(run2) {
|
|
257925
|
+
return "letterSpacing" in run2 && typeof run2.letterSpacing === "number" ? run2.letterSpacing : 0;
|
|
257926
|
+
}
|
|
257927
|
+
function normalizeFontSize$1(value) {
|
|
257928
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0)
|
|
257929
|
+
return value;
|
|
257930
|
+
if (typeof value === "string") {
|
|
257931
|
+
const parsed = parseFloat(value);
|
|
257932
|
+
if (Number.isFinite(parsed) && parsed > 0)
|
|
257933
|
+
return parsed;
|
|
257934
|
+
}
|
|
257935
|
+
return 12;
|
|
257936
|
+
}
|
|
257937
|
+
function normalizeFontFamily$1(value) {
|
|
257938
|
+
return typeof value === "string" && value.trim().length > 0 ? value : "Arial";
|
|
257939
|
+
}
|
|
257940
|
+
function stableSerialize(value) {
|
|
257941
|
+
if (value === null || typeof value !== "object")
|
|
257942
|
+
return JSON.stringify(value);
|
|
257943
|
+
if (Array.isArray(value))
|
|
257944
|
+
return `[${value.map((item) => stableSerialize(item)).join(",")}]`;
|
|
257945
|
+
return `{${Object.entries(value).sort(([left$1], [right$1]) => left$1.localeCompare(right$1)).map(([key2, entry]) => `${JSON.stringify(key2)}:${stableSerialize(entry)}`).join(",")}}`;
|
|
257946
|
+
}
|
|
257947
|
+
function isWordCharacter(value) {
|
|
257948
|
+
return /[A-Za-z0-9]/.test(value);
|
|
257949
|
+
}
|
|
256401
257950
|
function getTableBorderWidthPx(value) {
|
|
256402
257951
|
if (value == null)
|
|
256403
257952
|
return 0;
|
|
@@ -257888,141 +259437,9 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
257888
259437
|
...dropCapMeasure ? { dropCap: dropCapMeasure } : {}
|
|
257889
259438
|
};
|
|
257890
259439
|
}
|
|
257891
|
-
function resolveTableWidth(attrs, maxWidth) {
|
|
257892
|
-
const tableWidthAttr = resolveTableWidthAttr(attrs?.tableWidth);
|
|
257893
|
-
if (!tableWidthAttr)
|
|
257894
|
-
return;
|
|
257895
|
-
if (tableWidthAttr.type === "pct")
|
|
257896
|
-
return Math.round(maxWidth * (tableWidthAttr.width / OOXML_PCT_DIVISOR));
|
|
257897
|
-
else if (tableWidthAttr.type === "px" || tableWidthAttr.type === "pixel" || tableWidthAttr.type === "dxa")
|
|
257898
|
-
return tableWidthAttr.width;
|
|
257899
|
-
}
|
|
257900
259440
|
async function measureTableBlock(block, constraints) {
|
|
257901
|
-
const
|
|
257902
|
-
const
|
|
257903
|
-
let columnWidths;
|
|
257904
|
-
const maxCellCount = Math.max(1, Math.max(...block.rows.map((r$1) => r$1.cells.reduce((sum, cell2) => sum + (cell2.colSpan ?? 1), 0))));
|
|
257905
|
-
const effectiveTargetWidth = resolvedTableWidth != null ? resolvedTableWidth : maxWidth;
|
|
257906
|
-
if (block.columnWidths && block.columnWidths.length > 0) {
|
|
257907
|
-
columnWidths = [...block.columnWidths];
|
|
257908
|
-
const hasExplicitWidth = resolvedTableWidth != null;
|
|
257909
|
-
const hasFixedLayout = block.attrs?.tableLayout === "fixed";
|
|
257910
|
-
if (hasExplicitWidth || hasFixedLayout) {
|
|
257911
|
-
const totalWidth$1 = columnWidths.reduce((a2, b$1) => a2 + b$1, 0);
|
|
257912
|
-
const tableWidthType = block.attrs?.tableWidth?.type;
|
|
257913
|
-
const targetWidth = hasExplicitWidth ? effectiveTargetWidth : totalWidth$1;
|
|
257914
|
-
if ((totalWidth$1 > targetWidth || totalWidth$1 < targetWidth && targetWidth > 0 && (tableWidthType === "pct" || hasExplicitWidth && !hasFixedLayout)) && targetWidth > 0 && totalWidth$1 > 0) {
|
|
257915
|
-
const scale = targetWidth / totalWidth$1;
|
|
257916
|
-
columnWidths = columnWidths.map((w) => Math.max(1, Math.round(w * scale)));
|
|
257917
|
-
const scaledSum = columnWidths.reduce((a2, b$1) => a2 + b$1, 0);
|
|
257918
|
-
if (scaledSum !== targetWidth && columnWidths.length > 0) {
|
|
257919
|
-
const diff = targetWidth - scaledSum;
|
|
257920
|
-
columnWidths[columnWidths.length - 1] = Math.max(1, columnWidths[columnWidths.length - 1] + diff);
|
|
257921
|
-
}
|
|
257922
|
-
}
|
|
257923
|
-
} else if (columnWidths.length < maxCellCount) {
|
|
257924
|
-
const usedWidth = columnWidths.reduce((a2, b$1) => a2 + b$1, 0);
|
|
257925
|
-
const remainingWidth = Math.max(0, effectiveTargetWidth - usedWidth);
|
|
257926
|
-
const missingColumns = maxCellCount - columnWidths.length;
|
|
257927
|
-
const paddingWidth = Math.max(1, Math.floor(remainingWidth / missingColumns));
|
|
257928
|
-
columnWidths.push(...Array.from({ length: missingColumns }, () => paddingWidth));
|
|
257929
|
-
} else if (columnWidths.length > maxCellCount)
|
|
257930
|
-
columnWidths = columnWidths.slice(0, maxCellCount);
|
|
257931
|
-
} else {
|
|
257932
|
-
const columnWidth = Math.max(1, Math.floor(effectiveTargetWidth / maxCellCount));
|
|
257933
|
-
columnWidths = Array.from({ length: maxCellCount }, () => columnWidth);
|
|
257934
|
-
}
|
|
257935
|
-
const isFixedLayout = block.attrs?.tableLayout === "fixed";
|
|
257936
|
-
const gridLooksLikePlaceholder = columnWidths.reduce((a2, b$1) => a2 + b$1, 0) < maxWidth * 0.1;
|
|
257937
|
-
if (!isFixedLayout && gridLooksLikePlaceholder) {
|
|
257938
|
-
const gridColCount = columnWidths.length;
|
|
257939
|
-
const maxContentWidths = new Array(gridColCount).fill(0);
|
|
257940
|
-
const autoFitRowspanTracker = new Array(gridColCount).fill(0);
|
|
257941
|
-
for (const row2 of block.rows) {
|
|
257942
|
-
let colIndex = 0;
|
|
257943
|
-
for (const cell2 of row2.cells) {
|
|
257944
|
-
const colspan = cell2.colSpan ?? 1;
|
|
257945
|
-
const rowspan = cell2.rowSpan ?? 1;
|
|
257946
|
-
while (colIndex < gridColCount && autoFitRowspanTracker[colIndex] > 0) {
|
|
257947
|
-
autoFitRowspanTracker[colIndex]--;
|
|
257948
|
-
colIndex++;
|
|
257949
|
-
}
|
|
257950
|
-
if (colIndex >= gridColCount)
|
|
257951
|
-
break;
|
|
257952
|
-
if (colspan === 1) {
|
|
257953
|
-
const cellPadding = cell2.attrs?.padding ?? DEFAULT_CELL_PADDING;
|
|
257954
|
-
const paddingH = (cellPadding.left ?? 4) + (cellPadding.right ?? 4);
|
|
257955
|
-
const cellBlocks = cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : []);
|
|
257956
|
-
let cellMaxWidth = 0;
|
|
257957
|
-
for (const cellBlock of cellBlocks) {
|
|
257958
|
-
const maxMeasure = await measureBlock(cellBlock, {
|
|
257959
|
-
maxWidth: 99999,
|
|
257960
|
-
maxHeight: Infinity
|
|
257961
|
-
});
|
|
257962
|
-
let blockMaxWidth = 0;
|
|
257963
|
-
if (maxMeasure.kind === "paragraph") {
|
|
257964
|
-
for (const line of maxMeasure.lines)
|
|
257965
|
-
if (line.width > blockMaxWidth)
|
|
257966
|
-
blockMaxWidth = line.width;
|
|
257967
|
-
} else if (maxMeasure.kind === "image" || maxMeasure.kind === "drawing")
|
|
257968
|
-
blockMaxWidth = maxMeasure.width;
|
|
257969
|
-
else if (maxMeasure.kind === "table")
|
|
257970
|
-
blockMaxWidth = maxMeasure.totalWidth;
|
|
257971
|
-
else if (maxMeasure.kind === "list") {
|
|
257972
|
-
for (const item of maxMeasure.items)
|
|
257973
|
-
if (item.paragraph) {
|
|
257974
|
-
const gutterWidth = (item.indentLeft ?? 0) + (item.markerWidth ?? 0);
|
|
257975
|
-
for (const line of item.paragraph.lines) {
|
|
257976
|
-
const lineTotal = gutterWidth + line.width;
|
|
257977
|
-
if (lineTotal > blockMaxWidth)
|
|
257978
|
-
blockMaxWidth = lineTotal;
|
|
257979
|
-
}
|
|
257980
|
-
}
|
|
257981
|
-
}
|
|
257982
|
-
if (blockMaxWidth > cellMaxWidth)
|
|
257983
|
-
cellMaxWidth = blockMaxWidth;
|
|
257984
|
-
}
|
|
257985
|
-
const totalWidth$1 = cellMaxWidth + paddingH;
|
|
257986
|
-
if (totalWidth$1 > maxContentWidths[colIndex])
|
|
257987
|
-
maxContentWidths[colIndex] = totalWidth$1;
|
|
257988
|
-
}
|
|
257989
|
-
if (rowspan > 1)
|
|
257990
|
-
for (let c = 0;c < colspan && colIndex + c < gridColCount; c++)
|
|
257991
|
-
autoFitRowspanTracker[colIndex + c] = rowspan - 1;
|
|
257992
|
-
colIndex += colspan;
|
|
257993
|
-
}
|
|
257994
|
-
for (let col = colIndex;col < gridColCount; col++)
|
|
257995
|
-
if (autoFitRowspanTracker[col] > 0)
|
|
257996
|
-
autoFitRowspanTracker[col]--;
|
|
257997
|
-
}
|
|
257998
|
-
const contentTotal = maxContentWidths.reduce((a2, b$1) => a2 + b$1, 0);
|
|
257999
|
-
if (contentTotal > 0)
|
|
258000
|
-
if (contentTotal <= maxWidth) {
|
|
258001
|
-
for (let i4 = 0;i4 < gridColCount; i4++)
|
|
258002
|
-
if (maxContentWidths[i4] > columnWidths[i4])
|
|
258003
|
-
columnWidths[i4] = maxContentWidths[i4];
|
|
258004
|
-
const expandedTotal = columnWidths.reduce((a2, b$1) => a2 + b$1, 0);
|
|
258005
|
-
if (expandedTotal > maxWidth && gridColCount > 0) {
|
|
258006
|
-
const scale = maxWidth / expandedTotal;
|
|
258007
|
-
for (let i4 = 0;i4 < gridColCount; i4++)
|
|
258008
|
-
columnWidths[i4] = Math.max(1, Math.round(columnWidths[i4] * scale));
|
|
258009
|
-
const scaledSum = columnWidths.reduce((a2, b$1) => a2 + b$1, 0);
|
|
258010
|
-
if (scaledSum !== maxWidth) {
|
|
258011
|
-
const diff = maxWidth - scaledSum;
|
|
258012
|
-
columnWidths[gridColCount - 1] = Math.max(1, columnWidths[gridColCount - 1] + diff);
|
|
258013
|
-
}
|
|
258014
|
-
}
|
|
258015
|
-
} else {
|
|
258016
|
-
const scale = maxWidth / contentTotal;
|
|
258017
|
-
for (let i4 = 0;i4 < gridColCount; i4++)
|
|
258018
|
-
columnWidths[i4] = Math.max(1, Math.round(maxContentWidths[i4] * scale));
|
|
258019
|
-
const scaledSum = columnWidths.reduce((a2, b$1) => a2 + b$1, 0);
|
|
258020
|
-
if (scaledSum !== maxWidth && gridColCount > 0) {
|
|
258021
|
-
const diff = maxWidth - scaledSum;
|
|
258022
|
-
columnWidths[gridColCount - 1] = Math.max(1, columnWidths[gridColCount - 1] + diff);
|
|
258023
|
-
}
|
|
258024
|
-
}
|
|
258025
|
-
}
|
|
259441
|
+
const workingInput = buildAutoFitWorkingGridInput(block, { maxWidth: typeof constraints === "number" ? constraints : constraints.maxWidth });
|
|
259442
|
+
const columnWidths = await resolveRuntimeTableColumnWidths(block, workingInput);
|
|
258026
259443
|
const gridColumnCount = columnWidths.length;
|
|
258027
259444
|
const calculateCellWidth = (startCol, colspan) => {
|
|
258028
259445
|
let width = 0;
|
|
@@ -258036,11 +259453,19 @@ async function measureTableBlock(block, constraints) {
|
|
|
258036
259453
|
const spanConstraints = [];
|
|
258037
259454
|
for (let rowIndex = 0;rowIndex < block.rows.length; rowIndex++) {
|
|
258038
259455
|
const row2 = block.rows[rowIndex];
|
|
259456
|
+
const normalizedRow = workingInput.rows[rowIndex];
|
|
258039
259457
|
const cellMeasures = [];
|
|
258040
259458
|
let gridColIndex = 0;
|
|
258041
|
-
for (
|
|
259459
|
+
for (let cellIndex = 0;cellIndex < row2.cells.length; cellIndex++) {
|
|
259460
|
+
const cell2 = row2.cells[cellIndex];
|
|
258042
259461
|
const colspan = cell2.colSpan ?? 1;
|
|
258043
259462
|
const rowspan = cell2.rowSpan ?? 1;
|
|
259463
|
+
const preferredStartColumn = normalizedRow?.cells?.[cellIndex]?.startColumn ?? gridColIndex;
|
|
259464
|
+
while (gridColIndex < gridColumnCount && gridColIndex < preferredStartColumn) {
|
|
259465
|
+
if (rowspanTracker[gridColIndex] > 0)
|
|
259466
|
+
rowspanTracker[gridColIndex]--;
|
|
259467
|
+
gridColIndex++;
|
|
259468
|
+
}
|
|
258044
259469
|
while (gridColIndex < gridColumnCount && rowspanTracker[gridColIndex] > 0) {
|
|
258045
259470
|
rowspanTracker[gridColIndex]--;
|
|
258046
259471
|
gridColIndex++;
|
|
@@ -258143,18 +259568,48 @@ async function measureTableBlock(block, constraints) {
|
|
|
258143
259568
|
const borderWidthH = tableBorderWidths.left + tableBorderWidths.right;
|
|
258144
259569
|
const borderWidthV = tableBorderWidths.top + tableBorderWidths.bottom;
|
|
258145
259570
|
const includeOuterBordersInTotal = (block.attrs?.borderCollapse ?? (block.attrs?.cellSpacing != null ? "separate" : "collapse")) === "separate";
|
|
258146
|
-
const totalWidth = contentWidth + horizontalGaps + (includeOuterBordersInTotal ? borderWidthH : 0);
|
|
258147
|
-
const totalHeight = contentHeight + verticalGaps + (includeOuterBordersInTotal ? borderWidthV : 0);
|
|
258148
259571
|
return {
|
|
258149
259572
|
kind: "table",
|
|
258150
259573
|
rows,
|
|
258151
259574
|
columnWidths,
|
|
258152
|
-
totalWidth,
|
|
258153
|
-
totalHeight,
|
|
259575
|
+
totalWidth: contentWidth + horizontalGaps + (includeOuterBordersInTotal ? borderWidthH : 0),
|
|
259576
|
+
totalHeight: contentHeight + verticalGaps + (includeOuterBordersInTotal ? borderWidthV : 0),
|
|
258154
259577
|
cellSpacingPx: cellSpacingPx > 0 ? cellSpacingPx : undefined,
|
|
258155
259578
|
tableBorderWidths: borderWidthH > 0 || borderWidthV > 0 ? tableBorderWidths : undefined
|
|
258156
259579
|
};
|
|
258157
259580
|
}
|
|
259581
|
+
async function resolveRuntimeTableColumnWidths(block, workingInput) {
|
|
259582
|
+
const fixedLayout = computeFixedTableColumnWidths(workingInput);
|
|
259583
|
+
if (workingInput.layoutMode === "fixed")
|
|
259584
|
+
return fixedLayout.columnWidths;
|
|
259585
|
+
const { contentMetrics, cellMetricKeys } = await buildMeasuredAutoFitContentMetrics(block, workingInput, fixedLayout);
|
|
259586
|
+
const cacheKey = buildAutoFitTableResultCacheKey(block, {
|
|
259587
|
+
maxWidth: workingInput.maxTableWidth,
|
|
259588
|
+
cellMetricKeys,
|
|
259589
|
+
workingInput,
|
|
259590
|
+
fixedLayout
|
|
259591
|
+
});
|
|
259592
|
+
const cached2 = getCachedAutoFitTableResult(cacheKey);
|
|
259593
|
+
if (cached2)
|
|
259594
|
+
return cached2.columnWidths;
|
|
259595
|
+
const result = computeAutoFitColumnWidths({
|
|
259596
|
+
workingInput,
|
|
259597
|
+
fixedLayout,
|
|
259598
|
+
contentMetrics: { rowMetrics: contentMetrics.rowMetrics }
|
|
259599
|
+
});
|
|
259600
|
+
setCachedAutoFitTableResult(cacheKey, {
|
|
259601
|
+
columnWidths: result.columnWidths,
|
|
259602
|
+
totalWidth: result.totalWidth
|
|
259603
|
+
});
|
|
259604
|
+
return result.columnWidths;
|
|
259605
|
+
}
|
|
259606
|
+
async function buildMeasuredAutoFitContentMetrics(block, workingInput, fixedLayout) {
|
|
259607
|
+
const contentMetrics = await measureTableAutoFitContentMetrics(block, workingInput, fixedLayout, measureBlock);
|
|
259608
|
+
return {
|
|
259609
|
+
contentMetrics,
|
|
259610
|
+
cellMetricKeys: contentMetrics.cellMetricKeys
|
|
259611
|
+
};
|
|
259612
|
+
}
|
|
258158
259613
|
async function measureImageBlock(block, constraints) {
|
|
258159
259614
|
const intrinsic = getIntrinsicImageSize(block, constraints.maxWidth);
|
|
258160
259615
|
const isBlockBehindDoc = block.anchor?.behindDoc;
|
|
@@ -259007,7 +260462,7 @@ var Node$13 = class Node$14 {
|
|
|
259007
260462
|
"iPhone",
|
|
259008
260463
|
"iPod"
|
|
259009
260464
|
].includes(navigator.platform);
|
|
259010
|
-
}, OOXML_PCT_DIVISOR = 5000, TWIPS_PER_PX$
|
|
260465
|
+
}, OOXML_PCT_DIVISOR = 5000, TWIPS_PER_PX$3 = 15, isPlainObject$7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), OOXML_Z_INDEX_BASE = 251658240, SPACE_CHARS, isAtomicRunKind = (kind) => kind === "image" || kind === "lineBreak" || kind === "break" || kind === "tab" || kind === "fieldAnnotation", isImageLikeRun = (run2) => {
|
|
259011
260466
|
if (!run2 || typeof run2 !== "object")
|
|
259012
260467
|
return false;
|
|
259013
260468
|
return typeof run2.src === "string";
|
|
@@ -261274,7 +262729,7 @@ var Node$13 = class Node$14 {
|
|
|
261274
262729
|
const transaction = view.state.tr.setSelection(selection);
|
|
261275
262730
|
view.dispatch(transaction);
|
|
261276
262731
|
}
|
|
261277
|
-
}, StructuredContentInlineView, STRUCTURED_CONTENT_LOCK_KEY, structuredContentClass = "sd-structured-content", structuredContentInnerClass = "sd-structured-content__content", StructuredContent, StructuredContentBlockView, structuredContentBlockClass = "sd-structured-content-block", structuredContentBlockInnerClass = "sd-structured-content-block__content", StructuredContentBlock, structuredContentHelpers_exports, STRUCTURED_CONTENT_NAMES, findFirstTextNode$1 = (node2) => {
|
|
262732
|
+
}, StructuredContentInlineView, STRUCTURED_CONTENT_LOCK_KEY, INLINE_LEAF_TEXT = "", structuredContentClass = "sd-structured-content", structuredContentInnerClass = "sd-structured-content__content", StructuredContent, StructuredContentBlockView, structuredContentBlockClass = "sd-structured-content-block", structuredContentBlockInnerClass = "sd-structured-content-block__content", StructuredContentBlock, structuredContentHelpers_exports, STRUCTURED_CONTENT_NAMES, findFirstTextNode$1 = (node2) => {
|
|
261278
262733
|
let firstTextNode = null;
|
|
261279
262734
|
node2.descendants((child) => {
|
|
261280
262735
|
if (child.isText) {
|
|
@@ -274658,6 +276113,8 @@ var Node$13 = class Node$14 {
|
|
|
274658
276113
|
border: 1px solid transparent;
|
|
274659
276114
|
position: relative;
|
|
274660
276115
|
display: inline;
|
|
276116
|
+
font-size: initial;
|
|
276117
|
+
line-height: normal;
|
|
274661
276118
|
z-index: 10;
|
|
274662
276119
|
}
|
|
274663
276120
|
|
|
@@ -278578,9 +280035,17 @@ menclose::after {
|
|
|
278578
280035
|
inlineBorders = normalizeTableBorders(tableProps.borders);
|
|
278579
280036
|
if (typeof tableProps.justification === "string")
|
|
278580
280037
|
hydration.justification = tableProps.justification;
|
|
280038
|
+
const tableIndent = normalizeTableIndent(tableProps.tableIndent);
|
|
280039
|
+
if (tableIndent)
|
|
280040
|
+
hydration.tableIndent = tableIndent;
|
|
280041
|
+
if (typeof tableProps.tableLayout === "string")
|
|
280042
|
+
hydration.tableLayout = tableProps.tableLayout;
|
|
278581
280043
|
const tableWidth = normalizeTableWidth(tableProps.tableWidth);
|
|
278582
280044
|
if (tableWidth)
|
|
278583
280045
|
hydration.tableWidth = tableWidth;
|
|
280046
|
+
const tableCellSpacing = normalizeTableSpacing(tableProps.tableCellSpacing);
|
|
280047
|
+
if (tableCellSpacing)
|
|
280048
|
+
hydration.tableCellSpacing = tableCellSpacing;
|
|
278584
280049
|
}
|
|
278585
280050
|
const styleId = effectiveStyleId === null ? undefined : effectiveStyleId ?? (typeof tableNode.attrs?.tableStyleId === "string" ? tableNode.attrs.tableStyleId : undefined);
|
|
278586
280051
|
if (styleId && context?.translatedLinkedStyles) {
|
|
@@ -278607,8 +280072,18 @@ menclose::after {
|
|
|
278607
280072
|
hydration.cellPadding = inlinePadding;
|
|
278608
280073
|
if (!hydration.justification && resolved.justification)
|
|
278609
280074
|
hydration.justification = resolved.justification;
|
|
278610
|
-
if (resolved.
|
|
278611
|
-
|
|
280075
|
+
if (!hydration.tableIndent && resolved.tableIndent) {
|
|
280076
|
+
const tableIndent = normalizeTableIndent(resolved.tableIndent);
|
|
280077
|
+
if (tableIndent)
|
|
280078
|
+
hydration.tableIndent = tableIndent;
|
|
280079
|
+
}
|
|
280080
|
+
if (!hydration.tableLayout && resolved.tableLayout)
|
|
280081
|
+
hydration.tableLayout = resolved.tableLayout;
|
|
280082
|
+
if (!hydration.tableCellSpacing && resolved.tableCellSpacing) {
|
|
280083
|
+
const tableCellSpacing = normalizeTableSpacing(resolved.tableCellSpacing);
|
|
280084
|
+
if (tableCellSpacing)
|
|
280085
|
+
hydration.tableCellSpacing = tableCellSpacing;
|
|
280086
|
+
}
|
|
278612
280087
|
if (!hydration.tableWidth && resolved.tableWidth) {
|
|
278613
280088
|
const tableWidth = normalizeTableWidth(resolved.tableWidth);
|
|
278614
280089
|
if (tableWidth)
|
|
@@ -278706,7 +280181,41 @@ menclose::after {
|
|
|
278706
280181
|
width: raw,
|
|
278707
280182
|
type: measurement.type
|
|
278708
280183
|
};
|
|
278709
|
-
},
|
|
280184
|
+
}, normalizeTableIndent = (value) => {
|
|
280185
|
+
if (!value || typeof value !== "object")
|
|
280186
|
+
return;
|
|
280187
|
+
const measurement = value;
|
|
280188
|
+
const raw = typeof measurement.width === "number" ? measurement.width : measurement.value;
|
|
280189
|
+
if (typeof raw !== "number")
|
|
280190
|
+
return;
|
|
280191
|
+
if (!measurement.type || measurement.type === "px" || measurement.type === "pixel")
|
|
280192
|
+
return {
|
|
280193
|
+
width: raw,
|
|
280194
|
+
type: measurement.type ?? "px"
|
|
280195
|
+
};
|
|
280196
|
+
if (measurement.type === "dxa")
|
|
280197
|
+
return {
|
|
280198
|
+
width: twipsToPx$2(raw),
|
|
280199
|
+
type: "dxa"
|
|
280200
|
+
};
|
|
280201
|
+
return {
|
|
280202
|
+
width: raw,
|
|
280203
|
+
type: measurement.type
|
|
280204
|
+
};
|
|
280205
|
+
}, normalizeTableSpacing = (value) => {
|
|
280206
|
+
if (!value || typeof value !== "object")
|
|
280207
|
+
return;
|
|
280208
|
+
const measurement = value;
|
|
280209
|
+
if (typeof measurement.value !== "number")
|
|
280210
|
+
return;
|
|
280211
|
+
return {
|
|
280212
|
+
value: measurement.value,
|
|
280213
|
+
type: measurement.type ?? "px"
|
|
280214
|
+
};
|
|
280215
|
+
}, isTableRowNode = (node2) => node2.type === "tableRow" || node2.type === "table_row", isTableCellNode = (node2) => node2.type === "tableCell" || node2.type === "table_cell" || node2.type === "tableHeader" || node2.type === "table_header", isTableSkipPlaceholderCell = (node2) => {
|
|
280216
|
+
const placeholder = node2.attrs?.__placeholder;
|
|
280217
|
+
return placeholder === "gridBefore" || placeholder === "gridAfter";
|
|
280218
|
+
}, convertResolvedCellBorder = (value) => {
|
|
278710
280219
|
if (!value || typeof value !== "object")
|
|
278711
280220
|
return;
|
|
278712
280221
|
const border = value;
|
|
@@ -278974,6 +280483,8 @@ menclose::after {
|
|
|
278974
280483
|
const cells = [];
|
|
278975
280484
|
const rowCnfStyle = rowNode.attrs?.tableRowProperties?.cnfStyle;
|
|
278976
280485
|
rowNode.content.forEach((cellNode, cellIndex) => {
|
|
280486
|
+
if (isTableCellNode(cellNode) && isTableSkipPlaceholderCell(cellNode))
|
|
280487
|
+
return;
|
|
278977
280488
|
const parsedCell = parseTableCell({
|
|
278978
280489
|
cellNode,
|
|
278979
280490
|
rowIndex,
|
|
@@ -279324,7 +280835,7 @@ menclose::after {
|
|
|
279324
280835
|
return true;
|
|
279325
280836
|
}
|
|
279326
280837
|
return false;
|
|
279327
|
-
}, capitalizeText$
|
|
280838
|
+
}, capitalizeText$3 = (text5) => {
|
|
279328
280839
|
if (!text5)
|
|
279329
280840
|
return text5;
|
|
279330
280841
|
let result = "";
|
|
@@ -279334,7 +280845,7 @@ menclose::after {
|
|
|
279334
280845
|
result += isWordChar$3(ch) && !isWordChar$3(prevChar) ? ch.toUpperCase() : ch;
|
|
279335
280846
|
}
|
|
279336
280847
|
return result;
|
|
279337
|
-
}, applyTextTransform$
|
|
280848
|
+
}, applyTextTransform$3 = (text5, transform2) => {
|
|
279338
280849
|
if (!text5 || !transform2 || transform2 === "none")
|
|
279339
280850
|
return text5;
|
|
279340
280851
|
if (transform2 === "uppercase")
|
|
@@ -279342,7 +280853,7 @@ menclose::after {
|
|
|
279342
280853
|
if (transform2 === "lowercase")
|
|
279343
280854
|
return text5.toLowerCase();
|
|
279344
280855
|
if (transform2 === "capitalize")
|
|
279345
|
-
return capitalizeText$
|
|
280856
|
+
return capitalizeText$3(text5);
|
|
279346
280857
|
return text5;
|
|
279347
280858
|
}, countSpaces = (text5) => {
|
|
279348
280859
|
let spaces = 0;
|
|
@@ -280130,7 +281641,7 @@ menclose::after {
|
|
|
280130
281641
|
return false;
|
|
280131
281642
|
const code7 = char.charCodeAt(0);
|
|
280132
281643
|
return code7 >= 48 && code7 <= 57 || code7 >= 65 && code7 <= 90 || code7 >= 97 && code7 <= 122 || char === "'";
|
|
280133
|
-
}, capitalizeText$
|
|
281644
|
+
}, capitalizeText$2 = (text5, fullText, startOffset) => {
|
|
280134
281645
|
if (!text5)
|
|
280135
281646
|
return text5;
|
|
280136
281647
|
const hasFullText = typeof startOffset === "number" && fullText != null;
|
|
@@ -280141,7 +281652,7 @@ menclose::after {
|
|
|
280141
281652
|
result += isWordChar$1(ch) && !isWordChar$1(prevChar) ? ch.toUpperCase() : ch;
|
|
280142
281653
|
}
|
|
280143
281654
|
return result;
|
|
280144
|
-
}, applyTextTransform$
|
|
281655
|
+
}, applyTextTransform$2 = (text5, transform2, fullText, startOffset) => {
|
|
280145
281656
|
if (!text5 || !transform2 || transform2 === "none")
|
|
280146
281657
|
return text5;
|
|
280147
281658
|
if (transform2 === "uppercase")
|
|
@@ -280149,9 +281660,9 @@ menclose::after {
|
|
|
280149
281660
|
if (transform2 === "lowercase")
|
|
280150
281661
|
return text5.toLowerCase();
|
|
280151
281662
|
if (transform2 === "capitalize")
|
|
280152
|
-
return capitalizeText$
|
|
281663
|
+
return capitalizeText$2(text5, fullText, startOffset);
|
|
280153
281664
|
return text5;
|
|
280154
|
-
}, DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, TWIPS_PER_PX$
|
|
281665
|
+
}, DEFAULT_TAB_INTERVAL_TWIPS$1 = 720, TWIPS_PER_PX$2, TAB_EPSILON$1 = 0.1, WIDTH_FUDGE_PX = 0.5, twipsToPx$1 = (twips) => twips / TWIPS_PER_PX$2, pxToTwips$1 = (px) => Math.round(px * TWIPS_PER_PX$2), sanitizeIndent$1 = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0, sanitizeDecimalSeparator$1 = (value) => value === "," ? "," : ".", getRunWidth = (run2) => {
|
|
280155
281666
|
const width = run2.width;
|
|
280156
281667
|
return typeof width === "number" ? width : 0;
|
|
280157
281668
|
}, isLineBreakRun$1 = (run2) => run2.kind === "lineBreak" || run2.kind === "break" && run2.breakType === "line", markerFontString = (run2) => {
|
|
@@ -281759,13 +283270,13 @@ menclose::after {
|
|
|
281759
283270
|
if (startA == null)
|
|
281760
283271
|
return false;
|
|
281761
283272
|
return (endA ?? startA + 1) > startB && startA < endB;
|
|
281762
|
-
}, DEFAULT_CELL_PADDING$
|
|
283273
|
+
}, DEFAULT_CELL_PADDING$2, getCellPaddingFromRow = (cellIdx, row2) => {
|
|
281763
283274
|
const padding = row2?.cells?.[cellIdx]?.attrs?.padding ?? {};
|
|
281764
283275
|
return {
|
|
281765
|
-
top: padding.top ?? DEFAULT_CELL_PADDING$
|
|
281766
|
-
bottom: padding.bottom ?? DEFAULT_CELL_PADDING$
|
|
281767
|
-
left: padding.left ?? DEFAULT_CELL_PADDING$
|
|
281768
|
-
right: padding.right ?? DEFAULT_CELL_PADDING$
|
|
283276
|
+
top: padding.top ?? DEFAULT_CELL_PADDING$2.top,
|
|
283277
|
+
bottom: padding.bottom ?? DEFAULT_CELL_PADDING$2.bottom,
|
|
283278
|
+
left: padding.left ?? DEFAULT_CELL_PADDING$2.left,
|
|
283279
|
+
right: padding.right ?? DEFAULT_CELL_PADDING$2.right
|
|
281769
283280
|
};
|
|
281770
283281
|
}, getCellBlocks = (cell2) => {
|
|
281771
283282
|
if (!cell2)
|
|
@@ -286245,7 +287756,41 @@ menclose::after {
|
|
|
286245
287756
|
}
|
|
286246
287757
|
}, EMUS_PER_INCH = 914400, maxSize = 5000, cache, makeKey = (text5, font, letterSpacing) => {
|
|
286247
287758
|
return `${text5}|${font}|${letterSpacing || 0}`;
|
|
286248
|
-
}, fontMetricsCache, MAX_CACHE_SIZE = 1000, METRICS_TEST_STRING = "MHgypbdlÁÉÍ",
|
|
287759
|
+
}, fontMetricsCache, MAX_CACHE_SIZE = 1000, METRICS_TEST_STRING = "MHgypbdlÁÉÍ", DEFAULT_MIN_COLUMN_WIDTH = 8, TWIPS_PER_PX$1 = 15, PLACEHOLDER_COLUMN_MAX_WIDTH = 1, DEFAULT_CELL_PADDING$1, DEFAULT_FIELD_ANNOTATION_FONT_SIZE$1 = 16, FIELD_ANNOTATION_PILL_PADDING$1 = 8, TABLE_CELL_METRICS_CACHE_SIZE = 2000, TABLE_AUTOFIT_RESULT_CACHE_SIZE = 500, NO_WRAP_MAX_WIDTH, TOKEN_BOUNDARY_PATTERN, LruCache = class {
|
|
287760
|
+
constructor(maxSize$1) {
|
|
287761
|
+
this.cache = /* @__PURE__ */ new Map;
|
|
287762
|
+
this.maxSize = maxSize$1;
|
|
287763
|
+
}
|
|
287764
|
+
get(key2) {
|
|
287765
|
+
const hit = this.cache.get(key2);
|
|
287766
|
+
if (!hit)
|
|
287767
|
+
return;
|
|
287768
|
+
this.cache.delete(key2);
|
|
287769
|
+
this.cache.set(key2, hit);
|
|
287770
|
+
return hit.value;
|
|
287771
|
+
}
|
|
287772
|
+
set(key2, value) {
|
|
287773
|
+
this.cache.set(key2, { value });
|
|
287774
|
+
this.evictIfNeeded();
|
|
287775
|
+
}
|
|
287776
|
+
clear() {
|
|
287777
|
+
this.cache.clear();
|
|
287778
|
+
}
|
|
287779
|
+
resize(nextSize) {
|
|
287780
|
+
if (!Number.isFinite(nextSize) || nextSize <= 0)
|
|
287781
|
+
return;
|
|
287782
|
+
this.maxSize = nextSize;
|
|
287783
|
+
this.evictIfNeeded();
|
|
287784
|
+
}
|
|
287785
|
+
evictIfNeeded() {
|
|
287786
|
+
while (this.cache.size > this.maxSize) {
|
|
287787
|
+
const oldestKey = this.cache.keys().next().value;
|
|
287788
|
+
if (oldestKey === undefined)
|
|
287789
|
+
break;
|
|
287790
|
+
this.cache.delete(oldestKey);
|
|
287791
|
+
}
|
|
287792
|
+
}
|
|
287793
|
+
}, tableCellMetricsCache, autoFitTableResultCache, canvasContext$1 = null, computeTabStops, measurementConfig, canvasContext = null, DEFAULT_TAB_INTERVAL_TWIPS = 720, TWIPS_PER_PX, twipsToPx = (twips) => twips / TWIPS_PER_PX, pxToTwips = (px) => Math.round(px * TWIPS_PER_PX), DEFAULT_TAB_INTERVAL_PX, TAB_EPSILON = 0.1, DEFAULT_CELL_PADDING, DEFAULT_DECIMAL_SEPARATOR = ".", ALLOWED_TAB_VALS, FIELD_ANNOTATION_PILL_PADDING = 8, FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER = 1.2, FIELD_ANNOTATION_VERTICAL_PADDING = 6, DEFAULT_FIELD_ANNOTATION_FONT_SIZE = 16, DEFAULT_PARAGRAPH_FONT_SIZE = 12, DEFAULT_PARAGRAPH_FONT_FAMILY = "Arial", isValidFontSize = (value) => typeof value === "number" && Number.isFinite(value) && value > 0, normalizeFontSize = (value, fallback = DEFAULT_PARAGRAPH_FONT_SIZE) => {
|
|
286249
287794
|
if (isValidFontSize(value))
|
|
286250
287795
|
return value;
|
|
286251
287796
|
if (typeof value === "string") {
|
|
@@ -288076,12 +289621,12 @@ menclose::after {
|
|
|
288076
289621
|
return;
|
|
288077
289622
|
console.log(...args$1);
|
|
288078
289623
|
}, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
|
|
288079
|
-
var
|
|
289624
|
+
var init_src_DAF1K_X_es = __esm(() => {
|
|
288080
289625
|
init_rolldown_runtime_Bg48TavK_es();
|
|
288081
|
-
|
|
289626
|
+
init_SuperConverter_Dchjy0My_es();
|
|
288082
289627
|
init_jszip_C49i9kUs_es();
|
|
288083
289628
|
init_uuid_qzgm05fK_es();
|
|
288084
|
-
|
|
289629
|
+
init_create_headless_toolbar_CEcVKzGV_es();
|
|
288085
289630
|
init_constants_DrU4EASo_es();
|
|
288086
289631
|
init_dist_B8HfvhaK_es();
|
|
288087
289632
|
init_unified_Dsuw2be5_es();
|
|
@@ -314784,7 +316329,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
314784
316329
|
"even",
|
|
314785
316330
|
"odd"
|
|
314786
316331
|
];
|
|
314787
|
-
TWIPS_PER_PX$
|
|
316332
|
+
TWIPS_PER_PX$2 = 1440 / 96;
|
|
314788
316333
|
init_dist();
|
|
314789
316334
|
measureCache = new MeasureCache;
|
|
314790
316335
|
headerMeasureCache = new HeaderFooterLayoutCache;
|
|
@@ -314813,7 +316358,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
314813
316358
|
workerRoundTrip: 10,
|
|
314814
316359
|
layoutStaleness: 100
|
|
314815
316360
|
});
|
|
314816
|
-
DEFAULT_CELL_PADDING$
|
|
316361
|
+
DEFAULT_CELL_PADDING$2 = {
|
|
314817
316362
|
top: 0,
|
|
314818
316363
|
bottom: 0,
|
|
314819
316364
|
left: 4,
|
|
@@ -319420,6 +320965,16 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
319420
320965
|
EMUS_PER_INCH / 96;
|
|
319421
320966
|
cache = /* @__PURE__ */ new Map;
|
|
319422
320967
|
fontMetricsCache = /* @__PURE__ */ new Map;
|
|
320968
|
+
DEFAULT_CELL_PADDING$1 = {
|
|
320969
|
+
top: 0,
|
|
320970
|
+
right: 4,
|
|
320971
|
+
bottom: 0,
|
|
320972
|
+
left: 4
|
|
320973
|
+
};
|
|
320974
|
+
NO_WRAP_MAX_WIDTH = Number.MAX_SAFE_INTEGER;
|
|
320975
|
+
TOKEN_BOUNDARY_PATTERN = /[ \t\f\v\-\u00ad\u2010\u2012\u2013\u2014\u200b\u2028\u2029]+|\r\n|\r|\n|\u2028|\u2029/gu;
|
|
320976
|
+
tableCellMetricsCache = new LruCache(TABLE_CELL_METRICS_CACHE_SIZE);
|
|
320977
|
+
autoFitTableResultCache = new LruCache(TABLE_AUTOFIT_RESULT_CACHE_SIZE);
|
|
319423
320978
|
({ computeTabStops } = engines_exports);
|
|
319424
320979
|
measurementConfig = {
|
|
319425
320980
|
mode: "browser",
|
|
@@ -325292,11 +326847,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
325292
326847
|
];
|
|
325293
326848
|
});
|
|
325294
326849
|
|
|
325295
|
-
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-
|
|
326850
|
+
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-HW4PZyuU.es.js
|
|
325296
326851
|
var ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
|
|
325297
|
-
var
|
|
325298
|
-
|
|
325299
|
-
|
|
326852
|
+
var init_create_super_doc_ui_HW4PZyuU_es = __esm(() => {
|
|
326853
|
+
init_SuperConverter_Dchjy0My_es();
|
|
326854
|
+
init_create_headless_toolbar_CEcVKzGV_es();
|
|
325300
326855
|
ALL_TOOLBAR_COMMAND_IDS = Object.keys(createToolbarRegistry());
|
|
325301
326856
|
EMPTY_ACTIVE_IDS = Object.freeze([]);
|
|
325302
326857
|
});
|
|
@@ -325314,16 +326869,16 @@ var init_zipper_BxRAi0_5_es = __esm(() => {
|
|
|
325314
326869
|
|
|
325315
326870
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
325316
326871
|
var init_super_editor_es = __esm(() => {
|
|
325317
|
-
|
|
325318
|
-
|
|
326872
|
+
init_src_DAF1K_X_es();
|
|
326873
|
+
init_SuperConverter_Dchjy0My_es();
|
|
325319
326874
|
init_jszip_C49i9kUs_es();
|
|
325320
326875
|
init_xml_js_CqGKpaft_es();
|
|
325321
|
-
|
|
326876
|
+
init_create_headless_toolbar_CEcVKzGV_es();
|
|
325322
326877
|
init_constants_DrU4EASo_es();
|
|
325323
326878
|
init_dist_B8HfvhaK_es();
|
|
325324
326879
|
init_unified_Dsuw2be5_es();
|
|
325325
326880
|
init_DocxZipper_CUX64E5K_es();
|
|
325326
|
-
|
|
326881
|
+
init_create_super_doc_ui_HW4PZyuU_es();
|
|
325327
326882
|
init_ui_CGB3qmy3_es();
|
|
325328
326883
|
init_eventemitter3_BJrNoN9D_es();
|
|
325329
326884
|
init_errors_C_DoKMoN_es();
|
|
@@ -408763,10 +410318,38 @@ var DEFAULT_PAGE_WIDTH_TWIPS = 12240, DEFAULT_PAGE_MARGIN_TWIPS = 1440, DEFAULT_
|
|
|
408763
410318
|
return twipsToPixels4(widthTwips);
|
|
408764
410319
|
}
|
|
408765
410320
|
return null;
|
|
410321
|
+
}, getRawRowGridMetadata2 = (row2) => {
|
|
410322
|
+
const trPr = row2?.elements?.find((element3) => element3.name === "w:trPr");
|
|
410323
|
+
const getChild = (name) => trPr?.elements?.find((element3) => element3.name === name);
|
|
410324
|
+
const parseCount = (name) => {
|
|
410325
|
+
const rawValue = getChild(name)?.attributes?.["w:val"];
|
|
410326
|
+
const value = typeof rawValue === "number" ? rawValue : Number.parseInt(rawValue || "0", 10);
|
|
410327
|
+
return Number.isFinite(value) && value > 0 ? value : 0;
|
|
410328
|
+
};
|
|
410329
|
+
const parseMeasurement = (name) => {
|
|
410330
|
+
const node4 = getChild(name);
|
|
410331
|
+
if (!node4?.attributes)
|
|
410332
|
+
return null;
|
|
410333
|
+
const rawValue = node4.attributes["w:w"];
|
|
410334
|
+
const value = typeof rawValue === "number" ? rawValue : Number.parseInt(rawValue || "", 10);
|
|
410335
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
410336
|
+
return null;
|
|
410337
|
+
return {
|
|
410338
|
+
value,
|
|
410339
|
+
type: node4.attributes["w:type"] || "dxa"
|
|
410340
|
+
};
|
|
410341
|
+
};
|
|
410342
|
+
return {
|
|
410343
|
+
gridBefore: parseCount("w:gridBefore"),
|
|
410344
|
+
gridAfter: parseCount("w:gridAfter"),
|
|
410345
|
+
wBefore: parseMeasurement("w:wBefore"),
|
|
410346
|
+
wAfter: parseMeasurement("w:wAfter")
|
|
410347
|
+
};
|
|
408766
410348
|
}, countColumnsInRow2 = (row2) => {
|
|
408767
410349
|
if (!row2?.elements?.length)
|
|
408768
410350
|
return 0;
|
|
408769
|
-
|
|
410351
|
+
const { gridBefore, gridAfter } = getRawRowGridMetadata2(row2);
|
|
410352
|
+
const cellSpanCount = row2.elements.reduce((count, element3) => {
|
|
408770
410353
|
if (element3.name !== "w:tc")
|
|
408771
410354
|
return count;
|
|
408772
410355
|
const tcPr = element3.elements?.find((el) => el.name === "w:tcPr");
|
|
@@ -408774,9 +410357,47 @@ var DEFAULT_PAGE_WIDTH_TWIPS = 12240, DEFAULT_PAGE_MARGIN_TWIPS = 1440, DEFAULT_
|
|
|
408774
410357
|
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
408775
410358
|
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
408776
410359
|
}, 0);
|
|
408777
|
-
|
|
408778
|
-
|
|
408779
|
-
|
|
410360
|
+
return gridBefore + cellSpanCount + gridAfter;
|
|
410361
|
+
}, clampColumnWidthTwips2 = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS2), resolveSkippedColumnSeedWidthsTwips2 = (measurement, span) => {
|
|
410362
|
+
if (!measurement || !Number.isFinite(span) || span <= 0)
|
|
410363
|
+
return [];
|
|
410364
|
+
const resolvedPx = resolveMeasurementWidthPx2(measurement);
|
|
410365
|
+
if (resolvedPx == null || resolvedPx <= 0)
|
|
410366
|
+
return [];
|
|
410367
|
+
const totalTwips = clampColumnWidthTwips2(pixelsToTwips2(resolvedPx));
|
|
410368
|
+
const baseWidth = Math.floor(totalTwips / span);
|
|
410369
|
+
const remainder = totalTwips - baseWidth * span;
|
|
410370
|
+
return Array.from({ length: span }, (_3, index3) => clampColumnWidthTwips2(baseWidth + (index3 < remainder ? 1 : 0)));
|
|
410371
|
+
}, buildFallbackColumnWidthTwips2 = ({ columnCount, totalWidthTwips, rows }) => {
|
|
410372
|
+
const seededWidths = new Array(columnCount).fill(null);
|
|
410373
|
+
for (const row2 of rows) {
|
|
410374
|
+
const { gridBefore, gridAfter, wBefore, wAfter } = getRawRowGridMetadata2(row2);
|
|
410375
|
+
if (gridBefore > 0) {
|
|
410376
|
+
const beforeWidths = resolveSkippedColumnSeedWidthsTwips2(wBefore, gridBefore);
|
|
410377
|
+
beforeWidths.forEach((widthTwips, index3) => {
|
|
410378
|
+
if (index3 < columnCount) {
|
|
410379
|
+
seededWidths[index3] = Math.max(seededWidths[index3] ?? 0, widthTwips);
|
|
410380
|
+
}
|
|
410381
|
+
});
|
|
410382
|
+
}
|
|
410383
|
+
if (gridAfter > 0) {
|
|
410384
|
+
const afterWidths = resolveSkippedColumnSeedWidthsTwips2(wAfter, gridAfter);
|
|
410385
|
+
afterWidths.forEach((widthTwips, index3) => {
|
|
410386
|
+
const targetIndex = columnCount - gridAfter + index3;
|
|
410387
|
+
if (targetIndex >= 0 && targetIndex < columnCount) {
|
|
410388
|
+
seededWidths[targetIndex] = Math.max(seededWidths[targetIndex] ?? 0, widthTwips);
|
|
410389
|
+
}
|
|
410390
|
+
});
|
|
410391
|
+
}
|
|
410392
|
+
}
|
|
410393
|
+
const seededTotalTwips = seededWidths.reduce((sum, widthTwips) => sum + (widthTwips ?? 0), 0);
|
|
410394
|
+
const remainingColumns = seededWidths.filter((widthTwips) => widthTwips == null).length;
|
|
410395
|
+
const minimumRemainingTwips = remainingColumns * MIN_COLUMN_WIDTH_TWIPS2;
|
|
410396
|
+
const effectiveTotalTwips = Math.max(totalWidthTwips, seededTotalTwips + minimumRemainingTwips);
|
|
410397
|
+
const defaultRemainingTwips = remainingColumns > 0 ? clampColumnWidthTwips2((effectiveTotalTwips - seededTotalTwips) / remainingColumns) : 0;
|
|
410398
|
+
return seededWidths.map((widthTwips) => clampColumnWidthTwips2(widthTwips ?? defaultRemainingTwips));
|
|
410399
|
+
}, buildFallbackGridForTable2 = ({ params: params3, rows, tableWidth, tableWidthMeasurement }) => {
|
|
410400
|
+
const columnCount = rows.reduce((max3, row2) => Math.max(max3, countColumnsInRow2(row2)), 0);
|
|
408780
410401
|
if (!columnCount)
|
|
408781
410402
|
return null;
|
|
408782
410403
|
const schemaDefaultPx = getSchemaDefaultColumnWidthPx2(params3);
|
|
@@ -408793,12 +410414,16 @@ var DEFAULT_PAGE_WIDTH_TWIPS = 12240, DEFAULT_PAGE_MARGIN_TWIPS = 1440, DEFAULT_
|
|
|
408793
410414
|
if (totalWidthPx == null) {
|
|
408794
410415
|
totalWidthPx = twipsToPixels4(DEFAULT_CONTENT_WIDTH_TWIPS2);
|
|
408795
410416
|
}
|
|
408796
|
-
const
|
|
408797
|
-
const
|
|
408798
|
-
const
|
|
410417
|
+
const minimumColumnWidthTwips = clampColumnWidthTwips2(pixelsToTwips2(minimumColumnWidthPx));
|
|
410418
|
+
const baseTotalWidthTwips = Math.max(clampColumnWidthTwips2(pixelsToTwips2(totalWidthPx)), minimumColumnWidthTwips * columnCount);
|
|
410419
|
+
const fallbackColumnWidthTwips = buildFallbackColumnWidthTwips2({
|
|
410420
|
+
columnCount,
|
|
410421
|
+
totalWidthTwips: baseTotalWidthTwips,
|
|
410422
|
+
rows
|
|
410423
|
+
});
|
|
408799
410424
|
return {
|
|
408800
|
-
grid:
|
|
408801
|
-
columnWidths:
|
|
410425
|
+
grid: fallbackColumnWidthTwips.map((columnWidthTwips) => ({ col: clampColumnWidthTwips2(columnWidthTwips) })),
|
|
410426
|
+
columnWidths: fallbackColumnWidthTwips.map((columnWidthTwips) => twipsToPixels4(columnWidthTwips))
|
|
408802
410427
|
};
|
|
408803
410428
|
};
|
|
408804
410429
|
var init_tableFallbackHelpers = __esm(() => {
|
|
@@ -437158,31 +438783,13 @@ function mapBorderSizes2(borders, sizeMapper) {
|
|
|
437158
438783
|
}
|
|
437159
438784
|
}
|
|
437160
438785
|
|
|
437161
|
-
// ../../packages/super-editor/src/editors/v1/document-api-adapters/
|
|
437162
|
-
function createSeparatorParagraph2(schema) {
|
|
437163
|
-
const paragraphType = schema.nodes.paragraph;
|
|
437164
|
-
if (!paragraphType)
|
|
437165
|
-
return null;
|
|
437166
|
-
const separatorAttrs = {
|
|
437167
|
-
sdBlockId: v42(),
|
|
437168
|
-
paraId: generateDocxHexId2()
|
|
437169
|
-
};
|
|
437170
|
-
return paragraphType.createAndFill(separatorAttrs) ?? paragraphType.createAndFill();
|
|
437171
|
-
}
|
|
437172
|
-
function buildTableSuccess2(tableAddress, trackedChangeRefs) {
|
|
437173
|
-
return {
|
|
437174
|
-
success: true,
|
|
437175
|
-
table: tableAddress,
|
|
437176
|
-
trackedChangeRefs
|
|
437177
|
-
};
|
|
437178
|
-
}
|
|
438786
|
+
// ../../packages/super-editor/src/editors/v1/document-api-adapters/helpers/table-attr-sync.ts
|
|
437179
438787
|
function syncExtractedTableAttrs2(tp) {
|
|
437180
438788
|
const extracted = {};
|
|
437181
438789
|
extracted.tableStyleId = tp.tableStyleId ?? null;
|
|
437182
438790
|
extracted.justification = tp.justification ?? null;
|
|
437183
438791
|
extracted.tableLayout = tp.tableLayout ?? null;
|
|
437184
|
-
|
|
437185
|
-
extracted.borders = pixelBorders ?? tp.borders ?? null;
|
|
438792
|
+
extracted.borders = convertTableBordersToPixelUnits2(tp.borders) ?? {};
|
|
437186
438793
|
const indent3 = tp.tableIndent;
|
|
437187
438794
|
if (indent3?.value != null) {
|
|
437188
438795
|
extracted.tableIndent = {
|
|
@@ -437195,7 +438802,7 @@ function syncExtractedTableAttrs2(tp) {
|
|
|
437195
438802
|
const spacing = tp.tableCellSpacing;
|
|
437196
438803
|
if (spacing?.value != null) {
|
|
437197
438804
|
extracted.tableCellSpacing = {
|
|
437198
|
-
|
|
438805
|
+
value: twipsToPixels4(spacing.value),
|
|
437199
438806
|
type: spacing.type ?? "dxa"
|
|
437200
438807
|
};
|
|
437201
438808
|
extracted.borderCollapse = "separate";
|
|
@@ -437203,15 +438810,15 @@ function syncExtractedTableAttrs2(tp) {
|
|
|
437203
438810
|
extracted.tableCellSpacing = null;
|
|
437204
438811
|
extracted.borderCollapse = null;
|
|
437205
438812
|
}
|
|
437206
|
-
const
|
|
437207
|
-
if (
|
|
437208
|
-
if (
|
|
437209
|
-
extracted.tableWidth = { value:
|
|
437210
|
-
} else if (
|
|
438813
|
+
const width = tp.tableWidth;
|
|
438814
|
+
if (width) {
|
|
438815
|
+
if (width.type === "pct" && typeof width.value === "number") {
|
|
438816
|
+
extracted.tableWidth = { value: width.value, type: "pct" };
|
|
438817
|
+
} else if (width.type === "auto") {
|
|
437211
438818
|
extracted.tableWidth = { width: 0, type: "auto" };
|
|
437212
|
-
} else if (
|
|
437213
|
-
const widthPx = twipsToPixels4(
|
|
437214
|
-
extracted.tableWidth = widthPx != null ? { width: widthPx, type:
|
|
438819
|
+
} else if (width.value != null) {
|
|
438820
|
+
const widthPx = twipsToPixels4(width.value);
|
|
438821
|
+
extracted.tableWidth = widthPx != null ? { width: widthPx, type: width.type } : null;
|
|
437215
438822
|
} else {
|
|
437216
438823
|
extracted.tableWidth = null;
|
|
437217
438824
|
}
|
|
@@ -437227,7 +438834,101 @@ function convertTableBordersToPixelUnits2(value) {
|
|
|
437227
438834
|
mapBorderSizes2(clone2, eighthPointsToPixels2);
|
|
437228
438835
|
return Object.keys(clone2).length > 0 ? clone2 : undefined;
|
|
437229
438836
|
}
|
|
438837
|
+
function buildWidthAuthoringTableAttrs2(currentAttrs, attrOverrides = {}, tablePropertyOverrides = {}) {
|
|
438838
|
+
const currentTableProps = currentAttrs.tableProperties ?? {};
|
|
438839
|
+
const nextTableWidth = resolveWidthAuthoringTableWidth2(currentAttrs, attrOverrides, tablePropertyOverrides);
|
|
438840
|
+
const updatedTableProps = {
|
|
438841
|
+
...currentTableProps,
|
|
438842
|
+
...tablePropertyOverrides,
|
|
438843
|
+
tableLayout: "fixed"
|
|
438844
|
+
};
|
|
438845
|
+
if (nextTableWidth) {
|
|
438846
|
+
updatedTableProps.tableWidth = nextTableWidth;
|
|
438847
|
+
} else {
|
|
438848
|
+
delete updatedTableProps.tableWidth;
|
|
438849
|
+
}
|
|
438850
|
+
return {
|
|
438851
|
+
...currentAttrs,
|
|
438852
|
+
tableProperties: updatedTableProps,
|
|
438853
|
+
...attrOverrides,
|
|
438854
|
+
...syncExtractedTableAttrs2(updatedTableProps),
|
|
438855
|
+
userEdited: true
|
|
438856
|
+
};
|
|
438857
|
+
}
|
|
438858
|
+
function resolveWidthAuthoringTableWidth2(currentAttrs, attrOverrides, tablePropertyOverrides) {
|
|
438859
|
+
const explicitOverride = normalizeTableWidthMeasurement2(tablePropertyOverrides.tableWidth);
|
|
438860
|
+
if (explicitOverride)
|
|
438861
|
+
return explicitOverride;
|
|
438862
|
+
const gridWidth = sumGridColumnTwips2(attrOverrides.grid ?? currentAttrs.grid);
|
|
438863
|
+
if (gridWidth != null) {
|
|
438864
|
+
return { value: gridWidth, type: "dxa" };
|
|
438865
|
+
}
|
|
438866
|
+
return null;
|
|
438867
|
+
}
|
|
438868
|
+
function sumGridColumnTwips2(grid) {
|
|
438869
|
+
const columns = normalizeGridColumns2(grid);
|
|
438870
|
+
if (!columns || columns.length === 0)
|
|
438871
|
+
return null;
|
|
438872
|
+
const total = columns.reduce((sum, column) => sum + column.col, 0);
|
|
438873
|
+
return total > 0 ? total : null;
|
|
438874
|
+
}
|
|
438875
|
+
function normalizeGridColumns2(grid) {
|
|
438876
|
+
if (Array.isArray(grid)) {
|
|
438877
|
+
const columns = grid.map((width) => normalizeGridWidth2(width)).filter((width) => width != null);
|
|
438878
|
+
return columns.length > 0 ? columns : null;
|
|
438879
|
+
}
|
|
438880
|
+
if (grid && typeof grid === "object") {
|
|
438881
|
+
const rawColWidths = grid.colWidths;
|
|
438882
|
+
if (Array.isArray(rawColWidths)) {
|
|
438883
|
+
const columns = rawColWidths.map((width) => normalizeGridWidth2(width)).filter((width) => width != null);
|
|
438884
|
+
return columns.length > 0 ? columns : null;
|
|
438885
|
+
}
|
|
438886
|
+
}
|
|
438887
|
+
return null;
|
|
438888
|
+
}
|
|
437230
438889
|
function normalizeGridWidth2(width) {
|
|
438890
|
+
if (typeof width === "number" && Number.isFinite(width) && width > 0) {
|
|
438891
|
+
return { col: Math.round(width) };
|
|
438892
|
+
}
|
|
438893
|
+
const value = width?.col;
|
|
438894
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) {
|
|
438895
|
+
return { col: Math.round(value) };
|
|
438896
|
+
}
|
|
438897
|
+
return null;
|
|
438898
|
+
}
|
|
438899
|
+
function normalizeTableWidthMeasurement2(width) {
|
|
438900
|
+
if (!width || typeof width !== "object")
|
|
438901
|
+
return null;
|
|
438902
|
+
const value = width.value;
|
|
438903
|
+
const type = width.type;
|
|
438904
|
+
if (type !== "dxa" || typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
438905
|
+
return null;
|
|
438906
|
+
}
|
|
438907
|
+
return { value: Math.round(value), type: "dxa" };
|
|
438908
|
+
}
|
|
438909
|
+
var init_table_attr_sync = __esm(() => {
|
|
438910
|
+
init_helpers();
|
|
438911
|
+
});
|
|
438912
|
+
|
|
438913
|
+
// ../../packages/super-editor/src/editors/v1/document-api-adapters/tables-adapter.ts
|
|
438914
|
+
function createSeparatorParagraph2(schema) {
|
|
438915
|
+
const paragraphType = schema.nodes.paragraph;
|
|
438916
|
+
if (!paragraphType)
|
|
438917
|
+
return null;
|
|
438918
|
+
const separatorAttrs = {
|
|
438919
|
+
sdBlockId: v42(),
|
|
438920
|
+
paraId: generateDocxHexId2()
|
|
438921
|
+
};
|
|
438922
|
+
return paragraphType.createAndFill(separatorAttrs) ?? paragraphType.createAndFill();
|
|
438923
|
+
}
|
|
438924
|
+
function buildTableSuccess2(tableAddress, trackedChangeRefs) {
|
|
438925
|
+
return {
|
|
438926
|
+
success: true,
|
|
438927
|
+
table: tableAddress,
|
|
438928
|
+
trackedChangeRefs
|
|
438929
|
+
};
|
|
438930
|
+
}
|
|
438931
|
+
function normalizeGridWidth3(width) {
|
|
437231
438932
|
if (typeof width === "number" && Number.isFinite(width)) {
|
|
437232
438933
|
return { col: Math.round(width) };
|
|
437233
438934
|
}
|
|
@@ -437239,16 +438940,16 @@ function normalizeGridWidth2(width) {
|
|
|
437239
438940
|
}
|
|
437240
438941
|
return { col: DEFAULT_TABLE_GRID_WIDTH_TWIPS2 };
|
|
437241
438942
|
}
|
|
437242
|
-
function
|
|
438943
|
+
function normalizeGridColumns3(grid) {
|
|
437243
438944
|
if (Array.isArray(grid)) {
|
|
437244
438945
|
if (grid.length === 0)
|
|
437245
438946
|
return null;
|
|
437246
|
-
return { columns: grid.map((width) =>
|
|
438947
|
+
return { columns: grid.map((width) => normalizeGridWidth3(width)), format: "array" };
|
|
437247
438948
|
}
|
|
437248
438949
|
if (grid && typeof grid === "object") {
|
|
437249
438950
|
const rawColWidths = grid.colWidths;
|
|
437250
438951
|
if (Array.isArray(rawColWidths) && rawColWidths.length > 0) {
|
|
437251
|
-
return { columns: rawColWidths.map((width) =>
|
|
438952
|
+
return { columns: rawColWidths.map((width) => normalizeGridWidth3(width)), format: "object" };
|
|
437252
438953
|
}
|
|
437253
438954
|
}
|
|
437254
438955
|
return null;
|
|
@@ -437260,17 +438961,17 @@ function serializeGridColumns2(originalGrid, normalized) {
|
|
|
437260
438961
|
return { ...originalGrid, colWidths: normalized.columns };
|
|
437261
438962
|
}
|
|
437262
438963
|
function insertGridColumnWidth2(grid, insertIndex) {
|
|
437263
|
-
const normalized =
|
|
438964
|
+
const normalized = normalizeGridColumns3(grid);
|
|
437264
438965
|
if (!normalized)
|
|
437265
438966
|
return null;
|
|
437266
438967
|
const colWidths = normalized.columns.slice();
|
|
437267
438968
|
const boundedIndex = Math.max(0, Math.min(insertIndex, colWidths.length));
|
|
437268
|
-
const template = colWidths[Math.min(boundedIndex, colWidths.length - 1)] ?? colWidths[colWidths.length - 1] ??
|
|
438969
|
+
const template = colWidths[Math.min(boundedIndex, colWidths.length - 1)] ?? colWidths[colWidths.length - 1] ?? normalizeGridWidth3(null);
|
|
437269
438970
|
colWidths.splice(boundedIndex, 0, { ...template });
|
|
437270
438971
|
return serializeGridColumns2(grid, { ...normalized, columns: colWidths });
|
|
437271
438972
|
}
|
|
437272
438973
|
function removeGridColumnWidth2(grid, deleteIndex) {
|
|
437273
|
-
const normalized =
|
|
438974
|
+
const normalized = normalizeGridColumns3(grid);
|
|
437274
438975
|
if (!normalized || normalized.columns.length <= 1)
|
|
437275
438976
|
return null;
|
|
437276
438977
|
const colWidths = normalized.columns.slice();
|
|
@@ -437278,6 +438979,29 @@ function removeGridColumnWidth2(grid, deleteIndex) {
|
|
|
437278
438979
|
colWidths.splice(boundedIndex, 1);
|
|
437279
438980
|
return serializeGridColumns2(grid, { ...normalized, columns: colWidths });
|
|
437280
438981
|
}
|
|
438982
|
+
function buildFirstRowCellWidthProps2(attrs, cellStartCol, colspan, colwidth, gridColumns) {
|
|
438983
|
+
const currentCellProps = attrs.tableCellProperties && typeof attrs.tableCellProperties === "object" ? attrs.tableCellProperties : {};
|
|
438984
|
+
const spanTwips = resolveSpanWidthTwips2(cellStartCol, colspan, colwidth, gridColumns);
|
|
438985
|
+
if (spanTwips == null)
|
|
438986
|
+
return Object.keys(currentCellProps).length > 0 ? currentCellProps : undefined;
|
|
438987
|
+
return {
|
|
438988
|
+
...currentCellProps,
|
|
438989
|
+
cellWidth: { value: spanTwips, type: "dxa" }
|
|
438990
|
+
};
|
|
438991
|
+
}
|
|
438992
|
+
function resolveSpanWidthTwips2(cellStartCol, colspan, colwidth, gridColumns) {
|
|
438993
|
+
const boundedSpan = Math.max(1, colspan);
|
|
438994
|
+
if (Array.isArray(gridColumns) && cellStartCol >= 0 && cellStartCol + boundedSpan <= gridColumns.length) {
|
|
438995
|
+
const gridSpanTwips = gridColumns.slice(cellStartCol, cellStartCol + boundedSpan).reduce((sum, column) => sum + normalizeGridWidth3(column).col, 0);
|
|
438996
|
+
if (gridSpanTwips > 0)
|
|
438997
|
+
return gridSpanTwips;
|
|
438998
|
+
}
|
|
438999
|
+
const spanWidthPx = colwidth.slice(0, boundedSpan).reduce((sum, width) => sum + (Number.isFinite(width) ? width : 0), 0);
|
|
439000
|
+
if (spanWidthPx > 0) {
|
|
439001
|
+
return Math.round(spanWidthPx * PIXELS_TO_TWIPS2);
|
|
439002
|
+
}
|
|
439003
|
+
return;
|
|
439004
|
+
}
|
|
437281
439005
|
function normalizeCellAttrsForSingleCell2(attrs) {
|
|
437282
439006
|
const currentColwidth = Array.isArray(attrs.colwidth) ? attrs.colwidth : null;
|
|
437283
439007
|
const tableCellProperties = {
|
|
@@ -438185,8 +439909,14 @@ function tablesSetColumnWidthAdapter2(editor, input2, options) {
|
|
|
438185
439909
|
const tablePos = table2.candidate.pos;
|
|
438186
439910
|
const tableStart = tablePos + 1;
|
|
438187
439911
|
const tableNode = table2.candidate.node;
|
|
439912
|
+
const tableAttrs = tableNode.attrs;
|
|
438188
439913
|
const map10 = TableMap2.get(tableNode);
|
|
438189
439914
|
const widthPx = Math.round(input2.widthPt * (96 / 72));
|
|
439915
|
+
const normalizedGrid = normalizeGridColumns3(tableAttrs.grid);
|
|
439916
|
+
const nextGridColumns = normalizedGrid?.columns.slice();
|
|
439917
|
+
if (nextGridColumns && columnIndex < nextGridColumns.length) {
|
|
439918
|
+
nextGridColumns[columnIndex] = { col: Math.round(input2.widthPt * POINTS_TO_TWIPS2) };
|
|
439919
|
+
}
|
|
438190
439920
|
const processed = new Set;
|
|
438191
439921
|
for (let row2 = 0;row2 < map10.height; row2++) {
|
|
438192
439922
|
const index3 = row2 * map10.width + columnIndex;
|
|
@@ -438205,19 +439935,22 @@ function tablesSetColumnWidthAdapter2(editor, input2, options) {
|
|
|
438205
439935
|
while (colwidth.length < colspan)
|
|
438206
439936
|
colwidth.push(0);
|
|
438207
439937
|
colwidth[withinCol] = widthPx;
|
|
438208
|
-
|
|
439938
|
+
const nextAttrs = { ...attrs, colwidth };
|
|
439939
|
+
if (row2 === 0) {
|
|
439940
|
+
const nextCellProps = buildFirstRowCellWidthProps2(attrs, cellStartCol, colspan, colwidth, nextGridColumns);
|
|
439941
|
+
if (nextCellProps) {
|
|
439942
|
+
nextAttrs.tableCellProperties = nextCellProps;
|
|
439943
|
+
} else {
|
|
439944
|
+
delete nextAttrs.tableCellProperties;
|
|
439945
|
+
}
|
|
439946
|
+
}
|
|
439947
|
+
tr.setNodeMarkup(tableStart + pos, null, nextAttrs);
|
|
438209
439948
|
}
|
|
438210
|
-
const
|
|
438211
|
-
|
|
438212
|
-
|
|
438213
|
-
const newColumns = normalizedGrid.columns.slice();
|
|
438214
|
-
newColumns[columnIndex] = { col: Math.round(input2.widthPt * POINTS_TO_TWIPS2) };
|
|
438215
|
-
tr.setNodeMarkup(tablePos, null, {
|
|
438216
|
-
...tableAttrs,
|
|
438217
|
-
grid: serializeGridColumns2(tableAttrs.grid, { ...normalizedGrid, columns: newColumns }),
|
|
438218
|
-
userEdited: true
|
|
438219
|
-
});
|
|
439949
|
+
const tableAttrUpdates = {};
|
|
439950
|
+
if (normalizedGrid && nextGridColumns) {
|
|
439951
|
+
tableAttrUpdates.grid = serializeGridColumns2(tableAttrs.grid, { ...normalizedGrid, columns: nextGridColumns });
|
|
438220
439952
|
}
|
|
439953
|
+
tr.setNodeMarkup(tablePos, null, buildWidthAuthoringTableAttrs2(tableAttrs, tableAttrUpdates));
|
|
438221
439954
|
applyDirectMutationMeta2(tr);
|
|
438222
439955
|
editor.dispatch(tr);
|
|
438223
439956
|
clearIndexCache2(editor);
|
|
@@ -438242,7 +439975,10 @@ function tablesDistributeColumnsAdapter2(editor, input2, options) {
|
|
|
438242
439975
|
const tablePos = candidate.pos;
|
|
438243
439976
|
const tableStart = tablePos + 1;
|
|
438244
439977
|
const tableNode = candidate.node;
|
|
439978
|
+
const tableAttrs = tableNode.attrs;
|
|
438245
439979
|
const map10 = TableMap2.get(tableNode);
|
|
439980
|
+
const normalizedGrid = normalizeGridColumns3(tableAttrs.grid);
|
|
439981
|
+
const nextGridColumns = normalizedGrid?.columns.slice();
|
|
438246
439982
|
const rangeStart = input2.columnRange?.start ?? 0;
|
|
438247
439983
|
const rangeEnd = input2.columnRange?.end ?? map10.width - 1;
|
|
438248
439984
|
const rangeWidth = rangeEnd - rangeStart + 1;
|
|
@@ -438258,6 +439994,13 @@ function tablesDistributeColumnsAdapter2(editor, input2, options) {
|
|
|
438258
439994
|
totalWidth += colwidth?.[withinCol] ?? 100;
|
|
438259
439995
|
}
|
|
438260
439996
|
const evenWidth = Math.round(totalWidth / rangeWidth);
|
|
439997
|
+
if (nextGridColumns) {
|
|
439998
|
+
const evenWidthTwips = Math.max(1, Math.round(evenWidth * PIXELS_TO_TWIPS2));
|
|
439999
|
+
const maxColumn = Math.min(rangeEnd, nextGridColumns.length - 1);
|
|
440000
|
+
for (let col = Math.max(rangeStart, 0);col <= maxColumn; col++) {
|
|
440001
|
+
nextGridColumns[col] = { col: evenWidthTwips };
|
|
440002
|
+
}
|
|
440003
|
+
}
|
|
438261
440004
|
const processed = new Set;
|
|
438262
440005
|
for (let row2 = 0;row2 < map10.height; row2++) {
|
|
438263
440006
|
for (let col = rangeStart;col <= rangeEnd; col++) {
|
|
@@ -438281,22 +440024,23 @@ function tablesDistributeColumnsAdapter2(editor, input2, options) {
|
|
|
438281
440024
|
newColwidth[c] = evenWidth;
|
|
438282
440025
|
}
|
|
438283
440026
|
}
|
|
438284
|
-
|
|
440027
|
+
const nextAttrs = { ...attrs, colwidth: newColwidth };
|
|
440028
|
+
if (row2 === 0) {
|
|
440029
|
+
const nextCellProps = buildFirstRowCellWidthProps2(attrs, cellStartCol, colspan, newColwidth, nextGridColumns);
|
|
440030
|
+
if (nextCellProps) {
|
|
440031
|
+
nextAttrs.tableCellProperties = nextCellProps;
|
|
440032
|
+
} else {
|
|
440033
|
+
delete nextAttrs.tableCellProperties;
|
|
440034
|
+
}
|
|
440035
|
+
}
|
|
440036
|
+
tr.setNodeMarkup(tableStart + pos, null, nextAttrs);
|
|
438285
440037
|
}
|
|
438286
440038
|
}
|
|
438287
|
-
const
|
|
438288
|
-
|
|
438289
|
-
|
|
438290
|
-
if (normalizedGrid) {
|
|
438291
|
-
const newColumns = normalizedGrid.columns.slice();
|
|
438292
|
-
const evenWidthTwips = Math.max(1, Math.round(evenWidth * PIXELS_TO_TWIPS2));
|
|
438293
|
-
const maxColumn = Math.min(rangeEnd, newColumns.length - 1);
|
|
438294
|
-
for (let col = Math.max(rangeStart, 0);col <= maxColumn; col++) {
|
|
438295
|
-
newColumns[col] = { col: evenWidthTwips };
|
|
438296
|
-
}
|
|
438297
|
-
tableAttrUpdates.grid = serializeGridColumns2(tableAttrs.grid, { ...normalizedGrid, columns: newColumns });
|
|
440039
|
+
const tableAttrUpdates = {};
|
|
440040
|
+
if (normalizedGrid && nextGridColumns) {
|
|
440041
|
+
tableAttrUpdates.grid = serializeGridColumns2(tableAttrs.grid, { ...normalizedGrid, columns: nextGridColumns });
|
|
438298
440042
|
}
|
|
438299
|
-
tr.setNodeMarkup(tablePos, null, tableAttrUpdates);
|
|
440043
|
+
tr.setNodeMarkup(tablePos, null, buildWidthAuthoringTableAttrs2(tableAttrs, tableAttrUpdates));
|
|
438300
440044
|
applyDirectMutationMeta2(tr);
|
|
438301
440045
|
editor.dispatch(tr);
|
|
438302
440046
|
clearIndexCache2(editor);
|
|
@@ -438942,6 +440686,10 @@ function tablesSetCellPropertiesAdapter2(editor, input2, options) {
|
|
|
438942
440686
|
tableCellProperties: { ...currentCellProps, ...cellPropUpdates }
|
|
438943
440687
|
};
|
|
438944
440688
|
tr.setNodeMarkup(cellPos, null, newAttrs);
|
|
440689
|
+
if (input2.preferredWidthPt !== undefined) {
|
|
440690
|
+
const tableAttrs = table2.candidate.node.attrs;
|
|
440691
|
+
tr.setNodeMarkup(table2.candidate.pos, null, buildWidthAuthoringTableAttrs2(tableAttrs));
|
|
440692
|
+
}
|
|
438945
440693
|
applyDirectMutationMeta2(tr);
|
|
438946
440694
|
editor.dispatch(tr);
|
|
438947
440695
|
clearIndexCache2(editor);
|
|
@@ -440131,10 +441879,10 @@ var init_tables_adapter = __esm(() => {
|
|
|
440131
441879
|
init_tracked_change_refs();
|
|
440132
441880
|
init_errors4();
|
|
440133
441881
|
init_node_address_resolver();
|
|
440134
|
-
init_helpers();
|
|
440135
441882
|
init_ooxml();
|
|
440136
441883
|
init_document_settings();
|
|
440137
441884
|
init_mutate_part();
|
|
441885
|
+
init_table_attr_sync();
|
|
440138
441886
|
POINTS_TO_PIXELS2 = 96 / 72;
|
|
440139
441887
|
PIXELS_TO_TWIPS2 = 1440 / 96;
|
|
440140
441888
|
WORD_DEFAULT_TBL_LOOK2 = {
|