@superdoc-dev/cli 0.16.0-next.27 → 0.16.0-next.28
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 +1885 -278
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -10805,7 +10805,10 @@ var init_schemas = __esm(() => {
|
|
|
10805
10805
|
"sectionDefaults"
|
|
10806
10806
|
]
|
|
10807
10807
|
};
|
|
10808
|
-
const scopeReportSchema = objectSchema({ scope: scopeEnum, part: { type: "string" }, detail: { type: "string" } }, [
|
|
10808
|
+
const scopeReportSchema = objectSchema({ scope: scopeEnum, part: { type: "string" }, detail: { type: "string" } }, [
|
|
10809
|
+
"scope",
|
|
10810
|
+
"part"
|
|
10811
|
+
]);
|
|
10809
10812
|
const scopeSkipSchema = objectSchema({
|
|
10810
10813
|
scope: { type: "string" },
|
|
10811
10814
|
part: { type: "string" },
|
|
@@ -68345,7 +68348,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
|
|
|
68345
68348
|
emptyOptions2 = {};
|
|
68346
68349
|
});
|
|
68347
68350
|
|
|
68348
|
-
// ../../packages/superdoc/dist/chunks/SuperConverter-
|
|
68351
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-D2zNnC50.es.js
|
|
68349
68352
|
function getExtensionConfigField(extension$1, field, context = { name: "" }) {
|
|
68350
68353
|
const fieldValue = extension$1.config[field];
|
|
68351
68354
|
if (typeof fieldValue === "function")
|
|
@@ -76839,8 +76842,8 @@ function createBorderPropertyHandler(xmlName, sdName = null) {
|
|
|
76839
76842
|
createAttributeHandler("w:themeColor"),
|
|
76840
76843
|
createAttributeHandler("w:themeTint"),
|
|
76841
76844
|
createAttributeHandler("w:themeShade"),
|
|
76842
|
-
createAttributeHandler("w:sz", "size", parseInteger, integerToString),
|
|
76843
|
-
createAttributeHandler("w:space", null, parseInteger, integerToString),
|
|
76845
|
+
createAttributeHandler("w:sz", "size", parseInteger$1, integerToString),
|
|
76846
|
+
createAttributeHandler("w:space", null, parseInteger$1, integerToString),
|
|
76844
76847
|
createAttributeHandler("w:shadow", null, parseBoolean, booleanToString),
|
|
76845
76848
|
createAttributeHandler("w:frame", null, parseBoolean, booleanToString)
|
|
76846
76849
|
],
|
|
@@ -77045,7 +77048,7 @@ function readAttr(attributes, key) {
|
|
|
77045
77048
|
return attributes?.[`w14:${key}`] ?? attributes?.[`w:${key}`];
|
|
77046
77049
|
}
|
|
77047
77050
|
function encodeStylisticSet(node3) {
|
|
77048
|
-
const id2 = parseInteger(readAttr(node3?.attributes, "id"));
|
|
77051
|
+
const id2 = parseInteger$1(readAttr(node3?.attributes, "id"));
|
|
77049
77052
|
if (id2 == null)
|
|
77050
77053
|
return;
|
|
77051
77054
|
const valRaw = readAttr(node3?.attributes, "val");
|
|
@@ -78370,11 +78373,25 @@ function widthsEqual(a, b) {
|
|
|
78370
78373
|
return false;
|
|
78371
78374
|
return true;
|
|
78372
78375
|
}
|
|
78376
|
+
function usableExplicitWidths(input) {
|
|
78377
|
+
if (!input || input.equalWidth !== false || !Array.isArray(input.widths))
|
|
78378
|
+
return [];
|
|
78379
|
+
return input.widths.filter((width) => typeof width === "number" && Number.isFinite(width) && width > 0);
|
|
78380
|
+
}
|
|
78381
|
+
function resolveColumnMode(input) {
|
|
78382
|
+
return usableExplicitWidths(input).length > 0 ? "explicit" : "equal";
|
|
78383
|
+
}
|
|
78384
|
+
function resolveColumnCount(input) {
|
|
78385
|
+
const rawCount = input && Number.isFinite(input.count) ? Math.max(1, Math.floor(input.count)) : 1;
|
|
78386
|
+
const explicit = usableExplicitWidths(input);
|
|
78387
|
+
return explicit.length > 0 ? Math.min(rawCount, explicit.length) : rawCount;
|
|
78388
|
+
}
|
|
78373
78389
|
function cloneColumnLayout(columns) {
|
|
78374
78390
|
return columns ? {
|
|
78375
78391
|
count: columns.count,
|
|
78376
78392
|
gap: columns.gap,
|
|
78377
78393
|
...Array.isArray(columns.widths) ? { widths: [...columns.widths] } : {},
|
|
78394
|
+
...Array.isArray(columns.gaps) ? { gaps: [...columns.gaps] } : {},
|
|
78378
78395
|
...columns.equalWidth !== undefined ? { equalWidth: columns.equalWidth } : {},
|
|
78379
78396
|
...columns.withSeparator !== undefined ? { withSeparator: columns.withSeparator } : {}
|
|
78380
78397
|
} : {
|
|
@@ -78382,13 +78399,45 @@ function cloneColumnLayout(columns) {
|
|
|
78382
78399
|
gap: 0
|
|
78383
78400
|
};
|
|
78384
78401
|
}
|
|
78402
|
+
function resolveColumnLayout(input) {
|
|
78403
|
+
const count2 = resolveColumnCount(input);
|
|
78404
|
+
const resolved = cloneColumnLayout(input);
|
|
78405
|
+
resolved.count = count2;
|
|
78406
|
+
if (resolveColumnMode(input) === "explicit") {
|
|
78407
|
+
if (Array.isArray(resolved.widths))
|
|
78408
|
+
resolved.widths = resolved.widths.slice(0, count2);
|
|
78409
|
+
if (Array.isArray(resolved.gaps))
|
|
78410
|
+
resolved.gaps = resolved.gaps.slice(0, Math.max(0, count2 - 1));
|
|
78411
|
+
} else {
|
|
78412
|
+
delete resolved.widths;
|
|
78413
|
+
delete resolved.gaps;
|
|
78414
|
+
}
|
|
78415
|
+
return resolved;
|
|
78416
|
+
}
|
|
78417
|
+
function buildColumnGeometry(widths, gap, withSeparator) {
|
|
78418
|
+
const geometry = [];
|
|
78419
|
+
let x = 0;
|
|
78420
|
+
for (let i$1 = 0;i$1 < widths.length; i$1 += 1) {
|
|
78421
|
+
const width = widths[i$1];
|
|
78422
|
+
const isLast = i$1 === widths.length - 1;
|
|
78423
|
+
const gapAfter = isLast ? 0 : gap;
|
|
78424
|
+
const col = {
|
|
78425
|
+
index: i$1,
|
|
78426
|
+
x,
|
|
78427
|
+
width,
|
|
78428
|
+
gapAfter
|
|
78429
|
+
};
|
|
78430
|
+
if (withSeparator && !isLast)
|
|
78431
|
+
col.separatorX = x + width + gap / 2;
|
|
78432
|
+
geometry.push(col);
|
|
78433
|
+
x += width + gapAfter;
|
|
78434
|
+
}
|
|
78435
|
+
return geometry;
|
|
78436
|
+
}
|
|
78385
78437
|
function normalizeColumnLayout(input, contentWidth, epsilon = 0.0001) {
|
|
78386
|
-
const
|
|
78387
|
-
let count2 = Math.max(1, rawCount || 1);
|
|
78438
|
+
const count2 = resolveColumnCount(input);
|
|
78388
78439
|
const gap = Math.max(0, input?.gap ?? 0);
|
|
78389
|
-
const explicitWidths =
|
|
78390
|
-
if (explicitWidths.length > 0 && explicitWidths.length < count2)
|
|
78391
|
-
count2 = explicitWidths.length;
|
|
78440
|
+
const explicitWidths = usableExplicitWidths(input);
|
|
78392
78441
|
const availableWidth = contentWidth - gap * (count2 - 1);
|
|
78393
78442
|
let widths = explicitWidths.length > 0 ? explicitWidths.slice(0, count2) : Array.from({ length: count2 }, () => availableWidth > 0 ? availableWidth / count2 : contentWidth);
|
|
78394
78443
|
if (widths.length < count2) {
|
|
@@ -78418,6 +78467,45 @@ function normalizeColumnLayout(input, contentWidth, epsilon = 0.0001) {
|
|
|
78418
78467
|
width
|
|
78419
78468
|
};
|
|
78420
78469
|
}
|
|
78470
|
+
function getColumnGeometry(normalized) {
|
|
78471
|
+
return buildColumnGeometry(Array.isArray(normalized.widths) && normalized.widths.length > 0 ? normalized.widths : [normalized.width], normalized.gap, Boolean(normalized.withSeparator));
|
|
78472
|
+
}
|
|
78473
|
+
function clampColumnIndex(geometry, index2) {
|
|
78474
|
+
if (geometry.length === 0)
|
|
78475
|
+
return 0;
|
|
78476
|
+
return Math.max(0, Math.min(index2, geometry.length - 1));
|
|
78477
|
+
}
|
|
78478
|
+
function getColumnWidth(geometry, index2) {
|
|
78479
|
+
return geometry[clampColumnIndex(geometry, index2)]?.width ?? 0;
|
|
78480
|
+
}
|
|
78481
|
+
function getColumnX(geometry, index2, originX = 0) {
|
|
78482
|
+
return originX + (geometry[clampColumnIndex(geometry, index2)]?.x ?? 0);
|
|
78483
|
+
}
|
|
78484
|
+
function getColumnSeparatorPositions(geometry, originX = 0) {
|
|
78485
|
+
return geometry.filter((col) => typeof col.separatorX === "number").map((col) => originX + col.separatorX);
|
|
78486
|
+
}
|
|
78487
|
+
function columnRenderLayoutsEqual(a, b) {
|
|
78488
|
+
if (!a && !b)
|
|
78489
|
+
return true;
|
|
78490
|
+
if (!a || !b)
|
|
78491
|
+
return false;
|
|
78492
|
+
const mode = resolveColumnMode(a);
|
|
78493
|
+
if (mode !== resolveColumnMode(b))
|
|
78494
|
+
return false;
|
|
78495
|
+
if (resolveColumnCount(a) !== resolveColumnCount(b))
|
|
78496
|
+
return false;
|
|
78497
|
+
if ((a.gap ?? 0) !== (b.gap ?? 0))
|
|
78498
|
+
return false;
|
|
78499
|
+
if (Boolean(a.withSeparator) !== Boolean(b.withSeparator))
|
|
78500
|
+
return false;
|
|
78501
|
+
if (mode === "explicit") {
|
|
78502
|
+
const ra = resolveColumnLayout(a);
|
|
78503
|
+
const rb = resolveColumnLayout(b);
|
|
78504
|
+
if (!widthsEqual(ra.widths, rb.widths))
|
|
78505
|
+
return false;
|
|
78506
|
+
}
|
|
78507
|
+
return true;
|
|
78508
|
+
}
|
|
78421
78509
|
function getIdlessSdtContainerKey(metadata) {
|
|
78422
78510
|
const existingKey = idlessSdtContainerKeys.get(metadata);
|
|
78423
78511
|
if (existingKey)
|
|
@@ -78524,6 +78612,21 @@ function toUpperLetter$1(value) {
|
|
|
78524
78612
|
const repeatCount = Math.floor((normalized - 1) / 26) + 1;
|
|
78525
78613
|
return String.fromCharCode(65 + index2).repeat(repeatCount);
|
|
78526
78614
|
}
|
|
78615
|
+
function toOrdinal(value) {
|
|
78616
|
+
const remainder = value % 100;
|
|
78617
|
+
if (remainder >= 11 && remainder <= 13)
|
|
78618
|
+
return `${value}th`;
|
|
78619
|
+
switch (value % 10) {
|
|
78620
|
+
case 1:
|
|
78621
|
+
return `${value}st`;
|
|
78622
|
+
case 2:
|
|
78623
|
+
return `${value}nd`;
|
|
78624
|
+
case 3:
|
|
78625
|
+
return `${value}rd`;
|
|
78626
|
+
default:
|
|
78627
|
+
return `${value}th`;
|
|
78628
|
+
}
|
|
78629
|
+
}
|
|
78527
78630
|
function formatPageNumber(pageNumber, format) {
|
|
78528
78631
|
const value = Math.max(1, Math.trunc(Number.isFinite(pageNumber) ? pageNumber : 1));
|
|
78529
78632
|
switch (format) {
|
|
@@ -78537,12 +78640,16 @@ function formatPageNumber(pageNumber, format) {
|
|
|
78537
78640
|
return toUpperLetter$1(value).toLowerCase();
|
|
78538
78641
|
case "numberInDash":
|
|
78539
78642
|
return `- ${value} -`;
|
|
78643
|
+
case "ordinal":
|
|
78644
|
+
return toOrdinal(value);
|
|
78540
78645
|
case "decimal":
|
|
78541
78646
|
default:
|
|
78542
78647
|
return String(value);
|
|
78543
78648
|
}
|
|
78544
78649
|
}
|
|
78545
|
-
function formatPageNumberFieldValue
|
|
78650
|
+
function formatPageNumberFieldValue(pageNumber, fieldFormat) {
|
|
78651
|
+
if (fieldFormat?.numericPicture)
|
|
78652
|
+
return formatIntegerWithNumericPicture(Math.max(1, Math.trunc(Number.isFinite(pageNumber) ? pageNumber : 1)), fieldFormat.numericPicture);
|
|
78546
78653
|
const format = fieldFormat?.format ?? "decimal";
|
|
78547
78654
|
const formatted = formatPageNumber(pageNumber, format);
|
|
78548
78655
|
return fieldFormat?.zeroPadding && format === "decimal" ? formatted.padStart(fieldFormat.zeroPadding, "0") : formatted;
|
|
@@ -78574,6 +78681,373 @@ function formatSectionPageNumberText(args2) {
|
|
|
78574
78681
|
chapterSeparator: args2.chapterSeparator
|
|
78575
78682
|
});
|
|
78576
78683
|
}
|
|
78684
|
+
function formatIntegerWithNumericPicture(value, picture) {
|
|
78685
|
+
const integerValue = Math.trunc(Number.isFinite(value) ? value : 0);
|
|
78686
|
+
const sections = splitPictureSections(typeof picture === "string" && picture.length > 0 ? picture : "0");
|
|
78687
|
+
const hasExplicitNegativeSection = integerValue < 0 && sections[1] != null;
|
|
78688
|
+
const section = integerValue > 0 ? sections[0] : integerValue < 0 ? sections[1] ?? sections[0] : sections[2] ?? sections[0];
|
|
78689
|
+
return formatNumericPictureSection(Math.abs(integerValue), integerValue < 0, section ?? "0", hasExplicitNegativeSection);
|
|
78690
|
+
}
|
|
78691
|
+
function splitPictureSections(picture) {
|
|
78692
|
+
const sections = [];
|
|
78693
|
+
let current = "";
|
|
78694
|
+
let inQuote = false;
|
|
78695
|
+
for (let index2 = 0;index2 < picture.length; index2 += 1) {
|
|
78696
|
+
const char = picture[index2];
|
|
78697
|
+
if (char === "'") {
|
|
78698
|
+
inQuote = !inQuote;
|
|
78699
|
+
current += char;
|
|
78700
|
+
continue;
|
|
78701
|
+
}
|
|
78702
|
+
if (char === ";" && !inQuote) {
|
|
78703
|
+
sections.push(current);
|
|
78704
|
+
current = "";
|
|
78705
|
+
continue;
|
|
78706
|
+
}
|
|
78707
|
+
current += char;
|
|
78708
|
+
}
|
|
78709
|
+
sections.push(current);
|
|
78710
|
+
return sections;
|
|
78711
|
+
}
|
|
78712
|
+
function tokenizePicture(section) {
|
|
78713
|
+
const tokens = [];
|
|
78714
|
+
for (let index2 = 0;index2 < section.length; index2 += 1) {
|
|
78715
|
+
const char = section[index2];
|
|
78716
|
+
if (char === "'") {
|
|
78717
|
+
let literal = "";
|
|
78718
|
+
index2 += 1;
|
|
78719
|
+
while (index2 < section.length && section[index2] !== "'") {
|
|
78720
|
+
literal += section[index2];
|
|
78721
|
+
index2 += 1;
|
|
78722
|
+
}
|
|
78723
|
+
tokens.push({
|
|
78724
|
+
kind: "literal",
|
|
78725
|
+
value: literal
|
|
78726
|
+
});
|
|
78727
|
+
continue;
|
|
78728
|
+
}
|
|
78729
|
+
if (char === "0" || char === "#" || char === "x" || char === "," || char === "." || char === "+" || char === "-")
|
|
78730
|
+
tokens.push({
|
|
78731
|
+
kind: "placeholder",
|
|
78732
|
+
value: char
|
|
78733
|
+
});
|
|
78734
|
+
else
|
|
78735
|
+
tokens.push({
|
|
78736
|
+
kind: "literal",
|
|
78737
|
+
value: char
|
|
78738
|
+
});
|
|
78739
|
+
}
|
|
78740
|
+
return tokens;
|
|
78741
|
+
}
|
|
78742
|
+
function formatNumericPictureSection(value, isNegative, section, suppressDefaultNegative = false) {
|
|
78743
|
+
const tokens = tokenizePicture(section);
|
|
78744
|
+
const decimalIndex = tokens.findIndex((token) => token.kind === "placeholder" && token.value === ".");
|
|
78745
|
+
const integerTokens = decimalIndex >= 0 ? tokens.slice(0, decimalIndex) : tokens;
|
|
78746
|
+
const fractionalTokens = decimalIndex >= 0 ? tokens.slice(decimalIndex + 1) : [];
|
|
78747
|
+
const integerPart = formatIntegerPictureTokens(value, isNegative, integerTokens, suppressDefaultNegative);
|
|
78748
|
+
const fractionalPart = formatFractionalPictureTokens(fractionalTokens);
|
|
78749
|
+
return fractionalTokens.length > 0 ? `${integerPart}.${fractionalPart}` : integerPart;
|
|
78750
|
+
}
|
|
78751
|
+
function formatIntegerPictureTokens(value, isNegative, tokens, suppressDefaultNegative) {
|
|
78752
|
+
let xIndex = -1;
|
|
78753
|
+
for (let index2 = tokens.length - 1;index2 >= 0; index2 -= 1) {
|
|
78754
|
+
const token = tokens[index2];
|
|
78755
|
+
if (token.kind === "placeholder" && token.value === "x") {
|
|
78756
|
+
xIndex = index2;
|
|
78757
|
+
break;
|
|
78758
|
+
}
|
|
78759
|
+
}
|
|
78760
|
+
const activeTokens = xIndex >= 0 ? tokens.slice(xIndex + 1) : tokens;
|
|
78761
|
+
const placeholderCount = activeTokens.filter((token) => token.kind === "placeholder" && (token.value === "0" || token.value === "#")).length;
|
|
78762
|
+
const rawDigits = String(value);
|
|
78763
|
+
const digits = xIndex >= 0 && placeholderCount > 0 ? rawDigits.slice(-placeholderCount) : rawDigits;
|
|
78764
|
+
let digitIndex = digits.length - 1;
|
|
78765
|
+
let output = "";
|
|
78766
|
+
let signSlot = null;
|
|
78767
|
+
const hasGrouping = activeTokens.some((token) => token.kind === "placeholder" && token.value === ",");
|
|
78768
|
+
for (let index2 = activeTokens.length - 1;index2 >= 0; index2 -= 1) {
|
|
78769
|
+
const token = activeTokens[index2];
|
|
78770
|
+
if (token.kind === "literal") {
|
|
78771
|
+
output = token.value + output;
|
|
78772
|
+
continue;
|
|
78773
|
+
}
|
|
78774
|
+
switch (token.value) {
|
|
78775
|
+
case "0":
|
|
78776
|
+
output = (digitIndex >= 0 ? digits[digitIndex] : "0") + output;
|
|
78777
|
+
digitIndex -= 1;
|
|
78778
|
+
break;
|
|
78779
|
+
case "#":
|
|
78780
|
+
if (digitIndex >= 0) {
|
|
78781
|
+
output = digits[digitIndex] + output;
|
|
78782
|
+
digitIndex -= 1;
|
|
78783
|
+
}
|
|
78784
|
+
break;
|
|
78785
|
+
case "+":
|
|
78786
|
+
case "-":
|
|
78787
|
+
signSlot = token.value;
|
|
78788
|
+
break;
|
|
78789
|
+
case ",":
|
|
78790
|
+
case "x":
|
|
78791
|
+
case ".":
|
|
78792
|
+
break;
|
|
78793
|
+
}
|
|
78794
|
+
}
|
|
78795
|
+
if (placeholderCount > 0 && xIndex < 0 && digitIndex >= 0)
|
|
78796
|
+
output = digits.slice(0, digitIndex + 1) + output;
|
|
78797
|
+
if (hasGrouping)
|
|
78798
|
+
output = applyGrouping(output);
|
|
78799
|
+
if (signSlot === "+")
|
|
78800
|
+
output = `${isNegative ? "-" : "+"}${output}`;
|
|
78801
|
+
else if (signSlot === "-")
|
|
78802
|
+
output = `${isNegative ? "-" : " "}${output}`;
|
|
78803
|
+
else if (isNegative && !suppressDefaultNegative)
|
|
78804
|
+
output = `-${output}`;
|
|
78805
|
+
return output;
|
|
78806
|
+
}
|
|
78807
|
+
function formatFractionalPictureTokens(tokens) {
|
|
78808
|
+
let output = "";
|
|
78809
|
+
for (const token of tokens) {
|
|
78810
|
+
if (token.kind === "literal") {
|
|
78811
|
+
output += token.value;
|
|
78812
|
+
continue;
|
|
78813
|
+
}
|
|
78814
|
+
if (token.value === "0")
|
|
78815
|
+
output += "0";
|
|
78816
|
+
else if (token.value !== "#")
|
|
78817
|
+
output += token.value;
|
|
78818
|
+
}
|
|
78819
|
+
return output;
|
|
78820
|
+
}
|
|
78821
|
+
function applyGrouping(value) {
|
|
78822
|
+
const match = value.match(/^([^0-9]*)([0-9]+)(.*)$/);
|
|
78823
|
+
if (!match)
|
|
78824
|
+
return value;
|
|
78825
|
+
return `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3]}`;
|
|
78826
|
+
}
|
|
78827
|
+
function buildPageRefAnchorMap(bookmarks, layout, blocks = [], measures = []) {
|
|
78828
|
+
const anchors = /* @__PURE__ */ new Map;
|
|
78829
|
+
if (bookmarks.size === 0)
|
|
78830
|
+
return anchors;
|
|
78831
|
+
const blockById = /* @__PURE__ */ new Map;
|
|
78832
|
+
const measureById = /* @__PURE__ */ new Map;
|
|
78833
|
+
for (const block of blocks)
|
|
78834
|
+
blockById.set(block.id, block);
|
|
78835
|
+
for (let index2 = 0;index2 < blocks.length; index2 += 1) {
|
|
78836
|
+
const block = blocks[index2];
|
|
78837
|
+
const measure = measures[index2];
|
|
78838
|
+
if (block && measure)
|
|
78839
|
+
measureById.set(block.id, measure);
|
|
78840
|
+
}
|
|
78841
|
+
for (const [bookmarkName, pmPosition] of bookmarks) {
|
|
78842
|
+
const location2 = findPageRefLocation(pmPosition, layout, blockById, measureById);
|
|
78843
|
+
if (location2)
|
|
78844
|
+
anchors.set(bookmarkName, {
|
|
78845
|
+
...location2,
|
|
78846
|
+
pmPosition
|
|
78847
|
+
});
|
|
78848
|
+
}
|
|
78849
|
+
return anchors;
|
|
78850
|
+
}
|
|
78851
|
+
function findPageRefLocation(pmPosition, layout, blockById, measureById) {
|
|
78852
|
+
let nextLocation = null;
|
|
78853
|
+
let nextDistance = Number.POSITIVE_INFINITY;
|
|
78854
|
+
let hasPriorVisibleRange = false;
|
|
78855
|
+
for (const page of layout.pages)
|
|
78856
|
+
for (const fragment2 of page.fragments) {
|
|
78857
|
+
if (fragmentContainsPosition(fragment2, pmPosition))
|
|
78858
|
+
return pageRefLocationFromPage(page, pmPosition);
|
|
78859
|
+
const block = blockById.get(fragment2.blockId);
|
|
78860
|
+
if (fragment2.kind === "para" && block?.kind === "paragraph" && blockContainsPosition(block, pmPosition))
|
|
78861
|
+
return pageRefLocationFromPage(page, pmPosition);
|
|
78862
|
+
if (fragment2.kind === "table" && block?.kind === "table" && tableContainsPosition(block, fragment2, pmPosition, measureById.get(fragment2.blockId)))
|
|
78863
|
+
return pageRefLocationFromPage(page, pmPosition);
|
|
78864
|
+
if (fragment2.kind === "list-item" && block?.kind === "list" && listItemContainsPosition(block, fragment2.itemId, pmPosition))
|
|
78865
|
+
return pageRefLocationFromPage(page, pmPosition);
|
|
78866
|
+
const fragmentRange = fragmentPositionRange(fragment2, block);
|
|
78867
|
+
if (fragmentRange?.end != null && fragmentRange.end <= pmPosition)
|
|
78868
|
+
hasPriorVisibleRange = true;
|
|
78869
|
+
const fragmentStart = fragmentRange?.start ?? null;
|
|
78870
|
+
if (fragmentStart != null && fragmentStart > pmPosition) {
|
|
78871
|
+
const distance2 = fragmentStart - pmPosition;
|
|
78872
|
+
if ((!hasPriorVisibleRange || distance2 <= MAX_BOOKMARK_MARKER_LEAD_DISTANCE) && distance2 < nextDistance) {
|
|
78873
|
+
nextDistance = distance2;
|
|
78874
|
+
nextLocation = pageRefLocationFromPage(page, pmPosition);
|
|
78875
|
+
}
|
|
78876
|
+
}
|
|
78877
|
+
}
|
|
78878
|
+
return nextLocation;
|
|
78879
|
+
}
|
|
78880
|
+
function pageRefLocationFromPage(page, pmPosition) {
|
|
78881
|
+
const displayNumber = Math.max(1, page.displayNumber ?? page.effectivePageNumber ?? page.number);
|
|
78882
|
+
return {
|
|
78883
|
+
physicalPage: page.number,
|
|
78884
|
+
displayNumber,
|
|
78885
|
+
displayText: page.numberText ?? String(displayNumber),
|
|
78886
|
+
pageFormat: page.pageNumberFormat,
|
|
78887
|
+
chapterNumberText: page.pageNumberChapterText,
|
|
78888
|
+
chapterSeparator: page.pageNumberChapterSeparator,
|
|
78889
|
+
sectionIndex: page.sectionIndex,
|
|
78890
|
+
pmPosition
|
|
78891
|
+
};
|
|
78892
|
+
}
|
|
78893
|
+
function fragmentContainsPosition(fragment2, pmPosition) {
|
|
78894
|
+
const range = fragment2;
|
|
78895
|
+
return range.pmStart != null && range.pmEnd != null && pmPosition >= range.pmStart && pmPosition < range.pmEnd;
|
|
78896
|
+
}
|
|
78897
|
+
function blockContainsPosition(block, pmPosition) {
|
|
78898
|
+
const range = runRange(block.runs);
|
|
78899
|
+
return range != null && pmPosition >= range.start && pmPosition < range.end;
|
|
78900
|
+
}
|
|
78901
|
+
function tableContainsPosition(block, fragment2, pmPosition, measure) {
|
|
78902
|
+
const fromRow = Math.max(0, fragment2.fromRow);
|
|
78903
|
+
const toRow = Math.min(block.rows.length, fragment2.toRow);
|
|
78904
|
+
const tableMeasure = measure?.kind === "table" ? measure : undefined;
|
|
78905
|
+
for (let rowIndex = fromRow;rowIndex < toRow; rowIndex += 1) {
|
|
78906
|
+
const row = block.rows[rowIndex];
|
|
78907
|
+
if (!row)
|
|
78908
|
+
continue;
|
|
78909
|
+
const isPartialRow = fragment2.partialRow?.rowIndex === rowIndex;
|
|
78910
|
+
for (let cellIndex = 0;cellIndex < row.cells.length; cellIndex += 1) {
|
|
78911
|
+
const cell = row.cells[cellIndex];
|
|
78912
|
+
if (!cell)
|
|
78913
|
+
continue;
|
|
78914
|
+
if (isPartialRow && tableMeasure) {
|
|
78915
|
+
const cellMeasure = tableMeasure.rows[rowIndex]?.cells[cellIndex];
|
|
78916
|
+
if (cellContainsPositionInLineRange(cell, cellMeasure, fragment2.partialRow, cellIndex, pmPosition))
|
|
78917
|
+
return true;
|
|
78918
|
+
continue;
|
|
78919
|
+
}
|
|
78920
|
+
const blocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
|
|
78921
|
+
for (const childBlock of blocks) {
|
|
78922
|
+
if (childBlock.kind === "paragraph" && blockContainsPosition(childBlock, pmPosition))
|
|
78923
|
+
return true;
|
|
78924
|
+
if (childBlock.kind === "table" && tableBlockContainsPosition(childBlock, pmPosition))
|
|
78925
|
+
return true;
|
|
78926
|
+
}
|
|
78927
|
+
}
|
|
78928
|
+
}
|
|
78929
|
+
return false;
|
|
78930
|
+
}
|
|
78931
|
+
function cellContainsPositionInLineRange(cell, cellMeasure, partialRow, cellIndex, pmPosition) {
|
|
78932
|
+
if (!cellMeasure)
|
|
78933
|
+
return false;
|
|
78934
|
+
const totalLines = getCellTotalLines(cellMeasure);
|
|
78935
|
+
const rawFromLine = partialRow.fromLineByCell[cellIndex];
|
|
78936
|
+
const rawToLine = partialRow.toLineByCell[cellIndex];
|
|
78937
|
+
const fromLine = typeof rawFromLine === "number" && rawFromLine >= 0 ? Math.min(rawFromLine, totalLines) : 0;
|
|
78938
|
+
const toLine = typeof rawToLine === "number" ? Math.max(0, Math.min(rawToLine === -1 ? totalLines : rawToLine, totalLines)) : totalLines;
|
|
78939
|
+
const range = computeCellLineRange(cell, cellMeasure, fromLine, Math.max(fromLine, toLine));
|
|
78940
|
+
return range != null && pmPosition >= range.start && pmPosition < range.end;
|
|
78941
|
+
}
|
|
78942
|
+
function computeCellLineRange(cell, cellMeasure, fromLine, toLine) {
|
|
78943
|
+
let start = Number.POSITIVE_INFINITY;
|
|
78944
|
+
let end = Number.NEGATIVE_INFINITY;
|
|
78945
|
+
const blocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
|
|
78946
|
+
const measures = cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : []);
|
|
78947
|
+
const blockCount = Math.min(blocks.length, measures.length);
|
|
78948
|
+
let lineOffset = 0;
|
|
78949
|
+
for (let blockIndex = 0;blockIndex < blockCount; blockIndex += 1) {
|
|
78950
|
+
const childBlock = blocks[blockIndex];
|
|
78951
|
+
const childMeasure = measures[blockIndex];
|
|
78952
|
+
const lineCount = getBlockLineCount(childMeasure);
|
|
78953
|
+
const blockFromLine = Math.max(fromLine, lineOffset) - lineOffset;
|
|
78954
|
+
const blockToLine = Math.min(toLine, lineOffset + lineCount) - lineOffset;
|
|
78955
|
+
if (childBlock?.kind === "paragraph" && childMeasure?.kind === "paragraph" && blockFromLine < blockToLine) {
|
|
78956
|
+
const range = computeFragmentPmRange(childBlock, childMeasure.lines, blockFromLine, blockToLine);
|
|
78957
|
+
if (range.pmStart != null)
|
|
78958
|
+
start = Math.min(start, range.pmStart);
|
|
78959
|
+
if (range.pmEnd != null)
|
|
78960
|
+
end = Math.max(end, range.pmEnd);
|
|
78961
|
+
}
|
|
78962
|
+
lineOffset += lineCount;
|
|
78963
|
+
}
|
|
78964
|
+
return Number.isFinite(start) && Number.isFinite(end) && start < end ? {
|
|
78965
|
+
start,
|
|
78966
|
+
end
|
|
78967
|
+
} : null;
|
|
78968
|
+
}
|
|
78969
|
+
function getCellTotalLines(cellMeasure) {
|
|
78970
|
+
return (cellMeasure.blocks ?? (cellMeasure.paragraph ? [cellMeasure.paragraph] : [])).reduce((total, measure) => total + getBlockLineCount(measure), 0);
|
|
78971
|
+
}
|
|
78972
|
+
function getBlockLineCount(measure) {
|
|
78973
|
+
if (!measure)
|
|
78974
|
+
return 0;
|
|
78975
|
+
if (measure.kind === "paragraph")
|
|
78976
|
+
return measure.lines.length;
|
|
78977
|
+
if (measure.kind === "table")
|
|
78978
|
+
return measure.rows.length;
|
|
78979
|
+
return 1;
|
|
78980
|
+
}
|
|
78981
|
+
function tableBlockContainsPosition(block, pmPosition) {
|
|
78982
|
+
for (const row of block.rows)
|
|
78983
|
+
for (const cell of row.cells) {
|
|
78984
|
+
const blocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
|
|
78985
|
+
for (const childBlock of blocks) {
|
|
78986
|
+
if (childBlock.kind === "paragraph" && blockContainsPosition(childBlock, pmPosition))
|
|
78987
|
+
return true;
|
|
78988
|
+
if (childBlock.kind === "table" && tableBlockContainsPosition(childBlock, pmPosition))
|
|
78989
|
+
return true;
|
|
78990
|
+
}
|
|
78991
|
+
}
|
|
78992
|
+
return false;
|
|
78993
|
+
}
|
|
78994
|
+
function fragmentPositionRange(fragment2, block) {
|
|
78995
|
+
const fullRange = fragment2;
|
|
78996
|
+
if (fullRange.pmStart != null && fullRange.pmEnd != null)
|
|
78997
|
+
return {
|
|
78998
|
+
start: fullRange.pmStart,
|
|
78999
|
+
end: fullRange.pmEnd
|
|
79000
|
+
};
|
|
79001
|
+
if (block?.kind === "paragraph")
|
|
79002
|
+
return runRange(block.runs);
|
|
79003
|
+
if (block?.kind === "table")
|
|
79004
|
+
return tableRunRange(block);
|
|
79005
|
+
if (fragment2.kind === "list-item" && block?.kind === "list")
|
|
79006
|
+
return listItemRunRange(block, fragment2.itemId);
|
|
79007
|
+
return null;
|
|
79008
|
+
}
|
|
79009
|
+
function listItemContainsPosition(block, itemId, pmPosition) {
|
|
79010
|
+
const range = listItemRunRange(block, itemId);
|
|
79011
|
+
return range != null && pmPosition >= range.start && pmPosition < range.end;
|
|
79012
|
+
}
|
|
79013
|
+
function listItemRunRange(block, itemId) {
|
|
79014
|
+
const item = block.items.find((candidate) => candidate.id === itemId);
|
|
79015
|
+
return item ? runRange(item.paragraph.runs) : null;
|
|
79016
|
+
}
|
|
79017
|
+
function tableRunRange(block) {
|
|
79018
|
+
let start = Number.POSITIVE_INFINITY;
|
|
79019
|
+
let end = Number.NEGATIVE_INFINITY;
|
|
79020
|
+
for (const row of block.rows)
|
|
79021
|
+
for (const cell of row.cells) {
|
|
79022
|
+
const blocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
|
|
79023
|
+
for (const childBlock of blocks) {
|
|
79024
|
+
const range = childBlock.kind === "paragraph" ? runRange(childBlock.runs) : childBlock.kind === "table" ? tableRunRange(childBlock) : null;
|
|
79025
|
+
if (!range)
|
|
79026
|
+
continue;
|
|
79027
|
+
start = Math.min(start, range.start);
|
|
79028
|
+
end = Math.max(end, range.end);
|
|
79029
|
+
}
|
|
79030
|
+
}
|
|
79031
|
+
return Number.isFinite(start) && Number.isFinite(end) && start < end ? {
|
|
79032
|
+
start,
|
|
79033
|
+
end
|
|
79034
|
+
} : null;
|
|
79035
|
+
}
|
|
79036
|
+
function runRange(runs) {
|
|
79037
|
+
let start = Number.POSITIVE_INFINITY;
|
|
79038
|
+
let end = Number.NEGATIVE_INFINITY;
|
|
79039
|
+
for (const run$1 of runs) {
|
|
79040
|
+
const range = run$1;
|
|
79041
|
+
if (range.pmStart != null)
|
|
79042
|
+
start = Math.min(start, range.pmStart);
|
|
79043
|
+
if (range.pmEnd != null)
|
|
79044
|
+
end = Math.max(end, range.pmEnd);
|
|
79045
|
+
}
|
|
79046
|
+
return Number.isFinite(start) && Number.isFinite(end) && start < end ? {
|
|
79047
|
+
start,
|
|
79048
|
+
end
|
|
79049
|
+
} : null;
|
|
79050
|
+
}
|
|
78577
79051
|
function resolveSpacingIndent(style, numbering) {
|
|
78578
79052
|
const spacing = {
|
|
78579
79053
|
before: style.spacing?.before ?? 0,
|
|
@@ -82963,11 +83437,12 @@ function convertTiffToPng(data) {
|
|
|
82963
83437
|
}
|
|
82964
83438
|
}
|
|
82965
83439
|
function parsePageNumberFieldSwitches(instruction, fieldType) {
|
|
82966
|
-
const
|
|
83440
|
+
const switchInstruction = typeof instruction === "string" ? instruction.trim() : fieldType;
|
|
83441
|
+
const normalizedInstruction = normalizeInstructionWhitespace(switchInstruction);
|
|
82967
83442
|
const result = {};
|
|
82968
83443
|
if (normalizedInstruction && normalizedInstruction !== fieldType)
|
|
82969
83444
|
result.instruction = normalizedInstruction;
|
|
82970
|
-
for (const match of
|
|
83445
|
+
for (const match of switchInstruction.matchAll(/\\\*\s+("[^"]+"|\S+)/g)) {
|
|
82971
83446
|
const rawValue = unquote(match[1]);
|
|
82972
83447
|
const mapped = GENERAL_FORMATS.get(rawValue) ?? CASE_INSENSITIVE_GENERAL_FORMATS.get(rawValue.toLowerCase());
|
|
82973
83448
|
if (mapped) {
|
|
@@ -82975,25 +83450,55 @@ function parsePageNumberFieldSwitches(instruction, fieldType) {
|
|
|
82975
83450
|
break;
|
|
82976
83451
|
}
|
|
82977
83452
|
}
|
|
82978
|
-
for (const match of
|
|
83453
|
+
for (const match of switchInstruction.matchAll(/\\#\s+("[^"]+"|\S+)/g)) {
|
|
82979
83454
|
const picture = unquote(match[1]);
|
|
83455
|
+
if (!picture)
|
|
83456
|
+
continue;
|
|
82980
83457
|
if (/^0+$/.test(picture)) {
|
|
82981
83458
|
result.pageNumberFormat ??= "decimal";
|
|
82982
83459
|
result.pageNumberZeroPadding = picture.length;
|
|
82983
|
-
|
|
82984
|
-
|
|
83460
|
+
} else
|
|
83461
|
+
result.pageNumberNumericPicture = picture;
|
|
83462
|
+
break;
|
|
82985
83463
|
}
|
|
82986
83464
|
return result;
|
|
82987
83465
|
}
|
|
82988
|
-
function formatPageNumberFieldValue(pageNumber, attrs = {}) {
|
|
82989
|
-
return formatPageNumberFieldValue
|
|
83466
|
+
function formatPageNumberFieldValue$1(pageNumber, attrs = {}) {
|
|
83467
|
+
return formatPageNumberFieldValue(pageNumber, {
|
|
82990
83468
|
format: attrs.pageNumberFormat || "decimal",
|
|
82991
|
-
zeroPadding: attrs.pageNumberZeroPadding ?? undefined
|
|
83469
|
+
zeroPadding: attrs.pageNumberZeroPadding ?? undefined,
|
|
83470
|
+
numericPicture: attrs.pageNumberNumericPicture ?? undefined
|
|
82992
83471
|
});
|
|
82993
83472
|
}
|
|
82994
83473
|
function unquote(value) {
|
|
82995
83474
|
return value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value;
|
|
82996
83475
|
}
|
|
83476
|
+
function normalizeInstructionWhitespace(instruction) {
|
|
83477
|
+
let normalized = "";
|
|
83478
|
+
let inQuote = false;
|
|
83479
|
+
let pendingSpace = false;
|
|
83480
|
+
for (const char of instruction) {
|
|
83481
|
+
if (char === '"') {
|
|
83482
|
+
if (pendingSpace && normalized.length > 0) {
|
|
83483
|
+
normalized += " ";
|
|
83484
|
+
pendingSpace = false;
|
|
83485
|
+
}
|
|
83486
|
+
normalized += char;
|
|
83487
|
+
inQuote = !inQuote;
|
|
83488
|
+
continue;
|
|
83489
|
+
}
|
|
83490
|
+
if (!inQuote && /\s/.test(char)) {
|
|
83491
|
+
pendingSpace = true;
|
|
83492
|
+
continue;
|
|
83493
|
+
}
|
|
83494
|
+
if (pendingSpace && normalized.length > 0) {
|
|
83495
|
+
normalized += " ";
|
|
83496
|
+
pendingSpace = false;
|
|
83497
|
+
}
|
|
83498
|
+
normalized += char;
|
|
83499
|
+
}
|
|
83500
|
+
return normalized;
|
|
83501
|
+
}
|
|
82997
83502
|
function preProcessPageInstruction(nodesToCombine, instrText = "PAGE", options = {}) {
|
|
82998
83503
|
const fieldRunRPr = options.fieldRunRPr ?? null;
|
|
82999
83504
|
const normalizedInstruction = typeof instrText === "string" && instrText.trim() ? instrText.trim().replace(/\s+/g, " ") : "PAGE";
|
|
@@ -83091,11 +83596,123 @@ function extractCachedText$1(nodes) {
|
|
|
83091
83596
|
}
|
|
83092
83597
|
return texts.join("");
|
|
83093
83598
|
}
|
|
83599
|
+
function parsePageRefInstruction(instruction) {
|
|
83600
|
+
const rawInstruction = typeof instruction === "string" ? instruction.trim() : "";
|
|
83601
|
+
const tokens = tokenizeInstruction$1(rawInstruction);
|
|
83602
|
+
const result = {
|
|
83603
|
+
instruction: rawInstruction,
|
|
83604
|
+
bookmarkId: "",
|
|
83605
|
+
hasHyperlinkSwitch: false,
|
|
83606
|
+
hasRelativePositionSwitch: false,
|
|
83607
|
+
rawSwitches: []
|
|
83608
|
+
};
|
|
83609
|
+
if (!tokens.length || !/^PAGEREF$/i.test(tokens[0].value))
|
|
83610
|
+
return result;
|
|
83611
|
+
for (let index2 = 1;index2 < tokens.length; index2 += 1) {
|
|
83612
|
+
const token = tokens[index2].value;
|
|
83613
|
+
if (!token)
|
|
83614
|
+
continue;
|
|
83615
|
+
if (token.startsWith("\\")) {
|
|
83616
|
+
const normalized = token.toLowerCase();
|
|
83617
|
+
if (normalized === "\\h") {
|
|
83618
|
+
result.hasHyperlinkSwitch = true;
|
|
83619
|
+
result.rawSwitches.push({ switch: token });
|
|
83620
|
+
continue;
|
|
83621
|
+
}
|
|
83622
|
+
if (normalized === "\\p") {
|
|
83623
|
+
result.hasRelativePositionSwitch = true;
|
|
83624
|
+
result.rawSwitches.push({ switch: token });
|
|
83625
|
+
continue;
|
|
83626
|
+
}
|
|
83627
|
+
if (token === "\\*") {
|
|
83628
|
+
const value = tokens[index2 + 1]?.value;
|
|
83629
|
+
if (value != null) {
|
|
83630
|
+
result.rawSwitches.push({
|
|
83631
|
+
switch: token,
|
|
83632
|
+
value
|
|
83633
|
+
});
|
|
83634
|
+
applyGeneralFormat$1(result, value);
|
|
83635
|
+
index2 += 1;
|
|
83636
|
+
} else
|
|
83637
|
+
result.rawSwitches.push({ switch: token });
|
|
83638
|
+
continue;
|
|
83639
|
+
}
|
|
83640
|
+
if (token === "\\#") {
|
|
83641
|
+
const value = tokens[index2 + 1]?.value;
|
|
83642
|
+
if (value != null) {
|
|
83643
|
+
result.rawSwitches.push({
|
|
83644
|
+
switch: token,
|
|
83645
|
+
value
|
|
83646
|
+
});
|
|
83647
|
+
result.numericPictureFormat = { picture: value };
|
|
83648
|
+
if (/^0+$/.test(value))
|
|
83649
|
+
result.pageNumberFieldFormat = {
|
|
83650
|
+
...result.pageNumberFieldFormat ?? {},
|
|
83651
|
+
zeroPadding: value.length
|
|
83652
|
+
};
|
|
83653
|
+
index2 += 1;
|
|
83654
|
+
} else
|
|
83655
|
+
result.rawSwitches.push({ switch: token });
|
|
83656
|
+
continue;
|
|
83657
|
+
}
|
|
83658
|
+
result.rawSwitches.push({ switch: token });
|
|
83659
|
+
continue;
|
|
83660
|
+
}
|
|
83661
|
+
if (!result.bookmarkId)
|
|
83662
|
+
result.bookmarkId = token;
|
|
83663
|
+
}
|
|
83664
|
+
return result;
|
|
83665
|
+
}
|
|
83666
|
+
function tokenizeInstruction$1(instruction) {
|
|
83667
|
+
const tokens = [];
|
|
83668
|
+
for (const match of instruction.matchAll(TOKEN_PATTERN$1))
|
|
83669
|
+
tokens.push({ value: unescapeQuotedToken$1(match[1] ?? match[2] ?? match[0]) });
|
|
83670
|
+
return tokens;
|
|
83671
|
+
}
|
|
83672
|
+
function unescapeQuotedToken$1(value) {
|
|
83673
|
+
return value.replace(/\\(["'\\])/g, "$1");
|
|
83674
|
+
}
|
|
83675
|
+
function applyGeneralFormat$1(result, value) {
|
|
83676
|
+
const normalized = value.toLowerCase();
|
|
83677
|
+
if (normalized === "charformat") {
|
|
83678
|
+
result.fieldResultFormat = "charformat";
|
|
83679
|
+
return;
|
|
83680
|
+
}
|
|
83681
|
+
if (normalized === "mergeformat") {
|
|
83682
|
+
result.fieldResultFormat = "mergeformat";
|
|
83683
|
+
return;
|
|
83684
|
+
}
|
|
83685
|
+
const mapped = GENERAL_FORMATS.get(value) ?? CASE_INSENSITIVE_GENERAL_FORMATS.get(normalized);
|
|
83686
|
+
if (mapped)
|
|
83687
|
+
result.pageNumberFieldFormat = {
|
|
83688
|
+
...result.pageNumberFieldFormat ?? {},
|
|
83689
|
+
format: mapped
|
|
83690
|
+
};
|
|
83691
|
+
else
|
|
83692
|
+
result.unsupportedGeneralFormat = value;
|
|
83693
|
+
}
|
|
83094
83694
|
function preProcessPageRefInstruction(nodesToCombine, instrText, options = {}) {
|
|
83695
|
+
const parsed = parsePageRefInstruction(instrText);
|
|
83696
|
+
const instructionTokens = options.instructionTokens ?? null;
|
|
83697
|
+
const firstInstrTextRunRPr = options.firstInstrTextRunRPr ?? null;
|
|
83698
|
+
const fieldRunProperties = parsed.fieldResultFormat === "charformat" && firstInstrTextRunRPr ? translator$133.encode({
|
|
83699
|
+
...options.docx ? { docx: options.docx } : {},
|
|
83700
|
+
nodes: [firstInstrTextRunRPr]
|
|
83701
|
+
}) : null;
|
|
83095
83702
|
return [{
|
|
83096
83703
|
name: "sd:pageReference",
|
|
83097
83704
|
type: "element",
|
|
83098
|
-
attributes: {
|
|
83705
|
+
attributes: {
|
|
83706
|
+
instruction: parsed.instruction,
|
|
83707
|
+
...instructionTokens?.length ? { instructionTokens } : {},
|
|
83708
|
+
...parsed.bookmarkId ? { bookmarkId: parsed.bookmarkId } : {},
|
|
83709
|
+
...parsed.hasHyperlinkSwitch ? { hasHyperlinkSwitch: true } : {},
|
|
83710
|
+
...parsed.hasRelativePositionSwitch ? { hasRelativePositionSwitch: true } : {},
|
|
83711
|
+
...parsed.pageNumberFieldFormat ? { pageNumberFieldFormat: parsed.pageNumberFieldFormat } : {},
|
|
83712
|
+
...parsed.numericPictureFormat ? { numericPictureFormat: parsed.numericPictureFormat } : {},
|
|
83713
|
+
...parsed.fieldResultFormat ? { fieldResultFormat: parsed.fieldResultFormat } : {},
|
|
83714
|
+
...fieldRunProperties ? { fieldRunProperties } : {}
|
|
83715
|
+
},
|
|
83099
83716
|
elements: nodesToCombine
|
|
83100
83717
|
}];
|
|
83101
83718
|
}
|
|
@@ -83340,8 +83957,10 @@ function scanFieldSequence(nodes, beginIndex) {
|
|
|
83340
83957
|
const node3 = nodes[i$1];
|
|
83341
83958
|
const fldType = node3.elements?.find((el) => el.name === "w:fldChar")?.attributes?.["w:fldCharType"];
|
|
83342
83959
|
const instrTextEl = node3.elements?.find((el) => el.name === "w:instrText");
|
|
83343
|
-
if (instrTextEl)
|
|
83344
|
-
|
|
83960
|
+
if (instrTextEl) {
|
|
83961
|
+
const fragment2 = instrTextEl.elements?.[0]?.text || "";
|
|
83962
|
+
instrText += shouldInsertSwitchBoundarySpace(instrText, fragment2) ? ` ${fragment2}` : fragment2;
|
|
83963
|
+
}
|
|
83345
83964
|
if (!fieldRunRPr || separateIndex === -1 && fldType !== "end") {
|
|
83346
83965
|
const rPrNode = node3.elements?.find((el) => el.name === "w:rPr");
|
|
83347
83966
|
if (rPrNode && hasSignificantStyling(rPrNode))
|
|
@@ -83365,6 +83984,9 @@ function scanFieldSequence(nodes, beginIndex) {
|
|
|
83365
83984
|
endIndex
|
|
83366
83985
|
};
|
|
83367
83986
|
}
|
|
83987
|
+
function shouldInsertSwitchBoundarySpace(existingInstruction, nextFragment) {
|
|
83988
|
+
return /\w$/.test(existingInstruction) && /^\\/.test(nextFragment) || /(^|\s)\\[#*]$/.test(existingInstruction) && /^\S/.test(nextFragment);
|
|
83989
|
+
}
|
|
83368
83990
|
function getHeaderFooterFieldPreprocessor(fieldType) {
|
|
83369
83991
|
switch (fieldType) {
|
|
83370
83992
|
case "PAGE":
|
|
@@ -98835,22 +99457,201 @@ function parseTaInstruction(instruction) {
|
|
|
98835
99457
|
};
|
|
98836
99458
|
}
|
|
98837
99459
|
function parseSeqInstruction(instruction) {
|
|
98838
|
-
const
|
|
98839
|
-
const
|
|
98840
|
-
|
|
98841
|
-
|
|
98842
|
-
|
|
98843
|
-
|
|
98844
|
-
|
|
98845
|
-
|
|
98846
|
-
|
|
98847
|
-
|
|
98848
|
-
|
|
99460
|
+
const rawInstruction = typeof instruction === "string" ? instruction : "";
|
|
99461
|
+
const tokens = tokenizeInstruction(rawInstruction);
|
|
99462
|
+
const result = createEmptyParse(rawInstruction, tokens[0]?.value ?? "");
|
|
99463
|
+
if (extractFieldKeyword(rawInstruction) !== "SEQ")
|
|
99464
|
+
return result;
|
|
99465
|
+
let sawSwitch = false;
|
|
99466
|
+
for (let index2 = 1;index2 < tokens.length; index2 += 1) {
|
|
99467
|
+
const token = tokens[index2].value;
|
|
99468
|
+
if (!token)
|
|
99469
|
+
continue;
|
|
99470
|
+
if (token.startsWith("\\")) {
|
|
99471
|
+
sawSwitch = true;
|
|
99472
|
+
const attachedValueSwitch = parseAttachedNumericSwitch(token);
|
|
99473
|
+
const normalized = (attachedValueSwitch?.switchToken ?? token).toLowerCase();
|
|
99474
|
+
if (normalized === "\\n") {
|
|
99475
|
+
result.sequenceMode = "next";
|
|
99476
|
+
continue;
|
|
99477
|
+
}
|
|
99478
|
+
if (normalized === "\\c") {
|
|
99479
|
+
result.sequenceMode = "current";
|
|
99480
|
+
continue;
|
|
99481
|
+
}
|
|
99482
|
+
if (normalized === "\\h") {
|
|
99483
|
+
result.hideResult = true;
|
|
99484
|
+
continue;
|
|
99485
|
+
}
|
|
99486
|
+
if (normalized === "\\r") {
|
|
99487
|
+
const value$1 = attachedValueSwitch?.value ?? tokens[index2 + 1]?.value;
|
|
99488
|
+
if (value$1 != null && (attachedValueSwitch || !value$1.startsWith("\\"))) {
|
|
99489
|
+
const parsed = parseInteger(value$1);
|
|
99490
|
+
if (parsed != null)
|
|
99491
|
+
result.restartNumber = parsed;
|
|
99492
|
+
if (!attachedValueSwitch)
|
|
99493
|
+
index2 += 1;
|
|
99494
|
+
}
|
|
99495
|
+
continue;
|
|
99496
|
+
}
|
|
99497
|
+
if (normalized === "\\s") {
|
|
99498
|
+
const value$1 = attachedValueSwitch?.value ?? tokens[index2 + 1]?.value;
|
|
99499
|
+
if (value$1 != null && (attachedValueSwitch || !value$1.startsWith("\\"))) {
|
|
99500
|
+
const parsed = parseInteger(value$1);
|
|
99501
|
+
if (parsed != null && parsed >= 1 && parsed <= 9)
|
|
99502
|
+
result.restartLevel = parsed;
|
|
99503
|
+
if (!attachedValueSwitch)
|
|
99504
|
+
index2 += 1;
|
|
99505
|
+
}
|
|
99506
|
+
continue;
|
|
99507
|
+
}
|
|
99508
|
+
const attachedGeneralFormat = parseAttachedGeneralFormatSwitch(token);
|
|
99509
|
+
if (normalized === "\\*" || attachedGeneralFormat != null) {
|
|
99510
|
+
const value$1 = attachedGeneralFormat ?? tokens[index2 + 1]?.value;
|
|
99511
|
+
if (value$1 != null && (attachedGeneralFormat != null || !value$1.startsWith("\\"))) {
|
|
99512
|
+
result.format = value$1;
|
|
99513
|
+
result.hasGeneralFormat = true;
|
|
99514
|
+
applyGeneralFormat(result, value$1);
|
|
99515
|
+
if (attachedGeneralFormat == null)
|
|
99516
|
+
index2 += 1;
|
|
99517
|
+
} else
|
|
99518
|
+
result.unknownSwitches.push(token);
|
|
99519
|
+
continue;
|
|
99520
|
+
}
|
|
99521
|
+
const attachedNumericPicture = parseAttachedNumericPictureSwitch(token);
|
|
99522
|
+
if (normalized === "\\#" || attachedNumericPicture != null) {
|
|
99523
|
+
const value$1 = attachedNumericPicture ?? tokens[index2 + 1]?.value;
|
|
99524
|
+
if (value$1 != null && (attachedNumericPicture != null || !value$1.startsWith("\\"))) {
|
|
99525
|
+
if (result.numericPictureFormat == null)
|
|
99526
|
+
result.numericPictureFormat = { picture: value$1 };
|
|
99527
|
+
else
|
|
99528
|
+
result.unknownSwitches.push(token, value$1);
|
|
99529
|
+
if (attachedNumericPicture == null)
|
|
99530
|
+
index2 += 1;
|
|
99531
|
+
} else
|
|
99532
|
+
result.unknownSwitches.push(token);
|
|
99533
|
+
continue;
|
|
99534
|
+
}
|
|
99535
|
+
result.unknownSwitches.push(token);
|
|
99536
|
+
const value = tokens[index2 + 1]?.value;
|
|
99537
|
+
if (value != null && !value.startsWith("\\")) {
|
|
99538
|
+
result.unknownSwitches.push(value);
|
|
99539
|
+
index2 += 1;
|
|
99540
|
+
}
|
|
99541
|
+
continue;
|
|
98849
99542
|
}
|
|
99543
|
+
if (!result.identifier) {
|
|
99544
|
+
result.identifier = normalizeSeqIdentifier(token);
|
|
99545
|
+
continue;
|
|
99546
|
+
}
|
|
99547
|
+
if (!sawSwitch && !result.fieldArgument)
|
|
99548
|
+
result.fieldArgument = token;
|
|
99549
|
+
}
|
|
99550
|
+
return result;
|
|
99551
|
+
}
|
|
99552
|
+
function isSeqInstruction(instruction) {
|
|
99553
|
+
return extractFieldKeyword(instruction) === "SEQ";
|
|
99554
|
+
}
|
|
99555
|
+
function normalizeSeqIdentifier(identifier) {
|
|
99556
|
+
return typeof identifier === "string" ? identifier.trim() : "";
|
|
99557
|
+
}
|
|
99558
|
+
function sequenceFieldAttrsFromParsed(parsed) {
|
|
98850
99559
|
return {
|
|
98851
|
-
identifier,
|
|
98852
|
-
|
|
98853
|
-
|
|
99560
|
+
identifier: parsed.identifier,
|
|
99561
|
+
fieldArgument: parsed.fieldArgument,
|
|
99562
|
+
sequenceMode: parsed.sequenceMode,
|
|
99563
|
+
hideResult: parsed.hideResult,
|
|
99564
|
+
restartNumber: parsed.restartNumber,
|
|
99565
|
+
restartLevel: parsed.restartLevel,
|
|
99566
|
+
format: parsed.hasGeneralFormat ? parsed.format : "ARABIC",
|
|
99567
|
+
hasGeneralFormat: parsed.hasGeneralFormat,
|
|
99568
|
+
pageNumberFieldFormat: parsed.pageNumberFieldFormat ?? null,
|
|
99569
|
+
numericPictureFormat: parsed.numericPictureFormat
|
|
99570
|
+
};
|
|
99571
|
+
}
|
|
99572
|
+
function tokenizeInstruction(instruction) {
|
|
99573
|
+
const tokens = [];
|
|
99574
|
+
for (const match of instruction.matchAll(TOKEN_PATTERN))
|
|
99575
|
+
tokens.push({ value: match[1] !== undefined ? unescapeQuotedToken(match[1]) : match[0] });
|
|
99576
|
+
return tokens;
|
|
99577
|
+
}
|
|
99578
|
+
function createEmptyParse(instruction, keyword) {
|
|
99579
|
+
return {
|
|
99580
|
+
instruction,
|
|
99581
|
+
keyword,
|
|
99582
|
+
identifier: "",
|
|
99583
|
+
fieldArgument: "",
|
|
99584
|
+
sequenceMode: "next",
|
|
99585
|
+
hideResult: false,
|
|
99586
|
+
restartNumber: null,
|
|
99587
|
+
restartLevel: null,
|
|
99588
|
+
format: "Arabic",
|
|
99589
|
+
numericPictureFormat: null,
|
|
99590
|
+
hasGeneralFormat: false,
|
|
99591
|
+
unknownSwitches: []
|
|
99592
|
+
};
|
|
99593
|
+
}
|
|
99594
|
+
function parseInteger(value) {
|
|
99595
|
+
const number = Number(value);
|
|
99596
|
+
if (!Number.isFinite(number) || !Number.isInteger(number))
|
|
99597
|
+
return null;
|
|
99598
|
+
return Math.trunc(number);
|
|
99599
|
+
}
|
|
99600
|
+
function parseAttachedNumericSwitch(token) {
|
|
99601
|
+
const match = /^\\([rRsS])([+-]?\d+(?:\.\d+)?)$/.exec(token);
|
|
99602
|
+
if (!match)
|
|
99603
|
+
return null;
|
|
99604
|
+
return {
|
|
99605
|
+
switchToken: `\\${match[1]}`,
|
|
99606
|
+
value: match[2]
|
|
99607
|
+
};
|
|
99608
|
+
}
|
|
99609
|
+
function parseAttachedGeneralFormatSwitch(token) {
|
|
99610
|
+
return normalizeAttachedSwitchValue(/^\\\*(\S+)$/.exec(token)?.[1]);
|
|
99611
|
+
}
|
|
99612
|
+
function parseAttachedNumericPictureSwitch(token) {
|
|
99613
|
+
return normalizeAttachedSwitchValue(/^\\#(\S+)$/.exec(token)?.[1]);
|
|
99614
|
+
}
|
|
99615
|
+
function normalizeAttachedSwitchValue(value) {
|
|
99616
|
+
if (value == null)
|
|
99617
|
+
return null;
|
|
99618
|
+
if (value.startsWith('"') && value.endsWith('"'))
|
|
99619
|
+
return unescapeQuotedToken(value.slice(1, -1));
|
|
99620
|
+
return value;
|
|
99621
|
+
}
|
|
99622
|
+
function applyGeneralFormat(result, value) {
|
|
99623
|
+
const mapped = GENERAL_FORMATS.get(value) ?? CASE_INSENSITIVE_GENERAL_FORMATS.get(value.toLowerCase());
|
|
99624
|
+
if (mapped)
|
|
99625
|
+
result.pageNumberFieldFormat = { format: mapped };
|
|
99626
|
+
}
|
|
99627
|
+
function unescapeQuotedToken(value) {
|
|
99628
|
+
return value.replace(/\\(["\\])/g, "$1");
|
|
99629
|
+
}
|
|
99630
|
+
function buildResultContentNodes(params3, outputMarks) {
|
|
99631
|
+
const { node: node3 } = params3;
|
|
99632
|
+
const resolvedNumber = node3.attrs?.resolvedNumber;
|
|
99633
|
+
if (node3.attrs?.resolvedNumberIsCurrent === true)
|
|
99634
|
+
return typeof resolvedNumber === "string" && resolvedNumber.length > 0 ? [buildResolvedNumberRun(resolvedNumber, outputMarks)] : [];
|
|
99635
|
+
if (Array.isArray(node3.content) && node3.content.length > 0)
|
|
99636
|
+
return node3.content.flatMap((n) => exportSchemaToJson({
|
|
99637
|
+
...params3,
|
|
99638
|
+
node: n
|
|
99639
|
+
}));
|
|
99640
|
+
return typeof resolvedNumber === "string" && resolvedNumber.length > 0 ? [buildResolvedNumberRun(resolvedNumber, outputMarks)] : [];
|
|
99641
|
+
}
|
|
99642
|
+
function buildResolvedNumberRun(text$2, outputMarks) {
|
|
99643
|
+
return {
|
|
99644
|
+
name: "w:r",
|
|
99645
|
+
elements: [{
|
|
99646
|
+
name: "w:rPr",
|
|
99647
|
+
elements: outputMarks
|
|
99648
|
+
}, {
|
|
99649
|
+
name: "w:t",
|
|
99650
|
+
elements: [{
|
|
99651
|
+
type: "text",
|
|
99652
|
+
text: text$2
|
|
99653
|
+
}]
|
|
99654
|
+
}]
|
|
98854
99655
|
};
|
|
98855
99656
|
}
|
|
98856
99657
|
function extractResolvedText(content$2) {
|
|
@@ -98976,14 +99777,16 @@ function getPageNumberFieldAttrs(node3) {
|
|
|
98976
99777
|
attrs.pageNumberFormat = node3.attributes.pageNumberFormat;
|
|
98977
99778
|
if (node3.attributes?.pageNumberZeroPadding != null)
|
|
98978
99779
|
attrs.pageNumberZeroPadding = Number(node3.attributes.pageNumberZeroPadding);
|
|
99780
|
+
if (node3.attributes?.pageNumberNumericPicture)
|
|
99781
|
+
attrs.pageNumberNumericPicture = node3.attributes.pageNumberNumericPicture;
|
|
98979
99782
|
return attrs;
|
|
98980
99783
|
}
|
|
98981
99784
|
function resolveCachedPageCount(params3, node3) {
|
|
98982
99785
|
const cacheMap = params3.statFieldCacheMap;
|
|
98983
99786
|
if (cacheMap?.has?.("NUMPAGES")) {
|
|
98984
99787
|
const pageCount = Number(cacheMap.get("NUMPAGES"));
|
|
98985
|
-
if (node3.attrs?.pageNumberFormat || node3.attrs?.pageNumberZeroPadding)
|
|
98986
|
-
return formatPageNumberFieldValue(pageCount, node3.attrs);
|
|
99788
|
+
if (node3.attrs?.pageNumberFormat || node3.attrs?.pageNumberZeroPadding || node3.attrs?.pageNumberNumericPicture)
|
|
99789
|
+
return formatPageNumberFieldValue$1(pageCount, node3.attrs);
|
|
98987
99790
|
return String(cacheMap.get("NUMPAGES"));
|
|
98988
99791
|
}
|
|
98989
99792
|
if (node3.attrs?.resolvedText)
|
|
@@ -101902,16 +102705,26 @@ function extractColumns(elements) {
|
|
|
101902
102705
|
const equalWidth = equalWidthRaw === "0" || equalWidthRaw === 0 || equalWidthRaw === false ? false : equalWidthRaw === "1" || equalWidthRaw === 1 || equalWidthRaw === true ? true : undefined;
|
|
101903
102706
|
const columnChildren = Array.isArray(cols.elements) ? cols.elements.filter((child) => child?.name === "w:col") : [];
|
|
101904
102707
|
const isExplicit = equalWidth === false;
|
|
101905
|
-
const
|
|
101906
|
-
const
|
|
101907
|
-
|
|
101908
|
-
|
|
101909
|
-
|
|
102708
|
+
const toPx = (twips) => twips / TWIPS_PER_INCH$2 * PX_PER_INCH$1;
|
|
102709
|
+
const columnRecords = columnChildren.map((child) => {
|
|
102710
|
+
const widthTwips = Number(child.attributes?.["w:w"]);
|
|
102711
|
+
const spaceTwips = Number(child.attributes?.["w:space"]);
|
|
102712
|
+
return {
|
|
102713
|
+
widthTwips,
|
|
102714
|
+
spaceTwips: Number.isFinite(spaceTwips) && spaceTwips > 0 ? spaceTwips : 0
|
|
102715
|
+
};
|
|
102716
|
+
}).filter((record) => Number.isFinite(record.widthTwips) && record.widthTwips > 0);
|
|
102717
|
+
if (isExplicit && columnRecords.length > 0)
|
|
102718
|
+
count2 = Math.min(count2, columnRecords.length);
|
|
102719
|
+
const widths = columnRecords.slice(0, count2).map((record) => toPx(record.widthTwips));
|
|
102720
|
+
const gaps = columnRecords.slice(0, Math.max(0, count2 - 1)).map((record) => toPx(record.spaceTwips));
|
|
102721
|
+
const gapPx = isExplicit ? toPx(columnRecords[0]?.spaceTwips ?? 0) : parseColumnGap(cols.attributes["w:space"]) * PX_PER_INCH$1;
|
|
101910
102722
|
return {
|
|
101911
102723
|
count: count2,
|
|
101912
|
-
gap:
|
|
102724
|
+
gap: gapPx,
|
|
101913
102725
|
withSeparator,
|
|
101914
102726
|
...isExplicit && widths.length > 0 ? { widths } : {},
|
|
102727
|
+
...isExplicit && gaps.length > 0 ? { gaps } : {},
|
|
101915
102728
|
...equalWidth !== undefined ? { equalWidth } : {}
|
|
101916
102729
|
};
|
|
101917
102730
|
}
|
|
@@ -102790,6 +103603,64 @@ function normalizeTextInsets(value) {
|
|
|
102790
103603
|
left
|
|
102791
103604
|
};
|
|
102792
103605
|
}
|
|
103606
|
+
function isValidHeadingLevel(value) {
|
|
103607
|
+
return Number.isInteger(value) && value >= 1 && value <= 9;
|
|
103608
|
+
}
|
|
103609
|
+
function normalizeRestartLevel(value) {
|
|
103610
|
+
return isValidHeadingLevel(value) ? value : null;
|
|
103611
|
+
}
|
|
103612
|
+
function normalizeRestartNumber(value) {
|
|
103613
|
+
return Number.isFinite(value) && Number.isInteger(value) ? Math.trunc(value) : null;
|
|
103614
|
+
}
|
|
103615
|
+
function hasFieldArgument(field) {
|
|
103616
|
+
return typeof field?.fieldArgument === "string" && field.fieldArgument.trim().length > 0;
|
|
103617
|
+
}
|
|
103618
|
+
function formatSeqValue(value, field) {
|
|
103619
|
+
const picture = field?.numericPictureFormat?.picture;
|
|
103620
|
+
if (picture)
|
|
103621
|
+
return formatIntegerWithNumericPicture(value, picture);
|
|
103622
|
+
if (field?.pageNumberFieldFormat)
|
|
103623
|
+
return formatPageNumberFieldValue(value, field.pageNumberFieldFormat);
|
|
103624
|
+
return String(value);
|
|
103625
|
+
}
|
|
103626
|
+
function resolveSequenceFieldTokens(blocks) {
|
|
103627
|
+
const evaluator = new SequenceFieldEvaluator;
|
|
103628
|
+
for (const block of blocks)
|
|
103629
|
+
resolveBlock$1(block, evaluator);
|
|
103630
|
+
}
|
|
103631
|
+
function resolveBlock$1(block, evaluator) {
|
|
103632
|
+
if (block.kind === "paragraph") {
|
|
103633
|
+
resolveParagraph(block, evaluator);
|
|
103634
|
+
return;
|
|
103635
|
+
}
|
|
103636
|
+
if (block.kind === "table") {
|
|
103637
|
+
resolveTable2(block, evaluator);
|
|
103638
|
+
return;
|
|
103639
|
+
}
|
|
103640
|
+
if (block.kind === "list")
|
|
103641
|
+
resolveList(block, evaluator);
|
|
103642
|
+
}
|
|
103643
|
+
function resolveParagraph(block, evaluator) {
|
|
103644
|
+
evaluator.enterParagraph({ paragraphHeadingLevel: block.attrs?.headingLevel });
|
|
103645
|
+
for (const run$1 of block.runs)
|
|
103646
|
+
resolveRun(run$1, evaluator);
|
|
103647
|
+
}
|
|
103648
|
+
function resolveTable2(block, evaluator) {
|
|
103649
|
+
for (const row of block.rows)
|
|
103650
|
+
for (const cell of row.cells) {
|
|
103651
|
+
const childBlocks = cell.blocks ?? (cell.paragraph ? [cell.paragraph] : []);
|
|
103652
|
+
for (const childBlock of childBlocks)
|
|
103653
|
+
resolveBlock$1(childBlock, evaluator);
|
|
103654
|
+
}
|
|
103655
|
+
}
|
|
103656
|
+
function resolveList(block, evaluator) {
|
|
103657
|
+
for (const item of block.items)
|
|
103658
|
+
resolveParagraph(item.paragraph, evaluator);
|
|
103659
|
+
}
|
|
103660
|
+
function resolveRun(run$1, evaluator) {
|
|
103661
|
+
if ("token" in run$1 && run$1.token === "seq" && run$1.seqMetadata)
|
|
103662
|
+
run$1.text = evaluator.evaluateField(run$1.seqMetadata).text;
|
|
103663
|
+
}
|
|
102793
103664
|
function shiftBlockPositions(block, delta) {
|
|
102794
103665
|
if (block.kind === "paragraph") {
|
|
102795
103666
|
const paragraphBlock = block;
|
|
@@ -103064,11 +103935,13 @@ function getPageNumberFieldFormat(attrs) {
|
|
|
103064
103935
|
return;
|
|
103065
103936
|
const format = typeof attrs.pageNumberFormat === "string" ? attrs.pageNumberFormat : undefined;
|
|
103066
103937
|
const zeroPadding = typeof attrs.pageNumberZeroPadding === "number" && Number.isFinite(attrs.pageNumberZeroPadding) ? attrs.pageNumberZeroPadding : undefined;
|
|
103067
|
-
|
|
103938
|
+
const numericPicture = typeof attrs.pageNumberNumericPicture === "string" && attrs.pageNumberNumericPicture.length > 0 ? attrs.pageNumberNumericPicture : undefined;
|
|
103939
|
+
if (!format && !zeroPadding && !numericPicture)
|
|
103068
103940
|
return;
|
|
103069
103941
|
return {
|
|
103070
103942
|
...format ? { format } : {},
|
|
103071
|
-
...zeroPadding ? { zeroPadding } : {}
|
|
103943
|
+
...zeroPadding != null ? { zeroPadding } : {},
|
|
103944
|
+
...numericPicture ? { numericPicture } : {}
|
|
103072
103945
|
};
|
|
103073
103946
|
}
|
|
103074
103947
|
function textNodeToRun({ node: node3, positions, storyKey, defaultFont, defaultSize, inheritedMarks = [], sdtMetadata, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, enableComments, runProperties, inlineRunProperties, converterContext }) {
|
|
@@ -104033,10 +104906,17 @@ function pageReferenceNodeToBlock(params3) {
|
|
|
104033
104906
|
const instruction = getNodeInstruction(node3) || "";
|
|
104034
104907
|
const nodeAttrs = typeof node3.attrs === "object" && node3.attrs !== null ? node3.attrs : {};
|
|
104035
104908
|
const mergedMarks = [...Array.isArray(nodeAttrs.marksAsAttrs) ? nodeAttrs.marksAsAttrs : [], ...inheritedMarks ?? []];
|
|
104036
|
-
const
|
|
104037
|
-
const bookmarkId =
|
|
104909
|
+
const parsed = parsePageRefInstruction(instruction);
|
|
104910
|
+
const bookmarkId = readStringAttr(nodeAttrs.bookmarkId) || parsed.bookmarkId;
|
|
104911
|
+
const hasHyperlinkSwitch = readBooleanAttr(nodeAttrs.hasHyperlinkSwitch) || parsed.hasHyperlinkSwitch;
|
|
104912
|
+
const hasRelativePositionSwitch = readBooleanAttr(nodeAttrs.hasRelativePositionSwitch) || parsed.hasRelativePositionSwitch;
|
|
104913
|
+
const pageNumberFieldFormat = readObjectAttr$1(nodeAttrs.pageNumberFieldFormat) ?? parsed.pageNumberFieldFormat;
|
|
104914
|
+
const numericPictureFormat = readObjectAttr$1(nodeAttrs.numericPictureFormat) ?? parsed.numericPictureFormat;
|
|
104915
|
+
const attrFieldResultFormat = readStringAttr(nodeAttrs.fieldResultFormat);
|
|
104916
|
+
const fieldResultFormat = attrFieldResultFormat === "charformat" || attrFieldResultFormat === "mergeformat" ? attrFieldResultFormat : parsed.fieldResultFormat;
|
|
104038
104917
|
let runProperties = {};
|
|
104039
104918
|
if (bookmarkId) {
|
|
104919
|
+
const fieldRunProperties = readObjectAttr$1(nodeAttrs.fieldRunProperties);
|
|
104040
104920
|
let fallbackText = "??";
|
|
104041
104921
|
if (Array.isArray(node3.content) && node3.content.length > 0) {
|
|
104042
104922
|
const extractText = (n) => {
|
|
@@ -104050,6 +104930,10 @@ function pageReferenceNodeToBlock(params3) {
|
|
|
104050
104930
|
};
|
|
104051
104931
|
fallbackText = node3.content.map(extractText).join("").trim() || "??";
|
|
104052
104932
|
}
|
|
104933
|
+
if (fieldResultFormat === "charformat" && fieldRunProperties)
|
|
104934
|
+
runProperties = fieldRunProperties;
|
|
104935
|
+
else if (Object.keys(runProperties).length === 0 && fieldRunProperties)
|
|
104936
|
+
runProperties = fieldRunProperties;
|
|
104053
104937
|
const pageRefPos = positions.get(node3);
|
|
104054
104938
|
const resolvedRunProperties = resolveRunProperties(converterContext, runProperties, paragraphProperties, null, false, false);
|
|
104055
104939
|
const tokenRun = textNodeToRun({
|
|
@@ -104069,9 +104953,13 @@ function pageReferenceNodeToBlock(params3) {
|
|
|
104069
104953
|
tokenRun.token = "pageReference";
|
|
104070
104954
|
tokenRun.pageRefMetadata = {
|
|
104071
104955
|
bookmarkId,
|
|
104072
|
-
instruction
|
|
104956
|
+
instruction,
|
|
104957
|
+
...hasRelativePositionSwitch ? { relativePosition: true } : {},
|
|
104958
|
+
...pageNumberFieldFormat ? { pageNumberFieldFormat } : {},
|
|
104959
|
+
...numericPictureFormat ? { numericPictureFormat } : {},
|
|
104960
|
+
...fieldResultFormat ? { fieldResultFormat } : {}
|
|
104073
104961
|
};
|
|
104074
|
-
if (
|
|
104962
|
+
if (hasHyperlinkSwitch) {
|
|
104075
104963
|
const synthesized = buildFlowRunLink({ anchor: bookmarkId });
|
|
104076
104964
|
if (synthesized)
|
|
104077
104965
|
tokenRun.link = tokenRun.link ? {
|
|
@@ -104086,6 +104974,15 @@ function pageReferenceNodeToBlock(params3) {
|
|
|
104086
104974
|
} else if (Array.isArray(node3.content))
|
|
104087
104975
|
node3.content.forEach((child) => visitNode(child, mergedMarks, sdtMetadata, runProperties, false, parentInlineRunProperties));
|
|
104088
104976
|
}
|
|
104977
|
+
function readStringAttr(value) {
|
|
104978
|
+
return typeof value === "string" ? value : "";
|
|
104979
|
+
}
|
|
104980
|
+
function readBooleanAttr(value) {
|
|
104981
|
+
return typeof value === "boolean" ? value : undefined;
|
|
104982
|
+
}
|
|
104983
|
+
function readObjectAttr$1(value) {
|
|
104984
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
104985
|
+
}
|
|
104089
104986
|
function fieldAnnotationNodeToRun({ node: node3, positions }) {
|
|
104090
104987
|
const fieldMetadata = resolveNodeSdtMetadata(node3, "fieldAnnotation");
|
|
104091
104988
|
let contentText;
|
|
@@ -104439,15 +105336,31 @@ function crossReferenceNodeToRun(params3) {
|
|
|
104439
105336
|
}
|
|
104440
105337
|
function sequenceFieldNodeToRun(params3) {
|
|
104441
105338
|
const { node: node3, positions, sdtMetadata } = params3;
|
|
104442
|
-
const
|
|
105339
|
+
const attrs = node3.attrs ?? {};
|
|
105340
|
+
const cachedText = typeof attrs.resolvedNumber === "string" ? attrs.resolvedNumber : "";
|
|
104443
105341
|
const run$1 = textNodeToRun({
|
|
104444
105342
|
...params3,
|
|
104445
105343
|
node: {
|
|
104446
105344
|
type: "text",
|
|
104447
|
-
text:
|
|
105345
|
+
text: cachedText || "1",
|
|
104448
105346
|
marks: [...node3.marks ?? []]
|
|
104449
105347
|
}
|
|
104450
105348
|
});
|
|
105349
|
+
run$1.token = "seq";
|
|
105350
|
+
run$1.seqMetadata = {
|
|
105351
|
+
identifier: String(attrs.identifier ?? ""),
|
|
105352
|
+
instruction: String(attrs.instruction ?? ""),
|
|
105353
|
+
fieldArgument: String(attrs.fieldArgument ?? ""),
|
|
105354
|
+
sequenceMode: attrs.sequenceMode === "current" ? "current" : "next",
|
|
105355
|
+
hideResult: attrs.hideResult === true,
|
|
105356
|
+
restartNumber: typeof attrs.restartNumber === "number" ? attrs.restartNumber : null,
|
|
105357
|
+
restartLevel: typeof attrs.restartLevel === "number" ? attrs.restartLevel : null,
|
|
105358
|
+
format: typeof attrs.format === "string" ? attrs.format : undefined,
|
|
105359
|
+
hasGeneralFormat: attrs.hasGeneralFormat === true,
|
|
105360
|
+
pageNumberFieldFormat: readObjectAttr(attrs.pageNumberFieldFormat),
|
|
105361
|
+
numericPictureFormat: readObjectAttr(attrs.numericPictureFormat),
|
|
105362
|
+
cachedText
|
|
105363
|
+
};
|
|
104451
105364
|
const pos = positions.get(node3);
|
|
104452
105365
|
if (pos) {
|
|
104453
105366
|
run$1.pmStart = pos.start;
|
|
@@ -104457,6 +105370,9 @@ function sequenceFieldNodeToRun(params3) {
|
|
|
104457
105370
|
run$1.sdt = sdtMetadata;
|
|
104458
105371
|
return run$1;
|
|
104459
105372
|
}
|
|
105373
|
+
function readObjectAttr(value) {
|
|
105374
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
105375
|
+
}
|
|
104460
105376
|
function documentStatFieldNodeToRun(params3) {
|
|
104461
105377
|
const { node: node3, positions, sdtMetadata } = params3;
|
|
104462
105378
|
const attrs = node3.attrs ?? {};
|
|
@@ -105718,6 +106634,7 @@ function toFlowBlocks(pmDoc, options) {
|
|
|
105718
106634
|
});
|
|
105719
106635
|
const mergedBlocks = mergeFusedParagraphs(mergeDropCapParagraphs(hydrateImageBlocks(blocks, options?.mediaFiles)));
|
|
105720
106636
|
stampTrackedChangeColors(mergedBlocks, options?.resolveTrackedChangeColor);
|
|
106637
|
+
resolveSequenceFieldTokens(mergedBlocks);
|
|
105721
106638
|
flowBlockCache?.commit();
|
|
105722
106639
|
return {
|
|
105723
106640
|
blocks: mergedBlocks,
|
|
@@ -107363,6 +108280,20 @@ function pxToInches(value) {
|
|
|
107363
108280
|
return;
|
|
107364
108281
|
return value / PIXELS_PER_INCH;
|
|
107365
108282
|
}
|
|
108283
|
+
function toSectionPageNumbering(numbering) {
|
|
108284
|
+
if (!numbering)
|
|
108285
|
+
return;
|
|
108286
|
+
const format = SECTION_PAGE_NUMBER_FORMATS.includes(numbering.format) ? numbering.format : undefined;
|
|
108287
|
+
const result = {
|
|
108288
|
+
start: numbering.start,
|
|
108289
|
+
format,
|
|
108290
|
+
chapterStyle: numbering.chapterStyle,
|
|
108291
|
+
chapterSeparator: numbering.chapterSeparator
|
|
108292
|
+
};
|
|
108293
|
+
if (result.start === undefined && result.format === undefined && result.chapterStyle === undefined && result.chapterSeparator === undefined)
|
|
108294
|
+
return;
|
|
108295
|
+
return result;
|
|
108296
|
+
}
|
|
107366
108297
|
function buildSectionId(index2) {
|
|
107367
108298
|
return `section-${index2}`;
|
|
107368
108299
|
}
|
|
@@ -107539,7 +108470,7 @@ function sectionRangeToSectionDomain(range, address2, oddEvenHeadersFooters) {
|
|
|
107539
108470
|
headerFooterMargins: hasHeaderFooterMargins ? headerFooterMargins : undefined,
|
|
107540
108471
|
columns: hasColumns ? columns : undefined,
|
|
107541
108472
|
lineNumbering: parsedLineNumbering,
|
|
107542
|
-
pageNumbering: range.numbering ?? parsedPageNumbering,
|
|
108473
|
+
pageNumbering: toSectionPageNumbering(range.numbering) ?? parsedPageNumbering,
|
|
107543
108474
|
titlePage: range.titlePg,
|
|
107544
108475
|
oddEvenHeadersFooters,
|
|
107545
108476
|
verticalAlign: range.vAlign ?? parsedVerticalAlign,
|
|
@@ -113529,7 +114460,7 @@ var isRegExp = (value) => {
|
|
|
113529
114460
|
consumed: 1
|
|
113530
114461
|
};
|
|
113531
114462
|
}
|
|
113532
|
-
}), createSingleIntegerPropertyHandler = (xmlName, sdName = null) => createSingleAttrPropertyHandler(xmlName, sdName, "w:val", parseInteger, integerToString), UNSUPPORTED_TABLE_IDENTITY_ATTRS, parseMeasurementValue = (value, type) => {
|
|
114463
|
+
}), createSingleIntegerPropertyHandler = (xmlName, sdName = null) => createSingleAttrPropertyHandler(xmlName, sdName, "w:val", parseInteger$1, integerToString), UNSUPPORTED_TABLE_IDENTITY_ATTRS, parseMeasurementValue = (value, type) => {
|
|
113533
114464
|
if (value == null)
|
|
113534
114465
|
return;
|
|
113535
114466
|
const strValue = String(value);
|
|
@@ -113553,19 +114484,19 @@ var isRegExp = (value) => {
|
|
|
113553
114484
|
encode: (attributes) => transformEncode(attributes[xmlName]),
|
|
113554
114485
|
decode: (attributes) => transformDecode(attributes[sdName])
|
|
113555
114486
|
};
|
|
113556
|
-
}, createIntegerAttributeHandler = (xmlName, sdName = null) => createAttributeHandler(xmlName, sdName, parseInteger, integerToString), createBooleanAttributeHandler = (xmlName, sdName = null) => createAttributeHandler(xmlName, sdName, parseBoolean, booleanToString), parseBoolean = (value) => value != null ? [
|
|
114487
|
+
}, createIntegerAttributeHandler = (xmlName, sdName = null) => createAttributeHandler(xmlName, sdName, parseInteger$1, integerToString), createBooleanAttributeHandler = (xmlName, sdName = null) => createAttributeHandler(xmlName, sdName, parseBoolean, booleanToString), parseBoolean = (value) => value != null ? [
|
|
113557
114488
|
"1",
|
|
113558
114489
|
"true",
|
|
113559
114490
|
"on",
|
|
113560
114491
|
1,
|
|
113561
114492
|
true
|
|
113562
|
-
].includes(value) : undefined, booleanToString = (value) => value != null ? value ? "1" : "0" : undefined, parseInteger = (value) => {
|
|
114493
|
+
].includes(value) : undefined, booleanToString = (value) => value != null ? value ? "1" : "0" : undefined, parseInteger$1 = (value) => {
|
|
113563
114494
|
if (value == null)
|
|
113564
114495
|
return;
|
|
113565
114496
|
const intValue = parseInt(value, 10);
|
|
113566
114497
|
return isNaN(intValue) ? undefined : intValue;
|
|
113567
114498
|
}, integerToString = (value) => {
|
|
113568
|
-
const intValue = parseInteger(value);
|
|
114499
|
+
const intValue = parseInteger$1(value);
|
|
113569
114500
|
return intValue != null ? String(intValue) : undefined;
|
|
113570
114501
|
}, translator$46, translator$50, translator$48, translator$79, encode$73 = (attributes) => attributes?.["w:val"], decode$75 = (attrs) => attrs?.underline, attrConfig$29, encode$72 = (attributes) => attributes?.["w:color"], decode$74 = (attrs) => attrs?.color, attrConfig$30, encode$71 = (attributes) => attributes?.["w:themeColor"], decode$73 = (attrs) => attrs?.themeColor, attrConfig$31, encode$70 = (attributes) => attributes?.["w:themeTint"], decode$72 = (attrs) => attrs?.themeTint, attrConfig$32, encode$69 = (attributes) => attributes?.["w:themeShade"], decode$71 = (attrs) => attrs?.themeShade, attributes_default$7, XML_NODE_NAME$41 = "w:u", SD_ATTR_KEY$3 = "underline", encode$68 = (params3, encodedAttrs = {}) => {
|
|
113571
114502
|
const { nodes } = params3;
|
|
@@ -114030,7 +114961,7 @@ var isRegExp = (value) => {
|
|
|
114030
114961
|
}, stampTrackedChangeColors = (blocks, resolve2) => {
|
|
114031
114962
|
for (const block of blocks)
|
|
114032
114963
|
stampBlockTrackedChangeColors(block, resolve2);
|
|
114033
|
-
}, idlessSdtContainerKeys, nextIdlessSdtContainerKey = 0, engines_exports, EMPTY_SDT_PLACEHOLDER_TEXT = "Click or tap here to enter text", FONT_SLOT_THEME_PAIRS, TABLE_STYLE_ID_TABLE_GRID = "TableGrid", TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS, TABLE_FALLBACK_CELL_PADDING, DEFAULT_TBL_LOOK, CNF_STYLE_MAP, TABLE_STYLE_PRECEDENCE, getToCssFontFamily = () => {
|
|
114964
|
+
}, idlessSdtContainerKeys, nextIdlessSdtContainerKey = 0, MAX_BOOKMARK_MARKER_LEAD_DISTANCE = 3, engines_exports, EMPTY_SDT_PLACEHOLDER_TEXT = "Click or tap here to enter text", FONT_SLOT_THEME_PAIRS, TABLE_STYLE_ID_TABLE_GRID = "TableGrid", TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS, TABLE_FALLBACK_CELL_PADDING, DEFAULT_TBL_LOOK, CNF_STYLE_MAP, TABLE_STYLE_PRECEDENCE, getToCssFontFamily = () => {
|
|
114034
114965
|
return SuperConverter.toCssFontFamily;
|
|
114035
114966
|
}, getSpacingStyle = (spacing, isListItem$1) => {
|
|
114036
114967
|
let { before: before2, after: after2, line, lineRule, beforeAutospacing, afterAutospacing } = spacing;
|
|
@@ -119694,8 +120625,7 @@ var isRegExp = (value) => {
|
|
|
119694
120625
|
domEnvironment$1 = env || null;
|
|
119695
120626
|
}, MM_ANISOTROPIC = 8, EMF_SIGNATURE = 1179469088, EMF_PLUS_SIGNATURE = 726027589, EMR_COMMENT = 70, EMF_PLUS_OBJECT = 16392, EMF_PLUS_OBJECT_TYPE_IMAGE = 5, EMF_PLUS_IMAGE_TYPE_BITMAP = 1, EMF_PLUS_BITMAP_TYPE_PIXEL = 0, EMF_PLUS_BITMAP_TYPE_COMPRESSED = 1, EMF_PLUS_PIXEL_FORMAT_INDEXED_FLAG = 65536, EMF_PLUS_PIXEL_FORMAT_24BPP_RGB = 137224, EMF_PLUS_PIXEL_FORMAT_32BPP_RGB = 139273, EMF_PLUS_PIXEL_FORMAT_32BPP_ARGB = 2498570, EMF_PLUS_PIXEL_FORMAT_32BPP_PARGB = 925707, MAX_PIXEL_BITMAP_PIXELS = 1e8, base64ToArrayBuffer, require_common, require_trees, require_adler32, require_crc32, require_messages, require_deflate$1, require_strings, require_zstream, require_deflate, require_inffast, require_inftrees, require_inflate$1, require_constants2, require_gzheader, require_inflate, require_pako, import_UTIF, domEnvironment = null, MAX_PIXEL_COUNT = 1e8, setTiffDomEnvironment = (env) => {
|
|
119696
120627
|
domEnvironment = env || null;
|
|
119697
|
-
}, GENERAL_FORMATS, CASE_INSENSITIVE_GENERAL_FORMATS, getInstructionPreProcessor = (instruction) => {
|
|
119698
|
-
const rawInstructionType = String(instruction ?? "").trim().split(/\s+/)[0];
|
|
120628
|
+
}, GENERAL_FORMATS, CASE_INSENSITIVE_GENERAL_FORMATS, TOKEN_PATTERN$1, getInstructionPreProcessor = (instruction) => {
|
|
119699
120629
|
switch (extractFieldKeyword(instruction)) {
|
|
119700
120630
|
case "PAGE":
|
|
119701
120631
|
return preProcessPageInstruction;
|
|
@@ -119725,8 +120655,6 @@ var isRegExp = (value) => {
|
|
|
119725
120655
|
case "STYLEREF":
|
|
119726
120656
|
return preProcessStylerefInstruction;
|
|
119727
120657
|
case "SEQ":
|
|
119728
|
-
if (rawInstructionType !== "SEQ")
|
|
119729
|
-
return null;
|
|
119730
120658
|
return preProcessSeqInstruction;
|
|
119731
120659
|
case "CITATION":
|
|
119732
120660
|
return preProcessCitationInstruction;
|
|
@@ -119744,6 +120672,8 @@ var isRegExp = (value) => {
|
|
|
119744
120672
|
let collectedNodesStack = [];
|
|
119745
120673
|
let rawCollectedNodesStack = [];
|
|
119746
120674
|
let fieldRunRPrStack = [];
|
|
120675
|
+
let firstInstrTextRunRPrStack = [];
|
|
120676
|
+
let firstInstrTextRunSeenStack = [];
|
|
119747
120677
|
let currentFieldStack = [];
|
|
119748
120678
|
let unpairedEnd = null;
|
|
119749
120679
|
let unpairedEndPreserveRaw = null;
|
|
@@ -119754,10 +120684,12 @@ var isRegExp = (value) => {
|
|
|
119754
120684
|
const collectedNodes = collectedNodesStack.pop().filter((n) => n !== null);
|
|
119755
120685
|
const rawCollectedNodes = rawCollectedNodesStack.pop().filter((n) => n !== null);
|
|
119756
120686
|
const fieldRunRPr = fieldRunRPrStack.pop() ?? null;
|
|
120687
|
+
const firstInstrTextRunRPr = firstInstrTextRunRPrStack.pop() ?? null;
|
|
120688
|
+
firstInstrTextRunSeenStack.pop();
|
|
119757
120689
|
const currentField = currentFieldStack.pop();
|
|
119758
120690
|
let outputNodes = rawCollectedNodes;
|
|
119759
120691
|
if (!currentField.preserveRaw) {
|
|
119760
|
-
const combinedResult = _processCombinedNodesForFldChar(collectedNodes, currentField.instrText.trim(), docx, currentField.instructionTokens, fieldRunRPr);
|
|
120692
|
+
const combinedResult = _processCombinedNodesForFldChar(collectedNodes, currentField.instrText.trim(), docx, currentField.instructionTokens, fieldRunRPr, firstInstrTextRunRPr);
|
|
119761
120693
|
outputNodes = combinedResult.handled ? combinedResult.nodes : rawCollectedNodes;
|
|
119762
120694
|
} else if (currentField.preserveRawConstructive)
|
|
119763
120695
|
applyConstructiveFieldInterpretation(outputNodes, currentField.instrText.trim(), docx);
|
|
@@ -119819,6 +120751,8 @@ var isRegExp = (value) => {
|
|
|
119819
120751
|
rawNodeSourceTokens.set(rawNode, rawSourceToken);
|
|
119820
120752
|
capturedRawNodes.add(rawNode);
|
|
119821
120753
|
fieldRunRPrStack.push(extractFieldRunRPr(node3));
|
|
120754
|
+
firstInstrTextRunRPrStack.push(null);
|
|
120755
|
+
firstInstrTextRunSeenStack.push(false);
|
|
119822
120756
|
currentFieldStack.push({
|
|
119823
120757
|
instrText: "",
|
|
119824
120758
|
instructionTokens: [],
|
|
@@ -119835,6 +120769,10 @@ var isRegExp = (value) => {
|
|
|
119835
120769
|
const fieldRunRPr = extractFieldRunRPr(node3);
|
|
119836
120770
|
if (fieldRunRPr)
|
|
119837
120771
|
fieldRunRPrStack[fieldRunRPrStack.length - 1] = fieldRunRPr;
|
|
120772
|
+
if (instrTextEl && !firstInstrTextRunSeenStack[firstInstrTextRunSeenStack.length - 1]) {
|
|
120773
|
+
firstInstrTextRunSeenStack[firstInstrTextRunSeenStack.length - 1] = true;
|
|
120774
|
+
firstInstrTextRunRPrStack[firstInstrTextRunRPrStack.length - 1] = fieldRunRPr;
|
|
120775
|
+
}
|
|
119838
120776
|
currentField.instructionTokens.push(...instructionTokens);
|
|
119839
120777
|
const instrTextValue = instrTextEl?.elements?.[0]?.text;
|
|
119840
120778
|
if (instrTextValue != null)
|
|
@@ -119933,14 +120871,15 @@ var isRegExp = (value) => {
|
|
|
119933
120871
|
unpairedEnd,
|
|
119934
120872
|
unpairedEndPreserveRaw
|
|
119935
120873
|
};
|
|
119936
|
-
}, _processCombinedNodesForFldChar = (nodesToCombine = [], instrText, docx, instructionTokens, fieldRunRPr) => {
|
|
120874
|
+
}, _processCombinedNodesForFldChar = (nodesToCombine = [], instrText, docx, instructionTokens, fieldRunRPr, firstInstrTextRunRPr) => {
|
|
119937
120875
|
const instructionPreProcessor = getInstructionPreProcessor(instrText);
|
|
119938
120876
|
if (instructionPreProcessor)
|
|
119939
120877
|
return {
|
|
119940
120878
|
nodes: instructionPreProcessor(nodesToCombine, instrText, {
|
|
119941
120879
|
docx,
|
|
119942
120880
|
instructionTokens,
|
|
119943
|
-
fieldRunRPr
|
|
120881
|
+
fieldRunRPr,
|
|
120882
|
+
firstInstrTextRunRPr
|
|
119944
120883
|
}),
|
|
119945
120884
|
handled: true
|
|
119946
120885
|
};
|
|
@@ -125310,11 +126249,11 @@ var isRegExp = (value) => {
|
|
|
125310
126249
|
}, decode$29 = (attrs) => {
|
|
125311
126250
|
return attrs.ed;
|
|
125312
126251
|
}, attrConfig$8, encode$28 = (attributes) => {
|
|
125313
|
-
return parseInteger(attributes["w:colFirst"]);
|
|
126252
|
+
return parseInteger$1(attributes["w:colFirst"]);
|
|
125314
126253
|
}, decode$28 = (attrs) => {
|
|
125315
126254
|
return integerToString(attrs.colFirst);
|
|
125316
126255
|
}, attrConfig$9, encode$27 = (attributes) => {
|
|
125317
|
-
return parseInteger(attributes["w:colLast"]);
|
|
126256
|
+
return parseInteger$1(attributes["w:colLast"]);
|
|
125318
126257
|
}, decode$27 = (attrs) => {
|
|
125319
126258
|
return integerToString(attrs.colLast);
|
|
125320
126259
|
}, attributes_default$3, XML_NODE_NAME$20 = "w:permStart", SD_NODE_NAME$20, encode$26 = (params3, encodedAttrs = {}) => {
|
|
@@ -125353,7 +126292,44 @@ var isRegExp = (value) => {
|
|
|
125353
126292
|
if (decodedAttrs && Object.keys(decodedAttrs).length)
|
|
125354
126293
|
result.attributes = decodedAttrs;
|
|
125355
126294
|
return result;
|
|
125356
|
-
}, config$20, translator$16,
|
|
126295
|
+
}, config$20, translator$16, buildInstructionElements = (instruction, instructionTokens) => {
|
|
126296
|
+
const tokens = Array.isArray(instructionTokens) ? instructionTokens : [];
|
|
126297
|
+
if (tokens.length > 0)
|
|
126298
|
+
return tokens.map((tokenLike) => {
|
|
126299
|
+
if (typeof tokenLike === "string")
|
|
126300
|
+
return {
|
|
126301
|
+
name: "w:instrText",
|
|
126302
|
+
attributes: { "xml:space": "preserve" },
|
|
126303
|
+
elements: [{
|
|
126304
|
+
type: "text",
|
|
126305
|
+
text: tokenLike
|
|
126306
|
+
}]
|
|
126307
|
+
};
|
|
126308
|
+
const token = tokenLike;
|
|
126309
|
+
if (token?.type === "tab")
|
|
126310
|
+
return {
|
|
126311
|
+
name: "w:tab",
|
|
126312
|
+
elements: []
|
|
126313
|
+
};
|
|
126314
|
+
const text$2 = token?.text ?? "";
|
|
126315
|
+
return {
|
|
126316
|
+
name: "w:instrText",
|
|
126317
|
+
attributes: { "xml:space": "preserve" },
|
|
126318
|
+
elements: [{
|
|
126319
|
+
type: "text",
|
|
126320
|
+
text: text$2
|
|
126321
|
+
}]
|
|
126322
|
+
};
|
|
126323
|
+
});
|
|
126324
|
+
return [{
|
|
126325
|
+
name: "w:instrText",
|
|
126326
|
+
attributes: { "xml:space": "preserve" },
|
|
126327
|
+
elements: [{
|
|
126328
|
+
type: "text",
|
|
126329
|
+
text: instruction ?? ""
|
|
126330
|
+
}]
|
|
126331
|
+
}];
|
|
126332
|
+
}, XML_NODE_NAME$18 = "sd:pageReference", SD_NODE_NAME$18 = "pageReference", encode$22 = (params3) => {
|
|
125357
126333
|
const { nodes = [], nodeListHandler } = params3 || {};
|
|
125358
126334
|
const node3 = nodes[0];
|
|
125359
126335
|
const processedText = nodeListHandler.handler({
|
|
@@ -125364,7 +126340,15 @@ var isRegExp = (value) => {
|
|
|
125364
126340
|
type: "pageReference",
|
|
125365
126341
|
attrs: {
|
|
125366
126342
|
instruction: node3.attributes?.instruction || "",
|
|
125367
|
-
marksAsAttrs: node3.marks || []
|
|
126343
|
+
marksAsAttrs: node3.marks || [],
|
|
126344
|
+
...node3.attributes?.instructionTokens ? { instructionTokens: node3.attributes.instructionTokens } : {},
|
|
126345
|
+
...node3.attributes?.bookmarkId ? { bookmarkId: node3.attributes.bookmarkId } : {},
|
|
126346
|
+
...node3.attributes?.hasHyperlinkSwitch ? { hasHyperlinkSwitch: true } : {},
|
|
126347
|
+
...node3.attributes?.hasRelativePositionSwitch ? { hasRelativePositionSwitch: true } : {},
|
|
126348
|
+
...node3.attributes?.pageNumberFieldFormat ? { pageNumberFieldFormat: node3.attributes.pageNumberFieldFormat } : {},
|
|
126349
|
+
...node3.attributes?.numericPictureFormat ? { numericPictureFormat: node3.attributes.numericPictureFormat } : {},
|
|
126350
|
+
...node3.attributes?.fieldResultFormat ? { fieldResultFormat: node3.attributes.fieldResultFormat } : {},
|
|
126351
|
+
...node3.attributes?.fieldRunProperties ? { fieldRunProperties: node3.attributes.fieldRunProperties } : {}
|
|
125368
126352
|
},
|
|
125369
126353
|
content: processedText
|
|
125370
126354
|
};
|
|
@@ -125375,6 +126359,8 @@ var isRegExp = (value) => {
|
|
|
125375
126359
|
...params3,
|
|
125376
126360
|
node: n
|
|
125377
126361
|
}));
|
|
126362
|
+
const instructionElements = buildInstructionElements(node3.attrs?.instruction, node3.attrs?.instructionTokens);
|
|
126363
|
+
const instructionRunProperties = resolveInstructionRunProperties(params3, outputMarks);
|
|
125378
126364
|
return [
|
|
125379
126365
|
{
|
|
125380
126366
|
name: "w:r",
|
|
@@ -125390,15 +126376,8 @@ var isRegExp = (value) => {
|
|
|
125390
126376
|
name: "w:r",
|
|
125391
126377
|
elements: [{
|
|
125392
126378
|
name: "w:rPr",
|
|
125393
|
-
elements:
|
|
125394
|
-
},
|
|
125395
|
-
name: "w:instrText",
|
|
125396
|
-
attributes: { "xml:space": "preserve" },
|
|
125397
|
-
elements: [{
|
|
125398
|
-
type: "text",
|
|
125399
|
-
text: `${node3.attrs.instruction}`
|
|
125400
|
-
}]
|
|
125401
|
-
}]
|
|
126379
|
+
elements: instructionRunProperties
|
|
126380
|
+
}, ...instructionElements]
|
|
125402
126381
|
},
|
|
125403
126382
|
{
|
|
125404
126383
|
name: "w:r",
|
|
@@ -125422,44 +126401,17 @@ var isRegExp = (value) => {
|
|
|
125422
126401
|
}]
|
|
125423
126402
|
}
|
|
125424
126403
|
];
|
|
125425
|
-
},
|
|
125426
|
-
const
|
|
125427
|
-
|
|
125428
|
-
|
|
125429
|
-
|
|
125430
|
-
|
|
125431
|
-
|
|
125432
|
-
|
|
125433
|
-
|
|
125434
|
-
|
|
125435
|
-
|
|
125436
|
-
}]
|
|
125437
|
-
};
|
|
125438
|
-
const token = tokenLike;
|
|
125439
|
-
if (token?.type === "tab")
|
|
125440
|
-
return {
|
|
125441
|
-
name: "w:tab",
|
|
125442
|
-
elements: []
|
|
125443
|
-
};
|
|
125444
|
-
const text$2 = token?.text ?? "";
|
|
125445
|
-
return {
|
|
125446
|
-
name: "w:instrText",
|
|
125447
|
-
attributes: { "xml:space": "preserve" },
|
|
125448
|
-
elements: [{
|
|
125449
|
-
type: "text",
|
|
125450
|
-
text: text$2
|
|
125451
|
-
}]
|
|
125452
|
-
};
|
|
125453
|
-
});
|
|
125454
|
-
return [{
|
|
125455
|
-
name: "w:instrText",
|
|
125456
|
-
attributes: { "xml:space": "preserve" },
|
|
125457
|
-
elements: [{
|
|
125458
|
-
type: "text",
|
|
125459
|
-
text: instruction ?? ""
|
|
125460
|
-
}]
|
|
125461
|
-
}];
|
|
125462
|
-
}, XML_NODE_NAME$17 = "sd:crossReference", SD_NODE_NAME$17 = "crossReference", encode$21 = (params3) => {
|
|
126404
|
+
}, resolveInstructionRunProperties = (params3, outputMarks) => {
|
|
126405
|
+
const { node: node3 } = params3;
|
|
126406
|
+
const fieldRunProperties = node3.attrs?.fieldRunProperties;
|
|
126407
|
+
if (!(node3.attrs?.fieldResultFormat === "charformat" && fieldRunProperties && typeof fieldRunProperties === "object" && !Array.isArray(fieldRunProperties) && Object.keys(fieldRunProperties).length > 0))
|
|
126408
|
+
return outputMarks;
|
|
126409
|
+
const fieldRunPropertiesNode = translator$133.decode({
|
|
126410
|
+
...params3,
|
|
126411
|
+
node: { attrs: { runProperties: fieldRunProperties } }
|
|
126412
|
+
});
|
|
126413
|
+
return Array.isArray(fieldRunPropertiesNode?.elements) ? fieldRunPropertiesNode.elements : outputMarks;
|
|
126414
|
+
}, config$19, translator$17, XML_NODE_NAME$17 = "sd:crossReference", SD_NODE_NAME$17 = "crossReference", encode$21 = (params3) => {
|
|
125463
126415
|
const { nodes = [], nodeListHandler } = params3 || {};
|
|
125464
126416
|
const node3 = nodes[0];
|
|
125465
126417
|
const processedText = nodeListHandler.handler({
|
|
@@ -125703,7 +126655,7 @@ var isRegExp = (value) => {
|
|
|
125703
126655
|
...params3,
|
|
125704
126656
|
node: n
|
|
125705
126657
|
})), buildInstructionElements(node3.attrs?.instruction, node3.attrs?.instructionTokens), node3.attrs?.wrapperParagraphProperties ?? null);
|
|
125706
|
-
}, config$14, translator$22, XML_NODE_NAME$12 = "sd:sequenceField", SD_NODE_NAME$12 = "sequenceField", encode$16 = (params3) => {
|
|
126658
|
+
}, config$14, translator$22, TOKEN_PATTERN, XML_NODE_NAME$12 = "sd:sequenceField", SD_NODE_NAME$12 = "sequenceField", encode$16 = (params3) => {
|
|
125707
126659
|
const { nodes = [], nodeListHandler } = params3 || {};
|
|
125708
126660
|
const node3 = nodes[0];
|
|
125709
126661
|
const processedText = nodeListHandler.handler({
|
|
@@ -125711,16 +126663,15 @@ var isRegExp = (value) => {
|
|
|
125711
126663
|
nodes: node3.elements || []
|
|
125712
126664
|
});
|
|
125713
126665
|
const instruction = node3.attributes?.instruction || "";
|
|
125714
|
-
const
|
|
126666
|
+
const parsedAttrs = sequenceFieldAttrsFromParsed(parseSeqInstruction(instruction));
|
|
125715
126667
|
return {
|
|
125716
126668
|
type: SD_NODE_NAME$12,
|
|
125717
126669
|
attrs: {
|
|
125718
126670
|
instruction,
|
|
125719
126671
|
instructionTokens: node3.attributes?.instructionTokens || null,
|
|
125720
|
-
|
|
125721
|
-
format,
|
|
125722
|
-
restartLevel,
|
|
126672
|
+
...parsedAttrs,
|
|
125723
126673
|
resolvedNumber: extractResolvedText(processedText),
|
|
126674
|
+
resolvedNumberIsCurrent: false,
|
|
125724
126675
|
marksAsAttrs: node3.marks || []
|
|
125725
126676
|
},
|
|
125726
126677
|
content: processedText
|
|
@@ -125728,10 +126679,7 @@ var isRegExp = (value) => {
|
|
|
125728
126679
|
}, decode$16 = (params3) => {
|
|
125729
126680
|
const { node: node3 } = params3;
|
|
125730
126681
|
const outputMarks = processOutputMarks(node3.attrs?.marksAsAttrs || []);
|
|
125731
|
-
const contentNodes = (
|
|
125732
|
-
...params3,
|
|
125733
|
-
node: n
|
|
125734
|
-
}));
|
|
126682
|
+
const contentNodes = buildResultContentNodes(params3, outputMarks);
|
|
125735
126683
|
const instructionElements = buildInstructionElements(node3.attrs?.instruction, node3.attrs?.instructionTokens);
|
|
125736
126684
|
return [
|
|
125737
126685
|
{
|
|
@@ -126671,7 +127619,7 @@ var isRegExp = (value) => {
|
|
|
126671
127619
|
}),
|
|
126672
127620
|
consumed: 1
|
|
126673
127621
|
};
|
|
126674
|
-
}, alternateChoiceHandler, autoPageHandlerEntity, autoTotalPageCountEntity, sectionPageCountEntity, documentStatFieldHandlerEntity, pageReferenceEntity, crossReferenceEntity, handlePictNode = (params3) => {
|
|
127622
|
+
}, alternateChoiceHandler, autoPageHandlerEntity, autoTotalPageCountEntity, sectionPageCountEntity, documentStatFieldHandlerEntity, pageReferenceEntity, crossReferenceEntity, sequenceFieldEntity, handlePictNode = (params3) => {
|
|
126675
127623
|
const { nodes } = params3;
|
|
126676
127624
|
if (!Array.isArray(nodes) || nodes.length === 0 || nodes[0]?.name !== "w:pict")
|
|
126677
127625
|
return {
|
|
@@ -127584,6 +128532,7 @@ var isRegExp = (value) => {
|
|
|
127584
128532
|
documentStatFieldHandlerEntity,
|
|
127585
128533
|
pageReferenceEntity,
|
|
127586
128534
|
crossReferenceEntity,
|
|
128535
|
+
sequenceFieldEntity,
|
|
127587
128536
|
permStartHandlerEntity,
|
|
127588
128537
|
permEndHandlerEntity,
|
|
127589
128538
|
mathNodeHandlerEntity,
|
|
@@ -128951,6 +129900,83 @@ var isRegExp = (value) => {
|
|
|
128951
129900
|
width: typeof maybe.width === "string" && LINE_END_SIZES.has(maybe.width) ? maybe.width : undefined,
|
|
128952
129901
|
length: typeof maybe.length === "string" && LINE_END_SIZES.has(maybe.length) ? maybe.length : undefined
|
|
128953
129902
|
};
|
|
129903
|
+
}, SequenceFieldEvaluator = class {
|
|
129904
|
+
constructor(options = {}) {
|
|
129905
|
+
this.counters = new Map(options.initialCounters ?? []);
|
|
129906
|
+
this.headingSerialsByLevel = /* @__PURE__ */ new Map;
|
|
129907
|
+
this.lastResetSerialByIdentifierLevel = /* @__PURE__ */ new Map;
|
|
129908
|
+
}
|
|
129909
|
+
enterParagraph(context = {}) {
|
|
129910
|
+
const level = context.paragraphHeadingLevel;
|
|
129911
|
+
if (!isValidHeadingLevel(level))
|
|
129912
|
+
return;
|
|
129913
|
+
this.headingSerialsByLevel.set(level, (this.headingSerialsByLevel.get(level) ?? 0) + 1);
|
|
129914
|
+
for (let deeperLevel = level + 1;deeperLevel <= 9; deeperLevel += 1)
|
|
129915
|
+
this.headingSerialsByLevel.delete(deeperLevel);
|
|
129916
|
+
}
|
|
129917
|
+
evaluateField(field) {
|
|
129918
|
+
const identifier = normalizeSeqIdentifier(field?.identifier);
|
|
129919
|
+
const cachedText = typeof field?.cachedText === "string" ? field.cachedText : "";
|
|
129920
|
+
if (!identifier)
|
|
129921
|
+
return {
|
|
129922
|
+
value: null,
|
|
129923
|
+
text: cachedText,
|
|
129924
|
+
hidden: false
|
|
129925
|
+
};
|
|
129926
|
+
if (hasFieldArgument(field)) {
|
|
129927
|
+
if (cachedText)
|
|
129928
|
+
return {
|
|
129929
|
+
value: null,
|
|
129930
|
+
text: cachedText,
|
|
129931
|
+
hidden: false
|
|
129932
|
+
};
|
|
129933
|
+
if (!this.counters.has(identifier))
|
|
129934
|
+
return {
|
|
129935
|
+
value: null,
|
|
129936
|
+
text: "",
|
|
129937
|
+
hidden: false
|
|
129938
|
+
};
|
|
129939
|
+
const value$1 = this.counters.get(identifier);
|
|
129940
|
+
return {
|
|
129941
|
+
value: value$1,
|
|
129942
|
+
text: formatSeqValue(value$1, field),
|
|
129943
|
+
hidden: false
|
|
129944
|
+
};
|
|
129945
|
+
}
|
|
129946
|
+
const restartLevel = normalizeRestartLevel(field?.restartLevel);
|
|
129947
|
+
if (restartLevel != null) {
|
|
129948
|
+
const key = `${identifier}|${restartLevel}`;
|
|
129949
|
+
const serial = this.headingSerialsByLevel.get(restartLevel) ?? 0;
|
|
129950
|
+
const previousSerial = this.lastResetSerialByIdentifierLevel.get(key);
|
|
129951
|
+
if (previousSerial === undefined || serial !== previousSerial) {
|
|
129952
|
+
this.counters.set(identifier, 0);
|
|
129953
|
+
this.lastResetSerialByIdentifierLevel.set(key, serial);
|
|
129954
|
+
}
|
|
129955
|
+
}
|
|
129956
|
+
const restartNumber = normalizeRestartNumber(field?.restartNumber);
|
|
129957
|
+
let value;
|
|
129958
|
+
if (restartNumber != null) {
|
|
129959
|
+
this.counters.set(identifier, restartNumber);
|
|
129960
|
+
value = restartNumber;
|
|
129961
|
+
} else if (field?.sequenceMode === "current") {
|
|
129962
|
+
if (!this.counters.has(identifier))
|
|
129963
|
+
return {
|
|
129964
|
+
value: 0,
|
|
129965
|
+
text: cachedText,
|
|
129966
|
+
hidden: false
|
|
129967
|
+
};
|
|
129968
|
+
value = this.counters.get(identifier);
|
|
129969
|
+
} else {
|
|
129970
|
+
value = (this.counters.get(identifier) ?? 0) + 1;
|
|
129971
|
+
this.counters.set(identifier, value);
|
|
129972
|
+
}
|
|
129973
|
+
const hidden = Boolean(field?.hideResult && !field.hasGeneralFormat && !field.numericPictureFormat);
|
|
129974
|
+
return {
|
|
129975
|
+
value,
|
|
129976
|
+
text: hidden ? "" : formatSeqValue(value, field),
|
|
129977
|
+
hidden
|
|
129978
|
+
};
|
|
129979
|
+
}
|
|
128954
129980
|
}, getNodeRevision = (node3) => {
|
|
128955
129981
|
const attrs = node3?.attrs;
|
|
128956
129982
|
if (!attrs)
|
|
@@ -129516,6 +130542,10 @@ var isRegExp = (value) => {
|
|
|
129516
130542
|
const styleOutlineLevel = styleDefinition?.paragraphProperties?.outlineLvl;
|
|
129517
130543
|
if (typeof styleOutlineLevel === "number" && Number.isInteger(styleOutlineLevel))
|
|
129518
130544
|
return normalizeHeadingLevel(styleOutlineLevel + 1);
|
|
130545
|
+
}, resolveParagraphHeadingLevel = (paragraphProperties, converterContext) => {
|
|
130546
|
+
const properties = paragraphProperties ?? {};
|
|
130547
|
+
const resolvedParagraphProperties = converterContext ? resolveParagraphProperties(converterContext, properties, converterContext.tableInfo) : properties;
|
|
130548
|
+
return resolveHeadingLevel(resolvedParagraphProperties.styleId, resolvedParagraphProperties, converterContext);
|
|
129519
130549
|
}, TRACKED_CHANGE_KEYS, hasExplicitParagraphRunProperties = (paragraphProperties) => {
|
|
129520
130550
|
if (paragraphProperties?.runProperties == null)
|
|
129521
130551
|
return false;
|
|
@@ -131618,7 +132648,7 @@ var isRegExp = (value) => {
|
|
|
131618
132648
|
return;
|
|
131619
132649
|
updateGhostListMarkerOffsets(node3, paragraphBlocks, context);
|
|
131620
132650
|
applyGhostListMarkerOffsets(node3, paragraphBlocks, context);
|
|
131621
|
-
}, INLINE_CONVERTERS_REGISTRY, SHAPE_CONVERTERS_REGISTRY, JUSTIFICATION_TO_ALIGN, DEFAULT_FONT = "Times New Roman", DEFAULT_SIZE2, nodeHandlers, converters, CommentMarkName = "commentMark", LINK_MARK_NAME = "link", COMMENT_MARK_NAME, SUPPORTED_INLINE_TYPES, FALLBACK_PREFIX, UUID_LIKE_PATTERN, ALIAS_ELIGIBLE_TYPES, cacheByEditor, OBJECT_REPLACEMENT_CHAR = "", LINE_NUMBER_RESTART_VALUES, PAGE_NUMBER_FORMAT_VALUES, PAGE_NUMBER_CHAPTER_SEPARATOR_VALUES, SECTION_ORIENTATION_VALUES, SECTION_VERTICAL_ALIGN_VALUES, readSectPrHeaderFooterRefs, PIXELS_PER_INCH = 96, SETTINGS_PART_PATH = "word/settings.xml", VALID_EDIT_MODES, DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels", RELS_XMLNS = "http://schemas.openxmlformats.org/package/2006/relationships", HEADER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", WORDPROCESSINGML_XMLNS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", OFFICE_DOCUMENT_RELS_XMLNS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", RELATIONSHIP_ID_PATTERN, HEADER_FILE_PATTERN, FOOTER_FILE_PATTERN, SOURCE_HEADER_FOOTER_LOCAL = "header-footer-sync:local", HEADER_PATTERN, FOOTER_PATTERN, DEFAULT_HDR_FTR_ATTRS, HEADER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", VALID_VARIANTS, FOOTNOTES_PART_ID = "word/footnotes.xml", ENDNOTES_PART_ID = "word/endnotes.xml", FOOTNOTES_CONFIG, ENDNOTES_CONFIG, NOTES_XMLNS, footnotesPartDescriptor, endnotesPartDescriptor, storeByEditor, liveSessionsByHost, cacheByHost, hostStoreSyncedKeys, BODY_LOCATOR, findMarkPosition = (doc$2, pos, markName) => {
|
|
132651
|
+
}, INLINE_CONVERTERS_REGISTRY, SHAPE_CONVERTERS_REGISTRY, JUSTIFICATION_TO_ALIGN, DEFAULT_FONT = "Times New Roman", DEFAULT_SIZE2, nodeHandlers, converters, CommentMarkName = "commentMark", LINK_MARK_NAME = "link", COMMENT_MARK_NAME, SUPPORTED_INLINE_TYPES, FALLBACK_PREFIX, UUID_LIKE_PATTERN, ALIAS_ELIGIBLE_TYPES, cacheByEditor, OBJECT_REPLACEMENT_CHAR = "", LINE_NUMBER_RESTART_VALUES, PAGE_NUMBER_FORMAT_VALUES, PAGE_NUMBER_CHAPTER_SEPARATOR_VALUES, SECTION_ORIENTATION_VALUES, SECTION_VERTICAL_ALIGN_VALUES, readSectPrHeaderFooterRefs, PIXELS_PER_INCH = 96, SECTION_PAGE_NUMBER_FORMATS, SETTINGS_PART_PATH = "word/settings.xml", VALID_EDIT_MODES, DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels", RELS_XMLNS = "http://schemas.openxmlformats.org/package/2006/relationships", HEADER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", WORDPROCESSINGML_XMLNS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", OFFICE_DOCUMENT_RELS_XMLNS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", RELATIONSHIP_ID_PATTERN, HEADER_FILE_PATTERN, FOOTER_FILE_PATTERN, SOURCE_HEADER_FOOTER_LOCAL = "header-footer-sync:local", HEADER_PATTERN, FOOTER_PATTERN, DEFAULT_HDR_FTR_ATTRS, HEADER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", VALID_VARIANTS, FOOTNOTES_PART_ID = "word/footnotes.xml", ENDNOTES_PART_ID = "word/endnotes.xml", FOOTNOTES_CONFIG, ENDNOTES_CONFIG, NOTES_XMLNS, footnotesPartDescriptor, endnotesPartDescriptor, storeByEditor, liveSessionsByHost, cacheByHost, hostStoreSyncedKeys, BODY_LOCATOR, findMarkPosition = (doc$2, pos, markName) => {
|
|
131622
132652
|
const $pos = doc$2.resolve(pos);
|
|
131623
132653
|
const parent = $pos.parent;
|
|
131624
132654
|
const start = parent.childAfter($pos.parentOffset);
|
|
@@ -131723,7 +132753,7 @@ var isRegExp = (value) => {
|
|
|
131723
132753
|
state.kern = kernNode.attributes["w:val"];
|
|
131724
132754
|
}
|
|
131725
132755
|
}, SuperConverter;
|
|
131726
|
-
var
|
|
132756
|
+
var init_SuperConverter_D2zNnC50_es = __esm(() => {
|
|
131727
132757
|
init_rolldown_runtime_Bg48TavK_es();
|
|
131728
132758
|
init_jszip_C49i9kUs_es();
|
|
131729
132759
|
init_xml_js_CqGKpaft_es();
|
|
@@ -148190,7 +149220,7 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
148190
149220
|
translator$114
|
|
148191
149221
|
];
|
|
148192
149222
|
translator$116 = NodeTranslator.from(createNestedPropertiesTranslator("w:numPr", "numberingProperties", propertyTranslators$15));
|
|
148193
|
-
translator$121 = NodeTranslator.from(createSingleAttrPropertyHandler("w:outlineLvl", "outlineLvl", "w:val", parseInteger, integerToString));
|
|
149223
|
+
translator$121 = NodeTranslator.from(createSingleAttrPropertyHandler("w:outlineLvl", "outlineLvl", "w:val", parseInteger$1, integerToString));
|
|
148194
149224
|
translator$122 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:overflowPunct"));
|
|
148195
149225
|
translator$49 = NodeTranslator.from(createBorderPropertyHandler("w:bar"));
|
|
148196
149226
|
translator$213 = NodeTranslator.from(createBorderPropertyHandler("w:between"));
|
|
@@ -148497,7 +149527,7 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
148497
149527
|
};
|
|
148498
149528
|
translator$6 = NodeTranslator.from(config$32);
|
|
148499
149529
|
translator$186 = NodeTranslator.from(createMeasurementPropertyHandler("w:tcW", "cellWidth"));
|
|
148500
|
-
translator$73 = NodeTranslator.from(createSingleAttrPropertyHandler("w:gridSpan", null, "w:val", (v) => parseInteger(v) ?? undefined, (v) => integerToString(v)));
|
|
149530
|
+
translator$73 = NodeTranslator.from(createSingleAttrPropertyHandler("w:gridSpan", null, "w:val", (v) => parseInteger$1(v) ?? undefined, (v) => integerToString(v)));
|
|
148501
149531
|
translator$181 = NodeTranslator.from(createSingleAttrPropertyHandler("w:vMerge", null, "w:val", (val) => !val ? "continue" : val));
|
|
148502
149532
|
translator$67 = NodeTranslator.from(createBorderPropertyHandler("w:end"));
|
|
148503
149533
|
translator$206 = NodeTranslator.from(createMeasurementPropertyHandler("w:end", "marginEnd"));
|
|
@@ -148611,8 +149641,8 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
148611
149641
|
encode: ({ nodes }) => ["1", "true"].includes(nodes[0].attributes?.["w:val"] ?? "1"),
|
|
148612
149642
|
decode: ({ node: node3 }) => node3.attrs?.cantSplit ? { attributes: {} } : undefined
|
|
148613
149643
|
});
|
|
148614
|
-
translator$70 = NodeTranslator.from(createSingleAttrPropertyHandler("w:gridAfter", null, "w:val", (v) => parseInteger(v) ?? undefined, (v) => integerToString(v)));
|
|
148615
|
-
translator$71 = NodeTranslator.from(createSingleAttrPropertyHandler("w:gridBefore", null, "w:val", (v) => parseInteger(v) ?? undefined, (v) => integerToString(v)));
|
|
149644
|
+
translator$70 = NodeTranslator.from(createSingleAttrPropertyHandler("w:gridAfter", null, "w:val", (v) => parseInteger$1(v) ?? undefined, (v) => integerToString(v)));
|
|
149645
|
+
translator$71 = NodeTranslator.from(createSingleAttrPropertyHandler("w:gridBefore", null, "w:val", (v) => parseInteger$1(v) ?? undefined, (v) => integerToString(v)));
|
|
148616
149646
|
translator$76 = NodeTranslator.from(createSingleBooleanPropertyHandler("w:hidden"));
|
|
148617
149647
|
translator$159 = NodeTranslator.from(createMeasurementPropertyHandler("w:tblCellSpacing", "tableCellSpacing"));
|
|
148618
149648
|
translator$162 = NodeTranslator.from({
|
|
@@ -160526,9 +161556,11 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
160526
161556
|
["ROMAN", "upperRoman"],
|
|
160527
161557
|
["alphabetic", "lowerLetter"],
|
|
160528
161558
|
["ALPHABETIC", "upperLetter"],
|
|
160529
|
-
["ArabicDash", "numberInDash"]
|
|
161559
|
+
["ArabicDash", "numberInDash"],
|
|
161560
|
+
["Ordinal", "ordinal"]
|
|
160530
161561
|
]);
|
|
160531
161562
|
CASE_INSENSITIVE_GENERAL_FORMATS = new Map([["arabic", "decimal"], ["arabicdash", "numberInDash"]]);
|
|
161563
|
+
TOKEN_PATTERN$1 = /"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|\\[#*]|\\[^\s]+|[^\s]+/g;
|
|
160532
161564
|
TRACK_CHANGE_ELEMENT_NAMES = new Set([
|
|
160533
161565
|
"w:del",
|
|
160534
161566
|
"w:ins",
|
|
@@ -167890,7 +168922,7 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
167890
168922
|
"w:bottomFromText",
|
|
167891
168923
|
"w:tblpX",
|
|
167892
168924
|
"w:tblpY"
|
|
167893
|
-
].map((attr) => createAttributeHandler(attr, null, parseInteger, integerToString)).concat([
|
|
168925
|
+
].map((attr) => createAttributeHandler(attr, null, parseInteger$1, integerToString)).concat([
|
|
167894
168926
|
"w:horzAnchor",
|
|
167895
168927
|
"w:vertAnchor",
|
|
167896
168928
|
"w:tblpXSpec",
|
|
@@ -167963,7 +168995,7 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
167963
168995
|
translator$204 = NodeTranslator.from(createNestedPropertiesTranslator("w:tblStylePr", "tableStyleProperties", propertyTranslators$2, {}, attributeHandlers$1));
|
|
167964
168996
|
DEFAULT_CONTENT_WIDTH_TWIPS = 12240 - 2 * 1440;
|
|
167965
168997
|
MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
167966
|
-
translator$72 = NodeTranslator.from(createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger, integerToString));
|
|
168998
|
+
translator$72 = NodeTranslator.from(createSingleAttrPropertyHandler("w:gridCol", "col", "w:w", parseInteger$1, integerToString));
|
|
167967
168999
|
cellMinWidth = pixelsToTwips(10);
|
|
167968
169000
|
config$25 = {
|
|
167969
169001
|
xmlName: XML_NODE_NAME$25,
|
|
@@ -168199,6 +169231,7 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
168199
169231
|
decode: decode$17
|
|
168200
169232
|
};
|
|
168201
169233
|
translator$22 = NodeTranslator.from(config$14);
|
|
169234
|
+
TOKEN_PATTERN = /"((?:[^"\\]|\\.)*)"|\\[#*](?=\s|$)|\\[^\s]+|[^\s]+/g;
|
|
168202
169235
|
config$13 = {
|
|
168203
169236
|
xmlName: XML_NODE_NAME$12,
|
|
168204
169237
|
sdNodeOrKeyName: SD_NODE_NAME$12,
|
|
@@ -168893,6 +169926,7 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
168893
169926
|
documentStatFieldHandlerEntity = generateV2HandlerEntity("documentStatFieldHandler", translator$30);
|
|
168894
169927
|
pageReferenceEntity = generateV2HandlerEntity("pageReferenceNodeHandler", translator$17);
|
|
168895
169928
|
crossReferenceEntity = generateV2HandlerEntity("crossReferenceNodeHandler", translator$18);
|
|
169929
|
+
sequenceFieldEntity = generateV2HandlerEntity("sequenceFieldNodeHandler", translator$23);
|
|
168896
169930
|
pictNodeHandlerEntity = {
|
|
168897
169931
|
handlerName: "handlePictNode",
|
|
168898
169932
|
handler: handlePictNode
|
|
@@ -169523,6 +170557,14 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
169523
170557
|
"both"
|
|
169524
170558
|
];
|
|
169525
170559
|
readSectPrHeaderFooterRefs = readSectPrRefsByKind;
|
|
170560
|
+
SECTION_PAGE_NUMBER_FORMATS = [
|
|
170561
|
+
"decimal",
|
|
170562
|
+
"lowerLetter",
|
|
170563
|
+
"upperLetter",
|
|
170564
|
+
"lowerRoman",
|
|
170565
|
+
"upperRoman",
|
|
170566
|
+
"numberInDash"
|
|
170567
|
+
];
|
|
169526
170568
|
VALID_EDIT_MODES = new Set([
|
|
169527
170569
|
"readOnly",
|
|
169528
170570
|
"comments",
|
|
@@ -170758,7 +171800,7 @@ var init_SuperConverter_DBsJeu9t_es = __esm(() => {
|
|
|
170758
171800
|
};
|
|
170759
171801
|
});
|
|
170760
171802
|
|
|
170761
|
-
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-
|
|
171803
|
+
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-COmoIa5Q.es.js
|
|
170762
171804
|
function parseSizeUnit(val = "0") {
|
|
170763
171805
|
const length3 = val.toString() || "0";
|
|
170764
171806
|
const value = Number.parseFloat(length3);
|
|
@@ -181091,8 +182133,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
|
|
|
181091
182133
|
}
|
|
181092
182134
|
};
|
|
181093
182135
|
};
|
|
181094
|
-
var
|
|
181095
|
-
|
|
182136
|
+
var init_create_headless_toolbar_COmoIa5Q_es = __esm(() => {
|
|
182137
|
+
init_SuperConverter_D2zNnC50_es();
|
|
181096
182138
|
init_uuid_qzgm05fK_es();
|
|
181097
182139
|
init_constants_D9qj59G2_es();
|
|
181098
182140
|
init_dist_B8HfvhaK_es();
|
|
@@ -230255,7 +231297,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
|
|
|
230255
231297
|
init_remark_gfm_BhnWr3yf_es();
|
|
230256
231298
|
});
|
|
230257
231299
|
|
|
230258
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
231300
|
+
// ../../packages/superdoc/dist/chunks/src-eTZqPcFn.es.js
|
|
230259
231301
|
function deleteProps(obj, propOrProps) {
|
|
230260
231302
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
230261
231303
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -235236,7 +236278,7 @@ function tableStartFromCell($cell) {
|
|
|
235236
236278
|
return $cell.before(d) + 1;
|
|
235237
236279
|
return null;
|
|
235238
236280
|
}
|
|
235239
|
-
function
|
|
236281
|
+
function resolveTable3(tr, tablePos, tableNode) {
|
|
235240
236282
|
if (tableNode && tableNode.type && tableNode.type.name === "table")
|
|
235241
236283
|
return tableNode;
|
|
235242
236284
|
if (typeof tablePos === "number") {
|
|
@@ -236277,8 +237319,10 @@ function createTextElement2(textContent$1, textAlign, width, height, options = {
|
|
|
236277
237319
|
chapterSeparator: pageNumberChapterSeparator
|
|
236278
237320
|
});
|
|
236279
237321
|
}
|
|
236280
|
-
if (part.fieldType === "NUMPAGES")
|
|
236281
|
-
|
|
237322
|
+
if (part.fieldType === "NUMPAGES") {
|
|
237323
|
+
const count2 = totalPages ?? 1;
|
|
237324
|
+
return part.pageNumberFormat ? formatPageNumber(count2, part.pageNumberFormat) : String(count2);
|
|
237325
|
+
}
|
|
236282
237326
|
if (part.fieldType === "SECTIONPAGES") {
|
|
236283
237327
|
if (sectionPageCount == null)
|
|
236284
237328
|
return part.text ?? "1";
|
|
@@ -236494,7 +237538,7 @@ function findAllFields(doc$12) {
|
|
|
236494
237538
|
const counter = blockOccurrenceCounters.get(blockId) ?? 0;
|
|
236495
237539
|
blockOccurrenceCounters.set(blockId, counter + 1);
|
|
236496
237540
|
const fieldType = extractFieldType$1(instruction);
|
|
236497
|
-
const resolvedText = node3.attrs?.resolvedText ?? "";
|
|
237541
|
+
const resolvedText = node3.type.name === "sequenceField" ? node3.attrs?.resolvedNumber ?? "" : node3.attrs?.resolvedText ?? "";
|
|
236498
237542
|
results.push({
|
|
236499
237543
|
pos,
|
|
236500
237544
|
blockId,
|
|
@@ -236579,12 +237623,130 @@ function resolveSectionPageCountFieldValue(editor, node3) {
|
|
|
236579
237623
|
const pageNumberFormat = typeof node3.attrs?.pageNumberFormat === "string" && node3.attrs.pageNumberFormat ? node3.attrs.pageNumberFormat : undefined;
|
|
236580
237624
|
const pageNumberZeroPadding = typeof node3.attrs?.pageNumberZeroPadding === "number" && Number.isFinite(node3.attrs.pageNumberZeroPadding) ? node3.attrs.pageNumberZeroPadding : undefined;
|
|
236581
237625
|
if (pageNumberFormat || pageNumberZeroPadding != null)
|
|
236582
|
-
return formatPageNumberFieldValue
|
|
237626
|
+
return formatPageNumberFieldValue(Number(sectionPageCount) || 1, {
|
|
236583
237627
|
...pageNumberFormat ? { format: pageNumberFormat } : {},
|
|
236584
237628
|
...pageNumberZeroPadding != null ? { zeroPadding: pageNumberZeroPadding } : {}
|
|
236585
237629
|
});
|
|
236586
237630
|
return String(sectionPageCount);
|
|
236587
237631
|
}
|
|
237632
|
+
function updateSequenceFieldsInTransaction(args$1) {
|
|
237633
|
+
const { tr, scope = { kind: "all" }, converterContext } = args$1;
|
|
237634
|
+
const sequenceFieldType = args$1.schema.nodes.sequenceField;
|
|
237635
|
+
if (!sequenceFieldType)
|
|
237636
|
+
return {
|
|
237637
|
+
changed: false,
|
|
237638
|
+
updated: 0
|
|
237639
|
+
};
|
|
237640
|
+
const evaluator = new SequenceFieldEvaluator;
|
|
237641
|
+
let changed = false;
|
|
237642
|
+
let updated = 0;
|
|
237643
|
+
tr.doc.descendants((node3, pos) => {
|
|
237644
|
+
if (node3.type.name === "paragraph") {
|
|
237645
|
+
evaluator.enterParagraph({ paragraphHeadingLevel: resolveNodeHeadingLevel(node3, converterContext) });
|
|
237646
|
+
return true;
|
|
237647
|
+
}
|
|
237648
|
+
if (node3.type !== sequenceFieldType)
|
|
237649
|
+
return true;
|
|
237650
|
+
const nextAttrs = buildEvaluatedSequenceAttrs(node3);
|
|
237651
|
+
const evaluation = evaluator.evaluateField({
|
|
237652
|
+
identifier: nextAttrs.identifier,
|
|
237653
|
+
instruction: nextAttrs.instruction,
|
|
237654
|
+
fieldArgument: nextAttrs.fieldArgument,
|
|
237655
|
+
sequenceMode: nextAttrs.sequenceMode,
|
|
237656
|
+
hideResult: nextAttrs.hideResult,
|
|
237657
|
+
restartNumber: nextAttrs.restartNumber,
|
|
237658
|
+
restartLevel: nextAttrs.restartLevel,
|
|
237659
|
+
format: nextAttrs.format,
|
|
237660
|
+
hasGeneralFormat: nextAttrs.hasGeneralFormat,
|
|
237661
|
+
pageNumberFieldFormat: nextAttrs.pageNumberFieldFormat,
|
|
237662
|
+
numericPictureFormat: nextAttrs.numericPictureFormat,
|
|
237663
|
+
cachedText: typeof node3.attrs.resolvedNumber === "string" ? node3.attrs.resolvedNumber : ""
|
|
237664
|
+
});
|
|
237665
|
+
if (!shouldWriteSequenceField(node3, pos, scope, nextAttrs.identifier))
|
|
237666
|
+
return true;
|
|
237667
|
+
nextAttrs.resolvedNumber = evaluation.text;
|
|
237668
|
+
nextAttrs.resolvedNumberIsCurrent = true;
|
|
237669
|
+
if (!attrsEqual(node3.attrs, nextAttrs)) {
|
|
237670
|
+
tr.setNodeMarkup(resolveCurrentTransactionPos(tr, pos, node3), undefined, nextAttrs);
|
|
237671
|
+
changed = true;
|
|
237672
|
+
}
|
|
237673
|
+
updated += 1;
|
|
237674
|
+
return true;
|
|
237675
|
+
});
|
|
237676
|
+
return {
|
|
237677
|
+
changed,
|
|
237678
|
+
updated
|
|
237679
|
+
};
|
|
237680
|
+
}
|
|
237681
|
+
function getSequenceFieldUpdaterConverterContext(editor) {
|
|
237682
|
+
const converter = editor?.converter;
|
|
237683
|
+
if (!converter?.translatedLinkedStyles)
|
|
237684
|
+
return;
|
|
237685
|
+
return {
|
|
237686
|
+
translatedLinkedStyles: converter.translatedLinkedStyles,
|
|
237687
|
+
translatedNumbering: converter.translatedNumbering ?? {},
|
|
237688
|
+
docx: converter.docx
|
|
237689
|
+
};
|
|
237690
|
+
}
|
|
237691
|
+
function resolveNodeHeadingLevel(node3, converterContext) {
|
|
237692
|
+
const paragraphProperties = node3.attrs?.paragraphProperties;
|
|
237693
|
+
if (converterContext)
|
|
237694
|
+
return resolveParagraphHeadingLevel(isRecord$3(paragraphProperties) ? paragraphProperties : undefined, converterContext);
|
|
237695
|
+
}
|
|
237696
|
+
function buildEvaluatedSequenceAttrs(node3) {
|
|
237697
|
+
const instruction = typeof node3.attrs.instruction === "string" ? node3.attrs.instruction : "";
|
|
237698
|
+
const parsedAttrs = sequenceFieldAttrsFromParsed(parseSeqInstruction(instruction));
|
|
237699
|
+
return {
|
|
237700
|
+
...node3.attrs,
|
|
237701
|
+
instruction,
|
|
237702
|
+
...parsedAttrs,
|
|
237703
|
+
identifier: parsedAttrs.identifier || readStringAttr2(node3, "identifier")
|
|
237704
|
+
};
|
|
237705
|
+
}
|
|
237706
|
+
function shouldWriteSequenceField(node3, pos, scope, identifier) {
|
|
237707
|
+
if (scope.kind === "all")
|
|
237708
|
+
return true;
|
|
237709
|
+
if (scope.kind === "range") {
|
|
237710
|
+
const end$1 = pos + node3.nodeSize;
|
|
237711
|
+
return pos < scope.to && end$1 > scope.from;
|
|
237712
|
+
}
|
|
237713
|
+
return normalizeSeqIdentifier(identifier) === normalizeSeqIdentifier(scope.identifier);
|
|
237714
|
+
}
|
|
237715
|
+
function readStringAttr2(node3, key2) {
|
|
237716
|
+
const value = node3.attrs?.[key2];
|
|
237717
|
+
return typeof value === "string" ? value : "";
|
|
237718
|
+
}
|
|
237719
|
+
function attrsEqual(left$1, right$1) {
|
|
237720
|
+
const keys$1 = new Set([...Object.keys(left$1), ...Object.keys(right$1)]);
|
|
237721
|
+
for (const key2 of keys$1)
|
|
237722
|
+
if (!valuesEqual(left$1[key2], right$1[key2]))
|
|
237723
|
+
return false;
|
|
237724
|
+
return true;
|
|
237725
|
+
}
|
|
237726
|
+
function valuesEqual(left$1, right$1) {
|
|
237727
|
+
if (Object.is(left$1, right$1))
|
|
237728
|
+
return true;
|
|
237729
|
+
if (!isRecord$3(left$1) || !isRecord$3(right$1))
|
|
237730
|
+
return false;
|
|
237731
|
+
const keys$1 = new Set([...Object.keys(left$1), ...Object.keys(right$1)]);
|
|
237732
|
+
for (const key2 of keys$1)
|
|
237733
|
+
if (!valuesEqual(left$1[key2], right$1[key2]))
|
|
237734
|
+
return false;
|
|
237735
|
+
return true;
|
|
237736
|
+
}
|
|
237737
|
+
function resolveCurrentTransactionPos(tr, pos, node3) {
|
|
237738
|
+
if (tr.doc.nodeAt(pos)?.type === node3.type)
|
|
237739
|
+
return pos;
|
|
237740
|
+
return tr.mapping.map(pos);
|
|
237741
|
+
}
|
|
237742
|
+
function isRecord$3(value) {
|
|
237743
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
237744
|
+
}
|
|
237745
|
+
function resolveTotalPageNumberFieldValue(stats, node3) {
|
|
237746
|
+
if (stats.pages == null)
|
|
237747
|
+
return null;
|
|
237748
|
+
return formatPageNumberFieldValue(stats.pages, getPageNumberFieldFormat(node3.attrs));
|
|
237749
|
+
}
|
|
236588
237750
|
function createCascadeToggleCommands({ markName, setCommand, unsetCommand, toggleCommand, negationAttrs, isNegation, extendEmptyMarkRange } = {}) {
|
|
236589
237751
|
if (!markName)
|
|
236590
237752
|
throw new Error("createCascadeToggleCommands requires a markName");
|
|
@@ -266119,7 +267281,7 @@ function isCaptionParagraph(node3) {
|
|
|
266119
267281
|
const seqField = findSeqField(node3);
|
|
266120
267282
|
if (!seqField)
|
|
266121
267283
|
return false;
|
|
266122
|
-
return (seqField.attrs?.instruction ?? "")
|
|
267284
|
+
return isSeqInstruction(seqField.attrs?.instruction ?? "");
|
|
266123
267285
|
}
|
|
266124
267286
|
function findSeqField(node3) {
|
|
266125
267287
|
let seqNode = null;
|
|
@@ -266271,14 +267433,17 @@ function captionsInsertWrapper(editor, input2, options) {
|
|
|
266271
267433
|
const children = [];
|
|
266272
267434
|
const schema = editor.schema;
|
|
266273
267435
|
children.push(schema.text(`${label} `));
|
|
266274
|
-
if (schema.nodes.sequenceField)
|
|
267436
|
+
if (schema.nodes.sequenceField) {
|
|
267437
|
+
const instruction = `SEQ ${label} \\* ARABIC`;
|
|
267438
|
+
const parsed = parseSeqInstruction(instruction);
|
|
266275
267439
|
children.push(schema.nodes.sequenceField.create({
|
|
266276
|
-
instruction
|
|
266277
|
-
|
|
266278
|
-
format: "ARABIC",
|
|
267440
|
+
instruction,
|
|
267441
|
+
...sequenceFieldAttrsFromParsed(parsed),
|
|
266279
267442
|
resolvedNumber: "",
|
|
267443
|
+
resolvedNumberIsCurrent: false,
|
|
266280
267444
|
sdBlockId: `seq-${Date.now()}`
|
|
266281
267445
|
}));
|
|
267446
|
+
}
|
|
266282
267447
|
if (input2.text) {
|
|
266283
267448
|
const captionContent = buildTextWithTabs(schema, `: ${input2.text}`, undefined);
|
|
266284
267449
|
if (captionContent instanceof Fragment)
|
|
@@ -266289,6 +267454,15 @@ function captionsInsertWrapper(editor, input2, options) {
|
|
|
266289
267454
|
const captionParagraph = schema.nodes.paragraph.create(buildCaptionParagraphAttrs(nodeId), children);
|
|
266290
267455
|
const { tr } = editor.state;
|
|
266291
267456
|
tr.insert(pos, captionParagraph);
|
|
267457
|
+
updateSequenceFieldsInTransaction({
|
|
267458
|
+
tr,
|
|
267459
|
+
schema,
|
|
267460
|
+
scope: {
|
|
267461
|
+
kind: "identifier",
|
|
267462
|
+
identifier: label
|
|
267463
|
+
},
|
|
267464
|
+
converterContext: getSequenceFieldUpdaterConverterContext(editor)
|
|
267465
|
+
});
|
|
266292
267466
|
editor.dispatch(tr);
|
|
266293
267467
|
clearIndexCache(editor);
|
|
266294
267468
|
return true;
|
|
@@ -266365,18 +267539,29 @@ function captionsConfigureWrapper(editor, input2, options) {
|
|
|
266365
267539
|
return true;
|
|
266366
267540
|
const format = CAPTION_FORMAT_TO_OOXML[input2.format ?? "decimal"] ?? "ARABIC";
|
|
266367
267541
|
const newInstruction = `SEQ ${input2.label} \\* ${format}`;
|
|
266368
|
-
|
|
267542
|
+
const parsedAttrs = sequenceFieldAttrsFromParsed(parseSeqInstruction(newInstruction));
|
|
267543
|
+
if (node3.attrs.instruction === newInstruction && node3.attrs.format === format && JSON.stringify(node3.attrs.pageNumberFieldFormat) === JSON.stringify(parsedAttrs.pageNumberFieldFormat))
|
|
266369
267544
|
return true;
|
|
266370
267545
|
tr.setNodeMarkup(tr.mapping.map(pos), undefined, {
|
|
266371
267546
|
...node3.attrs,
|
|
266372
267547
|
instruction: newInstruction,
|
|
266373
|
-
|
|
267548
|
+
...parsedAttrs,
|
|
267549
|
+
resolvedNumberIsCurrent: false
|
|
266374
267550
|
});
|
|
266375
267551
|
changed = true;
|
|
266376
267552
|
return true;
|
|
266377
267553
|
});
|
|
266378
267554
|
if (!changed)
|
|
266379
267555
|
return false;
|
|
267556
|
+
updateSequenceFieldsInTransaction({
|
|
267557
|
+
tr,
|
|
267558
|
+
schema: editor.schema,
|
|
267559
|
+
scope: {
|
|
267560
|
+
kind: "identifier",
|
|
267561
|
+
identifier: input2.label
|
|
267562
|
+
},
|
|
267563
|
+
converterContext: getSequenceFieldUpdaterConverterContext(editor)
|
|
267564
|
+
});
|
|
266380
267565
|
editor.dispatch(tr);
|
|
266381
267566
|
clearIndexCache(editor);
|
|
266382
267567
|
return true;
|
|
@@ -266437,7 +267622,7 @@ function fieldsInsertWrapper(editor, input2, options) {
|
|
|
266437
267622
|
if (DOCUMENT_STAT_FIELD_TYPES.has(fieldType))
|
|
266438
267623
|
return insertDocumentStatField(editor, input2, resolved, options);
|
|
266439
267624
|
if (fieldType === "NUMPAGES")
|
|
266440
|
-
return insertNumPagesField(editor, resolved, options);
|
|
267625
|
+
return insertNumPagesField(editor, input2, resolved, options);
|
|
266441
267626
|
if (fieldType === "SECTIONPAGES")
|
|
266442
267627
|
return insertSectionPagesField(editor, input2, resolved, options);
|
|
266443
267628
|
return insertRawField(editor, input2, resolved, options);
|
|
@@ -266463,14 +267648,15 @@ function insertDocumentStatField(editor, input2, resolved, options) {
|
|
|
266463
267648
|
return fieldFailure("NO_OP", "Insert produced no change.");
|
|
266464
267649
|
return fieldSuccess(computeFieldAddress(editor.state.doc, resolved.from));
|
|
266465
267650
|
}
|
|
266466
|
-
function insertNumPagesField(editor, resolved, options) {
|
|
267651
|
+
function insertNumPagesField(editor, input2, resolved, options) {
|
|
266467
267652
|
if (!Boolean(editor.options?.isHeaderOrFooter))
|
|
266468
267653
|
return fieldFailure("INVALID_INPUT", "fields.insert: NUMPAGES insertion is only supported in headers/footers.");
|
|
266469
267654
|
const nodeType = editor.schema.nodes["total-page-number"];
|
|
266470
267655
|
if (!nodeType)
|
|
266471
267656
|
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "fields.insert: total-page-number node type not in schema.");
|
|
267657
|
+
const parsedInstruction = parsePageNumberFieldSwitches(input2.instruction, "NUMPAGES");
|
|
266472
267658
|
if (!receiptApplied$2(executeDomainCommand(editor, () => {
|
|
266473
|
-
const node3 = nodeType.create(
|
|
267659
|
+
const node3 = nodeType.create(parsedInstruction);
|
|
266474
267660
|
const { tr } = editor.state;
|
|
266475
267661
|
tr.insert(resolved.from, node3);
|
|
266476
267662
|
editor.dispatch(tr);
|
|
@@ -266513,7 +267699,14 @@ function insertRawField(editor, input2, resolved, options) {
|
|
|
266513
267699
|
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "fields.insert: sequenceField node type not in schema.");
|
|
266514
267700
|
if (!receiptApplied$2(executeDomainCommand(editor, () => {
|
|
266515
267701
|
const fieldType = extractFieldType(input2.instruction);
|
|
266516
|
-
const
|
|
267702
|
+
const parsed = isSeqInstruction(input2.instruction) ? parseSeqInstruction(input2.instruction) : null;
|
|
267703
|
+
const node3 = fieldNodeType.create(parsed ? {
|
|
267704
|
+
instruction: input2.instruction,
|
|
267705
|
+
...sequenceFieldAttrsFromParsed(parsed),
|
|
267706
|
+
resolvedNumber: "",
|
|
267707
|
+
resolvedNumberIsCurrent: false,
|
|
267708
|
+
sdBlockId: `field-${Date.now()}`
|
|
267709
|
+
} : {
|
|
266517
267710
|
instruction: input2.instruction,
|
|
266518
267711
|
identifier: fieldType,
|
|
266519
267712
|
format: "ARABIC",
|
|
@@ -266522,6 +267715,16 @@ function insertRawField(editor, input2, resolved, options) {
|
|
|
266522
267715
|
});
|
|
266523
267716
|
const { tr } = editor.state;
|
|
266524
267717
|
tr.insert(resolved.from, node3);
|
|
267718
|
+
if (parsed)
|
|
267719
|
+
updateSequenceFieldsInTransaction({
|
|
267720
|
+
tr,
|
|
267721
|
+
schema: editor.schema,
|
|
267722
|
+
scope: {
|
|
267723
|
+
kind: "identifier",
|
|
267724
|
+
identifier: parsed.identifier
|
|
267725
|
+
},
|
|
267726
|
+
converterContext: getSequenceFieldUpdaterConverterContext(editor)
|
|
267727
|
+
});
|
|
266525
267728
|
editor.dispatch(tr);
|
|
266526
267729
|
clearIndexCache(editor);
|
|
266527
267730
|
return true;
|
|
@@ -266549,6 +267752,8 @@ function fieldsRebuildWrapper(editor, input2, options) {
|
|
|
266549
267752
|
return rebuildTotalPageNumber(editor, resolved, address2, options);
|
|
266550
267753
|
if (node3.type.name === "section-page-count")
|
|
266551
267754
|
return rebuildSectionPageCount(editor, resolved, address2, options);
|
|
267755
|
+
if (node3.type.name === "sequenceField" && isSeqInstruction(node3.attrs?.instruction ?? ""))
|
|
267756
|
+
return rebuildSequenceFields(editor, address2, options);
|
|
266552
267757
|
if (!receiptApplied$2(executeDomainCommand(editor, () => {
|
|
266553
267758
|
const { tr } = editor.state;
|
|
266554
267759
|
const currentNode = tr.doc.nodeAt(resolved.pos);
|
|
@@ -266565,6 +267770,22 @@ function fieldsRebuildWrapper(editor, input2, options) {
|
|
|
266565
267770
|
return fieldFailure("NO_OP", "Rebuild produced no change.");
|
|
266566
267771
|
return fieldSuccess(address2);
|
|
266567
267772
|
}
|
|
267773
|
+
function rebuildSequenceFields(editor, address2, options) {
|
|
267774
|
+
executeDomainCommand(editor, () => {
|
|
267775
|
+
const { tr } = editor.state;
|
|
267776
|
+
if (updateSequenceFieldsInTransaction({
|
|
267777
|
+
tr,
|
|
267778
|
+
schema: editor.schema,
|
|
267779
|
+
scope: { kind: "all" },
|
|
267780
|
+
converterContext: getSequenceFieldUpdaterConverterContext(editor)
|
|
267781
|
+
}).changed) {
|
|
267782
|
+
editor.dispatch(tr);
|
|
267783
|
+
clearIndexCache(editor);
|
|
267784
|
+
}
|
|
267785
|
+
return true;
|
|
267786
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
267787
|
+
return fieldSuccess(address2);
|
|
267788
|
+
}
|
|
266568
267789
|
function rebuildDocumentStatField(editor, resolved, address2, options) {
|
|
266569
267790
|
const stats = getWordStatistics(resolveMainBodyEditor(editor));
|
|
266570
267791
|
const node3 = editor.state.doc.nodeAt(resolved.pos);
|
|
@@ -266591,7 +267812,10 @@ function rebuildTotalPageNumber(editor, resolved, address2, options) {
|
|
|
266591
267812
|
const stats = getWordStatistics(resolveMainBodyEditor(editor));
|
|
266592
267813
|
if (stats.pages == null)
|
|
266593
267814
|
return fieldSuccess(address2);
|
|
266594
|
-
const
|
|
267815
|
+
const node3 = editor.state.doc.nodeAt(resolved.pos);
|
|
267816
|
+
if (!node3)
|
|
267817
|
+
return fieldFailure("TARGET_NOT_FOUND", "Node not found.");
|
|
267818
|
+
const freshValue = formatPageNumberFieldValue(stats.pages, getPageNumberFieldFormat(node3.attrs));
|
|
266595
267819
|
if (!receiptApplied$2(executeDomainCommand(editor, () => {
|
|
266596
267820
|
const { tr } = editor.state;
|
|
266597
267821
|
const currentNode = tr.doc.nodeAt(resolved.pos);
|
|
@@ -271874,6 +273098,30 @@ function resolveDrawingItem(fragment2, fragmentIndex, pageIndex, blockMap) {
|
|
|
271874
273098
|
item.pmEnd = fragment2.pmEnd;
|
|
271875
273099
|
return item;
|
|
271876
273100
|
}
|
|
273101
|
+
function resolvePageRefText(args$1) {
|
|
273102
|
+
const formattedTargetPageText = formatTargetPageText(args$1.target, args$1.metadata);
|
|
273103
|
+
if (!args$1.metadata.relativePosition)
|
|
273104
|
+
return formattedTargetPageText;
|
|
273105
|
+
if (args$1.sourcePage !== args$1.target.physicalPage)
|
|
273106
|
+
return `on page ${formattedTargetPageText}`;
|
|
273107
|
+
return args$1.target.pmPosition != null && args$1.sourcePmPosition != null && args$1.target.pmPosition < args$1.sourcePmPosition ? "above" : "below";
|
|
273108
|
+
}
|
|
273109
|
+
function formatTargetPageText(target, metadata) {
|
|
273110
|
+
const displayNumber = Math.max(1, Math.trunc(Number.isFinite(target.displayNumber) ? target.displayNumber : 1));
|
|
273111
|
+
if (metadata.numericPictureFormat)
|
|
273112
|
+
return formatChapterPageNumberText({
|
|
273113
|
+
pageComponent: formatIntegerWithNumericPicture(displayNumber, metadata.numericPictureFormat.picture),
|
|
273114
|
+
chapterNumberText: target.chapterNumberText,
|
|
273115
|
+
chapterSeparator: target.chapterSeparator
|
|
273116
|
+
});
|
|
273117
|
+
if (metadata.pageNumberFieldFormat)
|
|
273118
|
+
return formatChapterPageNumberText({
|
|
273119
|
+
pageComponent: formatPageNumberFieldValue(displayNumber, metadata.pageNumberFieldFormat),
|
|
273120
|
+
chapterNumberText: target.chapterNumberText,
|
|
273121
|
+
chapterSeparator: target.chapterSeparator
|
|
273122
|
+
});
|
|
273123
|
+
return target.displayText;
|
|
273124
|
+
}
|
|
271877
273125
|
function buildBlockMap(blocks2, measures) {
|
|
271878
273126
|
const map$12 = /* @__PURE__ */ new Map;
|
|
271879
273127
|
for (let i4 = 0;i4 < blocks2.length; i4++)
|
|
@@ -271883,6 +273131,257 @@ function buildBlockMap(blocks2, measures) {
|
|
|
271883
273131
|
});
|
|
271884
273132
|
return map$12;
|
|
271885
273133
|
}
|
|
273134
|
+
function resolveParagraphPageRefs(fragment2, block, measure, context) {
|
|
273135
|
+
const runTexts = collectResolvedPageRefRunTexts(block, context);
|
|
273136
|
+
if (runTexts.size === 0)
|
|
273137
|
+
return {
|
|
273138
|
+
block,
|
|
273139
|
+
fragment: fragment2,
|
|
273140
|
+
changed: false
|
|
273141
|
+
};
|
|
273142
|
+
const nextRuns = resolvePageRefRuns(block, runTexts);
|
|
273143
|
+
const nextLines = (fragment2.lines ?? measure.lines.slice(fragment2.fromLine, fragment2.toLine)).map((line) => adjustLineForResolvedPageRefs(line, runTexts));
|
|
273144
|
+
return {
|
|
273145
|
+
block: {
|
|
273146
|
+
...block,
|
|
273147
|
+
runs: nextRuns
|
|
273148
|
+
},
|
|
273149
|
+
fragment: {
|
|
273150
|
+
...fragment2,
|
|
273151
|
+
lines: nextLines
|
|
273152
|
+
},
|
|
273153
|
+
changed: true
|
|
273154
|
+
};
|
|
273155
|
+
}
|
|
273156
|
+
function resolveParagraphPageRefBlock(block, measure, context) {
|
|
273157
|
+
const runTexts = collectResolvedPageRefRunTexts(block, context);
|
|
273158
|
+
if (runTexts.size === 0)
|
|
273159
|
+
return {
|
|
273160
|
+
block,
|
|
273161
|
+
changed: false
|
|
273162
|
+
};
|
|
273163
|
+
return {
|
|
273164
|
+
block: {
|
|
273165
|
+
...block,
|
|
273166
|
+
runs: resolvePageRefRuns(block, runTexts)
|
|
273167
|
+
},
|
|
273168
|
+
measure: measure ? {
|
|
273169
|
+
...measure,
|
|
273170
|
+
lines: measure.lines.map((line) => adjustLineForResolvedPageRefs(line, runTexts))
|
|
273171
|
+
} : undefined,
|
|
273172
|
+
changed: true
|
|
273173
|
+
};
|
|
273174
|
+
}
|
|
273175
|
+
function collectResolvedPageRefRunTexts(block, context) {
|
|
273176
|
+
const runTexts = /* @__PURE__ */ new Map;
|
|
273177
|
+
if (!context?.anchorMap?.size)
|
|
273178
|
+
return runTexts;
|
|
273179
|
+
block.runs.forEach((run2, index2) => {
|
|
273180
|
+
if (!isPageReferenceTextRun(run2))
|
|
273181
|
+
return;
|
|
273182
|
+
const target = context.anchorMap?.get(run2.pageRefMetadata.bookmarkId);
|
|
273183
|
+
if (!target)
|
|
273184
|
+
return;
|
|
273185
|
+
const resolvedText = resolvePageRefText({
|
|
273186
|
+
sourcePage: context.sourcePage,
|
|
273187
|
+
sourcePmPosition: run2.pmStart,
|
|
273188
|
+
target,
|
|
273189
|
+
metadata: run2.pageRefMetadata
|
|
273190
|
+
});
|
|
273191
|
+
if (resolvedText !== run2.text)
|
|
273192
|
+
runTexts.set(index2, {
|
|
273193
|
+
text: resolvedText,
|
|
273194
|
+
originalLength: run2.text.length
|
|
273195
|
+
});
|
|
273196
|
+
});
|
|
273197
|
+
return runTexts;
|
|
273198
|
+
}
|
|
273199
|
+
function resolvePageRefRuns(block, runTexts) {
|
|
273200
|
+
return block.runs.map((run2, index2) => runTexts.has(index2) && isTextRun$5(run2) ? {
|
|
273201
|
+
...run2,
|
|
273202
|
+
text: runTexts.get(index2).text
|
|
273203
|
+
} : run2);
|
|
273204
|
+
}
|
|
273205
|
+
function resolveTablePageRefs(block, measure, context) {
|
|
273206
|
+
if (!context?.anchorMap?.size)
|
|
273207
|
+
return {
|
|
273208
|
+
block,
|
|
273209
|
+
changed: false
|
|
273210
|
+
};
|
|
273211
|
+
let changed = false;
|
|
273212
|
+
let measureChanged = false;
|
|
273213
|
+
const measureRows = measure?.rows.slice();
|
|
273214
|
+
const rows = block.rows.map((row2, rowIndex) => {
|
|
273215
|
+
let rowChanged = false;
|
|
273216
|
+
const measureRow = measureRows?.[rowIndex];
|
|
273217
|
+
const measureCells = measureRow?.cells.slice();
|
|
273218
|
+
const cells = row2.cells.map((cell2, cellIndex) => {
|
|
273219
|
+
let cellChanged = false;
|
|
273220
|
+
let nextParagraph = cell2.paragraph;
|
|
273221
|
+
let nextCellMeasure = measureCells?.[cellIndex];
|
|
273222
|
+
if (cell2.paragraph) {
|
|
273223
|
+
const resolved = resolveParagraphPageRefBlock(cell2.paragraph, nextCellMeasure?.paragraph, context);
|
|
273224
|
+
nextParagraph = resolved.block;
|
|
273225
|
+
if (resolved.measure && nextCellMeasure)
|
|
273226
|
+
nextCellMeasure = {
|
|
273227
|
+
...nextCellMeasure,
|
|
273228
|
+
paragraph: resolved.measure
|
|
273229
|
+
};
|
|
273230
|
+
cellChanged ||= resolved.changed;
|
|
273231
|
+
}
|
|
273232
|
+
let nextBlocks = cell2.blocks;
|
|
273233
|
+
let nextBlockMeasures = nextCellMeasure?.blocks;
|
|
273234
|
+
if (cell2.blocks)
|
|
273235
|
+
nextBlocks = cell2.blocks.map((childBlock, childIndex) => {
|
|
273236
|
+
const childMeasure = nextBlockMeasures?.[childIndex];
|
|
273237
|
+
if (childBlock.kind === "paragraph") {
|
|
273238
|
+
const resolved = resolveParagraphPageRefBlock(childBlock, childMeasure?.kind === "paragraph" ? childMeasure : undefined, context);
|
|
273239
|
+
if (resolved.measure && nextBlockMeasures) {
|
|
273240
|
+
nextBlockMeasures = nextBlockMeasures.slice();
|
|
273241
|
+
nextBlockMeasures[childIndex] = resolved.measure;
|
|
273242
|
+
}
|
|
273243
|
+
cellChanged ||= resolved.changed;
|
|
273244
|
+
return resolved.block;
|
|
273245
|
+
}
|
|
273246
|
+
if (childBlock.kind === "table") {
|
|
273247
|
+
const resolved = resolveTablePageRefs(childBlock, childMeasure?.kind === "table" ? childMeasure : undefined, context);
|
|
273248
|
+
if (resolved.measure && nextBlockMeasures) {
|
|
273249
|
+
nextBlockMeasures = nextBlockMeasures.slice();
|
|
273250
|
+
nextBlockMeasures[childIndex] = resolved.measure;
|
|
273251
|
+
}
|
|
273252
|
+
cellChanged ||= resolved.changed;
|
|
273253
|
+
return resolved.block;
|
|
273254
|
+
}
|
|
273255
|
+
return childBlock;
|
|
273256
|
+
});
|
|
273257
|
+
if (!cellChanged)
|
|
273258
|
+
return cell2;
|
|
273259
|
+
rowChanged = true;
|
|
273260
|
+
if (nextCellMeasure && measureCells) {
|
|
273261
|
+
if (nextBlockMeasures && nextBlockMeasures !== nextCellMeasure.blocks)
|
|
273262
|
+
nextCellMeasure = {
|
|
273263
|
+
...nextCellMeasure,
|
|
273264
|
+
blocks: nextBlockMeasures
|
|
273265
|
+
};
|
|
273266
|
+
measureCells[cellIndex] = nextCellMeasure;
|
|
273267
|
+
measureChanged = true;
|
|
273268
|
+
}
|
|
273269
|
+
return {
|
|
273270
|
+
...cell2,
|
|
273271
|
+
...nextParagraph ? { paragraph: nextParagraph } : {},
|
|
273272
|
+
...nextBlocks ? { blocks: nextBlocks } : {}
|
|
273273
|
+
};
|
|
273274
|
+
});
|
|
273275
|
+
if (!rowChanged)
|
|
273276
|
+
return row2;
|
|
273277
|
+
changed = true;
|
|
273278
|
+
if (measureRow && measureCells && measureCells !== measureRow.cells)
|
|
273279
|
+
measureRows[rowIndex] = {
|
|
273280
|
+
...measureRow,
|
|
273281
|
+
cells: measureCells
|
|
273282
|
+
};
|
|
273283
|
+
return {
|
|
273284
|
+
...row2,
|
|
273285
|
+
cells
|
|
273286
|
+
};
|
|
273287
|
+
});
|
|
273288
|
+
return changed ? {
|
|
273289
|
+
block: {
|
|
273290
|
+
...block,
|
|
273291
|
+
rows
|
|
273292
|
+
},
|
|
273293
|
+
measure: measure && measureChanged && measureRows ? {
|
|
273294
|
+
...measure,
|
|
273295
|
+
rows: measureRows
|
|
273296
|
+
} : measure,
|
|
273297
|
+
changed: true
|
|
273298
|
+
} : {
|
|
273299
|
+
block,
|
|
273300
|
+
changed: false
|
|
273301
|
+
};
|
|
273302
|
+
}
|
|
273303
|
+
function resolveListItemPageRefs(block, itemId, measure, context) {
|
|
273304
|
+
if (!context?.anchorMap?.size)
|
|
273305
|
+
return {
|
|
273306
|
+
block,
|
|
273307
|
+
changed: false
|
|
273308
|
+
};
|
|
273309
|
+
let changed = false;
|
|
273310
|
+
let measureChanged = false;
|
|
273311
|
+
const measureItems = measure?.items.slice();
|
|
273312
|
+
const items = block.items.map((item) => {
|
|
273313
|
+
if (item.id !== itemId)
|
|
273314
|
+
return item;
|
|
273315
|
+
const itemMeasureIndex = measureItems?.findIndex((candidate) => candidate.itemId === itemId) ?? -1;
|
|
273316
|
+
const itemMeasure = itemMeasureIndex >= 0 ? measureItems?.[itemMeasureIndex] : undefined;
|
|
273317
|
+
const resolved = resolveParagraphPageRefBlock(item.paragraph, itemMeasure?.paragraph, context);
|
|
273318
|
+
if (!resolved.changed)
|
|
273319
|
+
return item;
|
|
273320
|
+
if (resolved.measure && itemMeasure && measureItems) {
|
|
273321
|
+
measureItems[itemMeasureIndex] = {
|
|
273322
|
+
...itemMeasure,
|
|
273323
|
+
paragraph: resolved.measure
|
|
273324
|
+
};
|
|
273325
|
+
measureChanged = true;
|
|
273326
|
+
}
|
|
273327
|
+
changed = true;
|
|
273328
|
+
return {
|
|
273329
|
+
...item,
|
|
273330
|
+
paragraph: resolved.block
|
|
273331
|
+
};
|
|
273332
|
+
});
|
|
273333
|
+
return changed ? {
|
|
273334
|
+
block: {
|
|
273335
|
+
...block,
|
|
273336
|
+
items
|
|
273337
|
+
},
|
|
273338
|
+
measure: measure && measureChanged && measureItems ? {
|
|
273339
|
+
...measure,
|
|
273340
|
+
items: measureItems
|
|
273341
|
+
} : measure,
|
|
273342
|
+
changed: true
|
|
273343
|
+
} : {
|
|
273344
|
+
block,
|
|
273345
|
+
changed: false
|
|
273346
|
+
};
|
|
273347
|
+
}
|
|
273348
|
+
function isTextRun$5(run2) {
|
|
273349
|
+
return (run2.kind === "text" || run2.kind === undefined) && "text" in run2;
|
|
273350
|
+
}
|
|
273351
|
+
function isPageReferenceTextRun(run2) {
|
|
273352
|
+
return isTextRun$5(run2) && run2.token === "pageReference" && run2.pageRefMetadata != null;
|
|
273353
|
+
}
|
|
273354
|
+
function adjustLineForResolvedPageRefs(line, runTexts) {
|
|
273355
|
+
let changed = false;
|
|
273356
|
+
const nextLine = { ...line };
|
|
273357
|
+
for (const [runIndex, resolved] of runTexts) {
|
|
273358
|
+
if (runIndex < line.fromRun || runIndex > line.toRun)
|
|
273359
|
+
continue;
|
|
273360
|
+
changed = true;
|
|
273361
|
+
if (line.fromRun === runIndex)
|
|
273362
|
+
nextLine.fromChar = clampResolvedRunBoundary(line.fromChar, resolved);
|
|
273363
|
+
if (line.toRun === runIndex)
|
|
273364
|
+
nextLine.toChar = clampResolvedRunBoundary(line.toChar, resolved);
|
|
273365
|
+
}
|
|
273366
|
+
if (line.segments?.length)
|
|
273367
|
+
nextLine.segments = line.segments.map((segment) => {
|
|
273368
|
+
const resolved = runTexts.get(segment.runIndex);
|
|
273369
|
+
if (resolved == null)
|
|
273370
|
+
return segment;
|
|
273371
|
+
changed = true;
|
|
273372
|
+
return {
|
|
273373
|
+
...segment,
|
|
273374
|
+
fromChar: clampResolvedRunBoundary(segment.fromChar, resolved),
|
|
273375
|
+
toChar: clampResolvedRunBoundary(segment.toChar, resolved)
|
|
273376
|
+
};
|
|
273377
|
+
});
|
|
273378
|
+
return changed ? nextLine : line;
|
|
273379
|
+
}
|
|
273380
|
+
function clampResolvedRunBoundary(offset$1, resolved) {
|
|
273381
|
+
if (offset$1 === resolved.originalLength)
|
|
273382
|
+
return resolved.text.length;
|
|
273383
|
+
return Math.min(offset$1, resolved.text.length);
|
|
273384
|
+
}
|
|
271886
273385
|
function sumLineHeights$2(lines, from$1, to) {
|
|
271887
273386
|
let total = 0;
|
|
271888
273387
|
for (let i4 = from$1;i4 < to && i4 < lines.length; i4++)
|
|
@@ -271937,13 +273436,16 @@ function resolveFragmentId(fragment2) {
|
|
|
271937
273436
|
}
|
|
271938
273437
|
}
|
|
271939
273438
|
}
|
|
271940
|
-
function resolveParagraphContentIfApplicable(fragment2, blockMap) {
|
|
273439
|
+
function resolveParagraphContentIfApplicable(fragment2, blockMap, pageRefContext) {
|
|
271941
273440
|
if (fragment2.kind !== "para")
|
|
271942
273441
|
return;
|
|
271943
273442
|
const entry = blockMap.get(fragment2.blockId);
|
|
271944
273443
|
if (!entry || entry.block.kind !== "paragraph" || entry.measure.kind !== "paragraph")
|
|
271945
273444
|
return;
|
|
271946
|
-
|
|
273445
|
+
const paragraphBlock = entry.block;
|
|
273446
|
+
const paragraphMeasure = entry.measure;
|
|
273447
|
+
const resolvedPageRefs = resolveParagraphPageRefs(fragment2, paragraphBlock, paragraphMeasure, pageRefContext);
|
|
273448
|
+
return resolveParagraphContent(resolvedPageRefs.fragment, resolvedPageRefs.block, paragraphMeasure);
|
|
271947
273449
|
}
|
|
271948
273450
|
function resolveFragmentParagraphBorders(fragment2, blockMap) {
|
|
271949
273451
|
const entry = blockMap.get(fragment2.blockId);
|
|
@@ -271978,11 +273480,14 @@ function computeBlockVersion(blockId, blockMap, cache$2, fontSignature = "") {
|
|
|
271978
273480
|
cache$2.set(blockId, "missing");
|
|
271979
273481
|
return "missing";
|
|
271980
273482
|
}
|
|
271981
|
-
const
|
|
271982
|
-
const versioned = fontSignature ? `${fontSignature}|${version$1}` : version$1;
|
|
273483
|
+
const versioned = deriveFontAwareBlockVersion(entry.block, fontSignature);
|
|
271983
273484
|
cache$2.set(blockId, versioned);
|
|
271984
273485
|
return versioned;
|
|
271985
273486
|
}
|
|
273487
|
+
function deriveFontAwareBlockVersion(block, fontSignature = "") {
|
|
273488
|
+
const version$1 = deriveBlockVersion(block);
|
|
273489
|
+
return fontSignature ? `${fontSignature}|${version$1}` : version$1;
|
|
273490
|
+
}
|
|
271986
273491
|
function applyPaintVersions(item, visualVersion) {
|
|
271987
273492
|
const evidenceVersion = sourceAnchorSignature(item.sourceAnchor);
|
|
271988
273493
|
item.version = visualVersion;
|
|
@@ -271992,19 +273497,25 @@ function applyPaintVersions(item, visualVersion) {
|
|
|
271992
273497
|
} else
|
|
271993
273498
|
item.paintCacheVersion = visualVersion;
|
|
271994
273499
|
}
|
|
271995
|
-
function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, blockVersionCache, story, fontSignature = "") {
|
|
273500
|
+
function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, blockVersionCache, story, fontSignature = "", pageRefContext) {
|
|
271996
273501
|
const sdtContainerKey = resolveFragmentSdtContainerKey(fragment2, blockMap);
|
|
271997
273502
|
const version$1 = fragmentSignature(fragment2, computeBlockVersion(fragment2.blockId, blockMap, blockVersionCache, fontSignature));
|
|
271998
273503
|
const layoutSourceIdentity = resolveFragmentLayoutIdentity(fragment2, story);
|
|
271999
273504
|
switch (fragment2.kind) {
|
|
272000
273505
|
case "table": {
|
|
272001
273506
|
const item = resolveTableItem(fragment2, fragmentIndex, pageIndex, blockMap);
|
|
273507
|
+
const tablePageRefs = resolveTablePageRefs(item.block, item.measure, pageRefContext);
|
|
273508
|
+
if (tablePageRefs.changed) {
|
|
273509
|
+
item.block = tablePageRefs.block;
|
|
273510
|
+
if (tablePageRefs.measure)
|
|
273511
|
+
item.measure = tablePageRefs.measure;
|
|
273512
|
+
}
|
|
272002
273513
|
if (sdtContainerKey != null)
|
|
272003
273514
|
item.sdtContainerKey = sdtContainerKey;
|
|
272004
273515
|
if (fragment2.sourceAnchor != null)
|
|
272005
273516
|
item.sourceAnchor = fragment2.sourceAnchor;
|
|
272006
273517
|
item.layoutSourceIdentity = layoutSourceIdentity;
|
|
272007
|
-
applyPaintVersions(item, version$1);
|
|
273518
|
+
applyPaintVersions(item, tablePageRefs.changed ? fragmentSignature(fragment2, deriveFontAwareBlockVersion(tablePageRefs.block, fontSignature)) : version$1);
|
|
272008
273519
|
return item;
|
|
272009
273520
|
}
|
|
272010
273521
|
case "image": {
|
|
@@ -272028,6 +273539,10 @@ function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, bloc
|
|
|
272028
273539
|
return item;
|
|
272029
273540
|
}
|
|
272030
273541
|
default: {
|
|
273542
|
+
const entry = blockMap.get(fragment2.blockId);
|
|
273543
|
+
const paragraphPageRefs = fragment2.kind === "para" && entry?.block.kind === "paragraph" && entry.measure.kind === "paragraph" ? resolveParagraphPageRefs(fragment2, entry.block, entry.measure, pageRefContext) : null;
|
|
273544
|
+
const listPageRefs = fragment2.kind === "list-item" && entry?.block.kind === "list" ? resolveListItemPageRefs(entry.block, fragment2.itemId, entry.measure.kind === "list" ? entry.measure : undefined, pageRefContext) : null;
|
|
273545
|
+
const itemVersion = paragraphPageRefs?.changed ? fragmentSignature(paragraphPageRefs.fragment, deriveFontAwareBlockVersion(paragraphPageRefs.block, fontSignature)) : listPageRefs?.changed ? fragmentSignature(fragment2, deriveFontAwareBlockVersion(listPageRefs.block, fontSignature)) : version$1;
|
|
272031
273546
|
const item = {
|
|
272032
273547
|
kind: "fragment",
|
|
272033
273548
|
id: resolveFragmentId(fragment2),
|
|
@@ -272041,25 +273556,24 @@ function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, bloc
|
|
|
272041
273556
|
fragment: fragment2,
|
|
272042
273557
|
blockId: fragment2.blockId,
|
|
272043
273558
|
fragmentIndex,
|
|
272044
|
-
content: resolveParagraphContentIfApplicable(fragment2, blockMap),
|
|
273559
|
+
content: paragraphPageRefs ? resolveParagraphContent(paragraphPageRefs.fragment, paragraphPageRefs.block, entry.measure) : resolveParagraphContentIfApplicable(fragment2, blockMap, pageRefContext),
|
|
272045
273560
|
layoutSourceIdentity
|
|
272046
273561
|
};
|
|
272047
273562
|
if (sdtContainerKey != null)
|
|
272048
273563
|
item.sdtContainerKey = sdtContainerKey;
|
|
272049
273564
|
if (fragment2.sourceAnchor != null)
|
|
272050
273565
|
item.sourceAnchor = fragment2.sourceAnchor;
|
|
272051
|
-
const entry = blockMap.get(fragment2.blockId);
|
|
272052
273566
|
if (entry) {
|
|
272053
273567
|
if (fragment2.kind === "para" && entry.block.kind === "paragraph" && entry.measure.kind === "paragraph") {
|
|
272054
|
-
item.block = entry.block;
|
|
273568
|
+
item.block = paragraphPageRefs?.block ?? entry.block;
|
|
272055
273569
|
item.measure = entry.measure;
|
|
272056
273570
|
if (item.sourceAnchor == null)
|
|
272057
273571
|
item.sourceAnchor = entry.block.sourceAnchor;
|
|
272058
273572
|
} else if (fragment2.kind === "list-item" && entry.block.kind === "list" && entry.measure.kind === "list") {
|
|
272059
|
-
const listBlock = entry.block;
|
|
273573
|
+
const listBlock = listPageRefs?.block ?? entry.block;
|
|
272060
273574
|
const listItem2 = listBlock.items.find((candidate) => candidate.id === fragment2.itemId);
|
|
272061
273575
|
item.block = listBlock;
|
|
272062
|
-
item.measure = entry.measure;
|
|
273576
|
+
item.measure = listPageRefs?.measure ?? entry.measure;
|
|
272063
273577
|
if (item.sourceAnchor == null)
|
|
272064
273578
|
item.sourceAnchor = listItem2?.sourceAnchor ?? listItem2?.paragraph.sourceAnchor ?? listBlock.sourceAnchor;
|
|
272065
273579
|
}
|
|
@@ -272090,16 +273604,17 @@ function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, bloc
|
|
|
272090
273604
|
if (listItem2.markerWidth != null)
|
|
272091
273605
|
item.markerWidth = listItem2.markerWidth;
|
|
272092
273606
|
}
|
|
272093
|
-
applyPaintVersions(item,
|
|
273607
|
+
applyPaintVersions(item, itemVersion);
|
|
272094
273608
|
return item;
|
|
272095
273609
|
}
|
|
272096
273610
|
}
|
|
272097
273611
|
}
|
|
272098
273612
|
function resolveLayout(input2) {
|
|
272099
|
-
const { layout, flowMode, blocks: blocks2, measures } = input2;
|
|
273613
|
+
const { layout, flowMode, blocks: blocks2, measures, bookmarks } = input2;
|
|
272100
273614
|
const fontSignature = input2.fontSignature ?? "";
|
|
272101
273615
|
const blockMap = buildBlockMap(blocks2, measures);
|
|
272102
273616
|
const blockVersionCache = /* @__PURE__ */ new Map;
|
|
273617
|
+
const pageRefAnchorMap = bookmarks?.size ? buildPageRefAnchorMap(bookmarks, layout, blocks2, measures) : undefined;
|
|
272103
273618
|
const pages = layout.pages.map((page, pageIndex) => ({
|
|
272104
273619
|
id: `page-${pageIndex}`,
|
|
272105
273620
|
index: pageIndex,
|
|
@@ -272108,7 +273623,10 @@ function resolveLayout(input2) {
|
|
|
272108
273623
|
number: page.number,
|
|
272109
273624
|
width: page.size?.w ?? layout.pageSize.w,
|
|
272110
273625
|
height: page.size?.h ?? layout.pageSize.h,
|
|
272111
|
-
items: page.fragments.map((fragment2, fragmentIndex) => resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, blockVersionCache, undefined, fontSignature
|
|
273626
|
+
items: page.fragments.map((fragment2, fragmentIndex) => resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, blockVersionCache, undefined, fontSignature, pageRefAnchorMap ? {
|
|
273627
|
+
sourcePage: page.number,
|
|
273628
|
+
anchorMap: pageRefAnchorMap
|
|
273629
|
+
} : undefined)),
|
|
272112
273630
|
margins: page.margins,
|
|
272113
273631
|
footnoteReserved: page.footnoteReserved,
|
|
272114
273632
|
displayNumber: page.displayNumber,
|
|
@@ -272413,8 +273931,8 @@ function getColumnConfig(blockColumns) {
|
|
|
272413
273931
|
}
|
|
272414
273932
|
function isColumnConfigChanging(blockColumns, activeColumns) {
|
|
272415
273933
|
if (blockColumns)
|
|
272416
|
-
return
|
|
272417
|
-
return activeColumns
|
|
273934
|
+
return !columnRenderLayoutsEqual(blockColumns, activeColumns);
|
|
273935
|
+
return resolveColumnCount(activeColumns) > 1 || Boolean(activeColumns.withSeparator);
|
|
272418
273936
|
}
|
|
272419
273937
|
function scheduleSectionBreak(block, state, baseMargins, maxHeaderContentHeight = 0, maxFooterContentHeight = 0) {
|
|
272420
273938
|
const next2 = { ...state };
|
|
@@ -272745,7 +274263,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
|
|
|
272745
274263
|
const anchorX = entry.block.anchor ? resolveAnchoredGraphicX(entry.block.anchor, state.columnIndex, anchors.columns, entry.measure.width, {
|
|
272746
274264
|
left: anchors.pageMargins.left,
|
|
272747
274265
|
right: anchors.pageMargins.right
|
|
272748
|
-
}, anchors.pageWidth) : columnX(state
|
|
274266
|
+
}, anchors.pageWidth) : columnX(state);
|
|
272749
274267
|
const pmRange = extractBlockPmRange(entry.block);
|
|
272750
274268
|
if (entry.block.kind === "image" && entry.measure.kind === "image") {
|
|
272751
274269
|
const pageContentHeight = Math.max(0, state.contentBottom - state.topMargin);
|
|
@@ -272821,7 +274339,7 @@ function layoutParagraphBlock(ctx$1, anchors) {
|
|
|
272821
274339
|
if (state.cursorY >= state.contentBottom)
|
|
272822
274340
|
state = advanceColumn(state);
|
|
272823
274341
|
const fragmentWidth = lines.reduce((max$2, line) => Math.max(max$2, line.width ?? 0), 0) || columnWidth;
|
|
272824
|
-
let x = columnX(state
|
|
274342
|
+
let x = columnX(state);
|
|
272825
274343
|
if (frame.xAlign === "right")
|
|
272826
274344
|
x += columnWidth - fragmentWidth;
|
|
272827
274345
|
else if (frame.xAlign === "center")
|
|
@@ -273030,9 +274548,9 @@ function layoutParagraphBlock(ctx$1, anchors) {
|
|
|
273030
274548
|
state.footnoteAnchorsThisPage.push(a2);
|
|
273031
274549
|
}
|
|
273032
274550
|
}
|
|
273033
|
-
const floatAdjustedX = columnX(state
|
|
274551
|
+
const floatAdjustedX = columnX(state) + offsetX;
|
|
273034
274552
|
const adjustedX = didRemeasureForFloats ? floatAdjustedX + Math.max(negativeLeftIndent, 0) : floatAdjustedX + negativeLeftIndent;
|
|
273035
|
-
const columnRight = columnX(state
|
|
274553
|
+
const columnRight = columnX(state) + columnWidth;
|
|
273036
274554
|
let adjustedWidth = didRemeasureForFloats ? effectiveColumnWidth : effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
|
|
273037
274555
|
if (didRemeasureForFloats)
|
|
273038
274556
|
adjustedWidth = Math.min(adjustedWidth, Math.max(1, columnRight - adjustedX));
|
|
@@ -273069,9 +274587,9 @@ function layoutParagraphBlock(ctx$1, anchors) {
|
|
|
273069
274587
|
if (lines[i4].width > maxLineWidth)
|
|
273070
274588
|
maxLineWidth = lines[i4].width;
|
|
273071
274589
|
if (floatAlignment === "right")
|
|
273072
|
-
fragment2.x = columnX(state
|
|
274590
|
+
fragment2.x = columnX(state) + offsetX + (effectiveColumnWidth - maxLineWidth);
|
|
273073
274591
|
else if (floatAlignment === "center")
|
|
273074
|
-
fragment2.x = columnX(state
|
|
274592
|
+
fragment2.x = columnX(state) + offsetX + (effectiveColumnWidth - maxLineWidth) / 2;
|
|
273075
274593
|
}
|
|
273076
274594
|
state.page.fragments.push(fragment2);
|
|
273077
274595
|
state.cursorY += borderExpansion.top + fragmentHeight + borderExpansion.bottom;
|
|
@@ -273139,7 +274657,7 @@ function layoutImageBlock({ block, measure, columns, ensurePage, advanceColumn,
|
|
|
273139
274657
|
const fragment2 = {
|
|
273140
274658
|
kind: "image",
|
|
273141
274659
|
blockId: block.id,
|
|
273142
|
-
x: columnX(state
|
|
274660
|
+
x: columnX(state) + marginLeft,
|
|
273143
274661
|
y: state.cursorY + marginTop,
|
|
273144
274662
|
width,
|
|
273145
274663
|
height,
|
|
@@ -273185,7 +274703,7 @@ function layoutDrawingBlock({ block, measure, columns, ensurePage, advanceColumn
|
|
|
273185
274703
|
if (state.cursorY + requiredHeight > state.contentBottom && state.cursorY > state.topMargin)
|
|
273186
274704
|
state = advanceColumn(state);
|
|
273187
274705
|
const pmRange = extractBlockPmRange(block);
|
|
273188
|
-
let x = columnX(state
|
|
274706
|
+
let x = columnX(state) + marginLeft + indentLeft;
|
|
273189
274707
|
if (isInlineShapeGroup && inlineParagraphAlignment) {
|
|
273190
274708
|
const pIndentLeft = typeof attrs?.paragraphIndentLeft === "number" ? attrs.paragraphIndentLeft : 0;
|
|
273191
274709
|
const pIndentRight = typeof attrs?.paragraphIndentRight === "number" ? attrs.paragraphIndentRight : 0;
|
|
@@ -273695,7 +275213,7 @@ function getCellPadding(cellIdx, blockRow) {
|
|
|
273695
275213
|
right: padding.right ?? 4
|
|
273696
275214
|
};
|
|
273697
275215
|
}
|
|
273698
|
-
function
|
|
275216
|
+
function getCellTotalLines2(cell2) {
|
|
273699
275217
|
return getCellLines(cell2).length;
|
|
273700
275218
|
}
|
|
273701
275219
|
function getRowContentHeight(blockRow, rowMeasure) {
|
|
@@ -273781,7 +275299,7 @@ function computeTableFragmentPmRange(block, measure, fromRow, toRow, partialRow)
|
|
|
273781
275299
|
const cellMeasure = rowMeasure.cells[cellIndex];
|
|
273782
275300
|
if (!cell2 || !cellMeasure)
|
|
273783
275301
|
continue;
|
|
273784
|
-
const totalLines =
|
|
275302
|
+
const totalLines = getCellTotalLines2(cellMeasure);
|
|
273785
275303
|
let fromLine = 0;
|
|
273786
275304
|
let toLine = totalLines;
|
|
273787
275305
|
if (isPartial) {
|
|
@@ -273859,7 +275377,7 @@ function computePartialRow(rowIndex, blockRow, measure, availableHeight, fromLin
|
|
|
273859
275377
|
const madeProgress = toLineByCell.some((cutLine, idx) => cutLine > (startLines[idx] || 0));
|
|
273860
275378
|
const isFirstPart = startLines.every((l) => l === 0);
|
|
273861
275379
|
const isLastPart = toLineByCell.every((cutLine, idx) => {
|
|
273862
|
-
return cutLine >=
|
|
275380
|
+
return cutLine >= getCellTotalLines2(row2.cells[idx]);
|
|
273863
275381
|
}) || !madeProgress;
|
|
273864
275382
|
if (actualPartialHeight === 0 && isFirstPart)
|
|
273865
275383
|
actualPartialHeight = maxPaddingTotal;
|
|
@@ -273964,7 +275482,7 @@ function layoutMonolithicTable(context) {
|
|
|
273964
275482
|
state = context.advanceColumn(state);
|
|
273965
275483
|
state = context.ensurePage();
|
|
273966
275484
|
const height = Math.min(context.measure.totalHeight, state.contentBottom - state.cursorY);
|
|
273967
|
-
const baseX = context.columnX(state
|
|
275485
|
+
const baseX = context.columnX(state);
|
|
273968
275486
|
const baseWidth = Math.max(0, context.measure.totalWidth || context.columnWidth);
|
|
273969
275487
|
const { x, width } = resolveTableFrame(baseX, context.columnWidth, baseWidth, context.block.attrs);
|
|
273970
275488
|
const columnWidths = rescaleColumnWidths(context.measure.columnWidths, context.measure.totalWidth, width);
|
|
@@ -274044,7 +275562,7 @@ function layoutTableBlock({ block, measure, columnWidth, ensurePage, advanceColu
|
|
|
274044
275562
|
let pendingPartialRow = null;
|
|
274045
275563
|
if (block.rows.length === 0 && measure.totalHeight > 0) {
|
|
274046
275564
|
const height = Math.min(measure.totalHeight, state.contentBottom - state.cursorY);
|
|
274047
|
-
const { x, width } = resolveTableFrame(columnX(state
|
|
275565
|
+
const { x, width } = resolveTableFrame(columnX(state), columnWidth, Math.max(0, measure.totalWidth || columnWidth), block.attrs);
|
|
274048
275566
|
const columnWidths = rescaleColumnWidths(measure.columnWidths, measure.totalWidth, width);
|
|
274049
275567
|
const metadata = generateFragmentMetadata(measure, block, 0, 0, 0, columnWidths);
|
|
274050
275568
|
const fragment2 = {
|
|
@@ -274108,14 +275626,14 @@ function layoutTableBlock({ block, measure, columnWidth, ensurePage, advanceColu
|
|
|
274108
275626
|
const continuationPartialRow = computePartialRow(rowIndex, block.rows[rowIndex], measure, availableForBody, fromLineByCell, fullPageHeightForBody);
|
|
274109
275627
|
const madeProgress = continuationPartialRow.toLineByCell.some((toLine, idx) => toLine > (fromLineByCell[idx] || 0));
|
|
274110
275628
|
const hasRemainingLinesAfterContinuation = continuationPartialRow.toLineByCell.some((toLine, idx) => {
|
|
274111
|
-
return toLine <
|
|
275629
|
+
return toLine < getCellTotalLines2(measure.rows[rowIndex].cells[idx]);
|
|
274112
275630
|
});
|
|
274113
275631
|
const hadRemainingLinesBefore = fromLineByCell.some((fromLine, idx) => {
|
|
274114
|
-
return fromLine <
|
|
275632
|
+
return fromLine < getCellTotalLines2(measure.rows[rowIndex].cells[idx]);
|
|
274115
275633
|
});
|
|
274116
275634
|
const fragmentHeight$1 = computeFragmentHeight(measure, rowIndex, rowIndex + 1, repeatHeaderCount, borderCollapse, continuationPartialRow);
|
|
274117
275635
|
if (fragmentHeight$1 > 0 && madeProgress) {
|
|
274118
|
-
const { x: x$1, width: width$1 } = resolveTableFrame(columnX(state
|
|
275636
|
+
const { x: x$1, width: width$1 } = resolveTableFrame(columnX(state), columnWidth, Math.max(0, measure.totalWidth || columnWidth), block.attrs);
|
|
274119
275637
|
const scaledWidths$1 = rescaleColumnWidths(measure.columnWidths, measure.totalWidth, width$1);
|
|
274120
275638
|
const fragment$1 = {
|
|
274121
275639
|
kind: "table",
|
|
@@ -274172,7 +275690,7 @@ function layoutTableBlock({ block, measure, columnWidth, ensurePage, advanceColu
|
|
|
274172
275690
|
}
|
|
274173
275691
|
const forcedEndRow = bodyStartRow + 1;
|
|
274174
275692
|
const fragmentHeight$1 = computeFragmentHeight(measure, bodyStartRow, forcedEndRow, repeatHeaderCount, borderCollapse, forcedPartialRow);
|
|
274175
|
-
const { x: x$1, width: width$1 } = resolveTableFrame(columnX(state
|
|
275693
|
+
const { x: x$1, width: width$1 } = resolveTableFrame(columnX(state), columnWidth, Math.max(0, measure.totalWidth || columnWidth), block.attrs);
|
|
274176
275694
|
const scaledWidths$1 = rescaleColumnWidths(measure.columnWidths, measure.totalWidth, width$1);
|
|
274177
275695
|
const fragment$1 = {
|
|
274178
275696
|
kind: "table",
|
|
@@ -274202,7 +275720,7 @@ function layoutTableBlock({ block, measure, columnWidth, ensurePage, advanceColu
|
|
|
274202
275720
|
continue;
|
|
274203
275721
|
}
|
|
274204
275722
|
const fragmentHeight = computeFragmentHeight(measure, bodyStartRow, endRow, repeatHeaderCount, borderCollapse, partialRow);
|
|
274205
|
-
const { x, width } = resolveTableFrame(columnX(state
|
|
275723
|
+
const { x, width } = resolveTableFrame(columnX(state), columnWidth, Math.max(0, measure.totalWidth || columnWidth), block.attrs);
|
|
274206
275724
|
const scaledWidths = rescaleColumnWidths(measure.columnWidths, measure.totalWidth, width);
|
|
274207
275725
|
const fragment2 = {
|
|
274208
275726
|
kind: "table",
|
|
@@ -274429,16 +275947,6 @@ function createPaginator(opts) {
|
|
|
274429
275947
|
return state.constraintBoundaries[state.activeConstraintIndex].columns;
|
|
274430
275948
|
return opts.getActiveColumns();
|
|
274431
275949
|
};
|
|
274432
|
-
const columnX = (columnIndex) => {
|
|
274433
|
-
const cols = opts.getCurrentColumns();
|
|
274434
|
-
const widths = Array.isArray(cols.widths) && cols.widths.length > 0 ? cols.widths : null;
|
|
274435
|
-
if (!widths)
|
|
274436
|
-
return opts.margins.left + columnIndex * (cols.width + cols.gap);
|
|
274437
|
-
let x = opts.margins.left;
|
|
274438
|
-
for (let index2 = 0;index2 < columnIndex; index2 += 1)
|
|
274439
|
-
x += (widths[index2] ?? cols.width) + cols.gap;
|
|
274440
|
-
return x;
|
|
274441
|
-
};
|
|
274442
275950
|
const startNewPage = () => {
|
|
274443
275951
|
if (opts.onNewPage)
|
|
274444
275952
|
opts.onNewPage(undefined);
|
|
@@ -274493,7 +276001,7 @@ function createPaginator(opts) {
|
|
|
274493
276001
|
};
|
|
274494
276002
|
const advanceColumn = (state) => {
|
|
274495
276003
|
const activeCols = getActiveColumnsForState(state);
|
|
274496
|
-
if (state.columnIndex < activeCols
|
|
276004
|
+
if (state.columnIndex < resolveColumnCount(activeCols) - 1) {
|
|
274497
276005
|
state.maxCursorY = Math.max(state.maxCursorY, state.cursorY);
|
|
274498
276006
|
state.columnIndex += 1;
|
|
274499
276007
|
if (state.activeConstraintIndex >= 0 && state.constraintBoundaries[state.activeConstraintIndex])
|
|
@@ -274518,7 +276026,6 @@ function createPaginator(opts) {
|
|
|
274518
276026
|
startNewPage,
|
|
274519
276027
|
ensurePage,
|
|
274520
276028
|
advanceColumn,
|
|
274521
|
-
columnX,
|
|
274522
276029
|
getActiveColumnsForState,
|
|
274523
276030
|
getPageByNumber,
|
|
274524
276031
|
pruneTrailingEmptyPages
|
|
@@ -275166,7 +276673,7 @@ function cloneBlockWithResolvedTokens(block, displayPageInfo, totalPagesStr, tot
|
|
|
275166
276673
|
if ("token" in run2 && run2.token) {
|
|
275167
276674
|
if (run2.token === "pageNumber") {
|
|
275168
276675
|
const resolvedText = run2.pageNumberFieldFormat ? formatChapterPageNumberText({
|
|
275169
|
-
pageComponent: formatPageNumberFieldValue
|
|
276676
|
+
pageComponent: formatPageNumberFieldValue(displayPageInfo.displayNumber, run2.pageNumberFieldFormat),
|
|
275170
276677
|
chapterNumberText: displayPageInfo.chapterNumberText,
|
|
275171
276678
|
chapterSeparator: displayPageInfo.chapterSeparator
|
|
275172
276679
|
}) : displayPageInfo.chapterNumberText ? formatSectionPageNumberText({
|
|
@@ -275181,14 +276688,14 @@ function cloneBlockWithResolvedTokens(block, displayPageInfo, totalPagesStr, tot
|
|
|
275181
276688
|
text: resolvedText
|
|
275182
276689
|
};
|
|
275183
276690
|
} else if (run2.token === "totalPageCount") {
|
|
275184
|
-
const resolvedText = run2.pageNumberFieldFormat ? formatPageNumberFieldValue
|
|
276691
|
+
const resolvedText = run2.pageNumberFieldFormat ? formatPageNumberFieldValue(totalPages, run2.pageNumberFieldFormat) : totalPagesStr;
|
|
275185
276692
|
changed ||= run2.text !== resolvedText;
|
|
275186
276693
|
return {
|
|
275187
276694
|
...run2,
|
|
275188
276695
|
text: resolvedText
|
|
275189
276696
|
};
|
|
275190
276697
|
} else if (run2.token === "sectionPageCount") {
|
|
275191
|
-
const resolvedText = run2.pageNumberFieldFormat ? formatPageNumberFieldValue
|
|
276698
|
+
const resolvedText = run2.pageNumberFieldFormat ? formatPageNumberFieldValue(sectionPageCount, run2.pageNumberFieldFormat) : String(sectionPageCount);
|
|
275192
276699
|
changed ||= run2.text !== resolvedText;
|
|
275193
276700
|
return {
|
|
275194
276701
|
...run2,
|
|
@@ -275613,7 +277120,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
275613
277120
|
if (block.orientation)
|
|
275614
277121
|
next2.pendingOrientation = block.orientation;
|
|
275615
277122
|
const sectionType = block.type ?? "continuous";
|
|
275616
|
-
const isColumnsChanging = block.columns &&
|
|
277123
|
+
const isColumnsChanging = block.columns && !columnRenderLayoutsEqual(block.columns, next2.activeColumns) || !block.columns && (resolveColumnCount(next2.activeColumns) > 1 || Boolean(next2.activeColumns.withSeparator));
|
|
275617
277124
|
const sectionIndexRaw = block.attrs?.sectionIndex;
|
|
275618
277125
|
const metadataIndex = typeof sectionIndexRaw === "number" ? sectionIndexRaw : Number(sectionIndexRaw ?? NaN);
|
|
275619
277126
|
if (Number.isFinite(metadataIndex))
|
|
@@ -275702,8 +277209,8 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
275702
277209
|
page.size = pageSizeOverride;
|
|
275703
277210
|
if (activeOrientation)
|
|
275704
277211
|
page.orientation = activeOrientation;
|
|
275705
|
-
if (activeColumns
|
|
275706
|
-
page.columns =
|
|
277212
|
+
if (resolveColumnCount(activeColumns) > 1)
|
|
277213
|
+
page.columns = resolveColumnLayout(activeColumns);
|
|
275707
277214
|
if (activeVAlign && activeVAlign !== "top") {
|
|
275708
277215
|
page.vAlign = activeVAlign;
|
|
275709
277216
|
page.baseMargins = {
|
|
@@ -275923,7 +277430,6 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
275923
277430
|
getActivePageSize: () => activePageSize,
|
|
275924
277431
|
getDefaultPageSize: () => pageSize,
|
|
275925
277432
|
getActiveColumns: () => activeColumns,
|
|
275926
|
-
getCurrentColumns: () => getCurrentColumns(),
|
|
275927
277433
|
createPage,
|
|
275928
277434
|
onNewPage: (state) => {
|
|
275929
277435
|
if (!state) {
|
|
@@ -276077,7 +277583,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276077
277583
|
const state = states[states.length - 1] ?? null;
|
|
276078
277584
|
const colsConfig = state ? getActiveColumnsForState(state) : activeColumns;
|
|
276079
277585
|
const constraintIndex = state ? state.activeConstraintIndex : -1;
|
|
276080
|
-
if (cachedColumnsState.state === state && cachedColumnsState.constraintIndex === constraintIndex && cachedColumnsState.contentWidth === currentContentWidth && cachedColumnsState.colsConfig
|
|
277586
|
+
if (cachedColumnsState.state === state && cachedColumnsState.constraintIndex === constraintIndex && cachedColumnsState.contentWidth === currentContentWidth && columnRenderLayoutsEqual(cachedColumnsState.colsConfig ?? undefined, colsConfig) && cachedColumnsState.normalized)
|
|
276081
277587
|
return cachedColumnsState.normalized;
|
|
276082
277588
|
const normalized = normalizeColumns(colsConfig, currentContentWidth);
|
|
276083
277589
|
cachedColumnsState = {
|
|
@@ -276089,10 +277595,19 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276089
277595
|
};
|
|
276090
277596
|
return normalized;
|
|
276091
277597
|
};
|
|
277598
|
+
const getColumnGeometryForState = (state) => {
|
|
277599
|
+
return getColumnGeometry(normalizeColumns(state.activeConstraintIndex >= 0 && state.constraintBoundaries[state.activeConstraintIndex] ? state.constraintBoundaries[state.activeConstraintIndex].columns : state.page.columns ?? {
|
|
277600
|
+
count: 1,
|
|
277601
|
+
gap: 0
|
|
277602
|
+
}, (state.page.size?.w ?? pageSize.w) - ((state.page.margins?.left ?? activeLeftMargin) + (state.page.margins?.right ?? activeRightMargin))));
|
|
277603
|
+
};
|
|
277604
|
+
const columnWidthForState = (state, columnIndex = state.columnIndex) => getColumnWidth(getColumnGeometryForState(state), columnIndex);
|
|
277605
|
+
const columnXForState = (state, columnIndex = state.columnIndex) => getColumnX(getColumnGeometryForState(state), columnIndex, state.page.margins?.left ?? activeLeftMargin);
|
|
276092
277606
|
const getCurrentColumnWidth = () => {
|
|
276093
|
-
|
|
277607
|
+
const state = states[states.length - 1] ?? null;
|
|
277608
|
+
return state ? columnWidthForState(state) : getColumnWidthAt(getCurrentColumns(), 0);
|
|
276094
277609
|
};
|
|
276095
|
-
const columnX =
|
|
277610
|
+
const columnX = columnXForState;
|
|
276096
277611
|
const advanceColumn = paginator.advanceColumn;
|
|
276097
277612
|
const startMidPageRegion = (state, newColumns) => {
|
|
276098
277613
|
const regionStartY = Math.max(state.cursorY, state.maxCursorY);
|
|
@@ -276360,7 +277875,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276360
277875
|
}
|
|
276361
277876
|
}
|
|
276362
277877
|
const endingSectionColumns = endingSectionIndex !== null ? sectionColumnsMap.get(endingSectionIndex) : undefined;
|
|
276363
|
-
const willBalance = endingSectionIndex !== null && !!endingSectionColumns && endingSectionColumns
|
|
277878
|
+
const willBalance = endingSectionIndex !== null && !!endingSectionColumns && resolveColumnCount(endingSectionColumns) > 1 && !sectionHasExplicitColumnBreak.has(endingSectionIndex);
|
|
276364
277879
|
let balanceResult = null;
|
|
276365
277880
|
if (willBalance) {
|
|
276366
277881
|
const activeRegionTop = state.constraintBoundaries[state.constraintBoundaries.length - 1]?.y ?? activeTopMargin;
|
|
@@ -276391,7 +277906,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276391
277906
|
alreadyBalancedSections.add(endingSectionIndex);
|
|
276392
277907
|
}
|
|
276393
277908
|
}
|
|
276394
|
-
if (balanceResult === null && columnIndexBefore >= newColumns
|
|
277909
|
+
if (balanceResult === null && columnIndexBefore >= resolveColumnCount(newColumns))
|
|
276395
277910
|
state = paginator.startNewPage();
|
|
276396
277911
|
startMidPageRegion(state, newColumns);
|
|
276397
277912
|
}
|
|
@@ -276546,7 +278061,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276546
278061
|
const offsetV = tableBlock.anchor?.offsetV ?? 0;
|
|
276547
278062
|
const anchorY = Math.max(anchorParagraphTopY, nextStackY) + offsetV;
|
|
276548
278063
|
floatManager.registerTable(tableBlock, tableMeasure, anchorY, state.columnIndex, state.page.number);
|
|
276549
|
-
const tableFragment = createAnchoredTableFragment(tableBlock, tableMeasure, tableBlock.anchor?.offsetH ?? columnX(state
|
|
278064
|
+
const tableFragment = createAnchoredTableFragment(tableBlock, tableMeasure, tableBlock.anchor?.offsetH ?? columnX(state), anchorY);
|
|
276550
278065
|
state.page.fragments.push(tableFragment);
|
|
276551
278066
|
placedAnchoredTableIds.add(tableBlock.id);
|
|
276552
278067
|
if ((tableBlock.wrap?.type ?? "None") !== "None") {
|
|
@@ -276579,7 +278094,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276579
278094
|
else if (relativeFrom === "margin")
|
|
276580
278095
|
maxWidth = activePageSize.w - (activeLeftMargin + activeRightMargin);
|
|
276581
278096
|
else
|
|
276582
|
-
maxWidth =
|
|
278097
|
+
maxWidth = columnWidthForState(state);
|
|
276583
278098
|
const aspectRatio = imgMeasure.width > 0 && imgMeasure.height > 0 ? imgMeasure.width / imgMeasure.height : 1;
|
|
276584
278099
|
const minWidth = 20;
|
|
276585
278100
|
const minHeight = minWidth / aspectRatio;
|
|
@@ -276694,7 +278209,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276694
278209
|
throw new Error(`layoutDocument: expected columnBreak measure for block ${block.id}`);
|
|
276695
278210
|
const state = paginator.ensurePage();
|
|
276696
278211
|
const activeCols = getActiveColumnsForState(state);
|
|
276697
|
-
if (state.columnIndex < activeCols
|
|
278212
|
+
if (state.columnIndex < resolveColumnCount(activeCols) - 1)
|
|
276698
278213
|
advanceColumn(state);
|
|
276699
278214
|
else
|
|
276700
278215
|
paginator.startNewPage();
|
|
@@ -276718,7 +278233,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276718
278233
|
if (columnWidthForTable > 0 && totalWidth >= columnWidthForTable * 0.99)
|
|
276719
278234
|
continue;
|
|
276720
278235
|
const anchorY = resolveParagraphlessAnchoredTableY(tableBlock, tableMeasure, state);
|
|
276721
|
-
const anchorX = tableBlock.anchor?.offsetH ?? columnX(state
|
|
278236
|
+
const anchorX = tableBlock.anchor?.offsetH ?? columnX(state);
|
|
276722
278237
|
floatManager.registerTable(tableBlock, tableMeasure, anchorY, state.columnIndex, state.page.number);
|
|
276723
278238
|
state.page.fragments.push(createAnchoredTableFragment(tableBlock, tableMeasure, anchorX, anchorY));
|
|
276724
278239
|
placedAnchoredTableIds.add(tableBlock.id);
|
|
@@ -276766,13 +278281,13 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276766
278281
|
fragment2.y += yOffset;
|
|
276767
278282
|
}
|
|
276768
278283
|
const FALLBACK_SECTION_IDX = -1;
|
|
276769
|
-
if (sectionColumnsMap.size === 0 && !documentHasAnySectionBreak && activeColumns
|
|
278284
|
+
if (sectionColumnsMap.size === 0 && !documentHasAnySectionBreak && resolveColumnCount(activeColumns) > 1 && !documentHasExplicitColumnBreak) {
|
|
276770
278285
|
sectionColumnsMap.set(FALLBACK_SECTION_IDX, cloneColumnLayout(activeColumns));
|
|
276771
278286
|
for (const block of blocks2)
|
|
276772
278287
|
blockSectionMap.set(block.id, FALLBACK_SECTION_IDX);
|
|
276773
278288
|
}
|
|
276774
278289
|
for (const [sectionIdx, sectionCols] of sectionColumnsMap) {
|
|
276775
|
-
if (sectionCols
|
|
278290
|
+
if (resolveColumnCount(sectionCols) <= 1)
|
|
276776
278291
|
continue;
|
|
276777
278292
|
if (sectionHasExplicitColumnBreak.has(sectionIdx))
|
|
276778
278293
|
continue;
|
|
@@ -276854,7 +278369,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276854
278369
|
regions.push({
|
|
276855
278370
|
yStart: start$1.y,
|
|
276856
278371
|
yEnd: end$1 ? end$1.y : state.contentBottom,
|
|
276857
|
-
columns: start$1.columns
|
|
278372
|
+
columns: resolveColumnLayout(start$1.columns)
|
|
276858
278373
|
});
|
|
276859
278374
|
}
|
|
276860
278375
|
state.page.columnRegions = regions;
|
|
@@ -276871,7 +278386,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
276871
278386
|
pageSize,
|
|
276872
278387
|
pages,
|
|
276873
278388
|
...options.documentBackground ? { documentBackground: options.documentBackground } : {},
|
|
276874
|
-
columns: activeColumns
|
|
278389
|
+
columns: resolveColumnCount(activeColumns) > 1 ? resolveColumnLayout(activeColumns) : undefined
|
|
276875
278390
|
};
|
|
276876
278391
|
}
|
|
276877
278392
|
function computeFragmentBottom(fragment2, block, measure) {
|
|
@@ -277451,7 +278966,7 @@ function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberTe
|
|
|
277451
278966
|
if ("token" in run2 && run2.token) {
|
|
277452
278967
|
if (run2.token === "pageNumber")
|
|
277453
278968
|
run2.text = run2.pageNumberFieldFormat ? formatChapterPageNumberText({
|
|
277454
|
-
pageComponent: formatPageNumberFieldValue
|
|
278969
|
+
pageComponent: formatPageNumberFieldValue(displayNumber, run2.pageNumberFieldFormat),
|
|
277455
278970
|
chapterNumberText,
|
|
277456
278971
|
chapterSeparator
|
|
277457
278972
|
}) : chapterNumberText ? formatSectionPageNumberText({
|
|
@@ -277461,9 +278976,9 @@ function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberTe
|
|
|
277461
278976
|
chapterSeparator
|
|
277462
278977
|
}) : pageNumberStr;
|
|
277463
278978
|
else if (run2.token === "totalPageCount")
|
|
277464
|
-
run2.text = run2.pageNumberFieldFormat ? formatPageNumberFieldValue
|
|
278979
|
+
run2.text = run2.pageNumberFieldFormat ? formatPageNumberFieldValue(totalPages, run2.pageNumberFieldFormat) : totalPagesStr;
|
|
277465
278980
|
else if (run2.token === "sectionPageCount")
|
|
277466
|
-
run2.text = run2.pageNumberFieldFormat ? formatPageNumberFieldValue
|
|
278981
|
+
run2.text = run2.pageNumberFieldFormat ? formatPageNumberFieldValue(sectionPageCountNumber, run2.pageNumberFieldFormat) : sectionPageCountStr;
|
|
277467
278982
|
}
|
|
277468
278983
|
});
|
|
277469
278984
|
}
|
|
@@ -277608,7 +279123,7 @@ function canUseDigitBucketingForVariant(blocks2, docTotalPages, pageResolver) {
|
|
|
277608
279123
|
const renderedBucketForPage = (pageNumber) => {
|
|
277609
279124
|
const pageInfo = pageResolver(pageNumber);
|
|
277610
279125
|
const renderedText = strategy.kind === "fieldFormat" ? Number.isFinite(pageInfo.displayNumber) ? formatChapterPageNumberText({
|
|
277611
|
-
pageComponent: formatPageNumberFieldValue
|
|
279126
|
+
pageComponent: formatPageNumberFieldValue(pageInfo.displayNumber ?? pageNumber, strategy.fieldFormat),
|
|
277612
279127
|
chapterNumberText: pageInfo.chapterNumberText,
|
|
277613
279128
|
chapterSeparator: pageInfo.chapterSeparator
|
|
277614
279129
|
}) : null : pageInfo.displayText;
|
|
@@ -287402,6 +288917,10 @@ async function measureParagraphBlock(block, maxWidth, fontContext) {
|
|
|
287402
288917
|
}
|
|
287403
288918
|
lastFontSize = run2.fontSize;
|
|
287404
288919
|
hasSeenTextRun = true;
|
|
288920
|
+
if (run2.text === "") {
|
|
288921
|
+
pendingRunSpacing = 0;
|
|
288922
|
+
continue;
|
|
288923
|
+
}
|
|
287405
288924
|
const { font } = buildFontString(run2, fontContext);
|
|
287406
288925
|
const tabSegments = run2.text.split("\t");
|
|
287407
288926
|
let charPosInRun = 0;
|
|
@@ -296930,7 +298449,7 @@ var Node$13 = class Node$14 {
|
|
|
296930
298449
|
}
|
|
296931
298450
|
case "total-page-number":
|
|
296932
298451
|
return {
|
|
296933
|
-
text: editor.options.totalPageCount || editor.options.parentEditor?.currentTotalPages ||
|
|
298452
|
+
text: formatPageNumberFieldValue(Number(editor.options.totalPageCount || editor.options.parentEditor?.currentTotalPages || 1) || 1, getPageNumberFieldFormat(node3?.attrs)),
|
|
296934
298453
|
className: "sd-editor-auto-total-pages",
|
|
296935
298454
|
dataId: "auto-total-pages",
|
|
296936
298455
|
ariaLabel: "Total page count node"
|
|
@@ -296941,7 +298460,7 @@ var Node$13 = class Node$14 {
|
|
|
296941
298460
|
const pageNumberFormat = typeof node3?.attrs?.pageNumberFormat === "string" ? node3.attrs.pageNumberFormat : undefined;
|
|
296942
298461
|
const pageNumberZeroPadding = typeof node3?.attrs?.pageNumberZeroPadding === "number" && Number.isFinite(node3.attrs.pageNumberZeroPadding) ? node3.attrs.pageNumberZeroPadding : undefined;
|
|
296943
298462
|
return {
|
|
296944
|
-
text: sectionPageCount != null ? pageNumberFormat || pageNumberZeroPadding != null ? formatPageNumberFieldValue
|
|
298463
|
+
text: sectionPageCount != null ? pageNumberFormat || pageNumberZeroPadding != null ? formatPageNumberFieldValue(Number(sectionPageCount) || 1, {
|
|
296945
298464
|
...pageNumberFormat ? { format: pageNumberFormat } : {},
|
|
296946
298465
|
...pageNumberZeroPadding != null ? { zeroPadding: pageNumberZeroPadding } : {}
|
|
296947
298466
|
}) : sectionPageCount : cachedText,
|
|
@@ -313163,7 +314682,7 @@ menclose::after {
|
|
|
313163
314682
|
if (runToken === "pageNumber") {
|
|
313164
314683
|
if (run2.pageNumberFieldFormat)
|
|
313165
314684
|
return formatChapterPageNumberText({
|
|
313166
|
-
pageComponent: formatPageNumberFieldValue
|
|
314685
|
+
pageComponent: formatPageNumberFieldValue(context.displayPageNumber ?? context.pageNumber, run2.pageNumberFieldFormat),
|
|
313167
314686
|
chapterNumberText: context.pageNumberChapterText,
|
|
313168
314687
|
chapterSeparator: context.pageNumberChapterSeparator
|
|
313169
314688
|
});
|
|
@@ -313178,7 +314697,7 @@ menclose::after {
|
|
|
313178
314697
|
}
|
|
313179
314698
|
if (runToken === "totalPageCount") {
|
|
313180
314699
|
if (run2.pageNumberFieldFormat)
|
|
313181
|
-
return formatPageNumberFieldValue
|
|
314700
|
+
return formatPageNumberFieldValue(context.totalPages || 1, run2.pageNumberFieldFormat);
|
|
313182
314701
|
return context.totalPages ? String(context.totalPages) : run2.text ?? "";
|
|
313183
314702
|
}
|
|
313184
314703
|
if (runToken === "sectionPageCount") {
|
|
@@ -313186,7 +314705,7 @@ menclose::after {
|
|
|
313186
314705
|
if (sectionPageCount == null)
|
|
313187
314706
|
return run2.text ?? "";
|
|
313188
314707
|
if (run2.pageNumberFieldFormat)
|
|
313189
|
-
return formatPageNumberFieldValue
|
|
314708
|
+
return formatPageNumberFieldValue(sectionPageCount, run2.pageNumberFieldFormat);
|
|
313190
314709
|
return String(sectionPageCount);
|
|
313191
314710
|
}
|
|
313192
314711
|
return run2.text ?? "";
|
|
@@ -314108,7 +315627,7 @@ menclose::after {
|
|
|
314108
315627
|
break;
|
|
314109
315628
|
}
|
|
314110
315629
|
return merged;
|
|
314111
|
-
}, isTextRun$
|
|
315630
|
+
}, isTextRun$6 = (run2) => (run2.kind === "text" || run2.kind === undefined) && ("text" in run2), isOverlaySafeRunKind = (run2) => {
|
|
314112
315631
|
const kind = run2.kind ?? "text";
|
|
314113
315632
|
return kind === "text" || kind === "tab" || kind === "lineBreak" || kind === "break";
|
|
314114
315633
|
}, shouldUseLineUnderlineOverlay = (runsForLine) => runsForLine.every(isOverlaySafeRunKind) && runsForLine.some((run2) => run2.kind === "tab" && canPaintUnderlineOverlay(run2)), cloneRunWithoutUnderline = (run2) => ({
|
|
@@ -314133,7 +315652,7 @@ menclose::after {
|
|
|
314133
315652
|
const segments = segmentsByRun.get(runIndex);
|
|
314134
315653
|
if (segments?.length)
|
|
314135
315654
|
return segments.reduce((sum, segment) => {
|
|
314136
|
-
const text5 = isTextRun$
|
|
315655
|
+
const text5 = isTextRun$6(run2) ? (run2.text ?? "").slice(segment.fromChar, segment.toChar) : "";
|
|
314137
315656
|
return sum + segment.width + spacingPerSpace * countSpaces$1(text5);
|
|
314138
315657
|
}, 0);
|
|
314139
315658
|
if ("width" in run2 && typeof run2.width === "number")
|
|
@@ -315566,29 +317085,17 @@ menclose::after {
|
|
|
315566
317085
|
}
|
|
315567
317086
|
}
|
|
315568
317087
|
getColumnSeparatorPositions(columns, leftMargin, contentWidth) {
|
|
315569
|
-
|
|
315570
|
-
|
|
315571
|
-
if (
|
|
317088
|
+
const normalized = normalizeColumnLayout(columns, contentWidth);
|
|
317089
|
+
if (resolveColumnMode(columns) === "equal") {
|
|
317090
|
+
if ((contentWidth - columns.gap * (normalized.count - 1)) / normalized.count <= 1)
|
|
315572
317091
|
return [];
|
|
315573
|
-
const separatorPositions$1 = [];
|
|
315574
|
-
for (let index2 = 0;index2 < columns.count - 1; index2 += 1)
|
|
315575
|
-
separatorPositions$1.push(leftMargin + (index2 + 1) * equalWidth + index2 * columns.gap + columns.gap / 2);
|
|
315576
|
-
return separatorPositions$1;
|
|
315577
317092
|
}
|
|
315578
|
-
const
|
|
315579
|
-
if (
|
|
317093
|
+
const geometry = getColumnGeometry(normalized);
|
|
317094
|
+
if (geometry.length <= 1)
|
|
315580
317095
|
return [];
|
|
315581
|
-
|
|
315582
|
-
if (columnWidths.some((columnWidth) => columnWidth <= 1))
|
|
317096
|
+
if (geometry.some((column) => column.width <= 1))
|
|
315583
317097
|
return [];
|
|
315584
|
-
|
|
315585
|
-
let cursorX = leftMargin;
|
|
315586
|
-
for (let index2 = 0;index2 < normalizedColumns.count - 1; index2 += 1) {
|
|
315587
|
-
const currentColumnWidth = columnWidths[index2] ?? normalizedColumns.width;
|
|
315588
|
-
separatorPositions.push(cursorX + currentColumnWidth + normalizedColumns.gap / 2);
|
|
315589
|
-
cursorX += currentColumnWidth + normalizedColumns.gap;
|
|
315590
|
-
}
|
|
315591
|
-
return separatorPositions;
|
|
317098
|
+
return getColumnSeparatorPositions(geometry, leftMargin);
|
|
315592
317099
|
}
|
|
315593
317100
|
renderDecorationsForPage(pageEl, page, pageIndex) {
|
|
315594
317101
|
if (this.isSemanticFlow)
|
|
@@ -316291,8 +317798,10 @@ menclose::after {
|
|
|
316291
317798
|
});
|
|
316292
317799
|
return context?.pageNumberText ?? String(context?.pageNumber ?? 1);
|
|
316293
317800
|
}
|
|
316294
|
-
if (part.fieldType === "NUMPAGES")
|
|
316295
|
-
|
|
317801
|
+
if (part.fieldType === "NUMPAGES") {
|
|
317802
|
+
const totalPages = context?.totalPages ?? 1;
|
|
317803
|
+
return part.pageNumberFormat ? formatPageNumber(totalPages, part.pageNumberFormat) : String(totalPages);
|
|
317804
|
+
}
|
|
316296
317805
|
if (part.fieldType === "SECTIONPAGES") {
|
|
316297
317806
|
if (context?.sectionPageCount == null)
|
|
316298
317807
|
return part.text ?? "1";
|
|
@@ -326550,13 +328059,13 @@ menclose::after {
|
|
|
326550
328059
|
return;
|
|
326551
328060
|
console.log(...args$1);
|
|
326552
328061
|
}, 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, TRACKED_MARK_NAMES;
|
|
326553
|
-
var
|
|
328062
|
+
var init_src_eTZqPcFn_es = __esm(() => {
|
|
326554
328063
|
init_rolldown_runtime_Bg48TavK_es();
|
|
326555
|
-
|
|
328064
|
+
init_SuperConverter_D2zNnC50_es();
|
|
326556
328065
|
init_jszip_C49i9kUs_es();
|
|
326557
328066
|
init_xml_js_CqGKpaft_es();
|
|
326558
328067
|
init_uuid_qzgm05fK_es();
|
|
326559
|
-
|
|
328068
|
+
init_create_headless_toolbar_COmoIa5Q_es();
|
|
326560
328069
|
init_constants_D9qj59G2_es();
|
|
326561
328070
|
init_dist_B8HfvhaK_es();
|
|
326562
328071
|
init_unified_Dsuw2be5_es();
|
|
@@ -331040,7 +332549,7 @@ ${err.toString()}`);
|
|
|
331040
332549
|
if (typeof tablePos !== "number" && !tableNode || !Array.isArray(valueRows) || !valueRows.length)
|
|
331041
332550
|
return false;
|
|
331042
332551
|
return chain().command(({ tr, dispatch }) => {
|
|
331043
|
-
const workingTable =
|
|
332552
|
+
const workingTable = resolveTable3(tr, tablePos, tableNode);
|
|
331044
332553
|
if (!workingTable)
|
|
331045
332554
|
return false;
|
|
331046
332555
|
const templateRow = pickTemplateRowForAppend(workingTable, editor.schema);
|
|
@@ -333537,6 +335046,10 @@ ${err.toString()}`);
|
|
|
333537
335046
|
default: null,
|
|
333538
335047
|
rendered: false
|
|
333539
335048
|
},
|
|
335049
|
+
pageNumberNumericPicture: {
|
|
335050
|
+
default: null,
|
|
335051
|
+
rendered: false
|
|
335052
|
+
},
|
|
333540
335053
|
importedCachedText: {
|
|
333541
335054
|
default: null,
|
|
333542
335055
|
rendered: false
|
|
@@ -333697,6 +335210,38 @@ ${err.toString()}`);
|
|
|
333697
335210
|
instruction: {
|
|
333698
335211
|
default: "",
|
|
333699
335212
|
rendered: false
|
|
335213
|
+
},
|
|
335214
|
+
instructionTokens: {
|
|
335215
|
+
default: null,
|
|
335216
|
+
rendered: false
|
|
335217
|
+
},
|
|
335218
|
+
bookmarkId: {
|
|
335219
|
+
default: "",
|
|
335220
|
+
rendered: false
|
|
335221
|
+
},
|
|
335222
|
+
hasHyperlinkSwitch: {
|
|
335223
|
+
default: false,
|
|
335224
|
+
rendered: false
|
|
335225
|
+
},
|
|
335226
|
+
hasRelativePositionSwitch: {
|
|
335227
|
+
default: false,
|
|
335228
|
+
rendered: false
|
|
335229
|
+
},
|
|
335230
|
+
pageNumberFieldFormat: {
|
|
335231
|
+
default: null,
|
|
335232
|
+
rendered: false
|
|
335233
|
+
},
|
|
335234
|
+
numericPictureFormat: {
|
|
335235
|
+
default: null,
|
|
335236
|
+
rendered: false
|
|
335237
|
+
},
|
|
335238
|
+
fieldResultFormat: {
|
|
335239
|
+
default: null,
|
|
335240
|
+
rendered: false
|
|
335241
|
+
},
|
|
335242
|
+
fieldRunProperties: {
|
|
335243
|
+
default: null,
|
|
335244
|
+
rendered: false
|
|
333700
335245
|
}
|
|
333701
335246
|
};
|
|
333702
335247
|
},
|
|
@@ -337262,6 +338807,22 @@ ${err.toString()}`);
|
|
|
337262
338807
|
default: "",
|
|
337263
338808
|
rendered: false
|
|
337264
338809
|
},
|
|
338810
|
+
fieldArgument: {
|
|
338811
|
+
default: "",
|
|
338812
|
+
rendered: false
|
|
338813
|
+
},
|
|
338814
|
+
sequenceMode: {
|
|
338815
|
+
default: "next",
|
|
338816
|
+
rendered: false
|
|
338817
|
+
},
|
|
338818
|
+
hideResult: {
|
|
338819
|
+
default: false,
|
|
338820
|
+
rendered: false
|
|
338821
|
+
},
|
|
338822
|
+
restartNumber: {
|
|
338823
|
+
default: null,
|
|
338824
|
+
rendered: false
|
|
338825
|
+
},
|
|
337265
338826
|
format: {
|
|
337266
338827
|
default: "ARABIC",
|
|
337267
338828
|
rendered: false
|
|
@@ -337270,10 +338831,26 @@ ${err.toString()}`);
|
|
|
337270
338831
|
default: null,
|
|
337271
338832
|
rendered: false
|
|
337272
338833
|
},
|
|
338834
|
+
hasGeneralFormat: {
|
|
338835
|
+
default: false,
|
|
338836
|
+
rendered: false
|
|
338837
|
+
},
|
|
338838
|
+
pageNumberFieldFormat: {
|
|
338839
|
+
default: null,
|
|
338840
|
+
rendered: false
|
|
338841
|
+
},
|
|
338842
|
+
numericPictureFormat: {
|
|
338843
|
+
default: null,
|
|
338844
|
+
rendered: false
|
|
338845
|
+
},
|
|
337273
338846
|
resolvedNumber: {
|
|
337274
338847
|
default: "",
|
|
337275
338848
|
rendered: false
|
|
337276
338849
|
},
|
|
338850
|
+
resolvedNumberIsCurrent: {
|
|
338851
|
+
default: false,
|
|
338852
|
+
rendered: false
|
|
338853
|
+
},
|
|
337277
338854
|
sdBlockId: {
|
|
337278
338855
|
default: null,
|
|
337279
338856
|
rendered: false
|
|
@@ -337288,7 +338865,7 @@ ${err.toString()}`);
|
|
|
337288
338865
|
return [{ tag: 'span[data-id="sequence-field"]' }];
|
|
337289
338866
|
},
|
|
337290
338867
|
renderDOM({ node: node3, htmlAttributes }) {
|
|
337291
|
-
const text5 = node3.attrs.resolvedNumber || "
|
|
338868
|
+
const text5 = node3.attrs.resolvedNumber || "";
|
|
337292
338869
|
return [
|
|
337293
338870
|
"span",
|
|
337294
338871
|
Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes),
|
|
@@ -337358,7 +338935,8 @@ ${err.toString()}`);
|
|
|
337358
338935
|
SYNTHETIC_FIELD_NODE_TYPES = {
|
|
337359
338936
|
"total-page-number": {
|
|
337360
338937
|
fieldType: "NUMPAGES",
|
|
337361
|
-
instruction: "NUMPAGES"
|
|
338938
|
+
instruction: "NUMPAGES",
|
|
338939
|
+
resolveInstruction: (node3) => typeof node3.attrs?.instruction === "string" && node3.attrs.instruction.trim() ? node3.attrs.instruction : "NUMPAGES"
|
|
337362
338940
|
},
|
|
337363
338941
|
"section-page-count": {
|
|
337364
338942
|
fieldType: "SECTIONPAGES",
|
|
@@ -337377,6 +338955,7 @@ ${err.toString()}`);
|
|
|
337377
338955
|
addCommands() {
|
|
337378
338956
|
return { updateFieldsInSelection: () => ({ editor, state, tr: outerTr, dispatch }) => {
|
|
337379
338957
|
const { from: from$1, to } = state.selection;
|
|
338958
|
+
const selectionHadSeq = findFieldsInRange(state.doc, from$1, to).some((field) => field.fieldType === "SEQ");
|
|
337380
338959
|
let tocPathRan = false;
|
|
337381
338960
|
if (editor?.doc?.toc?.update) {
|
|
337382
338961
|
const tocTargets = findAllTocNodes(state.doc).map((toc) => toc.commandNodeId).filter((id2) => typeof id2 === "string" && id2);
|
|
@@ -337407,22 +338986,27 @@ ${err.toString()}`);
|
|
|
337407
338986
|
tocPathRan = true;
|
|
337408
338987
|
}
|
|
337409
338988
|
}
|
|
337410
|
-
const
|
|
337411
|
-
|
|
338989
|
+
const activeState = tocPathRan && editor?.state?.doc ? editor.state : state;
|
|
338990
|
+
const activeDoc = activeState.doc ?? state.doc;
|
|
338991
|
+
const activeSchema = activeState.schema ?? state.schema;
|
|
338992
|
+
const fields = findFieldsInRange(activeDoc, Math.min(from$1, activeDoc.content.size), to >= state.doc.content.size ? activeDoc.content.size : Math.min(to, activeDoc.content.size));
|
|
338993
|
+
const updatable = fields.filter((f2) => UPDATABLE_FIELD_TYPES.has(f2.fieldType));
|
|
338994
|
+
const hasSeqSelection = selectionHadSeq || fields.some((field) => field.fieldType === "SEQ");
|
|
338995
|
+
if (updatable.length === 0 && !hasSeqSelection)
|
|
337412
338996
|
return tocPathRan;
|
|
337413
338997
|
const stats = getWordStatistics(resolveMainBodyEditor(editor));
|
|
337414
|
-
const tr =
|
|
338998
|
+
const tr = activeState.tr;
|
|
337415
338999
|
let changed = false;
|
|
337416
339000
|
const sorted = [...updatable].sort((a2, b$1) => b$1.pos - a2.pos);
|
|
337417
339001
|
for (const field of sorted) {
|
|
337418
339002
|
const node3 = tr.doc.nodeAt(field.pos);
|
|
337419
339003
|
if (!node3)
|
|
337420
339004
|
continue;
|
|
337421
|
-
const freshValue = field.fieldType === "SECTIONPAGES" ? resolveSectionPageCountFieldValue(editor, node3) : resolveDocumentStatFieldValue(field.fieldType, stats);
|
|
339005
|
+
const freshValue = field.fieldType === "SECTIONPAGES" ? resolveSectionPageCountFieldValue(editor, node3) : field.fieldType === "NUMPAGES" && node3.type.name === "total-page-number" ? resolveTotalPageNumberFieldValue(stats, node3) : resolveDocumentStatFieldValue(field.fieldType, stats);
|
|
337422
339006
|
if (freshValue == null)
|
|
337423
339007
|
continue;
|
|
337424
339008
|
if (node3.type.name === "total-page-number" || node3.type.name === "section-page-count") {
|
|
337425
|
-
const textChild = freshValue ?
|
|
339009
|
+
const textChild = freshValue ? activeSchema.text(freshValue) : null;
|
|
337426
339010
|
const newNode = node3.type.create({
|
|
337427
339011
|
...node3.attrs,
|
|
337428
339012
|
resolvedText: freshValue
|
|
@@ -337439,6 +339023,15 @@ ${err.toString()}`);
|
|
|
337439
339023
|
changed = true;
|
|
337440
339024
|
}
|
|
337441
339025
|
}
|
|
339026
|
+
if (hasSeqSelection) {
|
|
339027
|
+
const result = updateSequenceFieldsInTransaction({
|
|
339028
|
+
tr,
|
|
339029
|
+
schema: activeSchema,
|
|
339030
|
+
scope: { kind: "all" },
|
|
339031
|
+
converterContext: getSequenceFieldUpdaterConverterContext(editor)
|
|
339032
|
+
});
|
|
339033
|
+
changed = changed || result.changed;
|
|
339034
|
+
}
|
|
337442
339035
|
if (!changed)
|
|
337443
339036
|
return tocPathRan;
|
|
337444
339037
|
if (dispatch)
|
|
@@ -354364,7 +355957,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
354364
355957
|
const currentPageNumber = Number(opts.currentPageDisplayNumber || opts.currentPageNumber || 1);
|
|
354365
355958
|
const chapterNumberText = typeof opts.currentPageChapterNumberText === "string" ? opts.currentPageChapterNumberText : undefined;
|
|
354366
355959
|
const chapterSeparator = typeof opts.currentPageChapterSeparator === "string" ? opts.currentPageChapterSeparator : undefined;
|
|
354367
|
-
const totalPages =
|
|
355960
|
+
const totalPages = Number(opts.totalPageCount || parentEditor?.currentTotalPages || 1) || 1;
|
|
354368
355961
|
const sectionPages = opts.sectionPageCount;
|
|
354369
355962
|
const pageNumberEls = container.querySelectorAll('[data-id="auto-page-number"]');
|
|
354370
355963
|
const totalPagesEls = container.querySelectorAll('[data-id="auto-total-pages"]');
|
|
@@ -354381,8 +355974,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
354381
355974
|
el.textContent = text5;
|
|
354382
355975
|
});
|
|
354383
355976
|
totalPagesEls.forEach((el) => {
|
|
354384
|
-
|
|
354385
|
-
|
|
355977
|
+
const text5 = formatPageNumberFieldValue(totalPages, this.#getPageNumberFieldFormatForDomNode(editor, el));
|
|
355978
|
+
if (el.textContent !== text5)
|
|
355979
|
+
el.textContent = text5;
|
|
354386
355980
|
});
|
|
354387
355981
|
sectionPagesEls.forEach((el) => {
|
|
354388
355982
|
if (sectionPages == null)
|
|
@@ -354406,6 +356000,17 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
354406
356000
|
return null;
|
|
354407
356001
|
}
|
|
354408
356002
|
}
|
|
356003
|
+
#getPageNumberFieldFormatForDomNode(editor, el) {
|
|
356004
|
+
try {
|
|
356005
|
+
const view = editor.view;
|
|
356006
|
+
if (!view)
|
|
356007
|
+
return;
|
|
356008
|
+
const pos = view.posAtDOM(el, 0);
|
|
356009
|
+
return getPageNumberFieldFormat(editor.state.doc.nodeAt(pos)?.attrs);
|
|
356010
|
+
} catch {
|
|
356011
|
+
return;
|
|
356012
|
+
}
|
|
356013
|
+
}
|
|
354409
356014
|
getEditor(descriptor) {
|
|
354410
356015
|
if (!descriptor?.id)
|
|
354411
356016
|
return null;
|
|
@@ -356444,7 +358049,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
356444
358049
|
flowMode: this.#layoutOptions.flowMode ?? "paginated",
|
|
356445
358050
|
blocks: blocks2,
|
|
356446
358051
|
measures,
|
|
356447
|
-
fontSignature: this.#layoutFontSignature
|
|
358052
|
+
fontSignature: this.#layoutFontSignature,
|
|
358053
|
+
bookmarks: this.#layoutState.bookmarks
|
|
356448
358054
|
});
|
|
356449
358055
|
const isSemanticFlow = this.#layoutOptions.flowMode === "semantic";
|
|
356450
358056
|
this.#ensurePainter();
|
|
@@ -358720,7 +360326,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
358720
360326
|
flowMode: this.#layoutOptions.flowMode ?? "paginated",
|
|
358721
360327
|
blocks: bodyBlocksForPaint,
|
|
358722
360328
|
measures: bodyMeasuresForPaint,
|
|
358723
|
-
fontSignature
|
|
360329
|
+
fontSignature,
|
|
360330
|
+
bookmarks
|
|
358724
360331
|
});
|
|
358725
360332
|
headerLayouts = result.headers;
|
|
358726
360333
|
footerLayouts = result.footers;
|
|
@@ -361496,11 +363103,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
361496
363103
|
]);
|
|
361497
363104
|
});
|
|
361498
363105
|
|
|
361499
|
-
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-
|
|
363106
|
+
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-BOYlxpy0.es.js
|
|
361500
363107
|
var MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
|
|
361501
|
-
var
|
|
361502
|
-
|
|
361503
|
-
|
|
363108
|
+
var init_create_super_doc_ui_BOYlxpy0_es = __esm(() => {
|
|
363109
|
+
init_SuperConverter_D2zNnC50_es();
|
|
363110
|
+
init_create_headless_toolbar_COmoIa5Q_es();
|
|
361504
363111
|
MOD_ALIASES = new Set([
|
|
361505
363112
|
"Mod",
|
|
361506
363113
|
"Meta",
|
|
@@ -361542,16 +363149,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
|
|
|
361542
363149
|
|
|
361543
363150
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
361544
363151
|
var init_super_editor_es = __esm(() => {
|
|
361545
|
-
|
|
361546
|
-
|
|
363152
|
+
init_src_eTZqPcFn_es();
|
|
363153
|
+
init_SuperConverter_D2zNnC50_es();
|
|
361547
363154
|
init_jszip_C49i9kUs_es();
|
|
361548
363155
|
init_xml_js_CqGKpaft_es();
|
|
361549
|
-
|
|
363156
|
+
init_create_headless_toolbar_COmoIa5Q_es();
|
|
361550
363157
|
init_constants_D9qj59G2_es();
|
|
361551
363158
|
init_dist_B8HfvhaK_es();
|
|
361552
363159
|
init_unified_Dsuw2be5_es();
|
|
361553
363160
|
init_DocxZipper_Bu2Fhqkw_es();
|
|
361554
|
-
|
|
363161
|
+
init_create_super_doc_ui_BOYlxpy0_es();
|
|
361555
363162
|
init_ui_C5PAS9hY_es();
|
|
361556
363163
|
init_eventemitter3_BnGqBE_Q_es();
|
|
361557
363164
|
init_errors_CNaD6vcg_es();
|