@office-kit/pptx-preview 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MONO, c as TIMES, d as substituteFamily, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout } from "./src-
|
|
1
|
+
import { a as MONO, c as TIMES, d as substituteFamily, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout } from "./src-B2rbAoIa.js";
|
|
2
2
|
export { ARIAL, MONO, SANS, SERIF, TIMES, auditTextLayout, defaultMeasurer, renderSlideSvg as renderSlideToSvg, substituteFamily };
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MONO, c as TIMES, d as substituteFamily, i as AVG_GLYPH_W_RATIO, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout, u as isCjk } from "./src-
|
|
1
|
+
import { a as MONO, c as TIMES, d as substituteFamily, i as AVG_GLYPH_W_RATIO, l as defaultMeasurer, n as renderSlideSvg, o as SANS, r as ARIAL, s as SERIF, t as auditTextLayout, u as isCjk } from "./src-B2rbAoIa.js";
|
|
2
2
|
import { getSlideSize } from "@office-kit/pptx";
|
|
3
3
|
import { Resvg } from "@resvg/resvg-js";
|
|
4
4
|
import * as fontkit from "fontkit";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEffectiveColorMap, getGroupChildren, getGroupTransform, getParagraphAlignment, getParagraphBullet, getParagraphBulletImageBytes, getParagraphBulletStyle, getParagraphIndent, getParagraphLevel, getParagraphPropertiesEffective, getParagraphSpacing, getPresentationFonts, getPresentationTheme, getShapeAdjustValues, getShapeAltTitle, getShapeBodyPrEffective, getShapeBoundsResolved, getShapeChartSpec, getShapeClickAction, getShapeCustomGeometry, getShapeDescription, getShapeEffectsEffective, getShapeFillColorResolved, getShapeFillEffective, getShapeFlip, getShapeGradientFill, getShapeGradientFillEffective, getShapeHyperlink, getShapeHyperlinkTooltip, getShapeImageBiLevelThreshold, getShapeImageBrightness, getShapeImageBytes, getShapeImageContrast, getShapeImageCrop, getShapeImageDuotone, getShapeImageFillBytes, getShapeImageFormat, getShapeImageLinkUrl, getShapeImageOpacity, getShapeImagePartName, getShapeKind, getShapeName, getShapeParagraphCount, getShapeParagraphElements, getShapePatternFill, getShapePlaceholderType, getShapePreset, getShapeRotation, getShapeRunClickAction, getShapeRunFormat, getShapeRunFormatEffective, getShapeRunHyperlink, getShapeRunHyperlinkTooltip, getShapeStrokeArrow, getShapeStrokeCap, getShapeStrokeColorResolved, getShapeStrokeCompound, getShapeStrokeDash, getShapeStrokeEffective, getShapeStrokeJoin, getShapeTextAnchor, getShapeTextAutoFitParams, getShapeTextBodyRotationDeg, getShapeTextColumns, getShapeTextDirection, getShapeTextMargins, getShapeXmlString, getSlideBackground, getSlideBackgroundGradientFill, getSlideBackgroundImageBytes, getSlideBackgroundPatternFill, getSlideIndex, getSlideLayout, getSlideLayoutBackground, getSlideLayoutBackgroundGradientFill, getSlideLayoutBackgroundImageBytes, getSlideLayoutBackgroundPatternFill, getSlideLayoutShapes, getSlideMasterBackground, getSlideMasterBackgroundGradientFill, getSlideMasterBackgroundImageBytes, getSlideMasterBackgroundPatternFill, getSlideMasterShapes, getSlideShapes, getSlideSize, getSlides, getTableCellAnchor, getTableCellBorders, getTableCellFill, getTableCellMargins, getTableCellParagraphs, getTableCellSpan, getTableCells, getTableColumnWidths, getTableDimensions, getTableRowHeights, getTableStyleFlags, isChartShape, isParagraphBulletPicture, isShapeImageGrayscale, isShapePlaceholder, isShapeTextBox, isTableShape, resolveDeckBodyTextColor } from "@office-kit/pptx";
|
|
1
|
+
import { getEffectiveColorMap, getGroupChildren, getGroupTransform, getParagraphAlignment, getParagraphBullet, getParagraphBulletImageBytes, getParagraphBulletStyle, getParagraphIndent, getParagraphLevel, getParagraphPropertiesEffective, getParagraphSpacing, getPresentationFonts, getPresentationTheme, getShapeAdjustValues, getShapeAltTitle, getShapeBodyPrEffective, getShapeBoundsResolved, getShapeChartSpec, getShapeClickAction, getShapeCustomGeometry, getShapeDescription, getShapeEffectsEffective, getShapeFillColorResolved, getShapeFillEffective, getShapeFillOpacity, getShapeFlip, getShapeGradientFill, getShapeGradientFillEffective, getShapeHyperlink, getShapeHyperlinkTooltip, getShapeImageBiLevelThreshold, getShapeImageBrightness, getShapeImageBytes, getShapeImageContrast, getShapeImageCrop, getShapeImageDuotone, getShapeImageFillBytes, getShapeImageFormat, getShapeImageLinkUrl, getShapeImageOpacity, getShapeImagePartName, getShapeKind, getShapeName, getShapeParagraphCount, getShapeParagraphElements, getShapePatternFill, getShapePlaceholderType, getShapePreset, getShapeRotation, getShapeRunClickAction, getShapeRunFormat, getShapeRunFormatEffective, getShapeRunHyperlink, getShapeRunHyperlinkTooltip, getShapeStrokeArrow, getShapeStrokeCap, getShapeStrokeColorResolved, getShapeStrokeCompound, getShapeStrokeDash, getShapeStrokeEffective, getShapeStrokeJoin, getShapeStrokeOpacity, getShapeTextAnchor, getShapeTextAutoFitParams, getShapeTextBodyRotationDeg, getShapeTextColumns, getShapeTextDirection, getShapeTextMargins, getShapeXmlString, getSlideBackground, getSlideBackgroundGradientFill, getSlideBackgroundImageBytes, getSlideBackgroundPatternFill, getSlideIndex, getSlideLayout, getSlideLayoutBackground, getSlideLayoutBackgroundGradientFill, getSlideLayoutBackgroundImageBytes, getSlideLayoutBackgroundPatternFill, getSlideLayoutShapes, getSlideMasterBackground, getSlideMasterBackgroundGradientFill, getSlideMasterBackgroundImageBytes, getSlideMasterBackgroundPatternFill, getSlideMasterShapes, getSlideShapes, getSlideSize, getSlides, getTableCellAnchor, getTableCellBorders, getTableCellFill, getTableCellMargins, getTableCellParagraphs, getTableCellSpan, getTableCells, getTableColumnWidths, getTableDimensions, getTableRowHeights, getTableStyleFlags, isChartShape, isParagraphBulletPicture, isShapeImageGrayscale, isShapePlaceholder, isShapeTextBox, isTableShape, resolveDeckBodyTextColor } from "@office-kit/pptx";
|
|
2
2
|
//#region src/emf.ts
|
|
3
3
|
const WORD_BYTES = 4;
|
|
4
4
|
const SHORT_BYTES = 2;
|
|
@@ -1062,11 +1062,14 @@ const buildArrowMarker = (type, width, length, color, orient) => {
|
|
|
1062
1062
|
};
|
|
1063
1063
|
const paint = (shape, fill, stroke, theme, isPlaceholder, pres) => {
|
|
1064
1064
|
let fillColor;
|
|
1065
|
+
let fillAttrs = "";
|
|
1065
1066
|
let defs = "";
|
|
1066
1067
|
if (fill.kind === "solid") {
|
|
1067
1068
|
let resolved = null;
|
|
1068
1069
|
if (shape && pres) resolved = getShapeFillColorResolved(pres, shape);
|
|
1069
1070
|
fillColor = resolved ?? resolveColor(fill.color, theme, "#E5E7EB");
|
|
1071
|
+
const opacity = shape ? getShapeFillOpacity(shape) : null;
|
|
1072
|
+
if (opacity !== null && opacity < 1) fillAttrs = ` fill-opacity="${opacity.toFixed(3)}"`;
|
|
1070
1073
|
} else if (fill.kind === "none") fillColor = "none";
|
|
1071
1074
|
else if (fill.kind === "gradient") {
|
|
1072
1075
|
const grad = shape ? pres ? getShapeGradientFillEffective(pres, shape) : getShapeGradientFill(shape) : null;
|
|
@@ -1094,6 +1097,8 @@ const paint = (shape, fill, stroke, theme, isPlaceholder, pres) => {
|
|
|
1094
1097
|
strokeColor = resolved ?? resolveColor(stroke.color, theme, "#9CA3AF");
|
|
1095
1098
|
strokeWidth = stroke.widthEmu ?? 9525;
|
|
1096
1099
|
if (shape) {
|
|
1100
|
+
const opacity = getShapeStrokeOpacity(shape);
|
|
1101
|
+
if (opacity !== null && opacity < 1) strokeAttrParts.push(`stroke-opacity="${opacity.toFixed(3)}"`);
|
|
1097
1102
|
const dash = getShapeStrokeDash(shape);
|
|
1098
1103
|
if (dash && dash !== "solid") {
|
|
1099
1104
|
const pattern = DASH_PATTERNS[dash];
|
|
@@ -1128,6 +1133,7 @@ const paint = (shape, fill, stroke, theme, isPlaceholder, pres) => {
|
|
|
1128
1133
|
}
|
|
1129
1134
|
return {
|
|
1130
1135
|
fill: fillColor,
|
|
1136
|
+
fillAttrs,
|
|
1131
1137
|
stroke: strokeColor,
|
|
1132
1138
|
strokeWidth,
|
|
1133
1139
|
defs,
|
|
@@ -4293,7 +4299,7 @@ const arcToCubicSegments = (startX, startY, wR, hR, stAng, swAng) => {
|
|
|
4293
4299
|
* Per-path `fill="none"` paints stroke-only; `stroke="0"` paints
|
|
4294
4300
|
* fill-only — mirroring `ST_PathFillMode` / the path `stroke` flag.
|
|
4295
4301
|
*/
|
|
4296
|
-
const customGeometryToSvg = (geom, x, y, w, h, fill, stroke, strokeWidthEmu, strokeExtra, markerExtra) => {
|
|
4302
|
+
const customGeometryToSvg = (geom, x, y, w, h, fill, fillExtra, stroke, strokeWidthEmu, strokeExtra, markerExtra) => {
|
|
4297
4303
|
const out = [];
|
|
4298
4304
|
for (const path of geom.paths) {
|
|
4299
4305
|
const cw = path.w ?? w;
|
|
@@ -4350,8 +4356,9 @@ const customGeometryToSvg = (geom, x, y, w, h, fill, stroke, strokeWidthEmu, str
|
|
|
4350
4356
|
}
|
|
4351
4357
|
if (d.length === 0) continue;
|
|
4352
4358
|
const pathFill = path.fill === "none" ? "none" : fill;
|
|
4359
|
+
const fillAttrs = path.fill === "none" ? "" : fillExtra;
|
|
4353
4360
|
const strokeAttrs = path.stroke ? ` stroke="${stroke}" stroke-width="${E(strokeWidthEmu)}"${strokeExtra}${markerExtra}` : " stroke=\"none\"";
|
|
4354
|
-
out.push(`<path d="${d.join(" ")}" fill="${pathFill}"${strokeAttrs} fill-rule="evenodd"/>`);
|
|
4361
|
+
out.push(`<path d="${d.join(" ")}" fill="${pathFill}"${fillAttrs}${strokeAttrs} fill-rule="evenodd"/>`);
|
|
4355
4362
|
}
|
|
4356
4363
|
return out.join("");
|
|
4357
4364
|
};
|
|
@@ -4495,25 +4502,26 @@ const renderShape = (shape, pres, theme, ctx) => {
|
|
|
4495
4502
|
}
|
|
4496
4503
|
const rawPreset = getShapePreset(shape);
|
|
4497
4504
|
const preset = rawPreset ?? "rect";
|
|
4505
|
+
const fa = p.fillAttrs;
|
|
4498
4506
|
const sa = p.strokeAttrs ? ` ${p.strokeAttrs}` : "";
|
|
4499
4507
|
const ma = p.markerAttrs ?? "";
|
|
4500
4508
|
const customGeom = rawPreset === null ? getShapeCustomGeometry(shape) : null;
|
|
4501
|
-
let geomSvg = customGeom !== null ? customGeometryToSvg(customGeom, x, y, w, h, p.fill, p.stroke, p.strokeWidth, sa, ma) : "";
|
|
4509
|
+
let geomSvg = customGeom !== null ? customGeometryToSvg(customGeom, x, y, w, h, p.fill, fa, p.stroke, p.strokeWidth, sa, ma) : "";
|
|
4502
4510
|
const isCustGeom = geomSvg === "" && rawPreset === null && getShapeXmlString(shape).includes("custGeom");
|
|
4503
|
-
if (geomSvg !== "") {} else if (preset === "rect") geomSvg = `<rect x="${E(x)}" y="${E(y)}" width="${E(w)}" height="${E(h)}" fill="${p.fill}" stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma}/>`;
|
|
4511
|
+
if (geomSvg !== "") {} else if (preset === "rect") geomSvg = `<rect x="${E(x)}" y="${E(y)}" width="${E(w)}" height="${E(h)}" fill="${p.fill}"${fa} stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma}/>`;
|
|
4504
4512
|
else if (preset === "roundRect") {
|
|
4505
4513
|
const adjVal = getShapeAdjustValues(shape).adj ?? 16667;
|
|
4506
4514
|
const ratio = Math.max(0, Math.min(.5, adjVal / 1e5));
|
|
4507
4515
|
const r = E(Math.min(w, h) * ratio);
|
|
4508
|
-
geomSvg = `<rect x="${E(x)}" y="${E(y)}" width="${E(w)}" height="${E(h)}" rx="${r}" ry="${r}" fill="${p.fill}" stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma}/>`;
|
|
4509
|
-
} else if (preset === "ellipse" || preset === "oval") geomSvg = `<ellipse cx="${E(cx)}" cy="${E(cy)}" rx="${E(w / 2)}" ry="${E(h / 2)}" fill="${p.fill}" stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma}/>`;
|
|
4516
|
+
geomSvg = `<rect x="${E(x)}" y="${E(y)}" width="${E(w)}" height="${E(h)}" rx="${r}" ry="${r}" fill="${p.fill}"${fa} stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma}/>`;
|
|
4517
|
+
} else if (preset === "ellipse" || preset === "oval") geomSvg = `<ellipse cx="${E(cx)}" cy="${E(cy)}" rx="${E(w / 2)}" ry="${E(h / 2)}" fill="${p.fill}"${fa} stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma}/>`;
|
|
4510
4518
|
else {
|
|
4511
4519
|
const pathFn = PRESET_PATHS[preset];
|
|
4512
|
-
if (pathFn) geomSvg = `<path d="${pathFn(x / EMU_PER_PX, y / EMU_PER_PX, w / EMU_PER_PX, h / EMU_PER_PX)}" fill="${p.fill}" stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}" fill-rule="evenodd"${sa}${ma}/>`;
|
|
4520
|
+
if (pathFn) geomSvg = `<path d="${pathFn(x / EMU_PER_PX, y / EMU_PER_PX, w / EMU_PER_PX, h / EMU_PER_PX)}" fill="${p.fill}"${fa} stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}" fill-rule="evenodd"${sa}${ma}/>`;
|
|
4513
4521
|
else {
|
|
4514
4522
|
const pointsFn = PRESET_POINTS[preset];
|
|
4515
|
-
if (pointsFn) geomSvg = `<polygon points="${pointsFn(w / EMU_PER_PX, h / EMU_PER_PX).map(([nx, ny]) => `${E(x + nx * w)},${E(y + ny * h)}`).join(" ")}" fill="${p.fill}" stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma}/>`;
|
|
4516
|
-
else geomSvg = `<rect x="${E(x)}" y="${E(y)}" width="${E(w)}" height="${E(h)}" fill="${p.fill}" stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma} data-pptx-preset="${escapeXml(preset)}"><title>${escapeXml(`preset: ${preset}`)}</title></rect>`;
|
|
4523
|
+
if (pointsFn) geomSvg = `<polygon points="${pointsFn(w / EMU_PER_PX, h / EMU_PER_PX).map(([nx, ny]) => `${E(x + nx * w)},${E(y + ny * h)}`).join(" ")}" fill="${p.fill}"${fa} stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma}/>`;
|
|
4524
|
+
else geomSvg = `<rect x="${E(x)}" y="${E(y)}" width="${E(w)}" height="${E(h)}" fill="${p.fill}"${fa} stroke="${p.stroke}" stroke-width="${E(p.strokeWidth)}"${sa}${ma} data-pptx-preset="${escapeXml(preset)}"><title>${escapeXml(`preset: ${preset}`)}</title></rect>`;
|
|
4517
4525
|
}
|
|
4518
4526
|
}
|
|
4519
4527
|
const fx = buildEffectsFilter(pres, shape);
|
|
@@ -4936,4 +4944,4 @@ const auditTextLayout = (pres, options = {}) => {
|
|
|
4936
4944
|
//#endregion
|
|
4937
4945
|
export { MONO as a, TIMES as c, substituteFamily as d, AVG_GLYPH_W_RATIO as i, defaultMeasurer as l, renderSlideSvg as n, SANS as o, ARIAL as r, SERIF as s, auditTextLayout as t, isCjk as u };
|
|
4938
4946
|
|
|
4939
|
-
//# sourceMappingURL=src-
|
|
4947
|
+
//# sourceMappingURL=src-B2rbAoIa.js.map
|