ooxml-core 0.17.0 → 0.19.0
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/docx/column-settings.d.ts +16 -0
- package/dist/docx/column-settings.d.ts.map +1 -0
- package/dist/docx/document-stats.d.ts +18 -0
- package/dist/docx/document-stats.d.ts.map +1 -0
- package/dist/docx/index.cjs +206 -0
- package/dist/docx/index.d.ts +4 -0
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +190 -1
- package/dist/docx/line-spacing.d.ts +9 -0
- package/dist/docx/line-spacing.d.ts.map +1 -0
- package/dist/docx/section-layout.d.ts +14 -0
- package/dist/docx/section-layout.d.ts.map +1 -0
- package/dist/xlsx/formula/editor-text.d.ts +60 -0
- package/dist/xlsx/formula/editor-text.d.ts.map +1 -0
- package/dist/xlsx/formula/index.d.ts +1 -0
- package/dist/xlsx/formula/index.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +171 -0
- package/dist/xlsx/index.mjs +158 -1
- package/package.json +2 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SectionColumns, SectionProperties } from './section-model.js';
|
|
2
|
+
export declare const columnTextWidth: (section: SectionProperties) => number;
|
|
3
|
+
/** Word's Left/Right presets reserve one third of the text width for the narrow column. */
|
|
4
|
+
export declare function unequalColumnPreset(section: SectionProperties, preset: 'left' | 'right'): SectionColumns;
|
|
5
|
+
export declare function columnPreset(columns: SectionColumns): string;
|
|
6
|
+
export interface ColumnDraft {
|
|
7
|
+
widths: number[];
|
|
8
|
+
gaps: number[];
|
|
9
|
+
}
|
|
10
|
+
export declare function equalColumnDraft(total: number, count: number, gap: number): ColumnDraft;
|
|
11
|
+
export declare function readColumnDraft(section: SectionProperties): ColumnDraft;
|
|
12
|
+
/** Keep the overall text width fixed by taking the difference from the adjacent column. */
|
|
13
|
+
export declare function changeColumnWidth(draft: ColumnDraft, index: number, width: number): void;
|
|
14
|
+
export declare function changeColumnGap(draft: ColumnDraft, index: number, gap: number): void;
|
|
15
|
+
export declare function validColumnDraft(draft: ColumnDraft, total: number): boolean;
|
|
16
|
+
//# sourceMappingURL=column-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-settings.d.ts","sourceRoot":"","sources":["../../src/docx/column-settings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5E,eAAO,MAAM,eAAe,YAAa,iBAAiB,KAAG,MAIlC,CAAC;AAE5B,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,GAAG,OAAO,GACtB,cAAc,CAchB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAQ5D;AAED,MAAM,WAAW,WAAW;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CACf;AACD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAQvF;AACD,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,CAgBvE;AACD,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAKxF;AACD,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAIpF;AACD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAM3E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DocumentModel } from './model.js';
|
|
2
|
+
export interface DocumentStats {
|
|
3
|
+
paragraphs: number;
|
|
4
|
+
tables: number;
|
|
5
|
+
sections: number;
|
|
6
|
+
characters: number;
|
|
7
|
+
charactersWithSpaces: number;
|
|
8
|
+
comments: number;
|
|
9
|
+
revisions: number;
|
|
10
|
+
}
|
|
11
|
+
/** Facts for the File > Info page: counts of what the model holds, not layout results. */
|
|
12
|
+
export declare function documentStats(model: DocumentModel): DocumentStats;
|
|
13
|
+
/**
|
|
14
|
+
* The document as plain text for File > Export: one line per paragraph, table cells separated by
|
|
15
|
+
* tabs. Formatting, pictures and notes are not exported.
|
|
16
|
+
*/
|
|
17
|
+
export declare function plainText(model: DocumentModel): string;
|
|
18
|
+
//# sourceMappingURL=document-stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-stats.d.ts","sourceRoot":"","sources":["../../src/docx/document-stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,aAAa,EAAE,MAAM,YAAY,CAAC;AAGvD,MAAM,WAAW,aAAa;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB;AAmBD,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAmBjE;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAUtD"}
|
package/dist/docx/index.cjs
CHANGED
|
@@ -9631,6 +9631,195 @@ function resolveCellVisuals(table, cell, placement, styles) {
|
|
|
9631
9631
|
return { borders, ...shadingFill ? { shadingFill } : {} };
|
|
9632
9632
|
}
|
|
9633
9633
|
|
|
9634
|
+
// src/docx/document-stats.ts
|
|
9635
|
+
function visibleText(paragraph) {
|
|
9636
|
+
return paragraph.runs.filter((run) => !run.fieldCode && !run.fieldChar).filter((run) => run.revision?.kind !== "delete" && run.revision?.kind !== "moveFrom").map((run) => run.text).join("");
|
|
9637
|
+
}
|
|
9638
|
+
function paragraphsOf3(blocks) {
|
|
9639
|
+
return blocks.flatMap(
|
|
9640
|
+
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((cell) => cell.paragraphs))
|
|
9641
|
+
);
|
|
9642
|
+
}
|
|
9643
|
+
function documentStats(model) {
|
|
9644
|
+
const paragraphs = paragraphsOf3(model.blocks);
|
|
9645
|
+
const text = paragraphs.map(visibleText).join("");
|
|
9646
|
+
const revisions = paragraphs.reduce(
|
|
9647
|
+
(count, paragraph) => count + paragraph.runs.filter((run) => run.revision).length + (paragraph.markRevision ? 1 : 0),
|
|
9648
|
+
0
|
|
9649
|
+
);
|
|
9650
|
+
return {
|
|
9651
|
+
paragraphs: paragraphs.length,
|
|
9652
|
+
tables: model.blocks.filter((block) => block.type === "table").length,
|
|
9653
|
+
sections: model.sections?.length ?? 1,
|
|
9654
|
+
characters: [...text.replace(/\s/g, "")].length,
|
|
9655
|
+
charactersWithSpaces: [...text].length,
|
|
9656
|
+
comments: model.comments?.length ?? 0,
|
|
9657
|
+
revisions
|
|
9658
|
+
};
|
|
9659
|
+
}
|
|
9660
|
+
function plainText2(model) {
|
|
9661
|
+
return model.blocks.map(
|
|
9662
|
+
(block) => block.type === "paragraph" ? visibleText(block) : block.rows.map((row) => row.map((cell) => cell.paragraphs.map(visibleText).join(" ")).join(" ")).join("\n")
|
|
9663
|
+
).join("\n");
|
|
9664
|
+
}
|
|
9665
|
+
|
|
9666
|
+
// src/docx/column-settings.ts
|
|
9667
|
+
var columnTextWidth = (section) => section.pageWidthTwips - section.marginLeftTwips - section.marginRightTwips - (section.gutterTwips ?? 0);
|
|
9668
|
+
function unequalColumnPreset(section, preset) {
|
|
9669
|
+
const gap = 720;
|
|
9670
|
+
const available = columnTextWidth(section) - gap;
|
|
9671
|
+
const narrow = Math.round(available / 3);
|
|
9672
|
+
const wide = available - narrow;
|
|
9673
|
+
return {
|
|
9674
|
+
count: 2,
|
|
9675
|
+
equalWidth: false,
|
|
9676
|
+
spacingTwips: twips(gap),
|
|
9677
|
+
widths: [
|
|
9678
|
+
{ widthTwips: twips(preset === "left" ? narrow : wide), spacingTwips: twips(gap) },
|
|
9679
|
+
{ widthTwips: twips(preset === "left" ? wide : narrow) }
|
|
9680
|
+
]
|
|
9681
|
+
};
|
|
9682
|
+
}
|
|
9683
|
+
function columnPreset(columns) {
|
|
9684
|
+
if (columns.equalWidth) return String(columns.count);
|
|
9685
|
+
const [a, b] = columns.widths ?? [];
|
|
9686
|
+
if (columns.count === 2 && a && b) {
|
|
9687
|
+
if (Math.abs(a.widthTwips * 2 - b.widthTwips) <= 2) return "left";
|
|
9688
|
+
if (Math.abs(b.widthTwips * 2 - a.widthTwips) <= 2) return "right";
|
|
9689
|
+
}
|
|
9690
|
+
return "";
|
|
9691
|
+
}
|
|
9692
|
+
function equalColumnDraft(total, count, gap) {
|
|
9693
|
+
const width = Math.floor((total - gap * (count - 1)) / count);
|
|
9694
|
+
return {
|
|
9695
|
+
widths: Array.from(
|
|
9696
|
+
{ length: count },
|
|
9697
|
+
(_, i) => i === count - 1 ? total - gap * (count - 1) - width * (count - 1) : width
|
|
9698
|
+
),
|
|
9699
|
+
gaps: Array.from({ length: count }, (_, i) => i === count - 1 ? 0 : gap)
|
|
9700
|
+
};
|
|
9701
|
+
}
|
|
9702
|
+
function readColumnDraft(section) {
|
|
9703
|
+
const fallback = equalColumnDraft(
|
|
9704
|
+
columnTextWidth(section),
|
|
9705
|
+
section.columns.count,
|
|
9706
|
+
section.columns.spacingTwips ?? 720
|
|
9707
|
+
);
|
|
9708
|
+
return !section.columns.equalWidth && section.columns.widths?.length === section.columns.count ? {
|
|
9709
|
+
widths: section.columns.widths.map((column) => column.widthTwips),
|
|
9710
|
+
gaps: section.columns.widths.map(
|
|
9711
|
+
(column, i) => i === section.columns.count - 1 ? 0 : column.spacingTwips ?? section.columns.spacingTwips ?? 720
|
|
9712
|
+
)
|
|
9713
|
+
} : fallback;
|
|
9714
|
+
}
|
|
9715
|
+
function changeColumnWidth(draft, index, width) {
|
|
9716
|
+
const delta = width - draft.widths[index];
|
|
9717
|
+
draft.widths[index] = width;
|
|
9718
|
+
const neighbor = index < draft.widths.length - 1 ? index + 1 : index - 1;
|
|
9719
|
+
if (neighbor >= 0) draft.widths[neighbor] = draft.widths[neighbor] - delta;
|
|
9720
|
+
}
|
|
9721
|
+
function changeColumnGap(draft, index, gap) {
|
|
9722
|
+
const delta = gap - draft.gaps[index];
|
|
9723
|
+
draft.gaps[index] = gap;
|
|
9724
|
+
if (index + 1 < draft.widths.length) draft.widths[index + 1] = draft.widths[index + 1] - delta;
|
|
9725
|
+
}
|
|
9726
|
+
function validColumnDraft(draft, total) {
|
|
9727
|
+
return draft.widths.every((width) => Number.isSafeInteger(width) && width >= 720) && draft.gaps.every((gap) => Number.isSafeInteger(gap) && gap >= 0) && Math.abs(draft.widths.reduce((sum, value, i) => sum + value + draft.gaps[i], 0) - total) <= 1;
|
|
9728
|
+
}
|
|
9729
|
+
|
|
9730
|
+
// src/docx/line-spacing.ts
|
|
9731
|
+
var lineSpacingOptions = [
|
|
9732
|
+
["inherit", "Line: style default"],
|
|
9733
|
+
["auto:240", "1.0 lines"],
|
|
9734
|
+
["auto:276", "1.15 lines"],
|
|
9735
|
+
["auto:360", "1.5 lines"],
|
|
9736
|
+
["auto:480", "2.0 lines"],
|
|
9737
|
+
["auto:600", "2.5 lines"],
|
|
9738
|
+
["auto:720", "3.0 lines"]
|
|
9739
|
+
];
|
|
9740
|
+
function lineSpacingValue(attrs) {
|
|
9741
|
+
const rule = attrs.lineSpacingRule === "exact" || attrs.lineSpacingRule === "atLeast" ? attrs.lineSpacingRule : "auto";
|
|
9742
|
+
if (!Number.isSafeInteger(attrs.lineSpacingTwips))
|
|
9743
|
+
return attrs.lineSpacingRule === "exact" || attrs.lineSpacingRule === "atLeast" ? `rule-only:${attrs.lineSpacingRule}` : "inherit";
|
|
9744
|
+
return `${rule}:${Number(attrs.lineSpacingTwips)}`;
|
|
9745
|
+
}
|
|
9746
|
+
function lineSpacingLabel(value) {
|
|
9747
|
+
if (value === "inherit") return "Style default";
|
|
9748
|
+
const ruleOnly = /^rule-only:(exact|atLeast)$/.exec(value);
|
|
9749
|
+
if (ruleOnly) return `${ruleOnly[1] === "exact" ? "Exact" : "At least"} rule (no amount)`;
|
|
9750
|
+
const match = /^(auto|exact|atLeast):(\d+)$/.exec(value);
|
|
9751
|
+
if (!match) return "Mixed paragraphs";
|
|
9752
|
+
const [, rule, rawTwips] = match;
|
|
9753
|
+
const twips3 = Number(rawTwips);
|
|
9754
|
+
if (rule === "auto") {
|
|
9755
|
+
const ratios = {
|
|
9756
|
+
240: "1.0",
|
|
9757
|
+
276: "1.15",
|
|
9758
|
+
360: "1.5",
|
|
9759
|
+
480: "2.0",
|
|
9760
|
+
600: "2.5",
|
|
9761
|
+
720: "3.0"
|
|
9762
|
+
};
|
|
9763
|
+
return ratios[twips3] ? `${ratios[twips3]} lines` : `Automatic ${(twips3 / 240).toLocaleString(void 0, { maximumFractionDigits: 3 })} lines (${twips3}/240)`;
|
|
9764
|
+
}
|
|
9765
|
+
const points = (twips3 / 20).toLocaleString(void 0, { maximumFractionDigits: 2 });
|
|
9766
|
+
return `${rule === "exact" ? "Exact" : "At least"} ${points} pt`;
|
|
9767
|
+
}
|
|
9768
|
+
function parseLineSpacingValue(value) {
|
|
9769
|
+
const match = /^(auto|exact|atLeast):(\d+)$/.exec(value);
|
|
9770
|
+
if (!match) return null;
|
|
9771
|
+
const twips3 = Number(match[2]);
|
|
9772
|
+
return Number.isSafeInteger(twips3) && twips3 >= 0 ? { rule: match[1], twips: twips3 } : null;
|
|
9773
|
+
}
|
|
9774
|
+
|
|
9775
|
+
// src/docx/section-layout.ts
|
|
9776
|
+
function sectionLayoutJson(sections) {
|
|
9777
|
+
return JSON.stringify(
|
|
9778
|
+
sections.map(({ headers: _headers, footers: _footers, ...layout2 }) => layout2)
|
|
9779
|
+
);
|
|
9780
|
+
}
|
|
9781
|
+
function sectionsFromLayout(json, prior, blocks) {
|
|
9782
|
+
const layout2 = JSON.parse(json);
|
|
9783
|
+
const order = new Map(blocks.map((block, index) => [block.id, index]));
|
|
9784
|
+
const priorSections = prior ?? [];
|
|
9785
|
+
const endOf = (section, index, list) => index === list.length - 1 ? Number.POSITIVE_INFINITY : order.get(section.endsAtBlockId) ?? -1;
|
|
9786
|
+
const kept = layout2.filter(
|
|
9787
|
+
(section, index) => index === layout2.length - 1 || order.has(section.endsAtBlockId)
|
|
9788
|
+
);
|
|
9789
|
+
return kept.map((section, index) => {
|
|
9790
|
+
const end = endOf(section, index, kept);
|
|
9791
|
+
const source = priorSections.find((candidate) => candidate.endsAtBlockId === section.endsAtBlockId) ?? priorSections.find(
|
|
9792
|
+
(candidate, position) => endOf(candidate, position, priorSections) >= end
|
|
9793
|
+
) ?? priorSections.at(-1);
|
|
9794
|
+
return {
|
|
9795
|
+
...section,
|
|
9796
|
+
...source?.headers ? { headers: source.headers } : {},
|
|
9797
|
+
...source?.footers ? { footers: source.footers } : {}
|
|
9798
|
+
};
|
|
9799
|
+
});
|
|
9800
|
+
}
|
|
9801
|
+
function sectionsOf(model) {
|
|
9802
|
+
if (model.sections?.length) return model.sections;
|
|
9803
|
+
const { page } = model;
|
|
9804
|
+
return [
|
|
9805
|
+
{
|
|
9806
|
+
endsAtBlockId: model.blocks.at(-1)?.id ?? "",
|
|
9807
|
+
type: "nextPage",
|
|
9808
|
+
pageWidthTwips: twipsFromPixels(page.width),
|
|
9809
|
+
pageHeightTwips: twipsFromPixels(page.height),
|
|
9810
|
+
orientation: page.width > page.height ? "landscape" : "portrait",
|
|
9811
|
+
marginTopTwips: signedTwipsFromPixels(page.marginTop),
|
|
9812
|
+
marginRightTwips: twipsFromPixels(page.marginRight),
|
|
9813
|
+
marginBottomTwips: signedTwipsFromPixels(page.marginBottom),
|
|
9814
|
+
marginLeftTwips: twipsFromPixels(page.marginLeft),
|
|
9815
|
+
headerDistanceTwips: twips(720),
|
|
9816
|
+
footerDistanceTwips: twips(720),
|
|
9817
|
+
gutterTwips: twips(0),
|
|
9818
|
+
columns: { count: 1, spacingTwips: twips(720), equalWidth: true }
|
|
9819
|
+
}
|
|
9820
|
+
];
|
|
9821
|
+
}
|
|
9822
|
+
|
|
9634
9823
|
exports.DEFAULT_STYLES_XML = DEFAULT_STYLES_XML;
|
|
9635
9824
|
exports.DEFAULT_TABLE_BORDERS = DEFAULT_TABLE_BORDERS;
|
|
9636
9825
|
exports.DEFAULT_TOC_INSTRUCTION = DEFAULT_TOC_INSTRUCTION;
|
|
@@ -9755,6 +9944,10 @@ exports.applyThemeTint = applyThemeTint;
|
|
|
9755
9944
|
exports.assertValidDocumentModel = assertValidDocumentModel;
|
|
9756
9945
|
exports.buildTableOfContents = buildTableOfContents;
|
|
9757
9946
|
exports.captionParagraphs = captionParagraphs;
|
|
9947
|
+
exports.changeColumnGap = changeColumnGap;
|
|
9948
|
+
exports.changeColumnWidth = changeColumnWidth;
|
|
9949
|
+
exports.columnPreset = columnPreset;
|
|
9950
|
+
exports.columnTextWidth = columnTextWidth;
|
|
9758
9951
|
exports.computeListLabels = computeListLabels;
|
|
9759
9952
|
exports.createDocument = createDocument;
|
|
9760
9953
|
exports.createListDefinition = createListDefinition;
|
|
@@ -9764,6 +9957,7 @@ exports.defaultStyleCatalogs = defaultStyleCatalogs;
|
|
|
9764
9957
|
exports.diagramColorTheme = diagramColorTheme;
|
|
9765
9958
|
exports.diagramsIn = diagramsIn;
|
|
9766
9959
|
exports.displayListLabel = displayListLabel;
|
|
9960
|
+
exports.documentStats = documentStats;
|
|
9767
9961
|
exports.eighthPoints = eighthPoints;
|
|
9768
9962
|
exports.eighthPointsFromPoints = eighthPointsFromPoints;
|
|
9769
9963
|
exports.eighthPointsToPoints = eighthPointsToPoints;
|
|
@@ -9772,6 +9966,7 @@ exports.emuFromPixels = emuFromPixels;
|
|
|
9772
9966
|
exports.emuToPixels = emuToPixels;
|
|
9773
9967
|
exports.ensureListDefinition = ensureListDefinition;
|
|
9774
9968
|
exports.enumValue = enumValue;
|
|
9969
|
+
exports.equalColumnDraft = equalColumnDraft;
|
|
9775
9970
|
exports.fieldName = fieldName;
|
|
9776
9971
|
exports.findRevision = findRevision;
|
|
9777
9972
|
exports.findTableOfContents = findTableOfContents;
|
|
@@ -9889,6 +10084,9 @@ exports.isThemeColorToken = isThemeColorToken;
|
|
|
9889
10084
|
exports.isValidLanguageTag = isValidLanguageTag;
|
|
9890
10085
|
exports.isWordHighlightToken = isWordHighlightToken;
|
|
9891
10086
|
exports.isWordUnderlineStyle = isWordUnderlineStyle;
|
|
10087
|
+
exports.lineSpacingLabel = lineSpacingLabel;
|
|
10088
|
+
exports.lineSpacingOptions = lineSpacingOptions;
|
|
10089
|
+
exports.lineSpacingValue = lineSpacingValue;
|
|
9892
10090
|
exports.linkStylesToList = linkStylesToList;
|
|
9893
10091
|
exports.listRevisions = listRevisions;
|
|
9894
10092
|
exports.loadDocx = loadDocx;
|
|
@@ -9901,6 +10099,7 @@ exports.parseHalfPoints = parseHalfPoints;
|
|
|
9901
10099
|
exports.parseHexColor = parseHexColor;
|
|
9902
10100
|
exports.parseInteger = parseInteger;
|
|
9903
10101
|
exports.parseJustification = parseJustification;
|
|
10102
|
+
exports.parseLineSpacingValue = parseLineSpacingValue;
|
|
9904
10103
|
exports.parseNumberingCatalog = parseNumberingCatalog;
|
|
9905
10104
|
exports.parseOnOff = parseOnOff;
|
|
9906
10105
|
exports.parseParagraphStyleCatalog = parseParagraphStyleCatalog;
|
|
@@ -9914,6 +10113,8 @@ exports.parseTheme = parseTheme;
|
|
|
9914
10113
|
exports.parseTintShade = parseTintShade;
|
|
9915
10114
|
exports.parseTwips = parseTwips;
|
|
9916
10115
|
exports.parseUnsignedInteger = parseUnsignedInteger;
|
|
10116
|
+
exports.plainText = plainText2;
|
|
10117
|
+
exports.readColumnDraft = readColumnDraft;
|
|
9917
10118
|
exports.rejectAllRevisions = rejectAllRevisions;
|
|
9918
10119
|
exports.rejectRevision = rejectRevision;
|
|
9919
10120
|
exports.reportParseWarning = reportParseWarning;
|
|
@@ -9933,6 +10134,9 @@ exports.roundHalfPoints = roundHalfPoints;
|
|
|
9933
10134
|
exports.roundSignedTwips = roundSignedTwips;
|
|
9934
10135
|
exports.roundTwips = roundTwips;
|
|
9935
10136
|
exports.saveDocx = saveDocx;
|
|
10137
|
+
exports.sectionLayoutJson = sectionLayoutJson;
|
|
10138
|
+
exports.sectionsFromLayout = sectionsFromLayout;
|
|
10139
|
+
exports.sectionsOf = sectionsOf;
|
|
9936
10140
|
exports.signedTwips = signedTwips;
|
|
9937
10141
|
exports.signedTwipsFromPixels = signedTwipsFromPixels;
|
|
9938
10142
|
exports.signedTwipsFromPoints = signedTwipsFromPoints;
|
|
@@ -9949,8 +10153,10 @@ exports.twipsFromPoints = twipsFromPoints;
|
|
|
9949
10153
|
exports.twipsToInches = twipsToInches;
|
|
9950
10154
|
exports.twipsToPixels = twipsToPixels;
|
|
9951
10155
|
exports.twipsToPoints = twipsToPoints;
|
|
10156
|
+
exports.unequalColumnPreset = unequalColumnPreset;
|
|
9952
10157
|
exports.universalMeasureToTwips = universalMeasureToTwips;
|
|
9953
10158
|
exports.updateTableOfContents = updateTableOfContents;
|
|
10159
|
+
exports.validColumnDraft = validColumnDraft;
|
|
9954
10160
|
exports.validateDocumentModel = validateDocumentModel;
|
|
9955
10161
|
exports.withParseWarnings = withParseWarnings;
|
|
9956
10162
|
exports.withTocBookmarks = withTocBookmarks;
|
package/dist/docx/index.d.ts
CHANGED
|
@@ -37,4 +37,8 @@ export type { ParagraphAlign, ParsedJustification } from './paragraph-alignment.
|
|
|
37
37
|
export { withParseWarnings, enumValue, reportParseWarning } from './parse-diagnostics.js';
|
|
38
38
|
export { PROPERTY_FIELDS, type DocumentProperties } from './core-properties.js';
|
|
39
39
|
export { captionParagraphs, isCaptionOf, tableOfFiguresInstruction, tocCaptionLabel, } from './table-of-figures.js';
|
|
40
|
+
export * from './document-stats.js';
|
|
41
|
+
export * from './column-settings.js';
|
|
42
|
+
export * from './line-spacing.js';
|
|
43
|
+
export * from './section-layout.js';
|
|
40
44
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/docx/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docx/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC9E,cAAc,eAAe,CAAC;AAC9B,OAAO,EACN,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EACN,sBAAsB,EACtB,0BAA0B,EAC1B,cAAc,EACd,eAAe,EACf,iBAAiB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EACN,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,oBAAoB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EA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AoB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,cAAc,iCAAiC,CAAC;AAChD,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACtF,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACN,iBAAiB,EACjB,WAAW,EACX,yBAAyB,EACzB,eAAe,GACf,MAAM,uBAAuB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
package/dist/docx/index.mjs
CHANGED
|
@@ -9625,4 +9625,193 @@ function resolveCellVisuals(table, cell, placement, styles) {
|
|
|
9625
9625
|
return { borders, ...shadingFill ? { shadingFill } : {} };
|
|
9626
9626
|
}
|
|
9627
9627
|
|
|
9628
|
-
|
|
9628
|
+
// src/docx/document-stats.ts
|
|
9629
|
+
function visibleText(paragraph) {
|
|
9630
|
+
return paragraph.runs.filter((run) => !run.fieldCode && !run.fieldChar).filter((run) => run.revision?.kind !== "delete" && run.revision?.kind !== "moveFrom").map((run) => run.text).join("");
|
|
9631
|
+
}
|
|
9632
|
+
function paragraphsOf3(blocks) {
|
|
9633
|
+
return blocks.flatMap(
|
|
9634
|
+
(block) => block.type === "paragraph" ? [block] : block.rows.flatMap((row) => row.flatMap((cell) => cell.paragraphs))
|
|
9635
|
+
);
|
|
9636
|
+
}
|
|
9637
|
+
function documentStats(model) {
|
|
9638
|
+
const paragraphs = paragraphsOf3(model.blocks);
|
|
9639
|
+
const text = paragraphs.map(visibleText).join("");
|
|
9640
|
+
const revisions = paragraphs.reduce(
|
|
9641
|
+
(count, paragraph) => count + paragraph.runs.filter((run) => run.revision).length + (paragraph.markRevision ? 1 : 0),
|
|
9642
|
+
0
|
|
9643
|
+
);
|
|
9644
|
+
return {
|
|
9645
|
+
paragraphs: paragraphs.length,
|
|
9646
|
+
tables: model.blocks.filter((block) => block.type === "table").length,
|
|
9647
|
+
sections: model.sections?.length ?? 1,
|
|
9648
|
+
characters: [...text.replace(/\s/g, "")].length,
|
|
9649
|
+
charactersWithSpaces: [...text].length,
|
|
9650
|
+
comments: model.comments?.length ?? 0,
|
|
9651
|
+
revisions
|
|
9652
|
+
};
|
|
9653
|
+
}
|
|
9654
|
+
function plainText2(model) {
|
|
9655
|
+
return model.blocks.map(
|
|
9656
|
+
(block) => block.type === "paragraph" ? visibleText(block) : block.rows.map((row) => row.map((cell) => cell.paragraphs.map(visibleText).join(" ")).join(" ")).join("\n")
|
|
9657
|
+
).join("\n");
|
|
9658
|
+
}
|
|
9659
|
+
|
|
9660
|
+
// src/docx/column-settings.ts
|
|
9661
|
+
var columnTextWidth = (section) => section.pageWidthTwips - section.marginLeftTwips - section.marginRightTwips - (section.gutterTwips ?? 0);
|
|
9662
|
+
function unequalColumnPreset(section, preset) {
|
|
9663
|
+
const gap = 720;
|
|
9664
|
+
const available = columnTextWidth(section) - gap;
|
|
9665
|
+
const narrow = Math.round(available / 3);
|
|
9666
|
+
const wide = available - narrow;
|
|
9667
|
+
return {
|
|
9668
|
+
count: 2,
|
|
9669
|
+
equalWidth: false,
|
|
9670
|
+
spacingTwips: twips(gap),
|
|
9671
|
+
widths: [
|
|
9672
|
+
{ widthTwips: twips(preset === "left" ? narrow : wide), spacingTwips: twips(gap) },
|
|
9673
|
+
{ widthTwips: twips(preset === "left" ? wide : narrow) }
|
|
9674
|
+
]
|
|
9675
|
+
};
|
|
9676
|
+
}
|
|
9677
|
+
function columnPreset(columns) {
|
|
9678
|
+
if (columns.equalWidth) return String(columns.count);
|
|
9679
|
+
const [a, b] = columns.widths ?? [];
|
|
9680
|
+
if (columns.count === 2 && a && b) {
|
|
9681
|
+
if (Math.abs(a.widthTwips * 2 - b.widthTwips) <= 2) return "left";
|
|
9682
|
+
if (Math.abs(b.widthTwips * 2 - a.widthTwips) <= 2) return "right";
|
|
9683
|
+
}
|
|
9684
|
+
return "";
|
|
9685
|
+
}
|
|
9686
|
+
function equalColumnDraft(total, count, gap) {
|
|
9687
|
+
const width = Math.floor((total - gap * (count - 1)) / count);
|
|
9688
|
+
return {
|
|
9689
|
+
widths: Array.from(
|
|
9690
|
+
{ length: count },
|
|
9691
|
+
(_, i) => i === count - 1 ? total - gap * (count - 1) - width * (count - 1) : width
|
|
9692
|
+
),
|
|
9693
|
+
gaps: Array.from({ length: count }, (_, i) => i === count - 1 ? 0 : gap)
|
|
9694
|
+
};
|
|
9695
|
+
}
|
|
9696
|
+
function readColumnDraft(section) {
|
|
9697
|
+
const fallback = equalColumnDraft(
|
|
9698
|
+
columnTextWidth(section),
|
|
9699
|
+
section.columns.count,
|
|
9700
|
+
section.columns.spacingTwips ?? 720
|
|
9701
|
+
);
|
|
9702
|
+
return !section.columns.equalWidth && section.columns.widths?.length === section.columns.count ? {
|
|
9703
|
+
widths: section.columns.widths.map((column) => column.widthTwips),
|
|
9704
|
+
gaps: section.columns.widths.map(
|
|
9705
|
+
(column, i) => i === section.columns.count - 1 ? 0 : column.spacingTwips ?? section.columns.spacingTwips ?? 720
|
|
9706
|
+
)
|
|
9707
|
+
} : fallback;
|
|
9708
|
+
}
|
|
9709
|
+
function changeColumnWidth(draft, index, width) {
|
|
9710
|
+
const delta = width - draft.widths[index];
|
|
9711
|
+
draft.widths[index] = width;
|
|
9712
|
+
const neighbor = index < draft.widths.length - 1 ? index + 1 : index - 1;
|
|
9713
|
+
if (neighbor >= 0) draft.widths[neighbor] = draft.widths[neighbor] - delta;
|
|
9714
|
+
}
|
|
9715
|
+
function changeColumnGap(draft, index, gap) {
|
|
9716
|
+
const delta = gap - draft.gaps[index];
|
|
9717
|
+
draft.gaps[index] = gap;
|
|
9718
|
+
if (index + 1 < draft.widths.length) draft.widths[index + 1] = draft.widths[index + 1] - delta;
|
|
9719
|
+
}
|
|
9720
|
+
function validColumnDraft(draft, total) {
|
|
9721
|
+
return draft.widths.every((width) => Number.isSafeInteger(width) && width >= 720) && draft.gaps.every((gap) => Number.isSafeInteger(gap) && gap >= 0) && Math.abs(draft.widths.reduce((sum, value, i) => sum + value + draft.gaps[i], 0) - total) <= 1;
|
|
9722
|
+
}
|
|
9723
|
+
|
|
9724
|
+
// src/docx/line-spacing.ts
|
|
9725
|
+
var lineSpacingOptions = [
|
|
9726
|
+
["inherit", "Line: style default"],
|
|
9727
|
+
["auto:240", "1.0 lines"],
|
|
9728
|
+
["auto:276", "1.15 lines"],
|
|
9729
|
+
["auto:360", "1.5 lines"],
|
|
9730
|
+
["auto:480", "2.0 lines"],
|
|
9731
|
+
["auto:600", "2.5 lines"],
|
|
9732
|
+
["auto:720", "3.0 lines"]
|
|
9733
|
+
];
|
|
9734
|
+
function lineSpacingValue(attrs) {
|
|
9735
|
+
const rule = attrs.lineSpacingRule === "exact" || attrs.lineSpacingRule === "atLeast" ? attrs.lineSpacingRule : "auto";
|
|
9736
|
+
if (!Number.isSafeInteger(attrs.lineSpacingTwips))
|
|
9737
|
+
return attrs.lineSpacingRule === "exact" || attrs.lineSpacingRule === "atLeast" ? `rule-only:${attrs.lineSpacingRule}` : "inherit";
|
|
9738
|
+
return `${rule}:${Number(attrs.lineSpacingTwips)}`;
|
|
9739
|
+
}
|
|
9740
|
+
function lineSpacingLabel(value) {
|
|
9741
|
+
if (value === "inherit") return "Style default";
|
|
9742
|
+
const ruleOnly = /^rule-only:(exact|atLeast)$/.exec(value);
|
|
9743
|
+
if (ruleOnly) return `${ruleOnly[1] === "exact" ? "Exact" : "At least"} rule (no amount)`;
|
|
9744
|
+
const match = /^(auto|exact|atLeast):(\d+)$/.exec(value);
|
|
9745
|
+
if (!match) return "Mixed paragraphs";
|
|
9746
|
+
const [, rule, rawTwips] = match;
|
|
9747
|
+
const twips3 = Number(rawTwips);
|
|
9748
|
+
if (rule === "auto") {
|
|
9749
|
+
const ratios = {
|
|
9750
|
+
240: "1.0",
|
|
9751
|
+
276: "1.15",
|
|
9752
|
+
360: "1.5",
|
|
9753
|
+
480: "2.0",
|
|
9754
|
+
600: "2.5",
|
|
9755
|
+
720: "3.0"
|
|
9756
|
+
};
|
|
9757
|
+
return ratios[twips3] ? `${ratios[twips3]} lines` : `Automatic ${(twips3 / 240).toLocaleString(void 0, { maximumFractionDigits: 3 })} lines (${twips3}/240)`;
|
|
9758
|
+
}
|
|
9759
|
+
const points = (twips3 / 20).toLocaleString(void 0, { maximumFractionDigits: 2 });
|
|
9760
|
+
return `${rule === "exact" ? "Exact" : "At least"} ${points} pt`;
|
|
9761
|
+
}
|
|
9762
|
+
function parseLineSpacingValue(value) {
|
|
9763
|
+
const match = /^(auto|exact|atLeast):(\d+)$/.exec(value);
|
|
9764
|
+
if (!match) return null;
|
|
9765
|
+
const twips3 = Number(match[2]);
|
|
9766
|
+
return Number.isSafeInteger(twips3) && twips3 >= 0 ? { rule: match[1], twips: twips3 } : null;
|
|
9767
|
+
}
|
|
9768
|
+
|
|
9769
|
+
// src/docx/section-layout.ts
|
|
9770
|
+
function sectionLayoutJson(sections) {
|
|
9771
|
+
return JSON.stringify(
|
|
9772
|
+
sections.map(({ headers: _headers, footers: _footers, ...layout2 }) => layout2)
|
|
9773
|
+
);
|
|
9774
|
+
}
|
|
9775
|
+
function sectionsFromLayout(json, prior, blocks) {
|
|
9776
|
+
const layout2 = JSON.parse(json);
|
|
9777
|
+
const order = new Map(blocks.map((block, index) => [block.id, index]));
|
|
9778
|
+
const priorSections = prior ?? [];
|
|
9779
|
+
const endOf = (section, index, list) => index === list.length - 1 ? Number.POSITIVE_INFINITY : order.get(section.endsAtBlockId) ?? -1;
|
|
9780
|
+
const kept = layout2.filter(
|
|
9781
|
+
(section, index) => index === layout2.length - 1 || order.has(section.endsAtBlockId)
|
|
9782
|
+
);
|
|
9783
|
+
return kept.map((section, index) => {
|
|
9784
|
+
const end = endOf(section, index, kept);
|
|
9785
|
+
const source = priorSections.find((candidate) => candidate.endsAtBlockId === section.endsAtBlockId) ?? priorSections.find(
|
|
9786
|
+
(candidate, position) => endOf(candidate, position, priorSections) >= end
|
|
9787
|
+
) ?? priorSections.at(-1);
|
|
9788
|
+
return {
|
|
9789
|
+
...section,
|
|
9790
|
+
...source?.headers ? { headers: source.headers } : {},
|
|
9791
|
+
...source?.footers ? { footers: source.footers } : {}
|
|
9792
|
+
};
|
|
9793
|
+
});
|
|
9794
|
+
}
|
|
9795
|
+
function sectionsOf(model) {
|
|
9796
|
+
if (model.sections?.length) return model.sections;
|
|
9797
|
+
const { page } = model;
|
|
9798
|
+
return [
|
|
9799
|
+
{
|
|
9800
|
+
endsAtBlockId: model.blocks.at(-1)?.id ?? "",
|
|
9801
|
+
type: "nextPage",
|
|
9802
|
+
pageWidthTwips: twipsFromPixels(page.width),
|
|
9803
|
+
pageHeightTwips: twipsFromPixels(page.height),
|
|
9804
|
+
orientation: page.width > page.height ? "landscape" : "portrait",
|
|
9805
|
+
marginTopTwips: signedTwipsFromPixels(page.marginTop),
|
|
9806
|
+
marginRightTwips: twipsFromPixels(page.marginRight),
|
|
9807
|
+
marginBottomTwips: signedTwipsFromPixels(page.marginBottom),
|
|
9808
|
+
marginLeftTwips: twipsFromPixels(page.marginLeft),
|
|
9809
|
+
headerDistanceTwips: twips(720),
|
|
9810
|
+
footerDistanceTwips: twips(720),
|
|
9811
|
+
gutterTwips: twips(0),
|
|
9812
|
+
columns: { count: 1, spacingTwips: twips(720), equalWidth: true }
|
|
9813
|
+
}
|
|
9814
|
+
];
|
|
9815
|
+
}
|
|
9816
|
+
|
|
9817
|
+
export { DEFAULT_STYLES_XML, DEFAULT_TABLE_BORDERS, DEFAULT_TOC_INSTRUCTION, DIAGRAM_GRAPHIC_URI, DocxModelValidationError, EMPTY_FIGURES_TEXT, EMPTY_TOC_TEXT, EMU_PER_INCH, EMU_PER_PIXEL, EMU_PER_POINT, LIGATURE_VALUES, PIXELS_PER_INCH, PROPERTY_FIELDS, ST_AlgClass, ST_AlgType, ST_AnnotationVMerge, ST_Border, ST_BrClear, ST_BrType, ST_CalendarType, ST_CaptionPos, ST_ChapterSep, ST_CharacterSpacing, ST_CombineBrackets, ST_ConformanceClass, ST_CryptProv, ST_Direction, ST_DisplacedByCustomXml, ST_DocGrid, ST_DocPartBehavior, ST_DocPartGallery, ST_DocPartType, ST_DocProtect, ST_DropCap, ST_EdGrp, ST_EdnPos, ST_Em, ST_FFTextType, ST_FldCharType, ST_FontFamily, ST_FrameLayout, ST_FrameScrollbar, ST_FtnEdn, ST_FtnPos, ST_HAnchor, ST_HdrFtr, ST_HeightRule, ST_HexColorAuto, ST_HighlightColor, ST_Hint, ST_InfoTextType, ST_Jc, ST_JcTable, ST_LevelSuffix, ST_LineNumberRestart, ST_LineSpacingRule, ST_Lock, ST_MailMergeDest, ST_MailMergeDocType, ST_MailMergeOdsoFMDFieldType, ST_MailMergeSourceType, ST_Merge, ST_MultiLevelType, ST_NumberFormat, ST_ObjectDrawAspect, ST_ObjectUpdateMode, ST_OnOff1, ST_PTabAlignment, ST_PTabLeader, ST_PTabRelativeTo, ST_PageBorderDisplay, ST_PageBorderOffset, ST_PageBorderZOrder, ST_PageOrientation, ST_Pitch, ST_Proof, ST_ProofErr, ST_RelFromH, ST_RelFromV, ST_RestartNumber, ST_RubyAlign, ST_SchemeColorVal, ST_SdtDateMappingType, ST_SectionMark, ST_Shd, ST_StyleSort, ST_StyleType, ST_TabJc, ST_TabTlc, ST_TargetScreenSz, ST_TblLayoutType, ST_TblOverlap, ST_TblStyleOverrideType, ST_TblWidth, ST_TextAlignment, ST_TextDirection, ST_TextEffect, ST_TextboxTightWrap, ST_Theme, ST_ThemeColor, ST_TrueFalse, ST_TrueFalseBlank, ST_Underline, ST_VAnchor, ST_VerticalAlignRun, ST_VerticalJc, ST_View, ST_WmlColorSchemeIndex, ST_Wrap, ST_XAlign, ST_YAlign, ST_Zoom, TWIPS_PER_INCH, TWIPS_PER_POINT, WORD_HIGHLIGHT_TOKENS, WORD_UNDERLINE_TOKENS, acceptAllRevisions, acceptRevision, alignFromJustification, applyThemeShade, applyThemeTint, assertValidDocumentModel, buildTableOfContents, captionParagraphs, changeColumnGap, changeColumnWidth, columnPreset, columnTextWidth, computeListLabels, createDocument, createListDefinition, dateFieldResult, datePicture, defaultStyleCatalogs, diagramColorTheme, diagramsIn, displayListLabel, documentStats, eighthPoints, eighthPointsFromPoints, eighthPointsToPoints, emu, emuFromPixels, emuToPixels, ensureListDefinition, enumValue, equalColumnDraft, fieldName, findRevision, findTableOfContents, formatListNumber, formatNoteNumber, formatWordDate, halfPoints, halfPointsFromPoints, halfPointsToPoints, headingLevel, headingListLevels, isCaptionOf, isHeadingListKind, isLigatures, isStAlgClass, isStAlgType, isStAnnotationVMerge, isStBorder, isStBrClear, isStBrType, isStCalendarType, isStCaptionPos, isStChapterSep, isStCharacterSpacing, isStCombineBrackets, isStConformanceClass, isStCryptProv, isStDirection, isStDisplacedByCustomXml, isStDocGrid, isStDocPartBehavior, isStDocPartGallery, isStDocPartType, isStDocProtect, isStDropCap, isStEdGrp, isStEdnPos, isStEm, isStFFTextType, isStFldCharType, isStFontFamily, isStFrameLayout, isStFrameScrollbar, isStFtnEdn, isStFtnPos, isStHAnchor, isStHdrFtr, isStHeightRule, isStHexColorAuto, isStHighlightColor, isStHint, isStInfoTextType, isStJc, isStJcTable, isStLevelSuffix, isStLineNumberRestart, isStLineSpacingRule, isStLock, isStMailMergeDest, isStMailMergeDocType, isStMailMergeOdsoFMDFieldType, isStMailMergeSourceType, isStMerge, isStMultiLevelType, isStNumberFormat, isStObjectDrawAspect, isStObjectUpdateMode, isStOnOff1, isStPTabAlignment, isStPTabLeader, isStPTabRelativeTo, isStPageBorderDisplay, isStPageBorderOffset, isStPageBorderZOrder, isStPageOrientation, isStPitch, isStProof, isStProofErr, isStRelFromH, isStRelFromV, isStRestartNumber, isStRubyAlign, isStSchemeColorVal, isStSdtDateMappingType, isStSectionMark, isStShd, isStStyleSort, isStStyleType, isStTabJc, isStTabTlc, isStTargetScreenSz, isStTblLayoutType, isStTblOverlap, isStTblStyleOverrideType, isStTblWidth, isStTextAlignment, isStTextDirection, isStTextEffect, isStTextboxTightWrap, isStTheme, isStThemeColor, isStTrueFalse, isStTrueFalseBlank, isStUnderline, isStVAnchor, isStVerticalAlignRun, isStVerticalJc, isStView, isStWmlColorSchemeIndex, isStWrap, isStXAlign, isStYAlign, isStZoom, isThemeColorToken, isValidLanguageTag, isWordHighlightToken, isWordUnderlineStyle, lineSpacingLabel, lineSpacingOptions, lineSpacingValue, linkStylesToList, listRevisions, loadDocx, numberNotesInOrder, onOffAttribute, onOffElement, parseColorSchemeMapping, parseEighthPoints, parseHalfPoints, parseHexColor, parseInteger, parseJustification, parseLineSpacingValue, parseNumberingCatalog, parseOnOff, parseParagraphStyleCatalog, parseRgbColor, parseRunStyleCatalog, parseSignedHalfPoints, parseSignedTwips, parseTableStyleCatalog, parseTextScale, parseTheme, parseTintShade, parseTwips, parseUnsignedInteger, plainText2 as plainText, readColumnDraft, rejectAllRevisions, rejectRevision, reportParseWarning, resolveCellVisuals, resolveDiagramColor, resolveNumberingLevel, resolveParagraphFormatting, resolveParagraphNumbering, resolveRunFormatting, resolveStyleNumbering, resolveTableStyleFormatting, resolveThemeColorReference, resolveThemeColorToken, roundEighthPoints, roundEmu, roundHalfPoints, roundSignedTwips, roundTwips, saveDocx, sectionLayoutJson, sectionsFromLayout, sectionsOf, signedTwips, signedTwipsFromPixels, signedTwipsFromPoints, tableOfFiguresInstruction, tocBookmarks, tocCaptionLabel, tocEntries, tocHyperlinks, tocLevels, twips, twipsFromInches, twipsFromPixels, twipsFromPoints, twipsToInches, twipsToPixels, twipsToPoints, unequalColumnPreset, universalMeasureToTwips, updateTableOfContents, validColumnDraft, validateDocumentModel, withParseWarnings, withTocBookmarks };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type LineSpacingRule = 'auto' | 'exact' | 'atLeast';
|
|
2
|
+
export declare const lineSpacingOptions: Array<[string, string]>;
|
|
3
|
+
export declare function lineSpacingValue(attrs: Record<string, unknown>): string;
|
|
4
|
+
export declare function lineSpacingLabel(value: string): string;
|
|
5
|
+
export declare function parseLineSpacingValue(value: string): {
|
|
6
|
+
rule: LineSpacingRule;
|
|
7
|
+
twips: number;
|
|
8
|
+
} | null;
|
|
9
|
+
//# sourceMappingURL=line-spacing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-spacing.d.ts","sourceRoot":"","sources":["../../src/docx/line-spacing.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3D,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAQtD,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAUvE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAuBtD;AAED,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOjD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Block, DocumentModel } from './model.js';
|
|
2
|
+
import type { SectionProperties } from './section-model.js';
|
|
3
|
+
/** Section layout without header/footer content, as stored on the editor document for undo. */
|
|
4
|
+
export declare function sectionLayoutJson(sections: SectionProperties[]): string;
|
|
5
|
+
/**
|
|
6
|
+
* Rebuilds sections from the editor document's layout JSON, reattaching header/footer content
|
|
7
|
+
* from the previous model: a section keeps the content of the prior section ending at the same
|
|
8
|
+
* block, and a newly split section takes the content of the section it was split from. Sections
|
|
9
|
+
* whose ending paragraph no longer exists are dropped (deleting a break merges sections).
|
|
10
|
+
*/
|
|
11
|
+
export declare function sectionsFromLayout(json: string, prior: SectionProperties[] | undefined, blocks: Block[]): SectionProperties[];
|
|
12
|
+
/** The document's sections, creating one from the page settings for documents without any. */
|
|
13
|
+
export declare function sectionsOf(model: DocumentModel): SectionProperties[];
|
|
14
|
+
//# sourceMappingURL=section-layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-layout.d.ts","sourceRoot":"","sources":["../../src/docx/section-layout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAIvE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,iBAAiB,EAAE,GAAG,SAAS,EACtC,MAAM,EAAE,KAAK,EAAE,GACb,iBAAiB,EAAE,CAuBrB;AAED,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,iBAAiB,EAAE,CAoBpE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type CellRange } from '../address.js';
|
|
2
|
+
import type { FunctionInfo } from './functions/types.js';
|
|
3
|
+
/** Excel-like colours for references in a formula, in order of first appearance. */
|
|
4
|
+
export declare const REFERENCE_COLORS: readonly ['#2a6ad8', '#d24726', '#7d3fbf', '#0f8a3b', '#c0399f', '#946d00', '#d1102b', '#00788a'];
|
|
5
|
+
export declare const isFormulaText: (text: string) => boolean;
|
|
6
|
+
export interface ColoredReference {
|
|
7
|
+
/** Offsets into the formula text (which includes '='). */
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
text: string;
|
|
11
|
+
color: string;
|
|
12
|
+
/** Same reference text shares a colour (and a colour index). */
|
|
13
|
+
index: number;
|
|
14
|
+
}
|
|
15
|
+
/** The references of a formula with their colours (offsets into `text`, which includes '='). */
|
|
16
|
+
export declare function coloredReferences(text: string): ColoredReference[];
|
|
17
|
+
/** Whether typing a reference at `caret` makes sense (point mode may start). */
|
|
18
|
+
export declare function acceptsReference(text: string, caret: number): boolean;
|
|
19
|
+
/** True when `caret` is inside a "string literal". */
|
|
20
|
+
export declare function insideString(text: string, caret: number): boolean;
|
|
21
|
+
export interface NameToken {
|
|
22
|
+
start: number;
|
|
23
|
+
prefix: string;
|
|
24
|
+
}
|
|
25
|
+
/** The function-name prefix ending at the caret (`=SU|` -> `SU`), for autocomplete. */
|
|
26
|
+
export declare function nameAtCaret(text: string, caret: number): NameToken | undefined;
|
|
27
|
+
/** Catalog functions starting with `prefix` (case-insensitive), at most `limit`. */
|
|
28
|
+
export declare function functionMatches(prefix: string, limit?: number, catalog?: readonly FunctionInfo[]): FunctionInfo[];
|
|
29
|
+
export interface CallContext {
|
|
30
|
+
name: string;
|
|
31
|
+
/** Zero-based argument the caret is in. */
|
|
32
|
+
argIndex: number;
|
|
33
|
+
}
|
|
34
|
+
/** The innermost function call around the caret (`=IF(A1>0,|` -> IF, argument 1). */
|
|
35
|
+
export declare function callAtCaret(text: string, caret: number): CallContext | undefined;
|
|
36
|
+
/** Splits `SUM(number1, [number2], ...)` into its parameter texts. */
|
|
37
|
+
export declare function syntaxParams(syntax: string): {
|
|
38
|
+
name: string;
|
|
39
|
+
params: string[];
|
|
40
|
+
};
|
|
41
|
+
/** The parameter to highlight for an argument index (a trailing `...` repeats the last one). */
|
|
42
|
+
export declare function activeParam(params: string[], argIndex: number): number;
|
|
43
|
+
/** Replaces `text[start, end)` with `insert`; returns the new text and caret. */
|
|
44
|
+
export declare function splice(text: string, start: number, end: number, insert: string): {
|
|
45
|
+
text: string;
|
|
46
|
+
caret: number;
|
|
47
|
+
};
|
|
48
|
+
/** The sheet name and range a reference token names (`'My sheet'!$A$1:B2`, `A:C`, `2:5`). */
|
|
49
|
+
export declare function referenceTarget(text: string): {
|
|
50
|
+
sheet?: string;
|
|
51
|
+
range: CellRange;
|
|
52
|
+
} | undefined;
|
|
53
|
+
/** F4: cycles the absolute/relative form of the reference at the caret. */
|
|
54
|
+
export declare function toggleAbsolute(text: string, caret: number): {
|
|
55
|
+
text: string;
|
|
56
|
+
caret: number;
|
|
57
|
+
} | undefined;
|
|
58
|
+
/** Excel's commit-time autocorrect: appends the closing parentheses a formula is missing. */
|
|
59
|
+
export declare function closeParens(text: string): string;
|
|
60
|
+
//# sourceMappingURL=editor-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-text.d.ts","sourceRoot":"","sources":["../../../src/xlsx/formula/editor-text.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6C,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,YAC5B,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,CACA,CAAC;AAEX,eAAO,MAAM,aAAa,SAAU,MAAM,KAAG,OACA,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAChC,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;CACd;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAkBlE;AAKD,gFAAgF;AA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eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,CAsB9F;AAaD,2EAA2E;AAC3E,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAY7C;AAED,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUhD"}
|
|
@@ -11,4 +11,5 @@ export { deleteSheetInFormula, moveReferencesInFormula, type MoveSpec } from './
|
|
|
11
11
|
export { renameTableInFormula } from './table-refs.js';
|
|
12
12
|
export { structuredToA1, type StructuredTarget } from './structured-to-a1.js';
|
|
13
13
|
export { needsArrayEvaluation } from './array-context.js';
|
|
14
|
+
export * from './editor-text.js';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/xlsx/formula/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EACN,0BAA0B,EAC1B,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,YAAY,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,K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,KAAK,SAAS,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,cAAc,kBAAkB,CAAC"}
|
package/dist/xlsx/index.cjs
CHANGED
|
@@ -12893,6 +12893,163 @@ function needsArrayEvaluation(formula) {
|
|
|
12893
12893
|
return result2.needs || result2.multi;
|
|
12894
12894
|
}
|
|
12895
12895
|
|
|
12896
|
+
// src/xlsx/formula/editor-text.ts
|
|
12897
|
+
var REFERENCE_COLORS = [
|
|
12898
|
+
"#2a6ad8",
|
|
12899
|
+
"#d24726",
|
|
12900
|
+
"#7d3fbf",
|
|
12901
|
+
"#0f8a3b",
|
|
12902
|
+
"#c0399f",
|
|
12903
|
+
"#946d00",
|
|
12904
|
+
"#d1102b",
|
|
12905
|
+
"#00788a"
|
|
12906
|
+
];
|
|
12907
|
+
var isFormulaText = (text2) => text2.startsWith("=") || text2.startsWith("+");
|
|
12908
|
+
function coloredReferences(text2) {
|
|
12909
|
+
if (!isFormulaText(text2)) return [];
|
|
12910
|
+
const seen = /* @__PURE__ */ new Map();
|
|
12911
|
+
return referenceSpans(text2.slice(1), "").map((span3) => {
|
|
12912
|
+
const key = span3.text.replace(/\$/g, "").toUpperCase();
|
|
12913
|
+
let index2 = seen.get(key);
|
|
12914
|
+
if (index2 === void 0) {
|
|
12915
|
+
index2 = seen.size;
|
|
12916
|
+
seen.set(key, index2);
|
|
12917
|
+
}
|
|
12918
|
+
return {
|
|
12919
|
+
start: span3.start + 1,
|
|
12920
|
+
end: span3.end + 1,
|
|
12921
|
+
text: span3.text,
|
|
12922
|
+
index: index2,
|
|
12923
|
+
color: REFERENCE_COLORS[index2 % REFERENCE_COLORS.length] ?? REFERENCE_COLORS[0]
|
|
12924
|
+
};
|
|
12925
|
+
});
|
|
12926
|
+
}
|
|
12927
|
+
var POINT_AFTER = /* @__PURE__ */ new Set(["=", "(", ",", "+", "-", "*", "/", "^", "&", "<", ">", ":", ";", "%"]);
|
|
12928
|
+
function acceptsReference(text2, caret) {
|
|
12929
|
+
if (!isFormulaText(text2)) return false;
|
|
12930
|
+
if (text2.slice(caret).trimStart() !== "" && !/^[\s),;&+\-*/^<>=]/.test(text2.slice(caret)))
|
|
12931
|
+
return false;
|
|
12932
|
+
const before = text2.slice(0, caret).trimEnd();
|
|
12933
|
+
const last = before[before.length - 1];
|
|
12934
|
+
return last !== void 0 && POINT_AFTER.has(last) && !insideString(text2, caret);
|
|
12935
|
+
}
|
|
12936
|
+
function insideString(text2, caret) {
|
|
12937
|
+
let open = false;
|
|
12938
|
+
for (let i = 0; i < caret && i < text2.length; i++) if (text2[i] === '"') open = !open;
|
|
12939
|
+
return open;
|
|
12940
|
+
}
|
|
12941
|
+
function nameAtCaret(text2, caret) {
|
|
12942
|
+
if (!isFormulaText(text2) || insideString(text2, caret)) return void 0;
|
|
12943
|
+
const match2 = /[A-Za-z_][A-Za-z0-9_.]*$/.exec(text2.slice(0, caret));
|
|
12944
|
+
if (!match2) return void 0;
|
|
12945
|
+
const start = caret - match2[0].length;
|
|
12946
|
+
const prev = text2[start - 1] ?? "";
|
|
12947
|
+
if (start === 0 || /[A-Za-z0-9_$!'".:]/.test(prev)) return void 0;
|
|
12948
|
+
if (/^[A-Za-z0-9_.]/.test(text2.slice(caret))) return void 0;
|
|
12949
|
+
return { start, prefix: match2[0] };
|
|
12950
|
+
}
|
|
12951
|
+
function functionMatches(prefix, limit2 = 12, catalog = FUNCTION_CATALOG) {
|
|
12952
|
+
const upper2 = prefix.toUpperCase();
|
|
12953
|
+
if (!upper2) return [];
|
|
12954
|
+
const out = [];
|
|
12955
|
+
for (const info of catalog) {
|
|
12956
|
+
if (info.name.startsWith(upper2)) out.push(info);
|
|
12957
|
+
if (out.length >= limit2) break;
|
|
12958
|
+
}
|
|
12959
|
+
return out;
|
|
12960
|
+
}
|
|
12961
|
+
function callAtCaret(text2, caret) {
|
|
12962
|
+
if (!isFormulaText(text2)) return void 0;
|
|
12963
|
+
const stack2 = [];
|
|
12964
|
+
let inString = false;
|
|
12965
|
+
for (let i = 1; i < caret && i < text2.length; i++) {
|
|
12966
|
+
const ch = text2[i];
|
|
12967
|
+
if (ch === '"') inString = !inString;
|
|
12968
|
+
if (inString) continue;
|
|
12969
|
+
if (ch === "(") {
|
|
12970
|
+
const name = /([A-Za-z_][A-Za-z0-9_.]*)\s*$/.exec(text2.slice(0, i))?.[1];
|
|
12971
|
+
stack2.push({ name: (name ?? "").toUpperCase(), argIndex: 0 });
|
|
12972
|
+
} else if (ch === ")") stack2.pop();
|
|
12973
|
+
else if (ch === "," || ch === ";") {
|
|
12974
|
+
const top = stack2[stack2.length - 1];
|
|
12975
|
+
if (top) top.argIndex++;
|
|
12976
|
+
} else if (ch === "{") stack2.push({ name: "", argIndex: 0 });
|
|
12977
|
+
else if (ch === "}") stack2.pop();
|
|
12978
|
+
}
|
|
12979
|
+
for (let i = stack2.length - 1; i >= 0; i--) {
|
|
12980
|
+
const entry = stack2[i];
|
|
12981
|
+
if (entry?.name) return entry;
|
|
12982
|
+
if (entry && !entry.name) return void 0;
|
|
12983
|
+
}
|
|
12984
|
+
return void 0;
|
|
12985
|
+
}
|
|
12986
|
+
function syntaxParams(syntax) {
|
|
12987
|
+
const open = syntax.indexOf("(");
|
|
12988
|
+
const close = syntax.lastIndexOf(")");
|
|
12989
|
+
if (open < 0) return { name: syntax, params: [] };
|
|
12990
|
+
const inner2 = syntax.slice(open + 1, close < 0 ? void 0 : close).trim();
|
|
12991
|
+
const params = inner2 ? inner2.split(",").map((p) => p.trim()) : [];
|
|
12992
|
+
return { name: syntax.slice(0, open), params };
|
|
12993
|
+
}
|
|
12994
|
+
function activeParam(params, argIndex) {
|
|
12995
|
+
if (argIndex < params.length) {
|
|
12996
|
+
if (params[argIndex] === "...") return Math.max(0, argIndex - 1);
|
|
12997
|
+
return argIndex;
|
|
12998
|
+
}
|
|
12999
|
+
return params[params.length - 1] === "..." ? params.length - 2 : params.length - 1;
|
|
13000
|
+
}
|
|
13001
|
+
function splice(text2, start, end, insert) {
|
|
13002
|
+
return { text: text2.slice(0, start) + insert + text2.slice(end), caret: start + insert.length };
|
|
13003
|
+
}
|
|
13004
|
+
function referenceTarget(text2) {
|
|
13005
|
+
const bang = text2.lastIndexOf("!");
|
|
13006
|
+
const sheet = bang >= 0 ? text2.slice(0, bang).replace(/^'|'$/g, "").replace(/''/g, "'") : void 0;
|
|
13007
|
+
const body = text2.slice(bang + 1).replace(/\$/g, "").toUpperCase();
|
|
13008
|
+
let range;
|
|
13009
|
+
const cols = /^([A-Z]{1,3}):([A-Z]{1,3})$/.exec(body);
|
|
13010
|
+
const rows = /^(\d+):(\d+)$/.exec(body);
|
|
13011
|
+
if (cols) {
|
|
13012
|
+
const a = columnIndex(cols[1] ?? "A");
|
|
13013
|
+
const b = columnIndex(cols[2] ?? "A");
|
|
13014
|
+
range = { start: { row: 0, col: Math.min(a, b) }, end: { row: MAX_ROW, col: Math.max(a, b) } };
|
|
13015
|
+
} else if (rows) {
|
|
13016
|
+
const a = Number(rows[1]) - 1;
|
|
13017
|
+
const b = Number(rows[2]) - 1;
|
|
13018
|
+
range = { start: { row: Math.min(a, b), col: 0 }, end: { row: Math.max(a, b), col: MAX_COL } };
|
|
13019
|
+
} else range = parseRange(body);
|
|
13020
|
+
if (!range) return void 0;
|
|
13021
|
+
return sheet === void 0 ? { range } : { sheet, range };
|
|
13022
|
+
}
|
|
13023
|
+
var cycleCell = (cell) => {
|
|
13024
|
+
const m = /^(\$?)([A-Za-z]{1,3})(\$?)(\d+)$/.exec(cell);
|
|
13025
|
+
if (!m) return cell;
|
|
13026
|
+
const [, c2, col, r, row2] = m;
|
|
13027
|
+
if (!c2 && !r) return `$${col}$${row2}`;
|
|
13028
|
+
if (c2 && r) return `${col}$${row2}`;
|
|
13029
|
+
if (!c2 && r) return `$${col}${row2}`;
|
|
13030
|
+
return `${col}${row2}`;
|
|
13031
|
+
};
|
|
13032
|
+
function toggleAbsolute(text2, caret) {
|
|
13033
|
+
const ref = coloredReferences(text2).find((r) => caret >= r.start && caret <= r.end);
|
|
13034
|
+
if (!ref) return void 0;
|
|
13035
|
+
const bang = ref.text.lastIndexOf("!");
|
|
13036
|
+
const prefix = ref.text.slice(0, bang + 1);
|
|
13037
|
+
const body = ref.text.slice(bang + 1).split(":").map(cycleCell).join(":");
|
|
13038
|
+
const next = splice(text2, ref.start, ref.end, prefix + body);
|
|
13039
|
+
return next;
|
|
13040
|
+
}
|
|
13041
|
+
function closeParens(text2) {
|
|
13042
|
+
if (!isFormulaText(text2)) return text2;
|
|
13043
|
+
let depth = 0;
|
|
13044
|
+
let inString = false;
|
|
13045
|
+
for (const ch of text2) {
|
|
13046
|
+
if (ch === '"') inString = !inString;
|
|
13047
|
+
else if (!inString && ch === "(") depth++;
|
|
13048
|
+
else if (!inString && ch === ")") depth = Math.max(0, depth - 1);
|
|
13049
|
+
}
|
|
13050
|
+
return depth > 0 && !inString ? text2 + ")".repeat(depth) : text2;
|
|
13051
|
+
}
|
|
13052
|
+
|
|
12896
13053
|
// src/opc/relationship-types.ts
|
|
12897
13054
|
var BASE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
12898
13055
|
var RELATIONSHIP_TYPES = {
|
|
@@ -26056,8 +26213,11 @@ exports.MAX_ROW = MAX_ROW;
|
|
|
26056
26213
|
exports.MIN_TWO_CELL_PIXELS = MIN_TWO_CELL_PIXELS;
|
|
26057
26214
|
exports.OVERFLOW_TEXT = OVERFLOW_TEXT;
|
|
26058
26215
|
exports.PERCENT_SCALE = PERCENT_SCALE;
|
|
26216
|
+
exports.REFERENCE_COLORS = REFERENCE_COLORS;
|
|
26059
26217
|
exports.THEME_SLOTS = THEME_SLOTS;
|
|
26060
26218
|
exports.TIME_PERIODS = TIME_PERIODS;
|
|
26219
|
+
exports.acceptsReference = acceptsReference;
|
|
26220
|
+
exports.activeParam = activeParam;
|
|
26061
26221
|
exports.addFuturePrefixes = addFuturePrefixes;
|
|
26062
26222
|
exports.anchorKind = anchorKind;
|
|
26063
26223
|
exports.anchorToPixelBox = anchorToPixelBox;
|
|
@@ -26073,6 +26233,7 @@ exports.bordersView = bordersView;
|
|
|
26073
26233
|
exports.builtinCellStyle = builtinCellStyle;
|
|
26074
26234
|
exports.builtinFormatId = builtinFormatId;
|
|
26075
26235
|
exports.calcModeOf = calcModeOf;
|
|
26236
|
+
exports.callAtCaret = callAtCaret;
|
|
26076
26237
|
exports.categoryTotals = categoryTotals;
|
|
26077
26238
|
exports.cellError = cellError;
|
|
26078
26239
|
exports.cellInputText = cellInputText;
|
|
@@ -26082,6 +26243,8 @@ exports.cellsFromText = cellsFromText;
|
|
|
26082
26243
|
exports.charactersToColumnWidth = charactersToColumnWidth;
|
|
26083
26244
|
exports.charactersToPixels = charactersToPixels;
|
|
26084
26245
|
exports.chartView = chartView;
|
|
26246
|
+
exports.closeParens = closeParens;
|
|
26247
|
+
exports.coloredReferences = coloredReferences;
|
|
26085
26248
|
exports.columnIndex = columnIndex;
|
|
26086
26249
|
exports.columnLabel = columnLabel;
|
|
26087
26250
|
exports.columnWidthToPixels = columnWidthToPixels;
|
|
@@ -26114,17 +26277,20 @@ exports.formatRange = formatRange;
|
|
|
26114
26277
|
exports.formatRefSpec = formatRefSpec;
|
|
26115
26278
|
exports.formatValue = formatValue;
|
|
26116
26279
|
exports.formulaBarText = formulaBarText;
|
|
26280
|
+
exports.functionMatches = functionMatches;
|
|
26117
26281
|
exports.generalAlignment = generalAlignment;
|
|
26118
26282
|
exports.getCell = getCell;
|
|
26119
26283
|
exports.getCellAt = getCellAt;
|
|
26120
26284
|
exports.getValue = getValue;
|
|
26121
26285
|
exports.hls240ToRgb = hls240ToRgb;
|
|
26122
26286
|
exports.inTimePeriod = inTimePeriod;
|
|
26287
|
+
exports.insideString = insideString;
|
|
26123
26288
|
exports.internStyle = internStyle;
|
|
26124
26289
|
exports.isCellError = isCellError;
|
|
26125
26290
|
exports.isDateFormat = isDateFormat;
|
|
26126
26291
|
exports.isEmptyCell = isEmptyCell;
|
|
26127
26292
|
exports.isErrorCode = isErrorCode;
|
|
26293
|
+
exports.isFormulaText = isFormulaText;
|
|
26128
26294
|
exports.isOverflowTarget = isOverflowTarget;
|
|
26129
26295
|
exports.isSpilledCell = isSpilledCell;
|
|
26130
26296
|
exports.keyToAddress = keyToAddress;
|
|
@@ -26140,6 +26306,7 @@ exports.mixColors = mixColors;
|
|
|
26140
26306
|
exports.modernPasswordHash = modernPasswordHash;
|
|
26141
26307
|
exports.modulateLuminance = modulateLuminance;
|
|
26142
26308
|
exports.moveReferencesInFormula = moveReferencesInFormula;
|
|
26309
|
+
exports.nameAtCaret = nameAtCaret;
|
|
26143
26310
|
exports.navigate = navigate;
|
|
26144
26311
|
exports.needsArrayEvaluation = needsArrayEvaluation;
|
|
26145
26312
|
exports.newMediaPart = newMediaPart;
|
|
@@ -26175,6 +26342,7 @@ exports.rangeContains = rangeContains;
|
|
|
26175
26342
|
exports.rangeSize = rangeSize;
|
|
26176
26343
|
exports.rangesIntersect = rangesIntersect;
|
|
26177
26344
|
exports.referenceSpans = referenceSpans;
|
|
26345
|
+
exports.referenceTarget = referenceTarget;
|
|
26178
26346
|
exports.referencedRanges = referencedRanges;
|
|
26179
26347
|
exports.renameSheetInFormula = renameSheetInFormula;
|
|
26180
26348
|
exports.renameTableInFormula = renameTableInFormula;
|
|
@@ -26193,17 +26361,20 @@ exports.shiftFormula = shiftFormula;
|
|
|
26193
26361
|
exports.shiftRange = shiftRange;
|
|
26194
26362
|
exports.shiftSpan = shiftSpan;
|
|
26195
26363
|
exports.spillAnchorOf = spillAnchorOf;
|
|
26364
|
+
exports.splice = splice;
|
|
26196
26365
|
exports.stepDecimals = stepDecimals;
|
|
26197
26366
|
exports.stripFuturePrefixes = stripFuturePrefixes;
|
|
26198
26367
|
exports.structuredToA1 = structuredToA1;
|
|
26199
26368
|
exports.styleAt = styleAt;
|
|
26200
26369
|
exports.styleKey = styleKey;
|
|
26201
26370
|
exports.subtractRange = subtractRange;
|
|
26371
|
+
exports.syntaxParams = syntaxParams;
|
|
26202
26372
|
exports.themeColor = themeColor;
|
|
26203
26373
|
exports.timePeriodFormula = timePeriodFormula;
|
|
26204
26374
|
exports.toHexColor = toHexColor;
|
|
26205
26375
|
exports.toHtml = toHtml;
|
|
26206
26376
|
exports.toTsv = toTsv;
|
|
26377
|
+
exports.toggleAbsolute = toggleAbsolute;
|
|
26207
26378
|
exports.tokenize = tokenize;
|
|
26208
26379
|
exports.translateFormula = translateFormula;
|
|
26209
26380
|
exports.translateReferences = translateReferences;
|
package/dist/xlsx/index.mjs
CHANGED
|
@@ -12887,6 +12887,163 @@ function needsArrayEvaluation(formula) {
|
|
|
12887
12887
|
return result2.needs || result2.multi;
|
|
12888
12888
|
}
|
|
12889
12889
|
|
|
12890
|
+
// src/xlsx/formula/editor-text.ts
|
|
12891
|
+
var REFERENCE_COLORS = [
|
|
12892
|
+
"#2a6ad8",
|
|
12893
|
+
"#d24726",
|
|
12894
|
+
"#7d3fbf",
|
|
12895
|
+
"#0f8a3b",
|
|
12896
|
+
"#c0399f",
|
|
12897
|
+
"#946d00",
|
|
12898
|
+
"#d1102b",
|
|
12899
|
+
"#00788a"
|
|
12900
|
+
];
|
|
12901
|
+
var isFormulaText = (text2) => text2.startsWith("=") || text2.startsWith("+");
|
|
12902
|
+
function coloredReferences(text2) {
|
|
12903
|
+
if (!isFormulaText(text2)) return [];
|
|
12904
|
+
const seen = /* @__PURE__ */ new Map();
|
|
12905
|
+
return referenceSpans(text2.slice(1), "").map((span3) => {
|
|
12906
|
+
const key = span3.text.replace(/\$/g, "").toUpperCase();
|
|
12907
|
+
let index2 = seen.get(key);
|
|
12908
|
+
if (index2 === void 0) {
|
|
12909
|
+
index2 = seen.size;
|
|
12910
|
+
seen.set(key, index2);
|
|
12911
|
+
}
|
|
12912
|
+
return {
|
|
12913
|
+
start: span3.start + 1,
|
|
12914
|
+
end: span3.end + 1,
|
|
12915
|
+
text: span3.text,
|
|
12916
|
+
index: index2,
|
|
12917
|
+
color: REFERENCE_COLORS[index2 % REFERENCE_COLORS.length] ?? REFERENCE_COLORS[0]
|
|
12918
|
+
};
|
|
12919
|
+
});
|
|
12920
|
+
}
|
|
12921
|
+
var POINT_AFTER = /* @__PURE__ */ new Set(["=", "(", ",", "+", "-", "*", "/", "^", "&", "<", ">", ":", ";", "%"]);
|
|
12922
|
+
function acceptsReference(text2, caret) {
|
|
12923
|
+
if (!isFormulaText(text2)) return false;
|
|
12924
|
+
if (text2.slice(caret).trimStart() !== "" && !/^[\s),;&+\-*/^<>=]/.test(text2.slice(caret)))
|
|
12925
|
+
return false;
|
|
12926
|
+
const before = text2.slice(0, caret).trimEnd();
|
|
12927
|
+
const last = before[before.length - 1];
|
|
12928
|
+
return last !== void 0 && POINT_AFTER.has(last) && !insideString(text2, caret);
|
|
12929
|
+
}
|
|
12930
|
+
function insideString(text2, caret) {
|
|
12931
|
+
let open = false;
|
|
12932
|
+
for (let i = 0; i < caret && i < text2.length; i++) if (text2[i] === '"') open = !open;
|
|
12933
|
+
return open;
|
|
12934
|
+
}
|
|
12935
|
+
function nameAtCaret(text2, caret) {
|
|
12936
|
+
if (!isFormulaText(text2) || insideString(text2, caret)) return void 0;
|
|
12937
|
+
const match2 = /[A-Za-z_][A-Za-z0-9_.]*$/.exec(text2.slice(0, caret));
|
|
12938
|
+
if (!match2) return void 0;
|
|
12939
|
+
const start = caret - match2[0].length;
|
|
12940
|
+
const prev = text2[start - 1] ?? "";
|
|
12941
|
+
if (start === 0 || /[A-Za-z0-9_$!'".:]/.test(prev)) return void 0;
|
|
12942
|
+
if (/^[A-Za-z0-9_.]/.test(text2.slice(caret))) return void 0;
|
|
12943
|
+
return { start, prefix: match2[0] };
|
|
12944
|
+
}
|
|
12945
|
+
function functionMatches(prefix, limit2 = 12, catalog = FUNCTION_CATALOG) {
|
|
12946
|
+
const upper2 = prefix.toUpperCase();
|
|
12947
|
+
if (!upper2) return [];
|
|
12948
|
+
const out = [];
|
|
12949
|
+
for (const info of catalog) {
|
|
12950
|
+
if (info.name.startsWith(upper2)) out.push(info);
|
|
12951
|
+
if (out.length >= limit2) break;
|
|
12952
|
+
}
|
|
12953
|
+
return out;
|
|
12954
|
+
}
|
|
12955
|
+
function callAtCaret(text2, caret) {
|
|
12956
|
+
if (!isFormulaText(text2)) return void 0;
|
|
12957
|
+
const stack2 = [];
|
|
12958
|
+
let inString = false;
|
|
12959
|
+
for (let i = 1; i < caret && i < text2.length; i++) {
|
|
12960
|
+
const ch = text2[i];
|
|
12961
|
+
if (ch === '"') inString = !inString;
|
|
12962
|
+
if (inString) continue;
|
|
12963
|
+
if (ch === "(") {
|
|
12964
|
+
const name = /([A-Za-z_][A-Za-z0-9_.]*)\s*$/.exec(text2.slice(0, i))?.[1];
|
|
12965
|
+
stack2.push({ name: (name ?? "").toUpperCase(), argIndex: 0 });
|
|
12966
|
+
} else if (ch === ")") stack2.pop();
|
|
12967
|
+
else if (ch === "," || ch === ";") {
|
|
12968
|
+
const top = stack2[stack2.length - 1];
|
|
12969
|
+
if (top) top.argIndex++;
|
|
12970
|
+
} else if (ch === "{") stack2.push({ name: "", argIndex: 0 });
|
|
12971
|
+
else if (ch === "}") stack2.pop();
|
|
12972
|
+
}
|
|
12973
|
+
for (let i = stack2.length - 1; i >= 0; i--) {
|
|
12974
|
+
const entry = stack2[i];
|
|
12975
|
+
if (entry?.name) return entry;
|
|
12976
|
+
if (entry && !entry.name) return void 0;
|
|
12977
|
+
}
|
|
12978
|
+
return void 0;
|
|
12979
|
+
}
|
|
12980
|
+
function syntaxParams(syntax) {
|
|
12981
|
+
const open = syntax.indexOf("(");
|
|
12982
|
+
const close = syntax.lastIndexOf(")");
|
|
12983
|
+
if (open < 0) return { name: syntax, params: [] };
|
|
12984
|
+
const inner2 = syntax.slice(open + 1, close < 0 ? void 0 : close).trim();
|
|
12985
|
+
const params = inner2 ? inner2.split(",").map((p) => p.trim()) : [];
|
|
12986
|
+
return { name: syntax.slice(0, open), params };
|
|
12987
|
+
}
|
|
12988
|
+
function activeParam(params, argIndex) {
|
|
12989
|
+
if (argIndex < params.length) {
|
|
12990
|
+
if (params[argIndex] === "...") return Math.max(0, argIndex - 1);
|
|
12991
|
+
return argIndex;
|
|
12992
|
+
}
|
|
12993
|
+
return params[params.length - 1] === "..." ? params.length - 2 : params.length - 1;
|
|
12994
|
+
}
|
|
12995
|
+
function splice(text2, start, end, insert) {
|
|
12996
|
+
return { text: text2.slice(0, start) + insert + text2.slice(end), caret: start + insert.length };
|
|
12997
|
+
}
|
|
12998
|
+
function referenceTarget(text2) {
|
|
12999
|
+
const bang = text2.lastIndexOf("!");
|
|
13000
|
+
const sheet = bang >= 0 ? text2.slice(0, bang).replace(/^'|'$/g, "").replace(/''/g, "'") : void 0;
|
|
13001
|
+
const body = text2.slice(bang + 1).replace(/\$/g, "").toUpperCase();
|
|
13002
|
+
let range;
|
|
13003
|
+
const cols = /^([A-Z]{1,3}):([A-Z]{1,3})$/.exec(body);
|
|
13004
|
+
const rows = /^(\d+):(\d+)$/.exec(body);
|
|
13005
|
+
if (cols) {
|
|
13006
|
+
const a = columnIndex(cols[1] ?? "A");
|
|
13007
|
+
const b = columnIndex(cols[2] ?? "A");
|
|
13008
|
+
range = { start: { row: 0, col: Math.min(a, b) }, end: { row: MAX_ROW, col: Math.max(a, b) } };
|
|
13009
|
+
} else if (rows) {
|
|
13010
|
+
const a = Number(rows[1]) - 1;
|
|
13011
|
+
const b = Number(rows[2]) - 1;
|
|
13012
|
+
range = { start: { row: Math.min(a, b), col: 0 }, end: { row: Math.max(a, b), col: MAX_COL } };
|
|
13013
|
+
} else range = parseRange(body);
|
|
13014
|
+
if (!range) return void 0;
|
|
13015
|
+
return sheet === void 0 ? { range } : { sheet, range };
|
|
13016
|
+
}
|
|
13017
|
+
var cycleCell = (cell) => {
|
|
13018
|
+
const m = /^(\$?)([A-Za-z]{1,3})(\$?)(\d+)$/.exec(cell);
|
|
13019
|
+
if (!m) return cell;
|
|
13020
|
+
const [, c2, col, r, row2] = m;
|
|
13021
|
+
if (!c2 && !r) return `$${col}$${row2}`;
|
|
13022
|
+
if (c2 && r) return `${col}$${row2}`;
|
|
13023
|
+
if (!c2 && r) return `$${col}${row2}`;
|
|
13024
|
+
return `${col}${row2}`;
|
|
13025
|
+
};
|
|
13026
|
+
function toggleAbsolute(text2, caret) {
|
|
13027
|
+
const ref = coloredReferences(text2).find((r) => caret >= r.start && caret <= r.end);
|
|
13028
|
+
if (!ref) return void 0;
|
|
13029
|
+
const bang = ref.text.lastIndexOf("!");
|
|
13030
|
+
const prefix = ref.text.slice(0, bang + 1);
|
|
13031
|
+
const body = ref.text.slice(bang + 1).split(":").map(cycleCell).join(":");
|
|
13032
|
+
const next = splice(text2, ref.start, ref.end, prefix + body);
|
|
13033
|
+
return next;
|
|
13034
|
+
}
|
|
13035
|
+
function closeParens(text2) {
|
|
13036
|
+
if (!isFormulaText(text2)) return text2;
|
|
13037
|
+
let depth = 0;
|
|
13038
|
+
let inString = false;
|
|
13039
|
+
for (const ch of text2) {
|
|
13040
|
+
if (ch === '"') inString = !inString;
|
|
13041
|
+
else if (!inString && ch === "(") depth++;
|
|
13042
|
+
else if (!inString && ch === ")") depth = Math.max(0, depth - 1);
|
|
13043
|
+
}
|
|
13044
|
+
return depth > 0 && !inString ? text2 + ")".repeat(depth) : text2;
|
|
13045
|
+
}
|
|
13046
|
+
|
|
12890
13047
|
// src/opc/relationship-types.ts
|
|
12891
13048
|
var BASE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
12892
13049
|
var RELATIONSHIP_TYPES = {
|
|
@@ -26023,4 +26180,4 @@ function createRefEvaluator(workbook, calc, options = {}) {
|
|
|
26023
26180
|
};
|
|
26024
26181
|
}
|
|
26025
26182
|
|
|
26026
|
-
export { AxisMetrics, BORDER_STYLES, BUILTIN_CELL_STYLES, BUILTIN_NUMBER_FORMATS, CIRCULAR_REFERENCE_WARNING, COLUMN_PADDING_PX, DEFAULT_ANCHOR_EXTENT_EMU, DEFAULT_BASE_COL_WIDTH, DEFAULT_COL_WIDTH, DEFAULT_MAX_DIGIT_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE, ERROR_CODES, FORMAT_PRESETS, FUNCTION_CATALOG, FormulaError, IMAGE_EXTENSIONS, INDENT_PX_PER_LEVEL, INDEXED_COLORS, MAX_COL, MAX_DATE_SERIAL, MAX_OUTLINE_LEVEL, MAX_ROW, MIN_TWO_CELL_PIXELS, OVERFLOW_TEXT, PERCENT_SCALE, THEME_SLOTS, TIME_PERIODS, addFuturePrefixes, anchorKind, anchorToPixelBox, applyBuiltinStyle, applyStylePatch, applyTint, approximateMeasure, autoFitColumnWidth, autoFitRowHeight, autoGrowRows, autoSeriesColor, bordersView, builtinCellStyle, builtinFormatId, calcModeOf, categoryTotals, cellError, cellInputText, cellKey, cellView, cellsFromText, charactersToColumnWidth, charactersToPixels, chartView, columnIndex, columnLabel, columnWidthToPixels, compareCellValues, compareValues, createCalcEngine, createConditionalFormatEvaluator, createEditSession, createGridMetrics, createRefEvaluator, createWorkbook, createWorksheet, currentRegion, dateToSerial, defaultCellStyle, defaultColumnPixels, deleteCell, deleteSheetInFormula, detectSeries, edgeView, effectiveStyleId, fillView, fontView, forEachCell, forEachCellInRange, formatAddress, formatAxisValue, formatGeneral, formatRange, formatRefSpec, formatValue, formulaBarText, generalAlignment, getCell, getCellAt, getValue, hls240ToRgb, inTimePeriod, internStyle, isCellError, isDateFormat, isEmptyCell, isErrorCode, isOverflowTarget, isSpilledCell, keyToAddress, legacyPasswordHash, lineHeightPoints, listValidationOptions, loadXlsx, mergeAt, mergeFont, mergeView, mergeWouldDiscard, mixColors, modernPasswordHash, modulateLuminance, moveReferencesInFormula, navigate, needsArrayEvaluation, newMediaPart, nextSheetId, nextSheetName, niceScale, normalizeRange, numberInputText, numberToText, overflowExtent, parseAddress, parseCellInput, parseFormula, parseHex, parseHtmlTable, parseNumberText, parseRange, parseTsv, patchStyle, percentile, pictureAnchorAt, pixelBoxToAnchor, pixelSizeToExtent, pixelsToCharacters, pixelsToColumnWidth, pixelsToPoints, pointsToPixels, presetEdges, putCell, queryPattern, quoteSheetName, rangeContains, rangeSize, rangesIntersect, referenceSpans, referencedRanges, renameSheetInFormula, renameTableInFormula, renderChartSvg, replaceText, resolveColor, rgbToHls240, rotationDegrees, rowsToRefit, saveXlsx, scaleColor, selectionStats, serialToDate, sheetByName, shiftFormula, shiftRange, shiftSpan, spillAnchorOf, stepDecimals, stripFuturePrefixes, structuredToA1, styleAt, styleKey, subtractRange, themeColor, timePeriodFormula, toHexColor, toHtml, toTsv, tokenize, translateFormula, translateReferences, uniqueHeaders, usedRange, validateCellInput, validateDefinedName, validateSheetName, validateTableName, validationAt, verifySheetPassword, verifySheetPasswordAsync, verifyWorkbookPassword, visibleCells, wrappedLineCount, zoomPercent };
|
|
26183
|
+
export { AxisMetrics, BORDER_STYLES, BUILTIN_CELL_STYLES, BUILTIN_NUMBER_FORMATS, CIRCULAR_REFERENCE_WARNING, COLUMN_PADDING_PX, DEFAULT_ANCHOR_EXTENT_EMU, DEFAULT_BASE_COL_WIDTH, DEFAULT_COL_WIDTH, DEFAULT_MAX_DIGIT_WIDTH, DEFAULT_ROW_HEIGHT, DEFAULT_THEME, DEFAULT_VALIDATION_MESSAGE, ERROR_CODES, FORMAT_PRESETS, FUNCTION_CATALOG, FormulaError, IMAGE_EXTENSIONS, INDENT_PX_PER_LEVEL, INDEXED_COLORS, MAX_COL, MAX_DATE_SERIAL, MAX_OUTLINE_LEVEL, MAX_ROW, MIN_TWO_CELL_PIXELS, OVERFLOW_TEXT, PERCENT_SCALE, REFERENCE_COLORS, THEME_SLOTS, TIME_PERIODS, acceptsReference, activeParam, addFuturePrefixes, anchorKind, anchorToPixelBox, applyBuiltinStyle, applyStylePatch, applyTint, approximateMeasure, autoFitColumnWidth, autoFitRowHeight, autoGrowRows, autoSeriesColor, bordersView, builtinCellStyle, builtinFormatId, calcModeOf, callAtCaret, categoryTotals, cellError, cellInputText, cellKey, cellView, cellsFromText, charactersToColumnWidth, charactersToPixels, chartView, closeParens, coloredReferences, columnIndex, columnLabel, columnWidthToPixels, compareCellValues, compareValues, createCalcEngine, createConditionalFormatEvaluator, createEditSession, createGridMetrics, createRefEvaluator, createWorkbook, createWorksheet, currentRegion, dateToSerial, defaultCellStyle, defaultColumnPixels, deleteCell, deleteSheetInFormula, detectSeries, edgeView, effectiveStyleId, fillView, fontView, forEachCell, forEachCellInRange, formatAddress, formatAxisValue, formatGeneral, formatRange, formatRefSpec, formatValue, formulaBarText, functionMatches, generalAlignment, getCell, getCellAt, getValue, hls240ToRgb, inTimePeriod, insideString, internStyle, isCellError, isDateFormat, isEmptyCell, isErrorCode, isFormulaText, isOverflowTarget, isSpilledCell, keyToAddress, legacyPasswordHash, lineHeightPoints, listValidationOptions, loadXlsx, mergeAt, mergeFont, mergeView, mergeWouldDiscard, mixColors, modernPasswordHash, modulateLuminance, moveReferencesInFormula, nameAtCaret, navigate, needsArrayEvaluation, newMediaPart, nextSheetId, nextSheetName, niceScale, normalizeRange, numberInputText, numberToText, overflowExtent, parseAddress, parseCellInput, parseFormula, parseHex, parseHtmlTable, parseNumberText, parseRange, parseTsv, patchStyle, percentile, pictureAnchorAt, pixelBoxToAnchor, pixelSizeToExtent, pixelsToCharacters, pixelsToColumnWidth, pixelsToPoints, pointsToPixels, presetEdges, putCell, queryPattern, quoteSheetName, rangeContains, rangeSize, rangesIntersect, referenceSpans, referenceTarget, referencedRanges, renameSheetInFormula, renameTableInFormula, renderChartSvg, replaceText, resolveColor, rgbToHls240, rotationDegrees, rowsToRefit, saveXlsx, scaleColor, selectionStats, serialToDate, sheetByName, shiftFormula, shiftRange, shiftSpan, spillAnchorOf, splice, stepDecimals, stripFuturePrefixes, structuredToA1, styleAt, styleKey, subtractRange, syntaxParams, themeColor, timePeriodFormula, toHexColor, toHtml, toTsv, toggleAbsolute, tokenize, translateFormula, translateReferences, uniqueHeaders, usedRange, validateCellInput, validateDefinedName, validateSheetName, validateTableName, validationAt, verifySheetPassword, verifySheetPasswordAsync, verifyWorkbookPassword, visibleCells, wrappedLineCount, zoomPercent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ooxml-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Shared OOXML logic for the Word, PowerPoint and Excel viewers: everything except the UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"charts",
|
|
@@ -204,6 +204,7 @@
|
|
|
204
204
|
"test:package": "node scripts/package-smoke.mjs",
|
|
205
205
|
"test:scripts": "node --test 'scripts/*.test.mjs'",
|
|
206
206
|
"check:changelog": "node scripts/check-changelog-sections.mjs",
|
|
207
|
+
"fleet": "node scripts/fleet.mjs",
|
|
207
208
|
"release:plan": "node scripts/release-plan.mjs",
|
|
208
209
|
"release:publish": "node scripts/publish-released.mjs",
|
|
209
210
|
"changelog:unreleased": "bunx git-cliff --config cliff.toml --tag-pattern \"^ooxml-core@\" --unreleased",
|