@extend-ai/react-docx 0.6.1 → 0.6.3
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.cjs +1104 -263
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1104 -263
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3864,10 +3864,14 @@ function parseParagraphRuns(paragraphXml2, context) {
|
|
|
3864
3864
|
}
|
|
3865
3865
|
}
|
|
3866
3866
|
});
|
|
3867
|
+
let hyperlinkRangeCursor = 0;
|
|
3867
3868
|
return runRanges.map((range, runIndex) => {
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3869
|
+
while (hyperlinkRangeCursor < hyperlinkRanges.length && hyperlinkRanges[hyperlinkRangeCursor].end <= range.start) {
|
|
3870
|
+
hyperlinkRangeCursor += 1;
|
|
3871
|
+
}
|
|
3872
|
+
const currentHyperlinkRange = hyperlinkRanges[hyperlinkRangeCursor];
|
|
3873
|
+
const hyperlinkHref = currentHyperlinkRange && range.start >= currentHyperlinkRange.start && range.end <= currentHyperlinkRange.end ? currentHyperlinkRange.href : void 0;
|
|
3874
|
+
const link = hyperlinkHref ?? fieldLinksByRun.get(runIndex);
|
|
3871
3875
|
return {
|
|
3872
3876
|
xml: paragraphXml2.slice(range.start, range.end),
|
|
3873
3877
|
start: range.start,
|
|
@@ -4463,9 +4467,14 @@ function parseParagraph(paragraphXml2, context) {
|
|
|
4463
4467
|
runs
|
|
4464
4468
|
);
|
|
4465
4469
|
const contentTokens = [];
|
|
4470
|
+
let formFieldTokenCursor = 0;
|
|
4466
4471
|
for (const run of runs) {
|
|
4467
|
-
|
|
4468
|
-
|
|
4472
|
+
while (formFieldTokenCursor < formFieldTokens.length && formFieldTokens[formFieldTokenCursor].end <= run.start) {
|
|
4473
|
+
formFieldTokenCursor += 1;
|
|
4474
|
+
}
|
|
4475
|
+
const currentFormFieldToken = formFieldTokens[formFieldTokenCursor];
|
|
4476
|
+
const insideFormField = Boolean(
|
|
4477
|
+
currentFormFieldToken && run.start >= currentFormFieldToken.start && run.end <= currentFormFieldToken.end
|
|
4469
4478
|
);
|
|
4470
4479
|
if (insideFormField) {
|
|
4471
4480
|
continue;
|
|
@@ -8880,6 +8889,9 @@ function paragraphHasExplicitPageBreak(paragraph) {
|
|
|
8880
8889
|
return sourceXml.length > 0 && PAGE_BREAK_XML_PATTERN.test(sourceXml);
|
|
8881
8890
|
}
|
|
8882
8891
|
function paragraphHasPageBreakBefore(paragraph) {
|
|
8892
|
+
if (paragraph.style?.pageBreakBefore === true) {
|
|
8893
|
+
return true;
|
|
8894
|
+
}
|
|
8883
8895
|
const sourceXml = paragraph.sourceXml ?? "";
|
|
8884
8896
|
if (!sourceXml) {
|
|
8885
8897
|
return false;
|
|
@@ -10269,6 +10281,8 @@ var LARGE_TABLE_PAGE_VIRTUALIZATION_OVERSCAN = 0;
|
|
|
10269
10281
|
var LARGE_TABLE_PAGE_ADJACENT_RENDER_COUNT = 1;
|
|
10270
10282
|
var DEFAULT_PAGE_VIRTUALIZATION_SETTLE_DELAY_MS = 350;
|
|
10271
10283
|
var ENABLE_TABLE_ROW_SLICING = true;
|
|
10284
|
+
var MIN_TABLE_ROW_SLICE_REMAINING_HEIGHT_PX = MIN_PARAGRAPH_LINE_HEIGHT_PX * 2;
|
|
10285
|
+
var TABLE_ROW_SLICE_BOUNDARY_TOLERANCE_PX = 2;
|
|
10272
10286
|
var TOP_AND_BOTTOM_VERTICAL_DRAG_SNAP_PX = 10;
|
|
10273
10287
|
var HEADER_FOOTER_INACTIVE_OPACITY = 0.5;
|
|
10274
10288
|
var LETTERHEAD_INDENT_MIN_TWIPS = 900;
|
|
@@ -10304,6 +10318,10 @@ var paragraphDropCapBySourceXml = /* @__PURE__ */ new Map();
|
|
|
10304
10318
|
var paragraphTrackedMarkupBySourceXml = /* @__PURE__ */ new Map();
|
|
10305
10319
|
var paragraphMeasureCanvasContext;
|
|
10306
10320
|
var textWidthByFontAndValue = /* @__PURE__ */ new Map();
|
|
10321
|
+
var estimatedTextAdvanceWidthByFontAndValue = /* @__PURE__ */ new Map();
|
|
10322
|
+
var pretextWordBreakModeByText = /* @__PURE__ */ new Map();
|
|
10323
|
+
var paragraphBaseFontSizePxByParagraph = /* @__PURE__ */ new WeakMap();
|
|
10324
|
+
var paragraphDominantFontFamilyByParagraph = /* @__PURE__ */ new WeakMap();
|
|
10307
10325
|
function setCacheEntry(cache, key, value) {
|
|
10308
10326
|
if (!cache.has(key) && cache.size >= XML_CACHE_MAX_ENTRIES) {
|
|
10309
10327
|
const oldestKey = cache.keys().next().value;
|
|
@@ -11767,7 +11785,23 @@ function resolvePageContentHeightPxForPageSegments(pageSegments, pageIndex, defa
|
|
|
11767
11785
|
);
|
|
11768
11786
|
}
|
|
11769
11787
|
function resolveRenderPageContentHeightPxForPageSegments(params) {
|
|
11770
|
-
const
|
|
11788
|
+
const firstNodeIndex = params.pageSegments[0]?.nodeIndex ?? 0;
|
|
11789
|
+
const metricsIndex = resolvePaginationSectionMetricsIndexForNodeIndex(
|
|
11790
|
+
params.metricsBySection,
|
|
11791
|
+
firstNodeIndex,
|
|
11792
|
+
0
|
|
11793
|
+
);
|
|
11794
|
+
const sectionHeightMultiplier = Math.max(
|
|
11795
|
+
1,
|
|
11796
|
+
Math.round(
|
|
11797
|
+
params.metricsBySection[metricsIndex]?.pageContentHeightMultiplier ?? 1
|
|
11798
|
+
)
|
|
11799
|
+
);
|
|
11800
|
+
const pageContainsOnlySplitParagraphSegments = documentPageContainsOnlySplitParagraphSegments(params.pageSegments);
|
|
11801
|
+
const measuredHeightPx = params.useMeasuredPageContentHeights === false ? void 0 : params.measuredPageContentHeightsPxByPageIndex?.[params.pageIndex];
|
|
11802
|
+
const measuredHeightMatchesCurrentPage = params.pageIdentityKey === void 0 || params.measuredPageContentIdentityKeysByPageIndex?.[params.pageIndex] === void 0 || params.measuredPageContentIdentityKeysByPageIndex?.[params.pageIndex] === params.pageIdentityKey;
|
|
11803
|
+
const usesMeasuredVisualHeight = Number.isFinite(measuredHeightPx) && measuredHeightMatchesCurrentPage && !pageContainsOnlySplitParagraphSegments;
|
|
11804
|
+
let resolvedHeightPx = resolvePageContentHeightPxForPageSegments(
|
|
11771
11805
|
params.pageSegments,
|
|
11772
11806
|
params.pageIndex,
|
|
11773
11807
|
params.defaultPageContentHeightPx,
|
|
@@ -11777,12 +11811,15 @@ function resolveRenderPageContentHeightPxForPageSegments(params) {
|
|
|
11777
11811
|
params.pageIdentityKey
|
|
11778
11812
|
);
|
|
11779
11813
|
if (params.useMeasuredPageContentHeights === false && Number.isFinite(params.pageContentHeightScale) && Math.abs(params.pageContentHeightScale - 1) >= 1e-3) {
|
|
11780
|
-
|
|
11814
|
+
resolvedHeightPx = Math.max(
|
|
11781
11815
|
120,
|
|
11782
11816
|
Math.round(resolvedHeightPx * params.pageContentHeightScale)
|
|
11783
11817
|
);
|
|
11784
11818
|
}
|
|
11785
|
-
|
|
11819
|
+
if (usesMeasuredVisualHeight || sectionHeightMultiplier <= 1) {
|
|
11820
|
+
return resolvedHeightPx;
|
|
11821
|
+
}
|
|
11822
|
+
return Math.max(120, Math.round(resolvedHeightPx / sectionHeightMultiplier));
|
|
11786
11823
|
}
|
|
11787
11824
|
function documentPageContainsOnlySplitParagraphSegments(pageSegments) {
|
|
11788
11825
|
return pageSegments.length > 0 && pageSegments.every(
|
|
@@ -12141,76 +12178,7 @@ var defaultStarterModel = {
|
|
|
12141
12178
|
nodes: [
|
|
12142
12179
|
{
|
|
12143
12180
|
type: "paragraph",
|
|
12144
|
-
|
|
12145
|
-
children: [
|
|
12146
|
-
{ type: "text", text: "React DOCX WYSIWYG", style: { bold: true } }
|
|
12147
|
-
]
|
|
12148
|
-
},
|
|
12149
|
-
{
|
|
12150
|
-
type: "paragraph",
|
|
12151
|
-
children: [
|
|
12152
|
-
{
|
|
12153
|
-
type: "text",
|
|
12154
|
-
text: "Import a .docx, edit styles from the toolbar, and export.",
|
|
12155
|
-
style: { highlight: "yellow" }
|
|
12156
|
-
}
|
|
12157
|
-
]
|
|
12158
|
-
},
|
|
12159
|
-
{
|
|
12160
|
-
type: "table",
|
|
12161
|
-
style: {
|
|
12162
|
-
borders: createDefaultEditorTableBorders()
|
|
12163
|
-
},
|
|
12164
|
-
rows: [
|
|
12165
|
-
{
|
|
12166
|
-
type: "table-row",
|
|
12167
|
-
cells: [
|
|
12168
|
-
{
|
|
12169
|
-
type: "table-cell",
|
|
12170
|
-
style: { backgroundColor: "#eef2ff" },
|
|
12171
|
-
nodes: [
|
|
12172
|
-
{
|
|
12173
|
-
type: "paragraph",
|
|
12174
|
-
children: [{ type: "text", text: "Header A" }]
|
|
12175
|
-
}
|
|
12176
|
-
]
|
|
12177
|
-
},
|
|
12178
|
-
{
|
|
12179
|
-
type: "table-cell",
|
|
12180
|
-
style: { backgroundColor: "#eef2ff" },
|
|
12181
|
-
nodes: [
|
|
12182
|
-
{
|
|
12183
|
-
type: "paragraph",
|
|
12184
|
-
children: [{ type: "text", text: "Header B" }]
|
|
12185
|
-
}
|
|
12186
|
-
]
|
|
12187
|
-
}
|
|
12188
|
-
]
|
|
12189
|
-
},
|
|
12190
|
-
{
|
|
12191
|
-
type: "table-row",
|
|
12192
|
-
cells: [
|
|
12193
|
-
{
|
|
12194
|
-
type: "table-cell",
|
|
12195
|
-
nodes: [
|
|
12196
|
-
{
|
|
12197
|
-
type: "paragraph",
|
|
12198
|
-
children: [{ type: "text", text: "Row 1" }]
|
|
12199
|
-
}
|
|
12200
|
-
]
|
|
12201
|
-
},
|
|
12202
|
-
{
|
|
12203
|
-
type: "table-cell",
|
|
12204
|
-
nodes: [
|
|
12205
|
-
{
|
|
12206
|
-
type: "paragraph",
|
|
12207
|
-
children: [{ type: "text", text: "Value" }]
|
|
12208
|
-
}
|
|
12209
|
-
]
|
|
12210
|
-
}
|
|
12211
|
-
]
|
|
12212
|
-
}
|
|
12213
|
-
]
|
|
12181
|
+
children: [{ type: "text", text: "" }]
|
|
12214
12182
|
}
|
|
12215
12183
|
],
|
|
12216
12184
|
metadata: {
|
|
@@ -12293,6 +12261,9 @@ var defaultStarterModel = {
|
|
|
12293
12261
|
defaultParagraphStyleId: "Normal"
|
|
12294
12262
|
}
|
|
12295
12263
|
};
|
|
12264
|
+
function createBlankDocumentModel() {
|
|
12265
|
+
return cloneDocModel(defaultStarterModel);
|
|
12266
|
+
}
|
|
12296
12267
|
function textRuns2(paragraph) {
|
|
12297
12268
|
return paragraph.children.filter(
|
|
12298
12269
|
(child) => child.type === "text"
|
|
@@ -12336,7 +12307,9 @@ function firstExplicitFontFamilyInNodeTree(nodes) {
|
|
|
12336
12307
|
if (node.type === "table") {
|
|
12337
12308
|
for (const row of node.rows) {
|
|
12338
12309
|
for (const cell of row.cells) {
|
|
12339
|
-
const nestedFontFamily = firstExplicitFontFamilyInNodeTree(
|
|
12310
|
+
const nestedFontFamily = firstExplicitFontFamilyInNodeTree(
|
|
12311
|
+
cell.nodes
|
|
12312
|
+
);
|
|
12340
12313
|
if (nestedFontFamily) {
|
|
12341
12314
|
return nestedFontFamily;
|
|
12342
12315
|
}
|
|
@@ -13242,11 +13215,19 @@ function buildParagraphPretextTabSpacerText(widthPx, style, paragraphBaseFontPx)
|
|
|
13242
13215
|
while (measuredWidthPx + spacerAdvancePx * 0.5 < safeWidthPx && spacerCount < 64) {
|
|
13243
13216
|
spacerCount += 1;
|
|
13244
13217
|
spacerText = spacerCharacter.repeat(spacerCount);
|
|
13245
|
-
measuredWidthPx = measureTextWidthPx2(
|
|
13218
|
+
measuredWidthPx = measureTextWidthPx2(
|
|
13219
|
+
spacerText,
|
|
13220
|
+
style,
|
|
13221
|
+
paragraphBaseFontPx
|
|
13222
|
+
);
|
|
13246
13223
|
}
|
|
13247
13224
|
while (spacerCount > 1) {
|
|
13248
13225
|
const nextText = spacerCharacter.repeat(spacerCount - 1);
|
|
13249
|
-
const nextWidthPx = measureTextWidthPx2(
|
|
13226
|
+
const nextWidthPx = measureTextWidthPx2(
|
|
13227
|
+
nextText,
|
|
13228
|
+
style,
|
|
13229
|
+
paragraphBaseFontPx
|
|
13230
|
+
);
|
|
13250
13231
|
if (Math.abs(nextWidthPx - safeWidthPx) >= Math.abs(measuredWidthPx - safeWidthPx)) {
|
|
13251
13232
|
break;
|
|
13252
13233
|
}
|
|
@@ -13537,7 +13518,20 @@ function buildSyntheticPretextLayoutSource(text, style) {
|
|
|
13537
13518
|
};
|
|
13538
13519
|
}
|
|
13539
13520
|
function pretextWordBreakModeForText(text) {
|
|
13540
|
-
|
|
13521
|
+
const cached = pretextWordBreakModeByText.get(text);
|
|
13522
|
+
if (cached) {
|
|
13523
|
+
return cached;
|
|
13524
|
+
}
|
|
13525
|
+
const mode = KEEP_ALL_SCRIPT_RE.test(text) ? "keep-all" : "normal";
|
|
13526
|
+
setCacheEntry(pretextWordBreakModeByText, text, mode);
|
|
13527
|
+
while (pretextWordBreakModeByText.size > TEXT_MEASURE_CACHE_MAX_ENTRIES) {
|
|
13528
|
+
const firstKey = pretextWordBreakModeByText.keys().next().value;
|
|
13529
|
+
if (!firstKey) {
|
|
13530
|
+
break;
|
|
13531
|
+
}
|
|
13532
|
+
pretextWordBreakModeByText.delete(firstKey);
|
|
13533
|
+
}
|
|
13534
|
+
return mode;
|
|
13541
13535
|
}
|
|
13542
13536
|
function sanitizeRenderedPretextFragmentText(text) {
|
|
13543
13537
|
return text.replace(/\r\n?|\n/g, "");
|
|
@@ -14021,36 +14015,55 @@ function estimateTextAdvanceWidthPx(text, style) {
|
|
|
14021
14015
|
if (!text) {
|
|
14022
14016
|
return 0;
|
|
14023
14017
|
}
|
|
14024
|
-
const normalized = text.replace(/\u00a0/g, " ");
|
|
14025
14018
|
const fontSizePx = runFontSizePx(style);
|
|
14019
|
+
const normalized = text.includes("\xA0") ? text.replace(/\u00a0/g, " ") : text;
|
|
14020
|
+
const cacheKey = `${fontSizePx}\0${normalized}`;
|
|
14021
|
+
const cached = estimatedTextAdvanceWidthByFontAndValue.get(cacheKey);
|
|
14022
|
+
if (cached !== void 0) {
|
|
14023
|
+
return cached;
|
|
14024
|
+
}
|
|
14026
14025
|
let total = 0;
|
|
14027
|
-
for (
|
|
14028
|
-
|
|
14026
|
+
for (let index = 0; index < normalized.length; index += 1) {
|
|
14027
|
+
const code = normalized.charCodeAt(index);
|
|
14028
|
+
if (code === 10 || code === 13) {
|
|
14029
14029
|
continue;
|
|
14030
14030
|
}
|
|
14031
|
-
if (
|
|
14031
|
+
if (code === 9) {
|
|
14032
14032
|
total += fontSizePx * 2;
|
|
14033
14033
|
continue;
|
|
14034
14034
|
}
|
|
14035
|
-
if (
|
|
14035
|
+
if (code === 32) {
|
|
14036
14036
|
total += fontSizePx * 0.33;
|
|
14037
14037
|
continue;
|
|
14038
14038
|
}
|
|
14039
|
-
if (
|
|
14039
|
+
if (code === 33 || code === 39 || code === 44 || code === 46 || code === 49 || code === 58 || code === 59 || code === 73 || code === 96 || code === 105 || code === 108 || code === 124) {
|
|
14040
14040
|
total += fontSizePx * 0.29;
|
|
14041
14041
|
continue;
|
|
14042
14042
|
}
|
|
14043
|
-
if (
|
|
14043
|
+
if (code >= 65 && code <= 90 || code >= 48 && code <= 57) {
|
|
14044
14044
|
total += fontSizePx * 0.6;
|
|
14045
14045
|
continue;
|
|
14046
14046
|
}
|
|
14047
|
-
if (
|
|
14047
|
+
if (code >= 12288 && code <= 40959) {
|
|
14048
14048
|
total += fontSizePx * 0.95;
|
|
14049
14049
|
continue;
|
|
14050
14050
|
}
|
|
14051
14051
|
total += fontSizePx * 0.54;
|
|
14052
14052
|
}
|
|
14053
|
-
|
|
14053
|
+
const estimatedWidthPx = Math.max(0, Math.round(total));
|
|
14054
|
+
setCacheEntry(
|
|
14055
|
+
estimatedTextAdvanceWidthByFontAndValue,
|
|
14056
|
+
cacheKey,
|
|
14057
|
+
estimatedWidthPx
|
|
14058
|
+
);
|
|
14059
|
+
while (estimatedTextAdvanceWidthByFontAndValue.size > TEXT_MEASURE_CACHE_MAX_ENTRIES) {
|
|
14060
|
+
const firstKey = estimatedTextAdvanceWidthByFontAndValue.keys().next().value;
|
|
14061
|
+
if (!firstKey) {
|
|
14062
|
+
break;
|
|
14063
|
+
}
|
|
14064
|
+
estimatedTextAdvanceWidthByFontAndValue.delete(firstKey);
|
|
14065
|
+
}
|
|
14066
|
+
return estimatedWidthPx;
|
|
14054
14067
|
}
|
|
14055
14068
|
function updateEstimatedLineWidthPxForText(currentLineWidthPx, text, style) {
|
|
14056
14069
|
if (!text) {
|
|
@@ -14356,7 +14369,8 @@ function paragraphHasLastRenderedPageBreak(paragraph) {
|
|
|
14356
14369
|
if (cached) {
|
|
14357
14370
|
return cached.lastRenderedPageBreak;
|
|
14358
14371
|
}
|
|
14359
|
-
|
|
14372
|
+
paragraphHasExplicitPageBreak2(paragraph);
|
|
14373
|
+
return paragraphBreakFlagsBySourceXml.get(xml)?.lastRenderedPageBreak ?? false;
|
|
14360
14374
|
}
|
|
14361
14375
|
function paragraphStartsWithLastRenderedPageBreak(paragraph) {
|
|
14362
14376
|
const xml = paragraph.sourceXml ?? "";
|
|
@@ -14530,7 +14544,8 @@ function paragraphHasPageBreakBefore2(paragraph) {
|
|
|
14530
14544
|
if (cached) {
|
|
14531
14545
|
return cached.pageBreakBefore;
|
|
14532
14546
|
}
|
|
14533
|
-
|
|
14547
|
+
paragraphHasExplicitPageBreak2(paragraph);
|
|
14548
|
+
return paragraphBreakFlagsBySourceXml.get(xml)?.pageBreakBefore ?? false;
|
|
14534
14549
|
}
|
|
14535
14550
|
function sectionBreakAfterParagraphStartsNewPage(paragraph) {
|
|
14536
14551
|
const xml = paragraph.sourceXml ?? "";
|
|
@@ -14710,9 +14725,15 @@ function paragraphDominantFontSizePt(paragraph) {
|
|
|
14710
14725
|
return dominantFontSizePt;
|
|
14711
14726
|
}
|
|
14712
14727
|
function paragraphBaseFontSizePx(paragraph) {
|
|
14728
|
+
const cached = paragraphBaseFontSizePxByParagraph.get(paragraph);
|
|
14729
|
+
if (cached !== void 0) {
|
|
14730
|
+
return cached;
|
|
14731
|
+
}
|
|
14713
14732
|
const dominantRunFontSizePt = paragraphDominantFontSizePt(paragraph);
|
|
14714
14733
|
const fontSizePt = dominantRunFontSizePt && dominantRunFontSizePt > 0 ? dominantRunFontSizePt : Number.isFinite(paragraph.style?.headingLevel) ? DEFAULT_PARAGRAPH_FONT_SIZE_PT + Math.max(0, 6 - (paragraph.style?.headingLevel ?? 6)) : DEFAULT_PARAGRAPH_FONT_SIZE_PT;
|
|
14715
|
-
|
|
14734
|
+
const baseFontSizePx = Math.max(10, Math.round(fontSizePt * 96 / 72));
|
|
14735
|
+
paragraphBaseFontSizePxByParagraph.set(paragraph, baseFontSizePx);
|
|
14736
|
+
return baseFontSizePx;
|
|
14716
14737
|
}
|
|
14717
14738
|
function paragraphMaxFontSizePx(paragraph) {
|
|
14718
14739
|
const paragraphBaseFontPx = paragraphBaseFontSizePx(paragraph);
|
|
@@ -14737,6 +14758,10 @@ function normalizeFontFamilyToken(fontFamily) {
|
|
|
14737
14758
|
return normalized || void 0;
|
|
14738
14759
|
}
|
|
14739
14760
|
function paragraphDominantFontFamily(paragraph) {
|
|
14761
|
+
const cached = paragraphDominantFontFamilyByParagraph.get(paragraph);
|
|
14762
|
+
if (cached !== void 0) {
|
|
14763
|
+
return cached ?? void 0;
|
|
14764
|
+
}
|
|
14740
14765
|
const weightByFamily = /* @__PURE__ */ new Map();
|
|
14741
14766
|
const addWeight = (fontFamily, weight) => {
|
|
14742
14767
|
const normalizedFamily = normalizeFontFamilyToken(fontFamily);
|
|
@@ -14757,6 +14782,7 @@ function paragraphDominantFontFamily(paragraph) {
|
|
|
14757
14782
|
addWeight(child.style?.fontFamily, text.length);
|
|
14758
14783
|
});
|
|
14759
14784
|
if (weightByFamily.size === 0) {
|
|
14785
|
+
paragraphDominantFontFamilyByParagraph.set(paragraph, null);
|
|
14760
14786
|
return void 0;
|
|
14761
14787
|
}
|
|
14762
14788
|
let dominantFamily;
|
|
@@ -14767,6 +14793,7 @@ function paragraphDominantFontFamily(paragraph) {
|
|
|
14767
14793
|
dominantWeight = weight;
|
|
14768
14794
|
}
|
|
14769
14795
|
}
|
|
14796
|
+
paragraphDominantFontFamilyByParagraph.set(paragraph, dominantFamily ?? null);
|
|
14770
14797
|
return dominantFamily;
|
|
14771
14798
|
}
|
|
14772
14799
|
function singleLineAutoScaleForFontFamily(fontFamily) {
|
|
@@ -15856,6 +15883,11 @@ function rowHasDeepFlowContent(row) {
|
|
|
15856
15883
|
}
|
|
15857
15884
|
return nestedTableCount > 0 || blockNodeCount >= SPLITTABLE_TABLE_ROW_DEEP_CONTENT_NODE_THRESHOLD;
|
|
15858
15885
|
}
|
|
15886
|
+
function rowHasNestedTableContent(row) {
|
|
15887
|
+
return row.cells.some(
|
|
15888
|
+
(cell) => cell.nodes.some((contentNode) => contentNode.type === "table")
|
|
15889
|
+
);
|
|
15890
|
+
}
|
|
15859
15891
|
function capSplitFriendlyTableRowEstimatePx(row, estimatedRowHeightPx, explicitHeightPx, pageContentHeightPx) {
|
|
15860
15892
|
if (!rowAllowsPageSplit(row)) {
|
|
15861
15893
|
return estimatedRowHeightPx;
|
|
@@ -15989,6 +16021,280 @@ function estimateTableRowHeightsPx(table, maxAvailableWidthPx, numberingDefiniti
|
|
|
15989
16021
|
return Math.max(MIN_PARAGRAPH_LINE_HEIGHT_PX, rowHeightPx);
|
|
15990
16022
|
});
|
|
15991
16023
|
}
|
|
16024
|
+
function uniqueSortedPixelBoundaries(values) {
|
|
16025
|
+
const sorted = values.filter((value) => Number.isFinite(value)).map((value) => Math.max(0, Math.round(value))).sort((left, right) => left - right);
|
|
16026
|
+
const unique = [];
|
|
16027
|
+
for (const value of sorted) {
|
|
16028
|
+
const previous = unique[unique.length - 1];
|
|
16029
|
+
if (previous === void 0 || Math.abs(previous - value) > TABLE_ROW_SLICE_BOUNDARY_TOLERANCE_PX) {
|
|
16030
|
+
unique.push(value);
|
|
16031
|
+
}
|
|
16032
|
+
}
|
|
16033
|
+
return unique;
|
|
16034
|
+
}
|
|
16035
|
+
function estimateParagraphBoundaryOffsetsPx(paragraph, availableWidthPx, numberingDefinitions, applyWordTableDefaults, docGridLinePitchPx, paragraphIndex) {
|
|
16036
|
+
const paragraphForLayout = wordLikeTableCellParagraph(
|
|
16037
|
+
paragraph,
|
|
16038
|
+
applyWordTableDefaults
|
|
16039
|
+
);
|
|
16040
|
+
const disableDocGridSnap = paragraphDocGridSnapState(paragraph) === "disable";
|
|
16041
|
+
const paragraphHeightPx = estimateParagraphHeightPx(
|
|
16042
|
+
paragraphForLayout,
|
|
16043
|
+
availableWidthPx,
|
|
16044
|
+
numberingDefinitions,
|
|
16045
|
+
docGridLinePitchPx,
|
|
16046
|
+
disableDocGridSnap
|
|
16047
|
+
);
|
|
16048
|
+
const suppressTopSpacing = paragraphIndex === 0 && suppressFirstTableCellParagraphTopSpacing(paragraph);
|
|
16049
|
+
const beforeSpacingPx = suppressTopSpacing ? 0 : twipsToPixels(paragraphForLayout.style?.spacing?.beforeTwips) ?? 0;
|
|
16050
|
+
const afterSpacingPx = twipsToPixels(paragraphForLayout.style?.spacing?.afterTwips) ?? 0;
|
|
16051
|
+
const topBorderInsetPx = paragraphBorderInsetPx(
|
|
16052
|
+
paragraphForLayout.style?.borders?.top
|
|
16053
|
+
);
|
|
16054
|
+
const bottomBorderInsetPx = paragraphBorderInsetPx(
|
|
16055
|
+
paragraphForLayout.style?.borders?.bottom
|
|
16056
|
+
);
|
|
16057
|
+
const lineHeightPx = Math.max(
|
|
16058
|
+
MIN_PARAGRAPH_LINE_HEIGHT_PX,
|
|
16059
|
+
estimateParagraphLineHeightPx(
|
|
16060
|
+
paragraphForLayout,
|
|
16061
|
+
docGridLinePitchPx,
|
|
16062
|
+
disableDocGridSnap
|
|
16063
|
+
)
|
|
16064
|
+
);
|
|
16065
|
+
const pretextSource = buildParagraphPretextLayoutSource(paragraphForLayout, {
|
|
16066
|
+
allowExplicitLineBreakText: true,
|
|
16067
|
+
expandTabsForLayout: true
|
|
16068
|
+
});
|
|
16069
|
+
const paragraphTextWidthPx = paragraphAvailableTextWidthPx(
|
|
16070
|
+
paragraphForLayout,
|
|
16071
|
+
availableWidthPx,
|
|
16072
|
+
numberingDefinitions
|
|
16073
|
+
);
|
|
16074
|
+
const pretextLayout = pretextSource ? layoutParagraphPretextSource(
|
|
16075
|
+
paragraphForLayout,
|
|
16076
|
+
pretextSource,
|
|
16077
|
+
paragraphTextWidthPx,
|
|
16078
|
+
lineHeightPx,
|
|
16079
|
+
[]
|
|
16080
|
+
) : void 0;
|
|
16081
|
+
const lineTopOffsetsPx = pretextLayout ? pretextLayout.lines.map((line) => Math.max(0, Math.round(line.y))) : Array.from(
|
|
16082
|
+
{
|
|
16083
|
+
length: Math.max(
|
|
16084
|
+
1,
|
|
16085
|
+
paragraphLineCountWithinWidth(
|
|
16086
|
+
paragraphForLayout,
|
|
16087
|
+
availableWidthPx,
|
|
16088
|
+
numberingDefinitions
|
|
16089
|
+
)
|
|
16090
|
+
)
|
|
16091
|
+
},
|
|
16092
|
+
(_, lineIndex) => lineIndex * lineHeightPx
|
|
16093
|
+
);
|
|
16094
|
+
const textTopPx = beforeSpacingPx + topBorderInsetPx;
|
|
16095
|
+
const textHeightPx = pretextLayout ? wrappedPretextParagraphBlockHeightPx(pretextLayout) : lineTopOffsetsPx.length * lineHeightPx;
|
|
16096
|
+
const visualHeightPx = Math.max(
|
|
16097
|
+
1,
|
|
16098
|
+
beforeSpacingPx + topBorderInsetPx + textHeightPx + bottomBorderInsetPx + afterSpacingPx
|
|
16099
|
+
);
|
|
16100
|
+
const heightPx = Math.max(1, paragraphHeightPx, visualHeightPx);
|
|
16101
|
+
const lineBoundariesPx = lineTopOffsetsPx.map(
|
|
16102
|
+
(lineTopPx) => textTopPx + lineTopPx + lineHeightPx
|
|
16103
|
+
);
|
|
16104
|
+
return {
|
|
16105
|
+
heightPx,
|
|
16106
|
+
safeBoundariesPx: uniqueSortedPixelBoundaries([
|
|
16107
|
+
...lineBoundariesPx,
|
|
16108
|
+
heightPx
|
|
16109
|
+
])
|
|
16110
|
+
};
|
|
16111
|
+
}
|
|
16112
|
+
function estimateNestedTableBoundaryOffsetsPx(table, availableWidthPx, numberingDefinitions, docGridLinePitchPx) {
|
|
16113
|
+
const rowHeightsPx = estimateTableRowHeightsPx(
|
|
16114
|
+
table,
|
|
16115
|
+
availableWidthPx,
|
|
16116
|
+
numberingDefinitions,
|
|
16117
|
+
docGridLinePitchPx
|
|
16118
|
+
);
|
|
16119
|
+
const boundariesPx = [];
|
|
16120
|
+
let cursorPx = 0;
|
|
16121
|
+
for (const rowHeightPx of rowHeightsPx) {
|
|
16122
|
+
cursorPx += Math.max(MIN_PARAGRAPH_LINE_HEIGHT_PX, rowHeightPx);
|
|
16123
|
+
boundariesPx.push(cursorPx);
|
|
16124
|
+
}
|
|
16125
|
+
return {
|
|
16126
|
+
heightPx: Math.max(MIN_PARAGRAPH_LINE_HEIGHT_PX, cursorPx),
|
|
16127
|
+
safeBoundariesPx: uniqueSortedPixelBoundaries(boundariesPx)
|
|
16128
|
+
};
|
|
16129
|
+
}
|
|
16130
|
+
function estimateTableCellSliceBoundaryLayoutPx(params) {
|
|
16131
|
+
const {
|
|
16132
|
+
cell,
|
|
16133
|
+
rowHeightPx,
|
|
16134
|
+
contentWidthPx,
|
|
16135
|
+
tableCellMarginTwips,
|
|
16136
|
+
numberingDefinitions,
|
|
16137
|
+
applyWordTableDefaults,
|
|
16138
|
+
docGridLinePitchPx
|
|
16139
|
+
} = params;
|
|
16140
|
+
const paddingPx = resolveTableSpacingPaddingPx(
|
|
16141
|
+
mergeTableSpacing(tableCellMarginTwips, cell.style?.marginTwips)
|
|
16142
|
+
);
|
|
16143
|
+
const localBoundariesPx = [0, paddingPx.top];
|
|
16144
|
+
let contentCursorPx = paddingPx.top;
|
|
16145
|
+
let paragraphIndex = 0;
|
|
16146
|
+
for (const contentNode of cell.nodes) {
|
|
16147
|
+
const layout = contentNode.type === "paragraph" ? estimateParagraphBoundaryOffsetsPx(
|
|
16148
|
+
contentNode,
|
|
16149
|
+
contentWidthPx,
|
|
16150
|
+
numberingDefinitions,
|
|
16151
|
+
applyWordTableDefaults,
|
|
16152
|
+
docGridLinePitchPx,
|
|
16153
|
+
paragraphIndex++
|
|
16154
|
+
) : estimateNestedTableBoundaryOffsetsPx(
|
|
16155
|
+
contentNode,
|
|
16156
|
+
contentWidthPx,
|
|
16157
|
+
numberingDefinitions,
|
|
16158
|
+
docGridLinePitchPx
|
|
16159
|
+
);
|
|
16160
|
+
localBoundariesPx.push(
|
|
16161
|
+
...layout.safeBoundariesPx.map(
|
|
16162
|
+
(boundaryPx) => contentCursorPx + boundaryPx
|
|
16163
|
+
)
|
|
16164
|
+
);
|
|
16165
|
+
contentCursorPx += layout.heightPx;
|
|
16166
|
+
}
|
|
16167
|
+
const contentBottomPx = contentCursorPx + paddingPx.bottom;
|
|
16168
|
+
const contentFlowHeightPx = Math.max(0, contentCursorPx - paddingPx.top);
|
|
16169
|
+
const availableContentHeightPx = Math.max(
|
|
16170
|
+
0,
|
|
16171
|
+
rowHeightPx - paddingPx.top - paddingPx.bottom
|
|
16172
|
+
);
|
|
16173
|
+
const extraVerticalSpacePx = Math.max(
|
|
16174
|
+
0,
|
|
16175
|
+
availableContentHeightPx - contentFlowHeightPx
|
|
16176
|
+
);
|
|
16177
|
+
const verticalOffsetPx = cell.style?.verticalAlign === "center" ? Math.round(extraVerticalSpacePx / 2) : cell.style?.verticalAlign === "bottom" ? extraVerticalSpacePx : 0;
|
|
16178
|
+
return {
|
|
16179
|
+
safeBoundariesPx: uniqueSortedPixelBoundaries(
|
|
16180
|
+
localBoundariesPx.map(
|
|
16181
|
+
(boundaryPx) => Math.min(rowHeightPx, boundaryPx + verticalOffsetPx)
|
|
16182
|
+
)
|
|
16183
|
+
),
|
|
16184
|
+
contentBottomPx: Math.min(rowHeightPx, contentBottomPx + verticalOffsetPx)
|
|
16185
|
+
};
|
|
16186
|
+
}
|
|
16187
|
+
function tableCellSliceBoundaryIsSafe(layout, boundaryPx) {
|
|
16188
|
+
if (boundaryPx <= TABLE_ROW_SLICE_BOUNDARY_TOLERANCE_PX) {
|
|
16189
|
+
return true;
|
|
16190
|
+
}
|
|
16191
|
+
if (boundaryPx >= layout.contentBottomPx - TABLE_ROW_SLICE_BOUNDARY_TOLERANCE_PX) {
|
|
16192
|
+
return true;
|
|
16193
|
+
}
|
|
16194
|
+
return layout.safeBoundariesPx.some(
|
|
16195
|
+
(safeBoundaryPx) => Math.abs(safeBoundaryPx - boundaryPx) <= TABLE_ROW_SLICE_BOUNDARY_TOLERANCE_PX
|
|
16196
|
+
);
|
|
16197
|
+
}
|
|
16198
|
+
function resolveTableRowSliceHeightOnSafeBoundaryPx(params) {
|
|
16199
|
+
const {
|
|
16200
|
+
table,
|
|
16201
|
+
rowIndex,
|
|
16202
|
+
rowHeightPx,
|
|
16203
|
+
rowSliceOffsetPx,
|
|
16204
|
+
preferredSliceHeightPx,
|
|
16205
|
+
maxAvailableWidthPx,
|
|
16206
|
+
numberingDefinitions,
|
|
16207
|
+
docGridLinePitchPx
|
|
16208
|
+
} = params;
|
|
16209
|
+
const row = table.rows[rowIndex];
|
|
16210
|
+
if (!row || !rowHasNestedTableContent(row)) {
|
|
16211
|
+
return preferredSliceHeightPx;
|
|
16212
|
+
}
|
|
16213
|
+
const sliceStartPx = Math.max(0, Math.round(rowSliceOffsetPx));
|
|
16214
|
+
const preferredSliceEndPx = Math.min(
|
|
16215
|
+
rowHeightPx,
|
|
16216
|
+
sliceStartPx + Math.max(0, Math.round(preferredSliceHeightPx))
|
|
16217
|
+
);
|
|
16218
|
+
if (preferredSliceEndPx >= rowHeightPx - TABLE_ROW_SLICE_BOUNDARY_TOLERANCE_PX) {
|
|
16219
|
+
return Math.max(0, rowHeightPx - sliceStartPx);
|
|
16220
|
+
}
|
|
16221
|
+
const columnCount = tableColumnCount(table);
|
|
16222
|
+
const tableWidthPx = twipsToPixels(table.style?.widthTwips);
|
|
16223
|
+
const rawTableColumnWidthsPx = (() => {
|
|
16224
|
+
const definedWidthsTwips = columnWidthsFromTableDefinition(
|
|
16225
|
+
table,
|
|
16226
|
+
columnCount
|
|
16227
|
+
);
|
|
16228
|
+
if (!definedWidthsTwips || definedWidthsTwips.length === 0) {
|
|
16229
|
+
return defaultColumnWidthsPx(columnCount, tableWidthPx);
|
|
16230
|
+
}
|
|
16231
|
+
const widthsPx = definedWidthsTwips.map(
|
|
16232
|
+
(widthTwips) => twipsToPixels(widthTwips) ?? 0
|
|
16233
|
+
);
|
|
16234
|
+
return normalizeColumnWidthsPx(widthsPx, columnCount, tableWidthPx, 1);
|
|
16235
|
+
})();
|
|
16236
|
+
const rawResolvedTableWidthPx = tableWidthPx ?? rawTableColumnWidthsPx.reduce((sum, widthPx) => sum + widthPx, 0);
|
|
16237
|
+
const collapsedHorizontalBorderBleedPx = resolveCollapsedTableHorizontalOuterBleedPx(table, columnCount);
|
|
16238
|
+
const maxTableWidthPx = Number.isFinite(maxAvailableWidthPx) && maxAvailableWidthPx > 0 ? Math.max(
|
|
16239
|
+
120,
|
|
16240
|
+
maxAvailableWidthPx - collapsedHorizontalBorderBleedPx
|
|
16241
|
+
) : void 0;
|
|
16242
|
+
const resolvedTableWidthPx = clampTableWidthPx(
|
|
16243
|
+
rawResolvedTableWidthPx,
|
|
16244
|
+
maxTableWidthPx
|
|
16245
|
+
);
|
|
16246
|
+
const tableColumnWidthsPx = fitColumnWidthsToWidth(
|
|
16247
|
+
rawTableColumnWidthsPx,
|
|
16248
|
+
resolvedTableWidthPx
|
|
16249
|
+
);
|
|
16250
|
+
const applyWordTableDefaults = tableUsesWordLikeParagraphDefaults(table);
|
|
16251
|
+
const tableCellMarginTwips = table.style?.cellMarginTwips;
|
|
16252
|
+
const cellLayouts = [];
|
|
16253
|
+
const candidateBoundariesPx = [preferredSliceEndPx];
|
|
16254
|
+
let columnCursor = 0;
|
|
16255
|
+
for (const cell of row.cells) {
|
|
16256
|
+
const colSpanValue = cell.style?.gridSpan && cell.style.gridSpan > 1 ? cell.style.gridSpan : 1;
|
|
16257
|
+
const startColumnIndex = columnCursor;
|
|
16258
|
+
const endColumnIndex = Math.min(
|
|
16259
|
+
columnCount - 1,
|
|
16260
|
+
startColumnIndex + colSpanValue - 1
|
|
16261
|
+
);
|
|
16262
|
+
columnCursor += colSpanValue;
|
|
16263
|
+
const spannedWidthPx = tableColumnWidthsPx.slice(startColumnIndex, endColumnIndex + 1).reduce((sum, widthPx) => sum + widthPx, 0);
|
|
16264
|
+
const fallbackCellWidthPx = resolvedTableWidthPx / Math.max(1, columnCount) * colSpanValue;
|
|
16265
|
+
const cellRenderedWidthPx = twipsToPixels(cell.style?.widthTwips) ?? (spannedWidthPx > 0 ? spannedWidthPx : fallbackCellWidthPx);
|
|
16266
|
+
const cellPaddingPx = resolveTableSpacingPaddingPx(
|
|
16267
|
+
mergeTableSpacing(tableCellMarginTwips, cell.style?.marginTwips)
|
|
16268
|
+
);
|
|
16269
|
+
const cellContentWidthPx = Math.max(
|
|
16270
|
+
1,
|
|
16271
|
+
cellRenderedWidthPx - cellPaddingPx.left - cellPaddingPx.right
|
|
16272
|
+
);
|
|
16273
|
+
const cellLayout = estimateTableCellSliceBoundaryLayoutPx({
|
|
16274
|
+
cell,
|
|
16275
|
+
rowHeightPx,
|
|
16276
|
+
contentWidthPx: cellContentWidthPx,
|
|
16277
|
+
tableCellMarginTwips,
|
|
16278
|
+
numberingDefinitions,
|
|
16279
|
+
applyWordTableDefaults,
|
|
16280
|
+
docGridLinePitchPx
|
|
16281
|
+
});
|
|
16282
|
+
cellLayouts.push(cellLayout);
|
|
16283
|
+
candidateBoundariesPx.push(...cellLayout.safeBoundariesPx);
|
|
16284
|
+
}
|
|
16285
|
+
const minimumSliceEndPx = sliceStartPx + Math.max(1, MIN_TABLE_ROW_SLICE_REMAINING_HEIGHT_PX);
|
|
16286
|
+
const candidatesPx = uniqueSortedPixelBoundaries(candidateBoundariesPx).filter(
|
|
16287
|
+
(boundaryPx) => boundaryPx >= minimumSliceEndPx && boundaryPx <= preferredSliceEndPx + TABLE_ROW_SLICE_BOUNDARY_TOLERANCE_PX
|
|
16288
|
+
).sort((left, right) => right - left);
|
|
16289
|
+
for (const candidatePx of candidatesPx) {
|
|
16290
|
+
if (cellLayouts.every(
|
|
16291
|
+
(layout) => tableCellSliceBoundaryIsSafe(layout, candidatePx)
|
|
16292
|
+
)) {
|
|
16293
|
+
return Math.max(0, candidatePx - sliceStartPx);
|
|
16294
|
+
}
|
|
16295
|
+
}
|
|
16296
|
+
return void 0;
|
|
16297
|
+
}
|
|
15992
16298
|
function estimateTableHeightPx(table, maxAvailableWidthPx, numberingDefinitions, docGridLinePitchPx) {
|
|
15993
16299
|
const sourceXml = table.sourceXml;
|
|
15994
16300
|
const widthKey = heightEstimateCacheKeyPx(
|
|
@@ -16277,6 +16583,234 @@ function estimateRenderedPageSegmentHeightPx(node, segment, model, availableWidt
|
|
|
16277
16583
|
)
|
|
16278
16584
|
);
|
|
16279
16585
|
}
|
|
16586
|
+
function resolveParagraphColumnRenderLineRange(paragraph, segment, availableWidthPx, numberingDefinitions, docGridLinePitchPx) {
|
|
16587
|
+
const lineHeightPx = Math.max(
|
|
16588
|
+
1,
|
|
16589
|
+
segment.paragraphLineRange?.lineHeightPx ?? estimateParagraphLineHeightPx(paragraph, docGridLinePitchPx)
|
|
16590
|
+
);
|
|
16591
|
+
if (segment.paragraphLineRange) {
|
|
16592
|
+
return {
|
|
16593
|
+
...segment.paragraphLineRange,
|
|
16594
|
+
lineHeightPx
|
|
16595
|
+
};
|
|
16596
|
+
}
|
|
16597
|
+
const paragraphTextWidthPx = paragraphAvailableTextWidthPx(
|
|
16598
|
+
paragraph,
|
|
16599
|
+
availableWidthPx,
|
|
16600
|
+
numberingDefinitions
|
|
16601
|
+
);
|
|
16602
|
+
const pretextSource = buildParagraphPretextLayoutSource(paragraph, {
|
|
16603
|
+
allowExplicitLineBreakText: true,
|
|
16604
|
+
expandTabsForLayout: true
|
|
16605
|
+
});
|
|
16606
|
+
const pretextLayout = pretextSource ? layoutParagraphPretextSource(
|
|
16607
|
+
paragraph,
|
|
16608
|
+
pretextSource,
|
|
16609
|
+
paragraphTextWidthPx,
|
|
16610
|
+
lineHeightPx,
|
|
16611
|
+
[]
|
|
16612
|
+
) : void 0;
|
|
16613
|
+
const totalLineCount = pretextLayout && pretextLayout.lineCount > 0 ? pretextLayout.lineCount : paragraphLineCountWithinWidth(
|
|
16614
|
+
paragraph,
|
|
16615
|
+
availableWidthPx,
|
|
16616
|
+
numberingDefinitions
|
|
16617
|
+
);
|
|
16618
|
+
return {
|
|
16619
|
+
startLineIndex: 0,
|
|
16620
|
+
endLineIndex: Math.max(1, totalLineCount),
|
|
16621
|
+
totalLineCount: Math.max(1, totalLineCount),
|
|
16622
|
+
lineHeightPx
|
|
16623
|
+
};
|
|
16624
|
+
}
|
|
16625
|
+
function splitParagraphSegmentForColumnRender(params) {
|
|
16626
|
+
const {
|
|
16627
|
+
paragraph,
|
|
16628
|
+
segment,
|
|
16629
|
+
model,
|
|
16630
|
+
availableWidthPx,
|
|
16631
|
+
availableHeightPx,
|
|
16632
|
+
numberingDefinitions,
|
|
16633
|
+
docGridLinePitchPx
|
|
16634
|
+
} = params;
|
|
16635
|
+
if (segment.tableRowRange || segment.tableRowSlice || paragraphHasExplicitColumnBreak(paragraph)) {
|
|
16636
|
+
return void 0;
|
|
16637
|
+
}
|
|
16638
|
+
const fullLineRange = resolveParagraphColumnRenderLineRange(
|
|
16639
|
+
paragraph,
|
|
16640
|
+
segment,
|
|
16641
|
+
availableWidthPx,
|
|
16642
|
+
numberingDefinitions,
|
|
16643
|
+
docGridLinePitchPx
|
|
16644
|
+
);
|
|
16645
|
+
const startLineIndex = Math.max(0, fullLineRange.startLineIndex);
|
|
16646
|
+
const endLineIndex = Math.max(startLineIndex, fullLineRange.endLineIndex);
|
|
16647
|
+
if (endLineIndex - startLineIndex < 2 || !paragraphCanSplitAcrossPages(paragraph, fullLineRange.totalLineCount)) {
|
|
16648
|
+
return void 0;
|
|
16649
|
+
}
|
|
16650
|
+
const safeAvailableHeightPx = Math.max(0, Math.round(availableHeightPx));
|
|
16651
|
+
let bestSegment;
|
|
16652
|
+
let bestHeightPx = 0;
|
|
16653
|
+
for (let candidateEndLineIndex = startLineIndex + 1; candidateEndLineIndex < endLineIndex; candidateEndLineIndex += 1) {
|
|
16654
|
+
const candidateSegment = {
|
|
16655
|
+
...segment,
|
|
16656
|
+
paragraphLineRange: {
|
|
16657
|
+
startLineIndex,
|
|
16658
|
+
endLineIndex: candidateEndLineIndex,
|
|
16659
|
+
totalLineCount: fullLineRange.totalLineCount,
|
|
16660
|
+
lineHeightPx: fullLineRange.lineHeightPx
|
|
16661
|
+
}
|
|
16662
|
+
};
|
|
16663
|
+
const candidateHeightPx = estimateRenderedPageSegmentHeightPx(
|
|
16664
|
+
paragraph,
|
|
16665
|
+
candidateSegment,
|
|
16666
|
+
model,
|
|
16667
|
+
availableWidthPx,
|
|
16668
|
+
numberingDefinitions,
|
|
16669
|
+
docGridLinePitchPx
|
|
16670
|
+
);
|
|
16671
|
+
if (candidateHeightPx > safeAvailableHeightPx + PAGE_OVERFLOW_TOLERANCE_PX) {
|
|
16672
|
+
break;
|
|
16673
|
+
}
|
|
16674
|
+
bestSegment = candidateSegment;
|
|
16675
|
+
bestHeightPx = candidateHeightPx;
|
|
16676
|
+
}
|
|
16677
|
+
if (!bestSegment?.paragraphLineRange) {
|
|
16678
|
+
return void 0;
|
|
16679
|
+
}
|
|
16680
|
+
return {
|
|
16681
|
+
currentSegment: bestSegment,
|
|
16682
|
+
currentHeightPx: bestHeightPx,
|
|
16683
|
+
remainderSegment: {
|
|
16684
|
+
...segment,
|
|
16685
|
+
paragraphLineRange: {
|
|
16686
|
+
startLineIndex: bestSegment.paragraphLineRange.endLineIndex,
|
|
16687
|
+
endLineIndex,
|
|
16688
|
+
totalLineCount: fullLineRange.totalLineCount,
|
|
16689
|
+
lineHeightPx: fullLineRange.lineHeightPx
|
|
16690
|
+
}
|
|
16691
|
+
}
|
|
16692
|
+
};
|
|
16693
|
+
}
|
|
16694
|
+
function buildRenderColumnSegmentsForPageSection(model, flowSegments, columnWidthsPx, columnHeightPx, numberingDefinitions, docGridLinePitchPxByNodeIndex, measuredParagraphOuterHeightsPxByNodeIndex, balanceColumns = false) {
|
|
16695
|
+
const columnCount = Math.max(1, columnWidthsPx.length);
|
|
16696
|
+
const columns = Array.from(
|
|
16697
|
+
{ length: columnCount },
|
|
16698
|
+
() => []
|
|
16699
|
+
);
|
|
16700
|
+
const maxColumnHeightPx = Math.max(120, Math.round(columnHeightPx));
|
|
16701
|
+
const resolveSegmentHeightPx = (segment, columnWidthPx) => {
|
|
16702
|
+
const segmentNode = model.nodes[segment.nodeIndex];
|
|
16703
|
+
if (!segmentNode) {
|
|
16704
|
+
return MIN_PARAGRAPH_LINE_HEIGHT_PX;
|
|
16705
|
+
}
|
|
16706
|
+
const docGridLinePitchPx = docGridLinePitchPxByNodeIndex?.get(
|
|
16707
|
+
segment.nodeIndex
|
|
16708
|
+
);
|
|
16709
|
+
const measuredSegmentHeightPx = segmentNode.type === "paragraph" && !segment.paragraphLineRange && !segment.tableRowRange && !segment.tableRowSlice ? measuredParagraphOuterHeightsPxByNodeIndex?.get(segment.nodeIndex) : void 0;
|
|
16710
|
+
return Number.isFinite(measuredSegmentHeightPx) && measuredSegmentHeightPx > 0 ? Math.max(1, Math.round(measuredSegmentHeightPx)) : estimateRenderedPageSegmentHeightPx(
|
|
16711
|
+
segmentNode,
|
|
16712
|
+
segment,
|
|
16713
|
+
model,
|
|
16714
|
+
columnWidthPx,
|
|
16715
|
+
numberingDefinitions,
|
|
16716
|
+
docGridLinePitchPx
|
|
16717
|
+
);
|
|
16718
|
+
};
|
|
16719
|
+
const safeColumnHeightPx = balanceColumns && columnCount > 1 ? Math.min(
|
|
16720
|
+
maxColumnHeightPx,
|
|
16721
|
+
Math.max(
|
|
16722
|
+
MIN_PARAGRAPH_LINE_HEIGHT_PX * 4,
|
|
16723
|
+
Math.ceil(
|
|
16724
|
+
flowSegments.reduce((totalHeightPx, segment) => {
|
|
16725
|
+
const columnWidthPx = Math.max(
|
|
16726
|
+
120,
|
|
16727
|
+
Math.round(columnWidthsPx[0] ?? 120)
|
|
16728
|
+
);
|
|
16729
|
+
return totalHeightPx + resolveSegmentHeightPx(segment, columnWidthPx);
|
|
16730
|
+
}, 0) / columnCount
|
|
16731
|
+
) + PAGE_OVERFLOW_TOLERANCE_PX
|
|
16732
|
+
)
|
|
16733
|
+
) : maxColumnHeightPx;
|
|
16734
|
+
let columnIndex = 0;
|
|
16735
|
+
let consumedHeightPx = 0;
|
|
16736
|
+
const moveToNextColumn = () => {
|
|
16737
|
+
if (columnIndex + 1 >= columnCount) {
|
|
16738
|
+
return false;
|
|
16739
|
+
}
|
|
16740
|
+
columnIndex += 1;
|
|
16741
|
+
consumedHeightPx = 0;
|
|
16742
|
+
return true;
|
|
16743
|
+
};
|
|
16744
|
+
const pushSegment = (segment, heightPx) => {
|
|
16745
|
+
columns[columnIndex]?.push(segment);
|
|
16746
|
+
consumedHeightPx += Math.max(1, Math.round(heightPx));
|
|
16747
|
+
};
|
|
16748
|
+
for (const flowSegment of flowSegments) {
|
|
16749
|
+
let pendingSegment = flowSegment;
|
|
16750
|
+
let splitGuard = 0;
|
|
16751
|
+
while (pendingSegment && splitGuard < 256) {
|
|
16752
|
+
splitGuard += 1;
|
|
16753
|
+
const currentSegment = pendingSegment;
|
|
16754
|
+
const segmentNode = model.nodes[currentSegment.nodeIndex];
|
|
16755
|
+
if (!segmentNode) {
|
|
16756
|
+
columns[columnIndex]?.push(currentSegment);
|
|
16757
|
+
break;
|
|
16758
|
+
}
|
|
16759
|
+
const columnWidthPx = Math.max(
|
|
16760
|
+
120,
|
|
16761
|
+
Math.round(columnWidthsPx[columnIndex] ?? columnWidthsPx[0] ?? 120)
|
|
16762
|
+
);
|
|
16763
|
+
const docGridLinePitchPx = docGridLinePitchPxByNodeIndex?.get(
|
|
16764
|
+
currentSegment.nodeIndex
|
|
16765
|
+
);
|
|
16766
|
+
const segmentHeightPx = resolveSegmentHeightPx(
|
|
16767
|
+
currentSegment,
|
|
16768
|
+
columnWidthPx
|
|
16769
|
+
);
|
|
16770
|
+
const remainingHeightPx = Math.max(
|
|
16771
|
+
0,
|
|
16772
|
+
safeColumnHeightPx - consumedHeightPx
|
|
16773
|
+
);
|
|
16774
|
+
if (segmentHeightPx <= remainingHeightPx + PAGE_OVERFLOW_TOLERANCE_PX || columnIndex + 1 >= columnCount) {
|
|
16775
|
+
pushSegment(currentSegment, segmentHeightPx);
|
|
16776
|
+
pendingSegment = void 0;
|
|
16777
|
+
break;
|
|
16778
|
+
}
|
|
16779
|
+
const splitSegment = segmentNode.type === "paragraph" ? splitParagraphSegmentForColumnRender({
|
|
16780
|
+
paragraph: segmentNode,
|
|
16781
|
+
segment: currentSegment,
|
|
16782
|
+
model,
|
|
16783
|
+
availableWidthPx: columnWidthPx,
|
|
16784
|
+
availableHeightPx: remainingHeightPx,
|
|
16785
|
+
numberingDefinitions,
|
|
16786
|
+
docGridLinePitchPx
|
|
16787
|
+
}) : void 0;
|
|
16788
|
+
if (splitSegment) {
|
|
16789
|
+
pushSegment(splitSegment.currentSegment, splitSegment.currentHeightPx);
|
|
16790
|
+
pendingSegment = splitSegment.remainderSegment;
|
|
16791
|
+
if (!moveToNextColumn()) {
|
|
16792
|
+
const remainderSegment = splitSegment.remainderSegment;
|
|
16793
|
+
const remainderHeightPx = estimateRenderedPageSegmentHeightPx(
|
|
16794
|
+
segmentNode,
|
|
16795
|
+
remainderSegment,
|
|
16796
|
+
model,
|
|
16797
|
+
columnWidthPx,
|
|
16798
|
+
numberingDefinitions,
|
|
16799
|
+
docGridLinePitchPx
|
|
16800
|
+
);
|
|
16801
|
+
pushSegment(remainderSegment, remainderHeightPx);
|
|
16802
|
+
pendingSegment = void 0;
|
|
16803
|
+
}
|
|
16804
|
+
continue;
|
|
16805
|
+
}
|
|
16806
|
+
if (!moveToNextColumn()) {
|
|
16807
|
+
pushSegment(currentSegment, segmentHeightPx);
|
|
16808
|
+
pendingSegment = void 0;
|
|
16809
|
+
}
|
|
16810
|
+
}
|
|
16811
|
+
}
|
|
16812
|
+
return columns;
|
|
16813
|
+
}
|
|
16280
16814
|
function sumEstimatedTableRowHeightsPx(rowHeightsPx, startRowIndex, endRowIndex) {
|
|
16281
16815
|
let total = 0;
|
|
16282
16816
|
const clampedStart = Math.max(0, startRowIndex);
|
|
@@ -16750,16 +17284,10 @@ function buildDocumentPageNodeSegments(model, pageContentHeightPx, pageContentWi
|
|
|
16750
17284
|
const exactSegmentEndLineIndex = resolveMaxPretextLineRangeEndIndexThatFits(
|
|
16751
17285
|
pretextLayoutForSegmentSplitting,
|
|
16752
17286
|
lineCursor,
|
|
16753
|
-
Math.min(
|
|
16754
|
-
resolvedParagraphLineCount,
|
|
16755
|
-
lineCursor + linesThatFit
|
|
16756
|
-
),
|
|
17287
|
+
Math.min(resolvedParagraphLineCount, lineCursor + linesThatFit),
|
|
16757
17288
|
availableForLinesPx
|
|
16758
17289
|
);
|
|
16759
|
-
linesThatFit = Math.max(
|
|
16760
|
-
0,
|
|
16761
|
-
exactSegmentEndLineIndex - lineCursor
|
|
16762
|
-
);
|
|
17290
|
+
linesThatFit = Math.max(0, exactSegmentEndLineIndex - lineCursor);
|
|
16763
17291
|
}
|
|
16764
17292
|
if (linesThatFit < minLinesPerSegment) {
|
|
16765
17293
|
if (currentPageSegments.length > 0) {
|
|
@@ -16796,10 +17324,7 @@ function buildDocumentPageNodeSegments(model, pageContentHeightPx, pageContentWi
|
|
|
16796
17324
|
lineCursor,
|
|
16797
17325
|
segmentEndLineIndex
|
|
16798
17326
|
);
|
|
16799
|
-
if (topSpacingPx + resolveSegmentContentHeightPx(
|
|
16800
|
-
lineCursor,
|
|
16801
|
-
segmentEndLineIndex
|
|
16802
|
-
) + segmentReservePx <= remainingHeightPx2) {
|
|
17327
|
+
if (topSpacingPx + resolveSegmentContentHeightPx(lineCursor, segmentEndLineIndex) + segmentReservePx <= remainingHeightPx2) {
|
|
16803
17328
|
break;
|
|
16804
17329
|
}
|
|
16805
17330
|
linesThatFit -= 1;
|
|
@@ -17000,6 +17525,7 @@ function buildDocumentPageNodeSegments(model, pageContentHeightPx, pageContentWi
|
|
|
17000
17525
|
let rowStartIndex = 0;
|
|
17001
17526
|
let rowSliceOffsetPx = 0;
|
|
17002
17527
|
let repeatedHeaderHeightPxOnThisPage = 0;
|
|
17528
|
+
let tableBreakStartRowCursor = 0;
|
|
17003
17529
|
while (rowStartIndex < estimatedRowHeightsPx.length) {
|
|
17004
17530
|
if (currentPageSegments.length === 0) {
|
|
17005
17531
|
repeatedHeaderHeightPxOnThisPage = 0;
|
|
@@ -17034,9 +17560,10 @@ function buildDocumentPageNodeSegments(model, pageContentHeightPx, pageContentWi
|
|
|
17034
17560
|
currentPageContentHeightPx - repeatedHeaderHeightPxOnThisPage
|
|
17035
17561
|
);
|
|
17036
17562
|
const rowExceedsFreshPageHeightPx = currentRowTotalHeightPx > freshPageAvailableHeightPx + PAGE_OVERFLOW_TOLERANCE_PX;
|
|
17563
|
+
const hasUsableCurrentPageSliceSpace = pageConsumedHeightPx > 0 && remainingHeightPx >= MIN_TABLE_ROW_SLICE_REMAINING_HEIGHT_PX;
|
|
17037
17564
|
const canSplitCurrentRow = rowSliceOffsetPx > 0 || rowAllowsPageSplit(currentRow) || rowExceedsFreshPageHeightPx;
|
|
17038
17565
|
const shouldContinueExistingRowSlice = rowSliceOffsetPx > 0;
|
|
17039
|
-
const rowNeedsSliceOnThisPage = ENABLE_TABLE_ROW_SLICING && canSplitCurrentRow && currentRowRemainingHeightPx > remainingHeightPx + PAGE_OVERFLOW_TOLERANCE_PX && (shouldContinueExistingRowSlice || rowExceedsFreshPageHeightPx);
|
|
17566
|
+
const rowNeedsSliceOnThisPage = ENABLE_TABLE_ROW_SLICING && canSplitCurrentRow && currentRowRemainingHeightPx > remainingHeightPx + PAGE_OVERFLOW_TOLERANCE_PX && (shouldContinueExistingRowSlice || rowExceedsFreshPageHeightPx || hasUsableCurrentPageSliceSpace);
|
|
17040
17567
|
if (canSplitCurrentRow && currentRowRemainingHeightPx > remainingHeightPx + PAGE_OVERFLOW_TOLERANCE_PX && !rowNeedsSliceOnThisPage && currentPageSegments.length > 0) {
|
|
17041
17568
|
startNextPage();
|
|
17042
17569
|
pageConsumedHeightPx = 0;
|
|
@@ -17064,10 +17591,38 @@ function buildDocumentPageNodeSegments(model, pageContentHeightPx, pageContentWi
|
|
|
17064
17591
|
MIN_PARAGRAPH_LINE_HEIGHT_PX,
|
|
17065
17592
|
Math.round(remainingHeightPx)
|
|
17066
17593
|
);
|
|
17067
|
-
const
|
|
17594
|
+
const preferredSliceHeightPx = Math.max(
|
|
17068
17595
|
MIN_PARAGRAPH_LINE_HEIGHT_PX,
|
|
17069
17596
|
Math.min(currentRowRemainingHeightPx, availableSliceHeightPx)
|
|
17070
17597
|
);
|
|
17598
|
+
const safeSliceHeightPx = resolveTableRowSliceHeightOnSafeBoundaryPx({
|
|
17599
|
+
table: node,
|
|
17600
|
+
rowIndex: rowStartIndex,
|
|
17601
|
+
rowHeightPx: currentRowTotalHeightPx,
|
|
17602
|
+
rowSliceOffsetPx,
|
|
17603
|
+
preferredSliceHeightPx,
|
|
17604
|
+
maxAvailableWidthPx: nodeMetrics.pageContentWidthPx,
|
|
17605
|
+
numberingDefinitions,
|
|
17606
|
+
docGridLinePitchPx: nodeMetrics.docGridLinePitchPx
|
|
17607
|
+
});
|
|
17608
|
+
if (safeSliceHeightPx === void 0 && pageConsumedHeightPx > 0 && currentPageSegments.length > 0) {
|
|
17609
|
+
startNextPage();
|
|
17610
|
+
pageConsumedHeightPx = 0;
|
|
17611
|
+
previousParagraphAfterPx = 0;
|
|
17612
|
+
currentSectionPageFlowOriginPx = 0;
|
|
17613
|
+
currentPageContentHeightPx = resolveMetricsPageContentHeightPx(
|
|
17614
|
+
currentPageIndex,
|
|
17615
|
+
nodeMetrics
|
|
17616
|
+
);
|
|
17617
|
+
continue;
|
|
17618
|
+
}
|
|
17619
|
+
const sliceHeightPx = Math.max(
|
|
17620
|
+
MIN_PARAGRAPH_LINE_HEIGHT_PX,
|
|
17621
|
+
Math.min(
|
|
17622
|
+
currentRowRemainingHeightPx,
|
|
17623
|
+
safeSliceHeightPx ?? preferredSliceHeightPx
|
|
17624
|
+
)
|
|
17625
|
+
);
|
|
17071
17626
|
currentPageSegments.push({
|
|
17072
17627
|
nodeIndex,
|
|
17073
17628
|
tableRowRange: {
|
|
@@ -17133,9 +17688,10 @@ function buildDocumentPageNodeSegments(model, pageContentHeightPx, pageContentWi
|
|
|
17133
17688
|
pageConsumedHeightPx <= 0
|
|
17134
17689
|
);
|
|
17135
17690
|
let rowEndIndex = fittedRowEndIndex;
|
|
17136
|
-
|
|
17137
|
-
|
|
17138
|
-
|
|
17691
|
+
while (tableBreakStartRowCursor < tableBreakStartRows.length && tableBreakStartRows[tableBreakStartRowCursor] <= rowStartIndex) {
|
|
17692
|
+
tableBreakStartRowCursor += 1;
|
|
17693
|
+
}
|
|
17694
|
+
const forcedBreakRowIndex = tableBreakStartRows[tableBreakStartRowCursor];
|
|
17139
17695
|
if (forcedBreakRowIndex !== void 0) {
|
|
17140
17696
|
rowEndIndex = Math.min(rowEndIndex, forcedBreakRowIndex);
|
|
17141
17697
|
}
|
|
@@ -17201,6 +17757,19 @@ function buildDocumentPageNodeSegments(model, pageContentHeightPx, pageContentWi
|
|
|
17201
17757
|
rowStartIndex = rowEndIndex;
|
|
17202
17758
|
rowSliceOffsetPx = 0;
|
|
17203
17759
|
if (rowStartIndex < estimatedRowHeightsPx.length) {
|
|
17760
|
+
const nextRow = node.rows[rowStartIndex];
|
|
17761
|
+
const nextRowHeightPx = Math.max(
|
|
17762
|
+
MIN_PARAGRAPH_LINE_HEIGHT_PX,
|
|
17763
|
+
estimatedRowHeightsPx[rowStartIndex] ?? MIN_PARAGRAPH_LINE_HEIGHT_PX
|
|
17764
|
+
);
|
|
17765
|
+
const remainingHeightAfterSegmentPx = Math.max(
|
|
17766
|
+
0,
|
|
17767
|
+
currentPageContentHeightPx - pageConsumedHeightPx
|
|
17768
|
+
);
|
|
17769
|
+
const canSliceNextRowOnCurrentPage = ENABLE_TABLE_ROW_SLICING && nextRow !== void 0 && rowAllowsPageSplit(nextRow) && !tableBreakStartRows.includes(rowStartIndex) && remainingHeightAfterSegmentPx >= MIN_TABLE_ROW_SLICE_REMAINING_HEIGHT_PX && nextRowHeightPx > remainingHeightAfterSegmentPx + PAGE_OVERFLOW_TOLERANCE_PX;
|
|
17770
|
+
if (canSliceNextRowOnCurrentPage) {
|
|
17771
|
+
continue;
|
|
17772
|
+
}
|
|
17204
17773
|
startNextPage();
|
|
17205
17774
|
pageConsumedHeightPx = 0;
|
|
17206
17775
|
previousParagraphAfterPx = 0;
|
|
@@ -24253,7 +24822,8 @@ function useDocxEditor(options = {}) {
|
|
|
24253
24822
|
const [status, setStatus] = React.useState(
|
|
24254
24823
|
options.initialStatus ?? "Ready"
|
|
24255
24824
|
);
|
|
24256
|
-
const
|
|
24825
|
+
const [importError, setImportError] = React.useState();
|
|
24826
|
+
const [isImporting, setIsImporting] = React.useState(false);
|
|
24257
24827
|
const [documentTheme, setDocumentThemeState] = React.useState(options.initialDocumentTheme ?? "light");
|
|
24258
24828
|
const [showTrackedChanges, setShowTrackedChangesState] = React.useState(options.initialShowTrackedChanges ?? false);
|
|
24259
24829
|
const [paginationInfo, setPaginationInfo] = React.useState({
|
|
@@ -24770,12 +25340,36 @@ function useDocxEditor(options = {}) {
|
|
|
24770
25340
|
},
|
|
24771
25341
|
[dispatchEditorTransaction]
|
|
24772
25342
|
);
|
|
25343
|
+
const replaceDocumentWithImportError = React.useCallback(
|
|
25344
|
+
(fileName2, error) => {
|
|
25345
|
+
unloadEmbeddedFonts();
|
|
25346
|
+
setModel(createBlankDocumentModel());
|
|
25347
|
+
setDocumentLoadNonce((current) => current + 1);
|
|
25348
|
+
setHistory({ past: [], future: [] });
|
|
25349
|
+
setHistoryRestoreRequest(void 0);
|
|
25350
|
+
setBasePackage(void 0);
|
|
25351
|
+
setFileName(fileName2);
|
|
25352
|
+
setSelection({ kind: "paragraph", nodeIndex: 0 });
|
|
25353
|
+
setActiveTextRangeState(void 0);
|
|
25354
|
+
setPendingRunStyle(void 0);
|
|
25355
|
+
setSelectedFormFieldLocation(void 0);
|
|
25356
|
+
setImportError(error);
|
|
25357
|
+
setStatus(`Failed to load file: ${error.message}`);
|
|
25358
|
+
},
|
|
25359
|
+
[unloadEmbeddedFonts]
|
|
25360
|
+
);
|
|
24773
25361
|
const importDocxFile = React.useCallback(
|
|
24774
25362
|
async (file) => {
|
|
24775
25363
|
if (!/\.docx$/i.test(file.name)) {
|
|
24776
|
-
|
|
25364
|
+
replaceDocumentWithImportError(
|
|
25365
|
+
file.name,
|
|
25366
|
+
new Error("Only .docx files are supported")
|
|
25367
|
+
);
|
|
24777
25368
|
return;
|
|
24778
25369
|
}
|
|
25370
|
+
setIsImporting(true);
|
|
25371
|
+
setImportError(void 0);
|
|
25372
|
+
setStatus(`Loading ${file.name}...`);
|
|
24779
25373
|
try {
|
|
24780
25374
|
const buffer = await file.arrayBuffer();
|
|
24781
25375
|
const pkg = await parseDocx(buffer);
|
|
@@ -24791,14 +25385,16 @@ function useDocxEditor(options = {}) {
|
|
|
24791
25385
|
setActiveTextRangeState(void 0);
|
|
24792
25386
|
setPendingRunStyle(void 0);
|
|
24793
25387
|
setSelectedFormFieldLocation(void 0);
|
|
25388
|
+
setImportError(void 0);
|
|
24794
25389
|
setStatus(`Loaded ${file.name}`);
|
|
24795
25390
|
} catch (error) {
|
|
24796
|
-
|
|
24797
|
-
|
|
24798
|
-
|
|
25391
|
+
const nextError = error instanceof Error ? error : new Error("Unknown error");
|
|
25392
|
+
replaceDocumentWithImportError(file.name, nextError);
|
|
25393
|
+
} finally {
|
|
25394
|
+
setIsImporting(false);
|
|
24799
25395
|
}
|
|
24800
25396
|
},
|
|
24801
|
-
[loadEmbeddedFontsFromPackage]
|
|
25397
|
+
[loadEmbeddedFontsFromPackage, replaceDocumentWithImportError]
|
|
24802
25398
|
);
|
|
24803
25399
|
const newDocument = React.useCallback(() => {
|
|
24804
25400
|
unloadEmbeddedFonts();
|
|
@@ -24812,6 +25408,7 @@ function useDocxEditor(options = {}) {
|
|
|
24812
25408
|
setSelectedFormFieldLocation(void 0);
|
|
24813
25409
|
setHistory({ past: [], future: [] });
|
|
24814
25410
|
setHistoryRestoreRequest(void 0);
|
|
25411
|
+
setImportError(void 0);
|
|
24815
25412
|
setStatus("Created new document");
|
|
24816
25413
|
}, [unloadEmbeddedFonts]);
|
|
24817
25414
|
const exportDocx = React.useCallback(() => {
|
|
@@ -27720,6 +28317,7 @@ function useDocxEditor(options = {}) {
|
|
|
27720
28317
|
documentLoadNonce,
|
|
27721
28318
|
fileName,
|
|
27722
28319
|
status,
|
|
28320
|
+
importError,
|
|
27723
28321
|
isImporting,
|
|
27724
28322
|
documentTheme,
|
|
27725
28323
|
trackedChanges,
|
|
@@ -29285,7 +29883,7 @@ function DocxEditorViewer({
|
|
|
29285
29883
|
style,
|
|
29286
29884
|
pageBackgroundColor,
|
|
29287
29885
|
pageGapBackgroundColor,
|
|
29288
|
-
deferInitialPaginationPaint =
|
|
29886
|
+
deferInitialPaginationPaint = false,
|
|
29289
29887
|
loadingState,
|
|
29290
29888
|
pageVirtualization,
|
|
29291
29889
|
visiblePageRange,
|
|
@@ -29346,6 +29944,10 @@ function DocxEditorViewer({
|
|
|
29346
29944
|
const paragraphElementsRef = React.useRef(
|
|
29347
29945
|
/* @__PURE__ */ new Map()
|
|
29348
29946
|
);
|
|
29947
|
+
const [
|
|
29948
|
+
measuredParagraphOuterHeightsPxByNodeIndex,
|
|
29949
|
+
setMeasuredParagraphOuterHeightsPxByNodeIndex
|
|
29950
|
+
] = React.useState(() => /* @__PURE__ */ new Map());
|
|
29349
29951
|
const tableCellEditorElementsRef = React.useRef(
|
|
29350
29952
|
/* @__PURE__ */ new Map()
|
|
29351
29953
|
);
|
|
@@ -29620,6 +30222,9 @@ function DocxEditorViewer({
|
|
|
29620
30222
|
const paginationMeasurementResumeTimeoutRef = React.useRef(
|
|
29621
30223
|
null
|
|
29622
30224
|
);
|
|
30225
|
+
React.useLayoutEffect(() => {
|
|
30226
|
+
setMeasuredParagraphOuterHeightsPxByNodeIndex(/* @__PURE__ */ new Map());
|
|
30227
|
+
}, [editor.documentLoadNonce, paragraphStructureEpoch]);
|
|
29623
30228
|
const schedulePaginationMeasurementResume = React.useCallback(
|
|
29624
30229
|
(delayMs) => {
|
|
29625
30230
|
if (typeof window === "undefined") {
|
|
@@ -29832,10 +30437,20 @@ function DocxEditorViewer({
|
|
|
29832
30437
|
() => buildPaginationSectionMetrics(documentSections, documentLayout),
|
|
29833
30438
|
[documentLayout, documentSections]
|
|
29834
30439
|
);
|
|
29835
|
-
const
|
|
30440
|
+
const {
|
|
30441
|
+
docGridLinePitchPxByNodeIndex,
|
|
30442
|
+
pageContentWidthPxByNodeIndex,
|
|
30443
|
+
pageContentHeightPxByNodeIndex
|
|
30444
|
+
} = React.useMemo(() => {
|
|
29836
30445
|
const pitchByNodeIndex = /* @__PURE__ */ new Map();
|
|
30446
|
+
const widthByNodeIndex = /* @__PURE__ */ new Map();
|
|
30447
|
+
const heightByNodeIndex = /* @__PURE__ */ new Map();
|
|
29837
30448
|
if (editor.model.nodes.length === 0 || paginationSectionMetrics.length === 0) {
|
|
29838
|
-
return
|
|
30449
|
+
return {
|
|
30450
|
+
docGridLinePitchPxByNodeIndex: pitchByNodeIndex,
|
|
30451
|
+
pageContentWidthPxByNodeIndex: widthByNodeIndex,
|
|
30452
|
+
pageContentHeightPxByNodeIndex: heightByNodeIndex
|
|
30453
|
+
};
|
|
29839
30454
|
}
|
|
29840
30455
|
let currentMetricsIndex = 0;
|
|
29841
30456
|
for (let nodeIndex = 0; nodeIndex < editor.model.nodes.length; nodeIndex += 1) {
|
|
@@ -29844,51 +30459,22 @@ function DocxEditorViewer({
|
|
|
29844
30459
|
nodeIndex,
|
|
29845
30460
|
currentMetricsIndex
|
|
29846
30461
|
);
|
|
29847
|
-
const
|
|
30462
|
+
const nodeMetrics = paginationSectionMetrics[currentMetricsIndex];
|
|
30463
|
+
const docGridLinePitchPx = nodeMetrics?.docGridLinePitchPx;
|
|
29848
30464
|
if (Number.isFinite(docGridLinePitchPx) && docGridLinePitchPx > 0) {
|
|
29849
30465
|
pitchByNodeIndex.set(
|
|
29850
30466
|
nodeIndex,
|
|
29851
30467
|
Math.round(docGridLinePitchPx)
|
|
29852
30468
|
);
|
|
29853
30469
|
}
|
|
29854
|
-
|
|
29855
|
-
return pitchByNodeIndex;
|
|
29856
|
-
}, [editor.model.nodes, paginationSectionMetrics]);
|
|
29857
|
-
const pageContentWidthPxByNodeIndex = React.useMemo(() => {
|
|
29858
|
-
const widthByNodeIndex = /* @__PURE__ */ new Map();
|
|
29859
|
-
if (editor.model.nodes.length === 0 || paginationSectionMetrics.length === 0) {
|
|
29860
|
-
return widthByNodeIndex;
|
|
29861
|
-
}
|
|
29862
|
-
let currentMetricsIndex = 0;
|
|
29863
|
-
for (let nodeIndex = 0; nodeIndex < editor.model.nodes.length; nodeIndex += 1) {
|
|
29864
|
-
currentMetricsIndex = resolvePaginationSectionMetricsIndexForNodeIndex(
|
|
29865
|
-
paginationSectionMetrics,
|
|
29866
|
-
nodeIndex,
|
|
29867
|
-
currentMetricsIndex
|
|
29868
|
-
);
|
|
29869
|
-
const pageContentWidthPx = paginationSectionMetrics[currentMetricsIndex]?.pageContentWidthPx;
|
|
30470
|
+
const pageContentWidthPx = nodeMetrics?.pageContentWidthPx;
|
|
29870
30471
|
if (Number.isFinite(pageContentWidthPx) && pageContentWidthPx > 0) {
|
|
29871
30472
|
widthByNodeIndex.set(
|
|
29872
30473
|
nodeIndex,
|
|
29873
30474
|
Math.round(pageContentWidthPx)
|
|
29874
30475
|
);
|
|
29875
30476
|
}
|
|
29876
|
-
|
|
29877
|
-
return widthByNodeIndex;
|
|
29878
|
-
}, [editor.model.nodes, paginationSectionMetrics]);
|
|
29879
|
-
const pageContentHeightPxByNodeIndex = React.useMemo(() => {
|
|
29880
|
-
const heightByNodeIndex = /* @__PURE__ */ new Map();
|
|
29881
|
-
if (editor.model.nodes.length === 0 || paginationSectionMetrics.length === 0) {
|
|
29882
|
-
return heightByNodeIndex;
|
|
29883
|
-
}
|
|
29884
|
-
let currentMetricsIndex = 0;
|
|
29885
|
-
for (let nodeIndex = 0; nodeIndex < editor.model.nodes.length; nodeIndex += 1) {
|
|
29886
|
-
currentMetricsIndex = resolvePaginationSectionMetricsIndexForNodeIndex(
|
|
29887
|
-
paginationSectionMetrics,
|
|
29888
|
-
nodeIndex,
|
|
29889
|
-
currentMetricsIndex
|
|
29890
|
-
);
|
|
29891
|
-
const pageContentHeightPx = paginationSectionMetrics[currentMetricsIndex]?.pageContentHeightPx;
|
|
30477
|
+
const pageContentHeightPx = nodeMetrics?.pageContentHeightPx;
|
|
29892
30478
|
if (Number.isFinite(pageContentHeightPx) && pageContentHeightPx > 0) {
|
|
29893
30479
|
heightByNodeIndex.set(
|
|
29894
30480
|
nodeIndex,
|
|
@@ -29896,7 +30482,11 @@ function DocxEditorViewer({
|
|
|
29896
30482
|
);
|
|
29897
30483
|
}
|
|
29898
30484
|
}
|
|
29899
|
-
return
|
|
30485
|
+
return {
|
|
30486
|
+
docGridLinePitchPxByNodeIndex: pitchByNodeIndex,
|
|
30487
|
+
pageContentWidthPxByNodeIndex: widthByNodeIndex,
|
|
30488
|
+
pageContentHeightPxByNodeIndex: heightByNodeIndex
|
|
30489
|
+
};
|
|
29900
30490
|
}, [editor.model.nodes, paginationSectionMetrics]);
|
|
29901
30491
|
const sectionColumnsBySectionIndex = React.useMemo(
|
|
29902
30492
|
() => documentSections.map(
|
|
@@ -30048,11 +30638,11 @@ function DocxEditorViewer({
|
|
|
30048
30638
|
renderPageContentHeightScale: estimatedRenderPageContentHeightScale
|
|
30049
30639
|
};
|
|
30050
30640
|
}
|
|
30051
|
-
const pureEstimatedPages = buildEstimatedPages(
|
|
30052
|
-
tableMeasuredRowHeightsForPagination,
|
|
30053
|
-
null
|
|
30054
|
-
);
|
|
30055
30641
|
if (measuredPageContentHeightByIndex && measuredPageContentHeightByIndex.length > 0) {
|
|
30642
|
+
const pureEstimatedPages = buildEstimatedPages(
|
|
30643
|
+
tableMeasuredRowHeightsForPagination,
|
|
30644
|
+
null
|
|
30645
|
+
);
|
|
30056
30646
|
const measuredPagesAreOnlySplitParagraphs = estimatedPages.length > 0 && estimatedPages.every(
|
|
30057
30647
|
(pageSegments) => documentPageContainsOnlySplitParagraphSegments(pageSegments)
|
|
30058
30648
|
);
|
|
@@ -30099,9 +30689,9 @@ function DocxEditorViewer({
|
|
|
30099
30689
|
estimatedRenderMeasuredPageContentHeightsPxByPageIndex = bestCandidate.renderMeasuredPageContentHeightsPxByPageIndex;
|
|
30100
30690
|
estimatedRenderPageContentHeightScale = bestCandidate.renderPageContentHeightScale;
|
|
30101
30691
|
} else if (!editor.canUndo && !editor.canRedo && targetPageCount !== void 0 && !hasMultiColumnRenderedPageBreakHints) {
|
|
30102
|
-
const
|
|
30103
|
-
if (Math.abs(
|
|
30104
|
-
estimatedPages =
|
|
30692
|
+
const pureEstimatedPages = buildEstimatedPages(void 0, null);
|
|
30693
|
+
if (Math.abs(pureEstimatedPages.length - targetPageCount) < Math.abs(estimatedPages.length - targetPageCount)) {
|
|
30694
|
+
estimatedPages = pureEstimatedPages;
|
|
30105
30695
|
estimatedPagesUseMeasuredPageContentHeightsForRender = false;
|
|
30106
30696
|
estimatedRenderMeasuredPageContentHeightsPxByPageIndex = void 0;
|
|
30107
30697
|
estimatedRenderPageContentHeightScale = void 0;
|
|
@@ -30221,9 +30811,9 @@ function DocxEditorViewer({
|
|
|
30221
30811
|
) : void 0;
|
|
30222
30812
|
let reconciledRenderPageContentHeightScale = reconciledPagesUseMeasuredPageContentHeightsForRender ? void 0 : reconciledCandidate.scale;
|
|
30223
30813
|
if (!editor.canUndo && !editor.canRedo) {
|
|
30224
|
-
const
|
|
30814
|
+
const pureEstimatedPages = buildEstimatedPages(void 0, null);
|
|
30225
30815
|
const pureReconciledCandidate = reconcileCandidatePages(
|
|
30226
|
-
|
|
30816
|
+
pureEstimatedPages,
|
|
30227
30817
|
void 0,
|
|
30228
30818
|
null
|
|
30229
30819
|
);
|
|
@@ -30720,8 +31310,9 @@ function DocxEditorViewer({
|
|
|
30720
31310
|
pageCount,
|
|
30721
31311
|
pageVirtualization?.overscan
|
|
30722
31312
|
]);
|
|
31313
|
+
const shouldObserveVisiblePageRange = hasLargeTableLayoutSurface || internalVirtualItems.length === 0;
|
|
30723
31314
|
React.useLayoutEffect(() => {
|
|
30724
|
-
if (!internalPageVirtualizationEnabled || !internalVirtualScrollElement ||
|
|
31315
|
+
if (!internalPageVirtualizationEnabled || !internalVirtualScrollElement || !shouldObserveVisiblePageRange || typeof window === "undefined") {
|
|
30725
31316
|
setObservedVisiblePageRange(
|
|
30726
31317
|
(current) => current === void 0 ? current : void 0
|
|
30727
31318
|
);
|
|
@@ -30735,6 +31326,15 @@ function DocxEditorViewer({
|
|
|
30735
31326
|
return;
|
|
30736
31327
|
}
|
|
30737
31328
|
let frameId = null;
|
|
31329
|
+
const commitObservedVisiblePageRange = (updater) => {
|
|
31330
|
+
if (hasLargeTableLayoutSurface) {
|
|
31331
|
+
flushSync(() => {
|
|
31332
|
+
setObservedVisiblePageRange(updater);
|
|
31333
|
+
});
|
|
31334
|
+
return;
|
|
31335
|
+
}
|
|
31336
|
+
setObservedVisiblePageRange(updater);
|
|
31337
|
+
};
|
|
30738
31338
|
const syncVisiblePageRange = () => {
|
|
30739
31339
|
frameId = null;
|
|
30740
31340
|
const viewportRect = internalVirtualScrollUsesWindow ? {
|
|
@@ -30768,7 +31368,7 @@ function DocxEditorViewer({
|
|
|
30768
31368
|
lastVisiblePageIndex = pageIndex;
|
|
30769
31369
|
}
|
|
30770
31370
|
if (firstVisiblePageIndex === void 0 || lastVisiblePageIndex === void 0) {
|
|
30771
|
-
|
|
31371
|
+
commitObservedVisiblePageRange(
|
|
30772
31372
|
(current) => current === void 0 ? current : void 0
|
|
30773
31373
|
);
|
|
30774
31374
|
return;
|
|
@@ -30783,7 +31383,7 @@ function DocxEditorViewer({
|
|
|
30783
31383
|
startPageIndex,
|
|
30784
31384
|
pageCount - 1
|
|
30785
31385
|
);
|
|
30786
|
-
|
|
31386
|
+
commitObservedVisiblePageRange((current) => {
|
|
30787
31387
|
if (current?.startPageIndex === startPageIndex && current?.endPageIndex === endPageIndex) {
|
|
30788
31388
|
return current;
|
|
30789
31389
|
}
|
|
@@ -30835,14 +31435,42 @@ function DocxEditorViewer({
|
|
|
30835
31435
|
}
|
|
30836
31436
|
};
|
|
30837
31437
|
}, [
|
|
31438
|
+
hasLargeTableLayoutSurface,
|
|
30838
31439
|
internalPageVirtualizationEnabled,
|
|
30839
31440
|
internalVirtualItems.length,
|
|
30840
31441
|
internalVirtualScrollElement,
|
|
30841
31442
|
internalVirtualScrollUsesWindow,
|
|
30842
31443
|
pageCount,
|
|
30843
|
-
pageVirtualizationOverscan
|
|
31444
|
+
pageVirtualizationOverscan,
|
|
31445
|
+
shouldObserveVisiblePageRange
|
|
30844
31446
|
]);
|
|
30845
|
-
const
|
|
31447
|
+
const internalEffectiveRenderVisiblePageRange = React.useMemo(() => {
|
|
31448
|
+
if (!internalRenderVisiblePageRange) {
|
|
31449
|
+
return observedVisiblePageRange;
|
|
31450
|
+
}
|
|
31451
|
+
if (!observedVisiblePageRange || !hasLargeTableLayoutSurface) {
|
|
31452
|
+
return internalRenderVisiblePageRange;
|
|
31453
|
+
}
|
|
31454
|
+
const rangesAreAdjacentOrOverlapping = observedVisiblePageRange.startPageIndex <= internalRenderVisiblePageRange.endPageIndex + 2 && internalRenderVisiblePageRange.startPageIndex <= observedVisiblePageRange.endPageIndex + 2;
|
|
31455
|
+
if (!rangesAreAdjacentOrOverlapping) {
|
|
31456
|
+
return internalRenderVisiblePageRange;
|
|
31457
|
+
}
|
|
31458
|
+
return {
|
|
31459
|
+
startPageIndex: Math.min(
|
|
31460
|
+
internalRenderVisiblePageRange.startPageIndex,
|
|
31461
|
+
observedVisiblePageRange.startPageIndex
|
|
31462
|
+
),
|
|
31463
|
+
endPageIndex: Math.max(
|
|
31464
|
+
internalRenderVisiblePageRange.endPageIndex,
|
|
31465
|
+
observedVisiblePageRange.endPageIndex
|
|
31466
|
+
)
|
|
31467
|
+
};
|
|
31468
|
+
}, [
|
|
31469
|
+
hasLargeTableLayoutSurface,
|
|
31470
|
+
internalRenderVisiblePageRange,
|
|
31471
|
+
observedVisiblePageRange
|
|
31472
|
+
]);
|
|
31473
|
+
const effectiveVisiblePageRange = visiblePageRange ?? internalEffectiveRenderVisiblePageRange ?? observedVisiblePageRange ?? (internalPageVirtualizationPending ? {
|
|
30846
31474
|
startPageIndex: 0,
|
|
30847
31475
|
endPageIndex: Math.min(
|
|
30848
31476
|
pageCount - 1,
|
|
@@ -30891,6 +31519,43 @@ function DocxEditorViewer({
|
|
|
30891
31519
|
}
|
|
30892
31520
|
return indexes;
|
|
30893
31521
|
}, [pageCount, visiblePageEndIndex, visiblePageStartIndex]);
|
|
31522
|
+
React.useLayoutEffect(() => {
|
|
31523
|
+
if (typeof window === "undefined") {
|
|
31524
|
+
return;
|
|
31525
|
+
}
|
|
31526
|
+
setMeasuredParagraphOuterHeightsPxByNodeIndex((current) => {
|
|
31527
|
+
const next = new Map(current);
|
|
31528
|
+
let changed = false;
|
|
31529
|
+
paragraphElementsRef.current.forEach((element, nodeIndex) => {
|
|
31530
|
+
if (!element.isConnected || element.dataset.docxParagraphPartialLineRange === "true" || element.closest('[data-docx-header-footer-region="footer"]') || element.closest('[data-docx-header-footer-region="header"]')) {
|
|
31531
|
+
return;
|
|
31532
|
+
}
|
|
31533
|
+
const rect = element.getBoundingClientRect();
|
|
31534
|
+
if (rect.width <= 0 && rect.height <= 0) {
|
|
31535
|
+
return;
|
|
31536
|
+
}
|
|
31537
|
+
const style2 = window.getComputedStyle(element);
|
|
31538
|
+
const marginTop = Number.parseFloat(style2.marginTop || "0");
|
|
31539
|
+
const marginBottom = Number.parseFloat(style2.marginBottom || "0");
|
|
31540
|
+
const outerHeightPx = Math.max(
|
|
31541
|
+
1,
|
|
31542
|
+
Math.round(
|
|
31543
|
+
rect.height + (Number.isFinite(marginTop) ? marginTop : 0) + (Number.isFinite(marginBottom) ? marginBottom : 0)
|
|
31544
|
+
)
|
|
31545
|
+
);
|
|
31546
|
+
if (next.get(nodeIndex) !== outerHeightPx) {
|
|
31547
|
+
next.set(nodeIndex, outerHeightPx);
|
|
31548
|
+
changed = true;
|
|
31549
|
+
}
|
|
31550
|
+
});
|
|
31551
|
+
return changed ? next : current;
|
|
31552
|
+
});
|
|
31553
|
+
}, [
|
|
31554
|
+
editor.documentLoadNonce,
|
|
31555
|
+
pageNodeSegmentIdentityKeysByPage,
|
|
31556
|
+
visiblePageEndIndex,
|
|
31557
|
+
visiblePageStartIndex
|
|
31558
|
+
]);
|
|
30894
31559
|
const visibleTableRowIndexesByNodeIndex = React.useMemo(() => {
|
|
30895
31560
|
const rowsByNodeIndex = /* @__PURE__ */ new Map();
|
|
30896
31561
|
const addRowIndex = (nodeIndex, rowIndex) => {
|
|
@@ -30965,7 +31630,8 @@ function DocxEditorViewer({
|
|
|
30965
31630
|
tableMeasuredRowHeights,
|
|
30966
31631
|
visiblePageIndexes
|
|
30967
31632
|
]);
|
|
30968
|
-
const
|
|
31633
|
+
const allowPostImportPaginationMeasurement = !hasLargeTableLayoutSurface || !internalPageVirtualizationEnabled;
|
|
31634
|
+
const visiblePagesNeedMeasurementUnlock = !hideDocumentUntilPaginationSettled && allowPostImportPaginationMeasurement && visiblePagesHavePendingPaginationMeasurements;
|
|
30969
31635
|
React.useEffect(() => {
|
|
30970
31636
|
if (!visiblePagesNeedMeasurementUnlock) {
|
|
30971
31637
|
return;
|
|
@@ -40937,11 +41603,17 @@ function DocxEditorViewer({
|
|
|
40937
41603
|
} : void 0,
|
|
40938
41604
|
outline: "none"
|
|
40939
41605
|
};
|
|
40940
|
-
|
|
40941
|
-
|
|
40942
|
-
|
|
40943
|
-
|
|
40944
|
-
|
|
41606
|
+
let fallbackParagraphRuns;
|
|
41607
|
+
const getFallbackParagraphRuns = () => {
|
|
41608
|
+
if (fallbackParagraphRuns === void 0) {
|
|
41609
|
+
fallbackParagraphRuns = renderInteractiveParagraphRuns(
|
|
41610
|
+
paragraph,
|
|
41611
|
+
`body-cell-${tableIndex}-${rowIndex}-${cellIndex}-${contentIndex}`,
|
|
41612
|
+
location
|
|
41613
|
+
);
|
|
41614
|
+
}
|
|
41615
|
+
return fallbackParagraphRuns;
|
|
41616
|
+
};
|
|
40945
41617
|
const renderedInteractiveParagraphContent = shouldRenderParagraphSegmentWithPretext ? /* @__PURE__ */ jsx(
|
|
40946
41618
|
"div",
|
|
40947
41619
|
{
|
|
@@ -40979,11 +41651,11 @@ function DocxEditorViewer({
|
|
|
40979
41651
|
style: {
|
|
40980
41652
|
transform: `translateY(-${paragraphSegmentTranslateYPx - paragraphSegmentClipBleedTopPx}px)`
|
|
40981
41653
|
},
|
|
40982
|
-
children:
|
|
41654
|
+
children: getFallbackParagraphRuns()
|
|
40983
41655
|
}
|
|
40984
41656
|
)
|
|
40985
41657
|
}
|
|
40986
|
-
) :
|
|
41658
|
+
) : getFallbackParagraphRuns();
|
|
40987
41659
|
return /* @__PURE__ */ jsx(
|
|
40988
41660
|
"div",
|
|
40989
41661
|
{
|
|
@@ -41225,6 +41897,7 @@ function DocxEditorViewer({
|
|
|
41225
41897
|
...resolvedAfterSpacingPx !== void 0 ? { marginBottom: resolvedAfterSpacingPx } : void 0
|
|
41226
41898
|
} : void 0,
|
|
41227
41899
|
...letterheadStyleAdjustments ?? void 0,
|
|
41900
|
+
...options?.normalizeParagraphHostFontSize ? { fontSize: `${paragraphBaseFontSizePx(node)}px` } : void 0,
|
|
41228
41901
|
...options?.suppressLetterheadColumnLayout && options?.isFirstInLetterheadColumn ? { marginTop: 0 } : void 0,
|
|
41229
41902
|
...pageAbsoluteAnchorOnlyParagraph ? {
|
|
41230
41903
|
position: "relative",
|
|
@@ -41243,19 +41916,25 @@ function DocxEditorViewer({
|
|
|
41243
41916
|
} : void 0,
|
|
41244
41917
|
outline: "none"
|
|
41245
41918
|
};
|
|
41246
|
-
|
|
41247
|
-
|
|
41248
|
-
|
|
41249
|
-
|
|
41250
|
-
|
|
41251
|
-
|
|
41252
|
-
|
|
41253
|
-
|
|
41254
|
-
|
|
41255
|
-
|
|
41256
|
-
|
|
41919
|
+
let fallbackParagraphRuns;
|
|
41920
|
+
const getFallbackParagraphRuns = () => {
|
|
41921
|
+
if (fallbackParagraphRuns === void 0) {
|
|
41922
|
+
fallbackParagraphRuns = renderInteractiveParagraphRuns(
|
|
41923
|
+
node,
|
|
41924
|
+
`node-${nodeIndex}`,
|
|
41925
|
+
{
|
|
41926
|
+
kind: "paragraph",
|
|
41927
|
+
nodeIndex
|
|
41928
|
+
},
|
|
41929
|
+
{
|
|
41930
|
+
pageFlowTopPx: paragraphPageFlowTopPx,
|
|
41931
|
+
pageLayout: resolvedPageLayout,
|
|
41932
|
+
suppressLikelyFullPageCoverImageKeys: options?.suppressLikelyFullPageCoverImageKeys
|
|
41933
|
+
}
|
|
41934
|
+
);
|
|
41257
41935
|
}
|
|
41258
|
-
|
|
41936
|
+
return fallbackParagraphRuns;
|
|
41937
|
+
};
|
|
41259
41938
|
const renderedInteractiveParagraphContent = shouldRenderParagraphSegmentWithPretext ? /* @__PURE__ */ jsx(
|
|
41260
41939
|
"div",
|
|
41261
41940
|
{
|
|
@@ -41296,11 +41975,11 @@ function DocxEditorViewer({
|
|
|
41296
41975
|
style: {
|
|
41297
41976
|
transform: `translateY(-${paragraphSegmentTranslateYPx - paragraphSegmentClipBleedTopPx}px)`
|
|
41298
41977
|
},
|
|
41299
|
-
children:
|
|
41978
|
+
children: getFallbackParagraphRuns()
|
|
41300
41979
|
}
|
|
41301
41980
|
)
|
|
41302
41981
|
}
|
|
41303
|
-
) :
|
|
41982
|
+
) : getFallbackParagraphRuns();
|
|
41304
41983
|
const paragraphDraftHtml = paragraphDraftsRef.current.get(nodeIndex);
|
|
41305
41984
|
const renderedEditableParagraphHtml = typeof paragraphDraftHtml === "string" ? paragraphDraftHtml : renderStaticHtml(renderedInteractiveParagraphContent);
|
|
41306
41985
|
return /* @__PURE__ */ jsx(
|
|
@@ -41311,6 +41990,7 @@ function DocxEditorViewer({
|
|
|
41311
41990
|
"data-docx-paragraph-node-index": nodeIndex,
|
|
41312
41991
|
"data-docx-paragraph-start-line": paragraphSegmentStartLine,
|
|
41313
41992
|
"data-docx-paragraph-end-line": paragraphSegmentEndLine,
|
|
41993
|
+
"data-docx-paragraph-partial-line-range": hasPartialLineRange ? "true" : void 0,
|
|
41314
41994
|
style: paragraphStyle,
|
|
41315
41995
|
dangerouslySetInnerHTML: editable ? {
|
|
41316
41996
|
__html: renderedEditableParagraphHtml
|
|
@@ -42348,6 +43028,68 @@ ${currentText.slice(end)}`;
|
|
|
42348
43028
|
})() : void 0;
|
|
42349
43029
|
const tableCellDraftHtml = tableCellDraftsRef.current.get(cellDraftKey);
|
|
42350
43030
|
const renderedEditableCellHtml = editableCell ? typeof tableCellDraftHtml === "string" ? tableCellDraftHtml : renderStaticHtml(renderedEditableCellContent) : void 0;
|
|
43031
|
+
const renderStaticCellContent = () => {
|
|
43032
|
+
let paragraphCursor = 0;
|
|
43033
|
+
return cell.nodes.map(
|
|
43034
|
+
(cellContent, contentIndex) => {
|
|
43035
|
+
if (cellContent.type === "paragraph") {
|
|
43036
|
+
const paragraphIndex = paragraphCursor;
|
|
43037
|
+
paragraphCursor += 1;
|
|
43038
|
+
return /* @__PURE__ */ jsx(
|
|
43039
|
+
"div",
|
|
43040
|
+
{
|
|
43041
|
+
"data-docx-paragraph-host": "true",
|
|
43042
|
+
"data-docx-paragraph-kind": "table-cell",
|
|
43043
|
+
"data-docx-table-index": nodeIndex,
|
|
43044
|
+
"data-docx-row-index": rowIndex,
|
|
43045
|
+
"data-docx-cell-index": cellIndex,
|
|
43046
|
+
"data-docx-paragraph-index": paragraphIndex,
|
|
43047
|
+
"data-docx-table-paragraph-index": paragraphIndex,
|
|
43048
|
+
style: tableCellParagraphBlockStyle(
|
|
43049
|
+
cellContent,
|
|
43050
|
+
editor.model.metadata.numberingDefinitions,
|
|
43051
|
+
headingStyles,
|
|
43052
|
+
paragraphIndex,
|
|
43053
|
+
applyWordTableDefaults,
|
|
43054
|
+
nodeDocGridLinePitchPx
|
|
43055
|
+
),
|
|
43056
|
+
children: renderInteractiveParagraphRuns(
|
|
43057
|
+
cellContent,
|
|
43058
|
+
`body-cell-${nodeIndex}-${rowIndex}-${cellIndex}-${contentIndex}`,
|
|
43059
|
+
{
|
|
43060
|
+
kind: "table-cell",
|
|
43061
|
+
tableIndex: nodeIndex,
|
|
43062
|
+
rowIndex,
|
|
43063
|
+
cellIndex,
|
|
43064
|
+
paragraphIndex
|
|
43065
|
+
}
|
|
43066
|
+
)
|
|
43067
|
+
},
|
|
43068
|
+
`body-cell-p-${nodeIndex}-${rowIndex}-${cellIndex}-${contentIndex}`
|
|
43069
|
+
);
|
|
43070
|
+
}
|
|
43071
|
+
return renderHeaderNode(
|
|
43072
|
+
cellContent,
|
|
43073
|
+
`body-cell-nested-table-${nodeIndex}-${rowIndex}-${cellIndex}-${contentIndex}`,
|
|
43074
|
+
documentContentTheme,
|
|
43075
|
+
editor.model.metadata.numberingDefinitions,
|
|
43076
|
+
headingStyles,
|
|
43077
|
+
spannedWidthPx > 0 ? spannedWidthPx : void 0,
|
|
43078
|
+
scrollToBookmark,
|
|
43079
|
+
void 0,
|
|
43080
|
+
void 0,
|
|
43081
|
+
void 0,
|
|
43082
|
+
void 0,
|
|
43083
|
+
paragraphRunRenderOptions,
|
|
43084
|
+
void 0,
|
|
43085
|
+
void 0,
|
|
43086
|
+
tableCellEditScope,
|
|
43087
|
+
void 0,
|
|
43088
|
+
embeddedTableResizeController
|
|
43089
|
+
);
|
|
43090
|
+
}
|
|
43091
|
+
);
|
|
43092
|
+
};
|
|
42351
43093
|
return /* @__PURE__ */ jsx(
|
|
42352
43094
|
"td",
|
|
42353
43095
|
{
|
|
@@ -43233,68 +43975,27 @@ ${currentText.slice(end)}`;
|
|
|
43233
43975
|
);
|
|
43234
43976
|
})
|
|
43235
43977
|
}
|
|
43236
|
-
) : /* @__PURE__ */ jsx(
|
|
43237
|
-
|
|
43238
|
-
|
|
43239
|
-
|
|
43240
|
-
|
|
43241
|
-
|
|
43242
|
-
|
|
43243
|
-
|
|
43244
|
-
|
|
43245
|
-
|
|
43246
|
-
|
|
43247
|
-
|
|
43248
|
-
|
|
43249
|
-
|
|
43250
|
-
|
|
43251
|
-
|
|
43252
|
-
|
|
43253
|
-
style: tableCellParagraphBlockStyle(
|
|
43254
|
-
cellContent,
|
|
43255
|
-
editor.model.metadata.numberingDefinitions,
|
|
43256
|
-
headingStyles,
|
|
43257
|
-
paragraphIndex,
|
|
43258
|
-
applyWordTableDefaults,
|
|
43259
|
-
nodeDocGridLinePitchPx
|
|
43260
|
-
),
|
|
43261
|
-
children: renderInteractiveParagraphRuns(
|
|
43262
|
-
cellContent,
|
|
43263
|
-
`body-cell-${nodeIndex}-${rowIndex}-${cellIndex}-${contentIndex}`,
|
|
43264
|
-
{
|
|
43265
|
-
kind: "table-cell",
|
|
43266
|
-
tableIndex: nodeIndex,
|
|
43267
|
-
rowIndex,
|
|
43268
|
-
cellIndex,
|
|
43269
|
-
paragraphIndex
|
|
43270
|
-
}
|
|
43271
|
-
)
|
|
43272
|
-
},
|
|
43273
|
-
`body-cell-p-${nodeIndex}-${rowIndex}-${cellIndex}-${contentIndex}`
|
|
43274
|
-
);
|
|
43978
|
+
) : isSlicedRow && slicedCellViewportHeightPx ? /* @__PURE__ */ jsx(
|
|
43979
|
+
"div",
|
|
43980
|
+
{
|
|
43981
|
+
style: {
|
|
43982
|
+
height: slicedCellViewportHeightPx,
|
|
43983
|
+
overflow: "hidden",
|
|
43984
|
+
position: "relative"
|
|
43985
|
+
},
|
|
43986
|
+
children: /* @__PURE__ */ jsx(
|
|
43987
|
+
"div",
|
|
43988
|
+
{
|
|
43989
|
+
style: {
|
|
43990
|
+
display: "grid",
|
|
43991
|
+
gap: 0,
|
|
43992
|
+
transform: `translateY(-${tableRowSliceOffsetPx}px)`
|
|
43993
|
+
},
|
|
43994
|
+
children: renderStaticCellContent()
|
|
43275
43995
|
}
|
|
43276
|
-
|
|
43277
|
-
|
|
43278
|
-
|
|
43279
|
-
documentContentTheme,
|
|
43280
|
-
editor.model.metadata.numberingDefinitions,
|
|
43281
|
-
headingStyles,
|
|
43282
|
-
spannedWidthPx > 0 ? spannedWidthPx : void 0,
|
|
43283
|
-
scrollToBookmark,
|
|
43284
|
-
void 0,
|
|
43285
|
-
void 0,
|
|
43286
|
-
void 0,
|
|
43287
|
-
void 0,
|
|
43288
|
-
paragraphRunRenderOptions,
|
|
43289
|
-
void 0,
|
|
43290
|
-
void 0,
|
|
43291
|
-
tableCellEditScope,
|
|
43292
|
-
void 0,
|
|
43293
|
-
embeddedTableResizeController
|
|
43294
|
-
);
|
|
43295
|
-
}
|
|
43296
|
-
);
|
|
43297
|
-
})() })
|
|
43996
|
+
)
|
|
43997
|
+
}
|
|
43998
|
+
) : /* @__PURE__ */ jsx("div", { style: { display: "grid", gap: 0 }, children: renderStaticCellContent() })
|
|
43298
43999
|
},
|
|
43299
44000
|
`cell-${nodeIndex}-${rowIndex}-${cellIndex}`
|
|
43300
44001
|
);
|
|
@@ -44353,8 +45054,11 @@ ${currentText.slice(end)}`;
|
|
|
44353
45054
|
() => new Map(endnotes.map((note) => [note.id, note])),
|
|
44354
45055
|
[endnotes]
|
|
44355
45056
|
);
|
|
44356
|
-
const pageFootnotesByIndex = React.useMemo(
|
|
44357
|
-
(
|
|
45057
|
+
const pageFootnotesByIndex = React.useMemo(() => {
|
|
45058
|
+
if (footnotes.length === 0) {
|
|
45059
|
+
return pageNodeSegmentsByPage.map(() => []);
|
|
45060
|
+
}
|
|
45061
|
+
return pageNodeSegmentsByPage.map((nodeSegments) => {
|
|
44358
45062
|
const referencedIds = [];
|
|
44359
45063
|
const seen = /* @__PURE__ */ new Set();
|
|
44360
45064
|
nodeSegments.forEach((segment) => {
|
|
@@ -44376,10 +45080,17 @@ ${currentText.slice(end)}`;
|
|
|
44376
45080
|
});
|
|
44377
45081
|
});
|
|
44378
45082
|
return referencedIds.map((referenceId) => footnotesById.get(referenceId)).filter((note) => Boolean(note));
|
|
44379
|
-
})
|
|
44380
|
-
|
|
44381
|
-
|
|
45083
|
+
});
|
|
45084
|
+
}, [
|
|
45085
|
+
editor.model.nodes,
|
|
45086
|
+
footnotes.length,
|
|
45087
|
+
footnotesById,
|
|
45088
|
+
pageNodeSegmentsByPage
|
|
45089
|
+
]);
|
|
44382
45090
|
const referencedEndnotes = React.useMemo(() => {
|
|
45091
|
+
if (endnotes.length === 0) {
|
|
45092
|
+
return endnotes;
|
|
45093
|
+
}
|
|
44383
45094
|
const referencedIds = [];
|
|
44384
45095
|
const seen = /* @__PURE__ */ new Set();
|
|
44385
45096
|
editor.model.nodes.forEach((node) => {
|
|
@@ -44586,6 +45297,35 @@ ${currentText.slice(end)}`;
|
|
|
44586
45297
|
children: "Drop .docx anywhere to replace current document"
|
|
44587
45298
|
}
|
|
44588
45299
|
) : null,
|
|
45300
|
+
editor.importError ? /* @__PURE__ */ jsxs(
|
|
45301
|
+
"div",
|
|
45302
|
+
{
|
|
45303
|
+
role: "alert",
|
|
45304
|
+
"data-docx-import-error": "true",
|
|
45305
|
+
style: {
|
|
45306
|
+
position: "absolute",
|
|
45307
|
+
top: 24,
|
|
45308
|
+
left: "50%",
|
|
45309
|
+
transform: "translateX(-50%)",
|
|
45310
|
+
zIndex: 80,
|
|
45311
|
+
width: "min(520px, calc(100% - 32px))",
|
|
45312
|
+
display: "grid",
|
|
45313
|
+
gap: 6,
|
|
45314
|
+
padding: "12px 14px",
|
|
45315
|
+
borderRadius: 8,
|
|
45316
|
+
border: `1px solid ${editor.documentTheme === "dark" ? "rgba(248, 113, 113, 0.42)" : "rgba(185, 28, 28, 0.26)"}`,
|
|
45317
|
+
backgroundColor: editor.documentTheme === "dark" ? "rgba(69, 10, 10, 0.96)" : "rgba(254, 242, 242, 0.98)",
|
|
45318
|
+
color: editor.documentTheme === "dark" ? "#fee2e2" : "#7f1d1d",
|
|
45319
|
+
boxShadow: editor.documentTheme === "dark" ? "0 12px 28px rgba(2, 6, 23, 0.44)" : "0 12px 28px rgba(127, 29, 29, 0.12)",
|
|
45320
|
+
fontSize: 13,
|
|
45321
|
+
lineHeight: 1.35
|
|
45322
|
+
},
|
|
45323
|
+
children: [
|
|
45324
|
+
/* @__PURE__ */ jsx("strong", { style: { fontWeight: 600 }, children: "Failed to load DOCX" }),
|
|
45325
|
+
/* @__PURE__ */ jsx("span", { style: { overflowWrap: "anywhere" }, children: editor.importError.message })
|
|
45326
|
+
]
|
|
45327
|
+
}
|
|
45328
|
+
) : null,
|
|
44589
45329
|
tableMoveDropPreview && !isReadOnly ? /* @__PURE__ */ jsx(
|
|
44590
45330
|
"div",
|
|
44591
45331
|
{
|
|
@@ -44609,6 +45349,7 @@ ${currentText.slice(end)}`;
|
|
|
44609
45349
|
const pageVisible = isPageVisible(pageIndex);
|
|
44610
45350
|
const pageWrapperWidthPx = showTrackedChangeGutter ? pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX : pageLayout.pageWidthPx;
|
|
44611
45351
|
if (!pageVisible) {
|
|
45352
|
+
const placeholderBackgroundColor = pageBackgroundColor ?? editor.model.metadata.documentBackgroundColor ?? pageSurfaceBaseStyle.backgroundColor;
|
|
44612
45353
|
return /* @__PURE__ */ jsx(
|
|
44613
45354
|
"div",
|
|
44614
45355
|
{
|
|
@@ -44626,8 +45367,12 @@ ${currentText.slice(end)}`;
|
|
|
44626
45367
|
"data-docx-page-placeholder": "true",
|
|
44627
45368
|
ref: pagePlaceholderRefForIndex(pageIndex),
|
|
44628
45369
|
style: {
|
|
45370
|
+
...pageSurfaceBaseStyle,
|
|
44629
45371
|
height: pageLayout.pageHeightPx,
|
|
44630
|
-
|
|
45372
|
+
minHeight: pageLayout.pageHeightPx,
|
|
45373
|
+
width: pageLayout.pageWidthPx,
|
|
45374
|
+
backgroundColor: placeholderBackgroundColor,
|
|
45375
|
+
pointerEvents: "none"
|
|
44631
45376
|
}
|
|
44632
45377
|
}
|
|
44633
45378
|
)
|
|
@@ -45085,6 +45830,14 @@ ${currentText.slice(end)}`;
|
|
|
45085
45830
|
}
|
|
45086
45831
|
);
|
|
45087
45832
|
const explicitColumnWidthsPx = sectionColumns && sectionColumns.widthsPx?.length === sectionColumns.count ? sectionColumns.widthsPx : void 0;
|
|
45833
|
+
const flowSegmentsHaveExplicitColumnBreak = flowSegments.some((segment) => {
|
|
45834
|
+
if (segment.tableRowRange) {
|
|
45835
|
+
return false;
|
|
45836
|
+
}
|
|
45837
|
+
const segmentNode = editor.model.nodes[segment.nodeIndex];
|
|
45838
|
+
return segmentNode?.type === "paragraph" && paragraphHasExplicitColumnBreak(segmentNode);
|
|
45839
|
+
});
|
|
45840
|
+
const canUseColumnLineSplitRender = flowSegments.length > 0 && !flowSegmentsHaveExplicitColumnBreak;
|
|
45088
45841
|
const renderSegmentInColumn = (columnSegment, columnContentWidthPx) => {
|
|
45089
45842
|
const columnNode = editor.model.nodes[columnSegment.nodeIndex];
|
|
45090
45843
|
if (!columnNode) {
|
|
@@ -45116,7 +45869,8 @@ ${currentText.slice(end)}`;
|
|
|
45116
45869
|
suppressParagraphElementTracking: segmentIndex > 0,
|
|
45117
45870
|
syntheticKeySuffix: `column-break-${segmentIndex}`,
|
|
45118
45871
|
overrideBeforeSpacingPx: segmentIndex === 0 ? void 0 : 0,
|
|
45119
|
-
overrideAfterSpacingPx: isLastSegment ? void 0 : 0
|
|
45872
|
+
overrideAfterSpacingPx: isLastSegment ? void 0 : 0,
|
|
45873
|
+
normalizeParagraphHostFontSize: true
|
|
45120
45874
|
}
|
|
45121
45875
|
)
|
|
45122
45876
|
},
|
|
@@ -45137,7 +45891,8 @@ ${currentText.slice(end)}`;
|
|
|
45137
45891
|
{
|
|
45138
45892
|
pageLayout,
|
|
45139
45893
|
contentWidthPxOverride: columnContentWidthPx,
|
|
45140
|
-
suppressLikelyFullPageCoverImageKeys: suppressedLikelyFullPageCoverImageKeys
|
|
45894
|
+
suppressLikelyFullPageCoverImageKeys: suppressedLikelyFullPageCoverImageKeys,
|
|
45895
|
+
normalizeParagraphHostFontSize: true
|
|
45141
45896
|
}
|
|
45142
45897
|
);
|
|
45143
45898
|
const segmentKeySuffix = columnSegment.tableRowRange ? `rows-${columnSegment.tableRowRange.startRowIndex}-${columnSegment.tableRowRange.endRowIndex}${columnSegment.tableRowSlice ? `-slice-${Math.max(
|
|
@@ -45176,7 +45931,91 @@ ${currentText.slice(end)}`;
|
|
|
45176
45931
|
"div",
|
|
45177
45932
|
{
|
|
45178
45933
|
style: { position: "relative" },
|
|
45179
|
-
children:
|
|
45934
|
+
children: canUseColumnLineSplitRender ? (() => {
|
|
45935
|
+
const columnWidthsPx = explicitColumnWidthsPx && explicitColumnWidthsPx.length === sectionColumns.count ? explicitColumnWidthsPx : (() => {
|
|
45936
|
+
const inferredColumnWidthPx = Math.max(
|
|
45937
|
+
120,
|
|
45938
|
+
Math.round(
|
|
45939
|
+
(pageContentWidthPx - sectionColumns.gapPx * Math.max(
|
|
45940
|
+
0,
|
|
45941
|
+
sectionColumns.count - 1
|
|
45942
|
+
)) / Math.max(1, sectionColumns.count)
|
|
45943
|
+
)
|
|
45944
|
+
);
|
|
45945
|
+
return Array.from(
|
|
45946
|
+
{ length: sectionColumns.count },
|
|
45947
|
+
() => inferredColumnWidthPx
|
|
45948
|
+
);
|
|
45949
|
+
})();
|
|
45950
|
+
const columnSegments = buildRenderColumnSegmentsForPageSection(
|
|
45951
|
+
editor.model,
|
|
45952
|
+
flowSegments,
|
|
45953
|
+
columnWidthsPx,
|
|
45954
|
+
pageBodyAvailableHeightPx,
|
|
45955
|
+
editor.model.metadata.numberingDefinitions,
|
|
45956
|
+
docGridLinePitchPxByNodeIndex,
|
|
45957
|
+
measuredParagraphOuterHeightsPxByNodeIndex,
|
|
45958
|
+
isLastPage
|
|
45959
|
+
);
|
|
45960
|
+
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
45961
|
+
overlaySegments.map((overlaySegment) => {
|
|
45962
|
+
const overlayNode = editor.model.nodes[overlaySegment.nodeIndex];
|
|
45963
|
+
if (!overlayNode) {
|
|
45964
|
+
return null;
|
|
45965
|
+
}
|
|
45966
|
+
return /* @__PURE__ */ jsx(
|
|
45967
|
+
React.Fragment,
|
|
45968
|
+
{
|
|
45969
|
+
children: renderDocumentNode(
|
|
45970
|
+
overlayNode,
|
|
45971
|
+
overlaySegment.nodeIndex,
|
|
45972
|
+
overlaySegment.tableRowRange,
|
|
45973
|
+
overlaySegment.tableRowSlice,
|
|
45974
|
+
overlaySegment.paragraphLineRange,
|
|
45975
|
+
{
|
|
45976
|
+
pageLayout,
|
|
45977
|
+
suppressLikelyFullPageCoverImageKeys: suppressedLikelyFullPageCoverImageKeys
|
|
45978
|
+
}
|
|
45979
|
+
)
|
|
45980
|
+
},
|
|
45981
|
+
`column-layout-overlay-${pageIndex}-${overlaySegment.nodeIndex}-${segmentIdentityKey(
|
|
45982
|
+
overlaySegment
|
|
45983
|
+
)}`
|
|
45984
|
+
);
|
|
45985
|
+
}),
|
|
45986
|
+
/* @__PURE__ */ jsx(
|
|
45987
|
+
"div",
|
|
45988
|
+
{
|
|
45989
|
+
style: {
|
|
45990
|
+
display: "grid",
|
|
45991
|
+
gridTemplateColumns: columnWidthsPx.map((widthPx) => `${widthPx}px`).join(" "),
|
|
45992
|
+
columnGap: sectionColumns.gapPx,
|
|
45993
|
+
alignItems: "start",
|
|
45994
|
+
minHeight: pageBodyAvailableHeightPx,
|
|
45995
|
+
position: "relative",
|
|
45996
|
+
zIndex: 1
|
|
45997
|
+
},
|
|
45998
|
+
children: columnSegments.map(
|
|
45999
|
+
(segmentsForColumn, columnIndex) => /* @__PURE__ */ jsx(
|
|
46000
|
+
"div",
|
|
46001
|
+
{
|
|
46002
|
+
style: {
|
|
46003
|
+
minHeight: pageBodyAvailableHeightPx
|
|
46004
|
+
},
|
|
46005
|
+
children: segmentsForColumn.map(
|
|
46006
|
+
(segment) => renderSegmentInColumn(
|
|
46007
|
+
segment,
|
|
46008
|
+
columnWidthsPx[columnIndex]
|
|
46009
|
+
)
|
|
46010
|
+
)
|
|
46011
|
+
},
|
|
46012
|
+
`column-layout-flow-${pageIndex}-${groupIndex}-${columnIndex}`
|
|
46013
|
+
)
|
|
46014
|
+
)
|
|
46015
|
+
}
|
|
46016
|
+
)
|
|
46017
|
+
] });
|
|
46018
|
+
})() : explicitColumnWidthsPx && explicitColumnWidthsPx.length === 2 && flowSegments.length > 0 ? (() => {
|
|
45180
46019
|
const [leftColumnWidthPx, rightColumnWidthPx] = explicitColumnWidthsPx;
|
|
45181
46020
|
const prefixHeightsPx = new Array(
|
|
45182
46021
|
flowSegments.length + 1
|
|
@@ -47490,6 +48329,7 @@ function buildDocumentPageNodeSegments2(model, pageContentHeightPx, pageContentW
|
|
|
47490
48329
|
);
|
|
47491
48330
|
}
|
|
47492
48331
|
let rowStartIndex = 0;
|
|
48332
|
+
let tableBreakStartRowCursor = 0;
|
|
47493
48333
|
while (rowStartIndex < estimatedRowHeightsPx.length) {
|
|
47494
48334
|
const remainingHeightPx = Math.max(0, currentPageContentHeightPx - pageConsumedHeightPx);
|
|
47495
48335
|
const fittedRowEndIndex = fitTableRowsWithinHeightPx2(
|
|
@@ -47501,9 +48341,10 @@ function buildDocumentPageNodeSegments2(model, pageContentHeightPx, pageContentW
|
|
|
47501
48341
|
pageOverflowTolerancePx
|
|
47502
48342
|
);
|
|
47503
48343
|
let rowEndIndex = fittedRowEndIndex;
|
|
47504
|
-
|
|
47505
|
-
|
|
47506
|
-
|
|
48344
|
+
while (tableBreakStartRowCursor < tableBreakStartRows.length && tableBreakStartRows[tableBreakStartRowCursor] <= rowStartIndex) {
|
|
48345
|
+
tableBreakStartRowCursor += 1;
|
|
48346
|
+
}
|
|
48347
|
+
const forcedBreakRowIndex = tableBreakStartRows[tableBreakStartRowCursor];
|
|
47507
48348
|
if (forcedBreakRowIndex !== void 0) {
|
|
47508
48349
|
rowEndIndex = Math.min(rowEndIndex, forcedBreakRowIndex);
|
|
47509
48350
|
}
|