@superdoc-dev/cli 0.16.0-next.14 → 0.16.0-next.15
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 +765 -317
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -68110,7 +68110,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
|
|
|
68110
68110
|
emptyOptions2 = {};
|
|
68111
68111
|
});
|
|
68112
68112
|
|
|
68113
|
-
// ../../packages/superdoc/dist/chunks/SuperConverter-
|
|
68113
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-CvwFiCth.es.js
|
|
68114
68114
|
function getExtensionConfigField(extension$1, field, context = { name: "" }) {
|
|
68115
68115
|
const fieldValue = extension$1.config[field];
|
|
68116
68116
|
if (typeof fieldValue === "function")
|
|
@@ -77655,6 +77655,46 @@ function effectiveTableCellSpacing(spacing, isBoundary, padding) {
|
|
|
77655
77655
|
return 0;
|
|
77656
77656
|
return isBoundary ? Math.max(0, spacing - padding) : spacing;
|
|
77657
77657
|
}
|
|
77658
|
+
function selectHeaderFooterVariantForPage({ documentPageNumber, sectionPageNumber, titlePg, alternateHeaders }) {
|
|
77659
|
+
if (!Number.isFinite(documentPageNumber) || !Number.isFinite(sectionPageNumber))
|
|
77660
|
+
return null;
|
|
77661
|
+
if (sectionPageNumber < 1)
|
|
77662
|
+
return null;
|
|
77663
|
+
if (sectionPageNumber === 1 && titlePg === true)
|
|
77664
|
+
return "first";
|
|
77665
|
+
if (alternateHeaders === true)
|
|
77666
|
+
return documentPageNumber % 2 === 0 ? "even" : "odd";
|
|
77667
|
+
return "default";
|
|
77668
|
+
}
|
|
77669
|
+
function candidateVariantsFor(variant) {
|
|
77670
|
+
return variant === "odd" ? ["odd", "default"] : [variant];
|
|
77671
|
+
}
|
|
77672
|
+
function sectionRefsFor(section, kind) {
|
|
77673
|
+
return kind === "header" ? section?.headerRefs : section?.footerRefs;
|
|
77674
|
+
}
|
|
77675
|
+
function resolveEffectiveHeaderFooterRef({ sections, sectionIndex, kind, variant }) {
|
|
77676
|
+
if (sectionIndex < 0)
|
|
77677
|
+
return null;
|
|
77678
|
+
const sectionsByIndex = /* @__PURE__ */ new Map;
|
|
77679
|
+
for (const section of sections)
|
|
77680
|
+
sectionsByIndex.set(section.sectionIndex, section);
|
|
77681
|
+
const candidates = candidateVariantsFor(variant);
|
|
77682
|
+
for (let currentIndex = sectionIndex;currentIndex >= 0; currentIndex -= 1) {
|
|
77683
|
+
const refs = sectionRefsFor(sectionsByIndex.get(currentIndex), kind);
|
|
77684
|
+
if (!refs)
|
|
77685
|
+
continue;
|
|
77686
|
+
for (const candidate of candidates) {
|
|
77687
|
+
const refId = refs[candidate];
|
|
77688
|
+
if (refId)
|
|
77689
|
+
return {
|
|
77690
|
+
refId,
|
|
77691
|
+
matchedSectionIndex: currentIndex,
|
|
77692
|
+
matchedVariant: candidate
|
|
77693
|
+
};
|
|
77694
|
+
}
|
|
77695
|
+
}
|
|
77696
|
+
return null;
|
|
77697
|
+
}
|
|
77658
77698
|
function rescaleColumnWidths(measureColumnWidths, measureTotalWidth, fragmentWidth) {
|
|
77659
77699
|
if (!measureColumnWidths || measureColumnWidths.length === 0 || measureTotalWidth <= fragmentWidth || measureTotalWidth <= 0)
|
|
77660
77700
|
return;
|
|
@@ -78058,6 +78098,77 @@ function getSdtContainerKeyForBlock(block) {
|
|
|
78058
78098
|
return null;
|
|
78059
78099
|
return getSdtContainerKey(block.attrs?.sdt, block.attrs?.containerSdt);
|
|
78060
78100
|
}
|
|
78101
|
+
function toUpperRoman$1(value) {
|
|
78102
|
+
if (value < 1 || value > 3999)
|
|
78103
|
+
return String(value);
|
|
78104
|
+
const values = [
|
|
78105
|
+
1000,
|
|
78106
|
+
900,
|
|
78107
|
+
500,
|
|
78108
|
+
400,
|
|
78109
|
+
100,
|
|
78110
|
+
90,
|
|
78111
|
+
50,
|
|
78112
|
+
40,
|
|
78113
|
+
10,
|
|
78114
|
+
9,
|
|
78115
|
+
5,
|
|
78116
|
+
4,
|
|
78117
|
+
1
|
|
78118
|
+
];
|
|
78119
|
+
const numerals = [
|
|
78120
|
+
"M",
|
|
78121
|
+
"CM",
|
|
78122
|
+
"D",
|
|
78123
|
+
"CD",
|
|
78124
|
+
"C",
|
|
78125
|
+
"XC",
|
|
78126
|
+
"L",
|
|
78127
|
+
"XL",
|
|
78128
|
+
"X",
|
|
78129
|
+
"IX",
|
|
78130
|
+
"V",
|
|
78131
|
+
"IV",
|
|
78132
|
+
"I"
|
|
78133
|
+
];
|
|
78134
|
+
let remaining = value;
|
|
78135
|
+
let result = "";
|
|
78136
|
+
for (let i$1 = 0;i$1 < values.length; i$1 += 1)
|
|
78137
|
+
while (remaining >= values[i$1]) {
|
|
78138
|
+
result += numerals[i$1];
|
|
78139
|
+
remaining -= values[i$1];
|
|
78140
|
+
}
|
|
78141
|
+
return result;
|
|
78142
|
+
}
|
|
78143
|
+
function toUpperLetter$1(value) {
|
|
78144
|
+
const normalized = Math.max(1, value);
|
|
78145
|
+
const index2 = (normalized - 1) % 26;
|
|
78146
|
+
const repeatCount = Math.floor((normalized - 1) / 26) + 1;
|
|
78147
|
+
return String.fromCharCode(65 + index2).repeat(repeatCount);
|
|
78148
|
+
}
|
|
78149
|
+
function formatPageNumber(pageNumber, format) {
|
|
78150
|
+
const value = Math.max(1, Math.trunc(Number.isFinite(pageNumber) ? pageNumber : 1));
|
|
78151
|
+
switch (format) {
|
|
78152
|
+
case "upperRoman":
|
|
78153
|
+
return toUpperRoman$1(value);
|
|
78154
|
+
case "lowerRoman":
|
|
78155
|
+
return toUpperRoman$1(value).toLowerCase();
|
|
78156
|
+
case "upperLetter":
|
|
78157
|
+
return toUpperLetter$1(value);
|
|
78158
|
+
case "lowerLetter":
|
|
78159
|
+
return toUpperLetter$1(value).toLowerCase();
|
|
78160
|
+
case "numberInDash":
|
|
78161
|
+
return `- ${value} -`;
|
|
78162
|
+
case "decimal":
|
|
78163
|
+
default:
|
|
78164
|
+
return String(value);
|
|
78165
|
+
}
|
|
78166
|
+
}
|
|
78167
|
+
function formatPageNumberFieldValue$1(pageNumber, fieldFormat) {
|
|
78168
|
+
const format = fieldFormat?.format ?? "decimal";
|
|
78169
|
+
const formatted = formatPageNumber(pageNumber, format);
|
|
78170
|
+
return fieldFormat?.zeroPadding && format === "decimal" ? formatted.padStart(fieldFormat.zeroPadding, "0") : formatted;
|
|
78171
|
+
}
|
|
78061
78172
|
function resolveSpacingIndent(style, numbering) {
|
|
78062
78173
|
const spacing = {
|
|
78063
78174
|
before: style.spacing?.before ?? 0,
|
|
@@ -82446,10 +82557,48 @@ function convertTiffToPng(data) {
|
|
|
82446
82557
|
return null;
|
|
82447
82558
|
}
|
|
82448
82559
|
}
|
|
82449
|
-
function
|
|
82560
|
+
function parsePageNumberFieldSwitches(instruction, fieldType) {
|
|
82561
|
+
const normalizedInstruction = typeof instruction === "string" ? instruction.trim().replace(/\s+/g, " ") : fieldType;
|
|
82562
|
+
const result = {};
|
|
82563
|
+
if (normalizedInstruction && normalizedInstruction !== fieldType)
|
|
82564
|
+
result.instruction = normalizedInstruction;
|
|
82565
|
+
for (const match of normalizedInstruction.matchAll(/\\\*\s+("[^"]+"|\S+)/g)) {
|
|
82566
|
+
const rawValue = unquote(match[1]);
|
|
82567
|
+
const mapped = GENERAL_FORMATS.get(rawValue) ?? CASE_INSENSITIVE_GENERAL_FORMATS.get(rawValue.toLowerCase());
|
|
82568
|
+
if (mapped) {
|
|
82569
|
+
result.pageNumberFormat = mapped;
|
|
82570
|
+
break;
|
|
82571
|
+
}
|
|
82572
|
+
}
|
|
82573
|
+
for (const match of normalizedInstruction.matchAll(/\\#\s+("[^"]+"|\S+)/g)) {
|
|
82574
|
+
const picture = unquote(match[1]);
|
|
82575
|
+
if (/^0+$/.test(picture)) {
|
|
82576
|
+
result.pageNumberFormat ??= "decimal";
|
|
82577
|
+
result.pageNumberZeroPadding = picture.length;
|
|
82578
|
+
break;
|
|
82579
|
+
}
|
|
82580
|
+
}
|
|
82581
|
+
return result;
|
|
82582
|
+
}
|
|
82583
|
+
function formatPageNumberFieldValue(pageNumber, attrs = {}) {
|
|
82584
|
+
return formatPageNumberFieldValue$1(pageNumber, {
|
|
82585
|
+
format: attrs.pageNumberFormat || "decimal",
|
|
82586
|
+
zeroPadding: attrs.pageNumberZeroPadding ?? undefined
|
|
82587
|
+
});
|
|
82588
|
+
}
|
|
82589
|
+
function unquote(value) {
|
|
82590
|
+
return value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value;
|
|
82591
|
+
}
|
|
82592
|
+
function preProcessPageInstruction(nodesToCombine, instrText = "PAGE", options = {}) {
|
|
82593
|
+
const fieldRunRPr = options.fieldRunRPr ?? null;
|
|
82594
|
+
const normalizedInstruction = typeof instrText === "string" && instrText.trim() ? instrText.trim().replace(/\s+/g, " ") : "PAGE";
|
|
82450
82595
|
const pageNumNode = {
|
|
82451
82596
|
name: "sd:autoPageNumber",
|
|
82452
|
-
type: "element"
|
|
82597
|
+
type: "element",
|
|
82598
|
+
attributes: {
|
|
82599
|
+
instruction: normalizedInstruction,
|
|
82600
|
+
...parsePageNumberFieldSwitches(normalizedInstruction, "PAGE")
|
|
82601
|
+
}
|
|
82453
82602
|
};
|
|
82454
82603
|
let foundContentRPr = false;
|
|
82455
82604
|
nodesToCombine.forEach((n) => {
|
|
@@ -82463,11 +82612,12 @@ function preProcessPageInstruction(nodesToCombine, _instrText, fieldRunRPr = nul
|
|
|
82463
82612
|
pageNumNode.elements = [fieldRunRPr];
|
|
82464
82613
|
return [pageNumNode];
|
|
82465
82614
|
}
|
|
82466
|
-
function preProcessNumPagesInstruction(nodesToCombine,
|
|
82615
|
+
function preProcessNumPagesInstruction(nodesToCombine, instrText = "NUMPAGES", options = {}) {
|
|
82616
|
+
const fieldRunRPr = options.fieldRunRPr ?? null;
|
|
82467
82617
|
const totalPageNumNode = {
|
|
82468
82618
|
name: "sd:totalPageNumber",
|
|
82469
82619
|
type: "element",
|
|
82470
|
-
attributes: {}
|
|
82620
|
+
attributes: { ...parsePageNumberFieldSwitches(instrText, "NUMPAGES") }
|
|
82471
82621
|
};
|
|
82472
82622
|
const cachedText = extractCachedText$1(nodesToCombine);
|
|
82473
82623
|
if (cachedText)
|
|
@@ -82496,7 +82646,7 @@ function extractCachedText$1(nodes) {
|
|
|
82496
82646
|
}
|
|
82497
82647
|
return texts.join("");
|
|
82498
82648
|
}
|
|
82499
|
-
function preProcessPageRefInstruction(nodesToCombine, instrText) {
|
|
82649
|
+
function preProcessPageRefInstruction(nodesToCombine, instrText, options = {}) {
|
|
82500
82650
|
return [{
|
|
82501
82651
|
name: "sd:pageReference",
|
|
82502
82652
|
type: "element",
|
|
@@ -82505,7 +82655,7 @@ function preProcessPageRefInstruction(nodesToCombine, instrText) {
|
|
|
82505
82655
|
}];
|
|
82506
82656
|
}
|
|
82507
82657
|
function resolveHyperlinkAttributes(instruction, docx) {
|
|
82508
|
-
const urlMatch = instruction.match(
|
|
82658
|
+
const urlMatch = instruction.match(/^\s*HYPERLINK\s+"([^"]+)"/i);
|
|
82509
82659
|
if (urlMatch && urlMatch.length >= 2) {
|
|
82510
82660
|
const url2 = urlMatch[1];
|
|
82511
82661
|
const relationships = docx?.["word/_rels/document.xml.rels"]?.elements?.find((el) => el.name === "Relationships");
|
|
@@ -82545,7 +82695,8 @@ function resolveHyperlinkAttributes(instruction, docx) {
|
|
|
82545
82695
|
return null;
|
|
82546
82696
|
return { ...parsedSwitches };
|
|
82547
82697
|
}
|
|
82548
|
-
function preProcessHyperlinkInstruction(nodesToCombine, instruction,
|
|
82698
|
+
function preProcessHyperlinkInstruction(nodesToCombine, instruction, options = {}) {
|
|
82699
|
+
const docx = options.docx;
|
|
82549
82700
|
return [{
|
|
82550
82701
|
name: "w:hyperlink",
|
|
82551
82702
|
type: "element",
|
|
@@ -82553,7 +82704,7 @@ function preProcessHyperlinkInstruction(nodesToCombine, instruction, docx) {
|
|
|
82553
82704
|
elements: nodesToCombine
|
|
82554
82705
|
}];
|
|
82555
82706
|
}
|
|
82556
|
-
function preProcessTocInstruction(nodesToCombine, instrText) {
|
|
82707
|
+
function preProcessTocInstruction(nodesToCombine, instrText, options = {}) {
|
|
82557
82708
|
return [{
|
|
82558
82709
|
name: "sd:tableOfContents",
|
|
82559
82710
|
type: "element",
|
|
@@ -82604,10 +82755,11 @@ function buildBlockFieldNode(xmlName, nodesToCombine, instrText, instructionToke
|
|
|
82604
82755
|
elements: normalizeFieldContentToParagraphs(nodesToCombine)
|
|
82605
82756
|
}];
|
|
82606
82757
|
}
|
|
82607
|
-
function preProcessIndexInstruction(nodesToCombine, instrText,
|
|
82608
|
-
return buildBlockFieldNode("sd:index", nodesToCombine, instrText, instructionTokens);
|
|
82758
|
+
function preProcessIndexInstruction(nodesToCombine, instrText, options = {}, legacyInstructionTokens = null) {
|
|
82759
|
+
return buildBlockFieldNode("sd:index", nodesToCombine, instrText, options?.instructionTokens ?? legacyInstructionTokens);
|
|
82609
82760
|
}
|
|
82610
|
-
function preProcessXeInstruction(nodesToCombine, instrText,
|
|
82761
|
+
function preProcessXeInstruction(nodesToCombine, instrText, options = {}) {
|
|
82762
|
+
const instructionTokens = options.instructionTokens ?? null;
|
|
82611
82763
|
return [{
|
|
82612
82764
|
name: "sd:indexEntry",
|
|
82613
82765
|
type: "element",
|
|
@@ -82618,7 +82770,8 @@ function preProcessXeInstruction(nodesToCombine, instrText, _docx, instructionTo
|
|
|
82618
82770
|
elements: nodesToCombine
|
|
82619
82771
|
}];
|
|
82620
82772
|
}
|
|
82621
|
-
function preProcessTcInstruction(nodesToCombine, instrText,
|
|
82773
|
+
function preProcessTcInstruction(nodesToCombine, instrText, options = {}) {
|
|
82774
|
+
const instructionTokens = options.instructionTokens ?? null;
|
|
82622
82775
|
return [{
|
|
82623
82776
|
name: "sd:tableOfContentsEntry",
|
|
82624
82777
|
type: "element",
|
|
@@ -82629,7 +82782,7 @@ function preProcessTcInstruction(nodesToCombine, instrText, _docx, instructionTo
|
|
|
82629
82782
|
elements: nodesToCombine
|
|
82630
82783
|
}];
|
|
82631
82784
|
}
|
|
82632
|
-
function preProcessRefInstruction(nodesToCombine, instrText) {
|
|
82785
|
+
function preProcessRefInstruction(nodesToCombine, instrText, options = {}) {
|
|
82633
82786
|
return [{
|
|
82634
82787
|
name: "sd:crossReference",
|
|
82635
82788
|
type: "element",
|
|
@@ -82640,7 +82793,7 @@ function preProcessRefInstruction(nodesToCombine, instrText) {
|
|
|
82640
82793
|
elements: nodesToCombine
|
|
82641
82794
|
}];
|
|
82642
82795
|
}
|
|
82643
|
-
function preProcessNoterefInstruction(nodesToCombine, instrText) {
|
|
82796
|
+
function preProcessNoterefInstruction(nodesToCombine, instrText, options = {}) {
|
|
82644
82797
|
return [{
|
|
82645
82798
|
name: "sd:crossReference",
|
|
82646
82799
|
type: "element",
|
|
@@ -82651,7 +82804,7 @@ function preProcessNoterefInstruction(nodesToCombine, instrText) {
|
|
|
82651
82804
|
elements: nodesToCombine
|
|
82652
82805
|
}];
|
|
82653
82806
|
}
|
|
82654
|
-
function preProcessStylerefInstruction(nodesToCombine, instrText) {
|
|
82807
|
+
function preProcessStylerefInstruction(nodesToCombine, instrText, options = {}) {
|
|
82655
82808
|
return [{
|
|
82656
82809
|
name: "sd:crossReference",
|
|
82657
82810
|
type: "element",
|
|
@@ -82662,7 +82815,8 @@ function preProcessStylerefInstruction(nodesToCombine, instrText) {
|
|
|
82662
82815
|
elements: nodesToCombine
|
|
82663
82816
|
}];
|
|
82664
82817
|
}
|
|
82665
|
-
function preProcessSeqInstruction(nodesToCombine, instrText,
|
|
82818
|
+
function preProcessSeqInstruction(nodesToCombine, instrText, options = {}) {
|
|
82819
|
+
const instructionTokens = options.instructionTokens ?? null;
|
|
82666
82820
|
return [{
|
|
82667
82821
|
name: "sd:sequenceField",
|
|
82668
82822
|
type: "element",
|
|
@@ -82673,7 +82827,8 @@ function preProcessSeqInstruction(nodesToCombine, instrText, _docx, instructionT
|
|
|
82673
82827
|
elements: nodesToCombine
|
|
82674
82828
|
}];
|
|
82675
82829
|
}
|
|
82676
|
-
function preProcessCitationInstruction(nodesToCombine, instrText,
|
|
82830
|
+
function preProcessCitationInstruction(nodesToCombine, instrText, options = {}) {
|
|
82831
|
+
const instructionTokens = options.instructionTokens ?? null;
|
|
82677
82832
|
return [{
|
|
82678
82833
|
name: "sd:citation",
|
|
82679
82834
|
type: "element",
|
|
@@ -82684,10 +82839,11 @@ function preProcessCitationInstruction(nodesToCombine, instrText, _docx, instruc
|
|
|
82684
82839
|
elements: nodesToCombine
|
|
82685
82840
|
}];
|
|
82686
82841
|
}
|
|
82687
|
-
function preProcessBibliographyInstruction(nodesToCombine, instrText,
|
|
82688
|
-
return buildBlockFieldNode("sd:bibliography", nodesToCombine, instrText, instructionTokens);
|
|
82842
|
+
function preProcessBibliographyInstruction(nodesToCombine, instrText, options = {}, legacyInstructionTokens = null) {
|
|
82843
|
+
return buildBlockFieldNode("sd:bibliography", nodesToCombine, instrText, options?.instructionTokens ?? legacyInstructionTokens);
|
|
82689
82844
|
}
|
|
82690
|
-
function preProcessTaInstruction(nodesToCombine, instrText,
|
|
82845
|
+
function preProcessTaInstruction(nodesToCombine, instrText, options = {}) {
|
|
82846
|
+
const instructionTokens = options.instructionTokens ?? null;
|
|
82691
82847
|
return [{
|
|
82692
82848
|
name: "sd:authorityEntry",
|
|
82693
82849
|
type: "element",
|
|
@@ -82698,11 +82854,11 @@ function preProcessTaInstruction(nodesToCombine, instrText, _docx, instructionTo
|
|
|
82698
82854
|
elements: nodesToCombine
|
|
82699
82855
|
}];
|
|
82700
82856
|
}
|
|
82701
|
-
function preProcessToaInstruction(nodesToCombine, instrText,
|
|
82702
|
-
return buildBlockFieldNode("sd:tableOfAuthorities", nodesToCombine, instrText, instructionTokens);
|
|
82857
|
+
function preProcessToaInstruction(nodesToCombine, instrText, options = {}, legacyInstructionTokens = null) {
|
|
82858
|
+
return buildBlockFieldNode("sd:tableOfAuthorities", nodesToCombine, instrText, options?.instructionTokens ?? legacyInstructionTokens);
|
|
82703
82859
|
}
|
|
82704
|
-
function preProcessDocumentStatInstruction(nodesToCombine, instrText,
|
|
82705
|
-
const
|
|
82860
|
+
function preProcessDocumentStatInstruction(nodesToCombine, instrText, options = {}) {
|
|
82861
|
+
const fieldRunRPr = options.fieldRunRPr ?? null;
|
|
82706
82862
|
const statFieldNode = {
|
|
82707
82863
|
name: "sd:documentStatField",
|
|
82708
82864
|
type: "element",
|
|
@@ -82719,10 +82875,13 @@ function preProcessDocumentStatInstruction(nodesToCombine, instrText, _docxOrFie
|
|
|
82719
82875
|
foundContentRPr = true;
|
|
82720
82876
|
}
|
|
82721
82877
|
});
|
|
82722
|
-
if (!foundContentRPr &&
|
|
82723
|
-
statFieldNode.elements = [
|
|
82878
|
+
if (!foundContentRPr && fieldRunRPr && fieldRunRPr.name === "w:rPr")
|
|
82879
|
+
statFieldNode.elements = [fieldRunRPr, ...nodesToCombine];
|
|
82724
82880
|
return [statFieldNode];
|
|
82725
82881
|
}
|
|
82882
|
+
function extractFieldKeyword(instruction) {
|
|
82883
|
+
return String(instruction ?? "").trim().split(/\s+/)[0].toUpperCase();
|
|
82884
|
+
}
|
|
82726
82885
|
function scanFieldSequence(nodes, beginIndex) {
|
|
82727
82886
|
let instrText = "";
|
|
82728
82887
|
let separateIndex = -1;
|
|
@@ -82754,7 +82913,7 @@ function scanFieldSequence(nodes, beginIndex) {
|
|
|
82754
82913
|
if (endIndex === -1)
|
|
82755
82914
|
return null;
|
|
82756
82915
|
return {
|
|
82757
|
-
fieldType: instrText
|
|
82916
|
+
fieldType: extractFieldKeyword(instrText),
|
|
82758
82917
|
instrText: instrText.trim(),
|
|
82759
82918
|
contentNodes,
|
|
82760
82919
|
fieldRunRPr,
|
|
@@ -98239,7 +98398,16 @@ function parseSeqInstruction(instruction) {
|
|
|
98239
98398
|
function extractResolvedText(content$2) {
|
|
98240
98399
|
if (!Array.isArray(content$2))
|
|
98241
98400
|
return "";
|
|
98242
|
-
|
|
98401
|
+
let text$2 = "";
|
|
98402
|
+
for (const node3 of content$2) {
|
|
98403
|
+
if (!node3)
|
|
98404
|
+
continue;
|
|
98405
|
+
if (node3.type === "text")
|
|
98406
|
+
text$2 += node3.text || "";
|
|
98407
|
+
if (Array.isArray(node3.content))
|
|
98408
|
+
text$2 += extractResolvedText(node3.content);
|
|
98409
|
+
}
|
|
98410
|
+
return text$2;
|
|
98243
98411
|
}
|
|
98244
98412
|
function deriveRightAlignPageNumbers(content$2) {
|
|
98245
98413
|
for (const para of content$2) {
|
|
@@ -98250,6 +98418,33 @@ function deriveRightAlignPageNumbers(content$2) {
|
|
|
98250
98418
|
}
|
|
98251
98419
|
return true;
|
|
98252
98420
|
}
|
|
98421
|
+
function pageNumberFormatToInstructionSwitch(pageNumberFormat) {
|
|
98422
|
+
for (const [switchName, format] of Object.entries(PAGE_VALUE_FORMAT_SWITCHES))
|
|
98423
|
+
if (format === pageNumberFormat)
|
|
98424
|
+
return switchName;
|
|
98425
|
+
}
|
|
98426
|
+
function getPageNumberFieldAttrs$1(node3) {
|
|
98427
|
+
const attrs = {};
|
|
98428
|
+
if (node3.attributes?.instruction)
|
|
98429
|
+
attrs.instruction = node3.attributes.instruction;
|
|
98430
|
+
if (node3.attributes?.pageNumberFormat)
|
|
98431
|
+
attrs.pageNumberFormat = node3.attributes.pageNumberFormat;
|
|
98432
|
+
if (node3.attributes?.pageNumberZeroPadding != null)
|
|
98433
|
+
attrs.pageNumberZeroPadding = Number(node3.attributes.pageNumberZeroPadding);
|
|
98434
|
+
return attrs;
|
|
98435
|
+
}
|
|
98436
|
+
function getPageInstructionText(attrs = {}) {
|
|
98437
|
+
if (typeof attrs.instruction === "string" && attrs.instruction.trim())
|
|
98438
|
+
return attrs.instruction.trim();
|
|
98439
|
+
if (typeof attrs.pageNumberFormat === "string") {
|
|
98440
|
+
const instructionSwitch = pageNumberFormatToInstructionSwitch(attrs.pageNumberFormat);
|
|
98441
|
+
if (instructionSwitch)
|
|
98442
|
+
return `PAGE \\* ${instructionSwitch}${typeof attrs.pageNumberZeroPadding === "number" && attrs.pageNumberZeroPadding > 0 ? ` \\# ${"0".repeat(attrs.pageNumberZeroPadding)}` : ""}`;
|
|
98443
|
+
}
|
|
98444
|
+
if (typeof attrs.pageNumberZeroPadding === "number" && attrs.pageNumberZeroPadding > 0)
|
|
98445
|
+
return `PAGE \\# ${"0".repeat(attrs.pageNumberZeroPadding)}`;
|
|
98446
|
+
return "PAGE";
|
|
98447
|
+
}
|
|
98253
98448
|
function buildComplexFieldRuns({ instruction, cachedText, outputMarks, dirty }) {
|
|
98254
98449
|
const beginAttrs = { "w:fldCharType": "begin" };
|
|
98255
98450
|
if (dirty)
|
|
@@ -98315,10 +98510,24 @@ function buildComplexFieldRuns({ instruction, cachedText, outputMarks, dirty })
|
|
|
98315
98510
|
}
|
|
98316
98511
|
];
|
|
98317
98512
|
}
|
|
98513
|
+
function getPageNumberFieldAttrs(node3) {
|
|
98514
|
+
const attrs = {};
|
|
98515
|
+
if (node3.attributes?.instruction)
|
|
98516
|
+
attrs.instruction = node3.attributes.instruction;
|
|
98517
|
+
if (node3.attributes?.pageNumberFormat)
|
|
98518
|
+
attrs.pageNumberFormat = node3.attributes.pageNumberFormat;
|
|
98519
|
+
if (node3.attributes?.pageNumberZeroPadding != null)
|
|
98520
|
+
attrs.pageNumberZeroPadding = Number(node3.attributes.pageNumberZeroPadding);
|
|
98521
|
+
return attrs;
|
|
98522
|
+
}
|
|
98318
98523
|
function resolveCachedPageCount(params3, node3) {
|
|
98319
98524
|
const cacheMap = params3.statFieldCacheMap;
|
|
98320
|
-
if (cacheMap?.has?.("NUMPAGES"))
|
|
98525
|
+
if (cacheMap?.has?.("NUMPAGES")) {
|
|
98526
|
+
const pageCount = Number(cacheMap.get("NUMPAGES"));
|
|
98527
|
+
if (node3.attrs?.pageNumberFormat || node3.attrs?.pageNumberZeroPadding)
|
|
98528
|
+
return formatPageNumberFieldValue(pageCount, node3.attrs);
|
|
98321
98529
|
return String(cacheMap.get("NUMPAGES"));
|
|
98530
|
+
}
|
|
98322
98531
|
if (node3.attrs?.resolvedText)
|
|
98323
98532
|
return String(node3.attrs.resolvedText);
|
|
98324
98533
|
if (node3.attrs?.importedCachedText)
|
|
@@ -102320,6 +102529,18 @@ function computeWordParagraphLayout(input) {
|
|
|
102320
102529
|
};
|
|
102321
102530
|
return layout;
|
|
102322
102531
|
}
|
|
102532
|
+
function getPageNumberFieldFormat(attrs) {
|
|
102533
|
+
if (!attrs)
|
|
102534
|
+
return;
|
|
102535
|
+
const format = typeof attrs.pageNumberFormat === "string" ? attrs.pageNumberFormat : undefined;
|
|
102536
|
+
const zeroPadding = typeof attrs.pageNumberZeroPadding === "number" && Number.isFinite(attrs.pageNumberZeroPadding) ? attrs.pageNumberZeroPadding : undefined;
|
|
102537
|
+
if (!format && !zeroPadding)
|
|
102538
|
+
return;
|
|
102539
|
+
return {
|
|
102540
|
+
...format ? { format } : {},
|
|
102541
|
+
...zeroPadding ? { zeroPadding } : {}
|
|
102542
|
+
};
|
|
102543
|
+
}
|
|
102323
102544
|
function textNodeToRun({ node: node3, positions, storyKey, defaultFont, defaultSize, inheritedMarks = [], sdtMetadata, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors, enableComments, runProperties, inlineRunProperties, converterContext }) {
|
|
102324
102545
|
let run$1 = {
|
|
102325
102546
|
text: node3.text || "",
|
|
@@ -103545,6 +103766,9 @@ function tokenNodeToRun({ node: node3, positions, storyKey, defaultFont, default
|
|
|
103545
103766
|
fontFamily: defaultFont,
|
|
103546
103767
|
fontSize: defaultSize
|
|
103547
103768
|
};
|
|
103769
|
+
const pageNumberFieldFormat = getPageNumberFieldFormat(node3.attrs);
|
|
103770
|
+
if (pageNumberFieldFormat)
|
|
103771
|
+
run$1.pageNumberFieldFormat = pageNumberFieldFormat;
|
|
103548
103772
|
const pos = positions.get(node3);
|
|
103549
103773
|
if (pos) {
|
|
103550
103774
|
run$1.pmStart = pos.start;
|
|
@@ -107647,31 +107871,29 @@ function createHeaderFooterPart(editor, input) {
|
|
|
107647
107871
|
throw new Error(`[createHeaderFooterPart] Failed to create ${newPartPath}: mutation rolled back (possible afterCommit degradation).`);
|
|
107648
107872
|
return finalResult;
|
|
107649
107873
|
}
|
|
107650
|
-
function resolveEffectiveRef(
|
|
107651
|
-
|
|
107652
|
-
|
|
107653
|
-
|
|
107654
|
-
|
|
107655
|
-
|
|
107656
|
-
|
|
107657
|
-
|
|
107658
|
-
|
|
107659
|
-
|
|
107660
|
-
|
|
107661
|
-
|
|
107662
|
-
|
|
107663
|
-
|
|
107664
|
-
|
|
107665
|
-
|
|
107666
|
-
|
|
107667
|
-
|
|
107668
|
-
|
|
107669
|
-
|
|
107670
|
-
|
|
107671
|
-
|
|
107672
|
-
|
|
107673
|
-
}
|
|
107674
|
-
return null;
|
|
107874
|
+
function resolveEffectiveRef(sections, startSectionIndex, kind, variant) {
|
|
107875
|
+
const refsFor = (section, refKind) => refKind === "header" ? section.range.headerRefs ?? section.domain.headerRefs : section.range.footerRefs ?? section.domain.footerRefs;
|
|
107876
|
+
const resolved = resolveEffectiveHeaderFooterRef({
|
|
107877
|
+
sections: sections.map((section) => ({
|
|
107878
|
+
sectionIndex: section.range.sectionIndex,
|
|
107879
|
+
titlePg: section.range.titlePg,
|
|
107880
|
+
headerRefs: refsFor(section, "header"),
|
|
107881
|
+
footerRefs: refsFor(section, "footer")
|
|
107882
|
+
})),
|
|
107883
|
+
sectionIndex: startSectionIndex - 1,
|
|
107884
|
+
kind,
|
|
107885
|
+
variant
|
|
107886
|
+
});
|
|
107887
|
+
if (!resolved)
|
|
107888
|
+
return null;
|
|
107889
|
+
const resolvedSection = sections.find((section) => section.range.sectionIndex === resolved.matchedSectionIndex);
|
|
107890
|
+
if (!resolvedSection)
|
|
107891
|
+
return null;
|
|
107892
|
+
return {
|
|
107893
|
+
refId: resolved.refId,
|
|
107894
|
+
resolvedFromSection: resolvedSection.address,
|
|
107895
|
+
resolvedVariant: resolved.matchedVariant
|
|
107896
|
+
};
|
|
107675
107897
|
}
|
|
107676
107898
|
function getConverter$5(editor) {
|
|
107677
107899
|
return editor.converter;
|
|
@@ -107748,7 +107970,7 @@ function setLinkedToPreviousMutation(sectPr, projection, sections, kind, variant
|
|
|
107748
107970
|
message: `${operationName} already has an explicit reference.`
|
|
107749
107971
|
}
|
|
107750
107972
|
};
|
|
107751
|
-
const resolved = resolveEffectiveRef(
|
|
107973
|
+
const resolved = resolveEffectiveRef(sections, projection.range.sectionIndex, kind, variant);
|
|
107752
107974
|
if (dryRun) {
|
|
107753
107975
|
setSectPrHeaderFooterRef(sectPr, kind, variant, "(dry-run)");
|
|
107754
107976
|
return;
|
|
@@ -108264,7 +108486,7 @@ function ensureExplicitHeaderFooterSlot(editor, input) {
|
|
|
108264
108486
|
created: false
|
|
108265
108487
|
};
|
|
108266
108488
|
}
|
|
108267
|
-
const inheritedRef = resolveEffectiveRef(
|
|
108489
|
+
const inheritedRef = resolveEffectiveRef(sections, sections.indexOf(projection), kind, variant);
|
|
108268
108490
|
const effectiveSourceRefId = sourceRefId ?? inheritedRef?.refId ?? undefined;
|
|
108269
108491
|
let result = null;
|
|
108270
108492
|
if (!compoundMutation({
|
|
@@ -108331,7 +108553,7 @@ function resolveHeaderFooterSlotRuntime(hostEditor, locator, options = {}) {
|
|
|
108331
108553
|
storyKey,
|
|
108332
108554
|
resolution
|
|
108333
108555
|
});
|
|
108334
|
-
effectiveRefId = resolveEffectiveRef(
|
|
108556
|
+
effectiveRefId = resolveEffectiveRef(sections, projection.range.sectionIndex, headerFooterKind, variant)?.refId ?? null;
|
|
108335
108557
|
}
|
|
108336
108558
|
const isInherited = explicitRefId === null;
|
|
108337
108559
|
const onWrite = locator.onWrite ?? "materializeIfInherited";
|
|
@@ -118931,8 +119153,9 @@ var isRegExp = (value) => {
|
|
|
118931
119153
|
domEnvironment$1 = env || null;
|
|
118932
119154
|
}, 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) => {
|
|
118933
119155
|
domEnvironment = env || null;
|
|
118934
|
-
}, getInstructionPreProcessor = (instruction) => {
|
|
118935
|
-
|
|
119156
|
+
}, GENERAL_FORMATS, CASE_INSENSITIVE_GENERAL_FORMATS, getInstructionPreProcessor = (instruction) => {
|
|
119157
|
+
const rawInstructionType = String(instruction ?? "").trim().split(/\s+/)[0];
|
|
119158
|
+
switch (extractFieldKeyword(instruction)) {
|
|
118936
119159
|
case "PAGE":
|
|
118937
119160
|
return preProcessPageInstruction;
|
|
118938
119161
|
case "NUMPAGES":
|
|
@@ -118959,6 +119182,8 @@ var isRegExp = (value) => {
|
|
|
118959
119182
|
case "STYLEREF":
|
|
118960
119183
|
return preProcessStylerefInstruction;
|
|
118961
119184
|
case "SEQ":
|
|
119185
|
+
if (rawInstructionType !== "SEQ")
|
|
119186
|
+
return null;
|
|
118962
119187
|
return preProcessSeqInstruction;
|
|
118963
119188
|
case "CITATION":
|
|
118964
119189
|
return preProcessCitationInstruction;
|
|
@@ -119032,10 +119257,9 @@ var isRegExp = (value) => {
|
|
|
119032
119257
|
if (node3.name === "w:fldSimple") {
|
|
119033
119258
|
const instr = node3.attributes?.["w:instr"];
|
|
119034
119259
|
if (typeof instr === "string") {
|
|
119035
|
-
const
|
|
119036
|
-
const instructionPreProcessor = getInstructionPreProcessor(instructionType);
|
|
119260
|
+
const instructionPreProcessor = getInstructionPreProcessor(instr);
|
|
119037
119261
|
if (instructionPreProcessor) {
|
|
119038
|
-
const processed = instructionPreProcessor(node3.elements ?? [], instr, docx
|
|
119262
|
+
const processed = instructionPreProcessor(node3.elements ?? [], instr, { docx });
|
|
119039
119263
|
if (collecting) {
|
|
119040
119264
|
collectedNodesStack[collectedNodesStack.length - 1].push(...processed);
|
|
119041
119265
|
rawCollectedNodesStack[rawCollectedNodesStack.length - 1].push(...processed);
|
|
@@ -119167,11 +119391,14 @@ var isRegExp = (value) => {
|
|
|
119167
119391
|
unpairedEndPreserveRaw
|
|
119168
119392
|
};
|
|
119169
119393
|
}, _processCombinedNodesForFldChar = (nodesToCombine = [], instrText, docx, instructionTokens, fieldRunRPr) => {
|
|
119170
|
-
const
|
|
119171
|
-
const instructionPreProcessor = getInstructionPreProcessor(instructionType);
|
|
119394
|
+
const instructionPreProcessor = getInstructionPreProcessor(instrText);
|
|
119172
119395
|
if (instructionPreProcessor)
|
|
119173
119396
|
return {
|
|
119174
|
-
nodes: instructionPreProcessor(nodesToCombine, instrText,
|
|
119397
|
+
nodes: instructionPreProcessor(nodesToCombine, instrText, {
|
|
119398
|
+
docx,
|
|
119399
|
+
instructionTokens,
|
|
119400
|
+
fieldRunRPr
|
|
119401
|
+
}),
|
|
119175
119402
|
handled: true
|
|
119176
119403
|
};
|
|
119177
119404
|
return {
|
|
@@ -119179,7 +119406,7 @@ var isRegExp = (value) => {
|
|
|
119179
119406
|
handled: false
|
|
119180
119407
|
};
|
|
119181
119408
|
}, applyConstructiveFieldInterpretation = (rawNodes, instrText, docx) => {
|
|
119182
|
-
if (instrText
|
|
119409
|
+
if (extractFieldKeyword(instrText) !== "HYPERLINK")
|
|
119183
119410
|
return;
|
|
119184
119411
|
const linkAttributes = resolveHyperlinkAttributes(instrText, docx);
|
|
119185
119412
|
if (!linkAttributes)
|
|
@@ -119334,8 +119561,7 @@ var isRegExp = (value) => {
|
|
|
119334
119561
|
const fldType = node3.elements?.find((el) => el.name === "w:fldChar")?.attributes?.["w:fldCharType"];
|
|
119335
119562
|
if (node3.name === "w:fldSimple") {
|
|
119336
119563
|
const instrAttr = node3.attributes?.["w:instr"] || "";
|
|
119337
|
-
const
|
|
119338
|
-
const fldSimplePreprocessor = getHeaderFooterFieldPreprocessor(fieldType);
|
|
119564
|
+
const fldSimplePreprocessor = getHeaderFooterFieldPreprocessor(extractFieldKeyword(instrAttr));
|
|
119339
119565
|
if (fldSimplePreprocessor) {
|
|
119340
119566
|
const contentNodes = node3.elements || [];
|
|
119341
119567
|
let fieldRunRPr = null;
|
|
@@ -119346,7 +119572,7 @@ var isRegExp = (value) => {
|
|
|
119346
119572
|
break;
|
|
119347
119573
|
}
|
|
119348
119574
|
}
|
|
119349
|
-
const processedField = fldSimplePreprocessor(contentNodes, instrAttr.trim(), fieldRunRPr);
|
|
119575
|
+
const processedField = fldSimplePreprocessor(contentNodes, instrAttr.trim(), { fieldRunRPr });
|
|
119350
119576
|
processedNodes.push(...processedField);
|
|
119351
119577
|
i$1++;
|
|
119352
119578
|
continue;
|
|
@@ -119368,7 +119594,7 @@ var isRegExp = (value) => {
|
|
|
119368
119594
|
if (fieldInfo && complexFieldPreprocessor) {
|
|
119369
119595
|
const preprocessor = complexFieldPreprocessor;
|
|
119370
119596
|
const contentNodes = fieldInfo.contentNodes;
|
|
119371
|
-
const processedField = preprocessor(contentNodes, fieldInfo.instrText, fieldInfo.fieldRunRPr);
|
|
119597
|
+
const processedField = preprocessor(contentNodes, fieldInfo.instrText, { fieldRunRPr: fieldInfo.fieldRunRPr });
|
|
119372
119598
|
processedNodes.push(...processedField);
|
|
119373
119599
|
i$1 = fieldInfo.endIndex + 1;
|
|
119374
119600
|
continue;
|
|
@@ -119384,7 +119610,7 @@ var isRegExp = (value) => {
|
|
|
119384
119610
|
}
|
|
119385
119611
|
}
|
|
119386
119612
|
if (node3.name === "w:r" && node3.elements?.some((el) => el.name === "w:pgNum")) {
|
|
119387
|
-
const processedField = preProcessPageInstruction([], "", node3.elements.find((el) => el.name === "w:rPr") || null);
|
|
119613
|
+
const processedField = preProcessPageInstruction([], "", { fieldRunRPr: node3.elements.find((el) => el.name === "w:rPr") || null });
|
|
119388
119614
|
processedNodes.push(...processedField);
|
|
119389
119615
|
i$1++;
|
|
119390
119616
|
continue;
|
|
@@ -125170,16 +125396,26 @@ var isRegExp = (value) => {
|
|
|
125170
125396
|
}]
|
|
125171
125397
|
}
|
|
125172
125398
|
];
|
|
125173
|
-
}, config$9, translator$26, XML_NODE_NAME$7 = "sd:autoPageNumber", SD_NODE_NAME$7 = "page-number", encode$11 = (params3) => {
|
|
125399
|
+
}, config$9, translator$26, PAGE_VALUE_FORMAT_SWITCHES, XML_NODE_NAME$7 = "sd:autoPageNumber", SD_NODE_NAME$7 = "page-number", encode$11 = (params3) => {
|
|
125174
125400
|
const { nodes = [] } = params3 || {};
|
|
125175
|
-
const
|
|
125176
|
-
|
|
125401
|
+
const node3 = nodes[0];
|
|
125402
|
+
const rPr = node3.elements?.find((el) => el.name === "w:rPr");
|
|
125403
|
+
const processedNode = {
|
|
125177
125404
|
type: "page-number",
|
|
125178
|
-
attrs: {
|
|
125405
|
+
attrs: {
|
|
125406
|
+
marksAsAttrs: parseMarks(rPr || { elements: [] }),
|
|
125407
|
+
...getPageNumberFieldAttrs$1(node3)
|
|
125408
|
+
}
|
|
125179
125409
|
};
|
|
125410
|
+
if (typeof node3.attributes?.instruction === "string")
|
|
125411
|
+
processedNode.attrs.instruction = node3.attributes.instruction;
|
|
125412
|
+
if (typeof node3.attributes?.pageNumberFormat === "string")
|
|
125413
|
+
processedNode.attrs.pageNumberFormat = node3.attributes.pageNumberFormat;
|
|
125414
|
+
return processedNode;
|
|
125180
125415
|
}, decode$11 = (params3) => {
|
|
125181
125416
|
const { node: node3 } = params3;
|
|
125182
125417
|
const outputMarks = processOutputMarks(node3.attrs?.marksAsAttrs || []);
|
|
125418
|
+
const instruction = getPageInstructionText(node3.attrs);
|
|
125183
125419
|
return [
|
|
125184
125420
|
{
|
|
125185
125421
|
name: "w:r",
|
|
@@ -125201,7 +125437,7 @@ var isRegExp = (value) => {
|
|
|
125201
125437
|
attributes: { "xml:space": "preserve" },
|
|
125202
125438
|
elements: [{
|
|
125203
125439
|
type: "text",
|
|
125204
|
-
text:
|
|
125440
|
+
text: ` ${instruction}`
|
|
125205
125441
|
}]
|
|
125206
125442
|
}]
|
|
125207
125443
|
},
|
|
@@ -125234,17 +125470,20 @@ var isRegExp = (value) => {
|
|
|
125234
125470
|
type: "total-page-number",
|
|
125235
125471
|
attrs: {
|
|
125236
125472
|
marksAsAttrs: parseMarks(rPr || { elements: [] }),
|
|
125237
|
-
importedCachedText: node3.attributes?.importedCachedText || null
|
|
125473
|
+
importedCachedText: node3.attributes?.importedCachedText || null,
|
|
125474
|
+
...getPageNumberFieldAttrs(node3)
|
|
125238
125475
|
}
|
|
125239
125476
|
};
|
|
125240
125477
|
}, decode$10 = (params3) => {
|
|
125241
125478
|
const { node: node3 } = params3;
|
|
125242
125479
|
const outputMarks = processOutputMarks(node3.attrs?.marksAsAttrs || []);
|
|
125480
|
+
const cachedText = resolveCachedPageCount(params3, node3);
|
|
125481
|
+
const dirty = !params3.statFieldCacheMap?.has?.("NUMPAGES");
|
|
125243
125482
|
return buildComplexFieldRuns({
|
|
125244
|
-
instruction: "NUMPAGES",
|
|
125245
|
-
cachedText
|
|
125483
|
+
instruction: node3.attrs?.instruction || "NUMPAGES",
|
|
125484
|
+
cachedText,
|
|
125246
125485
|
outputMarks,
|
|
125247
|
-
dirty
|
|
125486
|
+
dirty
|
|
125248
125487
|
});
|
|
125249
125488
|
}, config$7, translator$28, XML_NODE_NAME$5 = "sd:documentStatField", SD_NODE_NAME$5 = "documentStatField", encode$9 = (params3) => {
|
|
125250
125489
|
const { nodes = [] } = params3 || {};
|
|
@@ -130806,7 +131045,7 @@ var isRegExp = (value) => {
|
|
|
130806
131045
|
state.kern = kernNode.attributes["w:val"];
|
|
130807
131046
|
}
|
|
130808
131047
|
}, SuperConverter;
|
|
130809
|
-
var
|
|
131048
|
+
var init_SuperConverter_CvwFiCth_es = __esm(() => {
|
|
130810
131049
|
init_rolldown_runtime_Bg48TavK_es();
|
|
130811
131050
|
init_jszip_C49i9kUs_es();
|
|
130812
131051
|
init_xml_js_CqGKpaft_es();
|
|
@@ -159390,6 +159629,16 @@ var init_SuperConverter_CcHCWpfX_es = __esm(() => {
|
|
|
159390
159629
|
})(UTIF, pako$1);
|
|
159391
159630
|
})();
|
|
159392
159631
|
}))(), 1);
|
|
159632
|
+
GENERAL_FORMATS = new Map([
|
|
159633
|
+
["Arabic", "decimal"],
|
|
159634
|
+
["roman", "lowerRoman"],
|
|
159635
|
+
["Roman", "upperRoman"],
|
|
159636
|
+
["ROMAN", "upperRoman"],
|
|
159637
|
+
["alphabetic", "lowerLetter"],
|
|
159638
|
+
["ALPHABETIC", "upperLetter"],
|
|
159639
|
+
["ArabicDash", "numberInDash"]
|
|
159640
|
+
]);
|
|
159641
|
+
CASE_INSENSITIVE_GENERAL_FORMATS = new Map([["arabic", "decimal"], ["arabicdash", "numberInDash"]]);
|
|
159393
159642
|
TRACK_CHANGE_ELEMENT_NAMES = new Set([
|
|
159394
159643
|
"w:del",
|
|
159395
159644
|
"w:ins",
|
|
@@ -167092,6 +167341,15 @@ var init_SuperConverter_CcHCWpfX_es = __esm(() => {
|
|
|
167092
167341
|
decode: decode$12
|
|
167093
167342
|
};
|
|
167094
167343
|
translator$26 = NodeTranslator.from(config$9);
|
|
167344
|
+
PAGE_VALUE_FORMAT_SWITCHES = {
|
|
167345
|
+
Arabic: "decimal",
|
|
167346
|
+
Roman: "upperRoman",
|
|
167347
|
+
ROMAN: "upperRoman",
|
|
167348
|
+
roman: "lowerRoman",
|
|
167349
|
+
ALPHABETIC: "upperLetter",
|
|
167350
|
+
alphabetic: "lowerLetter",
|
|
167351
|
+
ArabicDash: "numberInDash"
|
|
167352
|
+
};
|
|
167095
167353
|
config$8 = {
|
|
167096
167354
|
xmlName: XML_NODE_NAME$7,
|
|
167097
167355
|
sdNodeOrKeyName: SD_NODE_NAME$7,
|
|
@@ -169580,7 +169838,7 @@ var init_SuperConverter_CcHCWpfX_es = __esm(() => {
|
|
|
169580
169838
|
};
|
|
169581
169839
|
});
|
|
169582
169840
|
|
|
169583
|
-
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-
|
|
169841
|
+
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-DdDLS67b.es.js
|
|
169584
169842
|
function parseSizeUnit(val = "0") {
|
|
169585
169843
|
const length3 = val.toString() || "0";
|
|
169586
169844
|
const value = Number.parseFloat(length3);
|
|
@@ -179911,8 +180169,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
|
|
|
179911
180169
|
}
|
|
179912
180170
|
};
|
|
179913
180171
|
};
|
|
179914
|
-
var
|
|
179915
|
-
|
|
180172
|
+
var init_create_headless_toolbar_DdDLS67b_es = __esm(() => {
|
|
180173
|
+
init_SuperConverter_CvwFiCth_es();
|
|
179916
180174
|
init_uuid_qzgm05fK_es();
|
|
179917
180175
|
init_constants_D_X7xF4s_es();
|
|
179918
180176
|
init_dist_B8HfvhaK_es();
|
|
@@ -229075,7 +229333,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
|
|
|
229075
229333
|
init_remark_gfm_BhnWr3yf_es();
|
|
229076
229334
|
});
|
|
229077
229335
|
|
|
229078
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
229336
|
+
// ../../packages/superdoc/dist/chunks/src-BbNQjpxw.es.js
|
|
229079
229337
|
function deleteProps(obj, propOrProps) {
|
|
229080
229338
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
229081
229339
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -260004,7 +260262,7 @@ function headerFootersResolveAdapter(editor, input2) {
|
|
|
260004
260262
|
section: projection.address
|
|
260005
260263
|
};
|
|
260006
260264
|
}
|
|
260007
|
-
const resolved = resolveEffectiveRef(
|
|
260265
|
+
const resolved = resolveEffectiveRef(sections, projection.range.sectionIndex, headerFooterKind, variant);
|
|
260008
260266
|
if (resolved)
|
|
260009
260267
|
return {
|
|
260010
260268
|
status: "inherited",
|
|
@@ -268737,6 +268995,55 @@ function convertOmmlToMathml(ommlJson, doc$12) {
|
|
|
268737
268995
|
function isMinimalWordLayout$1(value) {
|
|
268738
268996
|
return isMinimalWordLayout(value);
|
|
268739
268997
|
}
|
|
268998
|
+
function pageContextSignature(context) {
|
|
268999
|
+
return [
|
|
269000
|
+
context.pageNumber,
|
|
269001
|
+
context.totalPages,
|
|
269002
|
+
context.pageNumberText ?? "",
|
|
269003
|
+
context.displayPageNumber ?? ""
|
|
269004
|
+
].join("|");
|
|
269005
|
+
}
|
|
269006
|
+
function hasPageContextTokenInShapeText(textContent$1) {
|
|
269007
|
+
return Array.isArray(textContent$1?.parts) && textContent$1.parts.some((part) => part.fieldType === "PAGE" || part.fieldType === "NUMPAGES");
|
|
269008
|
+
}
|
|
269009
|
+
function hasPageContextTokenInShapeGroup(shapes) {
|
|
269010
|
+
return Array.isArray(shapes) && shapes.some((shape) => {
|
|
269011
|
+
if (shape.shapeType !== "vectorShape")
|
|
269012
|
+
return false;
|
|
269013
|
+
return hasPageContextTokenInShapeText(shape.attrs.textContent);
|
|
269014
|
+
});
|
|
269015
|
+
}
|
|
269016
|
+
function hasPageContextTokenInBlock(block) {
|
|
269017
|
+
if (!block)
|
|
269018
|
+
return false;
|
|
269019
|
+
if (block.kind === "paragraph") {
|
|
269020
|
+
for (const run2 of block.runs)
|
|
269021
|
+
if ("token" in run2 && (run2.token === "pageNumber" || run2.token === "totalPageCount"))
|
|
269022
|
+
return true;
|
|
269023
|
+
} else if (block.kind === "list") {
|
|
269024
|
+
const list5 = block;
|
|
269025
|
+
for (const item of list5.items ?? [])
|
|
269026
|
+
if (hasPageContextTokenInBlock(item.paragraph))
|
|
269027
|
+
return true;
|
|
269028
|
+
} else if (block.kind === "table") {
|
|
269029
|
+
const table2 = block;
|
|
269030
|
+
for (const row2 of table2.rows ?? [])
|
|
269031
|
+
for (const cell2 of row2.cells ?? [])
|
|
269032
|
+
if ((cell2.blocks ? cell2.blocks : cell2.paragraph ? [cell2.paragraph] : []).some(hasPageContextTokenInBlock))
|
|
269033
|
+
return true;
|
|
269034
|
+
} else if (block.kind === "drawing") {
|
|
269035
|
+
const drawing = block;
|
|
269036
|
+
if (drawing.drawingKind === "vectorShape")
|
|
269037
|
+
return hasPageContextTokenInShapeText(drawing.textContent);
|
|
269038
|
+
if (drawing.drawingKind === "shapeGroup")
|
|
269039
|
+
return hasPageContextTokenInShapeGroup(drawing.shapes);
|
|
269040
|
+
}
|
|
269041
|
+
return false;
|
|
269042
|
+
}
|
|
269043
|
+
function needsRebuildForPageContext(currentContext, nextContext, resolvedItem) {
|
|
269044
|
+
const block = resolvedItem?.kind === "fragment" && "block" in resolvedItem ? resolvedItem.block : undefined;
|
|
269045
|
+
return pageContextSignature(currentContext) !== pageContextSignature(nextContext) && hasPageContextTokenInBlock(block);
|
|
269046
|
+
}
|
|
268740
269047
|
function roundSnapshotMetric(value) {
|
|
268741
269048
|
if (!Number.isFinite(value))
|
|
268742
269049
|
return null;
|
|
@@ -269533,6 +269840,7 @@ function resolveLayout(input2) {
|
|
|
269533
269840
|
footnoteReserved: page.footnoteReserved,
|
|
269534
269841
|
displayNumber: page.displayNumber,
|
|
269535
269842
|
numberText: page.numberText,
|
|
269843
|
+
effectivePageNumber: page.effectivePageNumber,
|
|
269536
269844
|
vAlign: page.vAlign,
|
|
269537
269845
|
baseMargins: page.baseMargins,
|
|
269538
269846
|
sectionIndex: page.sectionIndex,
|
|
@@ -271952,85 +272260,6 @@ function createPaginator(opts) {
|
|
|
271952
272260
|
pruneTrailingEmptyPages
|
|
271953
272261
|
};
|
|
271954
272262
|
}
|
|
271955
|
-
function toUpperRoman2(num) {
|
|
271956
|
-
if (num < 1 || num > 3999)
|
|
271957
|
-
return String(num);
|
|
271958
|
-
const values = [
|
|
271959
|
-
1000,
|
|
271960
|
-
900,
|
|
271961
|
-
500,
|
|
271962
|
-
400,
|
|
271963
|
-
100,
|
|
271964
|
-
90,
|
|
271965
|
-
50,
|
|
271966
|
-
40,
|
|
271967
|
-
10,
|
|
271968
|
-
9,
|
|
271969
|
-
5,
|
|
271970
|
-
4,
|
|
271971
|
-
1
|
|
271972
|
-
];
|
|
271973
|
-
const numerals = [
|
|
271974
|
-
"M",
|
|
271975
|
-
"CM",
|
|
271976
|
-
"D",
|
|
271977
|
-
"CD",
|
|
271978
|
-
"C",
|
|
271979
|
-
"XC",
|
|
271980
|
-
"L",
|
|
271981
|
-
"XL",
|
|
271982
|
-
"X",
|
|
271983
|
-
"IX",
|
|
271984
|
-
"V",
|
|
271985
|
-
"IV",
|
|
271986
|
-
"I"
|
|
271987
|
-
];
|
|
271988
|
-
let result = "";
|
|
271989
|
-
let remaining = num;
|
|
271990
|
-
for (let i4 = 0;i4 < values.length; i4++)
|
|
271991
|
-
while (remaining >= values[i4]) {
|
|
271992
|
-
result += numerals[i4];
|
|
271993
|
-
remaining -= values[i4];
|
|
271994
|
-
}
|
|
271995
|
-
return result;
|
|
271996
|
-
}
|
|
271997
|
-
function toLowerRoman(num) {
|
|
271998
|
-
return toUpperRoman2(num).toLowerCase();
|
|
271999
|
-
}
|
|
272000
|
-
function toUpperLetter2(num) {
|
|
272001
|
-
if (num < 1)
|
|
272002
|
-
return "A";
|
|
272003
|
-
let result = "";
|
|
272004
|
-
let n = num;
|
|
272005
|
-
while (n > 0) {
|
|
272006
|
-
const remainder = (n - 1) % 26;
|
|
272007
|
-
result = String.fromCharCode(65 + remainder) + result;
|
|
272008
|
-
n = Math.floor((n - 1) / 26);
|
|
272009
|
-
}
|
|
272010
|
-
return result;
|
|
272011
|
-
}
|
|
272012
|
-
function toLowerLetter(num) {
|
|
272013
|
-
return toUpperLetter2(num).toLowerCase();
|
|
272014
|
-
}
|
|
272015
|
-
function formatPageNumber(pageNumber, format) {
|
|
272016
|
-
const num = Math.max(1, pageNumber);
|
|
272017
|
-
switch (format) {
|
|
272018
|
-
case "decimal":
|
|
272019
|
-
return String(num);
|
|
272020
|
-
case "upperRoman":
|
|
272021
|
-
return toUpperRoman2(num);
|
|
272022
|
-
case "lowerRoman":
|
|
272023
|
-
return toLowerRoman(num);
|
|
272024
|
-
case "upperLetter":
|
|
272025
|
-
return toUpperLetter2(num);
|
|
272026
|
-
case "lowerLetter":
|
|
272027
|
-
return toLowerLetter(num);
|
|
272028
|
-
case "numberInDash":
|
|
272029
|
-
return `-${num}-`;
|
|
272030
|
-
default:
|
|
272031
|
-
return String(num);
|
|
272032
|
-
}
|
|
272033
|
-
}
|
|
272034
272263
|
function computeDisplayPageNumber(pages, sections) {
|
|
272035
272264
|
const result = [];
|
|
272036
272265
|
if (pages.length === 0)
|
|
@@ -272495,7 +272724,6 @@ function resolvePageNumberTokens(layout, blocks2, measures, numberingCtx) {
|
|
|
272495
272724
|
console.warn(`[resolvePageTokens] No display page info for page ${page.number} - skipping`);
|
|
272496
272725
|
continue;
|
|
272497
272726
|
}
|
|
272498
|
-
const displayPageText = displayPageInfo.displayText;
|
|
272499
272727
|
for (const fragment2 of page.fragments)
|
|
272500
272728
|
if (fragment2.kind === "para") {
|
|
272501
272729
|
const blockId = fragment2.blockId;
|
|
@@ -272510,7 +272738,7 @@ function resolvePageNumberTokens(layout, blocks2, measures, numberingCtx) {
|
|
|
272510
272738
|
processedBlocks.add(blockId);
|
|
272511
272739
|
continue;
|
|
272512
272740
|
}
|
|
272513
|
-
const clonedBlock = cloneBlockWithResolvedTokens(block,
|
|
272741
|
+
const clonedBlock = cloneBlockWithResolvedTokens(block, displayPageInfo, totalPagesStr, numberingCtx.totalPages);
|
|
272514
272742
|
updatedBlocks.set(blockId, clonedBlock);
|
|
272515
272743
|
affectedBlockIds.add(blockId);
|
|
272516
272744
|
processedBlocks.add(blockId);
|
|
@@ -272528,20 +272756,20 @@ function hasPageTokens$1(block) {
|
|
|
272528
272756
|
return true;
|
|
272529
272757
|
return false;
|
|
272530
272758
|
}
|
|
272531
|
-
function cloneBlockWithResolvedTokens(block,
|
|
272759
|
+
function cloneBlockWithResolvedTokens(block, displayPageInfo, totalPagesStr, totalPages) {
|
|
272532
272760
|
const clonedRuns = block.runs.map((run2) => {
|
|
272533
272761
|
if ("token" in run2 && run2.token) {
|
|
272534
272762
|
if (run2.token === "pageNumber") {
|
|
272535
|
-
const { token: _token, ...runWithoutToken } = run2;
|
|
272763
|
+
const { token: _token, pageNumberFieldFormat, ...runWithoutToken } = run2;
|
|
272536
272764
|
return {
|
|
272537
272765
|
...runWithoutToken,
|
|
272538
|
-
text:
|
|
272766
|
+
text: pageNumberFieldFormat ? formatPageNumberFieldValue$1(displayPageInfo.displayNumber, pageNumberFieldFormat) : displayPageInfo.displayText
|
|
272539
272767
|
};
|
|
272540
272768
|
} else if (run2.token === "totalPageCount") {
|
|
272541
272769
|
const { token: _token, ...runWithoutToken } = run2;
|
|
272542
272770
|
return {
|
|
272543
272771
|
...runWithoutToken,
|
|
272544
|
-
text: totalPagesStr
|
|
272772
|
+
text: run2.pageNumberFieldFormat ? formatPageNumberFieldValue$1(totalPages, run2.pageNumberFieldFormat) : totalPagesStr
|
|
272545
272773
|
};
|
|
272546
272774
|
}
|
|
272547
272775
|
}
|
|
@@ -272731,13 +272959,6 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
272731
272959
|
const headerContentHeightsBySectionRef = options.headerContentHeightsBySectionRef;
|
|
272732
272960
|
const footerContentHeightsByRId = options.footerContentHeightsByRId;
|
|
272733
272961
|
const footerContentHeightsBySectionRef = options.footerContentHeightsBySectionRef;
|
|
272734
|
-
const getVariantTypeForPage = (args$1) => {
|
|
272735
|
-
if (args$1.sectionPageNumber === 1 && args$1.titlePgEnabled)
|
|
272736
|
-
return "first";
|
|
272737
|
-
if (args$1.alternateHeaders)
|
|
272738
|
-
return args$1.parityPageNumber % 2 === 0 ? "even" : "odd";
|
|
272739
|
-
return "default";
|
|
272740
|
-
};
|
|
272741
272962
|
const getHeaderHeightForPage = (variantType, headerRef, sectionIndex) => {
|
|
272742
272963
|
if (headerRef && sectionIndex != null) {
|
|
272743
272964
|
const sectionKey = buildSectionAwareReferenceKey(headerRef, sectionIndex);
|
|
@@ -272804,9 +273025,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
272804
273025
|
const maxFooterContentHeight = footerContentHeights ? Math.max(0, validateContentHeight(footerContentHeights.default), validateContentHeight(footerContentHeights.first), validateContentHeight(footerContentHeights.even), validateContentHeight(footerContentHeights.odd)) : 0;
|
|
272805
273026
|
const headerDistance = margins.header ?? margins.top;
|
|
272806
273027
|
const footerDistance = margins.footer ?? margins.bottom;
|
|
272807
|
-
const
|
|
272808
|
-
const defaultFooterHeight = getFooterHeightForPage("default", undefined, 0);
|
|
272809
|
-
const effectiveMargins = clampHeaderFooterInflatedMargins(calculateEffectiveTopMargin(defaultHeaderHeight, headerDistance, margins.top), calculateEffectiveBottomMargin(defaultFooterHeight, footerDistance, margins.bottom), margins.top, margins.bottom, pageSize.h);
|
|
273028
|
+
const effectiveMargins = clampHeaderFooterInflatedMargins(calculateEffectiveTopMargin(0, headerDistance, margins.top), calculateEffectiveBottomMargin(0, footerDistance, margins.bottom), margins.top, margins.bottom, pageSize.h);
|
|
272810
273029
|
let activeTopMargin = effectiveMargins.top;
|
|
272811
273030
|
let activeBottomMargin = effectiveMargins.bottom;
|
|
272812
273031
|
let activeLeftMargin = margins.left;
|
|
@@ -272911,7 +273130,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
272911
273130
|
const firstMetadataIndex = typeof firstSectionIndexRaw === "number" ? firstSectionIndexRaw : Number(firstSectionIndexRaw ?? NaN);
|
|
272912
273131
|
if (Number.isFinite(firstMetadataIndex))
|
|
272913
273132
|
activeSectionIndex = firstMetadataIndex;
|
|
272914
|
-
const firstSectionMetadata = Number.isFinite(firstMetadataIndex) ?
|
|
273133
|
+
const firstSectionMetadata = Number.isFinite(firstMetadataIndex) ? getSectionMetadata(firstMetadataIndex) : undefined;
|
|
272915
273134
|
if (firstSectionMetadata?.numbering) {
|
|
272916
273135
|
if (firstSectionMetadata.numbering.format)
|
|
272917
273136
|
activeNumberFormat = firstSectionMetadata.numbering.format;
|
|
@@ -272969,7 +273188,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
272969
273188
|
const metadataIndex = typeof sectionIndexRaw === "number" ? sectionIndexRaw : Number(sectionIndexRaw ?? NaN);
|
|
272970
273189
|
if (Number.isFinite(metadataIndex))
|
|
272971
273190
|
pendingSectionIndex = metadataIndex;
|
|
272972
|
-
const sectionMetadata = Number.isFinite(metadataIndex) ?
|
|
273191
|
+
const sectionMetadata = Number.isFinite(metadataIndex) ? getSectionMetadata(metadataIndex) : undefined;
|
|
272973
273192
|
if (sectionMetadata?.numbering)
|
|
272974
273193
|
pendingNumbering = { ...sectionMetadata.numbering };
|
|
272975
273194
|
else if (block.numbering)
|
|
@@ -273212,6 +273431,29 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
273212
273431
|
};
|
|
273213
273432
|
};
|
|
273214
273433
|
const sectionMetadataList = options.sectionMetadata ?? [];
|
|
273434
|
+
const getSectionMetadata = (sectionIndex) => sectionMetadataList.find((section, fallbackIndex) => (section.sectionIndex ?? fallbackIndex) === sectionIndex);
|
|
273435
|
+
const runtimeSectionRefsByIndex = /* @__PURE__ */ new Map;
|
|
273436
|
+
const buildHeaderFooterResolutionSections = () => {
|
|
273437
|
+
const sectionIndexes = /* @__PURE__ */ new Set;
|
|
273438
|
+
sectionMetadataList.forEach((section, fallbackIndex) => sectionIndexes.add(section.sectionIndex ?? fallbackIndex));
|
|
273439
|
+
runtimeSectionRefsByIndex.forEach((_refs, sectionIndex) => sectionIndexes.add(sectionIndex));
|
|
273440
|
+
if (sectionIndexes.size === 0)
|
|
273441
|
+
sectionIndexes.add(0);
|
|
273442
|
+
return Array.from(sectionIndexes).sort((a2, b$1) => a2 - b$1).map((sectionIndex) => {
|
|
273443
|
+
const metadata = getSectionMetadata(sectionIndex);
|
|
273444
|
+
const runtimeRefs = runtimeSectionRefsByIndex.get(sectionIndex);
|
|
273445
|
+
return {
|
|
273446
|
+
sectionIndex,
|
|
273447
|
+
titlePg: metadata?.titlePg === true,
|
|
273448
|
+
headerRefs: runtimeRefs?.headerRefs ?? metadata?.headerRefs,
|
|
273449
|
+
footerRefs: runtimeRefs?.footerRefs ?? metadata?.footerRefs
|
|
273450
|
+
};
|
|
273451
|
+
});
|
|
273452
|
+
};
|
|
273453
|
+
const hasAnyHeaderFooterRefs = (sections, kind) => {
|
|
273454
|
+
const refKey = kind === "header" ? "headerRefs" : "footerRefs";
|
|
273455
|
+
return sections.some((section) => Object.values(section[refKey] ?? {}).some(Boolean));
|
|
273456
|
+
};
|
|
273215
273457
|
const initialSectionMetadata = sectionMetadataList[0];
|
|
273216
273458
|
if (initialSectionMetadata?.numbering?.format)
|
|
273217
273459
|
activeNumberFormat = initialSectionMetadata.numbering.format;
|
|
@@ -273221,11 +273463,13 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
273221
273463
|
}
|
|
273222
273464
|
let activeSectionRefs = null;
|
|
273223
273465
|
let pendingSectionRefs = null;
|
|
273224
|
-
if (initialSectionMetadata?.headerRefs || initialSectionMetadata?.footerRefs)
|
|
273466
|
+
if (initialSectionMetadata?.headerRefs || initialSectionMetadata?.footerRefs) {
|
|
273225
273467
|
activeSectionRefs = {
|
|
273226
273468
|
...initialSectionMetadata.headerRefs && { headerRefs: initialSectionMetadata.headerRefs },
|
|
273227
273469
|
...initialSectionMetadata.footerRefs && { footerRefs: initialSectionMetadata.footerRefs }
|
|
273228
273470
|
};
|
|
273471
|
+
runtimeSectionRefsByIndex.set(initialSectionMetadata.sectionIndex ?? 0, activeSectionRefs);
|
|
273472
|
+
}
|
|
273229
273473
|
if (initialSectionMetadata?.vAlign)
|
|
273230
273474
|
activeVAlign = initialSectionMetadata.vAlign;
|
|
273231
273475
|
let activeSectionIndex = initialSectionMetadata?.sectionIndex ?? 0;
|
|
@@ -273317,6 +273561,8 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
273317
273561
|
activeSectionIndex = pendingSectionIndex;
|
|
273318
273562
|
pendingSectionIndex = null;
|
|
273319
273563
|
}
|
|
273564
|
+
if (activeSectionRefs)
|
|
273565
|
+
runtimeSectionRefsByIndex.set(activeSectionIndex, activeSectionRefs);
|
|
273320
273566
|
if (pendingVAlign !== undefined) {
|
|
273321
273567
|
activeVAlign = pendingVAlign;
|
|
273322
273568
|
pendingVAlign = undefined;
|
|
@@ -273336,53 +273582,42 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
273336
273582
|
if (isEnteringNewSection || !sectionFirstPageNumbers.has(activeSectionIndex))
|
|
273337
273583
|
sectionFirstPageNumbers.set(activeSectionIndex, newPageNumber);
|
|
273338
273584
|
const sectionPageNumber = newPageNumber - (sectionFirstPageNumbers.get(activeSectionIndex) ?? newPageNumber) + 1;
|
|
273339
|
-
const titlePgEnabled =
|
|
273585
|
+
const titlePgEnabled = getSectionMetadata(activeSectionIndex)?.titlePg ?? false;
|
|
273340
273586
|
const alternateHeaders = options.alternateHeaders ?? false;
|
|
273341
|
-
const variantType =
|
|
273587
|
+
const variantType = selectHeaderFooterVariantForPage({
|
|
273342
273588
|
sectionPageNumber,
|
|
273343
|
-
|
|
273344
|
-
titlePgEnabled,
|
|
273589
|
+
documentPageNumber: activePageCounter,
|
|
273590
|
+
titlePg: titlePgEnabled,
|
|
273345
273591
|
alternateHeaders
|
|
273346
273592
|
});
|
|
273347
|
-
|
|
273348
|
-
|
|
273349
|
-
|
|
273350
|
-
|
|
273351
|
-
|
|
273352
|
-
|
|
273353
|
-
|
|
273354
|
-
|
|
273355
|
-
|
|
273356
|
-
|
|
273357
|
-
|
|
273358
|
-
|
|
273359
|
-
|
|
273360
|
-
|
|
273361
|
-
|
|
273362
|
-
|
|
273363
|
-
|
|
273364
|
-
const defaultHeaderRef = activeSectionRefs?.headerRefs?.default;
|
|
273365
|
-
const defaultFooterRef = activeSectionRefs?.footerRefs?.default;
|
|
273366
|
-
const shouldUseDefaultHeaderRef = variantType !== "default" && defaultHeaderRef && (!alternateHeaders || variantType === "odd");
|
|
273367
|
-
const shouldUseDefaultFooterRef = variantType !== "default" && defaultFooterRef && (!alternateHeaders || variantType === "odd");
|
|
273368
|
-
if (!headerRef && shouldUseDefaultHeaderRef) {
|
|
273369
|
-
headerRef = defaultHeaderRef;
|
|
273370
|
-
effectiveVariantType = "default";
|
|
273371
|
-
}
|
|
273372
|
-
if (!footerRef && shouldUseDefaultFooterRef)
|
|
273373
|
-
footerRef = defaultFooterRef;
|
|
273374
|
-
const headerHeight = getHeaderHeightForPage(effectiveVariantType, headerRef, activeSectionIndex);
|
|
273375
|
-
const footerHeight = getFooterHeightForPage(variantType !== "default" && !activeSectionRefs?.footerRefs?.[variantType] ? "default" : variantType, footerRef, activeSectionIndex);
|
|
273593
|
+
const resolutionSections = buildHeaderFooterResolutionSections();
|
|
273594
|
+
const headerResolved = variantType && resolveEffectiveHeaderFooterRef({
|
|
273595
|
+
sections: resolutionSections,
|
|
273596
|
+
sectionIndex: activeSectionIndex,
|
|
273597
|
+
kind: "header",
|
|
273598
|
+
variant: variantType
|
|
273599
|
+
});
|
|
273600
|
+
const footerResolved = variantType && resolveEffectiveHeaderFooterRef({
|
|
273601
|
+
sections: resolutionSections,
|
|
273602
|
+
sectionIndex: activeSectionIndex,
|
|
273603
|
+
kind: "footer",
|
|
273604
|
+
variant: variantType
|
|
273605
|
+
});
|
|
273606
|
+
const hasHeaderRefs = hasAnyHeaderFooterRefs(resolutionSections, "header");
|
|
273607
|
+
const hasFooterRefs = hasAnyHeaderFooterRefs(resolutionSections, "footer");
|
|
273608
|
+
const headerHeight = headerResolved ? getHeaderHeightForPage(headerResolved.matchedVariant, headerResolved.refId, activeSectionIndex) : variantType && !hasHeaderRefs ? getHeaderHeightForPage(variantType, undefined, activeSectionIndex) : 0;
|
|
273609
|
+
const footerHeight = footerResolved ? getFooterHeightForPage(footerResolved.matchedVariant, footerResolved.refId, activeSectionIndex) : variantType && !hasFooterRefs ? getFooterHeightForPage(variantType, undefined, activeSectionIndex) : 0;
|
|
273376
273610
|
const adjustedMargins = clampHeaderFooterInflatedMargins(calculateEffectiveTopMargin(headerHeight, activeHeaderDistance, activeSectionBaseTopMargin), calculateEffectiveBottomMargin(footerHeight, activeFooterDistance, activeSectionBaseBottomMargin), activeSectionBaseTopMargin, activeSectionBaseBottomMargin, activePageSize.h);
|
|
273377
273611
|
activeTopMargin = adjustedMargins.top;
|
|
273378
273612
|
activeBottomMargin = adjustedMargins.bottom;
|
|
273379
|
-
layoutLog(`[Layout] Page ${newPageNumber}: Using variant '${variantType}' - headerHeight: ${headerHeight}, footerHeight: ${footerHeight}`);
|
|
273613
|
+
layoutLog(`[Layout] Page ${newPageNumber}: Using variant '${variantType ?? "none"}' - headerHeight: ${headerHeight}, footerHeight: ${footerHeight}`);
|
|
273380
273614
|
layoutLog(`[Layout] Page ${newPageNumber}: Adjusted margins - top: ${activeTopMargin}, bottom: ${activeBottomMargin} (base: ${activeSectionBaseTopMargin}, ${activeSectionBaseBottomMargin})`);
|
|
273381
273615
|
return;
|
|
273382
273616
|
}
|
|
273383
273617
|
if (state?.page) {
|
|
273384
273618
|
state.page.displayNumber = activePageCounter;
|
|
273385
273619
|
state.page.numberText = formatPageNumber(activePageCounter, activeNumberFormat);
|
|
273620
|
+
state.page.effectivePageNumber = activePageCounter;
|
|
273386
273621
|
state.page.sectionIndex = activeSectionIndex;
|
|
273387
273622
|
layoutLog(`[Layout] Page ${state.page.number}: Stamped sectionIndex:`, activeSectionIndex);
|
|
273388
273623
|
if (activeSectionRefs) {
|
|
@@ -273691,7 +273926,7 @@ function layoutDocument(blocks2, measures, options = {}) {
|
|
|
273691
273926
|
activeSectionIndex = metadataIndex;
|
|
273692
273927
|
else
|
|
273693
273928
|
pendingSectionIndex = metadataIndex;
|
|
273694
|
-
const sectionMetadata = Number.isFinite(metadataIndex) ?
|
|
273929
|
+
const sectionMetadata = Number.isFinite(metadataIndex) ? getSectionMetadata(metadataIndex) : undefined;
|
|
273695
273930
|
if (sectionMetadata?.numbering)
|
|
273696
273931
|
if (isFirstSection) {
|
|
273697
273932
|
if (sectionMetadata.numbering.format)
|
|
@@ -274672,6 +274907,25 @@ function extractParagraphIndent(indent2) {
|
|
|
274672
274907
|
hanging: typeof indent2?.hanging === "number" && Number.isFinite(indent2.hanging) ? indent2.hanging : 0
|
|
274673
274908
|
};
|
|
274674
274909
|
}
|
|
274910
|
+
function refreshResolutionSections(identifier) {
|
|
274911
|
+
if (identifier.sectionCount === 0 && identifier.sectionHeaderIds.size === 0 && identifier.sectionFooterIds.size === 0 && identifier.sectionTitlePg.size === 0) {
|
|
274912
|
+
identifier.sections = [];
|
|
274913
|
+
return;
|
|
274914
|
+
}
|
|
274915
|
+
const maxIndex = Math.max(identifier.sectionCount - 1, ...Array.from(identifier.sectionHeaderIds.keys()), ...Array.from(identifier.sectionFooterIds.keys()), ...Array.from(identifier.sectionTitlePg.keys()));
|
|
274916
|
+
const sections = [];
|
|
274917
|
+
for (let sectionIndex = 0;sectionIndex <= maxIndex; sectionIndex += 1)
|
|
274918
|
+
sections.push({
|
|
274919
|
+
sectionIndex,
|
|
274920
|
+
titlePg: identifier.sectionTitlePg.get(sectionIndex) ?? false,
|
|
274921
|
+
headerRefs: identifier.sectionHeaderIds.get(sectionIndex),
|
|
274922
|
+
footerRefs: identifier.sectionFooterIds.get(sectionIndex)
|
|
274923
|
+
});
|
|
274924
|
+
identifier.sections = sections;
|
|
274925
|
+
}
|
|
274926
|
+
function getSectionTitlePg(identifier, sectionIndex) {
|
|
274927
|
+
return identifier.sectionTitlePg.get(sectionIndex) ?? false;
|
|
274928
|
+
}
|
|
274675
274929
|
function buildMultiSectionIdentifier(sectionMetadata, pageStyles$1, converterIds) {
|
|
274676
274930
|
const identifier = defaultMultiSectionIdentifier();
|
|
274677
274931
|
identifier.alternateHeaders = Boolean(pageStyles$1?.alternateHeaders ?? false);
|
|
@@ -274692,7 +274946,8 @@ function buildMultiSectionIdentifier(sectionMetadata, pageStyles$1, converterIds
|
|
|
274692
274946
|
even: section.footerRefs.even ?? null,
|
|
274693
274947
|
odd: section.footerRefs.odd ?? null
|
|
274694
274948
|
});
|
|
274695
|
-
|
|
274949
|
+
if (Object.prototype.hasOwnProperty.call(section, "titlePg"))
|
|
274950
|
+
identifier.sectionTitlePg.set(idx, section.titlePg === true);
|
|
274696
274951
|
}
|
|
274697
274952
|
const section0Headers = identifier.sectionHeaderIds.get(0);
|
|
274698
274953
|
const section0Footers = identifier.sectionFooterIds.get(0);
|
|
@@ -274717,45 +274972,28 @@ function buildMultiSectionIdentifier(sectionMetadata, pageStyles$1, converterIds
|
|
|
274717
274972
|
identifier.footerIds.even = identifier.footerIds.even ?? converterIds.footerIds.even ?? null;
|
|
274718
274973
|
identifier.footerIds.odd = identifier.footerIds.odd ?? converterIds.footerIds.odd ?? null;
|
|
274719
274974
|
}
|
|
274975
|
+
refreshResolutionSections(identifier);
|
|
274720
274976
|
return identifier;
|
|
274721
274977
|
}
|
|
274722
274978
|
function getHeaderFooterTypeForSection(pageNumber, sectionIndex, identifier, options) {
|
|
274723
|
-
if (pageNumber
|
|
274979
|
+
if (!Number.isFinite(pageNumber))
|
|
274724
274980
|
return null;
|
|
274725
274981
|
const kind = options?.kind ?? "header";
|
|
274726
274982
|
const sectionPageNumber = options?.sectionPageNumber ?? pageNumber;
|
|
274727
|
-
const
|
|
274728
|
-
|
|
274729
|
-
|
|
274730
|
-
|
|
274731
|
-
|
|
274732
|
-
|
|
274733
|
-
|
|
274734
|
-
let hasAny = hasFirst || hasEven || hasOdd || hasDefault;
|
|
274735
|
-
if (!hasAny)
|
|
274736
|
-
for (let index2 = sectionIndex - 1;index2 >= 0; index2 -= 1) {
|
|
274737
|
-
const inheritedIds = kind === "header" ? identifier.sectionHeaderIds.get(index2) : identifier.sectionFooterIds.get(index2);
|
|
274738
|
-
if (inheritedIds?.first || inheritedIds?.even || inheritedIds?.odd || inheritedIds?.default) {
|
|
274739
|
-
hasAny = true;
|
|
274740
|
-
break;
|
|
274741
|
-
}
|
|
274742
|
-
}
|
|
274743
|
-
if (!hasAny)
|
|
274744
|
-
hasAny = Boolean(legacyIds.first || legacyIds.even || legacyIds.odd || legacyIds.default);
|
|
274745
|
-
const titlePgEnabled = (identifier.sectionTitlePg.has(sectionIndex) ? identifier.sectionTitlePg.get(sectionIndex) : identifier.titlePg) === true;
|
|
274746
|
-
if (sectionPageNumber === 1 && titlePgEnabled) {
|
|
274747
|
-
if (hasAny)
|
|
274748
|
-
return "first";
|
|
274983
|
+
const variant = selectHeaderFooterVariantForPage({
|
|
274984
|
+
documentPageNumber: options?.parityPageNumber ?? pageNumber,
|
|
274985
|
+
sectionPageNumber,
|
|
274986
|
+
titlePg: getSectionTitlePg(identifier, sectionIndex),
|
|
274987
|
+
alternateHeaders: identifier.alternateHeaders
|
|
274988
|
+
});
|
|
274989
|
+
if (!variant)
|
|
274749
274990
|
return null;
|
|
274750
|
-
|
|
274751
|
-
|
|
274752
|
-
|
|
274753
|
-
|
|
274754
|
-
|
|
274755
|
-
}
|
|
274756
|
-
if (hasDefault)
|
|
274757
|
-
return "default";
|
|
274758
|
-
return null;
|
|
274991
|
+
return resolveEffectiveHeaderFooterRef({
|
|
274992
|
+
sections: identifier.sections,
|
|
274993
|
+
sectionIndex,
|
|
274994
|
+
kind,
|
|
274995
|
+
variant
|
|
274996
|
+
}) ? variant : null;
|
|
274759
274997
|
}
|
|
274760
274998
|
function isNoneBorder(value) {
|
|
274761
274999
|
return typeof value === "object" && value !== null && "none" in value && value.none === true;
|
|
@@ -274780,7 +275018,7 @@ function forEachParagraphBlock(blocks2, visit2) {
|
|
|
274780
275018
|
forEachParagraphBlock([cell2.paragraph], visit2);
|
|
274781
275019
|
}
|
|
274782
275020
|
}
|
|
274783
|
-
function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberText) {
|
|
275021
|
+
function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberText, displayPageNumber) {
|
|
274784
275022
|
if (!blocks2 || blocks2.length === 0)
|
|
274785
275023
|
return;
|
|
274786
275024
|
if (!Number.isFinite(pageNumber) || pageNumber < 1) {
|
|
@@ -274793,13 +275031,14 @@ function resolveHeaderFooterTokens(blocks2, pageNumber, totalPages, pageNumberTe
|
|
|
274793
275031
|
}
|
|
274794
275032
|
const pageNumberStr = pageNumberText ?? String(pageNumber);
|
|
274795
275033
|
const totalPagesStr = String(totalPages);
|
|
275034
|
+
const displayNumber = displayPageNumber ?? pageNumber;
|
|
274796
275035
|
forEachParagraphBlock(blocks2, (paraBlock) => {
|
|
274797
275036
|
for (const run2 of paraBlock.runs)
|
|
274798
275037
|
if ("token" in run2 && run2.token) {
|
|
274799
275038
|
if (run2.token === "pageNumber")
|
|
274800
|
-
run2.text = pageNumberStr;
|
|
275039
|
+
run2.text = run2.pageNumberFieldFormat ? formatPageNumberFieldValue$1(displayNumber, run2.pageNumberFieldFormat) : pageNumberStr;
|
|
274801
275040
|
else if (run2.token === "totalPageCount")
|
|
274802
|
-
run2.text = totalPagesStr;
|
|
275041
|
+
run2.text = run2.pageNumberFieldFormat ? formatPageNumberFieldValue$1(totalPages, run2.pageNumberFieldFormat) : totalPagesStr;
|
|
274803
275042
|
}
|
|
274804
275043
|
});
|
|
274805
275044
|
}
|
|
@@ -274864,17 +275103,122 @@ function getBucketRepresentative(bucket) {
|
|
|
274864
275103
|
return 5000;
|
|
274865
275104
|
}
|
|
274866
275105
|
}
|
|
275106
|
+
function getBucketForDigitCount(digitCount) {
|
|
275107
|
+
if (digitCount <= 1)
|
|
275108
|
+
return "d1";
|
|
275109
|
+
if (digitCount === 2)
|
|
275110
|
+
return "d2";
|
|
275111
|
+
if (digitCount === 3)
|
|
275112
|
+
return "d3";
|
|
275113
|
+
return "d4";
|
|
275114
|
+
}
|
|
275115
|
+
function getBucketForRenderedPageNumberText(text5) {
|
|
275116
|
+
const digitCount = (text5.match(/\d/g) ?? []).length;
|
|
275117
|
+
if (digitCount <= 0)
|
|
275118
|
+
return null;
|
|
275119
|
+
return getBucketForDigitCount(digitCount);
|
|
275120
|
+
}
|
|
275121
|
+
function forEachPageNumberRun(blocks2, visit2) {
|
|
275122
|
+
for (const block of blocks2)
|
|
275123
|
+
if (block.kind === "paragraph") {
|
|
275124
|
+
const paraBlock = block;
|
|
275125
|
+
for (const run2 of paraBlock.runs)
|
|
275126
|
+
if ("token" in run2 && run2.token === "pageNumber")
|
|
275127
|
+
visit2(run2);
|
|
275128
|
+
} else if (block.kind === "list") {
|
|
275129
|
+
const list5 = block;
|
|
275130
|
+
for (const item of list5.items ?? [])
|
|
275131
|
+
for (const run2 of item.paragraph.runs)
|
|
275132
|
+
if ("token" in run2 && run2.token === "pageNumber")
|
|
275133
|
+
visit2(run2);
|
|
275134
|
+
} else if (block.kind === "table") {
|
|
275135
|
+
const table2 = block;
|
|
275136
|
+
for (const row2 of table2.rows ?? [])
|
|
275137
|
+
for (const cell2 of row2.cells ?? [])
|
|
275138
|
+
forEachPageNumberRun(cell2.blocks ? cell2.blocks : cell2.paragraph ? [cell2.paragraph] : [], visit2);
|
|
275139
|
+
}
|
|
275140
|
+
}
|
|
275141
|
+
function buildCompatibleFieldFormatKey(fieldFormat) {
|
|
275142
|
+
return `${fieldFormat.format ?? "decimal"}:${fieldFormat.zeroPadding ?? ""}`;
|
|
275143
|
+
}
|
|
275144
|
+
function getPageNumberBucketingStrategy(blocks2) {
|
|
275145
|
+
let sawImplicitPageNumber = false;
|
|
275146
|
+
const explicitFieldFormats = /* @__PURE__ */ new Map;
|
|
275147
|
+
forEachPageNumberRun(blocks2, (run2) => {
|
|
275148
|
+
const fieldFormat = run2.pageNumberFieldFormat;
|
|
275149
|
+
if (!fieldFormat) {
|
|
275150
|
+
sawImplicitPageNumber = true;
|
|
275151
|
+
return;
|
|
275152
|
+
}
|
|
275153
|
+
if (!isDigitBucketCompatiblePageNumberFormat(fieldFormat.format)) {
|
|
275154
|
+
explicitFieldFormats.clear();
|
|
275155
|
+
sawImplicitPageNumber = true;
|
|
275156
|
+
return;
|
|
275157
|
+
}
|
|
275158
|
+
explicitFieldFormats.set(buildCompatibleFieldFormatKey(fieldFormat), fieldFormat);
|
|
275159
|
+
});
|
|
275160
|
+
if (explicitFieldFormats.size === 0)
|
|
275161
|
+
return sawImplicitPageNumber ? { kind: "displayText" } : null;
|
|
275162
|
+
if (sawImplicitPageNumber || explicitFieldFormats.size > 1)
|
|
275163
|
+
return null;
|
|
275164
|
+
return {
|
|
275165
|
+
kind: "fieldFormat",
|
|
275166
|
+
fieldFormat: explicitFieldFormats.values().next().value
|
|
275167
|
+
};
|
|
275168
|
+
}
|
|
275169
|
+
function canUseDigitBucketingForVariant(blocks2, docTotalPages, pageResolver) {
|
|
275170
|
+
const strategy = getPageNumberBucketingStrategy(blocks2);
|
|
275171
|
+
if (!strategy)
|
|
275172
|
+
return false;
|
|
275173
|
+
const renderedBucketForPage = (pageNumber) => {
|
|
275174
|
+
const pageInfo = pageResolver(pageNumber);
|
|
275175
|
+
const renderedText = strategy.kind === "fieldFormat" ? Number.isFinite(pageInfo.displayNumber) ? formatPageNumberFieldValue$1(pageInfo.displayNumber ?? pageNumber, strategy.fieldFormat) : null : pageInfo.displayText;
|
|
275176
|
+
return renderedText ? getBucketForRenderedPageNumberText(renderedText) : null;
|
|
275177
|
+
};
|
|
275178
|
+
const expectedRenderedBuckets = /* @__PURE__ */ new Map;
|
|
275179
|
+
for (let pageNumber = 1;pageNumber <= docTotalPages; pageNumber += 1) {
|
|
275180
|
+
const physicalBucket = getBucketForPageNumber(pageNumber);
|
|
275181
|
+
const renderedBucket = renderedBucketForPage(pageNumber);
|
|
275182
|
+
if (!renderedBucket)
|
|
275183
|
+
return false;
|
|
275184
|
+
const expectedBucket = expectedRenderedBuckets.get(physicalBucket);
|
|
275185
|
+
if (!expectedBucket) {
|
|
275186
|
+
expectedRenderedBuckets.set(physicalBucket, renderedBucket);
|
|
275187
|
+
continue;
|
|
275188
|
+
}
|
|
275189
|
+
if (expectedBucket !== renderedBucket)
|
|
275190
|
+
return false;
|
|
275191
|
+
}
|
|
275192
|
+
for (const [physicalBucket, expectedRenderedBucket] of expectedRenderedBuckets)
|
|
275193
|
+
if (renderedBucketForPage(getBucketRepresentative(physicalBucket)) !== expectedRenderedBucket)
|
|
275194
|
+
return false;
|
|
275195
|
+
return true;
|
|
275196
|
+
}
|
|
274867
275197
|
function paragraphHasPageToken(para) {
|
|
274868
275198
|
for (const run2 of para.runs)
|
|
274869
275199
|
if ("token" in run2 && (run2.token === "pageNumber" || run2.token === "totalPageCount"))
|
|
274870
275200
|
return true;
|
|
274871
275201
|
return false;
|
|
274872
275202
|
}
|
|
275203
|
+
function isDigitBucketCompatiblePageNumberFormat(format) {
|
|
275204
|
+
return !format || format === "decimal" || format === "numberInDash";
|
|
275205
|
+
}
|
|
275206
|
+
function paragraphRequiresPerPageLayout(para) {
|
|
275207
|
+
for (const run2 of para.runs)
|
|
275208
|
+
if ("token" in run2 && run2.token === "pageNumber" && run2.pageNumberFieldFormat && !isDigitBucketCompatiblePageNumberFormat(run2.pageNumberFieldFormat.format))
|
|
275209
|
+
return true;
|
|
275210
|
+
return false;
|
|
275211
|
+
}
|
|
274873
275212
|
function hasPageTokens(blocks2) {
|
|
274874
275213
|
for (const block of blocks2)
|
|
274875
275214
|
if (block.kind === "paragraph") {
|
|
274876
275215
|
if (paragraphHasPageToken(block))
|
|
274877
275216
|
return true;
|
|
275217
|
+
} else if (block.kind === "list") {
|
|
275218
|
+
const list5 = block;
|
|
275219
|
+
for (const item of list5.items ?? [])
|
|
275220
|
+
if (paragraphHasPageToken(item.paragraph))
|
|
275221
|
+
return true;
|
|
274878
275222
|
} else if (block.kind === "table") {
|
|
274879
275223
|
const table2 = block;
|
|
274880
275224
|
for (const row2 of table2.rows ?? [])
|
|
@@ -274884,6 +275228,25 @@ function hasPageTokens(blocks2) {
|
|
|
274884
275228
|
}
|
|
274885
275229
|
return false;
|
|
274886
275230
|
}
|
|
275231
|
+
function hasPageNumberTokensRequiringPerPageLayout(blocks2) {
|
|
275232
|
+
for (const block of blocks2)
|
|
275233
|
+
if (block.kind === "paragraph") {
|
|
275234
|
+
if (paragraphRequiresPerPageLayout(block))
|
|
275235
|
+
return true;
|
|
275236
|
+
} else if (block.kind === "list") {
|
|
275237
|
+
const list5 = block;
|
|
275238
|
+
for (const item of list5.items ?? [])
|
|
275239
|
+
if (paragraphRequiresPerPageLayout(item.paragraph))
|
|
275240
|
+
return true;
|
|
275241
|
+
} else if (block.kind === "table") {
|
|
275242
|
+
const table2 = block;
|
|
275243
|
+
for (const row2 of table2.rows ?? [])
|
|
275244
|
+
for (const cell2 of row2.cells ?? [])
|
|
275245
|
+
if (hasPageNumberTokensRequiringPerPageLayout(cell2.blocks ? cell2.blocks : cell2.paragraph ? [cell2.paragraph] : []))
|
|
275246
|
+
return true;
|
|
275247
|
+
}
|
|
275248
|
+
return false;
|
|
275249
|
+
}
|
|
274887
275250
|
async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind) {
|
|
274888
275251
|
const result = {};
|
|
274889
275252
|
if (!pageResolver) {
|
|
@@ -274919,7 +275282,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
|
|
|
274919
275282
|
continue;
|
|
274920
275283
|
}
|
|
274921
275284
|
let pagesToLayout;
|
|
274922
|
-
if (!useBucketing) {
|
|
275285
|
+
if (!(useBucketing && !hasPageNumberTokensRequiringPerPageLayout(blocks2) && canUseDigitBucketingForVariant(blocks2, docTotalPages, pageResolver))) {
|
|
274923
275286
|
pagesToLayout = Array.from({ length: docTotalPages }, (_$1, i4) => i4 + 1);
|
|
274924
275287
|
HeaderFooterCacheLogger.logBucketingDecision(docTotalPages, false);
|
|
274925
275288
|
} else {
|
|
@@ -274932,8 +275295,8 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
|
|
|
274932
275295
|
const pages = [];
|
|
274933
275296
|
for (const pageNum of pagesToLayout) {
|
|
274934
275297
|
const clonedBlocks = cloneHeaderFooterBlocks(blocks2);
|
|
274935
|
-
const { displayText, totalPages: totalPagesForPage } = pageResolver(pageNum);
|
|
274936
|
-
resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText);
|
|
275298
|
+
const { displayText, displayNumber, totalPages: totalPagesForPage } = pageResolver(pageNum);
|
|
275299
|
+
resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText, displayNumber);
|
|
274937
275300
|
const measures = await cache$2.measureBlocks(clonedBlocks, constraints, measureBlock$1);
|
|
274938
275301
|
const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints, kind);
|
|
274939
275302
|
const measuresById = /* @__PURE__ */ new Map;
|
|
@@ -274952,9 +275315,11 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
|
|
|
274952
275315
|
}) ?? [];
|
|
274953
275316
|
pages.push({
|
|
274954
275317
|
number: pageNum,
|
|
275318
|
+
displayNumber,
|
|
274955
275319
|
blocks: clonedBlocks,
|
|
274956
275320
|
measures,
|
|
274957
|
-
fragments: fragmentsWithLines
|
|
275321
|
+
fragments: fragmentsWithLines,
|
|
275322
|
+
numberText: displayText
|
|
274958
275323
|
});
|
|
274959
275324
|
}
|
|
274960
275325
|
const firstPageLayout = pages[0] ? layoutHeaderFooter(pages[0].blocks, pages[0].measures, constraints, kind) : {
|
|
@@ -274968,7 +275333,9 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
|
|
|
274968
275333
|
renderHeight: firstPageLayout.renderHeight,
|
|
274969
275334
|
pages: pages.map((p$12) => ({
|
|
274970
275335
|
number: p$12.number,
|
|
275336
|
+
displayNumber: p$12.displayNumber,
|
|
274971
275337
|
fragments: p$12.fragments,
|
|
275338
|
+
numberText: p$12.numberText,
|
|
274972
275339
|
blocks: p$12.blocks,
|
|
274973
275340
|
measures: p$12.measures
|
|
274974
275341
|
}))
|
|
@@ -275588,6 +275955,8 @@ function computeHeaderFooterContentHash(blocks2) {
|
|
|
275588
275955
|
parts.push("i");
|
|
275589
275956
|
if ("token" in run2 && run2.token)
|
|
275590
275957
|
parts.push(`token:${run2.token}`);
|
|
275958
|
+
if ("pageNumberFormat" in run2 && run2.pageNumberFormat)
|
|
275959
|
+
parts.push(`pnf:${run2.pageNumberFormat}`);
|
|
275591
275960
|
}
|
|
275592
275961
|
}
|
|
275593
275962
|
return parts.join("|");
|
|
@@ -276960,8 +277329,10 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
|
|
|
276960
277329
|
const numberingCtx = buildNumberingContext(layout, sections);
|
|
276961
277330
|
const pageResolver = FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? (pageNumber) => {
|
|
276962
277331
|
const pageIndex = pageNumber - 1;
|
|
277332
|
+
const displayInfo = numberingCtx.displayPages[pageIndex];
|
|
276963
277333
|
return {
|
|
276964
|
-
displayText:
|
|
277334
|
+
displayText: displayInfo?.displayText ?? String(pageNumber),
|
|
277335
|
+
displayNumber: displayInfo?.displayNumber ?? pageNumber,
|
|
276965
277336
|
totalPages: numberingCtx.totalPages
|
|
276966
277337
|
};
|
|
276967
277338
|
} : undefined;
|
|
@@ -285267,8 +285638,10 @@ async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetad
|
|
|
285267
285638
|
const displayPages = computeDisplayPageNumber(layout.pages, sectionMetadata);
|
|
285268
285639
|
const totalPages = layout.pages.length;
|
|
285269
285640
|
const pageResolver = (pageNumber) => {
|
|
285641
|
+
const displayInfo = displayPages[pageNumber - 1];
|
|
285270
285642
|
return {
|
|
285271
|
-
displayText:
|
|
285643
|
+
displayText: displayInfo?.displayText ?? String(pageNumber),
|
|
285644
|
+
displayNumber: displayInfo?.displayNumber ?? pageNumber,
|
|
285272
285645
|
totalPages
|
|
285273
285646
|
};
|
|
285274
285647
|
};
|
|
@@ -285371,6 +285744,10 @@ async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadat
|
|
|
285371
285744
|
}
|
|
285372
285745
|
}
|
|
285373
285746
|
}
|
|
285747
|
+
function hasSectionRefsForKind(identifier, kind) {
|
|
285748
|
+
const refKey = kind === "header" ? "headerRefs" : "footerRefs";
|
|
285749
|
+
return Boolean(identifier?.sections?.some((section) => section[refKey] !== undefined));
|
|
285750
|
+
}
|
|
285374
285751
|
function buildSurfacePmEntries(surface) {
|
|
285375
285752
|
const nodes = Array.from(surface.querySelectorAll("[data-pm-start][data-pm-end]"));
|
|
285376
285753
|
const nonLeaf = /* @__PURE__ */ new WeakSet;
|
|
@@ -285475,6 +285852,18 @@ function buildHeaderFooterStory(kind, id2) {
|
|
|
285475
285852
|
function storyIdFromHeaderFooterLayoutKey(key2) {
|
|
285476
285853
|
return key2.replace(/::s\d+$/, "");
|
|
285477
285854
|
}
|
|
285855
|
+
function refForVariant(refs, variant) {
|
|
285856
|
+
const ref$1 = refs?.[variant];
|
|
285857
|
+
if (ref$1)
|
|
285858
|
+
return {
|
|
285859
|
+
refId: ref$1,
|
|
285860
|
+
matchedVariant: variant
|
|
285861
|
+
};
|
|
285862
|
+
return variant === "odd" && refs?.default ? {
|
|
285863
|
+
refId: refs.default,
|
|
285864
|
+
matchedVariant: "default"
|
|
285865
|
+
} : undefined;
|
|
285866
|
+
}
|
|
285478
285867
|
function resolveResult(result, storyId) {
|
|
285479
285868
|
const story = buildHeaderFooterStory(result.kind, storyId ?? String(result.type));
|
|
285480
285869
|
return resolveHeaderFooterLayout(result.layout, result.blocks, result.measures, story);
|
|
@@ -285491,19 +285880,34 @@ function shiftResolvedPaintItemY(item, yOffset) {
|
|
|
285491
285880
|
y: item.y + yOffset
|
|
285492
285881
|
};
|
|
285493
285882
|
}
|
|
285494
|
-
function
|
|
285495
|
-
|
|
285883
|
+
function isExplicitBehindDocMediaFragment(fragment2) {
|
|
285884
|
+
return (fragment2.kind === "image" || fragment2.kind === "drawing") && fragment2.behindDoc === true;
|
|
285885
|
+
}
|
|
285886
|
+
function getDecorationNormalizationMinY(fragments, layoutMinY) {
|
|
285887
|
+
if (!Number.isFinite(layoutMinY) || layoutMinY >= 0)
|
|
285888
|
+
return 0;
|
|
285889
|
+
let minY = Infinity;
|
|
285890
|
+
for (const fragment2 of fragments) {
|
|
285891
|
+
if (isExplicitBehindDocMediaFragment(fragment2))
|
|
285892
|
+
continue;
|
|
285893
|
+
if (Number.isFinite(fragment2.y))
|
|
285894
|
+
minY = Math.min(minY, fragment2.y);
|
|
285895
|
+
}
|
|
285896
|
+
return minY < 0 ? minY : 0;
|
|
285897
|
+
}
|
|
285898
|
+
function normalizeDecorationFragments(fragments, normalizationMinY) {
|
|
285899
|
+
if (normalizationMinY >= 0)
|
|
285496
285900
|
return fragments;
|
|
285497
|
-
const yOffset = -
|
|
285901
|
+
const yOffset = -normalizationMinY;
|
|
285498
285902
|
return fragments.map((fragment2) => ({
|
|
285499
285903
|
...fragment2,
|
|
285500
285904
|
y: fragment2.y + yOffset
|
|
285501
285905
|
}));
|
|
285502
285906
|
}
|
|
285503
|
-
function normalizeDecorationItems(items,
|
|
285504
|
-
if (
|
|
285907
|
+
function normalizeDecorationItems(items, normalizationMinY) {
|
|
285908
|
+
if (normalizationMinY >= 0)
|
|
285505
285909
|
return items;
|
|
285506
|
-
const yOffset = -
|
|
285910
|
+
const yOffset = -normalizationMinY;
|
|
285507
285911
|
return items.map((item) => shiftResolvedPaintItemY(item, yOffset));
|
|
285508
285912
|
}
|
|
285509
285913
|
function createStoryHiddenHost(doc$12, widthPx, options = {}) {
|
|
@@ -306208,6 +306612,7 @@ menclose::after {
|
|
|
306208
306612
|
highlight: run2.highlight ?? null,
|
|
306209
306613
|
textTransform: run2.textTransform ?? null,
|
|
306210
306614
|
token: run2.token ?? null,
|
|
306615
|
+
pageNumberFieldFormat: run2.pageNumberFieldFormat ?? null,
|
|
306211
306616
|
pageRefMetadata: run2.pageRefMetadata ?? null,
|
|
306212
306617
|
trackedChange: run2.trackedChange ?? null,
|
|
306213
306618
|
trackedChanges: run2.trackedChanges ?? null,
|
|
@@ -309326,10 +309731,16 @@ menclose::after {
|
|
|
309326
309731
|
return "";
|
|
309327
309732
|
if (!runToken)
|
|
309328
309733
|
return run2.text ?? "";
|
|
309329
|
-
if (runToken === "pageNumber")
|
|
309734
|
+
if (runToken === "pageNumber") {
|
|
309735
|
+
if (run2.pageNumberFieldFormat)
|
|
309736
|
+
return formatPageNumberFieldValue$1(context.displayPageNumber ?? context.pageNumber, run2.pageNumberFieldFormat);
|
|
309330
309737
|
return context.pageNumberText ?? String(context.pageNumber);
|
|
309331
|
-
|
|
309738
|
+
}
|
|
309739
|
+
if (runToken === "totalPageCount") {
|
|
309740
|
+
if (run2.pageNumberFieldFormat)
|
|
309741
|
+
return formatPageNumberFieldValue$1(context.totalPages || 1, run2.pageNumberFieldFormat);
|
|
309332
309742
|
return context.totalPages ? String(context.totalPages) : run2.text ?? "";
|
|
309743
|
+
}
|
|
309333
309744
|
return run2.text ?? "";
|
|
309334
309745
|
}, extractLinkData = (run2) => {
|
|
309335
309746
|
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "math")
|
|
@@ -311586,6 +311997,7 @@ menclose::after {
|
|
|
311586
311997
|
totalPages: this.totalPages,
|
|
311587
311998
|
section: "body",
|
|
311588
311999
|
pageNumberText: page.numberText,
|
|
312000
|
+
displayPageNumber: page.displayNumber,
|
|
311589
312001
|
pageIndex
|
|
311590
312002
|
};
|
|
311591
312003
|
const resolvedItems = page.items;
|
|
@@ -311800,6 +312212,7 @@ menclose::after {
|
|
|
311800
312212
|
section: kind,
|
|
311801
312213
|
story: resolveDecorationStory(kind, data),
|
|
311802
312214
|
pageNumberText: page.numberText,
|
|
312215
|
+
displayPageNumber: page.displayNumber,
|
|
311803
312216
|
pageIndex
|
|
311804
312217
|
};
|
|
311805
312218
|
const decorationItems = data.items ?? [];
|
|
@@ -311945,6 +312358,7 @@ menclose::after {
|
|
|
311945
312358
|
totalPages: this.totalPages,
|
|
311946
312359
|
section: "body",
|
|
311947
312360
|
pageNumberText: page.numberText,
|
|
312361
|
+
displayPageNumber: page.displayNumber,
|
|
311948
312362
|
pageIndex
|
|
311949
312363
|
};
|
|
311950
312364
|
resolvedItems.forEach((resolvedItem, index2) => {
|
|
@@ -311961,9 +312375,10 @@ menclose::after {
|
|
|
311961
312375
|
const geometryChanged = hasFragmentGeometryChanged(current.fragment, fragment2);
|
|
311962
312376
|
const sdtBoundaryMismatch = shouldRebuildForSdtBoundary(current.element, sdtBoundary);
|
|
311963
312377
|
const betweenBorderMismatch = current.element.dataset.betweenBorder === "true" !== (betweenInfo?.showBetweenBorder ?? false) || current.element.dataset.suppressTopBorder === "true" !== (betweenInfo?.suppressTopBorder ?? false) || (current.element.dataset.gapBelow ?? "") !== (betweenInfo?.gapBelow ? String(betweenInfo.gapBelow) : "");
|
|
312378
|
+
const pageContextChanged = needsRebuildForPageContext(current.context, contextBase, resolvedItem);
|
|
311964
312379
|
const newPmStart = fragment2.pmStart;
|
|
311965
312380
|
const mappingUnreliable = this.currentMapping != null && newPmStart != null && current.element.dataset.pmStart != null && this.currentMapping.map(Number(current.element.dataset.pmStart)) !== newPmStart;
|
|
311966
|
-
if (geometryChanged || this.changedBlocks.has(fragment2.blockId) || current.signature !== resolvedSig || sdtBoundaryMismatch || betweenBorderMismatch || mappingUnreliable) {
|
|
312381
|
+
if (geometryChanged || this.changedBlocks.has(fragment2.blockId) || current.signature !== resolvedSig || sdtBoundaryMismatch || betweenBorderMismatch || pageContextChanged || mappingUnreliable) {
|
|
311967
312382
|
const replacement = this.renderFragment(fragment2, contextBase, sdtBoundary, betweenInfo, resolvedItem);
|
|
311968
312383
|
pageEl.replaceChild(replacement, current.element);
|
|
311969
312384
|
current.element = replacement;
|
|
@@ -312045,6 +312460,7 @@ menclose::after {
|
|
|
312045
312460
|
totalPages: this.totalPages,
|
|
312046
312461
|
section: "body",
|
|
312047
312462
|
pageNumberText: page.numberText,
|
|
312463
|
+
displayPageNumber: page.displayNumber,
|
|
312048
312464
|
pageIndex
|
|
312049
312465
|
};
|
|
312050
312466
|
const resolvedItems = page.items;
|
|
@@ -313595,6 +314011,7 @@ menclose::after {
|
|
|
313595
314011
|
textRun.vertAlign ?? "",
|
|
313596
314012
|
textRun.baselineShift != null ? textRun.baselineShift : "",
|
|
313597
314013
|
textRun.token ?? "",
|
|
314014
|
+
textRun.pageNumberFieldFormat ? JSON.stringify(textRun.pageNumberFieldFormat) : "",
|
|
313598
314015
|
trackedVersion,
|
|
313599
314016
|
textRun.comments?.length ?? 0,
|
|
313600
314017
|
textRun.bidi ? JSON.stringify(textRun.bidi) : ""
|
|
@@ -313751,6 +314168,9 @@ menclose::after {
|
|
|
313751
314168
|
hash$3 = hashString(hash$3, getRunBooleanProp(run2, "strike") ? "1" : "");
|
|
313752
314169
|
hash$3 = hashString(hash$3, getRunStringProp(run2, "vertAlign"));
|
|
313753
314170
|
hash$3 = hashNumber(hash$3, getRunNumberProp(run2, "baselineShift"));
|
|
314171
|
+
hash$3 = hashString(hash$3, getRunStringProp(run2, "token"));
|
|
314172
|
+
const pageNumberFieldFormat = run2.pageNumberFieldFormat;
|
|
314173
|
+
hash$3 = hashString(hash$3, pageNumberFieldFormat ? JSON.stringify(pageNumberFieldFormat) : "");
|
|
313754
314174
|
const bidi = run2.bidi;
|
|
313755
314175
|
hash$3 = hashString(hash$3, bidi ? JSON.stringify(bidi) : "");
|
|
313756
314176
|
hash$3 = hashString(hash$3, trackedChangeVersion(run2));
|
|
@@ -314144,7 +314564,8 @@ menclose::after {
|
|
|
314144
314564
|
sectionCount: 0,
|
|
314145
314565
|
sectionHeaderIds: /* @__PURE__ */ new Map,
|
|
314146
314566
|
sectionFooterIds: /* @__PURE__ */ new Map,
|
|
314147
|
-
sectionTitlePg: /* @__PURE__ */ new Map
|
|
314567
|
+
sectionTitlePg: /* @__PURE__ */ new Map,
|
|
314568
|
+
sections: []
|
|
314148
314569
|
}), fieldAnnotationKey = (run2) => {
|
|
314149
314570
|
if (run2.kind !== "fieldAnnotation")
|
|
314150
314571
|
return "";
|
|
@@ -321302,17 +321723,20 @@ menclose::after {
|
|
|
321302
321723
|
}
|
|
321303
321724
|
#computeExpectedSectionType(kind, page, sectionFirstPageNumbers) {
|
|
321304
321725
|
const pageNumber = page.number;
|
|
321726
|
+
const effectivePageNumber = page.effectivePageNumber ?? page.displayNumber ?? pageNumber;
|
|
321305
321727
|
const sectionIndex = page.sectionIndex ?? 0;
|
|
321306
321728
|
const isFirstPageOfSection = sectionFirstPageNumbers.get(sectionIndex) === pageNumber;
|
|
321307
321729
|
const converter = this.#options.editor.converter;
|
|
321308
|
-
const hasAlternateHeaders = converter?.pageStyles?.alternateHeaders === true;
|
|
321730
|
+
const hasAlternateHeaders = this.#multiSectionIdentifier?.alternateHeaders === true || converter?.pageStyles?.alternateHeaders === true;
|
|
321309
321731
|
const headerIds = converter?.headerIds;
|
|
321310
321732
|
const footerIds = converter?.footerIds;
|
|
321311
|
-
|
|
321733
|
+
let titlePgEnabled = headerIds?.titlePg === true || footerIds?.titlePg === true;
|
|
321734
|
+
if (this.#multiSectionIdentifier?.sectionTitlePg?.has(sectionIndex))
|
|
321735
|
+
titlePgEnabled = this.#multiSectionIdentifier.sectionTitlePg.get(sectionIndex) === true;
|
|
321312
321736
|
if (isFirstPageOfSection && titlePgEnabled)
|
|
321313
321737
|
return "first";
|
|
321314
321738
|
if (hasAlternateHeaders)
|
|
321315
|
-
return
|
|
321739
|
+
return effectivePageNumber % 2 === 0 ? "even" : "odd";
|
|
321316
321740
|
return "default";
|
|
321317
321741
|
}
|
|
321318
321742
|
#stripFootnoteReserveFromBottomMargin(margins, page) {
|
|
@@ -321693,37 +322117,33 @@ menclose::after {
|
|
|
321693
322117
|
if (!sectionFirstPageNumbers.has(idx))
|
|
321694
322118
|
sectionFirstPageNumbers.set(idx, p$12.number);
|
|
321695
322119
|
}
|
|
322120
|
+
const hasSectionResolution = hasSectionRefsForKind(multiSectionId, kind);
|
|
321696
322121
|
return (pageNumber, pageMargins, page) => {
|
|
321697
322122
|
const sectionIndex = page?.sectionIndex ?? 0;
|
|
322123
|
+
const effectivePageNumber = page?.effectivePageNumber ?? page?.displayNumber ?? pageNumber;
|
|
321698
322124
|
const firstPageInSection = sectionFirstPageNumbers.get(sectionIndex);
|
|
321699
322125
|
const sectionPageNumber = typeof firstPageInSection === "number" ? pageNumber - firstPageInSection + 1 : pageNumber;
|
|
321700
|
-
const
|
|
321701
|
-
const headerFooterType = multiSectionId ? getHeaderFooterTypeForSection(pageNumber, sectionIndex, multiSectionId, {
|
|
322126
|
+
const headerFooterType = hasSectionResolution ? getHeaderFooterTypeForSection(effectivePageNumber, sectionIndex, multiSectionId, {
|
|
321702
322127
|
kind,
|
|
321703
322128
|
sectionPageNumber,
|
|
321704
|
-
parityPageNumber
|
|
322129
|
+
parityPageNumber: effectivePageNumber
|
|
321705
322130
|
}) : getHeaderFooterType2(pageNumber, legacyIdentifier, {
|
|
321706
322131
|
kind,
|
|
321707
|
-
parityPageNumber
|
|
321708
|
-
});
|
|
321709
|
-
let sectionRId;
|
|
321710
|
-
if (page?.sectionRefs && kind === "header") {
|
|
321711
|
-
sectionRId = page.sectionRefs.headerRefs?.[headerFooterType];
|
|
321712
|
-
if (!sectionRId && headerFooterType && headerFooterType !== "default" && sectionIndex > 0 && multiSectionId)
|
|
321713
|
-
sectionRId = multiSectionId.sectionHeaderIds.get(sectionIndex - 1)?.[headerFooterType] ?? undefined;
|
|
321714
|
-
const shouldUseDefaultHeaderRef = headerFooterType !== "default" && page.sectionRefs.headerRefs?.default && (!multiSectionId?.alternateHeaders || headerFooterType === "odd");
|
|
321715
|
-
if (!sectionRId && shouldUseDefaultHeaderRef)
|
|
321716
|
-
sectionRId = page.sectionRefs.headerRefs?.default;
|
|
321717
|
-
} else if (page?.sectionRefs && kind === "footer") {
|
|
321718
|
-
sectionRId = page.sectionRefs.footerRefs?.[headerFooterType];
|
|
321719
|
-
if (!sectionRId && headerFooterType && headerFooterType !== "default" && sectionIndex > 0 && multiSectionId)
|
|
321720
|
-
sectionRId = multiSectionId.sectionFooterIds.get(sectionIndex - 1)?.[headerFooterType] ?? undefined;
|
|
321721
|
-
const shouldUseDefaultFooterRef = headerFooterType !== "default" && page.sectionRefs.footerRefs?.default && (!multiSectionId?.alternateHeaders || headerFooterType === "odd");
|
|
321722
|
-
if (!sectionRId && shouldUseDefaultFooterRef)
|
|
321723
|
-
sectionRId = page.sectionRefs.footerRefs?.default;
|
|
321724
|
-
}
|
|
322132
|
+
parityPageNumber: effectivePageNumber
|
|
322133
|
+
});
|
|
321725
322134
|
if (!headerFooterType)
|
|
321726
322135
|
return null;
|
|
322136
|
+
const pageSectionRefs = kind === "header" ? page?.sectionRefs?.headerRefs : page?.sectionRefs?.footerRefs;
|
|
322137
|
+
const sectionResolvedRef = hasSectionResolution ? resolveEffectiveHeaderFooterRef({
|
|
322138
|
+
sections: multiSectionId.sections,
|
|
322139
|
+
sectionIndex,
|
|
322140
|
+
kind,
|
|
322141
|
+
variant: headerFooterType
|
|
322142
|
+
}) : null;
|
|
322143
|
+
const legacyRefs = kind === "header" ? legacyIdentifier.headerIds : legacyIdentifier.footerIds;
|
|
322144
|
+
const resolvedRef = refForVariant(pageSectionRefs, headerFooterType) ?? sectionResolvedRef ?? (!hasSectionResolution ? refForVariant(legacyRefs, headerFooterType) : undefined);
|
|
322145
|
+
const sectionRId = resolvedRef?.refId;
|
|
322146
|
+
const layoutVariantType = resolvedRef?.matchedVariant ?? headerFooterType;
|
|
321727
322147
|
const compositeKey = sectionRId ? `${sectionRId}::s${sectionIndex}` : undefined;
|
|
321728
322148
|
const rIdLayoutKey = compositeKey && layoutsByRId.has(compositeKey) && compositeKey || sectionRId && layoutsByRId.has(sectionRId) && sectionRId || undefined;
|
|
321729
322149
|
if (rIdLayoutKey) {
|
|
@@ -321746,8 +322166,9 @@ menclose::after {
|
|
|
321746
322166
|
const rawLayoutHeight$1 = rIdLayout.layout.height ?? 0;
|
|
321747
322167
|
const metrics$1 = this.#computeMetrics(kind, rawLayoutHeight$1, box$1, pageHeight$1, margins$1?.footer ?? 0);
|
|
321748
322168
|
const layoutMinY$1 = rIdLayout.layout.minY ?? 0;
|
|
321749
|
-
const
|
|
321750
|
-
const
|
|
322169
|
+
const normalizationMinY$1 = getDecorationNormalizationMinY(fragments$1, layoutMinY$1);
|
|
322170
|
+
const normalizedFragments$1 = normalizeDecorationFragments(fragments$1, normalizationMinY$1);
|
|
322171
|
+
const normalizedItems$1 = normalizeDecorationItems(alignedItems, normalizationMinY$1);
|
|
321751
322172
|
const isActiveHeaderFooter$1 = this.#isActiveDecoration(kind, sectionRId, pageNumber);
|
|
321752
322173
|
return {
|
|
321753
322174
|
fragments: normalizedFragments$1,
|
|
@@ -321779,7 +322200,7 @@ menclose::after {
|
|
|
321779
322200
|
}
|
|
321780
322201
|
if (!results || results.length === 0)
|
|
321781
322202
|
return null;
|
|
321782
|
-
const variantIndex = results.findIndex((entry) => entry.type ===
|
|
322203
|
+
const variantIndex = results.findIndex((entry) => entry.type === layoutVariantType);
|
|
321783
322204
|
const variant = variantIndex >= 0 ? results[variantIndex] : undefined;
|
|
321784
322205
|
if (!variant || !variant.layout?.pages?.length)
|
|
321785
322206
|
return null;
|
|
@@ -321790,7 +322211,7 @@ menclose::after {
|
|
|
321790
322211
|
const fallbackId = this.#headerFooterManager?.getVariantId(kind, headerFooterType);
|
|
321791
322212
|
const finalHeaderId = sectionRId ?? fallbackId ?? undefined;
|
|
321792
322213
|
const resolvedVariant = resolvedResults?.[variantIndex];
|
|
321793
|
-
const alignedVariantItems = this.resolveAlignedDecorationItems(fragments, slotPage.number, variant, resolvedVariant, `variant '${
|
|
322214
|
+
const alignedVariantItems = this.resolveAlignedDecorationItems(fragments, slotPage.number, variant, resolvedVariant, `variant '${layoutVariantType}' page ${pageNumber}`, finalHeaderId ?? headerFooterType);
|
|
321794
322215
|
if (!alignedVariantItems)
|
|
321795
322216
|
return null;
|
|
321796
322217
|
const pageHeight = page?.height ?? resolvedLayout.pages[0]?.height ?? layoutOptions.pageSize?.h ?? defaultPageSize.h;
|
|
@@ -321800,8 +322221,9 @@ menclose::after {
|
|
|
321800
322221
|
const rawLayoutHeight = variant.layout.height ?? 0;
|
|
321801
322222
|
const metrics = this.#computeMetrics(kind, rawLayoutHeight, box, pageHeight, margins?.footer ?? 0);
|
|
321802
322223
|
const layoutMinY = variant.layout.minY ?? 0;
|
|
321803
|
-
const
|
|
321804
|
-
const
|
|
322224
|
+
const normalizationMinY = getDecorationNormalizationMinY(fragments, layoutMinY);
|
|
322225
|
+
const normalizedFragments = normalizeDecorationFragments(fragments, normalizationMinY);
|
|
322226
|
+
const normalizedItems = normalizeDecorationItems(alignedVariantItems, normalizationMinY);
|
|
321805
322227
|
const isActiveHeaderFooter = this.#isActiveDecoration(kind, finalHeaderId, pageNumber);
|
|
321806
322228
|
return {
|
|
321807
322229
|
fragments: normalizedFragments,
|
|
@@ -322382,13 +322804,13 @@ menclose::after {
|
|
|
322382
322804
|
return;
|
|
322383
322805
|
console.log(...args$1);
|
|
322384
322806
|
}, 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;
|
|
322385
|
-
var
|
|
322807
|
+
var init_src_BbNQjpxw_es = __esm(() => {
|
|
322386
322808
|
init_rolldown_runtime_Bg48TavK_es();
|
|
322387
|
-
|
|
322809
|
+
init_SuperConverter_CvwFiCth_es();
|
|
322388
322810
|
init_jszip_C49i9kUs_es();
|
|
322389
322811
|
init_xml_js_CqGKpaft_es();
|
|
322390
322812
|
init_uuid_qzgm05fK_es();
|
|
322391
|
-
|
|
322813
|
+
init_create_headless_toolbar_DdDLS67b_es();
|
|
322392
322814
|
init_constants_D_X7xF4s_es();
|
|
322393
322815
|
init_dist_B8HfvhaK_es();
|
|
322394
322816
|
init_unified_Dsuw2be5_es();
|
|
@@ -329268,10 +329690,24 @@ ${err.toString()}`);
|
|
|
329268
329690
|
} };
|
|
329269
329691
|
},
|
|
329270
329692
|
addAttributes() {
|
|
329271
|
-
return {
|
|
329272
|
-
|
|
329273
|
-
|
|
329274
|
-
|
|
329693
|
+
return {
|
|
329694
|
+
marksAsAttrs: {
|
|
329695
|
+
default: null,
|
|
329696
|
+
rendered: false
|
|
329697
|
+
},
|
|
329698
|
+
instruction: {
|
|
329699
|
+
default: null,
|
|
329700
|
+
rendered: false
|
|
329701
|
+
},
|
|
329702
|
+
pageNumberFormat: {
|
|
329703
|
+
default: null,
|
|
329704
|
+
rendered: false
|
|
329705
|
+
},
|
|
329706
|
+
pageNumberZeroPadding: {
|
|
329707
|
+
default: null,
|
|
329708
|
+
rendered: false
|
|
329709
|
+
}
|
|
329710
|
+
};
|
|
329275
329711
|
},
|
|
329276
329712
|
addNodeView() {
|
|
329277
329713
|
return ({ node: node3, editor, getPos, decorations }) => {
|
|
@@ -329328,6 +329764,18 @@ ${err.toString()}`);
|
|
|
329328
329764
|
default: null,
|
|
329329
329765
|
rendered: false
|
|
329330
329766
|
},
|
|
329767
|
+
instruction: {
|
|
329768
|
+
default: null,
|
|
329769
|
+
rendered: false
|
|
329770
|
+
},
|
|
329771
|
+
pageNumberFormat: {
|
|
329772
|
+
default: null,
|
|
329773
|
+
rendered: false
|
|
329774
|
+
},
|
|
329775
|
+
pageNumberZeroPadding: {
|
|
329776
|
+
default: null,
|
|
329777
|
+
rendered: false
|
|
329778
|
+
},
|
|
329331
329779
|
importedCachedText: {
|
|
329332
329780
|
default: null,
|
|
329333
329781
|
rendered: false
|
|
@@ -356738,11 +357186,11 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
356738
357186
|
]);
|
|
356739
357187
|
});
|
|
356740
357188
|
|
|
356741
|
-
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-
|
|
357189
|
+
// ../../packages/superdoc/dist/chunks/create-super-doc-ui-Dzh6dolN.es.js
|
|
356742
357190
|
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;
|
|
356743
|
-
var
|
|
356744
|
-
|
|
356745
|
-
|
|
357191
|
+
var init_create_super_doc_ui_Dzh6dolN_es = __esm(() => {
|
|
357192
|
+
init_SuperConverter_CvwFiCth_es();
|
|
357193
|
+
init_create_headless_toolbar_DdDLS67b_es();
|
|
356746
357194
|
MOD_ALIASES = new Set([
|
|
356747
357195
|
"Mod",
|
|
356748
357196
|
"Meta",
|
|
@@ -356784,16 +357232,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
|
|
|
356784
357232
|
|
|
356785
357233
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
356786
357234
|
var init_super_editor_es = __esm(() => {
|
|
356787
|
-
|
|
356788
|
-
|
|
357235
|
+
init_src_BbNQjpxw_es();
|
|
357236
|
+
init_SuperConverter_CvwFiCth_es();
|
|
356789
357237
|
init_jszip_C49i9kUs_es();
|
|
356790
357238
|
init_xml_js_CqGKpaft_es();
|
|
356791
|
-
|
|
357239
|
+
init_create_headless_toolbar_DdDLS67b_es();
|
|
356792
357240
|
init_constants_D_X7xF4s_es();
|
|
356793
357241
|
init_dist_B8HfvhaK_es();
|
|
356794
357242
|
init_unified_Dsuw2be5_es();
|
|
356795
357243
|
init_DocxZipper_nv_KfOqb_es();
|
|
356796
|
-
|
|
357244
|
+
init_create_super_doc_ui_Dzh6dolN_es();
|
|
356797
357245
|
init_ui_C5PAS9hY_es();
|
|
356798
357246
|
init_eventemitter3_BnGqBE_Q_es();
|
|
356799
357247
|
init_errors_CNaD6vcg_es();
|