pptx-react-viewer 4.64.1 → 4.66.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/CHANGELOG.md +65 -0
- package/dist/{AiChatPanel-7AFFNYEN.js → AiChatPanel-DL7EBR2V.js} +19 -19
- package/dist/AiChatPanel-DL7EBR2V.js.br +0 -0
- package/dist/AiChatPanel-DL7EBR2V.js.gz +0 -0
- package/dist/{AiChatPanel-7U7IJRNY.mjs → AiChatPanel-JKWJQX4N.mjs} +1 -1
- package/dist/AiChatPanel-JKWJQX4N.mjs.br +0 -0
- package/dist/AiChatPanel-JKWJQX4N.mjs.gz +0 -0
- package/dist/ai.js +2 -2
- package/dist/ai.js.br +2 -1
- package/dist/ai.js.gz +0 -0
- package/dist/ai.mjs +1 -1
- package/dist/ai.mjs.br +0 -0
- package/dist/ai.mjs.gz +0 -0
- package/dist/{chunk-5DBKW7F3.js → chunk-73S5EOD3.js} +67 -735
- package/dist/chunk-73S5EOD3.js.br +0 -0
- package/dist/chunk-73S5EOD3.js.gz +0 -0
- package/dist/{chunk-5ZW3GP6C.mjs → chunk-A4K2TM2K.mjs} +68 -737
- package/dist/chunk-A4K2TM2K.mjs.br +0 -0
- package/dist/chunk-A4K2TM2K.mjs.gz +0 -0
- package/dist/{chunk-HZBEKG5R.mjs → chunk-DORVZDQT.mjs} +17 -6
- package/dist/chunk-DORVZDQT.mjs.br +0 -0
- package/dist/chunk-DORVZDQT.mjs.gz +0 -0
- package/dist/{chunk-GXL2XMST.js → chunk-QLXYEA54.js} +572 -561
- package/dist/chunk-QLXYEA54.js.br +0 -0
- package/dist/chunk-QLXYEA54.js.gz +0 -0
- package/dist/{chunk-WAIX4VJ2.mjs → chunk-SLFVXZHA.mjs} +1 -1
- package/dist/chunk-SLFVXZHA.mjs.br +0 -0
- package/dist/chunk-SLFVXZHA.mjs.gz +0 -0
- package/dist/{chunk-PNDORR6S.js → chunk-UC57KUGO.js} +1 -1
- package/dist/chunk-UC57KUGO.js.br +0 -0
- package/dist/chunk-UC57KUGO.js.gz +0 -0
- package/dist/{chunk-VGU5S37T.js → chunk-YQ67KAQR.js} +318 -329
- package/dist/chunk-YQ67KAQR.js.br +0 -0
- package/dist/chunk-YQ67KAQR.js.gz +0 -0
- package/dist/{chunk-G5JGUSBL.mjs → chunk-ZRU67AVX.mjs} +122 -133
- package/dist/chunk-ZRU67AVX.mjs.br +0 -0
- package/dist/chunk-ZRU67AVX.mjs.gz +0 -0
- package/dist/i18n/de.cjs +5 -0
- package/dist/i18n/de.cjs.br +0 -0
- package/dist/i18n/de.cjs.gz +0 -0
- package/dist/i18n/de.mjs +5 -0
- package/dist/i18n/de.mjs.br +0 -0
- package/dist/i18n/de.mjs.gz +0 -0
- package/dist/i18n/es.cjs +5 -0
- package/dist/i18n/es.cjs.br +0 -0
- package/dist/i18n/es.cjs.gz +0 -0
- package/dist/i18n/es.mjs +5 -0
- package/dist/i18n/es.mjs.br +0 -0
- package/dist/i18n/es.mjs.gz +0 -0
- package/dist/i18n/fr.cjs +5 -0
- package/dist/i18n/fr.cjs.br +0 -0
- package/dist/i18n/fr.cjs.gz +0 -0
- package/dist/i18n/fr.mjs +5 -0
- package/dist/i18n/fr.mjs.br +0 -0
- package/dist/i18n/fr.mjs.gz +0 -0
- package/dist/i18n/zh-CN.cjs +5 -0
- package/dist/i18n/zh-CN.cjs.br +0 -0
- package/dist/i18n/zh-CN.cjs.gz +0 -0
- package/dist/i18n/zh-CN.mjs +5 -0
- package/dist/i18n/zh-CN.mjs.br +0 -0
- package/dist/i18n/zh-CN.mjs.gz +0 -0
- package/dist/index.js +27 -27
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.br +0 -0
- package/dist/index.mjs.gz +0 -0
- package/dist/internals.js +81 -81
- package/dist/internals.js.br +0 -0
- package/dist/internals.js.gz +0 -0
- package/dist/internals.mjs +2 -2
- package/dist/internals.mjs.br +0 -0
- package/dist/internals.mjs.gz +0 -0
- package/dist/viewer/index.js +21 -21
- package/dist/viewer/index.js.br +0 -0
- package/dist/viewer/index.js.gz +0 -0
- package/dist/viewer/index.mjs +4 -4
- package/dist/viewer/index.mjs.br +0 -0
- package/dist/viewer/index.mjs.gz +0 -0
- package/package.json +3 -3
- package/dist/AiChatPanel-7AFFNYEN.js.br +0 -0
- package/dist/AiChatPanel-7AFFNYEN.js.gz +0 -0
- package/dist/AiChatPanel-7U7IJRNY.mjs.br +0 -0
- package/dist/AiChatPanel-7U7IJRNY.mjs.gz +0 -0
- package/dist/chunk-5DBKW7F3.js.br +0 -0
- package/dist/chunk-5DBKW7F3.js.gz +0 -0
- package/dist/chunk-5ZW3GP6C.mjs.br +0 -0
- package/dist/chunk-5ZW3GP6C.mjs.gz +0 -0
- package/dist/chunk-G5JGUSBL.mjs.br +0 -0
- package/dist/chunk-G5JGUSBL.mjs.gz +0 -0
- package/dist/chunk-GXL2XMST.js.br +0 -0
- package/dist/chunk-GXL2XMST.js.gz +0 -0
- package/dist/chunk-HZBEKG5R.mjs.br +0 -0
- package/dist/chunk-HZBEKG5R.mjs.gz +0 -0
- package/dist/chunk-PNDORR6S.js.br +0 -0
- package/dist/chunk-PNDORR6S.js.gz +0 -0
- package/dist/chunk-VGU5S37T.js.br +0 -0
- package/dist/chunk-VGU5S37T.js.gz +0 -0
- package/dist/chunk-WAIX4VJ2.mjs.br +0 -0
- package/dist/chunk-WAIX4VJ2.mjs.gz +0 -0
|
@@ -60,7 +60,6 @@ function cloneHistorySnapshot(snapshot) {
|
|
|
60
60
|
var DEFAULT_CANVAS_WIDTH = 1280;
|
|
61
61
|
var DEFAULT_CANVAS_HEIGHT = 720;
|
|
62
62
|
var MIN_ELEMENT_SIZE = 12;
|
|
63
|
-
var EMU_PER_PX = 9525;
|
|
64
63
|
var DEFAULT_BODY_INSET_TB_PX = 45720 / 9525;
|
|
65
64
|
var DEFAULT_TEXT_COLOR = "#111827";
|
|
66
65
|
var DEFAULT_FILL_COLOR = "#3b82f6";
|
|
@@ -330,12 +329,6 @@ function shouldRenderFallbackLabel(element, isTextElement) {
|
|
|
330
329
|
}
|
|
331
330
|
return element.type === "chart" || element.type === "smartArt" || element.type === "unknown";
|
|
332
331
|
}
|
|
333
|
-
function ensureArrayValue(value) {
|
|
334
|
-
if (!value) {
|
|
335
|
-
return [];
|
|
336
|
-
}
|
|
337
|
-
return Array.isArray(value) ? value : [value];
|
|
338
|
-
}
|
|
339
332
|
function buildTrimFragment(element) {
|
|
340
333
|
const start = element.trimStartMs;
|
|
341
334
|
if (start === void 0 || start <= 0) {
|
|
@@ -471,6 +464,31 @@ function AudioWithMetadata({
|
|
|
471
464
|
}
|
|
472
465
|
) });
|
|
473
466
|
}
|
|
467
|
+
function useMediaControlBar(mediaRef, enabled, selected) {
|
|
468
|
+
const { t } = useTranslation();
|
|
469
|
+
const barRef = React8.useRef(null);
|
|
470
|
+
const selectedRef = React8.useRef(selected);
|
|
471
|
+
selectedRef.current = selected;
|
|
472
|
+
React8.useEffect(() => {
|
|
473
|
+
const media = mediaRef.current;
|
|
474
|
+
if (!enabled || !media) {
|
|
475
|
+
return void 0;
|
|
476
|
+
}
|
|
477
|
+
const host = media.closest("[data-pptx-element]") ?? media.parentElement ?? void 0;
|
|
478
|
+
if (!host) {
|
|
479
|
+
return void 0;
|
|
480
|
+
}
|
|
481
|
+
const bar = pptx.attachMediaControlBar(host, media, { t, selected: selectedRef.current });
|
|
482
|
+
barRef.current = bar;
|
|
483
|
+
return () => {
|
|
484
|
+
bar.dispose();
|
|
485
|
+
barRef.current = null;
|
|
486
|
+
};
|
|
487
|
+
}, [mediaRef, enabled, t]);
|
|
488
|
+
React8.useEffect(() => {
|
|
489
|
+
barRef.current?.setSelected(selected);
|
|
490
|
+
}, [selected]);
|
|
491
|
+
}
|
|
474
492
|
function PresentationMediaController({
|
|
475
493
|
element,
|
|
476
494
|
isPresentationMode,
|
|
@@ -478,11 +496,13 @@ function PresentationMediaController({
|
|
|
478
496
|
resolvedDataUrl,
|
|
479
497
|
isFullScreen,
|
|
480
498
|
onPlayStateChange,
|
|
499
|
+
controlBar,
|
|
481
500
|
children
|
|
482
501
|
}) {
|
|
483
502
|
const { t } = useTranslation();
|
|
484
503
|
const mediaRef = React8.useRef(null);
|
|
485
504
|
const [isMediaPlaying, setIsMediaPlaying] = React8.useState(false);
|
|
505
|
+
useMediaControlBar(mediaRef, controlBar !== void 0, controlBar?.selected === true);
|
|
486
506
|
const trimStartSec = element.trimStartMs !== void 0 ? element.trimStartMs / 1e3 : 0;
|
|
487
507
|
const hideWhenNotPlaying = isPresentationMode && element.hideWhenNotPlaying === true;
|
|
488
508
|
const { volume: playbackVolume, playbackRate } = pptx.mediaPlaybackAttributes({
|
|
@@ -754,6 +774,7 @@ function renderMediaElement(element, mediaDataUrls, options) {
|
|
|
754
774
|
resolvedDataUrl: dataUrl,
|
|
755
775
|
isFullScreen,
|
|
756
776
|
onPlayStateChange: options?.onPlayStateChange,
|
|
777
|
+
controlBar: options?.controlBar,
|
|
757
778
|
children: ({ mediaRef, onPlay }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
758
779
|
VideoWithMetadata,
|
|
759
780
|
{
|
|
@@ -787,6 +808,7 @@ function renderMediaElement(element, mediaDataUrls, options) {
|
|
|
787
808
|
resolvedDataUrl: dataUrl,
|
|
788
809
|
isFullScreen: false,
|
|
789
810
|
onPlayStateChange: options?.onPlayStateChange,
|
|
811
|
+
controlBar: options?.controlBar,
|
|
790
812
|
children: ({ mediaRef, onPlay }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
791
813
|
AudioWithMetadata,
|
|
792
814
|
{
|
|
@@ -1395,6 +1417,9 @@ function renderParagraphRun(run, segment, ctx, keySuffix = "") {
|
|
|
1395
1417
|
typeof run.style.fontSize === "string" ? run.style.fontSize : void 0
|
|
1396
1418
|
);
|
|
1397
1419
|
}
|
|
1420
|
+
if (run.text === "\n" && !run.hyperlink && !run.ruby && !findHighlights?.get(segmentIndex)) {
|
|
1421
|
+
return /* @__PURE__ */ jsxRuntime.jsx("br", { "data-seg-idx": segmentIndex }, key);
|
|
1422
|
+
}
|
|
1398
1423
|
const segmentStyle = segment?.style ?? {};
|
|
1399
1424
|
const textValue = run.text;
|
|
1400
1425
|
const lines = textValue.split("\n");
|
|
@@ -1963,7 +1988,17 @@ function renderSvgGradientDefs(gradient) {
|
|
|
1963
1988
|
return null;
|
|
1964
1989
|
}
|
|
1965
1990
|
if (gradient.kind === "rectPath") {
|
|
1966
|
-
return /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1991
|
+
return /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1992
|
+
"pattern",
|
|
1993
|
+
{
|
|
1994
|
+
id: gradient.id,
|
|
1995
|
+
patternUnits: "objectBoundingBox",
|
|
1996
|
+
patternContentUnits: "objectBoundingBox",
|
|
1997
|
+
width: 1,
|
|
1998
|
+
height: 1,
|
|
1999
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("image", { href: gradient.href, x: 0, y: 0, width: 1, height: 1, preserveAspectRatio: "none" })
|
|
2000
|
+
}
|
|
2001
|
+
) });
|
|
1967
2002
|
}
|
|
1968
2003
|
const stops = gradient.stops.map((stop, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1969
2004
|
"stop",
|
|
@@ -1997,7 +2032,7 @@ function strokeContext(shapeStyle, strokePaint, strokeWidth, dashArray) {
|
|
|
1997
2032
|
strokePaint,
|
|
1998
2033
|
strokeWidth,
|
|
1999
2034
|
dashArray,
|
|
2000
|
-
lineCap: pptx.svgLineCap(shapeStyle?.lineCap),
|
|
2035
|
+
lineCap: pptx.svgLineCap(shapeStyle?.lineCap, dashArray !== void 0),
|
|
2001
2036
|
lineJoin,
|
|
2002
2037
|
miterLimit,
|
|
2003
2038
|
offsets: pptx.getCompoundLineOffsets(shapeStyle?.compoundLine, strokeWidth),
|
|
@@ -2005,10 +2040,11 @@ function strokeContext(shapeStyle, strokePaint, strokeWidth, dashArray) {
|
|
|
2005
2040
|
};
|
|
2006
2041
|
}
|
|
2007
2042
|
function strokeStrands(d, keyBase, ctx) {
|
|
2043
|
+
const strokeD = ctx.dashArray === void 0 ? d : pptx.dashStartPathData(d);
|
|
2008
2044
|
return ctx.offsets.map((offset, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2009
2045
|
"path",
|
|
2010
2046
|
{
|
|
2011
|
-
d,
|
|
2047
|
+
d: strokeD,
|
|
2012
2048
|
fill: "none",
|
|
2013
2049
|
stroke: ctx.strokePaint,
|
|
2014
2050
|
strokeWidth: Math.max(ctx.widths[idx] ?? ctx.strokeWidth, 1),
|
|
@@ -2099,70 +2135,9 @@ function renderVectorShape(element, hasFill, fillColor, strokeWidth, strokeColor
|
|
|
2099
2135
|
const dashArray = pptx.getSvgStrokeDasharray(
|
|
2100
2136
|
dashType,
|
|
2101
2137
|
Math.max(strokeWidth, 1),
|
|
2102
|
-
element.shapeStyle?.customDashSegments
|
|
2138
|
+
element.shapeStyle?.customDashSegments,
|
|
2139
|
+
element.shapeStyle?.lineCap
|
|
2103
2140
|
);
|
|
2104
|
-
if (normalizedType === "can" || normalizedType === "cylinder") {
|
|
2105
|
-
const width = Math.max(element.width, 1);
|
|
2106
|
-
const height = Math.max(element.height, 1);
|
|
2107
|
-
const rim = Math.max(Math.min(height * 0.16, 28), 6);
|
|
2108
|
-
const stroke = Math.max(strokeWidth, 1);
|
|
2109
|
-
const screenStroke = { strokeWidth: pptx.screenStrokeWidth(stroke) };
|
|
2110
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2111
|
-
"svg",
|
|
2112
|
-
{
|
|
2113
|
-
viewBox: `0 0 ${width} ${height}`,
|
|
2114
|
-
className: "w-full h-full pointer-events-none",
|
|
2115
|
-
preserveAspectRatio: "none",
|
|
2116
|
-
children: [
|
|
2117
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2118
|
-
"ellipse",
|
|
2119
|
-
{
|
|
2120
|
-
cx: width / 2,
|
|
2121
|
-
cy: rim / 2,
|
|
2122
|
-
rx: width / 2,
|
|
2123
|
-
ry: rim / 2,
|
|
2124
|
-
fill: hasFill ? fillPaint : "none",
|
|
2125
|
-
stroke: strokeWidth > 0 ? strokePaint : "none",
|
|
2126
|
-
strokeWidth: stroke,
|
|
2127
|
-
strokeDasharray: dashArray,
|
|
2128
|
-
vectorEffect: "non-scaling-stroke",
|
|
2129
|
-
style: screenStroke
|
|
2130
|
-
}
|
|
2131
|
-
),
|
|
2132
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2133
|
-
"rect",
|
|
2134
|
-
{
|
|
2135
|
-
x: 0,
|
|
2136
|
-
y: rim / 2,
|
|
2137
|
-
width,
|
|
2138
|
-
height: Math.max(height - rim, 1),
|
|
2139
|
-
fill: hasFill ? fillPaint : "none",
|
|
2140
|
-
stroke: strokeWidth > 0 ? strokePaint : "none",
|
|
2141
|
-
strokeWidth: stroke,
|
|
2142
|
-
strokeDasharray: dashArray,
|
|
2143
|
-
vectorEffect: "non-scaling-stroke",
|
|
2144
|
-
style: screenStroke
|
|
2145
|
-
}
|
|
2146
|
-
),
|
|
2147
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2148
|
-
"ellipse",
|
|
2149
|
-
{
|
|
2150
|
-
cx: width / 2,
|
|
2151
|
-
cy: height - rim / 2,
|
|
2152
|
-
rx: width / 2,
|
|
2153
|
-
ry: rim / 2,
|
|
2154
|
-
fill: hasFill ? fillPaint : "none",
|
|
2155
|
-
stroke: strokeWidth > 0 ? strokePaint : "none",
|
|
2156
|
-
strokeWidth: stroke,
|
|
2157
|
-
strokeDasharray: dashArray,
|
|
2158
|
-
vectorEffect: "non-scaling-stroke",
|
|
2159
|
-
style: screenStroke
|
|
2160
|
-
}
|
|
2161
|
-
)
|
|
2162
|
-
]
|
|
2163
|
-
}
|
|
2164
|
-
);
|
|
2165
|
-
}
|
|
2166
2141
|
if ((element.type === "shape" || element.type === "image" || element.type === "picture") && element.pathData && element.pathWidth && element.pathHeight && element.pathWidth > 0 && element.pathHeight > 0) {
|
|
2167
2142
|
return renderCustomGeometryVector(
|
|
2168
2143
|
element.pathData,
|
|
@@ -2337,10 +2312,16 @@ function renderVectorShape(element, hasFill, fillColor, strokeWidth, strokeColor
|
|
|
2337
2312
|
const endArrowW = element.shapeStyle?.connectorEndArrowWidth;
|
|
2338
2313
|
const endArrowL = element.shapeStyle?.connectorEndArrowLength;
|
|
2339
2314
|
const compoundLine = element.shapeStyle?.compoundLine;
|
|
2340
|
-
const connectorLineCap = pptx.svgLineCap(element.shapeStyle?.lineCap);
|
|
2315
|
+
const connectorLineCap = pptx.svgLineCap(element.shapeStyle?.lineCap, dashArray !== void 0);
|
|
2341
2316
|
const hitTargetWidth = Math.max(strokeWidth * 3, 12);
|
|
2342
2317
|
const offsets = pptx.getCompoundLineOffsets(compoundLine, strokeWidth);
|
|
2343
2318
|
const widths = pptx.getCompoundLineWidths(compoundLine, strokeWidth);
|
|
2319
|
+
const snapTransform = pptx.connectorSnapTransform(
|
|
2320
|
+
element,
|
|
2321
|
+
!pptx.connectorNeedsPath(element.shapeType),
|
|
2322
|
+
offsets.length,
|
|
2323
|
+
strokeWidth
|
|
2324
|
+
);
|
|
2344
2325
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2345
2326
|
"svg",
|
|
2346
2327
|
{
|
|
@@ -2380,8 +2361,8 @@ function renderVectorShape(element, hasFill, fillColor, strokeWidth, strokeColor
|
|
|
2380
2361
|
vectorEffect: "non-scaling-stroke",
|
|
2381
2362
|
style: {
|
|
2382
2363
|
pointerEvents: "none",
|
|
2383
|
-
strokeWidth: pptx.
|
|
2384
|
-
...offset !== 0 ? { transform: `translate(0, ${offset}px)` } : {}
|
|
2364
|
+
strokeWidth: pptx.connectorStrandScreenWidth(widths, strokeWidth, idx),
|
|
2365
|
+
...offset !== 0 ? { transform: `translate(0, ${offset}px)` } : snapTransform ? { transform: snapTransform } : {}
|
|
2385
2366
|
}
|
|
2386
2367
|
},
|
|
2387
2368
|
idx
|
|
@@ -2392,466 +2373,8 @@ function renderVectorShape(element, hasFill, fillColor, strokeWidth, strokeColor
|
|
|
2392
2373
|
}
|
|
2393
2374
|
return null;
|
|
2394
2375
|
}
|
|
2395
|
-
function
|
|
2396
|
-
|
|
2397
|
-
return void 0;
|
|
2398
|
-
}
|
|
2399
|
-
const gsLstRaw = gradFill["a:gsLst"];
|
|
2400
|
-
if (!gsLstRaw) {
|
|
2401
|
-
return void 0;
|
|
2402
|
-
}
|
|
2403
|
-
const stops = ensureArrayValue(gsLstRaw["a:gs"]);
|
|
2404
|
-
if (stops.length === 0) {
|
|
2405
|
-
return void 0;
|
|
2406
|
-
}
|
|
2407
|
-
const rawStops = stops.map((gs) => {
|
|
2408
|
-
const pos = Number.parseInt(String(gs["@_pos"] || "0"), 10) / 1e3;
|
|
2409
|
-
const color = pptx.parseDrawingColor(gs) ?? "#888888";
|
|
2410
|
-
const opacity = pptx.parseDrawingColorOpacity(gs);
|
|
2411
|
-
return { position: pos, color, opacity };
|
|
2412
|
-
}).sort((a, b) => a.position - b.position);
|
|
2413
|
-
const stopStrings = rawStops.map((s) => `${pptx.colorWithOpacity(s.color, s.opacity)} ${s.position.toFixed(1)}%`).join(", ");
|
|
2414
|
-
const lin = gradFill["a:lin"];
|
|
2415
|
-
if (lin) {
|
|
2416
|
-
const angRaw = Number.parseInt(String(lin["@_ang"] || "0"), 10);
|
|
2417
|
-
const angleDeg = Math.round(pptx$1.ooxmlGradientAngleToCssDegrees(angRaw / 6e4));
|
|
2418
|
-
return `linear-gradient(${angleDeg}deg, ${stopStrings})`;
|
|
2419
|
-
}
|
|
2420
|
-
const path = gradFill["a:path"];
|
|
2421
|
-
if (path) {
|
|
2422
|
-
const pathType = String(path["@_path"] || "circle");
|
|
2423
|
-
const fillToRectXml = path["a:fillToRect"];
|
|
2424
|
-
const fillToRect = fillToRectXml ? {
|
|
2425
|
-
l: Number.parseInt(String(fillToRectXml["@_l"] || "0"), 10) / 1e5,
|
|
2426
|
-
t: Number.parseInt(String(fillToRectXml["@_t"] || "0"), 10) / 1e5,
|
|
2427
|
-
r: Number.parseInt(String(fillToRectXml["@_r"] || "0"), 10) / 1e5,
|
|
2428
|
-
b: Number.parseInt(String(fillToRectXml["@_b"] || "0"), 10) / 1e5
|
|
2429
|
-
} : void 0;
|
|
2430
|
-
if (pathType === "rect") {
|
|
2431
|
-
return pptx.buildRectPathGradient(rawStops, void 0, fillToRect);
|
|
2432
|
-
}
|
|
2433
|
-
let cx = 50;
|
|
2434
|
-
let cy = 50;
|
|
2435
|
-
if (fillToRect) {
|
|
2436
|
-
const { l, t, r, b } = fillToRect;
|
|
2437
|
-
cx = (l + (1 - r)) / 2 * 100;
|
|
2438
|
-
cy = (t + (1 - b)) / 2 * 100;
|
|
2439
|
-
}
|
|
2440
|
-
const posX = `${Math.round(cx)}%`;
|
|
2441
|
-
const posY = `${Math.round(cy)}%`;
|
|
2442
|
-
if (pathType === "shape") {
|
|
2443
|
-
return `radial-gradient(farthest-side at ${posX} ${posY}, ${stopStrings})`;
|
|
2444
|
-
}
|
|
2445
|
-
return `radial-gradient(circle at ${posX} ${posY}, ${stopStrings})`;
|
|
2446
|
-
}
|
|
2447
|
-
return `linear-gradient(180deg, ${stopStrings})`;
|
|
2448
|
-
}
|
|
2449
|
-
function parsePatternFillCss(pattFill) {
|
|
2450
|
-
if (!pattFill) {
|
|
2451
|
-
return void 0;
|
|
2452
|
-
}
|
|
2453
|
-
const fgColor = pptx.parseDrawingColor(pattFill["a:fgClr"]) ?? "#000000";
|
|
2454
|
-
const bgColor = pptx.parseDrawingColor(pattFill["a:bgClr"]) ?? "#ffffff";
|
|
2455
|
-
const preset = String(pattFill["@_prst"] || "ltDnDiag");
|
|
2456
|
-
switch (preset) {
|
|
2457
|
-
case "ltHorz":
|
|
2458
|
-
case "horz":
|
|
2459
|
-
case "narHorz":
|
|
2460
|
-
case "dkHorz":
|
|
2461
|
-
case "wdUpDiag":
|
|
2462
|
-
return `repeating-linear-gradient(0deg, ${bgColor}, ${bgColor} 3px, ${fgColor} 3px, ${fgColor} 4px)`;
|
|
2463
|
-
case "ltVert":
|
|
2464
|
-
case "vert":
|
|
2465
|
-
case "narVert":
|
|
2466
|
-
case "dkVert":
|
|
2467
|
-
case "wdDnDiag":
|
|
2468
|
-
return `repeating-linear-gradient(90deg, ${bgColor}, ${bgColor} 3px, ${fgColor} 3px, ${fgColor} 4px)`;
|
|
2469
|
-
case "ltDnDiag":
|
|
2470
|
-
case "dnDiag":
|
|
2471
|
-
case "dkDnDiag":
|
|
2472
|
-
return `repeating-linear-gradient(135deg, ${bgColor}, ${bgColor} 3px, ${fgColor} 3px, ${fgColor} 4px)`;
|
|
2473
|
-
case "ltUpDiag":
|
|
2474
|
-
case "upDiag":
|
|
2475
|
-
case "dkUpDiag":
|
|
2476
|
-
return `repeating-linear-gradient(45deg, ${bgColor}, ${bgColor} 3px, ${fgColor} 3px, ${fgColor} 4px)`;
|
|
2477
|
-
case "dashHorz":
|
|
2478
|
-
case "dashVert":
|
|
2479
|
-
case "dashDnDiag":
|
|
2480
|
-
case "dashUpDiag":
|
|
2481
|
-
return `repeating-linear-gradient(135deg, ${bgColor}, ${bgColor} 4px, ${fgColor} 4px, ${fgColor} 6px, ${bgColor} 6px, ${bgColor} 10px)`;
|
|
2482
|
-
case "smCheck":
|
|
2483
|
-
case "lgCheck":
|
|
2484
|
-
return `repeating-conic-gradient(${fgColor} 0% 25%, ${bgColor} 0% 50%) 0 0 / 8px 8px`;
|
|
2485
|
-
case "smGrid":
|
|
2486
|
-
case "lgGrid":
|
|
2487
|
-
return `repeating-linear-gradient(0deg, ${fgColor} 0px, ${fgColor} 1px, transparent 1px, transparent 6px), repeating-linear-gradient(90deg, ${fgColor} 0px, ${fgColor} 1px, transparent 1px, transparent 6px), ${bgColor}`;
|
|
2488
|
-
case "dotGrid":
|
|
2489
|
-
case "pct5":
|
|
2490
|
-
case "pct10":
|
|
2491
|
-
case "pct20":
|
|
2492
|
-
case "pct25":
|
|
2493
|
-
case "pct30":
|
|
2494
|
-
case "pct40":
|
|
2495
|
-
case "pct50":
|
|
2496
|
-
case "pct60":
|
|
2497
|
-
case "pct70":
|
|
2498
|
-
case "pct75":
|
|
2499
|
-
case "pct80":
|
|
2500
|
-
case "pct90":
|
|
2501
|
-
return `radial-gradient(${fgColor} 1px, ${bgColor} 1px) 0 0 / 4px 4px`;
|
|
2502
|
-
case "smConfetti":
|
|
2503
|
-
case "lgConfetti":
|
|
2504
|
-
case "zigZag":
|
|
2505
|
-
case "wave":
|
|
2506
|
-
case "sphere":
|
|
2507
|
-
case "divot":
|
|
2508
|
-
case "shingle":
|
|
2509
|
-
case "weave":
|
|
2510
|
-
case "plaid":
|
|
2511
|
-
case "trellis":
|
|
2512
|
-
return `repeating-linear-gradient(45deg, ${bgColor}, ${bgColor} 2px, ${fgColor} 2px, ${fgColor} 3px)`;
|
|
2513
|
-
case "solidDmnd":
|
|
2514
|
-
case "openDmnd":
|
|
2515
|
-
return `repeating-conic-gradient(${fgColor} 0% 25%, ${bgColor} 0% 50%) 0 0 / 10px 10px`;
|
|
2516
|
-
default:
|
|
2517
|
-
return `repeating-linear-gradient(135deg, ${bgColor}, ${bgColor} 3px, ${fgColor} 3px, ${fgColor} 4px)`;
|
|
2518
|
-
}
|
|
2519
|
-
}
|
|
2520
|
-
function ooxmlDashToCss(dashVal) {
|
|
2521
|
-
if (!dashVal) {
|
|
2522
|
-
return "solid";
|
|
2523
|
-
}
|
|
2524
|
-
switch (dashVal) {
|
|
2525
|
-
case "dot":
|
|
2526
|
-
case "sysDot":
|
|
2527
|
-
return "dotted";
|
|
2528
|
-
case "dash":
|
|
2529
|
-
case "sysDash":
|
|
2530
|
-
case "lgDash":
|
|
2531
|
-
return "dashed";
|
|
2532
|
-
case "dashDot":
|
|
2533
|
-
case "lgDashDot":
|
|
2534
|
-
case "sysDashDot":
|
|
2535
|
-
case "lgDashDotDot":
|
|
2536
|
-
case "sysDashDotDot":
|
|
2537
|
-
return "dashed";
|
|
2538
|
-
case "solid":
|
|
2539
|
-
return "solid";
|
|
2540
|
-
default:
|
|
2541
|
-
return "solid";
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
function parseCellBorders(cellProperties) {
|
|
2545
|
-
if (!cellProperties) {
|
|
2546
|
-
return {};
|
|
2547
|
-
}
|
|
2548
|
-
const borderStyle = {};
|
|
2549
|
-
const edges = [
|
|
2550
|
-
{ xml: "a:lnL", prefix: "borderLeft" },
|
|
2551
|
-
{ xml: "a:lnR", prefix: "borderRight" },
|
|
2552
|
-
{ xml: "a:lnT", prefix: "borderTop" },
|
|
2553
|
-
{ xml: "a:lnB", prefix: "borderBottom" }
|
|
2554
|
-
];
|
|
2555
|
-
for (const edge of edges) {
|
|
2556
|
-
const ln = cellProperties[edge.xml];
|
|
2557
|
-
if (!ln) {
|
|
2558
|
-
continue;
|
|
2559
|
-
}
|
|
2560
|
-
const widthEmu = Number.parseInt(String(ln["@_w"] || "0"), 10);
|
|
2561
|
-
const widthPx = Math.max(1, Math.round(widthEmu / 12700));
|
|
2562
|
-
const prstDash = ln["a:prstDash"];
|
|
2563
|
-
const dashVal = prstDash ? String(prstDash["@_val"] || "") : void 0;
|
|
2564
|
-
const cssBorderStyle = ooxmlDashToCss(dashVal);
|
|
2565
|
-
const color = pptx.parseDrawingColor(ln["a:solidFill"]);
|
|
2566
|
-
if (color) {
|
|
2567
|
-
const opacity = pptx.parseDrawingColorOpacity(ln["a:solidFill"]);
|
|
2568
|
-
const key = `${edge.prefix}`;
|
|
2569
|
-
borderStyle[key] = pptx.screenBorder(
|
|
2570
|
-
widthPx,
|
|
2571
|
-
cssBorderStyle,
|
|
2572
|
-
pptx.colorWithOpacity(color, opacity)
|
|
2573
|
-
);
|
|
2574
|
-
}
|
|
2575
|
-
}
|
|
2576
|
-
return borderStyle;
|
|
2577
|
-
}
|
|
2578
|
-
function parseCellTextEffects(runProps) {
|
|
2579
|
-
const effectLst = runProps?.["a:effectLst"];
|
|
2580
|
-
if (!effectLst) {
|
|
2581
|
-
return void 0;
|
|
2582
|
-
}
|
|
2583
|
-
const textShadowParts = [];
|
|
2584
|
-
const outerShdw = effectLst["a:outerShdw"];
|
|
2585
|
-
if (outerShdw) {
|
|
2586
|
-
const shdwColor = pptx.parseDrawingColor(outerShdw);
|
|
2587
|
-
if (shdwColor) {
|
|
2588
|
-
const blurRad = Number.parseInt(String(outerShdw["@_blurRad"] || "0"), 10);
|
|
2589
|
-
const blurPx = blurRad > 0 ? Math.round(blurRad / 12700) : 0;
|
|
2590
|
-
const distVal = Number.parseInt(String(outerShdw["@_dist"] || "0"), 10);
|
|
2591
|
-
const dirVal = Number.parseInt(String(outerShdw["@_dir"] || "0"), 10);
|
|
2592
|
-
let offX = 0;
|
|
2593
|
-
let offY = 0;
|
|
2594
|
-
if (distVal > 0) {
|
|
2595
|
-
const angleRad = dirVal / 6e4 * (Math.PI / 180);
|
|
2596
|
-
offX = Math.round(distVal * Math.cos(angleRad) / 12700);
|
|
2597
|
-
offY = Math.round(distVal * Math.sin(angleRad) / 12700);
|
|
2598
|
-
}
|
|
2599
|
-
textShadowParts.push(`${offX}px ${offY}px ${blurPx}px ${shdwColor}`);
|
|
2600
|
-
}
|
|
2601
|
-
}
|
|
2602
|
-
const glow = effectLst["a:glow"];
|
|
2603
|
-
if (glow) {
|
|
2604
|
-
const glowColor = pptx.parseDrawingColor(glow);
|
|
2605
|
-
if (glowColor) {
|
|
2606
|
-
const glowRad = Number.parseInt(String(glow["@_rad"] || "0"), 10);
|
|
2607
|
-
const glowPx = glowRad > 0 ? Math.round(glowRad / 12700) : 2;
|
|
2608
|
-
textShadowParts.push(`0px 0px ${glowPx}px ${glowColor}`);
|
|
2609
|
-
}
|
|
2610
|
-
}
|
|
2611
|
-
return textShadowParts.length > 0 ? textShadowParts.join(", ") : void 0;
|
|
2612
|
-
}
|
|
2613
|
-
function extractCellText(cellXml) {
|
|
2614
|
-
if (!cellXml) {
|
|
2615
|
-
return "";
|
|
2616
|
-
}
|
|
2617
|
-
const txBody = cellXml["a:txBody"];
|
|
2618
|
-
const paragraphs = ensureArrayValue(txBody?.["a:p"]);
|
|
2619
|
-
const paragraphTexts = [];
|
|
2620
|
-
paragraphs.forEach((paragraph) => {
|
|
2621
|
-
const textParts = [];
|
|
2622
|
-
const runs = ensureArrayValue(paragraph["a:r"]);
|
|
2623
|
-
runs.forEach((run) => {
|
|
2624
|
-
textParts.push(pptx$1.xmlText(run["a:t"]) ?? "");
|
|
2625
|
-
});
|
|
2626
|
-
const fields = ensureArrayValue(paragraph["a:fld"]);
|
|
2627
|
-
fields.forEach((field) => {
|
|
2628
|
-
textParts.push(pptx$1.xmlText(field["a:t"]) ?? "");
|
|
2629
|
-
});
|
|
2630
|
-
paragraphTexts.push(textParts.join(""));
|
|
2631
|
-
});
|
|
2632
|
-
return paragraphTexts.join("\n");
|
|
2633
|
-
}
|
|
2634
|
-
function parseParagraphAlignment(value) {
|
|
2635
|
-
const alignment = String(value || "").toLowerCase();
|
|
2636
|
-
if (alignment === "ctr") {
|
|
2637
|
-
return "center";
|
|
2638
|
-
}
|
|
2639
|
-
if (alignment === "r") {
|
|
2640
|
-
return "right";
|
|
2641
|
-
}
|
|
2642
|
-
if (alignment === "just" || alignment === "justify") {
|
|
2643
|
-
return "justify";
|
|
2644
|
-
}
|
|
2645
|
-
return "left";
|
|
2646
|
-
}
|
|
2647
|
-
function extractTableCellStyle(cellXml, fallbackStyle, schemeColorOverrides) {
|
|
2648
|
-
const { color: _fallbackColor, ...fallbackWithoutColor } = fallbackStyle;
|
|
2649
|
-
const cellStyle = { ...fallbackWithoutColor };
|
|
2650
|
-
const txBody = cellXml["a:txBody"];
|
|
2651
|
-
const paragraphs = ensureArrayValue(txBody?.["a:p"]);
|
|
2652
|
-
const firstParagraph = paragraphs[0];
|
|
2653
|
-
const paragraphProperties = firstParagraph?.["a:pPr"];
|
|
2654
|
-
const runs = ensureArrayValue(firstParagraph?.["a:r"]);
|
|
2655
|
-
const firstRun = runs[0];
|
|
2656
|
-
const runProps = firstRun?.["a:rPr"] || paragraphProperties?.["a:defRPr"];
|
|
2657
|
-
if (runProps?.["@_sz"]) {
|
|
2658
|
-
const pointSize = Number.parseInt(String(runProps["@_sz"]), 10) / 100;
|
|
2659
|
-
if (Number.isFinite(pointSize) && pointSize > 0) {
|
|
2660
|
-
cellStyle.fontSize = pointSize * (96 / 72);
|
|
2661
|
-
}
|
|
2662
|
-
}
|
|
2663
|
-
if (runProps?.["@_b"] !== void 0) {
|
|
2664
|
-
cellStyle.fontWeight = runProps["@_b"] === "1" ? 700 : 400;
|
|
2665
|
-
}
|
|
2666
|
-
if (runProps?.["@_i"] !== void 0) {
|
|
2667
|
-
cellStyle.fontStyle = runProps["@_i"] === "1" ? "italic" : "normal";
|
|
2668
|
-
}
|
|
2669
|
-
if (runProps?.["@_u"] !== void 0) {
|
|
2670
|
-
cellStyle.textDecorationLine = runProps["@_u"] === "sng" ? "underline" : "none";
|
|
2671
|
-
}
|
|
2672
|
-
const runColor = pptx.parseDrawingColor(runProps?.["a:solidFill"], schemeColorOverrides) || pptx.parseDrawingColor(runProps?.["a:highlight"], schemeColorOverrides);
|
|
2673
|
-
if (runColor) {
|
|
2674
|
-
const opacity = pptx.parseDrawingColorOpacity(runProps?.["a:solidFill"]);
|
|
2675
|
-
cellStyle.color = pptx.colorWithOpacity(runColor, opacity);
|
|
2676
|
-
}
|
|
2677
|
-
const fontFamily = runProps?.["a:latin"]?.["@_typeface"] || runProps?.["a:ea"]?.["@_typeface"] || runProps?.["a:cs"]?.["@_typeface"];
|
|
2678
|
-
if (fontFamily) {
|
|
2679
|
-
cellStyle.fontFamily = fontFamily;
|
|
2680
|
-
}
|
|
2681
|
-
if (paragraphProperties?.["@_algn"]) {
|
|
2682
|
-
cellStyle.textAlign = parseParagraphAlignment(paragraphProperties["@_algn"]);
|
|
2683
|
-
}
|
|
2684
|
-
const cellProperties = cellXml["a:tcPr"];
|
|
2685
|
-
const cellFill = pptx.parseDrawingColor(
|
|
2686
|
-
cellProperties?.["a:solidFill"],
|
|
2687
|
-
schemeColorOverrides
|
|
2688
|
-
);
|
|
2689
|
-
if (cellFill) {
|
|
2690
|
-
const opacity = pptx.parseDrawingColorOpacity(
|
|
2691
|
-
cellProperties?.["a:solidFill"]
|
|
2692
|
-
);
|
|
2693
|
-
cellStyle.backgroundColor = pptx.colorWithOpacity(cellFill, opacity);
|
|
2694
|
-
} else {
|
|
2695
|
-
const gradCss = parseGradientFillCss(cellProperties?.["a:gradFill"]);
|
|
2696
|
-
if (gradCss) {
|
|
2697
|
-
cellStyle.background = gradCss;
|
|
2698
|
-
} else {
|
|
2699
|
-
const pattCss = parsePatternFillCss(cellProperties?.["a:pattFill"]);
|
|
2700
|
-
if (pattCss) {
|
|
2701
|
-
cellStyle.background = pattCss;
|
|
2702
|
-
}
|
|
2703
|
-
}
|
|
2704
|
-
}
|
|
2705
|
-
const edgeBorders = parseCellBorders(cellProperties);
|
|
2706
|
-
Object.assign(cellStyle, edgeBorders);
|
|
2707
|
-
if (!cellStyle.borderLeftColor && !cellStyle.borderRightColor && !cellStyle.borderTopColor && !cellStyle.borderBottomColor) {
|
|
2708
|
-
const borderColor = pptx.parseDrawingColor(
|
|
2709
|
-
cellProperties?.["a:lnL"]?.["a:solidFill"],
|
|
2710
|
-
schemeColorOverrides
|
|
2711
|
-
) || pptx.parseDrawingColor(
|
|
2712
|
-
cellProperties?.["a:lnR"]?.["a:solidFill"],
|
|
2713
|
-
schemeColorOverrides
|
|
2714
|
-
) || pptx.parseDrawingColor(
|
|
2715
|
-
cellProperties?.["a:lnT"]?.["a:solidFill"],
|
|
2716
|
-
schemeColorOverrides
|
|
2717
|
-
) || pptx.parseDrawingColor(
|
|
2718
|
-
cellProperties?.["a:lnB"]?.["a:solidFill"],
|
|
2719
|
-
schemeColorOverrides
|
|
2720
|
-
);
|
|
2721
|
-
if (borderColor) {
|
|
2722
|
-
cellStyle.borderColor = borderColor;
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
if (cellProperties) {
|
|
2726
|
-
const margin = (key) => Number.parseInt(String(cellProperties[key] ?? ""), 10) / EMU_PER_PX;
|
|
2727
|
-
const marL = margin("@_marL");
|
|
2728
|
-
const marR = margin("@_marR");
|
|
2729
|
-
const marT = margin("@_marT");
|
|
2730
|
-
const marB = margin("@_marB");
|
|
2731
|
-
if (marL >= 0) {
|
|
2732
|
-
cellStyle.paddingLeft = marL;
|
|
2733
|
-
}
|
|
2734
|
-
if (marR >= 0) {
|
|
2735
|
-
cellStyle.paddingRight = marR;
|
|
2736
|
-
}
|
|
2737
|
-
if (marT >= 0) {
|
|
2738
|
-
cellStyle.paddingTop = marT;
|
|
2739
|
-
}
|
|
2740
|
-
if (marB >= 0) {
|
|
2741
|
-
cellStyle.paddingBottom = marB;
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
if (cellProperties?.["@_anchor"]) {
|
|
2745
|
-
const anchor = String(cellProperties["@_anchor"]);
|
|
2746
|
-
if (anchor === "ctr") {
|
|
2747
|
-
cellStyle.verticalAlign = "middle";
|
|
2748
|
-
} else if (anchor === "b") {
|
|
2749
|
-
cellStyle.verticalAlign = "bottom";
|
|
2750
|
-
} else {
|
|
2751
|
-
cellStyle.verticalAlign = "top";
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2754
|
-
if (cellProperties?.["@_vert"]) {
|
|
2755
|
-
const vert = String(cellProperties["@_vert"]);
|
|
2756
|
-
switch (vert) {
|
|
2757
|
-
case "vert":
|
|
2758
|
-
case "eaVert":
|
|
2759
|
-
case "wordArtVert":
|
|
2760
|
-
case "wordArtVertRtl":
|
|
2761
|
-
cellStyle.writingMode = "vertical-rl";
|
|
2762
|
-
break;
|
|
2763
|
-
case "vert270":
|
|
2764
|
-
case "mongolianVert":
|
|
2765
|
-
cellStyle.writingMode = "vertical-lr";
|
|
2766
|
-
break;
|
|
2767
|
-
}
|
|
2768
|
-
if (vert === "wordArtVert") {
|
|
2769
|
-
cellStyle.textOrientation = "upright";
|
|
2770
|
-
} else if (cellStyle.writingMode) {
|
|
2771
|
-
cellStyle.textOrientation = "mixed";
|
|
2772
|
-
}
|
|
2773
|
-
if (vert === "wordArtVertRtl") {
|
|
2774
|
-
cellStyle.direction = "rtl";
|
|
2775
|
-
}
|
|
2776
|
-
}
|
|
2777
|
-
const textShadow = parseCellTextEffects(runProps);
|
|
2778
|
-
if (textShadow) {
|
|
2779
|
-
cellStyle.textShadow = textShadow;
|
|
2780
|
-
}
|
|
2781
|
-
return cellStyle;
|
|
2782
|
-
}
|
|
2783
|
-
function getTableCellBandStyle(element, rowIndex, cellIndex, rowCount, columnCount, styleCtx) {
|
|
2784
|
-
if (element.type !== "table") {
|
|
2785
|
-
return void 0;
|
|
2786
|
-
}
|
|
2787
|
-
return pptx.getTableCellBandStyle(element.tableData, rowIndex, cellIndex, rowCount, columnCount, {
|
|
2788
|
-
tableStyleMap: styleCtx?.tableStyleMap,
|
|
2789
|
-
colorScheme: styleCtx?.theme?.colorScheme,
|
|
2790
|
-
fontScheme: styleCtx?.theme?.fontScheme,
|
|
2791
|
-
formatScheme: styleCtx?.theme?.formatScheme
|
|
2792
|
-
});
|
|
2793
|
-
}
|
|
2794
|
-
|
|
2795
|
-
// src/viewer/utils/table-data-parse.tsx
|
|
2796
|
-
function getGraphicDataFromElement(element) {
|
|
2797
|
-
return element.rawXml?.["a:graphic"]?.["a:graphicData"];
|
|
2798
|
-
}
|
|
2799
|
-
function getTableXmlFromElement(element) {
|
|
2800
|
-
return getGraphicDataFromElement(element)?.["a:tbl"];
|
|
2801
|
-
}
|
|
2802
|
-
function parseTableElementData(element, fallbackTextStyle) {
|
|
2803
|
-
const table = getTableXmlFromElement(element);
|
|
2804
|
-
if (!table) {
|
|
2805
|
-
return null;
|
|
2806
|
-
}
|
|
2807
|
-
const rows = ensureArrayValue(table["a:tr"]);
|
|
2808
|
-
if (rows.length === 0) {
|
|
2809
|
-
return null;
|
|
2810
|
-
}
|
|
2811
|
-
const tableGrid = table["a:tblGrid"];
|
|
2812
|
-
const gridColumns = ensureArrayValue(
|
|
2813
|
-
tableGrid?.["a:gridCol"]
|
|
2814
|
-
);
|
|
2815
|
-
const columnWidths = gridColumns.map((column) => {
|
|
2816
|
-
const width = Number.parseInt(String(column?.["@_w"] || ""), 10);
|
|
2817
|
-
return Number.isFinite(width) && width > 0 ? width : 0;
|
|
2818
|
-
});
|
|
2819
|
-
const totalColumnWidth = columnWidths.reduce((sum, width) => sum + width, 0);
|
|
2820
|
-
let columnPercentages = totalColumnWidth > 0 ? columnWidths.map((width) => width / totalColumnWidth * 100) : [];
|
|
2821
|
-
const modelWidths = element.type === "table" ? element.tableData?.columnWidths : void 0;
|
|
2822
|
-
if (modelWidths?.length && modelWidths.length === gridColumns.length && modelWidths.every((width) => Number.isFinite(width) && width >= 0) && Math.abs(modelWidths.reduce((sum, width) => sum + width, 0) - 1) <= Number.EPSILON * modelWidths.length * 4) {
|
|
2823
|
-
columnPercentages = modelWidths.map((width) => width * 100);
|
|
2824
|
-
}
|
|
2825
|
-
const cells = [];
|
|
2826
|
-
rows.forEach((row, rowIndex) => {
|
|
2827
|
-
const rowCells = ensureArrayValue(row["a:tc"]);
|
|
2828
|
-
rowCells.forEach((cell, columnIndex) => {
|
|
2829
|
-
cells.push({
|
|
2830
|
-
rowIndex,
|
|
2831
|
-
columnIndex,
|
|
2832
|
-
text: extractCellText(cell),
|
|
2833
|
-
style: extractTableCellStyle(cell, fallbackTextStyle),
|
|
2834
|
-
rawCell: cell
|
|
2835
|
-
});
|
|
2836
|
-
});
|
|
2837
|
-
});
|
|
2838
|
-
const columnCount = Math.max(
|
|
2839
|
-
columnPercentages.length,
|
|
2840
|
-
rows.reduce((maxCount, row) => {
|
|
2841
|
-
const rowCells = ensureArrayValue(row["a:tc"]);
|
|
2842
|
-
return Math.max(maxCount, rowCells.length);
|
|
2843
|
-
}, 0)
|
|
2844
|
-
);
|
|
2845
|
-
return {
|
|
2846
|
-
rowCount: rows.length,
|
|
2847
|
-
columnCount,
|
|
2848
|
-
rows,
|
|
2849
|
-
columnPercentages,
|
|
2850
|
-
cells
|
|
2851
|
-
};
|
|
2852
|
-
}
|
|
2853
|
-
function renderTableCellContent(cell, fallbackText, cellCss) {
|
|
2854
|
-
const blocks = cell ? pptx.cellParagraphBlocks(cell) : void 0;
|
|
2376
|
+
function renderTableCellContent(cell, fallbackText, cellCss, defaultFontPt) {
|
|
2377
|
+
const blocks = cell ? pptx.cellParagraphBlocks(cell, { cellCss, defaultFontPt }) : void 0;
|
|
2855
2378
|
if (blocks) {
|
|
2856
2379
|
return blocks.map((block, index) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "block", ...block.css }, children: block.runs.map((run, runIndex) => renderRun(run, runIndex, cellCss)) }, `p-${index}`));
|
|
2857
2380
|
}
|
|
@@ -3312,7 +2835,8 @@ function renderTableFromTableData(element, textStyle, options) {
|
|
|
3312
2835
|
) : renderTableCellContent(
|
|
3313
2836
|
cell,
|
|
3314
2837
|
cell.text || "\xA0",
|
|
3315
|
-
cellCss(cell, rowIndex, cellIndex)
|
|
2838
|
+
cellCss(cell, rowIndex, cellIndex),
|
|
2839
|
+
tableData.defaultCellFontSize
|
|
3316
2840
|
)
|
|
3317
2841
|
]
|
|
3318
2842
|
},
|
|
@@ -3331,204 +2855,11 @@ function renderTableFromTableData(element, textStyle, options) {
|
|
|
3331
2855
|
);
|
|
3332
2856
|
}
|
|
3333
2857
|
function renderTableElement(element, textStyle, options) {
|
|
3334
|
-
const parsedTable = parseTableElementData(element, textStyle);
|
|
3335
|
-
if (!parsedTable) {
|
|
3336
|
-
const tableEl2 = element;
|
|
3337
|
-
if (tableEl2.tableData && tableEl2.tableData.rows.length > 0) {
|
|
3338
|
-
return renderTableFromTableData(tableEl2, textStyle, options);
|
|
3339
|
-
}
|
|
3340
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full flex items-center justify-center text-[11px] text-white/80 pointer-events-none", children: i18n.translationsEn["pptx.table.title"] });
|
|
3341
|
-
}
|
|
3342
|
-
const selectedCell = options?.selectedCell || null;
|
|
3343
|
-
const isEditable = Boolean(options?.editable) && pptx.canDrillDown(element);
|
|
3344
|
-
const hasCellSelectionHandler = typeof options?.onSelectCell === "function";
|
|
3345
2858
|
const tableEl = element;
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
if (!tableEl.tableData) {
|
|
3351
|
-
return void 0;
|
|
3352
|
-
}
|
|
3353
|
-
const first = selectedCell.selectedCells[0];
|
|
3354
|
-
const last = selectedCell.selectedCells[selectedCell.selectedCells.length - 1];
|
|
3355
|
-
return pptx.computeSelectionRect(first.row, first.col, last.row, last.col, tableEl.tableData);
|
|
3356
|
-
})();
|
|
3357
|
-
const schemeOverrides = options?.styleCtx?.theme?.colorScheme ? options.styleCtx.theme.colorScheme : void 0;
|
|
3358
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3359
|
-
TableResizeOverlay,
|
|
3360
|
-
{
|
|
3361
|
-
columnWidths: parsedTable.columnPercentages.map((p) => p / 100),
|
|
3362
|
-
rows: tableEl.tableData?.rows,
|
|
3363
|
-
editable: isEditable,
|
|
3364
|
-
onResizeColumns: options?.onResizeColumns,
|
|
3365
|
-
onResizeRow: options?.onResizeRow,
|
|
3366
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3367
|
-
"div",
|
|
3368
|
-
{
|
|
3369
|
-
className: cn(
|
|
3370
|
-
"w-full h-full overflow-hidden",
|
|
3371
|
-
isEditable && hasCellSelectionHandler ? "pointer-events-auto" : "pointer-events-none"
|
|
3372
|
-
),
|
|
3373
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3374
|
-
"table",
|
|
3375
|
-
{
|
|
3376
|
-
className: "w-full h-full border-collapse table-fixed",
|
|
3377
|
-
style: {
|
|
3378
|
-
fontFamily: pptx.DEFAULT_FONT_FAMILY,
|
|
3379
|
-
// `a:tblPr@rtl` mirrors the column order for RTL decks.
|
|
3380
|
-
...pptx.tableContainerCss(tableEl.tableData)
|
|
3381
|
-
},
|
|
3382
|
-
children: [
|
|
3383
|
-
parsedTable.columnPercentages.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("colgroup", { children: parsedTable.columnPercentages.map((percentage, columnIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3384
|
-
"col",
|
|
3385
|
-
{
|
|
3386
|
-
style: { width: `${percentage.toFixed(2)}%` }
|
|
3387
|
-
},
|
|
3388
|
-
`${element.id}-col-${columnIndex}`
|
|
3389
|
-
)) }) : null,
|
|
3390
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: parsedTable.rows.map((row, rowIndex) => {
|
|
3391
|
-
const cells = ensureArrayValue(row["a:tc"]);
|
|
3392
|
-
const rowHeightRaw = Number.parseInt(String(row["@_h"] || ""), 10);
|
|
3393
|
-
const rowHeight = Number.isFinite(rowHeightRaw) && rowHeightRaw > 0 ? Math.max(16, rowHeightRaw / EMU_PER_PX) : void 0;
|
|
3394
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3395
|
-
"tr",
|
|
3396
|
-
{
|
|
3397
|
-
style: rowHeight ? { height: rowHeight } : void 0,
|
|
3398
|
-
children: cells.map((cell, cellIndex) => {
|
|
3399
|
-
const isHMerged = cell["@_hMerge"] === "1";
|
|
3400
|
-
const isVMerged = cell["@_vMerge"] === "1";
|
|
3401
|
-
if (isHMerged || isVMerged) {
|
|
3402
|
-
return null;
|
|
3403
|
-
}
|
|
3404
|
-
const gridSpanRaw = Number.parseInt(String(cell["@_gridSpan"] || ""), 10);
|
|
3405
|
-
const colSpan = Number.isFinite(gridSpanRaw) && gridSpanRaw > 1 ? gridSpanRaw : void 0;
|
|
3406
|
-
const rowSpanRaw = Number.parseInt(String(cell["@_rowSpan"] || ""), 10);
|
|
3407
|
-
const rSpan = Number.isFinite(rowSpanRaw) && rowSpanRaw > 1 ? rowSpanRaw : void 0;
|
|
3408
|
-
const bandStyle = getTableCellBandStyle(
|
|
3409
|
-
element,
|
|
3410
|
-
rowIndex,
|
|
3411
|
-
cellIndex,
|
|
3412
|
-
parsedTable.rowCount,
|
|
3413
|
-
parsedTable.columnCount,
|
|
3414
|
-
options?.styleCtx
|
|
3415
|
-
);
|
|
3416
|
-
const xmlCellStyle = extractTableCellStyle(cell, textStyle, schemeOverrides);
|
|
3417
|
-
const tdCellOverride = tableEl.tableData?.rows[rowIndex]?.cells[cellIndex]?.style;
|
|
3418
|
-
const diag = getCellDiagonalBorders(
|
|
3419
|
-
tdCellOverride,
|
|
3420
|
-
tableEl.tableData,
|
|
3421
|
-
{
|
|
3422
|
-
rowIndex,
|
|
3423
|
-
cellIndex,
|
|
3424
|
-
rowCount: parsedTable.rowCount,
|
|
3425
|
-
columnCount: parsedTable.columnCount
|
|
3426
|
-
},
|
|
3427
|
-
options?.styleCtx
|
|
3428
|
-
);
|
|
3429
|
-
const mergedStyle = {
|
|
3430
|
-
// Lowest-priority fallback: `xmlCellStyle` never carries a
|
|
3431
|
-
// `color` of its own (see `extractTableCellStyle`), so this
|
|
3432
|
-
// is the only source when neither the table style band nor
|
|
3433
|
-
// an explicit run/cell colour applies.
|
|
3434
|
-
color: textStyle.color,
|
|
3435
|
-
// PowerPoint's line spacing and default margins, as
|
|
3436
|
-
// `tableCellCss` gives the structured-model path.
|
|
3437
|
-
...pptx.TABLE_CELL_TEXT_DEFAULTS,
|
|
3438
|
-
...bandStyle,
|
|
3439
|
-
...xmlCellStyle,
|
|
3440
|
-
...tdCellOverride ? pptx.cellStyleToCss(tdCellOverride) : void 0,
|
|
3441
|
-
...diag ? { position: "relative" } : void 0
|
|
3442
|
-
};
|
|
3443
|
-
pptx.applyTableCellFontWeight(mergedStyle);
|
|
3444
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3445
|
-
"td",
|
|
3446
|
-
{
|
|
3447
|
-
className: cn(
|
|
3448
|
-
"px-1 py-0.5 align-top",
|
|
3449
|
-
// No border of its own: a side the deck gives no border renders
|
|
3450
|
-
// with none, as PowerPoint does. Editing keeps a faint grid.
|
|
3451
|
-
isEditable && hasCellSelectionHandler ? "border border-blue-200/70 cursor-cell" : null,
|
|
3452
|
-
selectedCell?.rowIndex === rowIndex && selectedCell?.columnIndex === cellIndex ? "ring-1 ring-inset ring-blue-500" : null,
|
|
3453
|
-
pptx.isCellInRect(rowIndex, cellIndex, xmlSelectionRect) && !(selectedCell?.rowIndex === rowIndex && selectedCell?.columnIndex === cellIndex) ? "bg-blue-500/15 ring-1 ring-inset ring-blue-400/50" : null
|
|
3454
|
-
),
|
|
3455
|
-
colSpan,
|
|
3456
|
-
rowSpan: rSpan,
|
|
3457
|
-
style: mergedStyle,
|
|
3458
|
-
onClick: (event) => {
|
|
3459
|
-
if (!isEditable || !hasCellSelectionHandler) {
|
|
3460
|
-
return;
|
|
3461
|
-
}
|
|
3462
|
-
event.stopPropagation();
|
|
3463
|
-
if (event.shiftKey && selectedCell && tableEl.tableData) {
|
|
3464
|
-
const rect = pptx.computeSelectionRect(
|
|
3465
|
-
selectedCell.rowIndex,
|
|
3466
|
-
selectedCell.columnIndex,
|
|
3467
|
-
rowIndex,
|
|
3468
|
-
cellIndex,
|
|
3469
|
-
tableEl.tableData
|
|
3470
|
-
);
|
|
3471
|
-
options?.onSelectCell?.({
|
|
3472
|
-
rowIndex: selectedCell.rowIndex,
|
|
3473
|
-
columnIndex: selectedCell.columnIndex,
|
|
3474
|
-
selectedCells: pptx.rectToCells(rect)
|
|
3475
|
-
});
|
|
3476
|
-
} else {
|
|
3477
|
-
options?.onSelectCell?.({
|
|
3478
|
-
rowIndex,
|
|
3479
|
-
columnIndex: cellIndex
|
|
3480
|
-
});
|
|
3481
|
-
}
|
|
3482
|
-
},
|
|
3483
|
-
onDoubleClick: (event) => {
|
|
3484
|
-
if (!isEditable || !hasCellSelectionHandler) {
|
|
3485
|
-
return;
|
|
3486
|
-
}
|
|
3487
|
-
event.stopPropagation();
|
|
3488
|
-
options?.onSelectCell?.({
|
|
3489
|
-
rowIndex,
|
|
3490
|
-
columnIndex: cellIndex,
|
|
3491
|
-
isEditing: true
|
|
3492
|
-
});
|
|
3493
|
-
},
|
|
3494
|
-
children: [
|
|
3495
|
-
diag ? /* @__PURE__ */ jsxRuntime.jsx(TableCellDiagonalBorders, { diag }) : null,
|
|
3496
|
-
selectedCell?.rowIndex === rowIndex && selectedCell?.columnIndex === cellIndex && selectedCell?.isEditing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3497
|
-
TableCellInput,
|
|
3498
|
-
{
|
|
3499
|
-
initialText: extractCellText(cell) ?? "",
|
|
3500
|
-
style: mergedStyle,
|
|
3501
|
-
onCommit: (text) => {
|
|
3502
|
-
options?.onCommitCellEdit?.(rowIndex, cellIndex, text);
|
|
3503
|
-
},
|
|
3504
|
-
onCancel: () => {
|
|
3505
|
-
options?.onSelectCell?.({
|
|
3506
|
-
rowIndex,
|
|
3507
|
-
columnIndex: cellIndex
|
|
3508
|
-
});
|
|
3509
|
-
}
|
|
3510
|
-
}
|
|
3511
|
-
) : renderTableCellContent(
|
|
3512
|
-
tableEl.tableData?.rows[rowIndex]?.cells[cellIndex],
|
|
3513
|
-
extractCellText(cell) || "\xA0",
|
|
3514
|
-
mergedStyle
|
|
3515
|
-
)
|
|
3516
|
-
]
|
|
3517
|
-
},
|
|
3518
|
-
`${element.id}-cell-${rowIndex}-${cellIndex}`
|
|
3519
|
-
);
|
|
3520
|
-
})
|
|
3521
|
-
},
|
|
3522
|
-
`${element.id}-row-${rowIndex}`
|
|
3523
|
-
);
|
|
3524
|
-
}) })
|
|
3525
|
-
]
|
|
3526
|
-
}
|
|
3527
|
-
)
|
|
3528
|
-
}
|
|
3529
|
-
)
|
|
3530
|
-
}
|
|
3531
|
-
);
|
|
2859
|
+
if (tableEl.tableData && tableEl.tableData.rows.length > 0) {
|
|
2860
|
+
return renderTableFromTableData(tableEl, textStyle, options);
|
|
2861
|
+
}
|
|
2862
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full flex items-center justify-center text-[11px] text-white/80 pointer-events-none", children: i18n.translationsEn["pptx.table.title"] });
|
|
3532
2863
|
}
|
|
3533
2864
|
function renderGradientStops(stops) {
|
|
3534
2865
|
return stops.map((stop, i) => /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: stop.offset, stopColor: stop.color, stopOpacity: stop.opacity }, i));
|
|
@@ -4249,7 +3580,6 @@ exports.DEFAULT_TABLE_ROWS = DEFAULT_TABLE_ROWS;
|
|
|
4249
3580
|
exports.DEFAULT_TEXT_COLOR = DEFAULT_TEXT_COLOR;
|
|
4250
3581
|
exports.DEFAULT_TEXT_FONT_SIZE = DEFAULT_TEXT_FONT_SIZE;
|
|
4251
3582
|
exports.GRID_SIZE = GRID_SIZE;
|
|
4252
|
-
exports.HYPERLINK_COLOR = HYPERLINK_COLOR;
|
|
4253
3583
|
exports.MIN_ELEMENT_SIZE = MIN_ELEMENT_SIZE;
|
|
4254
3584
|
exports.PptxI18nContext = PptxI18nContext;
|
|
4255
3585
|
exports.SHAPE_PRESETS = SHAPE_PRESETS;
|
|
@@ -4290,6 +3620,8 @@ exports.renderMediaElement = renderMediaElement;
|
|
|
4290
3620
|
exports.renderTableElement = renderTableElement;
|
|
4291
3621
|
exports.renderTextSegments = renderTextSegments;
|
|
4292
3622
|
exports.renderVectorShape = renderVectorShape;
|
|
3623
|
+
exports.rendersCustomVectorPath = rendersCustomVectorPath;
|
|
3624
|
+
exports.rendersWedgeCalloutVector = rendersWedgeCalloutVector;
|
|
4293
3625
|
exports.shouldRenderFallbackLabel = shouldRenderFallbackLabel;
|
|
4294
3626
|
exports.startMotionPathPreview = startMotionPathPreview;
|
|
4295
3627
|
exports.startPreviewAnimation = startPreviewAnimation;
|