reamkit 1.21.0 → 1.23.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/esm/core/bytes.d.ts +22 -4
- package/dist/esm/core/bytes.js +73 -5
- package/dist/esm/core/converter/ream.d.ts +16 -0
- package/dist/esm/core/converter/ream.js +59 -9
- package/dist/esm/core/document-model/types.d.ts +78 -0
- package/dist/esm/core/drawingml/chart-geometry.js +11 -5
- package/dist/esm/core/drawingml/chart-parser.d.ts +2 -1
- package/dist/esm/core/drawingml/chart-parser.js +23 -1
- package/dist/esm/core/drawingml/colors.d.ts +30 -4
- package/dist/esm/core/drawingml/colors.js +45 -6
- package/dist/esm/core/drawingml/preset-geometry.js +236 -0
- package/dist/esm/core/drawingml/theme-parser.d.ts +38 -0
- package/dist/esm/core/drawingml/theme-parser.js +64 -1
- package/dist/esm/core/fonts/families.d.ts +10 -0
- package/dist/esm/core/fonts/families.js +44 -0
- package/dist/esm/core/fonts/index.d.ts +3 -2
- package/dist/esm/core/fonts/remote-fonts.d.ts +50 -0
- package/dist/esm/core/fonts/remote-fonts.js +114 -8
- package/dist/esm/core/fonts/scripts.d.ts +26 -0
- package/dist/esm/core/fonts/scripts.js +177 -0
- package/dist/esm/core/metafile/blit.d.ts +33 -0
- package/dist/esm/core/metafile/blit.js +67 -0
- package/dist/esm/core/metafile/dib.d.ts +61 -0
- package/dist/esm/core/metafile/dib.js +205 -0
- package/dist/esm/core/metafile/emf.js +139 -24
- package/dist/esm/core/metafile/picture.d.ts +12 -1
- package/dist/esm/core/metafile/symbol-fonts.d.ts +42 -0
- package/dist/esm/core/metafile/symbol-fonts.js +154 -0
- package/dist/esm/core/metafile/wmf.js +183 -10
- package/dist/esm/core/ole/escher-blip.d.ts +12 -0
- package/dist/esm/core/ole/escher-blip.js +88 -0
- package/dist/esm/{pdf-reader → core}/png-encode.js +1 -1
- package/dist/esm/core/vector.d.ts +5 -0
- package/dist/esm/excel/print-model.js +3 -1
- package/dist/esm/excel/sheet-shape-parser.js +1 -12
- package/dist/esm/excel/styles-parser.js +1 -1
- package/dist/esm/excel/xls/biff-reader.js +53 -18
- package/dist/esm/excel/xls/biff-styles.d.ts +5 -2
- package/dist/esm/excel/xls/biff-styles.js +9 -7
- package/dist/esm/excel/xls/escher.js +90 -24
- package/dist/esm/excel/xlsx-reader.d.ts +1 -1
- package/dist/esm/excel/xlsx-reader.js +3 -3
- package/dist/esm/layout/page-doc.d.ts +77 -0
- package/dist/esm/layout/page-doc.js +34 -18
- package/dist/esm/layout/styled-layout.d.ts +2 -2
- package/dist/esm/layout/styled-layout.js +467 -76
- package/dist/esm/pdf/shading.d.ts +19 -0
- package/dist/esm/pdf/shading.js +84 -11
- package/dist/esm/pdf/styled-page-emitter.js +647 -444
- package/dist/esm/pdf-reader/image-decode.js +1 -1
- package/dist/esm/pptx/embedded-fonts.d.ts +31 -0
- package/dist/esm/pptx/embedded-fonts.js +104 -0
- package/dist/esm/pptx/ole-preview.d.ts +10 -0
- package/dist/esm/pptx/ole-preview.js +52 -0
- package/dist/esm/pptx/placeholder-cascade.d.ts +136 -5
- package/dist/esm/pptx/placeholder-cascade.js +260 -27
- package/dist/esm/pptx/ppt/ppt-reader.js +120 -10
- package/dist/esm/pptx/ppt/ppt-text.d.ts +66 -1
- package/dist/esm/pptx/ppt/ppt-text.js +576 -137
- package/dist/esm/pptx/pptx-reader.d.ts +8 -0
- package/dist/esm/pptx/pptx-reader.js +271 -41
- package/dist/esm/pptx/preset-table-styles.d.ts +9 -0
- package/dist/esm/pptx/preset-table-styles.js +27 -0
- package/dist/esm/pptx/slide-parser.d.ts +78 -10
- package/dist/esm/pptx/slide-parser.js +396 -95
- package/dist/esm/pptx/sp-helpers.d.ts +2 -1
- package/dist/esm/pptx/sp-helpers.js +22 -6
- package/dist/esm/pptx/table-style.d.ts +64 -0
- package/dist/esm/pptx/table-style.js +203 -0
- package/dist/esm/svg/svg-writer.js +53 -5
- package/dist/esm/word/document-parser.d.ts +7 -1
- package/dist/esm/word/document-parser.js +6 -6
- package/dist/esm/word/docx-reader.js +8 -5
- package/dist/esm/word/docx-to-pdf.d.ts +8 -7
- package/dist/esm/word/docx-to-pdf.js +25 -7
- package/dist/esm/word/drawing-parser.d.ts +34 -0
- package/dist/esm/word/drawing-parser.js +173 -15
- package/dist/esm/word/numbering-parser.d.ts +2 -1
- package/dist/esm/word/numbering-parser.js +6 -6
- package/dist/esm/word/paragraph-properties.d.ts +2 -1
- package/dist/esm/word/paragraph-properties.js +2 -2
- package/dist/esm/word/run-properties.d.ts +5 -2
- package/dist/esm/word/run-properties.js +13 -8
- package/dist/esm/word/styles-parser.d.ts +2 -1
- package/dist/esm/word/styles-parser.js +12 -12
- package/dist/esm/word/table-parser.js +3 -3
- package/dist/esm/word/theme-fonts.d.ts +10 -0
- package/dist/esm/word/theme-fonts.js +28 -0
- package/package.json +1 -1
- /package/dist/esm/{pdf-reader → core}/png-encode.d.ts +0 -0
|
@@ -157,6 +157,26 @@ export declare function parseVmlPicture(node: PoNode, parseBody?: ParseBody): Dr
|
|
|
157
157
|
* @returns The fill.
|
|
158
158
|
*/
|
|
159
159
|
export declare function vmlFill(shape: PoNode, shapeType?: PoNode, resolveImage?: (id: string) => ResourceId | undefined): ShapeFill;
|
|
160
|
+
/**
|
|
161
|
+
* Whether an `spPr` states a fill AT ALL — including `a:noFill`, which is a
|
|
162
|
+
* shape saying it has none rather than saying nothing. A placeholder that says
|
|
163
|
+
* nothing inherits its prototype's.
|
|
164
|
+
*
|
|
165
|
+
* @param spPr The shape properties, or undefined.
|
|
166
|
+
* @returns Whether a fill element is present.
|
|
167
|
+
*/
|
|
168
|
+
export declare function statesFill(spPr: PoNode | undefined): boolean;
|
|
169
|
+
export declare function styleRefFill(style: PoNode, resolveColor: ColorResolver, themeStyles?: ThemeStyles): ShapeFill;
|
|
170
|
+
export declare function styleRefLine(style: PoNode, resolveColor: ColorResolver, themeLineWidths?: ReadonlyArray<number>): ShapeLine | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* §20.1.4.2.14 `a:fontRef` — the colour a gallery style writes its text in.
|
|
173
|
+
*
|
|
174
|
+
* @param style The shape's `p:style`/`wps:style` node.
|
|
175
|
+
* @param resolveColor The document's colour resolver.
|
|
176
|
+
* @returns The 6-hex colour, or `undefined` when the style names none.
|
|
177
|
+
*/
|
|
178
|
+
export declare function styleRefFontColor(style: PoNode, resolveColor: ColorResolver): string | undefined;
|
|
179
|
+
export declare function withStyleFontColor(text: ShapeTextBody, style: PoNode, resolveColor: ColorResolver): ShapeTextBody;
|
|
160
180
|
/**
|
|
161
181
|
* §20.1.7.6 `a:xfrm` — how a shape sits in its box: rotated about its centre by
|
|
162
182
|
* `@rot` (sixtieth-thousandths of a degree) and mirrored by `@flipH`/`@flipV`.
|
|
@@ -190,6 +210,20 @@ export declare function parseCustGeom(cust: PoNode): ShapeGeometry;
|
|
|
190
210
|
* @param resolveColor Resolver for theme/scheme colours.
|
|
191
211
|
*/
|
|
192
212
|
export declare function parseFill(spPr: PoNode, resolveColor: ColorResolver, resolveImage?: (relId: string) => ResourceId | undefined): ShapeFill;
|
|
213
|
+
/**
|
|
214
|
+
* §20.1.8.16 `a:clrChange` — the colour a picture declares away, and what it
|
|
215
|
+
* becomes. `useA` (default true) says the destination's alpha counts, so a
|
|
216
|
+
* destination at zero alpha knocks the colour OUT rather than replacing it.
|
|
217
|
+
*
|
|
218
|
+
* @param blip The `a:blip` node.
|
|
219
|
+
* @param resolveColor The colour resolver.
|
|
220
|
+
* @returns The change, or `undefined` when the blip declares none.
|
|
221
|
+
*/
|
|
222
|
+
export declare function colorChangeOf(blip: PoNode, resolveColor: ColorResolver): {
|
|
223
|
+
readonly fromHex: string;
|
|
224
|
+
readonly toHex: string;
|
|
225
|
+
readonly transparent: boolean;
|
|
226
|
+
} | undefined;
|
|
193
227
|
/**
|
|
194
228
|
* Parse a shape's drop shadow from its `a:spPr` (§20.1.8.40 `a:effectLst` →
|
|
195
229
|
* `a:outerShdw`).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { emuToPt, pt } from "../core/ir/units.js";
|
|
2
2
|
import { buildStroke } from "../core/drawingml/shape-render.js";
|
|
3
3
|
import { poAttr, poAttrLocal, poChildren, poFindDescendant, poIntAttr, poIs, poIsLocal, poTag, poText } from "../core/po-helpers.js";
|
|
4
|
-
import {
|
|
4
|
+
import { placeholderColors, readColorMods, resolveColorNode } from "../core/drawingml/colors.js";
|
|
5
5
|
//#region src/word/drawing-parser.ts
|
|
6
6
|
var WPS_URI = "http://schemas.microsoft.com/office/word/2010/wordprocessingShape";
|
|
7
7
|
var DRAWINGML_URI_BASES = ["http://schemas.openxmlformats.org/drawingml/2006/", "http://purl.oclc.org/ooxml/drawingml/"];
|
|
@@ -1524,9 +1524,6 @@ function styleRefShadow(style, resolveColor, themeEffectStyles) {
|
|
|
1524
1524
|
const phHex = child ? resolveColorNode(child, resolveColor) : void 0;
|
|
1525
1525
|
return shadowFromOuterShdw(shdw, phHex ? placeholderColors(resolveColor, phHex) : resolveColor);
|
|
1526
1526
|
}
|
|
1527
|
-
function placeholderColors(base, phHex) {
|
|
1528
|
-
return (raw) => "scheme" in raw && raw.scheme === "phClr" ? applyColorMods(phHex, raw.mods ?? []) : base(raw);
|
|
1529
|
-
}
|
|
1530
1527
|
var FILL_TAGS = new Set([
|
|
1531
1528
|
"a:noFill",
|
|
1532
1529
|
"a:solidFill",
|
|
@@ -1535,6 +1532,14 @@ var FILL_TAGS = new Set([
|
|
|
1535
1532
|
"a:pattFill",
|
|
1536
1533
|
"a:grpFill"
|
|
1537
1534
|
]);
|
|
1535
|
+
/**
|
|
1536
|
+
* Whether an `spPr` states a fill AT ALL — including `a:noFill`, which is a
|
|
1537
|
+
* shape saying it has none rather than saying nothing. A placeholder that says
|
|
1538
|
+
* nothing inherits its prototype's.
|
|
1539
|
+
*
|
|
1540
|
+
* @param spPr The shape properties, or undefined.
|
|
1541
|
+
* @returns Whether a fill element is present.
|
|
1542
|
+
*/
|
|
1538
1543
|
function statesFill(spPr) {
|
|
1539
1544
|
return spPr !== void 0 && poChildren(spPr).some((c) => FILL_TAGS.has(poTag(c) ?? ""));
|
|
1540
1545
|
}
|
|
@@ -1567,9 +1572,19 @@ function styleRefLine(style, resolveColor, themeLineWidths) {
|
|
|
1567
1572
|
width: pt((idx !== void 0 && idx > 0 ? themeLineWidths?.[idx - 1] : void 0) ?? .75)
|
|
1568
1573
|
};
|
|
1569
1574
|
}
|
|
1570
|
-
|
|
1575
|
+
/**
|
|
1576
|
+
* §20.1.4.2.14 `a:fontRef` — the colour a gallery style writes its text in.
|
|
1577
|
+
*
|
|
1578
|
+
* @param style The shape's `p:style`/`wps:style` node.
|
|
1579
|
+
* @param resolveColor The document's colour resolver.
|
|
1580
|
+
* @returns The 6-hex colour, or `undefined` when the style names none.
|
|
1581
|
+
*/
|
|
1582
|
+
function styleRefFontColor(style, resolveColor) {
|
|
1571
1583
|
const child = firstElementChild(poChildren(style).find((c) => poIs(c, "a:fontRef")));
|
|
1572
|
-
|
|
1584
|
+
return child ? resolveColorNode(child, resolveColor) : void 0;
|
|
1585
|
+
}
|
|
1586
|
+
function withStyleFontColor(text, style, resolveColor) {
|
|
1587
|
+
const colorHex = styleRefFontColor(style, resolveColor);
|
|
1573
1588
|
if (colorHex === void 0) return text;
|
|
1574
1589
|
return {
|
|
1575
1590
|
...text,
|
|
@@ -1801,11 +1816,23 @@ function fillFromNode(child, resolveColor, resolveImage) {
|
|
|
1801
1816
|
const resource = relId !== void 0 ? resolveImage?.(relId) : void 0;
|
|
1802
1817
|
if (resource === void 0) return { kind: "none" };
|
|
1803
1818
|
const crop = parseSrcRect(poFindDescendant(child, "a:srcRect")) ?? fillRectCrop(child);
|
|
1819
|
+
const rect = fillRectBox(child);
|
|
1820
|
+
const duotone = blip ? duotoneOf(blip, resolveColor) : void 0;
|
|
1821
|
+
const tile = poChildren(child).find((c) => poIs(c, "a:tile"));
|
|
1822
|
+
const tiled = tile !== void 0;
|
|
1823
|
+
const tileScale = tile ? tileScaleOf(tile) : void 0;
|
|
1824
|
+
const fixed = blip ? poChildren(blip).find((c) => poIs(c, "a:alphaModFix")) : void 0;
|
|
1825
|
+
const amt = fixed ? poIntAttr(fixed, "amt") : void 0;
|
|
1826
|
+
const alpha = amt === void 0 ? void 0 : Math.min(1, Math.max(0, amt / 1e5));
|
|
1804
1827
|
return {
|
|
1805
1828
|
kind: "picture",
|
|
1806
1829
|
imageResource: resource,
|
|
1807
|
-
...
|
|
1808
|
-
...
|
|
1830
|
+
...tiled ? { tiled: true } : {},
|
|
1831
|
+
...tileScale ? { tileScale } : {},
|
|
1832
|
+
...crop ? { imageCrop: crop } : {},
|
|
1833
|
+
...rect ? { imageFillRect: rect } : {},
|
|
1834
|
+
...duotone ? { duotone } : {},
|
|
1835
|
+
...alpha !== void 0 && alpha < 1 ? { alpha } : {}
|
|
1809
1836
|
};
|
|
1810
1837
|
}
|
|
1811
1838
|
if (poIs(child, "a:solidFill")) {
|
|
@@ -1830,10 +1857,13 @@ function fillFromNode(child, resolveColor, resolveImage) {
|
|
|
1830
1857
|
}
|
|
1831
1858
|
if (poIs(child, "a:gradFill")) {
|
|
1832
1859
|
const gradient = parseGradient(child, resolveColor);
|
|
1833
|
-
|
|
1860
|
+
if (!gradient) return { kind: "none" };
|
|
1861
|
+
const alpha = gradientAlpha(gradient.stops);
|
|
1862
|
+
return {
|
|
1834
1863
|
kind: "gradient",
|
|
1835
|
-
gradient
|
|
1836
|
-
|
|
1864
|
+
gradient,
|
|
1865
|
+
...alpha !== void 0 ? { alpha } : {}
|
|
1866
|
+
};
|
|
1837
1867
|
}
|
|
1838
1868
|
}
|
|
1839
1869
|
/**
|
|
@@ -1907,6 +1937,102 @@ function fillRectCrop(blipFill) {
|
|
|
1907
1937
|
};
|
|
1908
1938
|
}
|
|
1909
1939
|
/**
|
|
1940
|
+
* §20.1.8.16 `a:clrChange` — the colour a picture declares away, and what it
|
|
1941
|
+
* becomes. `useA` (default true) says the destination's alpha counts, so a
|
|
1942
|
+
* destination at zero alpha knocks the colour OUT rather than replacing it.
|
|
1943
|
+
*
|
|
1944
|
+
* @param blip The `a:blip` node.
|
|
1945
|
+
* @param resolveColor The colour resolver.
|
|
1946
|
+
* @returns The change, or `undefined` when the blip declares none.
|
|
1947
|
+
*/
|
|
1948
|
+
function colorChangeOf(blip, resolveColor) {
|
|
1949
|
+
const change = poChildren(blip).find((c) => poIs(c, "a:clrChange"));
|
|
1950
|
+
if (!change) return void 0;
|
|
1951
|
+
const side = (tag) => poChildren(change).find((c) => poIs(c, tag));
|
|
1952
|
+
const from = side("a:clrFrom");
|
|
1953
|
+
const to = side("a:clrTo");
|
|
1954
|
+
const inner = (holder) => holder ? poChildren(holder).find((c) => poTag(c) !== void 0) : void 0;
|
|
1955
|
+
const fromNode = inner(from);
|
|
1956
|
+
const toNode = inner(to);
|
|
1957
|
+
const fromHex = fromNode ? resolveColorNode(fromNode, resolveColor) : void 0;
|
|
1958
|
+
if (fromHex === void 0) return void 0;
|
|
1959
|
+
const toHex = (toNode ? resolveColorNode(toNode, resolveColor) : void 0) ?? fromHex;
|
|
1960
|
+
const useA = poAttr(change, "useA") !== "0";
|
|
1961
|
+
const alpha = toNode ? nodeAlpha(toNode) : void 0;
|
|
1962
|
+
return {
|
|
1963
|
+
fromHex,
|
|
1964
|
+
toHex,
|
|
1965
|
+
transparent: useA && alpha !== void 0 && alpha <= .001
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
/** §20.1.2.3.1 — a colour node's own `a:alpha`, as a fraction. */
|
|
1969
|
+
function nodeAlpha(color) {
|
|
1970
|
+
const alpha = poChildren(color).find((c) => poIs(c, "a:alpha"));
|
|
1971
|
+
const val = alpha ? poIntAttr(alpha, "val") : void 0;
|
|
1972
|
+
return val === void 0 ? void 0 : val / 1e5;
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* §20.1.8.23 `a:duotone` — the two colours a picture is recoloured between,
|
|
1976
|
+
* dark end first. Both are ordinary colour containers, so a theme's `phClr`
|
|
1977
|
+
* resolves through whatever resolver the caller bound.
|
|
1978
|
+
*
|
|
1979
|
+
* @param blip The `a:blip` node.
|
|
1980
|
+
* @param resolveColor The colour resolver.
|
|
1981
|
+
* @returns The pair, or `undefined` when the blip states no duotone.
|
|
1982
|
+
*/
|
|
1983
|
+
function duotoneOf(blip, resolveColor) {
|
|
1984
|
+
const duotone = poChildren(blip).find((c) => poIs(c, "a:duotone"));
|
|
1985
|
+
if (!duotone) return void 0;
|
|
1986
|
+
const [shadowHex, highlightHex] = poChildren(duotone).map((c) => resolveColorNode(c, resolveColor)).filter((hex) => hex !== void 0);
|
|
1987
|
+
return shadowHex !== void 0 && highlightHex !== void 0 ? {
|
|
1988
|
+
shadowHex,
|
|
1989
|
+
highlightHex
|
|
1990
|
+
} : void 0;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* §20.1.8.30 `a:stretch/a:fillRect` with POSITIVE insets — the part of the box
|
|
1994
|
+
* the picture is stretched INTO. The negative case is the zoom {@link
|
|
1995
|
+
* fillRectCrop} reads; this is the other one, and unread it drew a background
|
|
1996
|
+
* picture inset into the corner of a slide across the whole of it
|
|
1997
|
+
* (tdf153466.pptx: a triangle five times its size).
|
|
1998
|
+
*
|
|
1999
|
+
* @param blipFill The `a:blipFill` node.
|
|
2000
|
+
* @returns The rect as fractions of the box, or `undefined` when every inset
|
|
2001
|
+
* is zero or negative.
|
|
2002
|
+
*/
|
|
2003
|
+
function tileScaleOf(tile) {
|
|
2004
|
+
const pct = (name) => {
|
|
2005
|
+
const v = poIntAttr(tile, name);
|
|
2006
|
+
return v === void 0 || v <= 0 ? 1 : v / 1e5;
|
|
2007
|
+
};
|
|
2008
|
+
const sx = pct("sx");
|
|
2009
|
+
const sy = pct("sy");
|
|
2010
|
+
return sx === 1 && sy === 1 ? void 0 : {
|
|
2011
|
+
sx,
|
|
2012
|
+
sy
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
function fillRectBox(blipFill) {
|
|
2016
|
+
const stretch = poChildren(blipFill).find((c) => poIs(c, "a:stretch"));
|
|
2017
|
+
const rect = stretch ? poChildren(stretch).find((c) => poIs(c, "a:fillRect")) : void 0;
|
|
2018
|
+
if (!rect) return void 0;
|
|
2019
|
+
const side = (name) => Math.max(0, (poIntAttr(rect, name) ?? 0) / 1e5);
|
|
2020
|
+
const [left, top, right, bottom] = [
|
|
2021
|
+
side("l"),
|
|
2022
|
+
side("t"),
|
|
2023
|
+
side("r"),
|
|
2024
|
+
side("b")
|
|
2025
|
+
];
|
|
2026
|
+
if (left + top + right + bottom === 0) return void 0;
|
|
2027
|
+
if (left + right >= 1 || top + bottom >= 1) return void 0;
|
|
2028
|
+
return {
|
|
2029
|
+
left,
|
|
2030
|
+
top,
|
|
2031
|
+
right,
|
|
2032
|
+
bottom
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
/**
|
|
1910
2036
|
* Parse a shape's drop shadow from its `a:spPr` (§20.1.8.40 `a:effectLst` →
|
|
1911
2037
|
* `a:outerShdw`).
|
|
1912
2038
|
*
|
|
@@ -1936,14 +2062,15 @@ function shadowFromOuterShdw(shdw, resolveColor) {
|
|
|
1936
2062
|
const colorHex = colorNode ? resolveColorNode(colorNode, resolveColor) : void 0;
|
|
1937
2063
|
if (!colorHex) return void 0;
|
|
1938
2064
|
const alphaMod = colorNode ? readColorMods(colorNode).find((m) => m.kind === "alpha") : void 0;
|
|
2065
|
+
const alpha = alphaMod ? alphaMod.val : 1;
|
|
1939
2066
|
const dist = emuToPt(poIntAttr(shdw, "dist") ?? 0);
|
|
1940
2067
|
const rad = (poIntAttr(shdw, "dir") ?? 0) / 6e4 * Math.PI / 180;
|
|
1941
2068
|
return {
|
|
1942
2069
|
dxPt: dist * Math.cos(rad),
|
|
1943
2070
|
dyPt: dist * Math.sin(rad),
|
|
1944
2071
|
blurPt: emuToPt(poIntAttr(shdw, "blurRad") ?? 0),
|
|
1945
|
-
colorHex,
|
|
1946
|
-
alpha
|
|
2072
|
+
colorHex: alpha < 1 ? unblendWhite(colorHex, alpha) : colorHex,
|
|
2073
|
+
alpha
|
|
1947
2074
|
};
|
|
1948
2075
|
}
|
|
1949
2076
|
/**
|
|
@@ -2089,6 +2216,34 @@ function colorFromContainer(parent, resolveColor) {
|
|
|
2089
2216
|
if (hex) return hex;
|
|
2090
2217
|
}
|
|
2091
2218
|
}
|
|
2219
|
+
/**
|
|
2220
|
+
* §20.1.2.3.1 — a gradient's stop transparencies, settled.
|
|
2221
|
+
*
|
|
2222
|
+
* The resolver composites a translucent colour over the PAPER, because a solid
|
|
2223
|
+
* fill has nowhere else to put the transparency. A gradient does: its stops
|
|
2224
|
+
* become a luminosity soft mask of the same sweep (§11.6.5.2,
|
|
2225
|
+
* `buildGradientAlphaMask`), so each stop keeps its own alpha and its own
|
|
2226
|
+
* colour, and the mask decides what shows through.
|
|
2227
|
+
*
|
|
2228
|
+
* That means the washing has to be undone here, on every stop — including the
|
|
2229
|
+
* opaque ones, where undoing it is a no-op. It used to be undone only when
|
|
2230
|
+
* EVERY stop was translucent, on the reasoning that a page paints a gradient at
|
|
2231
|
+
* one transparency; the mask makes that false, and the cost of the old reading
|
|
2232
|
+
* was a band that should have been half-transparent over a blue slide drawn as
|
|
2233
|
+
* an opaque pale stripe (45541's layout fades the middle of its left rule to
|
|
2234
|
+
* 50 %).
|
|
2235
|
+
*/
|
|
2236
|
+
function normalizeStopAlpha(stops) {
|
|
2237
|
+
for (const [i, s] of stops.entries()) stops[i] = {
|
|
2238
|
+
...s,
|
|
2239
|
+
colorHex: unblendWhite(s.colorHex, s.alpha ?? 1)
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
/** The one transparency a gradient can be drawn at; see {@link normalizeStopAlpha}. */
|
|
2243
|
+
function gradientAlpha(stops) {
|
|
2244
|
+
const strongest = Math.max(...stops.map((s) => s.alpha ?? 1));
|
|
2245
|
+
return strongest < 1 ? strongest : void 0;
|
|
2246
|
+
}
|
|
2092
2247
|
function parseGradient(grad, resolveColor) {
|
|
2093
2248
|
const gsLst = poChildren(grad).find((c) => poIs(c, "a:gsLst"));
|
|
2094
2249
|
if (!gsLst) return void 0;
|
|
@@ -2103,13 +2258,16 @@ function parseGradient(grad, resolveColor) {
|
|
|
2103
2258
|
if (!hex) continue;
|
|
2104
2259
|
const pos = poIntAttr(gs, "pos");
|
|
2105
2260
|
const offset = pos !== void 0 ? clampUnit(pos / 1e5) : stops.length === 0 ? 0 : 1;
|
|
2261
|
+
const alpha = containerAlpha(gs);
|
|
2106
2262
|
stops.push({
|
|
2107
2263
|
offset,
|
|
2108
|
-
colorHex: hex
|
|
2264
|
+
colorHex: hex,
|
|
2265
|
+
...alpha !== void 0 ? { alpha } : {}
|
|
2109
2266
|
});
|
|
2110
2267
|
}
|
|
2111
2268
|
if (stops.length === 0) return void 0;
|
|
2112
2269
|
stops.sort((a, b) => a.offset - b.offset);
|
|
2270
|
+
normalizeStopAlpha(stops);
|
|
2113
2271
|
const path = poChildren(grad).find((c) => poIs(c, "a:path"));
|
|
2114
2272
|
if (path) {
|
|
2115
2273
|
const rect = poChildren(path).find((c) => poIs(c, "a:fillToRect"));
|
|
@@ -2144,4 +2302,4 @@ function clampUnit(x) {
|
|
|
2144
2302
|
return x < 0 ? 0 : x > 1 ? 1 : x;
|
|
2145
2303
|
}
|
|
2146
2304
|
//#endregion
|
|
2147
|
-
export { expandMcChildren, parseCustGeom, parseDrawing, parseFill, parseLine, parsePrstGeom, parseShadow, parseVmlPicture, parseXfrm, shadowFromOuterShdw, vmlFill };
|
|
2305
|
+
export { colorChangeOf, expandMcChildren, parseCustGeom, parseDrawing, parseFill, parseLine, parsePrstGeom, parseShadow, parseVmlPicture, parseXfrm, shadowFromOuterShdw, statesFill, styleRefFill, styleRefFontColor, styleRefLine, vmlFill };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Numbering } from '../core/document-model/index.js';
|
|
2
2
|
import { ResourceId } from '../core/ir/index.js';
|
|
3
|
+
import { ThemeFonts } from '../core/drawingml/theme-parser.js';
|
|
3
4
|
/** The empty {@link Numbering} returned when a document has no `numbering.xml`. */
|
|
4
5
|
export declare const EMPTY_NUMBERING: Numbering;
|
|
5
6
|
/**
|
|
@@ -12,4 +13,4 @@ export declare const EMPTY_NUMBERING: Numbering;
|
|
|
12
13
|
* @param data The raw `numbering.xml` bytes.
|
|
13
14
|
* @returns The parsed numbering, or {@link EMPTY_NUMBERING} when the root is absent.
|
|
14
15
|
*/
|
|
15
|
-
export declare function parseNumbering(data: Uint8Array, resolveImage?: (relId: string) => ResourceId | undefined): Numbering;
|
|
16
|
+
export declare function parseNumbering(data: Uint8Array, resolveImage?: (relId: string) => ResourceId | undefined, themeFonts?: ThemeFonts): Numbering;
|
|
@@ -56,7 +56,7 @@ var EMPTY_NUMBERING = {
|
|
|
56
56
|
* @param data The raw `numbering.xml` bytes.
|
|
57
57
|
* @returns The parsed numbering, or {@link EMPTY_NUMBERING} when the root is absent.
|
|
58
58
|
*/
|
|
59
|
-
function parseNumbering(data, resolveImage) {
|
|
59
|
+
function parseNumbering(data, resolveImage, themeFonts) {
|
|
60
60
|
const xml = decoder.decode(data);
|
|
61
61
|
const root = asElement(parser.parse(xml)["w:numbering"]);
|
|
62
62
|
if (!root) return EMPTY_NUMBERING;
|
|
@@ -69,7 +69,7 @@ function parseNumbering(data, resolveImage) {
|
|
|
69
69
|
if (!id) continue;
|
|
70
70
|
const levels = /* @__PURE__ */ new Map();
|
|
71
71
|
for (const lvlNode of asArray(el["w:lvl"])) {
|
|
72
|
-
const lvl = parseLevel(lvlNode, picBullets);
|
|
72
|
+
const lvl = parseLevel(lvlNode, picBullets, themeFonts);
|
|
73
73
|
if (lvl) levels.set(lvl.ilvl, lvl);
|
|
74
74
|
}
|
|
75
75
|
abstractNums.set(id, {
|
|
@@ -94,7 +94,7 @@ function parseNumbering(data, resolveImage) {
|
|
|
94
94
|
if (!Number.isFinite(ilvl)) continue;
|
|
95
95
|
const start = Number(getValVal(ovr["w:startOverride"]));
|
|
96
96
|
if (Number.isFinite(start)) startOverrides.set(ilvl, start);
|
|
97
|
-
const lvl = parseLevel(ovr["w:lvl"], picBullets);
|
|
97
|
+
const lvl = parseLevel(ovr["w:lvl"], picBullets, themeFonts);
|
|
98
98
|
if (lvl) levelOverrides.set(ilvl, lvl);
|
|
99
99
|
}
|
|
100
100
|
numInstances.set(numId, {
|
|
@@ -109,7 +109,7 @@ function parseNumbering(data, resolveImage) {
|
|
|
109
109
|
numInstances
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
function parseLevel(node, picBullets) {
|
|
112
|
+
function parseLevel(node, picBullets, themeFonts) {
|
|
113
113
|
const lvlEl = asElement(node);
|
|
114
114
|
if (!lvlEl) return void 0;
|
|
115
115
|
const ilvlStr = getAttr(lvlEl, "ilvl");
|
|
@@ -131,8 +131,8 @@ function parseLevel(node, picBullets) {
|
|
|
131
131
|
lvlText,
|
|
132
132
|
...isLegal ? { isLegal: true } : {},
|
|
133
133
|
...picBullet ? { picBullet } : {},
|
|
134
|
-
paragraphProperties: parseParagraphProperties(lvlEl["w:pPr"]),
|
|
135
|
-
runProperties: parseRunProperties(lvlEl["w:rPr"])
|
|
134
|
+
paragraphProperties: parseParagraphProperties(lvlEl["w:pPr"], 0, themeFonts),
|
|
135
|
+
runProperties: parseRunProperties(lvlEl["w:rPr"], themeFonts)
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
function parsePicBullets(root, resolveImage) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ParagraphProperties } from '../core/document-model/index.js';
|
|
2
|
+
import { ThemeFonts } from '../core/drawingml/theme-parser.js';
|
|
2
3
|
/**
|
|
3
4
|
* §17.3.1.1/§17.3.1.3 — the gap `w:*Autospacing` asks the consumer for. Word's
|
|
4
5
|
* own automatic value is HTML's 14pt, and only a document old enough to state
|
|
@@ -19,4 +20,4 @@ export declare const HTML_AUTO_SPACING_PT = 14;
|
|
|
19
20
|
* compatibility mode, and 0 (the default) for every Word 2007-or-later one.
|
|
20
21
|
* @returns The extracted properties; an empty object when `pPr` is absent.
|
|
21
22
|
*/
|
|
22
|
-
export declare function parseParagraphProperties(pPr: unknown, autoSpacingPt?: number): ParagraphProperties;
|
|
23
|
+
export declare function parseParagraphProperties(pPr: unknown, autoSpacingPt?: number, themeFonts?: ThemeFonts): ParagraphProperties;
|
|
@@ -104,7 +104,7 @@ function parseFramePr(node) {
|
|
|
104
104
|
* compatibility mode, and 0 (the default) for every Word 2007-or-later one.
|
|
105
105
|
* @returns The extracted properties; an empty object when `pPr` is absent.
|
|
106
106
|
*/
|
|
107
|
-
function parseParagraphProperties(pPr, autoSpacingPt = 0) {
|
|
107
|
+
function parseParagraphProperties(pPr, autoSpacingPt = 0, themeFonts) {
|
|
108
108
|
const el = asElement(pPr);
|
|
109
109
|
if (!el) return {};
|
|
110
110
|
const out = {};
|
|
@@ -197,7 +197,7 @@ function parseParagraphProperties(pPr, autoSpacingPt = 0) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
if ("w:rPr" in el) {
|
|
200
|
-
const rPr = parseRunProperties(el["w:rPr"]);
|
|
200
|
+
const rPr = parseRunProperties(el["w:rPr"], themeFonts);
|
|
201
201
|
if (Object.keys(rPr).length > 0) out.runProperties = rPr;
|
|
202
202
|
}
|
|
203
203
|
return out;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RunProperties } from '../core/document-model/index.js';
|
|
2
|
+
import { ThemeFonts } from '../core/drawingml/theme-parser.js';
|
|
2
3
|
/**
|
|
3
4
|
* Parse a run-properties element (`w:rPr`, ECMA-376 Part 1 §17.3.2) into the
|
|
4
5
|
* typed {@link RunProperties}. Reads the character formatting the renderer needs:
|
|
@@ -6,7 +7,9 @@ import { RunProperties } from '../core/document-model/index.js';
|
|
|
6
7
|
* font family map, vertical alignment, RTL, and language; sizes convert from
|
|
7
8
|
* half-points to points and colours normalize to uppercase hex.
|
|
8
9
|
*
|
|
9
|
-
* @param rPr
|
|
10
|
+
* @param rPr The flat-tree `w:rPr` element (or `undefined`/non-element).
|
|
11
|
+
* @param themeFonts The document theme's font scheme, for the fonts a run names
|
|
12
|
+
* by slot rather than by name (§17.3.2.26 `w:asciiTheme`).
|
|
10
13
|
* @returns The parsed properties; an empty object when `rPr` is absent.
|
|
11
14
|
*/
|
|
12
|
-
export declare function parseRunProperties(rPr: unknown): RunProperties;
|
|
15
|
+
export declare function parseRunProperties(rPr: unknown, themeFonts?: ThemeFonts): RunProperties;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { halfPtToPt, twipsToPt } from "../core/ir/units.js";
|
|
2
|
+
import { resolveThemeFont } from "../core/drawingml/theme-parser.js";
|
|
2
3
|
import { asElement, getAttr, getVal, parseHalfPointAttr, parseToggle } from "./xml-helpers.js";
|
|
4
|
+
import { resolveWordThemeFont } from "./theme-fonts.js";
|
|
3
5
|
import { shadingFillHex } from "./shading.js";
|
|
4
6
|
//#region src/word/run-properties.ts
|
|
5
7
|
var UNDERLINE_STYLES = new Set([
|
|
@@ -43,10 +45,12 @@ var HIGHLIGHT_COLORS = new Map([
|
|
|
43
45
|
* font family map, vertical alignment, RTL, and language; sizes convert from
|
|
44
46
|
* half-points to points and colours normalize to uppercase hex.
|
|
45
47
|
*
|
|
46
|
-
* @param rPr
|
|
48
|
+
* @param rPr The flat-tree `w:rPr` element (or `undefined`/non-element).
|
|
49
|
+
* @param themeFonts The document theme's font scheme, for the fonts a run names
|
|
50
|
+
* by slot rather than by name (§17.3.2.26 `w:asciiTheme`).
|
|
47
51
|
* @returns The parsed properties; an empty object when `rPr` is absent.
|
|
48
52
|
*/
|
|
49
|
-
function parseRunProperties(rPr) {
|
|
53
|
+
function parseRunProperties(rPr, themeFonts) {
|
|
50
54
|
const el = asElement(rPr);
|
|
51
55
|
if (!el) return {};
|
|
52
56
|
const out = {};
|
|
@@ -90,7 +94,7 @@ function parseRunProperties(rPr) {
|
|
|
90
94
|
else if (v === "auto") out.colorHex = "000000";
|
|
91
95
|
}
|
|
92
96
|
if ("w:rFonts" in el) {
|
|
93
|
-
const ff = parseFontFamily(el["w:rFonts"]);
|
|
97
|
+
const ff = parseFontFamily(el["w:rFonts"], themeFonts);
|
|
94
98
|
if (ff) out.fontFamily = ff;
|
|
95
99
|
}
|
|
96
100
|
if ("w:vertAlign" in el) {
|
|
@@ -121,12 +125,13 @@ function parseRunProperties(rPr) {
|
|
|
121
125
|
}
|
|
122
126
|
return out;
|
|
123
127
|
}
|
|
124
|
-
function parseFontFamily(node) {
|
|
128
|
+
function parseFontFamily(node, themeFonts) {
|
|
125
129
|
const ff = {};
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
+
const slot = (literal, theme) => resolveThemeFont(getAttr(node, literal), themeFonts) ?? resolveWordThemeFont(getAttr(node, theme), themeFonts);
|
|
131
|
+
const ascii = slot("ascii", "asciiTheme");
|
|
132
|
+
const hAnsi = slot("hAnsi", "hAnsiTheme");
|
|
133
|
+
const cs = slot("cs", "cstheme");
|
|
134
|
+
const eastAsia = slot("eastAsia", "eastAsiaTheme");
|
|
130
135
|
if (ascii) ff.ascii = ascii;
|
|
131
136
|
if (hAnsi) ff.hAnsi = hAnsi;
|
|
132
137
|
if (cs) ff.cs = cs;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from '../core/document-model/index.js';
|
|
2
|
+
import { ThemeFonts } from '../core/drawingml/theme-parser.js';
|
|
2
3
|
/**
|
|
3
4
|
* Parse `word/styles.xml` (ECMA-376 Part 1 §17.7) into a {@link StyleSheet}: the
|
|
4
5
|
* document defaults (`w:docDefaults` run/paragraph properties) plus the named
|
|
@@ -9,4 +10,4 @@ import { StyleSheet } from '../core/document-model/index.js';
|
|
|
9
10
|
* @param stylesXml The raw `styles.xml` bytes.
|
|
10
11
|
* @returns The parsed stylesheet, or `EMPTY_STYLE_SHEET` when the root is absent.
|
|
11
12
|
*/
|
|
12
|
-
export declare function parseStyles(stylesXml: Uint8Array): StyleSheet;
|
|
13
|
+
export declare function parseStyles(stylesXml: Uint8Array, themeFonts?: ThemeFonts): StyleSheet;
|
|
@@ -32,7 +32,7 @@ var STYLE_TYPES = new Set([
|
|
|
32
32
|
* @param stylesXml The raw `styles.xml` bytes.
|
|
33
33
|
* @returns The parsed stylesheet, or `EMPTY_STYLE_SHEET` when the root is absent.
|
|
34
34
|
*/
|
|
35
|
-
function parseStyles(stylesXml) {
|
|
35
|
+
function parseStyles(stylesXml, themeFonts) {
|
|
36
36
|
const xml = decoder.decode(stylesXml);
|
|
37
37
|
const root = asElement(parser.parse(xml)["w:styles"]);
|
|
38
38
|
if (!root) return EMPTY_STYLE_SHEET;
|
|
@@ -41,9 +41,9 @@ function parseStyles(stylesXml) {
|
|
|
41
41
|
let defaultParagraphProperties = {};
|
|
42
42
|
if (docDefaults) {
|
|
43
43
|
const rPrDef = asElement(docDefaults["w:rPrDefault"]);
|
|
44
|
-
if (rPrDef) defaultRunProperties = parseRunProperties(rPrDef["w:rPr"]);
|
|
44
|
+
if (rPrDef) defaultRunProperties = parseRunProperties(rPrDef["w:rPr"], themeFonts);
|
|
45
45
|
const pPrDef = asElement(docDefaults["w:pPrDefault"]);
|
|
46
|
-
if (pPrDef) defaultParagraphProperties = parseParagraphProperties(pPrDef["w:pPr"]);
|
|
46
|
+
if (pPrDef) defaultParagraphProperties = parseParagraphProperties(pPrDef["w:pPr"], 0, themeFonts);
|
|
47
47
|
}
|
|
48
48
|
const styles = /* @__PURE__ */ new Map();
|
|
49
49
|
for (const s of asArray(root["w:style"])) {
|
|
@@ -61,9 +61,9 @@ function parseStyles(stylesXml) {
|
|
|
61
61
|
type,
|
|
62
62
|
...basedOnVal ? { basedOn: basedOnVal } : {},
|
|
63
63
|
isDefault,
|
|
64
|
-
runProperties: parseRunProperties(el["w:rPr"]),
|
|
65
|
-
paragraphProperties: parseParagraphProperties(el["w:pPr"]),
|
|
66
|
-
...type === "table" ? parseTableStyleParts(el) : {}
|
|
64
|
+
runProperties: parseRunProperties(el["w:rPr"], themeFonts),
|
|
65
|
+
paragraphProperties: parseParagraphProperties(el["w:pPr"], 0, themeFonts),
|
|
66
|
+
...type === "table" ? parseTableStyleParts(el, themeFonts) : {}
|
|
67
67
|
};
|
|
68
68
|
styles.set(id, style);
|
|
69
69
|
}
|
|
@@ -88,9 +88,9 @@ var CONDITION_TYPES = new Set([
|
|
|
88
88
|
"swCell",
|
|
89
89
|
"seCell"
|
|
90
90
|
]);
|
|
91
|
-
function parseTableStyleParts(el) {
|
|
91
|
+
function parseTableStyleParts(el, themeFonts) {
|
|
92
92
|
const out = {};
|
|
93
|
-
const base = parseTableStyleLayer(el);
|
|
93
|
+
const base = parseTableStyleLayer(el, themeFonts);
|
|
94
94
|
if (base) out.tableLayer = base;
|
|
95
95
|
const tblPr = asElement(el["w:tblPr"]);
|
|
96
96
|
if (tblPr) {
|
|
@@ -105,7 +105,7 @@ function parseTableStyleParts(el) {
|
|
|
105
105
|
if (!cond) continue;
|
|
106
106
|
const typeAttr = getAttr(cond, "type");
|
|
107
107
|
if (!typeAttr || !CONDITION_TYPES.has(typeAttr)) continue;
|
|
108
|
-
const layer = parseTableStyleLayer(cond);
|
|
108
|
+
const layer = parseTableStyleLayer(cond, themeFonts);
|
|
109
109
|
if (layer) conditions.push({
|
|
110
110
|
type: typeAttr,
|
|
111
111
|
layer
|
|
@@ -114,7 +114,7 @@ function parseTableStyleParts(el) {
|
|
|
114
114
|
if (conditions.length > 0) out.tableConditions = conditions;
|
|
115
115
|
return out;
|
|
116
116
|
}
|
|
117
|
-
function parseTableStyleLayer(el) {
|
|
117
|
+
function parseTableStyleLayer(el, themeFonts) {
|
|
118
118
|
const tblPr = asElement(el["w:tblPr"]);
|
|
119
119
|
const tcPr = asElement(el["w:tcPr"]);
|
|
120
120
|
const borders = parseFlatBorders(tblPr ? asElement(tblPr["w:tblBorders"]) : void 0) ?? parseFlatBorders(tcPr ? asElement(tcPr["w:tcBorders"]) : void 0);
|
|
@@ -124,8 +124,8 @@ function parseTableStyleLayer(el) {
|
|
|
124
124
|
const indType = tblInd ? getAttr(tblInd, "type") : void 0;
|
|
125
125
|
const indentPt = indW !== void 0 && (indType === void 0 || indType === "dxa") ? twipsToPt(indW) : void 0;
|
|
126
126
|
const shading = parseFlatShading(tcPr ? tcPr["w:shd"] : void 0);
|
|
127
|
-
const runProperties = parseRunProperties(el["w:rPr"]);
|
|
128
|
-
const paragraphProperties = parseParagraphProperties(el["w:pPr"]);
|
|
127
|
+
const runProperties = parseRunProperties(el["w:rPr"], themeFonts);
|
|
128
|
+
const paragraphProperties = parseParagraphProperties(el["w:pPr"], 0, themeFonts);
|
|
129
129
|
const layer = {
|
|
130
130
|
...borders ? { borders } : {},
|
|
131
131
|
...cellMargins ? { cellMargins } : {},
|
|
@@ -115,11 +115,11 @@ function parseTable(tbl, ctx = DEFAULT_PARSE_CONTEXT) {
|
|
|
115
115
|
function poChildrenThroughSdt(node, tag) {
|
|
116
116
|
return childrenThroughSdt(node, tag).map((c) => c.node);
|
|
117
117
|
}
|
|
118
|
-
function childrenThroughSdt(node, tag) {
|
|
118
|
+
function childrenThroughSdt(node, tag, themeFonts) {
|
|
119
119
|
const out = [];
|
|
120
120
|
for (const child of poChildren(node)) if (poIs(child, tag)) out.push({ node: child });
|
|
121
121
|
else if (poIs(child, "w:sdt")) {
|
|
122
|
-
const props = sdtRunProperties(child);
|
|
122
|
+
const props = sdtRunProperties(child, themeFonts);
|
|
123
123
|
for (const inner of poChildrenWith(poFirstChild(child, "w:sdtContent"), tag)) out.push({
|
|
124
124
|
node: inner,
|
|
125
125
|
...props ? { sdtRunProps: props } : {}
|
|
@@ -270,7 +270,7 @@ function isDeletedRow(tr) {
|
|
|
270
270
|
function parseTableRow(tr, ctx) {
|
|
271
271
|
const properties = parseRowProperties(poFirstChild(tr, "w:trPr"));
|
|
272
272
|
const cells = [];
|
|
273
|
-
for (const { node, sdtRunProps } of childrenThroughSdt(tr, "w:tc")) cells.push(parseTableCell(node, ctx, sdtRunProps));
|
|
273
|
+
for (const { node, sdtRunProps } of childrenThroughSdt(tr, "w:tc", ctx.themeFonts)) cells.push(parseTableCell(node, ctx, sdtRunProps));
|
|
274
274
|
return {
|
|
275
275
|
properties,
|
|
276
276
|
cells
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ThemeFonts } from '../core/drawingml/theme-parser.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a `w:rFonts` theme attribute to the typeface it stands for.
|
|
4
|
+
*
|
|
5
|
+
* @param value The attribute as written (`minorHAnsi`, `majorBidi`, …).
|
|
6
|
+
* @param fonts The theme's font scheme, when the part was read.
|
|
7
|
+
* @returns The typeface, or `undefined` for an unknown slot, a missing theme,
|
|
8
|
+
* or a slot the theme leaves empty.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveWordThemeFont(value: string | undefined, fonts: ThemeFonts | undefined): string | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/word/theme-fonts.ts
|
|
2
|
+
var THEME_SLOTS = new Map([
|
|
3
|
+
["majorascii", ["major", "latin"]],
|
|
4
|
+
["majorhansi", ["major", "latin"]],
|
|
5
|
+
["majoreastasia", ["major", "ea"]],
|
|
6
|
+
["majorbidi", ["major", "cs"]],
|
|
7
|
+
["minorascii", ["minor", "latin"]],
|
|
8
|
+
["minorhansi", ["minor", "latin"]],
|
|
9
|
+
["minoreastasia", ["minor", "ea"]],
|
|
10
|
+
["minorbidi", ["minor", "cs"]]
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a `w:rFonts` theme attribute to the typeface it stands for.
|
|
14
|
+
*
|
|
15
|
+
* @param value The attribute as written (`minorHAnsi`, `majorBidi`, …).
|
|
16
|
+
* @param fonts The theme's font scheme, when the part was read.
|
|
17
|
+
* @returns The typeface, or `undefined` for an unknown slot, a missing theme,
|
|
18
|
+
* or a slot the theme leaves empty.
|
|
19
|
+
*/
|
|
20
|
+
function resolveWordThemeFont(value, fonts) {
|
|
21
|
+
if (value === void 0 || !fonts) return void 0;
|
|
22
|
+
const slot = THEME_SLOTS.get(value.trim().toLowerCase());
|
|
23
|
+
if (!slot) return void 0;
|
|
24
|
+
const [which, script] = slot;
|
|
25
|
+
return fonts[which][script];
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { resolveWordThemeFont };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reamkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "Ream — convert DOCX, XLSX, PPTX and PDF to PDF, SVG, HTML, DOCX and XLSX, built from scratch on the ECMA-376 and ISO 32000 specifications. Parse once, convert anywhere.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alex Krassavin <info@reamkit.dev>",
|
|
File without changes
|