reamkit 1.23.0 → 1.24.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/bmp.d.ts +33 -0
- package/dist/esm/core/bmp.js +276 -0
- package/dist/esm/core/document-model/types.d.ts +37 -0
- package/dist/esm/core/drawingml/chart-geometry.js +3 -2
- package/dist/esm/core/drawingml/diagram/colors.d.ts +52 -0
- package/dist/esm/core/drawingml/diagram/colors.js +125 -0
- package/dist/esm/core/drawingml/diagram/data-model.d.ts +47 -0
- package/dist/esm/core/drawingml/diagram/data-model.js +119 -0
- package/dist/esm/core/drawingml/diagram/layout-engine.d.ts +46 -0
- package/dist/esm/core/drawingml/diagram/layout-engine.js +948 -0
- package/dist/esm/core/drawingml/diagram/run.d.ts +37 -0
- package/dist/esm/core/drawingml/diagram/run.js +50 -0
- package/dist/esm/core/drawingml/diagram/to-drawing.d.ts +16 -0
- package/dist/esm/core/drawingml/diagram/to-drawing.js +86 -0
- package/dist/esm/core/drawingml/preset-geometry.js +116 -6
- package/dist/esm/core/drawingml/text-warp.d.ts +58 -0
- package/dist/esm/core/drawingml/text-warp.js +355 -0
- package/dist/esm/core/drawingml/theme-parser.js +9 -3
- package/dist/esm/core/font/measure.d.ts +12 -0
- package/dist/esm/core/font/measure.js +36 -0
- package/dist/esm/core/images.d.ts +30 -2
- package/dist/esm/core/images.js +121 -5
- package/dist/esm/core/metafile/emf.js +144 -16
- package/dist/esm/core/metafile/picture.d.ts +49 -0
- package/dist/esm/core/metafile/picture.js +70 -1
- package/dist/esm/core/metafile/wmf.js +53 -4
- package/dist/esm/core/ole/escher-blip.js +11 -1
- package/dist/esm/excel/print-model.js +2 -2
- package/dist/esm/excel/sheet-drawing.js +1 -1
- package/dist/esm/excel/sheet-to-flow.js +16 -2
- package/dist/esm/html/html-writer.js +2 -1
- package/dist/esm/layout/page-doc.d.ts +35 -0
- package/dist/esm/layout/page-doc.js +14 -1
- package/dist/esm/layout/styled-layout.js +176 -15
- package/dist/esm/pdf/shading.js +8 -6
- package/dist/esm/pdf/styled-page-emitter.js +42 -3
- package/dist/esm/pdf/vector-graphics.js +1 -1
- package/dist/esm/pdf-reader/image-decode.js +1 -1
- package/dist/esm/pptx/ppt/ppt-reader.js +95 -27
- package/dist/esm/pptx/ppt/ppt-text.d.ts +41 -0
- package/dist/esm/pptx/ppt/ppt-text.js +327 -37
- package/dist/esm/pptx/pptx-reader.js +90 -10
- package/dist/esm/pptx/slide-parser.d.ts +4 -1
- package/dist/esm/pptx/slide-parser.js +99 -13
- package/dist/esm/pptx/sp-helpers.d.ts +7 -3
- package/dist/esm/pptx/sp-helpers.js +45 -7
- package/dist/esm/pptx/table-style.d.ts +7 -0
- package/dist/esm/pptx/table-style.js +59 -7
- package/dist/esm/svg/svg-writer.js +1 -0
- package/dist/esm/word/document-parser.d.ts +4 -1
- package/dist/esm/word/document-parser.js +4 -1
- package/dist/esm/word/docx-reader.js +26 -13
- package/dist/esm/word/docx-writer.js +4 -0
- package/dist/esm/word/drawing-parser.d.ts +20 -0
- package/dist/esm/word/drawing-parser.js +37 -4
- package/dist/esm/word/table-parser.js +3 -0
- package/package.json +1 -1
|
@@ -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
|
+
* §20.1.8.55 `a:srcRect` — the picture's own edges, cut away before it is
|
|
162
|
+
* fitted to its frame. Each is a percentage in thousandths (ST_Percentage), so
|
|
163
|
+
* `l="14711"` drops the left 14.711%.
|
|
164
|
+
*
|
|
165
|
+
* @param node The `a:srcRect` element, or `undefined` when the fill declares none.
|
|
166
|
+
* @returns The crop, or `undefined` when nothing is cut away.
|
|
167
|
+
*/
|
|
168
|
+
export declare function parseSrcRect(node: PoNode | undefined): ImageCrop | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* The fill with the direction the SHAPE states, where it states one and no
|
|
171
|
+
* colours: §20.1.8.33's `a:gradFill` holding only an `a:lin` says "sweep the
|
|
172
|
+
* gallery style's run of colours this way". 63200.pptx's ellipse asks for the
|
|
173
|
+
* diagonal where the theme's slot sweeps straight down.
|
|
174
|
+
*
|
|
175
|
+
* @param fill The fill resolved from the style (or anywhere else).
|
|
176
|
+
* @param spPr The shape's own properties.
|
|
177
|
+
* @returns The fill, turned; unchanged when the shape states no bare direction.
|
|
178
|
+
*/
|
|
179
|
+
export declare function withStatedDirection(fill: ShapeFill, spPr: PoNode | undefined): ShapeFill;
|
|
160
180
|
/**
|
|
161
181
|
* Whether an `spPr` states a fill AT ALL — including `a:noFill`, which is a
|
|
162
182
|
* shape saying it has none rather than saying nothing. A placeholder that says
|
|
@@ -1532,6 +1532,34 @@ var FILL_TAGS = new Set([
|
|
|
1532
1532
|
"a:pattFill",
|
|
1533
1533
|
"a:grpFill"
|
|
1534
1534
|
]);
|
|
1535
|
+
function emptyGradient(node) {
|
|
1536
|
+
return poIs(node, "a:gradFill") && !poChildren(node).some((c) => poIs(c, "a:gsLst"));
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* The fill with the direction the SHAPE states, where it states one and no
|
|
1540
|
+
* colours: §20.1.8.33's `a:gradFill` holding only an `a:lin` says "sweep the
|
|
1541
|
+
* gallery style's run of colours this way". 63200.pptx's ellipse asks for the
|
|
1542
|
+
* diagonal where the theme's slot sweeps straight down.
|
|
1543
|
+
*
|
|
1544
|
+
* @param fill The fill resolved from the style (or anywhere else).
|
|
1545
|
+
* @param spPr The shape's own properties.
|
|
1546
|
+
* @returns The fill, turned; unchanged when the shape states no bare direction.
|
|
1547
|
+
*/
|
|
1548
|
+
function withStatedDirection(fill, spPr) {
|
|
1549
|
+
const gradient = fill.kind === "gradient" ? fill.gradient : void 0;
|
|
1550
|
+
if (gradient === void 0 || gradient.kind !== "linear" || spPr === void 0) return fill;
|
|
1551
|
+
const grad = poChildren(spPr).find((c) => emptyGradient(c));
|
|
1552
|
+
const lin = grad ? poChildren(grad).find((c) => poIs(c, "a:lin")) : void 0;
|
|
1553
|
+
const ang = lin ? poIntAttr(lin, "ang") : void 0;
|
|
1554
|
+
if (ang === void 0) return fill;
|
|
1555
|
+
return {
|
|
1556
|
+
...fill,
|
|
1557
|
+
gradient: {
|
|
1558
|
+
...gradient,
|
|
1559
|
+
angle: ang / 6e4 % 360
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1535
1563
|
/**
|
|
1536
1564
|
* Whether an `spPr` states a fill AT ALL — including `a:noFill`, which is a
|
|
1537
1565
|
* shape saying it has none rather than saying nothing. A placeholder that says
|
|
@@ -1541,7 +1569,7 @@ var FILL_TAGS = new Set([
|
|
|
1541
1569
|
* @returns Whether a fill element is present.
|
|
1542
1570
|
*/
|
|
1543
1571
|
function statesFill(spPr) {
|
|
1544
|
-
return spPr !== void 0 && poChildren(spPr).some((c) => FILL_TAGS.has(poTag(c) ?? ""));
|
|
1572
|
+
return spPr !== void 0 && poChildren(spPr).some((c) => FILL_TAGS.has(poTag(c) ?? "") && !emptyGradient(c));
|
|
1545
1573
|
}
|
|
1546
1574
|
function styleRefFill(style, resolveColor, themeStyles) {
|
|
1547
1575
|
const ref = poChildren(style).find((c) => poIs(c, "a:fillRef"));
|
|
@@ -1819,7 +1847,8 @@ function fillFromNode(child, resolveColor, resolveImage) {
|
|
|
1819
1847
|
const rect = fillRectBox(child);
|
|
1820
1848
|
const duotone = blip ? duotoneOf(blip, resolveColor) : void 0;
|
|
1821
1849
|
const tile = poChildren(child).find((c) => poIs(c, "a:tile"));
|
|
1822
|
-
const
|
|
1850
|
+
const stretched = poChildren(child).some((c) => poIs(c, "a:stretch"));
|
|
1851
|
+
const tiled = tile !== void 0 || !stretched;
|
|
1823
1852
|
const tileScale = tile ? tileScaleOf(tile) : void 0;
|
|
1824
1853
|
const fixed = blip ? poChildren(blip).find((c) => poIs(c, "a:alphaModFix")) : void 0;
|
|
1825
1854
|
const amt = fixed ? poIntAttr(fixed, "amt") : void 0;
|
|
@@ -1981,6 +2010,10 @@ function nodeAlpha(color) {
|
|
|
1981
2010
|
* @returns The pair, or `undefined` when the blip states no duotone.
|
|
1982
2011
|
*/
|
|
1983
2012
|
function duotoneOf(blip, resolveColor) {
|
|
2013
|
+
if (poChildren(blip).some((c) => poIs(c, "a:grayscl"))) return {
|
|
2014
|
+
shadowHex: "000000",
|
|
2015
|
+
highlightHex: "FFFFFF"
|
|
2016
|
+
};
|
|
1984
2017
|
const duotone = poChildren(blip).find((c) => poIs(c, "a:duotone"));
|
|
1985
2018
|
if (!duotone) return void 0;
|
|
1986
2019
|
const [shadowHex, highlightHex] = poChildren(duotone).map((c) => resolveColorNode(c, resolveColor)).filter((hex) => hex !== void 0);
|
|
@@ -2286,7 +2319,7 @@ function parseGradient(grad, resolveColor) {
|
|
|
2286
2319
|
return {
|
|
2287
2320
|
kind: "radial",
|
|
2288
2321
|
stops,
|
|
2289
|
-
...poAttr(path, "path") === "rect" ? { sweep: "rect" } : {},
|
|
2322
|
+
...poAttr(path, "path") === "rect" || poAttr(path, "path") === "shape" ? { sweep: "rect" } : {},
|
|
2290
2323
|
...center ? { center } : {}
|
|
2291
2324
|
};
|
|
2292
2325
|
}
|
|
@@ -2302,4 +2335,4 @@ function clampUnit(x) {
|
|
|
2302
2335
|
return x < 0 ? 0 : x > 1 ? 1 : x;
|
|
2303
2336
|
}
|
|
2304
2337
|
//#endregion
|
|
2305
|
-
export { colorChangeOf, expandMcChildren, parseCustGeom, parseDrawing, parseFill, parseLine, parsePrstGeom, parseShadow, parseVmlPicture, parseXfrm, shadowFromOuterShdw, statesFill, styleRefFill, styleRefFontColor, styleRefLine, vmlFill };
|
|
2338
|
+
export { colorChangeOf, expandMcChildren, parseCustGeom, parseDrawing, parseFill, parseLine, parsePrstGeom, parseShadow, parseSrcRect, parseVmlPicture, parseXfrm, shadowFromOuterShdw, statesFill, styleRefFill, styleRefFontColor, styleRefLine, vmlFill, withStatedDirection };
|
|
@@ -353,6 +353,9 @@ function parseCellProperties(tcPr) {
|
|
|
353
353
|
}
|
|
354
354
|
const vAlign = poVal(poFirstChild(tcPr, "w:vAlign"));
|
|
355
355
|
if (vAlign === "center" || vAlign === "bottom" || vAlign === "top") out.verticalAlign = vAlign;
|
|
356
|
+
const dir = poVal(poFirstChild(tcPr, "w:textDirection"));
|
|
357
|
+
if (dir === "btLr" || dir === "tbLr") out.textDirection = "vert270";
|
|
358
|
+
else if (dir === "tbRl") out.textDirection = "vert";
|
|
356
359
|
if (poFirstChild(tcPr, "w:hideMark")) out.hideMark = true;
|
|
357
360
|
return {
|
|
358
361
|
properties: out,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reamkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.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>",
|