@office-kit/pptx 0.17.0 → 0.18.1
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/CHANGELOG.md +55 -0
- package/dist/{api-DTHZaBPq.js → api-DlzYhUxG.js} +732 -64
- package/dist/api-DlzYhUxG.js.map +1 -0
- package/dist/{index-Bfvx6-CU.d.ts → index-CAPRpjn2.d.ts} +27 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/package.json +1 -1
- package/dist/api-DTHZaBPq.js.map +0 -1
|
@@ -1682,6 +1682,310 @@ const oneOf = (value, allowed, field) => {
|
|
|
1682
1682
|
return value;
|
|
1683
1683
|
};
|
|
1684
1684
|
//#endregion
|
|
1685
|
+
//#region src/internal/enum-values.ts
|
|
1686
|
+
const SHAPE_PRESETS = [
|
|
1687
|
+
"line",
|
|
1688
|
+
"lineInv",
|
|
1689
|
+
"triangle",
|
|
1690
|
+
"rtTriangle",
|
|
1691
|
+
"rect",
|
|
1692
|
+
"diamond",
|
|
1693
|
+
"parallelogram",
|
|
1694
|
+
"trapezoid",
|
|
1695
|
+
"nonIsoscelesTrapezoid",
|
|
1696
|
+
"pentagon",
|
|
1697
|
+
"hexagon",
|
|
1698
|
+
"heptagon",
|
|
1699
|
+
"octagon",
|
|
1700
|
+
"decagon",
|
|
1701
|
+
"dodecagon",
|
|
1702
|
+
"star4",
|
|
1703
|
+
"star5",
|
|
1704
|
+
"star6",
|
|
1705
|
+
"star7",
|
|
1706
|
+
"star8",
|
|
1707
|
+
"star10",
|
|
1708
|
+
"star12",
|
|
1709
|
+
"star16",
|
|
1710
|
+
"star24",
|
|
1711
|
+
"star32",
|
|
1712
|
+
"roundRect",
|
|
1713
|
+
"round1Rect",
|
|
1714
|
+
"round2SameRect",
|
|
1715
|
+
"round2DiagRect",
|
|
1716
|
+
"snipRoundRect",
|
|
1717
|
+
"snip1Rect",
|
|
1718
|
+
"snip2SameRect",
|
|
1719
|
+
"snip2DiagRect",
|
|
1720
|
+
"plaque",
|
|
1721
|
+
"ellipse",
|
|
1722
|
+
"teardrop",
|
|
1723
|
+
"homePlate",
|
|
1724
|
+
"chevron",
|
|
1725
|
+
"pieWedge",
|
|
1726
|
+
"pie",
|
|
1727
|
+
"blockArc",
|
|
1728
|
+
"donut",
|
|
1729
|
+
"noSmoking",
|
|
1730
|
+
"rightArrow",
|
|
1731
|
+
"leftArrow",
|
|
1732
|
+
"upArrow",
|
|
1733
|
+
"downArrow",
|
|
1734
|
+
"stripedRightArrow",
|
|
1735
|
+
"notchedRightArrow",
|
|
1736
|
+
"bentUpArrow",
|
|
1737
|
+
"leftRightArrow",
|
|
1738
|
+
"upDownArrow",
|
|
1739
|
+
"leftUpArrow",
|
|
1740
|
+
"leftRightUpArrow",
|
|
1741
|
+
"quadArrow",
|
|
1742
|
+
"leftArrowCallout",
|
|
1743
|
+
"rightArrowCallout",
|
|
1744
|
+
"upArrowCallout",
|
|
1745
|
+
"downArrowCallout",
|
|
1746
|
+
"leftRightArrowCallout",
|
|
1747
|
+
"upDownArrowCallout",
|
|
1748
|
+
"quadArrowCallout",
|
|
1749
|
+
"bentArrow",
|
|
1750
|
+
"uturnArrow",
|
|
1751
|
+
"circularArrow",
|
|
1752
|
+
"leftCircularArrow",
|
|
1753
|
+
"leftRightCircularArrow",
|
|
1754
|
+
"curvedRightArrow",
|
|
1755
|
+
"curvedLeftArrow",
|
|
1756
|
+
"curvedUpArrow",
|
|
1757
|
+
"curvedDownArrow",
|
|
1758
|
+
"swooshArrow",
|
|
1759
|
+
"cube",
|
|
1760
|
+
"can",
|
|
1761
|
+
"lightningBolt",
|
|
1762
|
+
"heart",
|
|
1763
|
+
"sun",
|
|
1764
|
+
"moon",
|
|
1765
|
+
"smileyFace",
|
|
1766
|
+
"irregularSeal1",
|
|
1767
|
+
"irregularSeal2",
|
|
1768
|
+
"foldedCorner",
|
|
1769
|
+
"bevel",
|
|
1770
|
+
"frame",
|
|
1771
|
+
"halfFrame",
|
|
1772
|
+
"corner",
|
|
1773
|
+
"diagStripe",
|
|
1774
|
+
"chord",
|
|
1775
|
+
"arc",
|
|
1776
|
+
"leftBracket",
|
|
1777
|
+
"rightBracket",
|
|
1778
|
+
"leftBrace",
|
|
1779
|
+
"rightBrace",
|
|
1780
|
+
"bracketPair",
|
|
1781
|
+
"bracePair",
|
|
1782
|
+
"straightConnector1",
|
|
1783
|
+
"bentConnector2",
|
|
1784
|
+
"bentConnector3",
|
|
1785
|
+
"bentConnector4",
|
|
1786
|
+
"bentConnector5",
|
|
1787
|
+
"curvedConnector2",
|
|
1788
|
+
"curvedConnector3",
|
|
1789
|
+
"curvedConnector4",
|
|
1790
|
+
"curvedConnector5",
|
|
1791
|
+
"callout1",
|
|
1792
|
+
"callout2",
|
|
1793
|
+
"callout3",
|
|
1794
|
+
"accentCallout1",
|
|
1795
|
+
"accentCallout2",
|
|
1796
|
+
"accentCallout3",
|
|
1797
|
+
"borderCallout1",
|
|
1798
|
+
"borderCallout2",
|
|
1799
|
+
"borderCallout3",
|
|
1800
|
+
"accentBorderCallout1",
|
|
1801
|
+
"accentBorderCallout2",
|
|
1802
|
+
"accentBorderCallout3",
|
|
1803
|
+
"wedgeRectCallout",
|
|
1804
|
+
"wedgeRoundRectCallout",
|
|
1805
|
+
"wedgeEllipseCallout",
|
|
1806
|
+
"cloudCallout",
|
|
1807
|
+
"cloud",
|
|
1808
|
+
"ribbon",
|
|
1809
|
+
"ribbon2",
|
|
1810
|
+
"ellipseRibbon",
|
|
1811
|
+
"ellipseRibbon2",
|
|
1812
|
+
"leftRightRibbon",
|
|
1813
|
+
"verticalScroll",
|
|
1814
|
+
"horizontalScroll",
|
|
1815
|
+
"wave",
|
|
1816
|
+
"doubleWave",
|
|
1817
|
+
"plus",
|
|
1818
|
+
"flowChartProcess",
|
|
1819
|
+
"flowChartDecision",
|
|
1820
|
+
"flowChartInputOutput",
|
|
1821
|
+
"flowChartPredefinedProcess",
|
|
1822
|
+
"flowChartInternalStorage",
|
|
1823
|
+
"flowChartDocument",
|
|
1824
|
+
"flowChartMultidocument",
|
|
1825
|
+
"flowChartTerminator",
|
|
1826
|
+
"flowChartPreparation",
|
|
1827
|
+
"flowChartManualInput",
|
|
1828
|
+
"flowChartManualOperation",
|
|
1829
|
+
"flowChartConnector",
|
|
1830
|
+
"flowChartPunchedCard",
|
|
1831
|
+
"flowChartPunchedTape",
|
|
1832
|
+
"flowChartSummingJunction",
|
|
1833
|
+
"flowChartOr",
|
|
1834
|
+
"flowChartCollate",
|
|
1835
|
+
"flowChartSort",
|
|
1836
|
+
"flowChartExtract",
|
|
1837
|
+
"flowChartMerge",
|
|
1838
|
+
"flowChartOfflineStorage",
|
|
1839
|
+
"flowChartOnlineStorage",
|
|
1840
|
+
"flowChartMagneticTape",
|
|
1841
|
+
"flowChartMagneticDisk",
|
|
1842
|
+
"flowChartMagneticDrum",
|
|
1843
|
+
"flowChartDisplay",
|
|
1844
|
+
"flowChartDelay",
|
|
1845
|
+
"flowChartAlternateProcess",
|
|
1846
|
+
"flowChartOffpageConnector",
|
|
1847
|
+
"actionButtonBlank",
|
|
1848
|
+
"actionButtonHome",
|
|
1849
|
+
"actionButtonHelp",
|
|
1850
|
+
"actionButtonInformation",
|
|
1851
|
+
"actionButtonForwardNext",
|
|
1852
|
+
"actionButtonBackPrevious",
|
|
1853
|
+
"actionButtonEnd",
|
|
1854
|
+
"actionButtonBeginning",
|
|
1855
|
+
"actionButtonReturn",
|
|
1856
|
+
"actionButtonDocument",
|
|
1857
|
+
"actionButtonSound",
|
|
1858
|
+
"actionButtonMovie",
|
|
1859
|
+
"gear6",
|
|
1860
|
+
"gear9",
|
|
1861
|
+
"funnel",
|
|
1862
|
+
"mathPlus",
|
|
1863
|
+
"mathMinus",
|
|
1864
|
+
"mathMultiply",
|
|
1865
|
+
"mathDivide",
|
|
1866
|
+
"mathEqual",
|
|
1867
|
+
"mathNotEqual",
|
|
1868
|
+
"cornerTabs",
|
|
1869
|
+
"squareTabs",
|
|
1870
|
+
"plaqueTabs",
|
|
1871
|
+
"chartX",
|
|
1872
|
+
"chartStar",
|
|
1873
|
+
"chartPlus"
|
|
1874
|
+
];
|
|
1875
|
+
const LINE_DASHES = [
|
|
1876
|
+
"solid",
|
|
1877
|
+
"dot",
|
|
1878
|
+
"dash",
|
|
1879
|
+
"lgDash",
|
|
1880
|
+
"dashDot",
|
|
1881
|
+
"lgDashDot",
|
|
1882
|
+
"lgDashDotDot",
|
|
1883
|
+
"sysDash",
|
|
1884
|
+
"sysDot",
|
|
1885
|
+
"sysDashDot",
|
|
1886
|
+
"sysDashDotDot"
|
|
1887
|
+
];
|
|
1888
|
+
const TEXT_DIRECTIONS = [
|
|
1889
|
+
"horz",
|
|
1890
|
+
"vert",
|
|
1891
|
+
"vert270",
|
|
1892
|
+
"wordArtVert",
|
|
1893
|
+
"eaVert",
|
|
1894
|
+
"mongolianVert",
|
|
1895
|
+
"wordArtVertRtl"
|
|
1896
|
+
];
|
|
1897
|
+
const AUTO_NUMBER_SCHEMES = [
|
|
1898
|
+
"alphaLcParenBoth",
|
|
1899
|
+
"alphaUcParenBoth",
|
|
1900
|
+
"alphaLcParenR",
|
|
1901
|
+
"alphaUcParenR",
|
|
1902
|
+
"alphaLcPeriod",
|
|
1903
|
+
"alphaUcPeriod",
|
|
1904
|
+
"arabicParenBoth",
|
|
1905
|
+
"arabicParenR",
|
|
1906
|
+
"arabicPeriod",
|
|
1907
|
+
"arabicPlain",
|
|
1908
|
+
"romanLcParenBoth",
|
|
1909
|
+
"romanUcParenBoth",
|
|
1910
|
+
"romanLcParenR",
|
|
1911
|
+
"romanUcParenR",
|
|
1912
|
+
"romanLcPeriod",
|
|
1913
|
+
"romanUcPeriod",
|
|
1914
|
+
"circleNumDbPlain",
|
|
1915
|
+
"circleNumWdBlackPlain",
|
|
1916
|
+
"circleNumWdWhitePlain",
|
|
1917
|
+
"arabicDbPeriod",
|
|
1918
|
+
"arabicDbPlain",
|
|
1919
|
+
"ea1ChsPeriod",
|
|
1920
|
+
"ea1ChsPlain",
|
|
1921
|
+
"ea1ChtPeriod",
|
|
1922
|
+
"ea1ChtPlain",
|
|
1923
|
+
"ea1JpnChsDbPeriod",
|
|
1924
|
+
"ea1JpnKorPlain",
|
|
1925
|
+
"ea1JpnKorPeriod",
|
|
1926
|
+
"arabic1Minus",
|
|
1927
|
+
"arabic2Minus",
|
|
1928
|
+
"hebrew2Minus",
|
|
1929
|
+
"thaiAlphaPeriod",
|
|
1930
|
+
"thaiAlphaParenR",
|
|
1931
|
+
"thaiAlphaParenBoth",
|
|
1932
|
+
"thaiNumPeriod",
|
|
1933
|
+
"thaiNumParenR",
|
|
1934
|
+
"thaiNumParenBoth",
|
|
1935
|
+
"hindiAlphaPeriod",
|
|
1936
|
+
"hindiNumPeriod",
|
|
1937
|
+
"hindiNumParenR",
|
|
1938
|
+
"hindiAlpha1Period"
|
|
1939
|
+
];
|
|
1940
|
+
const UNDERLINES = [
|
|
1941
|
+
"none",
|
|
1942
|
+
"words",
|
|
1943
|
+
"sng",
|
|
1944
|
+
"dbl",
|
|
1945
|
+
"heavy",
|
|
1946
|
+
"dotted",
|
|
1947
|
+
"dottedHeavy",
|
|
1948
|
+
"dash",
|
|
1949
|
+
"dashHeavy",
|
|
1950
|
+
"dashLong",
|
|
1951
|
+
"dashLongHeavy",
|
|
1952
|
+
"dotDash",
|
|
1953
|
+
"dotDashHeavy",
|
|
1954
|
+
"dotDotDash",
|
|
1955
|
+
"dotDotDashHeavy",
|
|
1956
|
+
"wavy",
|
|
1957
|
+
"wavyHeavy",
|
|
1958
|
+
"wavyDbl"
|
|
1959
|
+
];
|
|
1960
|
+
const STRIKES = [
|
|
1961
|
+
"noStrike",
|
|
1962
|
+
"sngStrike",
|
|
1963
|
+
"dblStrike"
|
|
1964
|
+
];
|
|
1965
|
+
const SLIDE_SIZE_TYPES = [
|
|
1966
|
+
"screen4x3",
|
|
1967
|
+
"letter",
|
|
1968
|
+
"A4",
|
|
1969
|
+
"35mm",
|
|
1970
|
+
"overhead",
|
|
1971
|
+
"banner",
|
|
1972
|
+
"custom",
|
|
1973
|
+
"ledger",
|
|
1974
|
+
"A3",
|
|
1975
|
+
"B4ISO",
|
|
1976
|
+
"B5ISO",
|
|
1977
|
+
"B4JIS",
|
|
1978
|
+
"B5JIS",
|
|
1979
|
+
"hagakiCard",
|
|
1980
|
+
"screen16x9",
|
|
1981
|
+
"screen16x10"
|
|
1982
|
+
];
|
|
1983
|
+
const TEXT_ANCHORS = {
|
|
1984
|
+
top: "t",
|
|
1985
|
+
center: "ctr",
|
|
1986
|
+
bottom: "b"
|
|
1987
|
+
};
|
|
1988
|
+
//#endregion
|
|
1685
1989
|
//#region src/internal/drawingml/color.ts
|
|
1686
1990
|
const NAME_SRGB_CLR$4 = qname("a", "srgbClr", NS.dml);
|
|
1687
1991
|
const NAME_SCHEME_CLR$2 = qname("a", "schemeClr", NS.dml);
|
|
@@ -1838,8 +2142,21 @@ const setHighlight = (rPr, value) => {
|
|
|
1838
2142
|
if (parsed === null) throw new Error(`unrecognized highlight color: ${value}`);
|
|
1839
2143
|
insertChildByRank(rPr, elem(NAME_HIGHLIGHT, { children: [parsed.kind === "srgb" ? elem(NAME_SRGB_CLR$3, { attrs: [attr(ATTR_VAL$8, parsed.hex)] }) : elem(NAME_SCHEME_CLR$1, { attrs: [attr(ATTR_VAL$8, parsed.token)] })] }), rprChildRank);
|
|
1840
2144
|
};
|
|
2145
|
+
const validateFormatEnums = (format, caller) => {
|
|
2146
|
+
if (format.underline != null && typeof format.underline !== "boolean") oneOf(format.underline, UNDERLINES, `${caller}: underline`);
|
|
2147
|
+
if (format.strike != null && typeof format.strike !== "boolean") oneOf(format.strike, STRIKES, `${caller}: strike`);
|
|
2148
|
+
if (format.cap != null) oneOf(format.cap, [
|
|
2149
|
+
"none",
|
|
2150
|
+
"small",
|
|
2151
|
+
"all"
|
|
2152
|
+
], `${caller}: cap`);
|
|
2153
|
+
};
|
|
1841
2154
|
/** Mutates `rPr` in place per `format`. */
|
|
1842
|
-
const applyRunFormat = (rPr, format) => {
|
|
2155
|
+
const applyRunFormat = (rPr, format, caller = "setShapeRunFormat") => {
|
|
2156
|
+
validateFormatEnums(format, caller);
|
|
2157
|
+
applyValidatedRunFormat(rPr, format);
|
|
2158
|
+
};
|
|
2159
|
+
const applyValidatedRunFormat = (rPr, format) => {
|
|
1843
2160
|
let attrs = rPr.attrs;
|
|
1844
2161
|
if (format.size !== void 0) {
|
|
1845
2162
|
const sz = fontSizeHundredthPt(format.size * 100, "setShapeRunFormat: size");
|
|
@@ -1877,7 +2194,11 @@ const applyRunFormat = (rPr, format) => {
|
|
|
1877
2194
|
* supplied format. Existing run-property attributes not addressed by
|
|
1878
2195
|
* `format` are preserved.
|
|
1879
2196
|
*/
|
|
1880
|
-
const applyFormatToAllRuns = (txBody, format) => {
|
|
2197
|
+
const applyFormatToAllRuns = (txBody, format, caller = "setShapeTextFormat") => {
|
|
2198
|
+
validateFormatEnums(format, caller);
|
|
2199
|
+
applyValidatedFormatToAllRuns(txBody, format);
|
|
2200
|
+
};
|
|
2201
|
+
const applyValidatedFormatToAllRuns = (txBody, format) => {
|
|
1881
2202
|
for (const p of txBody.children) {
|
|
1882
2203
|
if (p.kind !== "element" || p.name.namespaceURI !== NS.dml || p.name.localName !== "p") continue;
|
|
1883
2204
|
for (const r of p.children) {
|
|
@@ -1887,7 +2208,7 @@ const applyFormatToAllRuns = (txBody, format) => {
|
|
|
1887
2208
|
rPr = elem(NAME_RPR$6);
|
|
1888
2209
|
r.children.unshift(rPr);
|
|
1889
2210
|
}
|
|
1890
|
-
|
|
2211
|
+
applyValidatedRunFormat(rPr, format);
|
|
1891
2212
|
}
|
|
1892
2213
|
}
|
|
1893
2214
|
};
|
|
@@ -2026,7 +2347,12 @@ const replaceTextInTree = (root, from, to) => {
|
|
|
2026
2347
|
});
|
|
2027
2348
|
return count;
|
|
2028
2349
|
};
|
|
2029
|
-
const normalizeBulletStyle = (s) => {
|
|
2350
|
+
const normalizeBulletStyle = (s, caller) => {
|
|
2351
|
+
if (typeof s === "string") oneOf(s, [
|
|
2352
|
+
"bullet",
|
|
2353
|
+
"number",
|
|
2354
|
+
"none"
|
|
2355
|
+
], `${caller}: bullets`);
|
|
2030
2356
|
if (s === "bullet") return {
|
|
2031
2357
|
kind: "char",
|
|
2032
2358
|
char: "•"
|
|
@@ -2042,11 +2368,10 @@ const normalizeBulletStyle = (s) => {
|
|
|
2042
2368
|
};
|
|
2043
2369
|
return {
|
|
2044
2370
|
kind: "autoNum",
|
|
2045
|
-
type: s.autoNum
|
|
2371
|
+
type: oneOf(s.autoNum, AUTO_NUMBER_SCHEMES, `${caller}: bullets.autoNum`)
|
|
2046
2372
|
};
|
|
2047
2373
|
};
|
|
2048
|
-
const buildBulletElement = (
|
|
2049
|
-
const n = normalizeBulletStyle(style);
|
|
2374
|
+
const buildBulletElement = (n) => {
|
|
2050
2375
|
switch (n.kind) {
|
|
2051
2376
|
case "char": return elem(NAME_BU_CHAR, { attrs: [attr(ATTR_CHAR, n.char)] });
|
|
2052
2377
|
case "autoNum": return elem(NAME_BU_AUTO_NUM, { attrs: [attr(ATTR_START_AT, "1"), attr(ATTR_BU_TYPE, n.type)] });
|
|
@@ -2055,7 +2380,35 @@ const buildBulletElement = (style) => {
|
|
|
2055
2380
|
};
|
|
2056
2381
|
const NAME_PPR_FOR_BULLET = qname("a", "pPr", NS.dml);
|
|
2057
2382
|
const NAME_P_FOR_BULLET = qname("a", "p", NS.dml);
|
|
2058
|
-
const
|
|
2383
|
+
const ALIGNMENT_TOKENS = [
|
|
2384
|
+
"l",
|
|
2385
|
+
"ctr",
|
|
2386
|
+
"r",
|
|
2387
|
+
"just",
|
|
2388
|
+
"dist",
|
|
2389
|
+
"justLow",
|
|
2390
|
+
"thaiDist"
|
|
2391
|
+
];
|
|
2392
|
+
/**
|
|
2393
|
+
* Parses an `algn` attribute value from a file. A value outside
|
|
2394
|
+
* `ST_TextAlignType` is malformed input and reads as unset.
|
|
2395
|
+
*/
|
|
2396
|
+
const parseAlignmentToken = (value) => ALIGNMENT_TOKENS.find((token) => token === value) ?? null;
|
|
2397
|
+
const alignToken = (a, caller) => {
|
|
2398
|
+
oneOf(a, [
|
|
2399
|
+
"left",
|
|
2400
|
+
"center",
|
|
2401
|
+
"right",
|
|
2402
|
+
"justify",
|
|
2403
|
+
"distribute",
|
|
2404
|
+
"l",
|
|
2405
|
+
"ctr",
|
|
2406
|
+
"r",
|
|
2407
|
+
"just",
|
|
2408
|
+
"dist",
|
|
2409
|
+
"justLow",
|
|
2410
|
+
"thaiDist"
|
|
2411
|
+
], `${caller}: align`);
|
|
2059
2412
|
switch (a) {
|
|
2060
2413
|
case "left":
|
|
2061
2414
|
case "l": return "l";
|
|
@@ -2075,8 +2428,10 @@ const ATTR_ALGN$1 = qname("", "algn", "");
|
|
|
2075
2428
|
* Sets `<a:pPr algn="...">` on every paragraph in `txBody`. Existing
|
|
2076
2429
|
* pPr attributes other than `algn` are preserved.
|
|
2077
2430
|
*/
|
|
2078
|
-
const applyAlignmentToAllParagraphs = (txBody, align) => {
|
|
2079
|
-
|
|
2431
|
+
const applyAlignmentToAllParagraphs = (txBody, align, caller = "setShapeAlignment") => {
|
|
2432
|
+
applyAlignmentTokenToAllParagraphs(txBody, alignToken(align, caller));
|
|
2433
|
+
};
|
|
2434
|
+
const applyAlignmentTokenToAllParagraphs = (txBody, token) => {
|
|
2080
2435
|
for (const p of txBody.children) {
|
|
2081
2436
|
if (p.kind !== "element" || p.name.namespaceURI !== NAME_P_FOR_BULLET.namespaceURI || p.name.localName !== "p") continue;
|
|
2082
2437
|
let pPr = firstChildElement(p, NAME_PPR_FOR_BULLET);
|
|
@@ -2118,32 +2473,39 @@ const BULLET_INDENT_BY_LEVEL = [
|
|
|
2118
2473
|
const bulletIndentForLevel = (lvl) => BULLET_INDENT_BY_LEVEL[Math.min(lvl, BULLET_INDENT_BY_LEVEL.length - 1)];
|
|
2119
2474
|
const ATTR_MAR_L$1 = qname("", "marL", "");
|
|
2120
2475
|
const ATTR_INDENT$1 = qname("", "indent", "");
|
|
2476
|
+
const updateBulletIndentForLevel = (pPr, previousLevel, level) => {
|
|
2477
|
+
const previous = bulletIndentForLevel(previousLevel);
|
|
2478
|
+
const marL = pPr.attrs.find((a) => a.name.namespaceURI === "" && a.name.localName === "marL");
|
|
2479
|
+
const indent = pPr.attrs.find((a) => a.name.namespaceURI === "" && a.name.localName === "indent");
|
|
2480
|
+
if (marL?.value !== String(previous.marL) || indent?.value !== String(previous.indent)) return;
|
|
2481
|
+
const next = bulletIndentForLevel(level);
|
|
2482
|
+
pPr.attrs = pPr.attrs.map((a) => a === marL ? attr(a.name, String(next.marL)) : a === indent ? attr(a.name, String(next.indent)) : a);
|
|
2483
|
+
};
|
|
2121
2484
|
const hasAttr = (el, local) => el.attrs.some((a) => a.name.namespaceURI === "" && a.name.localName === local);
|
|
2122
|
-
const
|
|
2485
|
+
const applyNormalizedBullet = (paragraph, style) => {
|
|
2123
2486
|
let pPr = firstChildElement(paragraph, NAME_PPR_FOR_BULLET);
|
|
2124
2487
|
if (pPr === null) {
|
|
2125
2488
|
pPr = elem(NAME_PPR_FOR_BULLET);
|
|
2126
2489
|
paragraph.children.unshift(pPr);
|
|
2127
2490
|
}
|
|
2128
2491
|
pPr.children = pPr.children.filter((c) => !(c.kind === "element" && c.name.namespaceURI === NS.dml && (c.name.localName === "buChar" || c.name.localName === "buAutoNum" || c.name.localName === "buNone" || c.name.localName === "buFont")));
|
|
2129
|
-
if (style !== "none") {
|
|
2492
|
+
if (style.kind !== "none") {
|
|
2130
2493
|
const lvl = Number.parseInt(pPr.attrs.find((a) => a.name.localName === "lvl")?.value ?? "0", 10);
|
|
2131
2494
|
const { marL, indent } = bulletIndentForLevel(Number.isFinite(lvl) ? lvl : 0);
|
|
2132
2495
|
if (!hasAttr(pPr, "marL")) pPr.attrs.push(attr(ATTR_MAR_L$1, String(marL)));
|
|
2133
2496
|
if (!hasAttr(pPr, "indent")) pPr.attrs.push(attr(ATTR_INDENT$1, String(indent)));
|
|
2134
2497
|
}
|
|
2135
|
-
if (
|
|
2498
|
+
if (style.kind === "autoNum") pPr.children.push(elem(NAME_BU_FONT, { attrs: [attr(ATTR_TYPEFACE$2, "+mj-lt")] }));
|
|
2136
2499
|
pPr.children.push(buildBulletElement(style));
|
|
2137
2500
|
};
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
* before inserting the new one. Creates `<a:pPr>` if absent.
|
|
2142
|
-
*/
|
|
2501
|
+
const applyBulletToParagraph = (paragraph, style) => {
|
|
2502
|
+
applyNormalizedBullet(paragraph, normalizeBulletStyle(style, "setParagraphBullet"));
|
|
2503
|
+
};
|
|
2143
2504
|
const applyBulletToAllParagraphs = (txBody, style) => {
|
|
2505
|
+
const normalized = normalizeBulletStyle(style, "setShapeBullets");
|
|
2144
2506
|
for (const p of txBody.children) {
|
|
2145
2507
|
if (p.kind !== "element" || p.name.namespaceURI !== NAME_P_FOR_BULLET.namespaceURI || p.name.localName !== "p") continue;
|
|
2146
|
-
|
|
2508
|
+
applyNormalizedBullet(p, normalized);
|
|
2147
2509
|
}
|
|
2148
2510
|
};
|
|
2149
2511
|
/**
|
|
@@ -2159,7 +2521,8 @@ const applyBulletToAllParagraphs = (txBody, style) => {
|
|
|
2159
2521
|
*
|
|
2160
2522
|
* The `bodyPr` and `lstStyle` children (if any) are preserved untouched.
|
|
2161
2523
|
*/
|
|
2162
|
-
const setTextBody = (txBody, value) => {
|
|
2524
|
+
const setTextBody = (txBody, value, bullets) => {
|
|
2525
|
+
const normalized = bullets === void 0 ? void 0 : normalizeBulletStyle(bullets, "setShapeText");
|
|
2163
2526
|
const rPrTemplate = findFirstRunProperties(txBody);
|
|
2164
2527
|
const pPrTemplate = findFirstParagraphProperties(txBody);
|
|
2165
2528
|
removeAllParagraphs(txBody);
|
|
@@ -2168,6 +2531,7 @@ const setTextBody = (txBody, value) => {
|
|
|
2168
2531
|
const t = elem(NAME_T$5, { children: line.length > 0 ? [text(line)] : [] });
|
|
2169
2532
|
const r = elem(NAME_R$4, { children: rPrTemplate !== null ? [cloneElement(rPrTemplate), t] : [t] });
|
|
2170
2533
|
const p = elem(NAME_P$5, { children: pPrTemplate !== null ? [cloneElement(pPrTemplate), r] : [r] });
|
|
2534
|
+
if (normalized !== void 0) applyNormalizedBullet(p, normalized);
|
|
2171
2535
|
txBody.children.push(p);
|
|
2172
2536
|
}
|
|
2173
2537
|
};
|
|
@@ -2176,21 +2540,21 @@ const setTextBody = (txBody, value) => {
|
|
|
2176
2540
|
* here, so a caller that builds before it touches the tree leaves the
|
|
2177
2541
|
* existing text intact when a value is rejected.
|
|
2178
2542
|
*/
|
|
2179
|
-
const buildTextBodyParagraphs = (paragraphs) => {
|
|
2543
|
+
const buildTextBodyParagraphs = (paragraphs, caller = "setShapeParagraphs") => {
|
|
2180
2544
|
if (paragraphs.length === 0) throw new Error("setTextBodyParagraphs: at least one paragraph is required");
|
|
2181
2545
|
const built = [];
|
|
2182
2546
|
for (const para of paragraphs) {
|
|
2183
2547
|
const children = [];
|
|
2184
|
-
if (para.align !== void 0) children.push(elem(NAME_PPR$1, { attrs: [attr(ATTR_ALGN$1, alignToken(para.align))] }));
|
|
2548
|
+
if (para.align !== void 0) children.push(elem(NAME_PPR$1, { attrs: [attr(ATTR_ALGN$1, alignToken(para.align, caller))] }));
|
|
2185
2549
|
for (const run of para.runs) {
|
|
2186
2550
|
const rPr = elem(NAME_RPR$5);
|
|
2187
|
-
if (run.format !== void 0) applyRunFormat(rPr, run.format);
|
|
2551
|
+
if (run.format !== void 0) applyRunFormat(rPr, run.format, caller);
|
|
2188
2552
|
const t = elem(NAME_T$5, { children: run.text.length > 0 ? [text(run.text)] : [] });
|
|
2189
2553
|
children.push(elem(NAME_R$4, { children: [rPr, t] }));
|
|
2190
2554
|
}
|
|
2191
2555
|
if (para.endFormat !== void 0) {
|
|
2192
2556
|
const endParaRPr = elem(NAME_END_PARA_RPR);
|
|
2193
|
-
applyRunFormat(endParaRPr, para.endFormat);
|
|
2557
|
+
applyRunFormat(endParaRPr, para.endFormat, caller);
|
|
2194
2558
|
children.push(endParaRPr);
|
|
2195
2559
|
}
|
|
2196
2560
|
built.push(elem(NAME_P$5, { children }));
|
|
@@ -2350,6 +2714,12 @@ const setPatternFill = (host, options) => {
|
|
|
2350
2714
|
};
|
|
2351
2715
|
/** Sets `<a:gradFill>` on `host`, replacing any previous fill choice. */
|
|
2352
2716
|
const setGradientFill = (host, options) => {
|
|
2717
|
+
if (options.path !== void 0) oneOf(options.path, [
|
|
2718
|
+
"linear",
|
|
2719
|
+
"circle",
|
|
2720
|
+
"rect",
|
|
2721
|
+
"shape"
|
|
2722
|
+
], "setShapeGradientFill: path");
|
|
2353
2723
|
if (options.stops.length < 2) throw new Error("gradient fill requires at least two stops");
|
|
2354
2724
|
removeAnyFill(host);
|
|
2355
2725
|
const stops = options.stops.map((s) => {
|
|
@@ -2534,6 +2904,7 @@ const ATTR_VAL$6 = qname("", "val", "");
|
|
|
2534
2904
|
* `<a:ln>` if absent. Replacing the dash choice on subsequent calls.
|
|
2535
2905
|
*/
|
|
2536
2906
|
const setStrokeDash = (spPr, dash) => {
|
|
2907
|
+
oneOf(dash, LINE_DASHES, "setShapeStrokeDash: dash");
|
|
2537
2908
|
const ln = ensureLn(spPr);
|
|
2538
2909
|
ln.children = ln.children.filter((c) => !(c.kind === "element" && c.name.namespaceURI === NS.dml && c.name.localName === "prstDash"));
|
|
2539
2910
|
insertLnChild(ln, elem(NAME_PRST_DASH, { attrs: [attr(ATTR_VAL$6, dash)] }));
|
|
@@ -2551,8 +2922,30 @@ const ATTR_LEN = qname("", "len", "");
|
|
|
2551
2922
|
* behavior).
|
|
2552
2923
|
*/
|
|
2553
2924
|
const setStrokeArrow = (spPr, end, options) => {
|
|
2925
|
+
oneOf(end, ["head", "tail"], "setShapeStrokeArrow: end");
|
|
2926
|
+
oneOf(options.type, [
|
|
2927
|
+
"none",
|
|
2928
|
+
"triangle",
|
|
2929
|
+
"stealth",
|
|
2930
|
+
"diamond",
|
|
2931
|
+
"oval",
|
|
2932
|
+
"arrow"
|
|
2933
|
+
], "setShapeStrokeArrow: type");
|
|
2934
|
+
if (options.width !== void 0) oneOf(options.width, [
|
|
2935
|
+
"sm",
|
|
2936
|
+
"med",
|
|
2937
|
+
"lg"
|
|
2938
|
+
], "setShapeStrokeArrow: width");
|
|
2939
|
+
if (options.length !== void 0) oneOf(options.length, [
|
|
2940
|
+
"sm",
|
|
2941
|
+
"med",
|
|
2942
|
+
"lg"
|
|
2943
|
+
], "setShapeStrokeArrow: length");
|
|
2554
2944
|
const ln = ensureLn(spPr);
|
|
2555
|
-
const localName =
|
|
2945
|
+
const localName = {
|
|
2946
|
+
head: "headEnd",
|
|
2947
|
+
tail: "tailEnd"
|
|
2948
|
+
}[end];
|
|
2556
2949
|
ln.children = ln.children.filter((c) => !(c.kind === "element" && c.name.namespaceURI === NS.dml && c.name.localName === localName));
|
|
2557
2950
|
const attrs = [attr(ATTR_TYPE$5, options.type)];
|
|
2558
2951
|
if (options.width !== void 0) attrs.push(attr(ATTR_W$3, options.width));
|
|
@@ -2561,6 +2954,11 @@ const setStrokeArrow = (spPr, end, options) => {
|
|
|
2561
2954
|
};
|
|
2562
2955
|
/** Sets `<a:ln cap="…"/>`. Pass `null` to clear the attribute. */
|
|
2563
2956
|
const setStrokeCap = (spPr, cap) => {
|
|
2957
|
+
if (cap !== null) oneOf(cap, [
|
|
2958
|
+
"rnd",
|
|
2959
|
+
"sq",
|
|
2960
|
+
"flat"
|
|
2961
|
+
], "setShapeStrokeCap: cap");
|
|
2564
2962
|
const ln = ensureLn(spPr);
|
|
2565
2963
|
ln.attrs = ln.attrs.filter((a) => !(a.name.namespaceURI === "" && a.name.localName === "cap"));
|
|
2566
2964
|
if (cap !== null) ln.attrs.push(attr(qname("", "cap", ""), cap));
|
|
@@ -2572,12 +2970,24 @@ const JOIN_LOCALS = new Set([
|
|
|
2572
2970
|
]);
|
|
2573
2971
|
/** Replaces the join child of `<a:ln>`. Pass `null` to remove it. */
|
|
2574
2972
|
const setStrokeJoin = (spPr, join) => {
|
|
2973
|
+
if (join !== null) oneOf(join, [
|
|
2974
|
+
"round",
|
|
2975
|
+
"bevel",
|
|
2976
|
+
"miter"
|
|
2977
|
+
], "setShapeStrokeJoin: join");
|
|
2575
2978
|
const ln = ensureLn(spPr);
|
|
2576
2979
|
removeChildrenIn(ln, JOIN_LOCALS);
|
|
2577
2980
|
if (join !== null) insertLnChild(ln, elem(qname("a", join, NS.dml)));
|
|
2578
2981
|
};
|
|
2579
2982
|
/** Sets `<a:ln cmpd="…"/>`. Pass `null` to clear the attribute. */
|
|
2580
2983
|
const setStrokeCompound = (spPr, cmpd) => {
|
|
2984
|
+
if (cmpd !== null) oneOf(cmpd, [
|
|
2985
|
+
"sng",
|
|
2986
|
+
"dbl",
|
|
2987
|
+
"thickThin",
|
|
2988
|
+
"thinThick",
|
|
2989
|
+
"tri"
|
|
2990
|
+
], "setShapeStrokeCompound: cmpd");
|
|
2581
2991
|
const ln = ensureLn(spPr);
|
|
2582
2992
|
ln.attrs = ln.attrs.filter((a) => !(a.name.namespaceURI === "" && a.name.localName === "cmpd"));
|
|
2583
2993
|
if (cmpd !== null) ln.attrs.push(attr(qname("", "cmpd", ""), cmpd));
|
|
@@ -3487,6 +3897,12 @@ const buildTextBody = (text$1, anchor) => {
|
|
|
3487
3897
|
] });
|
|
3488
3898
|
};
|
|
3489
3899
|
const buildShape = (opts) => {
|
|
3900
|
+
oneOf(opts.preset, SHAPE_PRESETS, "addSlideShape: preset");
|
|
3901
|
+
if (opts.textAnchor !== void 0) oneOf(opts.textAnchor, [
|
|
3902
|
+
"t",
|
|
3903
|
+
"ctr",
|
|
3904
|
+
"b"
|
|
3905
|
+
], "addSlideShape: textAnchor");
|
|
3490
3906
|
const name = opts.name ?? `${opts.preset} ${opts.id}`;
|
|
3491
3907
|
const anchor = opts.textAnchor ?? "ctr";
|
|
3492
3908
|
const children = [elem(NAME_NV_SP_PR$1, { children: [
|
|
@@ -4125,12 +4541,20 @@ const buildEffectElement = (opts) => {
|
|
|
4125
4541
|
attrs.push(attr(ATTR_DIR, opts.direction));
|
|
4126
4542
|
}
|
|
4127
4543
|
}
|
|
4128
|
-
if (opts.orientation !== void 0 && opts.effect === "split")
|
|
4544
|
+
if (opts.orientation !== void 0 && opts.effect === "split") {
|
|
4545
|
+
oneOf(opts.orientation, ["horz", "vert"], "setSlideTransition: orientation");
|
|
4546
|
+
attrs.push(attr(ATTR_ORIENT, opts.orientation));
|
|
4547
|
+
}
|
|
4129
4548
|
if (opts.thruBlack && THRU_BLK_EFFECTS.has(opts.effect)) attrs.push(attr(ATTR_THRU_BLK, "1"));
|
|
4130
4549
|
return elem(name, { attrs });
|
|
4131
4550
|
};
|
|
4132
4551
|
/** Returns a complete `<p:transition>` element. */
|
|
4133
4552
|
const buildTransition = (opts) => {
|
|
4553
|
+
if (opts.speed !== void 0) oneOf(opts.speed, [
|
|
4554
|
+
"slow",
|
|
4555
|
+
"med",
|
|
4556
|
+
"fast"
|
|
4557
|
+
], "setSlideTransition: speed");
|
|
4134
4558
|
const attrs = [];
|
|
4135
4559
|
if (opts.speed !== void 0) attrs.push(attr(ATTR_SPD, opts.speed));
|
|
4136
4560
|
if (opts.advanceOnClick === false) attrs.push(attr(ATTR_ADV_CLICK, "0"));
|
|
@@ -4267,10 +4691,15 @@ const buildOpacityAnim = (spid, durationMs, fadeIn) => {
|
|
|
4267
4691
|
};
|
|
4268
4692
|
/**
|
|
4269
4693
|
* Builds the complete `<p:timing>` element for a single click-effect on
|
|
4270
|
-
* the given shape id.
|
|
4694
|
+
* the given shape id.
|
|
4271
4695
|
*/
|
|
4272
4696
|
const buildSingleEffectTiming = (spid, opts) => {
|
|
4273
|
-
const preset = PRESETS[opts.effect
|
|
4697
|
+
const preset = PRESETS[oneOf(opts.effect, [
|
|
4698
|
+
"fadeIn",
|
|
4699
|
+
"fadeOut",
|
|
4700
|
+
"appear",
|
|
4701
|
+
"disappear"
|
|
4702
|
+
], "setShapeAnimation: effect")];
|
|
4274
4703
|
const duration = opts.durationMs === void 0 ? 500 : unsignedIntMs(opts.durationMs, "setShapeAnimation: durationMs");
|
|
4275
4704
|
const isFade = opts.effect === "fadeIn" || opts.effect === "fadeOut";
|
|
4276
4705
|
const isEntrance = preset.presetClass === "entr";
|
|
@@ -5381,6 +5810,218 @@ const setShapeClickAction = (shape, action) => {
|
|
|
5381
5810
|
commitAndRefresh(shape);
|
|
5382
5811
|
};
|
|
5383
5812
|
//#endregion
|
|
5813
|
+
//#region src/internal/chartml/enum-validation.ts
|
|
5814
|
+
const LABEL_POSITIONS = [
|
|
5815
|
+
"ctr",
|
|
5816
|
+
"inEnd",
|
|
5817
|
+
"outEnd",
|
|
5818
|
+
"inBase",
|
|
5819
|
+
"t",
|
|
5820
|
+
"b",
|
|
5821
|
+
"l",
|
|
5822
|
+
"r",
|
|
5823
|
+
"bestFit"
|
|
5824
|
+
];
|
|
5825
|
+
const DISPLAY_UNITS = [
|
|
5826
|
+
"hundreds",
|
|
5827
|
+
"thousands",
|
|
5828
|
+
"tenThousands",
|
|
5829
|
+
"hundredThousands",
|
|
5830
|
+
"millions",
|
|
5831
|
+
"tenMillions",
|
|
5832
|
+
"hundredMillions",
|
|
5833
|
+
"billions",
|
|
5834
|
+
"trillions"
|
|
5835
|
+
];
|
|
5836
|
+
const LABEL_ALIGNMENTS = [
|
|
5837
|
+
"ctr",
|
|
5838
|
+
"l",
|
|
5839
|
+
"r"
|
|
5840
|
+
];
|
|
5841
|
+
const DISPLAY_BLANKS = [
|
|
5842
|
+
"gap",
|
|
5843
|
+
"zero",
|
|
5844
|
+
"span"
|
|
5845
|
+
];
|
|
5846
|
+
const SCATTER_STYLES = [
|
|
5847
|
+
"none",
|
|
5848
|
+
"line",
|
|
5849
|
+
"lineMarker",
|
|
5850
|
+
"marker",
|
|
5851
|
+
"smooth",
|
|
5852
|
+
"smoothMarker"
|
|
5853
|
+
];
|
|
5854
|
+
const RADAR_STYLES = [
|
|
5855
|
+
"standard",
|
|
5856
|
+
"marker",
|
|
5857
|
+
"filled"
|
|
5858
|
+
];
|
|
5859
|
+
const BAR_3D_SHAPES = [
|
|
5860
|
+
"box",
|
|
5861
|
+
"cone",
|
|
5862
|
+
"coneToMax",
|
|
5863
|
+
"cylinder",
|
|
5864
|
+
"pyramid",
|
|
5865
|
+
"pyramidToMax"
|
|
5866
|
+
];
|
|
5867
|
+
const OF_PIE_TYPES = ["pie", "bar"];
|
|
5868
|
+
const SPLIT_TYPES = [
|
|
5869
|
+
"auto",
|
|
5870
|
+
"cust",
|
|
5871
|
+
"percent",
|
|
5872
|
+
"pos",
|
|
5873
|
+
"val"
|
|
5874
|
+
];
|
|
5875
|
+
const LAYOUT_TARGETS = ["inner", "outer"];
|
|
5876
|
+
const AXIS_CROSSES = [
|
|
5877
|
+
"autoZero",
|
|
5878
|
+
"min",
|
|
5879
|
+
"max"
|
|
5880
|
+
];
|
|
5881
|
+
const LEGEND_POSITIONS = [
|
|
5882
|
+
"r",
|
|
5883
|
+
"t",
|
|
5884
|
+
"b",
|
|
5885
|
+
"l",
|
|
5886
|
+
"tr"
|
|
5887
|
+
];
|
|
5888
|
+
const MARKER_SYMBOLS = [
|
|
5889
|
+
"none",
|
|
5890
|
+
"auto",
|
|
5891
|
+
"circle",
|
|
5892
|
+
"square",
|
|
5893
|
+
"diamond",
|
|
5894
|
+
"triangle",
|
|
5895
|
+
"star",
|
|
5896
|
+
"x",
|
|
5897
|
+
"plus",
|
|
5898
|
+
"dash",
|
|
5899
|
+
"dot",
|
|
5900
|
+
"picture"
|
|
5901
|
+
];
|
|
5902
|
+
const TRENDLINE_TYPES = [
|
|
5903
|
+
"linear",
|
|
5904
|
+
"exp",
|
|
5905
|
+
"log",
|
|
5906
|
+
"poly",
|
|
5907
|
+
"power",
|
|
5908
|
+
"movingAvg"
|
|
5909
|
+
];
|
|
5910
|
+
const ERROR_BAR_TYPES = [
|
|
5911
|
+
"both",
|
|
5912
|
+
"plus",
|
|
5913
|
+
"minus"
|
|
5914
|
+
];
|
|
5915
|
+
const ERROR_VALUE_TYPES = [
|
|
5916
|
+
"fixedVal",
|
|
5917
|
+
"percentage",
|
|
5918
|
+
"stdDev",
|
|
5919
|
+
"stdErr",
|
|
5920
|
+
"cust"
|
|
5921
|
+
];
|
|
5922
|
+
const GROUPINGS = [
|
|
5923
|
+
"clustered",
|
|
5924
|
+
"stacked",
|
|
5925
|
+
"percentStacked",
|
|
5926
|
+
"standard"
|
|
5927
|
+
];
|
|
5928
|
+
const TICK_MARKS = [
|
|
5929
|
+
"in",
|
|
5930
|
+
"out",
|
|
5931
|
+
"cross",
|
|
5932
|
+
"none"
|
|
5933
|
+
];
|
|
5934
|
+
const TICK_LABEL_POSITIONS = [
|
|
5935
|
+
"none",
|
|
5936
|
+
"low",
|
|
5937
|
+
"high",
|
|
5938
|
+
"nextTo"
|
|
5939
|
+
];
|
|
5940
|
+
const ORIENTATIONS = ["minMax", "maxMin"];
|
|
5941
|
+
const CROSS_BETWEEN = ["between", "midCat"];
|
|
5942
|
+
const TIME_UNITS$1 = [
|
|
5943
|
+
"days",
|
|
5944
|
+
"months",
|
|
5945
|
+
"years"
|
|
5946
|
+
];
|
|
5947
|
+
const validateLabels = (labels, field) => {
|
|
5948
|
+
if (labels?.position !== void 0) oneOf(labels.position, LABEL_POSITIONS, `${field}.position`);
|
|
5949
|
+
};
|
|
5950
|
+
const validateScaling = (scaling, field) => {
|
|
5951
|
+
if (scaling?.displayUnits !== void 0) oneOf(scaling.displayUnits, DISPLAY_UNITS, `${field}.displayUnits`);
|
|
5952
|
+
};
|
|
5953
|
+
/** Validate before chart XML or its embedded workbook is changed. */
|
|
5954
|
+
const validateChartSpecEnums = (spec, caller) => {
|
|
5955
|
+
oneOf(spec.kind, [
|
|
5956
|
+
"bar",
|
|
5957
|
+
"column",
|
|
5958
|
+
"line",
|
|
5959
|
+
"pie",
|
|
5960
|
+
"doughnut",
|
|
5961
|
+
"area",
|
|
5962
|
+
"scatter",
|
|
5963
|
+
"radar",
|
|
5964
|
+
"bubble",
|
|
5965
|
+
"stock",
|
|
5966
|
+
"surface"
|
|
5967
|
+
], `${caller}: kind`);
|
|
5968
|
+
if (spec.grouping !== void 0) oneOf(spec.grouping, GROUPINGS, `${caller}: grouping`);
|
|
5969
|
+
if (spec.valueAxisMajorTickMark !== void 0) oneOf(spec.valueAxisMajorTickMark, TICK_MARKS, `${caller}: valueAxisMajorTickMark`);
|
|
5970
|
+
if (spec.valueAxisMinorTickMark !== void 0) oneOf(spec.valueAxisMinorTickMark, TICK_MARKS, `${caller}: valueAxisMinorTickMark`);
|
|
5971
|
+
if (spec.categoryAxisMajorTickMark !== void 0) oneOf(spec.categoryAxisMajorTickMark, TICK_MARKS, `${caller}: categoryAxisMajorTickMark`);
|
|
5972
|
+
if (spec.categoryAxisMinorTickMark !== void 0) oneOf(spec.categoryAxisMinorTickMark, TICK_MARKS, `${caller}: categoryAxisMinorTickMark`);
|
|
5973
|
+
if (spec.valueAxisTickLabelPos !== void 0) oneOf(spec.valueAxisTickLabelPos, TICK_LABEL_POSITIONS, `${caller}: valueAxisTickLabelPos`);
|
|
5974
|
+
if (spec.categoryAxisTickLabelPos !== void 0) oneOf(spec.categoryAxisTickLabelPos, TICK_LABEL_POSITIONS, `${caller}: categoryAxisTickLabelPos`);
|
|
5975
|
+
if (spec.categoryAxisLabelAlign !== void 0) oneOf(spec.categoryAxisLabelAlign, LABEL_ALIGNMENTS, `${caller}: categoryAxisLabelAlign`);
|
|
5976
|
+
if (spec.categoryAxisOrientation !== void 0) oneOf(spec.categoryAxisOrientation, ORIENTATIONS, `${caller}: categoryAxisOrientation`);
|
|
5977
|
+
if (spec.valueAxisOrientation !== void 0) oneOf(spec.valueAxisOrientation, ORIENTATIONS, `${caller}: valueAxisOrientation`);
|
|
5978
|
+
if (spec.valueAxisCrossBetween !== void 0) oneOf(spec.valueAxisCrossBetween, CROSS_BETWEEN, `${caller}: valueAxisCrossBetween`);
|
|
5979
|
+
if (spec.dispBlanksAs !== void 0) oneOf(spec.dispBlanksAs, DISPLAY_BLANKS, `${caller}: dispBlanksAs`);
|
|
5980
|
+
if (spec.scatterStyle !== void 0) oneOf(spec.scatterStyle, SCATTER_STYLES, `${caller}: scatterStyle`);
|
|
5981
|
+
if (spec.radarStyle !== void 0) oneOf(spec.radarStyle, RADAR_STYLES, `${caller}: radarStyle`);
|
|
5982
|
+
if (spec.bubbleSizeRepresents !== void 0) oneOf(spec.bubbleSizeRepresents, ["area", "width"], `${caller}: bubbleSizeRepresents`);
|
|
5983
|
+
if (spec.bar3DShape !== void 0) oneOf(spec.bar3DShape, BAR_3D_SHAPES, `${caller}: bar3DShape`);
|
|
5984
|
+
if (spec.secondaryValueAxis?.majorTickMark !== void 0) oneOf(spec.secondaryValueAxis.majorTickMark, TICK_MARKS, `${caller}: secondaryValueAxis.majorTickMark`);
|
|
5985
|
+
if (spec.secondaryValueAxis?.minorTickMark !== void 0) oneOf(spec.secondaryValueAxis.minorTickMark, TICK_MARKS, `${caller}: secondaryValueAxis.minorTickMark`);
|
|
5986
|
+
if (spec.secondaryValueAxis?.tickLabelPos !== void 0) oneOf(spec.secondaryValueAxis.tickLabelPos, TICK_LABEL_POSITIONS, `${caller}: secondaryValueAxis.tickLabelPos`);
|
|
5987
|
+
if (spec.secondaryValueAxis?.crossBetween !== void 0) oneOf(spec.secondaryValueAxis.crossBetween, CROSS_BETWEEN, `${caller}: secondaryValueAxis.crossBetween`);
|
|
5988
|
+
if (spec.seriesAxis?.orientation !== void 0) oneOf(spec.seriesAxis.orientation, ORIENTATIONS, `${caller}: seriesAxis.orientation`);
|
|
5989
|
+
if (spec.seriesAxis?.tickLabelPos !== void 0) oneOf(spec.seriesAxis.tickLabelPos, TICK_LABEL_POSITIONS, `${caller}: seriesAxis.tickLabelPos`);
|
|
5990
|
+
if (spec.categoryAxisDate?.baseTimeUnit !== void 0) oneOf(spec.categoryAxisDate.baseTimeUnit, TIME_UNITS$1, `${caller}: categoryAxisDate.baseTimeUnit`);
|
|
5991
|
+
if (spec.categoryAxisDate?.majorTimeUnit !== void 0) oneOf(spec.categoryAxisDate.majorTimeUnit, TIME_UNITS$1, `${caller}: categoryAxisDate.majorTimeUnit`);
|
|
5992
|
+
if (spec.categoryAxisDate?.minorTimeUnit !== void 0) oneOf(spec.categoryAxisDate.minorTimeUnit, TIME_UNITS$1, `${caller}: categoryAxisDate.minorTimeUnit`);
|
|
5993
|
+
if (spec.ofPie?.type !== void 0) oneOf(spec.ofPie.type, OF_PIE_TYPES, `${caller}: ofPie.type`);
|
|
5994
|
+
if (spec.ofPie?.splitType !== void 0) oneOf(spec.ofPie.splitType, SPLIT_TYPES, `${caller}: ofPie.splitType`);
|
|
5995
|
+
if (spec.plotAreaLayout?.target !== void 0) oneOf(spec.plotAreaLayout.target, LAYOUT_TARGETS, `${caller}: plotAreaLayout.target`);
|
|
5996
|
+
if (spec.legend?.layout?.target !== void 0) oneOf(spec.legend.layout.target, LAYOUT_TARGETS, `${caller}: legend.layout.target`);
|
|
5997
|
+
if (spec.valueAxisCrosses !== void 0 && typeof spec.valueAxisCrosses !== "object") oneOf(spec.valueAxisCrosses, AXIS_CROSSES, `${caller}: valueAxisCrosses`);
|
|
5998
|
+
if (spec.legend?.position != null) oneOf(spec.legend.position, LEGEND_POSITIONS, `${caller}: legend.position`);
|
|
5999
|
+
validateLabels(spec.dataLabels, `${caller}: dataLabels`);
|
|
6000
|
+
validateScaling(spec.valueAxis, `${caller}: valueAxis`);
|
|
6001
|
+
validateScaling(spec.categoryAxisScaling, `${caller}: categoryAxisScaling`);
|
|
6002
|
+
validateScaling(spec.secondaryValueAxis?.scaling, `${caller}: secondaryValueAxis.scaling`);
|
|
6003
|
+
for (const [index, series] of spec.series.entries()) {
|
|
6004
|
+
const field = `${caller}: series[${index}]`;
|
|
6005
|
+
if (series.chartKind !== void 0) oneOf(series.chartKind, [
|
|
6006
|
+
"bar",
|
|
6007
|
+
"column",
|
|
6008
|
+
"line",
|
|
6009
|
+
"area"
|
|
6010
|
+
], `${field}.chartKind`);
|
|
6011
|
+
if (series.lineDash !== void 0) oneOf(series.lineDash, LINE_DASHES, `${field}.lineDash`);
|
|
6012
|
+
if (series.markerSymbol !== void 0) oneOf(series.markerSymbol, MARKER_SYMBOLS, `${field}.markerSymbol`);
|
|
6013
|
+
if (series.trendline !== void 0) oneOf(series.trendline.type, TRENDLINE_TYPES, `${field}.trendline.type`);
|
|
6014
|
+
validateLabels(series.dataLabels, `${field}.dataLabels`);
|
|
6015
|
+
for (const [point, labels] of (series.pointDataLabels ?? []).entries()) validateLabels(labels, `${field}.pointDataLabels[${point}]`);
|
|
6016
|
+
for (const direction of ["errorBars", "xErrorBars"]) {
|
|
6017
|
+
const bars = series[direction];
|
|
6018
|
+
if (bars === void 0) continue;
|
|
6019
|
+
oneOf(bars.barType, ERROR_BAR_TYPES, `${field}.${direction}.barType`);
|
|
6020
|
+
oneOf(bars.amount.type, ERROR_VALUE_TYPES, `${field}.${direction}.amount.type`);
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
6023
|
+
};
|
|
6024
|
+
//#endregion
|
|
5384
6025
|
//#region src/internal/chartml/embedded-xlsx.ts
|
|
5385
6026
|
const TEXT_ENCODER = new TextEncoder();
|
|
5386
6027
|
const encode = (s) => TEXT_ENCODER.encode(s);
|
|
@@ -9267,6 +9908,7 @@ const withChartDefaultTextColor = (spec, color) => {
|
|
|
9267
9908
|
};
|
|
9268
9909
|
};
|
|
9269
9910
|
const addSlideChart = (slide, opts) => {
|
|
9911
|
+
validateChartSpecEnums(opts.spec, "addSlideChart");
|
|
9270
9912
|
validateChartSpecColors(opts.spec);
|
|
9271
9913
|
validateChartSpecAxes(opts.spec);
|
|
9272
9914
|
const spec = withChartDefaultTextColor(opts.spec, resolveDeckBodyTextColor(slide));
|
|
@@ -9348,6 +9990,7 @@ const resolveChartPartName = (slide, shape) => {
|
|
|
9348
9990
|
* fresh data."
|
|
9349
9991
|
*/
|
|
9350
9992
|
const setChartSpec = (chart, spec) => {
|
|
9993
|
+
validateChartSpecEnums(spec, "setChartSpec");
|
|
9351
9994
|
validateChartSpecColors(spec);
|
|
9352
9995
|
validateChartSpecAxes(spec);
|
|
9353
9996
|
const slide = chart.shape[SHAPE_SLIDE];
|
|
@@ -10855,6 +11498,7 @@ const ensureCellTxBody = (cell) => {
|
|
|
10855
11498
|
txBody = elem(NAME_A_TX_BODY_TBL);
|
|
10856
11499
|
txBody.children.push(elem(qname("a", "bodyPr", NS.dml)));
|
|
10857
11500
|
txBody.children.push(elem(qname("a", "lstStyle", NS.dml)));
|
|
11501
|
+
txBody.children.push(elem(qname("a", "p", NS.dml)));
|
|
10858
11502
|
tc.children.unshift(txBody);
|
|
10859
11503
|
}
|
|
10860
11504
|
return txBody;
|
|
@@ -10882,7 +11526,7 @@ const setTableCellText = (cell, text) => {
|
|
|
10882
11526
|
* `getTableCellParagraphs`.
|
|
10883
11527
|
*/
|
|
10884
11528
|
const setTableCellParagraphs = (cell, paragraphs) => {
|
|
10885
|
-
const built = buildTextBodyParagraphs(paragraphs);
|
|
11529
|
+
const built = buildTextBodyParagraphs(paragraphs, "setTableCellParagraphs");
|
|
10886
11530
|
replaceTextBodyParagraphs(ensureCellTxBody(cell), built);
|
|
10887
11531
|
commitTableCell(cell);
|
|
10888
11532
|
};
|
|
@@ -11086,6 +11730,9 @@ const writeBorderLn = (tcPr, local, border) => {
|
|
|
11086
11730
|
* cardinal four — a strikethrough cell can have only a diagonal.
|
|
11087
11731
|
*/
|
|
11088
11732
|
const setTableCellBorders = (cell, sides) => {
|
|
11733
|
+
if (sides !== null) {
|
|
11734
|
+
for (const [side, border] of Object.entries(sides)) if (border?.dash != null) oneOf(border.dash, LINE_DASHES, `setTableCellBorders: ${side}.dash`);
|
|
11735
|
+
}
|
|
11089
11736
|
const tcPr = ensureCellTcPr(cell);
|
|
11090
11737
|
if (sides === null) for (const local of Object.values(BORDER_SIDE_LOCALS)) writeBorderLn(tcPr, local, null);
|
|
11091
11738
|
else for (const [key, local] of Object.entries(BORDER_SIDE_LOCALS)) {
|
|
@@ -11118,6 +11765,7 @@ const getTableCellTextDirection = (cell) => {
|
|
|
11118
11765
|
* default horizontal direction. Creates `<a:tcPr>` if absent.
|
|
11119
11766
|
*/
|
|
11120
11767
|
const setTableCellTextDirection = (cell, direction) => {
|
|
11768
|
+
if (direction !== null) oneOf(direction, TEXT_DIRECTIONS, "setTableCellTextDirection: direction");
|
|
11121
11769
|
const tcPr = ensureCellTcPr(cell);
|
|
11122
11770
|
tcPr.attrs = tcPr.attrs.filter((a) => !(a.name.namespaceURI === "" && a.name.localName === "vert"));
|
|
11123
11771
|
if (direction !== null && direction !== "horz") tcPr.attrs.push(attr(qname("", "vert", ""), direction));
|
|
@@ -11143,10 +11791,15 @@ const getTableCellAnchor = (cell) => {
|
|
|
11143
11791
|
* default (`ctr`). Creates `<a:tcPr>` if absent.
|
|
11144
11792
|
*/
|
|
11145
11793
|
const setTableCellAnchor = (cell, anchor) => {
|
|
11794
|
+
if (anchor !== null) oneOf(anchor, [
|
|
11795
|
+
"top",
|
|
11796
|
+
"center",
|
|
11797
|
+
"bottom"
|
|
11798
|
+
], "setTableCellAnchor: anchor");
|
|
11146
11799
|
const tcPr = ensureCellTcPr(cell);
|
|
11147
11800
|
tcPr.attrs = tcPr.attrs.filter((a) => !(a.name.namespaceURI === "" && a.name.localName === "anchor"));
|
|
11148
11801
|
if (anchor !== null) {
|
|
11149
|
-
const mapped = anchor
|
|
11802
|
+
const mapped = TEXT_ANCHORS[anchor];
|
|
11150
11803
|
tcPr.attrs.push(attr(qname("", "anchor", ""), mapped));
|
|
11151
11804
|
}
|
|
11152
11805
|
commitTableCell(cell);
|
|
@@ -11294,12 +11947,14 @@ const getTableCellFill = (cell) => {
|
|
|
11294
11947
|
};
|
|
11295
11948
|
/** Applies a TextFormat to every run in the cell's text. */
|
|
11296
11949
|
const setTableCellTextFormat = (cell, format) => {
|
|
11297
|
-
|
|
11950
|
+
validateFormatEnums(format, "setTableCellTextFormat");
|
|
11951
|
+
applyValidatedFormatToAllRuns(ensureCellTxBody(cell), format);
|
|
11298
11952
|
commitTableCell(cell);
|
|
11299
11953
|
};
|
|
11300
11954
|
/** Sets horizontal alignment on every paragraph in the cell. */
|
|
11301
11955
|
const setTableCellAlignment = (cell, align) => {
|
|
11302
|
-
|
|
11956
|
+
const token = alignToken(align, "setTableCellAlignment");
|
|
11957
|
+
applyAlignmentTokenToAllParagraphs(ensureCellTxBody(cell), token);
|
|
11303
11958
|
commitTableCell(cell);
|
|
11304
11959
|
};
|
|
11305
11960
|
/** Zero-based (row, col) of the cell. */
|
|
@@ -11308,10 +11963,12 @@ const getTableCellPosition = (cell) => ({
|
|
|
11308
11963
|
col: cell[CELL_COL]
|
|
11309
11964
|
});
|
|
11310
11965
|
/**
|
|
11311
|
-
* Reads the horizontal alignment from the cell's first paragraph
|
|
11312
|
-
* (`l`, `ctr`, `r`, `just`, `dist`, `justLow`, `thaiDist`)
|
|
11313
|
-
* `
|
|
11314
|
-
* has no
|
|
11966
|
+
* Reads the horizontal alignment from the cell's first paragraph as its
|
|
11967
|
+
* spec token (`l`, `ctr`, `r`, `just`, `dist`, `justLow`, `thaiDist`) — so
|
|
11968
|
+
* `setTableCellAlignment(cell, 'center')` reads back as `'ctr'`. Returns
|
|
11969
|
+
* `null` when the cell has no `<a:txBody>`, or its first paragraph has no
|
|
11970
|
+
* valid `algn` attribute (PowerPoint then defaults to `l`). For a
|
|
11971
|
+
* plain-English name per paragraph, use `getTableCellParagraphs`.
|
|
11315
11972
|
*/
|
|
11316
11973
|
const getTableCellAlignment = (cell) => {
|
|
11317
11974
|
const txBody = firstChildElement(cell[CELL_ELEMENT], NAME_A_TX_BODY_TBL);
|
|
@@ -11320,7 +11977,7 @@ const getTableCellAlignment = (cell) => {
|
|
|
11320
11977
|
if (p.kind !== "element" || p.name.namespaceURI !== NS.dml || p.name.localName !== "p") continue;
|
|
11321
11978
|
const pPr = firstChildElement(p, qname("a", "pPr", NS.dml));
|
|
11322
11979
|
if (!pPr) return null;
|
|
11323
|
-
return getAttrValue(pPr, qname("", "algn", ""))
|
|
11980
|
+
return parseAlignmentToken(getAttrValue(pPr, qname("", "algn", "")));
|
|
11324
11981
|
}
|
|
11325
11982
|
return null;
|
|
11326
11983
|
};
|
|
@@ -12014,8 +12671,9 @@ const getSlideTransition = (slide) => {
|
|
|
12014
12671
|
};
|
|
12015
12672
|
/** Sets the slide's transition effect. */
|
|
12016
12673
|
const setSlideTransition = (slide, options) => {
|
|
12674
|
+
const transition = buildTransition(options);
|
|
12017
12675
|
removeTransition(slide);
|
|
12018
|
-
insertAfterClrMapOvr(slide,
|
|
12676
|
+
insertAfterClrMapOvr(slide, transition);
|
|
12019
12677
|
commitSlideData(slide);
|
|
12020
12678
|
refreshSlideData(slide);
|
|
12021
12679
|
};
|
|
@@ -12588,6 +13246,7 @@ const NAME_SLD_ID_LST_FN = qname("p", "sldIdLst", NS.pml);
|
|
|
12588
13246
|
* §19.2.1.26; we insert at the correct position when bootstrapping.
|
|
12589
13247
|
*/
|
|
12590
13248
|
const setSlideSize = (pres, opts) => {
|
|
13249
|
+
if (opts.type !== void 0) oneOf(opts.type, SLIDE_SIZE_TYPES, "setSlideSize: type");
|
|
12591
13250
|
const presPart = pres[INTERNAL_PACKAGE].getPart(PRES_PART_NAME);
|
|
12592
13251
|
if (!presPart) throw new Error("presentation.xml is missing");
|
|
12593
13252
|
const doc = parseXml(decode$1(presPart.data));
|
|
@@ -13740,35 +14399,23 @@ const ensurePPr = (paragraph) => {
|
|
|
13740
14399
|
paragraph.children.unshift(fresh);
|
|
13741
14400
|
return fresh;
|
|
13742
14401
|
};
|
|
13743
|
-
const alignTokenForFn = (a) => {
|
|
13744
|
-
switch (a) {
|
|
13745
|
-
case "left":
|
|
13746
|
-
case "l": return "l";
|
|
13747
|
-
case "center":
|
|
13748
|
-
case "ctr": return "ctr";
|
|
13749
|
-
case "right":
|
|
13750
|
-
case "r": return "r";
|
|
13751
|
-
case "justify":
|
|
13752
|
-
case "just": return "just";
|
|
13753
|
-
case "distribute":
|
|
13754
|
-
case "dist": return "dist";
|
|
13755
|
-
default: return a;
|
|
13756
|
-
}
|
|
13757
|
-
};
|
|
13758
14402
|
/**
|
|
13759
14403
|
* Sets the horizontal alignment of a single paragraph. Same token set
|
|
13760
14404
|
* as `setShapeAlignment`. Other paragraphs are untouched.
|
|
13761
14405
|
*/
|
|
13762
14406
|
const setParagraphAlignment = (shape, paragraphIndex, align) => {
|
|
14407
|
+
const token = alignToken(align, "setParagraphAlignment");
|
|
13763
14408
|
const pPr = ensurePPr(requireParagraph(shape, paragraphIndex));
|
|
13764
14409
|
pPr.attrs = pPr.attrs.filter((a) => a.name.localName !== "algn");
|
|
13765
|
-
pPr.attrs.push(attr(ATTR_ALGN_FN,
|
|
14410
|
+
pPr.attrs.push(attr(ATTR_ALGN_FN, token));
|
|
13766
14411
|
commitAndRefresh(shape);
|
|
13767
14412
|
};
|
|
13768
14413
|
/**
|
|
13769
14414
|
* Sets the paragraph's nesting level (`<a:pPr lvl="N"/>`). Levels are
|
|
13770
14415
|
* 0-indexed; PowerPoint accepts 0 through 8. Pass `0` to clear an
|
|
13771
14416
|
* existing level — `<a:pPr lvl="0"/>` is the same as omitting the attr.
|
|
14417
|
+
* Indents matching the previous level's default bullet pair follow the level;
|
|
14418
|
+
* other indent values are preserved.
|
|
13772
14419
|
*
|
|
13773
14420
|
* Used in tandem with bullets to author nested lists:
|
|
13774
14421
|
*
|
|
@@ -13779,18 +14426,24 @@ const setParagraphAlignment = (shape, paragraphIndex, align) => {
|
|
|
13779
14426
|
const setParagraphLevel = (shape, paragraphIndex, level) => {
|
|
13780
14427
|
if (!Number.isInteger(level) || level < 0 || level > 8) throw new RangeError(`paragraph level must be an integer in [0, 8], got ${level}`);
|
|
13781
14428
|
const pPr = ensurePPr(requireParagraph(shape, paragraphIndex));
|
|
14429
|
+
const previousLevel = Number.parseInt(getAttrValue(pPr, ATTR_LVL) ?? "0", 10);
|
|
13782
14430
|
pPr.attrs = pPr.attrs.filter((a) => a.name.localName !== "lvl");
|
|
13783
14431
|
if (level > 0) pPr.attrs.push(attr(ATTR_LVL, String(level)));
|
|
14432
|
+
updateBulletIndentForLevel(pPr, Number.isFinite(previousLevel) ? previousLevel : 0, level);
|
|
13784
14433
|
commitAndRefresh(shape);
|
|
13785
14434
|
};
|
|
13786
14435
|
/**
|
|
13787
|
-
* Reads the paragraph's
|
|
13788
|
-
* `
|
|
14436
|
+
* Reads the paragraph's own `algn` as its spec token (`l`, `ctr`, `r`,
|
|
14437
|
+
* `just`, `dist`, `justLow`, `thaiDist`) — so `setParagraphAlignment(…,
|
|
14438
|
+
* 'center')` reads back as `'ctr'`. Returns `null` when the attribute is
|
|
14439
|
+
* absent (the paragraph inherits from its layout / master) or is not a
|
|
14440
|
+
* valid token. For the inherited value under a plain-English name, use
|
|
14441
|
+
* `getParagraphPropertiesEffective`.
|
|
13789
14442
|
*/
|
|
13790
14443
|
const getParagraphAlignment = (shape, paragraphIndex) => {
|
|
13791
14444
|
const pPr = firstChildElement(requireParagraph(shape, paragraphIndex), NAME_A_PPR);
|
|
13792
14445
|
if (pPr === null) return null;
|
|
13793
|
-
return getAttrValue(pPr, ATTR_ALGN_FN)
|
|
14446
|
+
return parseAlignmentToken(getAttrValue(pPr, ATTR_ALGN_FN));
|
|
13794
14447
|
};
|
|
13795
14448
|
/**
|
|
13796
14449
|
* Reads the paragraph's nesting level (`lvl` attribute), or `0` when
|
|
@@ -16459,8 +17112,7 @@ const setShapeText = (shape, value, options = {}) => {
|
|
|
16459
17112
|
if (shape[SHAPE_SNAPSHOT].kind !== "shape") throw new Error(`setShapeText only works on text-bearing shapes; ${shape[SHAPE_SNAPSHOT].kind} is not one`);
|
|
16460
17113
|
const txBody = firstChildElement(shape[SHAPE_ELEMENT], NAME_TX_BODY);
|
|
16461
17114
|
if (txBody === null) throw new Error(`shape "${shape[SHAPE_SNAPSHOT].name}" has no <p:txBody>`);
|
|
16462
|
-
setTextBody(txBody, value);
|
|
16463
|
-
if (options.bullets !== void 0) applyBulletToAllParagraphs(txBody, options.bullets);
|
|
17115
|
+
setTextBody(txBody, value, options.bullets);
|
|
16464
17116
|
commitAndRefresh(shape);
|
|
16465
17117
|
};
|
|
16466
17118
|
/**
|
|
@@ -16503,6 +17155,7 @@ const requireBodyPr = (shape) => {
|
|
|
16503
17155
|
* Throws for non-text-bearing shape kinds.
|
|
16504
17156
|
*/
|
|
16505
17157
|
const setShapeTextWrap = (shape, wrap) => {
|
|
17158
|
+
oneOf(wrap, ["none", "square"], "setShapeTextWrap: wrap");
|
|
16506
17159
|
const bodyPr = requireBodyPr(shape);
|
|
16507
17160
|
const ATTR_WRAP = qname("", "wrap", "");
|
|
16508
17161
|
bodyPr.attrs = bodyPr.attrs.filter((a) => !(a.name.namespaceURI === "" && a.name.localName === "wrap"));
|
|
@@ -16530,9 +17183,18 @@ const getShapeTextWrap = (shape) => {
|
|
|
16530
17183
|
* non-text-bearing shape kinds.
|
|
16531
17184
|
*/
|
|
16532
17185
|
const setShapeTextAutoFit = (shape, mode) => {
|
|
17186
|
+
oneOf(mode, [
|
|
17187
|
+
"none",
|
|
17188
|
+
"normal",
|
|
17189
|
+
"shape"
|
|
17190
|
+
], "setShapeTextAutoFit: mode");
|
|
16533
17191
|
const bodyPr = requireBodyPr(shape);
|
|
16534
17192
|
bodyPr.children = bodyPr.children.filter((c) => !(c.kind === "element" && c.name.namespaceURI === NS.dml && AUTO_FIT_LOCALS.has(c.name.localName)));
|
|
16535
|
-
const local =
|
|
17193
|
+
const local = {
|
|
17194
|
+
none: "noAutofit",
|
|
17195
|
+
normal: "normAutofit",
|
|
17196
|
+
shape: "spAutoFit"
|
|
17197
|
+
}[mode];
|
|
16536
17198
|
bodyPr.children.push(elem(qname("a", local, NS.dml)));
|
|
16537
17199
|
commitAndRefresh(shape);
|
|
16538
17200
|
};
|
|
@@ -16725,6 +17387,7 @@ const getShapeTextDirection = (shape) => {
|
|
|
16725
17387
|
* horizontal direction. Throws for non-text-bearing shape kinds.
|
|
16726
17388
|
*/
|
|
16727
17389
|
const setShapeTextDirection = (shape, direction) => {
|
|
17390
|
+
if (direction !== null) oneOf(direction, TEXT_DIRECTIONS, "setShapeTextDirection: direction");
|
|
16728
17391
|
const bodyPr = requireBodyPr(shape);
|
|
16729
17392
|
bodyPr.attrs = bodyPr.attrs.filter((a) => !(a.name.namespaceURI === "" && a.name.localName === "vert"));
|
|
16730
17393
|
if (direction !== null && direction !== "horz") bodyPr.attrs.push(attr(qname("", "vert", ""), direction));
|
|
@@ -16841,13 +17504,18 @@ const getShapeBodyPrEffective = (pres, shape) => {
|
|
|
16841
17504
|
return result;
|
|
16842
17505
|
};
|
|
16843
17506
|
const setShapeTextAnchor = (shape, anchor) => {
|
|
17507
|
+
oneOf(anchor, [
|
|
17508
|
+
"top",
|
|
17509
|
+
"center",
|
|
17510
|
+
"bottom"
|
|
17511
|
+
], "setShapeTextAnchor: anchor");
|
|
16844
17512
|
const txBody = requireTxBody(shape);
|
|
16845
17513
|
let bodyPr = firstChildElement(txBody, NAME_A_BODY_PR);
|
|
16846
17514
|
if (bodyPr === null) {
|
|
16847
17515
|
bodyPr = elem(NAME_A_BODY_PR);
|
|
16848
17516
|
txBody.children.unshift(bodyPr);
|
|
16849
17517
|
}
|
|
16850
|
-
const token = anchor
|
|
17518
|
+
const token = TEXT_ANCHORS[anchor];
|
|
16851
17519
|
const ATTR_ANCHOR = qname("", "anchor", "");
|
|
16852
17520
|
bodyPr.attrs = bodyPr.attrs.filter((a) => !(a.name.namespaceURI === "" && a.name.localName === "anchor"));
|
|
16853
17521
|
bodyPr.attrs.push(attr(ATTR_ANCHOR, token));
|
|
@@ -16911,7 +17579,7 @@ const setShapeAlignment = (shape, align) => {
|
|
|
16911
17579
|
* updates compose.
|
|
16912
17580
|
*/
|
|
16913
17581
|
const setShapeTextFormat = (shape, format) => {
|
|
16914
|
-
applyFormatToAllRuns(requireTxBody(shape), format);
|
|
17582
|
+
applyFormatToAllRuns(requireTxBody(shape), format, "setShapeTextFormat");
|
|
16915
17583
|
commitAndRefresh(shape);
|
|
16916
17584
|
};
|
|
16917
17585
|
/**
|
|
@@ -18824,8 +19492,8 @@ const getShapeMedia = (shape) => {
|
|
|
18824
19492
|
const findShapesWithMedia = (slide) => slide[SLIDE_SHAPES].filter((shape) => getShapeMedia(shape) !== null);
|
|
18825
19493
|
//#endregion
|
|
18826
19494
|
//#region src/api/index.ts
|
|
18827
|
-
const VERSION = "0.
|
|
19495
|
+
const VERSION = "0.18.1";
|
|
18828
19496
|
//#endregion
|
|
18829
19497
|
export { replaceTokensInPresentation as $, getTableCellAnchor as $a, appendSlideNotes as $i, getShapePreset as $n, getSlideLayoutType as $o, getShapeParagraphCount as $r, findCommentsByAuthor as $s, getShapeStroke as $t, getOutlineText as A, removeSlideNotes as Aa, getShapeImageBiLevelThreshold as Ai, setSlideLayout as An, setTableCellTextFormat as Ao, setShapePatternFill as Ar, getSlideColorMapOverride as As, setShapeText as At, getSlideLayoutCount as B, getPackageSize as Ba, getShapeImagePartName as Bi, getShapeAltTitle as Bn, getPresentationCreated as Bo, getShapeRunFormat as Br, getSlideMasterBackgroundPatternFill as Bs, findShapesByEffect as Bt, setSlideSections as C, getSlidesWithHyperlinks as Ca, emu as Cc, findFlippedShapes as Ci, getShapeSlide as Cn, setTableCellAnchor as Co, setShapeAdjustValues as Cr, getEffectiveColorMap as Cs, getShapeTextColumns as Ct, findSlidesByNotes as D, getSlidesWithTables as Da, findSlidesByLayoutPartName as Di, getSlideShapes as Dn, setTableCellParagraphs as Do, setShapeImageFill as Dr, getSlideBackgroundGradientFill as Ds, setShapeAlignment as Dt, findSlideByTitle as E, getSlidesWithOverlap as Ea, pt as Ec, findSlidesByLayoutName as Ei, getSlideLayout as En, setTableCellMargins as Eo, setShapeGradientFill as Er, getSlideBackground as Es, getShapeTextWrap as Et, getShapeAt as F, setSlideTransition as Fa, getShapeImageDuotone as Fi, getGroupChildren as Fn, getThumbnail as Fo, setShapeStrokeArrow as Fr, getSlideLayoutBackgroundShapes as Fs, setShapeTextDirection as Ft, getSlideXmlString as G, setMediaPartBytes as Ga, setShapeImageContrast as Gi, getShapeDescription as Gn, touchModified as Go, getParagraphBulletImageBytes as Gr, setShapeClickAction as Gs, setShapeShadow as Gt, getSlidePartName as H, getSlideMediaPartNames as Ha, hasShapeText as Hi, getShapeBoundsResolved as Hn, incrementRevision as Ho, resolveDrawingColorOpacity as Hr, setSlideBackground as Hs, getShapeEffects as Ht, getSlideAt as I, _internalPackageOf as Ia, getShapeImageFillBytes as Ii, getGroupTransform as In, removeThumbnail as Io, setShapeStrokeCap as Ir, getSlideLayoutShapes as Is, setShapeTextFormat as It, isSlideHidden as J, clearTableCellFill as Ja, SLIDE_SIZE_16_10 as Ji, getShapeKind as Jn, findSlideLayoutByPartName as Jo, getParagraphIndent as Jr, clearAllSlideComments as Js, getShapeFill as Jt, getSlides as K, slidesUsingMediaPart as Ka, setShapeImageCrop as Ki, getShapeFlip as Kn, findLayoutsWithPlaceholderType as Ko, getParagraphBulletStyle as Kr, setShapeImage as Ks, getShapeGradientFill as Kt, getSlideCount as L, compactPackage as La, getShapeImageFormat as Li, getMaxShapeId as Ln, setThumbnail as Lo, setShapeStrokeCompound as Lr, getSlideMasterBackground as Ls, setShapeTextMargins as Lt, getPresentationText as M, setSlideNotes as Ma, getShapeImageBytes as Mi, centerShapeOnSlide as Mn, setTableRowHeight as Mo, setShapeRotation as Mr, getSlideLayoutBackgroundGradientFill as Ms, setShapeTextAutoFit as Mt, getPresentationTextLength as N, clearSlideTransition as Na, getShapeImageContrast as Ni, findShapesAtPoint as Nn, setTableStyleFlags as No, setShapeSize as Nr, getSlideLayoutBackgroundImageBytes as Ns, setShapeTextBodyRotationDeg as Nt, findSlidesByText as O, getVisibleSlides as Oa, findSlidesByLayoutType as Oi, getSlidesWithEmptyPlaceholders as On, setTableCellText as Oo, setShapeNoFill as Or, getSlideBackgroundImageBytes as Os, setShapeBullets as Ot, getPresentationTextLengthsBySlide as P, getSlideTransition as Pa, getShapeImageCrop as Pi, findShapesInRect as Pn, setTableStyleId as Po, setShapeStroke as Pr, getSlideLayoutBackgroundPatternFill as Ps, setShapeTextColumns as Pt, replaceTextInSlideNotes as Q, getTableCellAlignment as Qa, setSlideSize as Qi, getShapePosition as Qn, getSlideLayoutPlaceholders as Qo, getShapeHyperlinkTooltip as Qr, findCommentsBefore as Qs, getShapeFillOpacity as Qt, getSlideIndex as R, getMediaParts as Ra, getShapeImageLinkUrl as Ri, getMaxShapeIdInPresentation as Rn, getCoreProperties as Ro, setShapeStrokeDash as Rr, getSlideMasterBackgroundGradientFill as Rs, setShapeTextWrap as Rt, getSlideSections as S, getSlidesWithComments as Sa, cm as Sc, setShapeAnimation as Si, getShapeIndex as Sn, setTableCellAlignment as So, getShapeStrokeDash as Sr, setChartSpec as Ss, getShapeTextBodyRotationDeg as St, findSlideByText as T, getSlidesWithNotes as Ta, mm as Tc, findShapesOutsideCanvas as Ti, getShapesBounds as Tn, setTableCellFill as To, setShapeFlip as Tr, clearSlideBackground as Ts, getShapeTextMargins as Tt, getSlideText as U, listPackageParts as Ua, isShapeImageGrayscale as Ui, getShapeCenter as Un, setCoreProperties as Uo, getParagraphAlignment as Ur, setSlideBackgroundImage as Us, getShapeEffectsEffective as Ut, getSlideOutline as V, getPresentationSummary as Va, hasShapeImage as Vi, getShapeBounds as Vn, getPresentationModified as Vo, resolveDrawingColor as Vr, getSlideMasterShapes as Vs, getShapeEffect as Vt, getSlideTextLength as W, readPackagePart as Wa, setShapeImageBrightness as Wi, getShapeCustomGeometry as Wn, setExtendedProperties as Wo, getParagraphBullet as Wr, getShapeClickAction as Ws, setShapeGlow as Wt, replaceTextInPresentation as X, getSlideTables as Xa, SLIDE_SIZE_4_3 as Xi, getShapePlaceholderIdx as Xn, getSlideLayoutName as Xo, getParagraphLineSpacing as Xr, findCommentAuthorByName as Xs, getShapeFillColorResolved as Xt, replaceTextInNotes as Y, getPresentationTableCountsBySlide as Ya, SLIDE_SIZE_16_9 as Yi, getShapeName as Yn, findSlideLayoutByType as Yo, getParagraphLevel as Yr, clearSlideComments as Ys, getShapeFillColor as Yt, replaceTextInSlide as Z, getTableCell as Za, getSlideSize as Zi, getShapePlaceholderType as Zn, getSlideLayoutPartName as Zo, getParagraphSpacing as Zr, findCommentsAfter as Zs, getShapeFillEffective as Zt, moveSlide as _, getPresentationNotesLengthsBySlide as _a, setPresentationFonts as _c, setSlidePlaceholders as _i, findShapesByText as _n, isChartShape as _o, shapesOverlap as _r, getShapeChartKind as _s, appendShapeText as _t, groupShapes as a, findSlidesWithChartTrendlines as aa, getCommentPosition as ac, getShapeRunText as ai, getShapeStrokeJoin as an, getTableCellSpan as ao, getSlideMasterPartNames as ar, getShapeHyperlink as as, addSlideShape as at, sortSlides as b, getSlideNotesLength as ba, loadPresentation as bc, findShapesWithAnimation as bi, findSlidePlaceholderByIdx as bn, removeTableColumn as bo, getShapePatternFill as br, getShapeChartSpec as bs, getShapeTextAutoFit as bt, addContentSlide as c, getAllHyperlinks as ca, getCommentsSortedByDate as cc, setParagraphBullet as ci, findEmptyPlaceholders as cn, getTableCells as co, isShapeHidden as cr, setShapeRunFormat as cs, bringShapeForward as ct, addSlideAt as d, getAllTables as da, getPresentationCommenters as dc, setParagraphSpacing as di, findShapeByText as dn, getTableRowHeights as do, pointInShape as dr, findChartsBySeriesName as ds, copyShape as dt, clearAllHyperlinks as ea, findCommentsByText as ec, getShapeParagraphElements as ei, getShapeStrokeCap as en, getTableCellBorders as eo, getShapeRotation as er, getSlideLayoutUsageCounts as es, searchSlides as et, addTitleSlide as f, getDistinctHyperlinkUrls as fa, getSlideCommentAuthors as fc, setShapeRunHyperlink as fi, findShapeInPresentation as fn, getTableSize as fo, renameShape as fr, findChartsWithDataLabels as fs, getShapeZIndex as ft, mergePresentations as g, getPresentationNotesLength as ga, getPresentationTheme as gc, setSlideBody as gi, findShapesByPreset as gn, insertTableRow as go, setShapeHidden as gr, getShapeChartCategories as gs, setShapeZIndex as gt, importSlide as h, getPresentationHyperlinkCountsBySlide as ha, getPresentationFonts as hc, getSlideTitle as hi, findShapesByName as hn, insertTableColumn as ho, setShapeDescription as hr, getPresentationChartKindCounts as hs, sendShapeToBack as ht, getShapeMedia as i, findSlidesWithChartKind as ia, getCommentDate as ic, getShapeRunHyperlinkTooltip as ii, getShapeStrokeEffective as in, getTableCellPosition as io, getSlideMasterPartName as ir, getParagraphPropertiesEffective as is, addSlideLine as it, getPresentationShapeCountsBySlide as j, replaceHyperlink as ja, getShapeImageBrightness as ji, translateShapes as jn, setTableColumnWidth as jo, setShapePosition as jr, getSlideLayoutBackground as js, setShapeTextAnchor as jt, getAllShapes as k, hasSlideNotes as ka, getPresentationImageCountsBySlide as ki, replaceTokensInSlide as kn, setTableCellTextDirection as ko, setShapeNoStroke as kr, getSlideBackgroundPatternFill as ks, setShapeParagraphs as kt, addSectionHeaderSlide as l, getAllImages as la, getPresentationCommentCountsByAuthor as lc, setParagraphLevel as li, findShapeById as ln, getTableColumnWidths as lo, isShapePlaceholder as lr, addSlideChart as ls, bringShapeToFront as lt, duplicateSlideAt as m, getHiddenSlides as ma, removeSlideComment as mc, getSlideBody as mi, findShapesByKind as mn, getTableStyleId as mo, setShapeBounds as mr, getPresentationChartCountsBySlide as ms, sendShapeBackward as mt, addSlideMedia as n, clearSlideHyperlinks as na, getCommentAuthor as nc, getShapeRunCount as ni, getShapeStrokeColorResolved as nn, getTableCellMargins as no, getShapeText as nr, getSlideLayouts as ns, slideHasAnimations as nt, ungroupShapes as o, getAllCharts as oa, getCommentSlide as oc, isParagraphBulletPicture as oi, getShapeStrokeOpacity as on, getTableCellText as oo, getSlideMasterUsageCounts as or, getShapeRunFormatEffective as os, addSlideTable as ot, duplicateSlide as p, getEmptySlides as pa, getSlideComments as pc, setShapeRunText as pi, findShapesByHyperlink as pn, getTableStyleFlags as po, setShapeAltTitle as pr, findChartsWithTrendlines as ps, removeShape as pt, getSlidesByLayout as q, validatePresentation as qa, setShapeImageOpacity as qi, getShapeId as qn, findSlideLayout as qo, getParagraphEndFormat as qr, addSlideComment as qs, getShapeGradientFillEffective as qt, findShapesWithMedia as r, findSlidesByHyperlink as ra, getCommentAuthors as rc, getShapeRunHyperlink as ri, getShapeStrokeCompound as rn, getTableCellParagraphs as ro, getSlideMasterCount as rr, getUnusedSlideLayouts as rs, addSlideImage as rt, addBlankSlide as s, getAllComments as sa, getCommentText as sc, setParagraphAlignment as si, getShapeStrokeWidth as sn, getTableCellTextDirection as so, getUnusedSlideMasters as sr, setShapeHyperlink as ss, addSlideTextBox as st, VERSION as t, clearAllSlideNotes as ta, findSlidesWithCommentsByAuthor as tc, getShapeRunClickAction as ti, getShapeStrokeColor as tn, getTableCellFill as to, getShapeSize as tr, getSlideLayoutUsageCountsByType as ts, setSlideHidden as tt, addSlide as u, getAllNotes as ua, getPresentationCommentCountsBySlide as uc, setParagraphLineSpacing as ui, findShapeByName as un, getTableDimensions as uo, isShapeTextBox as ur, findChartByKind as us, clearSlideShapes as ut, removeSlide as v, getPresentationNotesText as va, setPresentationTheme as vc, setSlideTitle as vi, findShapesWithHyperlinks as vn, isTableShape as vo, clearShapeFill as vr, getShapeChartSeriesNames as vs, getShapeBodyPrEffective as vt, findSlideByPartName as w, getSlidesWithImages as wa, inches as wc, findOverlappingShapePairs as wi, getShapeXmlString as wn, setTableCellBorders as wo, setShapeFill as wr, resolveDeckBodyTextColor as ws, getShapeTextDirection as wt, swapSlides as x, getSlidesWithCharts as xa, savePresentation as xc, getShapeAnimation as xi, findSlidePlaceholders as xn, removeTableRow as xo, getShapeStrokeArrow as xr, getSlideCharts as xs, getShapeTextAutoFitParams as xt, reverseSlides as y, getSlideNotes as ya, createPresentation as yc, clearSlideAnimations as yi, findSlidePlaceholder as yn, mergeTableCells as yo, clearShapeStroke as yr, getShapeChartSeriesValues as ys, getShapeTextAnchor as yt, getSlideInfo as z, getOrphanMediaPartNames as za, getShapeImageOpacity as zi, getShapeAdjustValues as zn, getExtendedProperties as zo, setShapeStrokeJoin as zr, getSlideMasterBackgroundImageBytes as zs, clearShapeEffects as zt };
|
|
18830
19498
|
|
|
18831
|
-
//# sourceMappingURL=api-
|
|
19499
|
+
//# sourceMappingURL=api-DlzYhUxG.js.map
|