@office-kit/pptx-preview 0.9.2 → 0.9.4
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-DI8o3Vmu.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-DI8o3Vmu.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,
|
|
@@ -3054,7 +3060,7 @@ const approxLegendTextPx = (text, fontPx) => {
|
|
|
3054
3060
|
for (const ch of text) units += FULLWIDTH_CHAR_PATTERN.test(ch) ? 1 : .55;
|
|
3055
3061
|
return units * fontPx;
|
|
3056
3062
|
};
|
|
3057
|
-
const renderChartLegend = (f, names, colors, position = "b", textStyle,
|
|
3063
|
+
const renderChartLegend = (f, names, colors, position = "b", textStyle, markers) => {
|
|
3058
3064
|
if (names.length === 0) return "";
|
|
3059
3065
|
const sz = textStyle?.sizePt ?? 11;
|
|
3060
3066
|
const fill = textStyle?.color ?? "#374151";
|
|
@@ -3063,10 +3069,10 @@ const renderChartLegend = (f, names, colors, position = "b", textStyle, markerSy
|
|
|
3063
3069
|
const textAttrs = `font-family="sans-serif" font-size="${chartFontPx(sz)}" fill="${fill}"${weight}${italic}`;
|
|
3064
3070
|
const swatch = (i, swatchX, swatchY) => {
|
|
3065
3071
|
const color = colors[i % colors.length];
|
|
3066
|
-
const
|
|
3067
|
-
if (
|
|
3072
|
+
const marker = markers?.[i];
|
|
3073
|
+
if (marker !== void 0 && marker.markerSymbol !== "none") {
|
|
3068
3074
|
const r = 4.5;
|
|
3069
|
-
return seriesMarker(autoMarkerSymbol(
|
|
3075
|
+
return seriesMarker(autoMarkerSymbol(marker.markerSymbol, i), swatchX + r, swatchY + r, r, ...markerColors(marker, color));
|
|
3070
3076
|
}
|
|
3071
3077
|
return `<rect x="${px(swatchX)}" y="${px(swatchY)}" width="9" height="9" fill="${color}"/>`;
|
|
3072
3078
|
};
|
|
@@ -3302,11 +3308,12 @@ const AUTO_MARKER_SYMBOLS = [
|
|
|
3302
3308
|
"dash"
|
|
3303
3309
|
];
|
|
3304
3310
|
const autoMarkerSymbol = (symbol, seriesIdx) => symbol !== void 0 && symbol !== "auto" ? symbol : AUTO_MARKER_SYMBOLS[seriesIdx % AUTO_MARKER_SYMBOLS.length];
|
|
3305
|
-
const seriesMarker = (symbol, cx, cy, r, color) => {
|
|
3311
|
+
const seriesMarker = (symbol, cx, cy, r, color, lineColor = color) => {
|
|
3312
|
+
const paint = lineColor === color ? `fill="${color}"` : `fill="${color}" stroke="${lineColor}" stroke-width="1"`;
|
|
3306
3313
|
switch (symbol) {
|
|
3307
|
-
case "square": return `<rect x="${px(cx - r)}" y="${px(cy - r)}" width="${px(r * 2)}" height="${px(r * 2)}"
|
|
3308
|
-
case "diamond": return `<polygon points="${px(cx)},${px(cy - r)} ${px(cx + r)},${px(cy)} ${px(cx)},${px(cy + r)} ${px(cx - r)},${px(cy)}"
|
|
3309
|
-
case "triangle": return `<polygon points="${px(cx)},${px(cy - r)} ${px(cx + r)},${px(cy + r)} ${px(cx - r)},${px(cy + r)}"
|
|
3314
|
+
case "square": return `<rect x="${px(cx - r)}" y="${px(cy - r)}" width="${px(r * 2)}" height="${px(r * 2)}" ${paint}/>`;
|
|
3315
|
+
case "diamond": return `<polygon points="${px(cx)},${px(cy - r)} ${px(cx + r)},${px(cy)} ${px(cx)},${px(cy + r)} ${px(cx - r)},${px(cy)}" ${paint}/>`;
|
|
3316
|
+
case "triangle": return `<polygon points="${px(cx)},${px(cy - r)} ${px(cx + r)},${px(cy + r)} ${px(cx - r)},${px(cy + r)}" ${paint}/>`;
|
|
3310
3317
|
case "star": return `<polygon points="${(() => {
|
|
3311
3318
|
const pts = [];
|
|
3312
3319
|
for (let i = 0; i < 10; i++) {
|
|
@@ -3315,14 +3322,18 @@ const seriesMarker = (symbol, cx, cy, r, color) => {
|
|
|
3315
3322
|
pts.push(`${px(cx + rr * Math.cos(ang))},${px(cy + rr * Math.sin(ang))}`);
|
|
3316
3323
|
}
|
|
3317
3324
|
return pts.join(" ");
|
|
3318
|
-
})()}"
|
|
3319
|
-
case "x": return `<g stroke="${
|
|
3320
|
-
case "plus": return `<g stroke="${
|
|
3321
|
-
case "dash": return `<line x1="${px(cx - r)}" y1="${px(cy)}" x2="${px(cx + r)}" y2="${px(cy)}" stroke="${
|
|
3322
|
-
case "dot": return `<circle cx="${px(cx)}" cy="${px(cy)}" r="${(r * .6).toFixed(2)}"
|
|
3323
|
-
default: return `<circle cx="${px(cx)}" cy="${px(cy)}" r="${px(r)}"
|
|
3325
|
+
})()}" ${paint}/>`;
|
|
3326
|
+
case "x": return `<g stroke="${lineColor}" stroke-width="1.2" stroke-linecap="round"><line x1="${px(cx - r)}" y1="${px(cy - r)}" x2="${px(cx + r)}" y2="${px(cy + r)}"/><line x1="${px(cx - r)}" y1="${px(cy + r)}" x2="${px(cx + r)}" y2="${px(cy - r)}"/></g>`;
|
|
3327
|
+
case "plus": return `<g stroke="${lineColor}" stroke-width="1.2" stroke-linecap="round"><line x1="${px(cx - r)}" y1="${px(cy)}" x2="${px(cx + r)}" y2="${px(cy)}"/><line x1="${px(cx)}" y1="${px(cy - r)}" x2="${px(cx)}" y2="${px(cy + r)}"/></g>`;
|
|
3328
|
+
case "dash": return `<line x1="${px(cx - r)}" y1="${px(cy)}" x2="${px(cx + r)}" y2="${px(cy)}" stroke="${lineColor}" stroke-width="${Math.max(1.5, r * .6).toFixed(2)}" stroke-linecap="round"/>`;
|
|
3329
|
+
case "dot": return `<circle cx="${px(cx)}" cy="${px(cy)}" r="${(r * .6).toFixed(2)}" ${paint}/>`;
|
|
3330
|
+
default: return `<circle cx="${px(cx)}" cy="${px(cy)}" r="${px(r)}" ${paint}/>`;
|
|
3324
3331
|
}
|
|
3325
3332
|
};
|
|
3333
|
+
const markerColors = (series, seriesColor) => {
|
|
3334
|
+
const fill = series.markerColor ?? seriesColor;
|
|
3335
|
+
return [fill, series.markerLineColor ?? fill];
|
|
3336
|
+
};
|
|
3326
3337
|
const formatChartValue = (v) => {
|
|
3327
3338
|
if (!Number.isFinite(v)) return "";
|
|
3328
3339
|
if (Number.isInteger(v)) return String(v);
|
|
@@ -3512,14 +3523,14 @@ const renderLineChart = (f, spec, colors, fill) => {
|
|
|
3512
3523
|
if (!pat) return "";
|
|
3513
3524
|
return ` stroke-dasharray="${pat.split(" ").map((n) => (Number.parseFloat(n) * sw).toFixed(2)).join(" ")}"`;
|
|
3514
3525
|
})() : "";
|
|
3515
|
-
out.push(`<path d="${dPath}" fill="none" stroke="${color}" stroke-width="${lineWPx.toFixed(2)}" stroke-linejoin="round" stroke-linecap="round"${dashAttr}/>`);
|
|
3526
|
+
out.push(`<path d="${dPath}" fill="none" stroke="${series.lineColor ?? color}" stroke-width="${lineWPx.toFixed(2)}" stroke-linejoin="round" stroke-linecap="round"${dashAttr}/>`);
|
|
3516
3527
|
if (!isStacked) {
|
|
3517
3528
|
const explicitSymbol = series.markerSymbol !== void 0 && series.markerSymbol !== "auto" && series.markerSymbol !== "none";
|
|
3518
3529
|
if (series.markerSymbol !== "none" && !fill && (spec.lineMarkers === true || explicitSymbol)) {
|
|
3519
3530
|
const symbol = autoMarkerSymbol(series.markerSymbol, s);
|
|
3520
3531
|
const size = series.markerSizePt ?? 5;
|
|
3521
3532
|
const r = Math.max(1, size * .5);
|
|
3522
|
-
for (const [xp, yp] of pts) out.push(seriesMarker(symbol, xp, yp, r, color));
|
|
3533
|
+
for (const [xp, yp] of pts) out.push(seriesMarker(symbol, xp, yp, r, ...markerColors(series, color)));
|
|
3523
3534
|
}
|
|
3524
3535
|
}
|
|
3525
3536
|
if (series.dataLabels?.showValue ?? spec.dataLabels?.showValue ?? false) {
|
|
@@ -3754,13 +3765,14 @@ const renderScatterChart = (f, spec, colors) => {
|
|
|
3754
3765
|
if (showLine && proj.length >= 2) {
|
|
3755
3766
|
const d = smooth && proj.length > 2 ? smoothPath(proj) : proj.map(([xp, yp], i) => `${i === 0 ? "M" : "L"}${px(xp)},${px(yp)}`).join(" ");
|
|
3756
3767
|
const lineWPx = series.lineWidthEmu ? Math.max(.3, series.lineWidthEmu / EMU_PER_PX) : 1.5;
|
|
3757
|
-
out.push(`<path d="${d}" fill="none" stroke="${color}" stroke-width="${lineWPx.toFixed(2)}" stroke-linejoin="round" stroke-linecap="round"/>`);
|
|
3768
|
+
out.push(`<path d="${d}" fill="none" stroke="${series.lineColor ?? color}" stroke-width="${lineWPx.toFixed(2)}" stroke-linejoin="round" stroke-linecap="round"/>`);
|
|
3758
3769
|
}
|
|
3759
3770
|
const sym = series.markerSymbol;
|
|
3760
3771
|
if (sym === "none" ? false : showMarker || sym !== void 0 && sym !== "auto") {
|
|
3761
3772
|
const r = Math.max(1.5, (series.markerSizePt ?? 5) * .5);
|
|
3762
3773
|
const glyph = autoMarkerSymbol(sym, s);
|
|
3763
|
-
|
|
3774
|
+
const [markerFill, markerLine] = markerColors(series, color);
|
|
3775
|
+
for (const [xp, yp] of proj) out.push(seriesMarker(glyph, xp, yp, r, markerFill, markerLine));
|
|
3764
3776
|
}
|
|
3765
3777
|
}
|
|
3766
3778
|
return out.join("");
|
|
@@ -3861,11 +3873,12 @@ const renderRadarChart = (f, spec, colors) => {
|
|
|
3861
3873
|
if (proj.length < 2) continue;
|
|
3862
3874
|
const ptsStr = proj.map(([xp, yp]) => `${px(xp)},${px(yp)}`).join(" ");
|
|
3863
3875
|
const lineWPx = series.lineWidthEmu ? Math.max(.3, series.lineWidthEmu / EMU_PER_PX) : 1.8;
|
|
3864
|
-
out.push(filled ? `<polygon points="${ptsStr}" fill="${color}" fill-opacity="0.3" stroke="${color}" stroke-width="${lineWPx.toFixed(2)}" stroke-linejoin="round"/>` : `<polygon points="${ptsStr}" fill="none" stroke="${color}" stroke-width="${lineWPx.toFixed(2)}" stroke-linejoin="round"/>`);
|
|
3876
|
+
out.push(filled ? `<polygon points="${ptsStr}" fill="${color}" fill-opacity="0.3" stroke="${series.lineColor ?? color}" stroke-width="${lineWPx.toFixed(2)}" stroke-linejoin="round"/>` : `<polygon points="${ptsStr}" fill="none" stroke="${series.lineColor ?? color}" stroke-width="${lineWPx.toFixed(2)}" stroke-linejoin="round"/>`);
|
|
3865
3877
|
if (showMarker) {
|
|
3866
3878
|
const r = Math.max(1.5, (series.markerSizePt ?? 5) * .5);
|
|
3867
3879
|
const glyph = autoMarkerSymbol(series.markerSymbol, s);
|
|
3868
|
-
|
|
3880
|
+
const [markerFill, markerLine] = markerColors(series, color);
|
|
3881
|
+
for (const [xp, yp] of proj) out.push(seriesMarker(glyph, xp, yp, r, markerFill, markerLine));
|
|
3869
3882
|
}
|
|
3870
3883
|
}
|
|
3871
3884
|
return out.join("");
|
|
@@ -3889,7 +3902,7 @@ const renderChart = (shape, x, y, w, h, transform, theme) => {
|
|
|
3889
3902
|
const seriesNamesForLegend = allNamesForLegend.filter((_, i) => !hiddenSet.has(i));
|
|
3890
3903
|
const seriesColorsForLegend = allColorsForLegend.filter((_, i) => !hiddenSet.has(i));
|
|
3891
3904
|
const explicitMarker = (sym) => sym !== void 0 && sym !== "auto" && sym !== "none";
|
|
3892
|
-
const
|
|
3905
|
+
const markersForLegend = spec.kind === "line" && (spec.lineMarkers === true || spec.series.some((s) => explicitMarker(s.markerSymbol))) ? spec.series.filter((_, i) => !hiddenSet.has(i)) : void 0;
|
|
3893
3906
|
let finiteCount = 0;
|
|
3894
3907
|
for (const s of spec.series) for (const v of s.values) if (v !== null && Number.isFinite(v)) finiteCount++;
|
|
3895
3908
|
let plot = "";
|
|
@@ -4046,7 +4059,7 @@ const renderChart = (shape, x, y, w, h, transform, theme) => {
|
|
|
4046
4059
|
categoryAxisTitleSvg,
|
|
4047
4060
|
plot,
|
|
4048
4061
|
emptyHint,
|
|
4049
|
-
hasLegend ? renderChartLegend(f, seriesNamesForLegend, seriesColorsForLegend, spec.legend?.position ?? "b", spec.legend?.textStyle,
|
|
4062
|
+
hasLegend ? renderChartLegend(f, seriesNamesForLegend, seriesColorsForLegend, spec.legend?.position ?? "b", spec.legend?.textStyle, markersForLegend) : "",
|
|
4050
4063
|
"</g>"
|
|
4051
4064
|
].join("");
|
|
4052
4065
|
};
|
|
@@ -4293,7 +4306,7 @@ const arcToCubicSegments = (startX, startY, wR, hR, stAng, swAng) => {
|
|
|
4293
4306
|
* Per-path `fill="none"` paints stroke-only; `stroke="0"` paints
|
|
4294
4307
|
* fill-only — mirroring `ST_PathFillMode` / the path `stroke` flag.
|
|
4295
4308
|
*/
|
|
4296
|
-
const customGeometryToSvg = (geom, x, y, w, h, fill, stroke, strokeWidthEmu, strokeExtra, markerExtra) => {
|
|
4309
|
+
const customGeometryToSvg = (geom, x, y, w, h, fill, fillExtra, stroke, strokeWidthEmu, strokeExtra, markerExtra) => {
|
|
4297
4310
|
const out = [];
|
|
4298
4311
|
for (const path of geom.paths) {
|
|
4299
4312
|
const cw = path.w ?? w;
|
|
@@ -4350,8 +4363,9 @@ const customGeometryToSvg = (geom, x, y, w, h, fill, stroke, strokeWidthEmu, str
|
|
|
4350
4363
|
}
|
|
4351
4364
|
if (d.length === 0) continue;
|
|
4352
4365
|
const pathFill = path.fill === "none" ? "none" : fill;
|
|
4366
|
+
const fillAttrs = path.fill === "none" ? "" : fillExtra;
|
|
4353
4367
|
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"/>`);
|
|
4368
|
+
out.push(`<path d="${d.join(" ")}" fill="${pathFill}"${fillAttrs}${strokeAttrs} fill-rule="evenodd"/>`);
|
|
4355
4369
|
}
|
|
4356
4370
|
return out.join("");
|
|
4357
4371
|
};
|
|
@@ -4495,25 +4509,26 @@ const renderShape = (shape, pres, theme, ctx) => {
|
|
|
4495
4509
|
}
|
|
4496
4510
|
const rawPreset = getShapePreset(shape);
|
|
4497
4511
|
const preset = rawPreset ?? "rect";
|
|
4512
|
+
const fa = p.fillAttrs;
|
|
4498
4513
|
const sa = p.strokeAttrs ? ` ${p.strokeAttrs}` : "";
|
|
4499
4514
|
const ma = p.markerAttrs ?? "";
|
|
4500
4515
|
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) : "";
|
|
4516
|
+
let geomSvg = customGeom !== null ? customGeometryToSvg(customGeom, x, y, w, h, p.fill, fa, p.stroke, p.strokeWidth, sa, ma) : "";
|
|
4502
4517
|
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}/>`;
|
|
4518
|
+
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
4519
|
else if (preset === "roundRect") {
|
|
4505
4520
|
const adjVal = getShapeAdjustValues(shape).adj ?? 16667;
|
|
4506
4521
|
const ratio = Math.max(0, Math.min(.5, adjVal / 1e5));
|
|
4507
4522
|
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}/>`;
|
|
4523
|
+
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}/>`;
|
|
4524
|
+
} 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
4525
|
else {
|
|
4511
4526
|
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}/>`;
|
|
4527
|
+
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
4528
|
else {
|
|
4514
4529
|
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>`;
|
|
4530
|
+
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}/>`;
|
|
4531
|
+
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
4532
|
}
|
|
4518
4533
|
}
|
|
4519
4534
|
const fx = buildEffectsFilter(pres, shape);
|
|
@@ -4936,4 +4951,4 @@ const auditTextLayout = (pres, options = {}) => {
|
|
|
4936
4951
|
//#endregion
|
|
4937
4952
|
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
4953
|
|
|
4939
|
-
//# sourceMappingURL=src-
|
|
4954
|
+
//# sourceMappingURL=src-DI8o3Vmu.js.map
|