@openmaic/renderer 0.0.2 → 0.0.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/DESIGN.md +7 -1
- package/README.md +11 -3
- package/dist/SlideCanvas.d.ts +12 -1
- package/dist/SlideCanvas.js +105 -0
- package/dist/SlideCanvas.js.map +1 -0
- package/dist/SlideElement.d.ts +3 -2
- package/dist/SlideElement.js +60 -0
- package/dist/SlideElement.js.map +1 -0
- package/dist/context.d.ts +2 -1
- package/dist/context.js +27 -0
- package/dist/context.js.map +1 -0
- package/dist/editing/EditableSlideCanvas.d.ts +26 -0
- package/dist/editing/EditableSlideCanvas.js +352 -0
- package/dist/editing/EditableSlideCanvas.js.map +1 -0
- package/dist/editing/core/drag.d.ts +108 -0
- package/dist/editing/core/drag.js +119 -0
- package/dist/editing/core/drag.js.map +1 -0
- package/dist/editing/core/geometry.d.ts +48 -0
- package/dist/editing/core/geometry.js +186 -0
- package/dist/editing/core/geometry.js.map +1 -0
- package/dist/editing/core/intent.d.ts +39 -0
- package/dist/editing/core/intent.js +35 -0
- package/dist/editing/core/intent.js.map +1 -0
- package/dist/editing/core/line-drag.d.ts +19 -0
- package/dist/editing/core/line-drag.js +163 -0
- package/dist/editing/core/line-drag.js.map +1 -0
- package/dist/editing/core/marquee.d.ts +56 -0
- package/dist/editing/core/marquee.js +74 -0
- package/dist/editing/core/marquee.js.map +1 -0
- package/dist/editing/core/resize.d.ts +121 -0
- package/dist/editing/core/resize.js +392 -0
- package/dist/editing/core/resize.js.map +1 -0
- package/dist/editing/core/rotate.d.ts +37 -0
- package/dist/editing/core/rotate.js +74 -0
- package/dist/editing/core/rotate.js.map +1 -0
- package/dist/editing/core/selection.d.ts +68 -0
- package/dist/editing/core/selection.js +108 -0
- package/dist/editing/core/selection.js.map +1 -0
- package/dist/editing/core/snapping.d.ts +54 -0
- package/dist/editing/core/snapping.js +96 -0
- package/dist/editing/core/snapping.js.map +1 -0
- package/dist/editing/handles/BorderLine.d.ts +15 -0
- package/dist/editing/handles/BorderLine.js +17 -0
- package/dist/editing/handles/BorderLine.js.map +1 -0
- package/dist/editing/handles/LineHandles.d.ts +28 -0
- package/dist/editing/handles/LineHandles.js +51 -0
- package/dist/editing/handles/LineHandles.js.map +1 -0
- package/dist/editing/handles/MarqueeBox.d.ts +19 -0
- package/dist/editing/handles/MarqueeBox.js +26 -0
- package/dist/editing/handles/MarqueeBox.js.map +1 -0
- package/dist/editing/handles/ResizeHandles.d.ts +31 -0
- package/dist/editing/handles/ResizeHandles.js +44 -0
- package/dist/editing/handles/ResizeHandles.js.map +1 -0
- package/dist/editing/handles/RotateHandle.d.ts +26 -0
- package/dist/editing/handles/RotateHandle.js +52 -0
- package/dist/editing/handles/RotateHandle.js.map +1 -0
- package/dist/editing/handles/SelectionOverlay.d.ts +18 -0
- package/dist/editing/handles/SelectionOverlay.js +35 -0
- package/dist/editing/handles/SelectionOverlay.js.map +1 -0
- package/dist/editing/index.d.ts +3 -0
- package/dist/editing/index.js +4 -0
- package/dist/editing/index.js.map +1 -0
- package/dist/editing/types.d.ts +107 -0
- package/dist/editing/types.js +7 -0
- package/dist/editing/types.js.map +1 -0
- package/dist/editing/useEditGesture.d.ts +46 -0
- package/dist/editing/useEditGesture.js +217 -0
- package/dist/editing/useEditGesture.js.map +1 -0
- package/dist/editing/useLineHandleGesture.d.ts +35 -0
- package/dist/editing/useLineHandleGesture.js +112 -0
- package/dist/editing/useLineHandleGesture.js.map +1 -0
- package/dist/editing/useMarqueeGesture.d.ts +43 -0
- package/dist/editing/useMarqueeGesture.js +157 -0
- package/dist/editing/useMarqueeGesture.js.map +1 -0
- package/dist/editing/useResizeGesture.d.ts +43 -0
- package/dist/editing/useResizeGesture.js +137 -0
- package/dist/editing/useResizeGesture.js.map +1 -0
- package/dist/editing/useRotateGesture.d.ts +47 -0
- package/dist/editing/useRotateGesture.js +128 -0
- package/dist/editing/useRotateGesture.js.map +1 -0
- package/dist/effects/HighlightOverlay.js +44 -0
- package/dist/effects/HighlightOverlay.js.map +1 -0
- package/dist/effects/LaserOverlay.js +40 -0
- package/dist/effects/LaserOverlay.js.map +1 -0
- package/dist/effects/SpotlightOverlay.d.ts +3 -1
- package/dist/effects/SpotlightOverlay.js +99 -0
- package/dist/effects/SpotlightOverlay.js.map +1 -0
- package/dist/effects/ZoomWrapper.js +19 -0
- package/dist/effects/ZoomWrapper.js.map +1 -0
- package/dist/elements/chart/BaseChartElement.js +22 -0
- package/dist/elements/chart/BaseChartElement.js.map +1 -0
- package/dist/elements/chart/Chart.js +83 -0
- package/dist/elements/chart/Chart.js.map +1 -0
- package/dist/elements/chart/chartOption.js +178 -0
- package/dist/elements/chart/chartOption.js.map +1 -0
- package/dist/elements/code/BaseCodeElement.js +525 -0
- package/dist/elements/code/BaseCodeElement.js.map +1 -0
- package/dist/elements/image/BaseImageElement.d.ts +4 -4
- package/dist/elements/image/BaseImageElement.js +76 -0
- package/dist/elements/image/BaseImageElement.js.map +1 -0
- package/dist/elements/image/ImageOutline.js +30 -0
- package/dist/elements/image/ImageOutline.js.map +1 -0
- package/dist/elements/image/clipPaths.js +130 -0
- package/dist/elements/image/clipPaths.js.map +1 -0
- package/dist/elements/image/useClipImage.js +40 -0
- package/dist/elements/image/useClipImage.js.map +1 -0
- package/dist/elements/image/useFilter.d.ts +1 -0
- package/dist/elements/image/useFilter.js +35 -0
- package/dist/elements/image/useFilter.js.map +1 -0
- package/dist/elements/index.js +14 -9
- package/dist/elements/index.js.map +1 -1
- package/dist/elements/latex/BaseLatexElement.js +94 -0
- package/dist/elements/latex/BaseLatexElement.js.map +1 -0
- package/dist/elements/line/BaseLineElement.js +72 -0
- package/dist/elements/line/BaseLineElement.js.map +1 -0
- package/dist/elements/line/LinePointMarker.js +19 -0
- package/dist/elements/line/LinePointMarker.js.map +1 -0
- package/dist/elements/shape/BaseShapeElement.js +174 -0
- package/dist/elements/shape/BaseShapeElement.js.map +1 -0
- package/dist/elements/shape/GradientDefs.js +11 -0
- package/dist/elements/shape/GradientDefs.js.map +1 -0
- package/dist/elements/shape/PatternDefs.js +8 -0
- package/dist/elements/shape/PatternDefs.js.map +1 -0
- package/dist/elements/shared/ElementOutline.js +13 -0
- package/dist/elements/shared/ElementOutline.js.map +1 -0
- package/dist/elements/shared/useElementFill.js +15 -0
- package/dist/elements/shared/useElementFill.js.map +1 -0
- package/dist/elements/shared/useElementFlip.js +18 -0
- package/dist/elements/shared/useElementFlip.js.map +1 -0
- package/dist/elements/shared/useElementOutline.js +19 -0
- package/dist/elements/shared/useElementOutline.js.map +1 -0
- package/dist/elements/shared/useElementShadow.js +15 -0
- package/dist/elements/shared/useElementShadow.js.map +1 -0
- package/dist/elements/table/BaseTableElement.js +21 -0
- package/dist/elements/table/BaseTableElement.js.map +1 -0
- package/dist/elements/table/StaticTable.js +117 -0
- package/dist/elements/table/StaticTable.js.map +1 -0
- package/dist/elements/table/tableUtils.js +28 -0
- package/dist/elements/table/tableUtils.js.map +1 -0
- package/dist/elements/text/BaseTextElement.js +46 -0
- package/dist/elements/text/BaseTextElement.js.map +1 -0
- package/dist/elements/video/BaseVideoElement.d.ts +3 -1
- package/dist/elements/video/BaseVideoElement.js +36 -0
- package/dist/elements/video/BaseVideoElement.js.map +1 -0
- package/dist/hooks/useSlideBackgroundStyle.js +43 -0
- package/dist/hooks/useSlideBackgroundStyle.js.map +1 -0
- package/dist/hooks/useViewportSize.d.ts +2 -0
- package/dist/hooks/useViewportSize.js +71 -0
- package/dist/hooks/useViewportSize.js.map +1 -0
- package/dist/index.js +11 -31
- package/dist/index.js.map +1 -1
- package/dist/snapshot/index.d.ts +1 -0
- package/dist/snapshot/index.js +93 -28
- package/dist/snapshot/index.js.map +1 -1
- package/dist/snapshot/katex-fonts-embed.d.ts +10 -0
- package/dist/snapshot/katex-fonts-embed.js +13 -0
- package/dist/snapshot/katex-fonts-embed.js.map +1 -0
- package/dist/snapshot/measure.d.ts +32 -0
- package/dist/snapshot/measure.js +129 -0
- package/dist/snapshot/measure.js.map +1 -0
- package/dist/styles.js +50 -0
- package/dist/styles.js.map +1 -0
- package/dist/types/effects.d.ts +2 -0
- package/dist/utils/cn.js +9 -0
- package/dist/utils/cn.js.map +1 -0
- package/dist/utils/element.js +85 -0
- package/dist/utils/element.js.map +1 -0
- package/dist/utils/geometry.d.ts +2 -2
- package/dist/utils/geometry.js +44 -0
- package/dist/utils/geometry.js.map +1 -0
- package/package.json +14 -4
- package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js +0 -1742
- package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js.map +0 -1
- package/dist/chunks/SlideCanvas-KcCxfrYE.js +0 -477
- package/dist/chunks/SlideCanvas-KcCxfrYE.js.map +0 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useElementOutline } from '../shared/useElementOutline.js';
|
|
4
|
+
import { useElementShadow } from '../shared/useElementShadow.js';
|
|
5
|
+
import { useElementFlip } from '../shared/useElementFlip.js';
|
|
6
|
+
import { useElementFill } from '../shared/useElementFill.js';
|
|
7
|
+
import { GradientDefs } from './GradientDefs.js';
|
|
8
|
+
import { PatternDefs } from './PatternDefs.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Bounding box of a path's coordinates (path/viewBox space). Uses control
|
|
12
|
+
* points for curves (a safe superset). Handles the commands our shapes emit
|
|
13
|
+
* (M/L/C/Q/S/H/V/A/T/Z, absolute). Returns null if no coordinates.
|
|
14
|
+
*/
|
|
15
|
+
function pathCoordBBox(d) {
|
|
16
|
+
const tokens = d.match(/[a-zA-Z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi);
|
|
17
|
+
if (!tokens)
|
|
18
|
+
return null;
|
|
19
|
+
let i = 0;
|
|
20
|
+
let cmd = '';
|
|
21
|
+
let minX = Infinity;
|
|
22
|
+
let minY = Infinity;
|
|
23
|
+
let maxX = -Infinity;
|
|
24
|
+
let maxY = -Infinity;
|
|
25
|
+
const addX = (x) => {
|
|
26
|
+
if (x < minX)
|
|
27
|
+
minX = x;
|
|
28
|
+
if (x > maxX)
|
|
29
|
+
maxX = x;
|
|
30
|
+
};
|
|
31
|
+
const addY = (y) => {
|
|
32
|
+
if (y < minY)
|
|
33
|
+
minY = y;
|
|
34
|
+
if (y > maxY)
|
|
35
|
+
maxY = y;
|
|
36
|
+
};
|
|
37
|
+
const num = () => parseFloat(tokens[i++]);
|
|
38
|
+
while (i < tokens.length) {
|
|
39
|
+
// Path commands are single letters. Use an anchored test so number tokens
|
|
40
|
+
// in scientific notation (e.g. "4.74e-16") aren't misread as commands.
|
|
41
|
+
if (/^[a-zA-Z]$/.test(tokens[i])) {
|
|
42
|
+
cmd = tokens[i];
|
|
43
|
+
i++;
|
|
44
|
+
}
|
|
45
|
+
const c = cmd.toUpperCase();
|
|
46
|
+
if (c === 'M' || c === 'L' || c === 'T') {
|
|
47
|
+
addX(num());
|
|
48
|
+
addY(num());
|
|
49
|
+
}
|
|
50
|
+
else if (c === 'C') {
|
|
51
|
+
addX(num());
|
|
52
|
+
addY(num());
|
|
53
|
+
addX(num());
|
|
54
|
+
addY(num());
|
|
55
|
+
addX(num());
|
|
56
|
+
addY(num());
|
|
57
|
+
}
|
|
58
|
+
else if (c === 'Q' || c === 'S') {
|
|
59
|
+
addX(num());
|
|
60
|
+
addY(num());
|
|
61
|
+
addX(num());
|
|
62
|
+
addY(num());
|
|
63
|
+
}
|
|
64
|
+
else if (c === 'H') {
|
|
65
|
+
addX(num());
|
|
66
|
+
}
|
|
67
|
+
else if (c === 'V') {
|
|
68
|
+
addY(num());
|
|
69
|
+
}
|
|
70
|
+
else if (c === 'A') {
|
|
71
|
+
num();
|
|
72
|
+
num();
|
|
73
|
+
num();
|
|
74
|
+
num();
|
|
75
|
+
num();
|
|
76
|
+
addX(num());
|
|
77
|
+
addY(num());
|
|
78
|
+
}
|
|
79
|
+
else if (c === 'Z') ;
|
|
80
|
+
else {
|
|
81
|
+
i++; // unknown token, skip to avoid infinite loop
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!Number.isFinite(minX) ||
|
|
85
|
+
!Number.isFinite(minY) ||
|
|
86
|
+
!Number.isFinite(maxX) ||
|
|
87
|
+
!Number.isFinite(maxY)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return { minX, minY, maxX, maxY };
|
|
91
|
+
}
|
|
92
|
+
function BaseShapeElement({ elementInfo }) {
|
|
93
|
+
const { fill } = useElementFill(elementInfo, 'base');
|
|
94
|
+
const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(elementInfo.outline);
|
|
95
|
+
const { shadowStyle } = useElementShadow(elementInfo.shadow);
|
|
96
|
+
const { flipStyle } = useElementFlip(elementInfo.flipH, elementInfo.flipV);
|
|
97
|
+
const text = elementInfo.text || {
|
|
98
|
+
content: '',
|
|
99
|
+
align: 'middle',
|
|
100
|
+
defaultFontName: 'Microsoft YaHei',
|
|
101
|
+
defaultColor: '#333333',
|
|
102
|
+
};
|
|
103
|
+
const justifyContent = text.align === 'top' ? 'flex-start' : text.align === 'bottom' ? 'flex-end' : 'center';
|
|
104
|
+
return (jsx("div", { className: "base-element-shape", style: {
|
|
105
|
+
position: 'absolute',
|
|
106
|
+
top: `${elementInfo.top}px`,
|
|
107
|
+
left: `${elementInfo.left}px`,
|
|
108
|
+
width: `${elementInfo.width}px`,
|
|
109
|
+
height: `${elementInfo.height}px`,
|
|
110
|
+
}, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
111
|
+
width: '100%',
|
|
112
|
+
height: '100%',
|
|
113
|
+
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
114
|
+
}, children: jsxs("div", { className: "element-content", style: {
|
|
115
|
+
position: 'relative',
|
|
116
|
+
width: '100%',
|
|
117
|
+
height: '100%',
|
|
118
|
+
opacity: elementInfo.opacity,
|
|
119
|
+
filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',
|
|
120
|
+
transform: flipStyle,
|
|
121
|
+
color: text.defaultColor,
|
|
122
|
+
fontFamily: text.defaultFontName,
|
|
123
|
+
}, children: [(() => {
|
|
124
|
+
// The shape's path can extend OUTSIDE its width×height box (e.g.
|
|
125
|
+
// curved connectors whose extreme adj values bulge the curve far
|
|
126
|
+
// past the bbox). A browser shows that via overflow:visible, but
|
|
127
|
+
// html2canvas-pro rasterizes each SVG to its width×height viewport
|
|
128
|
+
// and CLIPS the overflow — turning connector arcs into stubs in the
|
|
129
|
+
// exported PNG. Fix: grow the SVG viewport to contain the full path
|
|
130
|
+
// bbox and offset it back, so the geometry renders in the exact same
|
|
131
|
+
// place but nothing falls outside the captured viewport.
|
|
132
|
+
const sx = elementInfo.width / (elementInfo.viewBox[0] || elementInfo.width || 1);
|
|
133
|
+
const sy = elementInfo.height / (elementInfo.viewBox[1] || elementInfo.height || 1);
|
|
134
|
+
const bbox = pathCoordBBox(elementInfo.path);
|
|
135
|
+
const CAP = 4000; // guard against pathological coords blowing up the SVG
|
|
136
|
+
let padL = 0;
|
|
137
|
+
let padT = 0;
|
|
138
|
+
let padR = 0;
|
|
139
|
+
let padB = 0;
|
|
140
|
+
if (bbox) {
|
|
141
|
+
padL = Math.min(CAP, Math.max(0, -bbox.minX * sx));
|
|
142
|
+
padT = Math.min(CAP, Math.max(0, -bbox.minY * sy));
|
|
143
|
+
padR = Math.min(CAP, Math.max(0, bbox.maxX * sx - elementInfo.width));
|
|
144
|
+
padB = Math.min(CAP, Math.max(0, bbox.maxY * sy - elementInfo.height));
|
|
145
|
+
}
|
|
146
|
+
return (jsxs("svg", { overflow: "visible", width: elementInfo.width + padL + padR, height: elementInfo.height + padT + padB, style: {
|
|
147
|
+
position: 'absolute',
|
|
148
|
+
left: -padL,
|
|
149
|
+
top: -padT,
|
|
150
|
+
transformOrigin: '0 0',
|
|
151
|
+
overflow: 'visible',
|
|
152
|
+
display: 'block',
|
|
153
|
+
}, children: [jsxs("defs", { children: [elementInfo.pattern && (jsx(PatternDefs, { id: `base-pattern-${elementInfo.id}`, src: elementInfo.pattern })), elementInfo.gradient && (jsx(GradientDefs, { id: `base-gradient-${elementInfo.id}`, type: elementInfo.gradient.type, colors: elementInfo.gradient.colors, rotate: elementInfo.gradient.rotate }))] }), jsx("g", { transform: `translate(${padL},${padT}) scale(${sx}, ${sy})`, children: jsx("path", { vectorEffect: "non-scaling-stroke", strokeLinecap: "butt", strokeMiterlimit: "8", d: elementInfo.path, fill: fill, stroke: outlineColor, strokeWidth: outlineWidth, strokeDasharray: strokeDashArray }) })] }));
|
|
154
|
+
})(), jsx("div", { className: "shape-text", style: {
|
|
155
|
+
position: 'absolute',
|
|
156
|
+
inset: 0,
|
|
157
|
+
display: 'flex',
|
|
158
|
+
flexDirection: 'column',
|
|
159
|
+
justifyContent,
|
|
160
|
+
overflowWrap: 'break-word',
|
|
161
|
+
lineHeight: text.lineHeight,
|
|
162
|
+
letterSpacing: `${text.wordSpace || 0}px`,
|
|
163
|
+
// PowerPoint/WPS 在 group flipH/flipV 时只镜像几何与位置,文字字形保持
|
|
164
|
+
// 正向。父层 element-content 已应用 flipStyle 镜像 SVG path;这里给文字
|
|
165
|
+
// 叠加同一个 flipStyle,两次 flip 抵消,让文字保持正向。
|
|
166
|
+
transform: flipStyle,
|
|
167
|
+
}, children: jsx("div", { className: "ProseMirror-static slide-renderer-prose", style: {
|
|
168
|
+
// @ts-expect-error CSS custom properties
|
|
169
|
+
'--paragraphSpace': `${text.paragraphSpace === undefined ? 5 : text.paragraphSpace}px`,
|
|
170
|
+
}, dangerouslySetInnerHTML: { __html: text.content } }) })] }) }) }));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { BaseShapeElement };
|
|
174
|
+
//# sourceMappingURL=BaseShapeElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseShapeElement.js","sources":["../../../src/elements/shape/BaseShapeElement.tsx"],"sourcesContent":["'use client';\n\nimport type { PPTShapeElement, ShapeText } from '@openmaic/dsl';\nimport { useElementOutline } from '../shared/useElementOutline';\nimport { useElementShadow } from '../shared/useElementShadow';\nimport { useElementFlip } from '../shared/useElementFlip';\nimport { useElementFill } from '../shared/useElementFill';\nimport { GradientDefs } from './GradientDefs';\nimport { PatternDefs } from './PatternDefs';\n\nexport interface BaseShapeElementProps {\n elementInfo: PPTShapeElement;\n}\n\n/**\n * Bounding box of a path's coordinates (path/viewBox space). Uses control\n * points for curves (a safe superset). Handles the commands our shapes emit\n * (M/L/C/Q/S/H/V/A/T/Z, absolute). Returns null if no coordinates.\n */\nfunction pathCoordBBox(\n d: string,\n): { minX: number; minY: number; maxX: number; maxY: number } | null {\n const tokens = d.match(/[a-zA-Z]|-?\\d*\\.?\\d+(?:e[-+]?\\d+)?/gi);\n if (!tokens) return null;\n let i = 0;\n let cmd = '';\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n const addX = (x: number) => {\n if (x < minX) minX = x;\n if (x > maxX) maxX = x;\n };\n const addY = (y: number) => {\n if (y < minY) minY = y;\n if (y > maxY) maxY = y;\n };\n const num = () => parseFloat(tokens[i++]);\n while (i < tokens.length) {\n // Path commands are single letters. Use an anchored test so number tokens\n // in scientific notation (e.g. \"4.74e-16\") aren't misread as commands.\n if (/^[a-zA-Z]$/.test(tokens[i])) {\n cmd = tokens[i];\n i++;\n }\n const c = cmd.toUpperCase();\n if (c === 'M' || c === 'L' || c === 'T') {\n addX(num());\n addY(num());\n } else if (c === 'C') {\n addX(num());\n addY(num());\n addX(num());\n addY(num());\n addX(num());\n addY(num());\n } else if (c === 'Q' || c === 'S') {\n addX(num());\n addY(num());\n addX(num());\n addY(num());\n } else if (c === 'H') {\n addX(num());\n } else if (c === 'V') {\n addY(num());\n } else if (c === 'A') {\n num();\n num();\n num();\n num();\n num();\n addX(num());\n addY(num());\n } else if (c === 'Z') {\n // no coords\n } else {\n i++; // unknown token, skip to avoid infinite loop\n }\n }\n if (\n !Number.isFinite(minX) ||\n !Number.isFinite(minY) ||\n !Number.isFinite(maxX) ||\n !Number.isFinite(maxY)\n ) {\n return null;\n }\n return { minX, minY, maxX, maxY };\n}\n\nexport function BaseShapeElement({ elementInfo }: BaseShapeElementProps) {\n const { fill } = useElementFill(elementInfo, 'base');\n const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(elementInfo.outline);\n const { shadowStyle } = useElementShadow(elementInfo.shadow);\n const { flipStyle } = useElementFlip(elementInfo.flipH, elementInfo.flipV);\n\n const text: ShapeText = elementInfo.text || {\n content: '',\n align: 'middle',\n defaultFontName: 'Microsoft YaHei',\n defaultColor: '#333333',\n };\n\n const justifyContent =\n text.align === 'top' ? 'flex-start' : text.align === 'bottom' ? 'flex-end' : 'center';\n\n return (\n <div\n className=\"base-element-shape\"\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n }}\n >\n <div\n className=\"rotate-wrapper\"\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n }}\n >\n <div\n className=\"element-content\"\n style={{\n position: 'relative',\n width: '100%',\n height: '100%',\n opacity: elementInfo.opacity,\n filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',\n transform: flipStyle,\n color: text.defaultColor,\n fontFamily: text.defaultFontName,\n }}\n >\n {(() => {\n // The shape's path can extend OUTSIDE its width×height box (e.g.\n // curved connectors whose extreme adj values bulge the curve far\n // past the bbox). A browser shows that via overflow:visible, but\n // html2canvas-pro rasterizes each SVG to its width×height viewport\n // and CLIPS the overflow — turning connector arcs into stubs in the\n // exported PNG. Fix: grow the SVG viewport to contain the full path\n // bbox and offset it back, so the geometry renders in the exact same\n // place but nothing falls outside the captured viewport.\n const sx = elementInfo.width / (elementInfo.viewBox[0] || elementInfo.width || 1);\n const sy = elementInfo.height / (elementInfo.viewBox[1] || elementInfo.height || 1);\n const bbox = pathCoordBBox(elementInfo.path);\n const CAP = 4000; // guard against pathological coords blowing up the SVG\n let padL = 0;\n let padT = 0;\n let padR = 0;\n let padB = 0;\n if (bbox) {\n padL = Math.min(CAP, Math.max(0, -bbox.minX * sx));\n padT = Math.min(CAP, Math.max(0, -bbox.minY * sy));\n padR = Math.min(CAP, Math.max(0, bbox.maxX * sx - elementInfo.width));\n padB = Math.min(CAP, Math.max(0, bbox.maxY * sy - elementInfo.height));\n }\n return (\n <svg\n overflow=\"visible\"\n width={elementInfo.width + padL + padR}\n height={elementInfo.height + padT + padB}\n style={{\n position: 'absolute',\n left: -padL,\n top: -padT,\n transformOrigin: '0 0',\n overflow: 'visible',\n display: 'block',\n }}\n >\n <defs>\n {elementInfo.pattern && (\n <PatternDefs id={`base-pattern-${elementInfo.id}`} src={elementInfo.pattern} />\n )}\n {elementInfo.gradient && (\n <GradientDefs\n id={`base-gradient-${elementInfo.id}`}\n type={elementInfo.gradient.type}\n colors={elementInfo.gradient.colors}\n rotate={elementInfo.gradient.rotate}\n />\n )}\n </defs>\n <g transform={`translate(${padL},${padT}) scale(${sx}, ${sy})`}>\n <path\n vectorEffect=\"non-scaling-stroke\"\n strokeLinecap=\"butt\"\n strokeMiterlimit=\"8\"\n d={elementInfo.path}\n fill={fill}\n stroke={outlineColor}\n strokeWidth={outlineWidth}\n strokeDasharray={strokeDashArray}\n />\n </g>\n </svg>\n );\n })()}\n\n <div\n className=\"shape-text\"\n style={{\n position: 'absolute',\n inset: 0,\n display: 'flex',\n flexDirection: 'column',\n justifyContent,\n overflowWrap: 'break-word',\n lineHeight: text.lineHeight,\n letterSpacing: `${text.wordSpace || 0}px`,\n // PowerPoint/WPS 在 group flipH/flipV 时只镜像几何与位置,文字字形保持\n // 正向。父层 element-content 已应用 flipStyle 镜像 SVG path;这里给文字\n // 叠加同一个 flipStyle,两次 flip 抵消,让文字保持正向。\n transform: flipStyle,\n }}\n >\n <div\n className=\"ProseMirror-static slide-renderer-prose\"\n style={{\n // @ts-expect-error CSS custom properties\n '--paragraphSpace': `${text.paragraphSpace === undefined ? 5 : text.paragraphSpace}px`,\n }}\n dangerouslySetInnerHTML={{ __html: text.content }}\n />\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAcA;;;;AAIG;AACH;;AAIE;AAAa;;;;;AAKb;AACA;AACA;;;;;AAGA;AACA;;;;;AAGA;AACA;AACA;;;;AAII;AACA;;AAEF;AACA;AACE;AACA;;AACK;AACL;AACA;AACA;AACA;AACA;AACA;;;AAEA;AACA;AACA;AACA;;AACK;AACL;;AACK;AACL;;AACK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AACK;;;;;AAMT;AAEE;AACA;AACA;AAEA;;;AAGJ;AAEM;;AAEJ;;AAEA;AAEA;AACE;AACA;AACA;AACA;;;AAMF;AAIM;AACA;AACA;AACA;AACA;AACD;AAKG;AACA;AACA;AACD;AAKG;AACA;AACA;;;AAGA;;;;;;;;;;;;;;;AAiBA;;;;;;;;;;;;AAiBM;;;AAGA;AACA;AACA;;;AAmCJ;AACA;AACA;AACA;;AAEA;;AAEA;;;;AAIA;AACD;;AAMG;AACD;AAQf;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
function GradientDefs({ id, type, colors, rotate = 0 }) {
|
|
4
|
+
if (type === 'linear') {
|
|
5
|
+
return (jsx("linearGradient", { id: id, x1: "0%", y1: "0%", x2: "100%", y2: "0%", gradientTransform: `rotate(${rotate},0.5,0.5)`, children: colors.map((item, index) => (jsx("stop", { offset: `${item.pos}%`, stopColor: item.color }, index))) }));
|
|
6
|
+
}
|
|
7
|
+
return (jsx("radialGradient", { id: id, children: colors.map((item, index) => (jsx("stop", { offset: `${item.pos}%`, stopColor: item.color }, index))) }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { GradientDefs };
|
|
11
|
+
//# sourceMappingURL=GradientDefs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GradientDefs.js","sources":["../../../src/elements/shape/GradientDefs.tsx"],"sourcesContent":["import type { GradientColor, GradientType } from '@openmaic/dsl';\n\ninterface GradientDefsProps {\n id: string;\n type: GradientType;\n colors: GradientColor[];\n rotate?: number;\n}\n\nexport function GradientDefs({ id, type, colors, rotate = 0 }: GradientDefsProps) {\n if (type === 'linear') {\n return (\n <linearGradient\n id={id}\n x1=\"0%\"\n y1=\"0%\"\n x2=\"100%\"\n y2=\"0%\"\n gradientTransform={`rotate(${rotate},0.5,0.5)`}\n >\n {colors.map((item, index) => (\n <stop key={index} offset={`${item.pos}%`} stopColor={item.color} />\n ))}\n </linearGradient>\n );\n }\n\n return (\n <radialGradient id={id}>\n {colors.map((item, index) => (\n <stop key={index} offset={`${item.pos}%`} stopColor={item.color} />\n ))}\n </radialGradient>\n );\n}\n"],"names":["_jsx"],"mappings":";;AASM,SAAU,YAAY,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAqB,EAAA;AAC9E,IAAA,IAAI,IAAI,KAAK,QAAQ,EAAE;AACrB,QAAA,QACEA,GAAA,CAAA,gBAAA,EAAA,EACE,EAAE,EAAE,EAAE,EACN,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,MAAM,EACT,EAAE,EAAC,IAAI,EACP,iBAAiB,EAAE,CAAA,OAAA,EAAU,MAAM,CAAA,SAAA,CAAW,EAAA,QAAA,EAE7C,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACtBA,GAAA,CAAA,MAAA,EAAA,EAAkB,MAAM,EAAE,CAAA,EAAG,IAAI,CAAC,GAAG,CAAA,CAAA,CAAG,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,EAAA,EAApD,KAAK,CAAmD,CACpE,CAAC,EAAA,CACa;IAErB;AAEA,IAAA,QACEA,GAAA,CAAA,gBAAA,EAAA,EAAgB,EAAE,EAAE,EAAE,YACnB,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACtBA,GAAA,CAAA,MAAA,EAAA,EAAkB,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAA,CAAA,CAAG,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,IAApD,KAAK,CAAmD,CACpE,CAAC,EAAA,CACa;AAErB;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
function PatternDefs({ id, src }) {
|
|
4
|
+
return (jsx("pattern", { id: id, patternContentUnits: "objectBoundingBox", patternUnits: "objectBoundingBox", width: "1", height: "1", children: jsx("image", { href: src, width: "1", height: "1", preserveAspectRatio: "xMidYMid slice" }) }));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { PatternDefs };
|
|
8
|
+
//# sourceMappingURL=PatternDefs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PatternDefs.js","sources":["../../../src/elements/shape/PatternDefs.tsx"],"sourcesContent":["interface PatternDefsProps {\n id: string;\n src: string;\n}\n\nexport function PatternDefs({ id, src }: PatternDefsProps) {\n return (\n <pattern\n id={id}\n patternContentUnits=\"objectBoundingBox\"\n patternUnits=\"objectBoundingBox\"\n width=\"1\"\n height=\"1\"\n >\n <image href={src} width=\"1\" height=\"1\" preserveAspectRatio=\"xMidYMid slice\" />\n </pattern>\n );\n}\n"],"names":["_jsx"],"mappings":";;SAKgB,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,EAAoB,EAAA;AACvD,IAAA,QACEA,GAAA,CAAA,SAAA,EAAA,EACE,EAAE,EAAE,EAAE,EACN,mBAAmB,EAAC,mBAAmB,EACvC,YAAY,EAAC,mBAAmB,EAChC,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,GAAG,EAAA,QAAA,EAEVA,eAAO,IAAI,EAAE,GAAG,EAAE,KAAK,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG,EAAC,mBAAmB,EAAC,gBAAgB,EAAA,CAAG,EAAA,CACtE;AAEd;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useElementOutline } from './useElementOutline.js';
|
|
4
|
+
|
|
5
|
+
function ElementOutline({ width, height, outline }) {
|
|
6
|
+
const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);
|
|
7
|
+
if (!outline)
|
|
8
|
+
return null;
|
|
9
|
+
return (jsx("svg", { className: "element-outline", style: { position: 'absolute', top: 0, left: 0, overflow: 'visible' }, width: width, height: height, children: jsx("path", { vectorEffect: "non-scaling-stroke", strokeLinecap: "butt", strokeMiterlimit: "8", fill: "transparent", d: `M0,0 L${width},0 L${width},${height} L0,${height} Z`, stroke: outlineColor, strokeWidth: outlineWidth, strokeDasharray: strokeDashArray }) }));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { ElementOutline };
|
|
13
|
+
//# sourceMappingURL=ElementOutline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ElementOutline.js","sources":["../../../src/elements/shared/ElementOutline.tsx"],"sourcesContent":["'use client';\n\nimport type { PPTElementOutline } from '@openmaic/dsl';\nimport { useElementOutline } from './useElementOutline';\n\nexport interface ElementOutlineProps {\n width: number;\n height: number;\n outline?: PPTElementOutline;\n}\n\nexport function ElementOutline({ width, height, outline }: ElementOutlineProps) {\n const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);\n\n if (!outline) return null;\n\n return (\n <svg\n className=\"element-outline\"\n style={{ position: 'absolute', top: 0, left: 0, overflow: 'visible' }}\n width={width}\n height={height}\n >\n <path\n vectorEffect=\"non-scaling-stroke\"\n strokeLinecap=\"butt\"\n strokeMiterlimit=\"8\"\n fill=\"transparent\"\n d={`M0,0 L${width},0 L${width},${height} L0,${height} Z`}\n stroke={outlineColor}\n strokeWidth={outlineWidth}\n strokeDasharray={strokeDashArray}\n />\n </svg>\n );\n}\n"],"names":[],"mappings":";;;;AAWM;AACJ;AAEA;AAAc;AAEd;AAmBF;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
function useElementFill(element, source) {
|
|
4
|
+
const fill = useMemo(() => {
|
|
5
|
+
if (element.pattern)
|
|
6
|
+
return `url(#${source}-pattern-${element.id})`;
|
|
7
|
+
if (element.gradient)
|
|
8
|
+
return `url(#${source}-gradient-${element.id})`;
|
|
9
|
+
return element.fill || 'none';
|
|
10
|
+
}, [element.pattern, element.gradient, element.fill, element.id, source]);
|
|
11
|
+
return { fill };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { useElementFill };
|
|
15
|
+
//# sourceMappingURL=useElementFill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementFill.js","sources":["../../../src/elements/shared/useElementFill.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { PPTShapeElement } from '@openmaic/dsl';\n\nexport function useElementFill(element: PPTShapeElement, source: string) {\n const fill = useMemo(() => {\n if (element.pattern) return `url(#${source}-pattern-${element.id})`;\n if (element.gradient) return `url(#${source}-gradient-${element.id})`;\n return element.fill || 'none';\n }, [element.pattern, element.gradient, element.fill, element.id, source]);\n\n return { fill };\n}\n"],"names":[],"mappings":";;AAGM,SAAU,cAAc,CAAC,OAAwB,EAAE,MAAc,EAAA;AACrE,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAK;QACxB,IAAI,OAAO,CAAC,OAAO;AAAE,YAAA,OAAO,QAAQ,MAAM,CAAA,SAAA,EAAY,OAAO,CAAC,EAAE,GAAG;QACnE,IAAI,OAAO,CAAC,QAAQ;AAAE,YAAA,OAAO,QAAQ,MAAM,CAAA,UAAA,EAAa,OAAO,CAAC,EAAE,GAAG;AACrE,QAAA,OAAO,OAAO,CAAC,IAAI,IAAI,MAAM;IAC/B,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAEzE,OAAO,EAAE,IAAI,EAAE;AACjB;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
function useElementFlip(flipH, flipV) {
|
|
4
|
+
const flipStyle = useMemo(() => {
|
|
5
|
+
let style = '';
|
|
6
|
+
if (flipH && flipV)
|
|
7
|
+
style = 'rotateX(180deg) rotateY(180deg)';
|
|
8
|
+
else if (flipV)
|
|
9
|
+
style = 'rotateX(180deg)';
|
|
10
|
+
else if (flipH)
|
|
11
|
+
style = 'rotateY(180deg)';
|
|
12
|
+
return style;
|
|
13
|
+
}, [flipH, flipV]);
|
|
14
|
+
return { flipStyle };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { useElementFlip };
|
|
18
|
+
//# sourceMappingURL=useElementFlip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementFlip.js","sources":["../../../src/elements/shared/useElementFlip.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nexport function useElementFlip(flipH?: boolean, flipV?: boolean) {\n const flipStyle = useMemo(() => {\n let style = '';\n if (flipH && flipV) style = 'rotateX(180deg) rotateY(180deg)';\n else if (flipV) style = 'rotateX(180deg)';\n else if (flipH) style = 'rotateY(180deg)';\n return style;\n }, [flipH, flipV]);\n\n return { flipStyle };\n}\n"],"names":[],"mappings":";;AAEM,SAAU,cAAc,CAAC,KAAe,EAAE,KAAe,EAAA;AAC7D,IAAA,MAAM,SAAS,GAAG,OAAO,CAAC,MAAK;QAC7B,IAAI,KAAK,GAAG,EAAE;QACd,IAAI,KAAK,IAAI,KAAK;YAAE,KAAK,GAAG,iCAAiC;AACxD,aAAA,IAAI,KAAK;YAAE,KAAK,GAAG,iBAAiB;AACpC,aAAA,IAAI,KAAK;YAAE,KAAK,GAAG,iBAAiB;AACzC,QAAA,OAAO,KAAK;AACd,IAAA,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAElB,OAAO,EAAE,SAAS,EAAE;AACtB;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
function useElementOutline(outline) {
|
|
4
|
+
const outlineWidth = useMemo(() => outline?.width ?? 0, [outline?.width]);
|
|
5
|
+
const outlineStyle = useMemo(() => outline?.style || 'solid', [outline?.style]);
|
|
6
|
+
const outlineColor = useMemo(() => outline?.color || '#d14424', [outline?.color]);
|
|
7
|
+
const strokeDashArray = useMemo(() => {
|
|
8
|
+
const size = outlineWidth;
|
|
9
|
+
if (outlineStyle === 'dashed')
|
|
10
|
+
return size <= 6 ? `${size * 4.5} ${size * 2}` : `${size * 4} ${size * 1.5}`;
|
|
11
|
+
if (outlineStyle === 'dotted')
|
|
12
|
+
return size <= 6 ? `${size * 1.8} ${size * 1.6}` : `${size * 1.5} ${size * 1.2}`;
|
|
13
|
+
return '0 0';
|
|
14
|
+
}, [outlineWidth, outlineStyle]);
|
|
15
|
+
return { outlineWidth, outlineStyle, outlineColor, strokeDashArray };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { useElementOutline };
|
|
19
|
+
//# sourceMappingURL=useElementOutline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementOutline.js","sources":["../../../src/elements/shared/useElementOutline.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { PPTElementOutline } from '@openmaic/dsl';\n\nexport function useElementOutline(outline?: PPTElementOutline) {\n const outlineWidth = useMemo(() => outline?.width ?? 0, [outline?.width]);\n const outlineStyle = useMemo(() => outline?.style || 'solid', [outline?.style]);\n const outlineColor = useMemo(() => outline?.color || '#d14424', [outline?.color]);\n\n const strokeDashArray = useMemo(() => {\n const size = outlineWidth;\n if (outlineStyle === 'dashed')\n return size <= 6 ? `${size * 4.5} ${size * 2}` : `${size * 4} ${size * 1.5}`;\n if (outlineStyle === 'dotted')\n return size <= 6 ? `${size * 1.8} ${size * 1.6}` : `${size * 1.5} ${size * 1.2}`;\n return '0 0';\n }, [outlineWidth, outlineStyle]);\n\n return { outlineWidth, outlineStyle, outlineColor, strokeDashArray };\n}\n"],"names":[],"mappings":";;AAGM,SAAU,iBAAiB,CAAC,OAA2B,EAAA;AAC3D,IAAA,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACzE,IAAA,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC/E,IAAA,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAEjF,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,MAAK;QACnC,MAAM,IAAI,GAAG,YAAY;QACzB,IAAI,YAAY,KAAK,QAAQ;YAC3B,OAAO,IAAI,IAAI,CAAC,GAAG,CAAA,EAAG,IAAI,GAAG,GAAG,CAAA,CAAA,EAAI,IAAI,GAAG,CAAC,CAAA,CAAE,GAAG,CAAA,EAAG,IAAI,GAAG,CAAC,CAAA,CAAA,EAAI,IAAI,GAAG,GAAG,CAAA,CAAE;QAC9E,IAAI,YAAY,KAAK,QAAQ;YAC3B,OAAO,IAAI,IAAI,CAAC,GAAG,CAAA,EAAG,IAAI,GAAG,GAAG,CAAA,CAAA,EAAI,IAAI,GAAG,GAAG,CAAA,CAAE,GAAG,CAAA,EAAG,IAAI,GAAG,GAAG,CAAA,CAAA,EAAI,IAAI,GAAG,GAAG,CAAA,CAAE;AAClF,QAAA,OAAO,KAAK;AACd,IAAA,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAEhC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE;AACtE;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
function useElementShadow(shadow) {
|
|
4
|
+
const shadowStyle = useMemo(() => {
|
|
5
|
+
if (shadow) {
|
|
6
|
+
const { h, v, blur, color } = shadow;
|
|
7
|
+
return `${h}px ${v}px ${blur}px ${color}`;
|
|
8
|
+
}
|
|
9
|
+
return '';
|
|
10
|
+
}, [shadow]);
|
|
11
|
+
return { shadowStyle };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { useElementShadow };
|
|
15
|
+
//# sourceMappingURL=useElementShadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementShadow.js","sources":["../../../src/elements/shared/useElementShadow.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { PPTElementShadow } from '@openmaic/dsl';\n\nexport function useElementShadow(shadow?: PPTElementShadow) {\n const shadowStyle = useMemo(() => {\n if (shadow) {\n const { h, v, blur, color } = shadow;\n return `${h}px ${v}px ${blur}px ${color}`;\n }\n return '';\n }, [shadow]);\n\n return { shadowStyle };\n}\n"],"names":[],"mappings":";;AAGM,SAAU,gBAAgB,CAAC,MAAyB,EAAA;AACxD,IAAA,MAAM,WAAW,GAAG,OAAO,CAAC,MAAK;QAC/B,IAAI,MAAM,EAAE;YACV,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM;YACpC,OAAO,CAAA,EAAG,CAAC,CAAA,GAAA,EAAM,CAAC,MAAM,IAAI,CAAA,GAAA,EAAM,KAAK,CAAA,CAAE;QAC3C;AACA,QAAA,OAAO,EAAE;AACX,IAAA,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAEZ,OAAO,EAAE,WAAW,EAAE;AACxB;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { StaticTable } from './StaticTable.js';
|
|
4
|
+
|
|
5
|
+
function BaseTableElement({ elementInfo, target }) {
|
|
6
|
+
return (jsx("div", { className: "base-element-table", style: {
|
|
7
|
+
position: 'absolute',
|
|
8
|
+
top: `${elementInfo.top}px`,
|
|
9
|
+
left: `${elementInfo.left}px`,
|
|
10
|
+
width: `${elementInfo.width}px`,
|
|
11
|
+
height: `${elementInfo.height}px`,
|
|
12
|
+
pointerEvents: target === 'thumbnail' ? 'none' : undefined,
|
|
13
|
+
}, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
14
|
+
width: '100%',
|
|
15
|
+
height: '100%',
|
|
16
|
+
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
17
|
+
}, children: jsx("div", { className: "element-content", style: { width: '100%', height: '100%' }, children: jsx(StaticTable, { elementInfo: elementInfo }) }) }) }));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { BaseTableElement };
|
|
21
|
+
//# sourceMappingURL=BaseTableElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseTableElement.js","sources":["../../../src/elements/table/BaseTableElement.tsx"],"sourcesContent":["'use client';\n\nimport type { PPTTableElement } from '@openmaic/dsl';\nimport { StaticTable } from './StaticTable';\n\nexport interface BaseTableElementProps {\n elementInfo: PPTTableElement;\n target?: string;\n}\n\nexport function BaseTableElement({ elementInfo, target }: BaseTableElementProps) {\n return (\n <div\n className=\"base-element-table\"\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n pointerEvents: target === 'thumbnail' ? 'none' : undefined,\n }}\n >\n <div\n className=\"rotate-wrapper\"\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n }}\n >\n <div className=\"element-content\" style={{ width: '100%', height: '100%' }}>\n <StaticTable elementInfo={elementInfo} />\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AAWE;AAIM;AACA;AACA;AACA;AACA;;AAED;AAKG;AACA;AACA;AACD;AAQT;;"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { getTableSubThemeColor } from '../../utils/element.js';
|
|
5
|
+
import { getTextStyle } from './tableUtils.js';
|
|
6
|
+
|
|
7
|
+
function cellBorderCss(b) {
|
|
8
|
+
if (!b || b.width <= 0)
|
|
9
|
+
return undefined;
|
|
10
|
+
const style = b.style === 'dashed' || b.style === 'dotted' ? b.style : 'solid';
|
|
11
|
+
return `${b.width}px ${style} ${b.color}`;
|
|
12
|
+
}
|
|
13
|
+
function StaticTable({ elementInfo }) {
|
|
14
|
+
const { width, data, colWidths, cellMinHeight, rowHeights, outline, theme } = elementInfo;
|
|
15
|
+
const [subThemeDark, subThemeLight] = useMemo(() => {
|
|
16
|
+
if (!theme)
|
|
17
|
+
return ['', ''];
|
|
18
|
+
return getTableSubThemeColor(theme.color);
|
|
19
|
+
}, [theme]);
|
|
20
|
+
const borderStyle = useMemo(() => {
|
|
21
|
+
if (!outline)
|
|
22
|
+
return 'none';
|
|
23
|
+
const w = outline.width ?? 1;
|
|
24
|
+
const c = outline.color ?? '#000';
|
|
25
|
+
const s = outline.style === 'dashed' ? 'dashed' : 'solid';
|
|
26
|
+
return `${w}px ${s} ${c}`;
|
|
27
|
+
}, [outline]);
|
|
28
|
+
const getCellBg = (rowIdx, colIdx, cellBackcolor) => {
|
|
29
|
+
if (cellBackcolor)
|
|
30
|
+
return cellBackcolor;
|
|
31
|
+
if (!theme)
|
|
32
|
+
return undefined;
|
|
33
|
+
const rowCount = data.length;
|
|
34
|
+
const colCount = data[0]?.length ?? 0;
|
|
35
|
+
if (theme.rowHeader && rowIdx === 0)
|
|
36
|
+
return theme.color;
|
|
37
|
+
if (theme.rowFooter && rowIdx === rowCount - 1)
|
|
38
|
+
return theme.color;
|
|
39
|
+
if (theme.colHeader && colIdx === 0)
|
|
40
|
+
return subThemeDark;
|
|
41
|
+
if (theme.colFooter && colIdx === colCount - 1)
|
|
42
|
+
return subThemeDark;
|
|
43
|
+
const effectiveRow = theme.rowHeader ? rowIdx - 1 : rowIdx;
|
|
44
|
+
if (effectiveRow >= 0 && effectiveRow % 2 === 0)
|
|
45
|
+
return subThemeLight;
|
|
46
|
+
return undefined;
|
|
47
|
+
};
|
|
48
|
+
const getHeaderTextColor = (rowIdx) => {
|
|
49
|
+
if (!theme)
|
|
50
|
+
return undefined;
|
|
51
|
+
const rowCount = data.length;
|
|
52
|
+
if (theme.rowHeader && rowIdx === 0)
|
|
53
|
+
return '#fff';
|
|
54
|
+
if (theme.rowFooter && rowIdx === rowCount - 1)
|
|
55
|
+
return '#fff';
|
|
56
|
+
return undefined;
|
|
57
|
+
};
|
|
58
|
+
return (jsxs("table", { className: "slide-renderer-prose", style: {
|
|
59
|
+
width: '100%',
|
|
60
|
+
height: '100%',
|
|
61
|
+
borderCollapse: 'collapse',
|
|
62
|
+
tableLayout: 'fixed',
|
|
63
|
+
}, children: [jsx("colgroup", { children: colWidths.map((w, i) => (jsx("col", { style: { width: `${w * width}px` } }, i))) }), jsx("tbody", { children: data.map((row, rowIdx) => (jsx("tr", { style: { height: `${rowHeights?.[rowIdx] ?? cellMinHeight}px` }, children: row.map((cell, colIdx) => {
|
|
64
|
+
// parser side (transformParsedToSlides) 已经把 hMerge/vMerge
|
|
65
|
+
// continuation 单元格剔除了,data[r] 只剩 top-left cells;浏览器
|
|
66
|
+
// 的 HTML table layout 通过 td.colSpan/rowSpan 自动算正确位置,
|
|
67
|
+
// 不需要再手动算 hiddenCells(旧实现用 data-index 比对 grid-coord
|
|
68
|
+
// key,混了两种坐标系,把 colspan 跨过的 grid-coord 等于另一格
|
|
69
|
+
// 的 data-index 时会误隐藏,slide 26 表头 "权重"/"好" 就是中招)。
|
|
70
|
+
const bgColor = getCellBg(rowIdx, colIdx, cell.style?.backcolor);
|
|
71
|
+
const headerColor = getHeaderTextColor(rowIdx);
|
|
72
|
+
const textStyle = getTextStyle(cell.style);
|
|
73
|
+
if (headerColor && !cell.style?.color) {
|
|
74
|
+
textStyle.color = headerColor;
|
|
75
|
+
}
|
|
76
|
+
// 单元格自带逐边描边时按边渲染(未定义的边不画);否则回退到
|
|
77
|
+
// 表级 outline 套四边的旧行为,保留真·网格表格的表现。
|
|
78
|
+
const cellBorders = cell.borders;
|
|
79
|
+
const borderCss = cellBorders &&
|
|
80
|
+
(cellBorders.top || cellBorders.bottom || cellBorders.left || cellBorders.right)
|
|
81
|
+
? {
|
|
82
|
+
borderTop: cellBorderCss(cellBorders.top) ?? 'none',
|
|
83
|
+
borderBottom: cellBorderCss(cellBorders.bottom) ?? 'none',
|
|
84
|
+
borderLeft: cellBorderCss(cellBorders.left) ?? 'none',
|
|
85
|
+
borderRight: cellBorderCss(cellBorders.right) ?? 'none',
|
|
86
|
+
}
|
|
87
|
+
: { border: borderStyle };
|
|
88
|
+
return (jsx("td", { colSpan: cell.colspan > 1 ? cell.colspan : undefined, rowSpan: cell.rowspan > 1 ? cell.rowspan : undefined, style: {
|
|
89
|
+
...borderCss,
|
|
90
|
+
backgroundColor: bgColor,
|
|
91
|
+
...textStyle,
|
|
92
|
+
}, children: jsx("div", { className: "slide-renderer-cell-text", style: {
|
|
93
|
+
minHeight: `${(rowHeights?.[rowIdx] ?? cellMinHeight) - 4}px`,
|
|
94
|
+
padding: cell.padding,
|
|
95
|
+
display: 'flex',
|
|
96
|
+
flexDirection: 'column',
|
|
97
|
+
lineHeight: 1,
|
|
98
|
+
justifyContent: cell.vAlign === 'top'
|
|
99
|
+
? 'flex-start'
|
|
100
|
+
: cell.vAlign === 'bottom'
|
|
101
|
+
? 'flex-end'
|
|
102
|
+
: cell.vAlign === 'middle'
|
|
103
|
+
? 'center'
|
|
104
|
+
: undefined,
|
|
105
|
+
},
|
|
106
|
+
// cell.text is already final HTML (transformParsedToSlides
|
|
107
|
+
// escapes text + converts \n/spaces and keeps <p> positioning
|
|
108
|
+
// styles). Do NOT run formatText here — its space→
|
|
109
|
+
// replacement corrupts style attributes like
|
|
110
|
+
// `margin-left: calc(42px + 0.25em)` → the title indent is
|
|
111
|
+
// lost and collides with the cell's left icon (slide 5).
|
|
112
|
+
dangerouslySetInnerHTML: { __html: cell.text } }) }, cell.id));
|
|
113
|
+
}) }, rowIdx))) })] }));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { StaticTable };
|
|
117
|
+
//# sourceMappingURL=StaticTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StaticTable.js","sources":["../../../src/elements/table/StaticTable.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo, type CSSProperties } from 'react';\nimport type { PPTTableElement, TableCellBorder } from '@openmaic/dsl';\nimport { getTableSubThemeColor } from '../../utils/element';\nimport { getTextStyle } from './tableUtils';\n\nfunction cellBorderCss(b?: TableCellBorder): string | undefined {\n if (!b || b.width <= 0) return undefined;\n const style = b.style === 'dashed' || b.style === 'dotted' ? b.style : 'solid';\n return `${b.width}px ${style} ${b.color}`;\n}\n\ninterface StaticTableProps {\n elementInfo: PPTTableElement;\n}\n\nexport function StaticTable({ elementInfo }: StaticTableProps) {\n const { width, data, colWidths, cellMinHeight, rowHeights, outline, theme } = elementInfo;\n\n const [subThemeDark, subThemeLight] = useMemo(() => {\n if (!theme) return ['', ''];\n return getTableSubThemeColor(theme.color);\n }, [theme]);\n\n const borderStyle = useMemo(() => {\n if (!outline) return 'none';\n const w = outline.width ?? 1;\n const c = outline.color ?? '#000';\n const s = outline.style === 'dashed' ? 'dashed' : 'solid';\n return `${w}px ${s} ${c}`;\n }, [outline]);\n\n const getCellBg = (\n rowIdx: number,\n colIdx: number,\n cellBackcolor?: string,\n ): string | undefined => {\n if (cellBackcolor) return cellBackcolor;\n if (!theme) return undefined;\n\n const rowCount = data.length;\n const colCount = data[0]?.length ?? 0;\n\n if (theme.rowHeader && rowIdx === 0) return theme.color;\n if (theme.rowFooter && rowIdx === rowCount - 1) return theme.color;\n if (theme.colHeader && colIdx === 0) return subThemeDark;\n if (theme.colFooter && colIdx === colCount - 1) return subThemeDark;\n\n const effectiveRow = theme.rowHeader ? rowIdx - 1 : rowIdx;\n if (effectiveRow >= 0 && effectiveRow % 2 === 0) return subThemeLight;\n\n return undefined;\n };\n\n const getHeaderTextColor = (rowIdx: number): string | undefined => {\n if (!theme) return undefined;\n const rowCount = data.length;\n if (theme.rowHeader && rowIdx === 0) return '#fff';\n if (theme.rowFooter && rowIdx === rowCount - 1) return '#fff';\n return undefined;\n };\n\n return (\n <table\n className=\"slide-renderer-prose\"\n style={{\n width: '100%',\n height: '100%',\n borderCollapse: 'collapse',\n tableLayout: 'fixed',\n }}\n >\n <colgroup>\n {colWidths.map((w, i) => (\n <col key={i} style={{ width: `${w * width}px` }} />\n ))}\n </colgroup>\n <tbody>\n {data.map((row, rowIdx) => (\n <tr key={rowIdx} style={{ height: `${rowHeights?.[rowIdx] ?? cellMinHeight}px` }}>\n {row.map((cell, colIdx) => {\n // parser side (transformParsedToSlides) 已经把 hMerge/vMerge\n // continuation 单元格剔除了,data[r] 只剩 top-left cells;浏览器\n // 的 HTML table layout 通过 td.colSpan/rowSpan 自动算正确位置,\n // 不需要再手动算 hiddenCells(旧实现用 data-index 比对 grid-coord\n // key,混了两种坐标系,把 colspan 跨过的 grid-coord 等于另一格\n // 的 data-index 时会误隐藏,slide 26 表头 \"权重\"/\"好\" 就是中招)。\n const bgColor = getCellBg(rowIdx, colIdx, cell.style?.backcolor);\n const headerColor = getHeaderTextColor(rowIdx);\n const textStyle = getTextStyle(cell.style);\n\n if (headerColor && !cell.style?.color) {\n textStyle.color = headerColor;\n }\n\n // 单元格自带逐边描边时按边渲染(未定义的边不画);否则回退到\n // 表级 outline 套四边的旧行为,保留真·网格表格的表现。\n const cellBorders = cell.borders;\n const borderCss: CSSProperties =\n cellBorders &&\n (cellBorders.top || cellBorders.bottom || cellBorders.left || cellBorders.right)\n ? {\n borderTop: cellBorderCss(cellBorders.top) ?? 'none',\n borderBottom: cellBorderCss(cellBorders.bottom) ?? 'none',\n borderLeft: cellBorderCss(cellBorders.left) ?? 'none',\n borderRight: cellBorderCss(cellBorders.right) ?? 'none',\n }\n : { border: borderStyle };\n\n return (\n <td\n key={cell.id}\n colSpan={cell.colspan > 1 ? cell.colspan : undefined}\n rowSpan={cell.rowspan > 1 ? cell.rowspan : undefined}\n style={{\n ...borderCss,\n backgroundColor: bgColor,\n ...textStyle,\n }}\n >\n <div\n className=\"slide-renderer-cell-text\"\n style={{\n minHeight: `${(rowHeights?.[rowIdx] ?? cellMinHeight) - 4}px`,\n padding: cell.padding,\n display: 'flex',\n flexDirection: 'column',\n lineHeight: 1,\n justifyContent:\n cell.vAlign === 'top'\n ? 'flex-start'\n : cell.vAlign === 'bottom'\n ? 'flex-end'\n : cell.vAlign === 'middle'\n ? 'center'\n : undefined,\n }}\n // cell.text is already final HTML (transformParsedToSlides\n // escapes text + converts \\n/spaces and keeps <p> positioning\n // styles). Do NOT run formatText here — its space→ \n // replacement corrupts style attributes like\n // `margin-left: calc(42px + 0.25em)` → the title indent is\n // lost and collides with the cell's left icon (slide 5).\n dangerouslySetInnerHTML={{ __html: cell.text }}\n />\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"],"names":[],"mappings":";;;;;;AAOA;AACE;AAAwB;;;AAG1B;AAMM;AACJ;;AAGE;AAAY;AACZ;AACF;AAEA;AACE;AAAc;AACd;AACA;AACA;AACA;AACF;;AAOE;AAAmB;AACnB;AAAY;AAEZ;;AAGA;;;;AAEA;AAAqC;;AACW;AAEhD;;AACiD;AAEjD;AACF;AAEA;AACE;AAAY;AACZ;AACA;AAAqC;;AACW;AAChD;AACF;AAEA;AAIM;AACA;AACA;AACA;AACD;;;;;;;AAiBO;AACA;;;AAIE;;;;AAKF;;AAGE;AACE;;;;;AAKG;AACH;AAEJ;AAMM;AACA;AACA;AACD;AAKG;;AAEA;AACA;AACA;AACA;AAEI;AACA;AACE;AACA;AACE;AACA;AACT;;;;;;;AAOD;;AAUpB;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function getTextStyle(style) {
|
|
2
|
+
if (!style)
|
|
3
|
+
return {};
|
|
4
|
+
const css = {};
|
|
5
|
+
if (style.bold)
|
|
6
|
+
css.fontWeight = 'bold';
|
|
7
|
+
if (style.em)
|
|
8
|
+
css.fontStyle = 'italic';
|
|
9
|
+
if (style.underline)
|
|
10
|
+
css.textDecoration = 'underline';
|
|
11
|
+
if (style.strikethrough) {
|
|
12
|
+
css.textDecoration = css.textDecoration ? `${css.textDecoration} line-through` : 'line-through';
|
|
13
|
+
}
|
|
14
|
+
if (style.color)
|
|
15
|
+
css.color = style.color;
|
|
16
|
+
if (style.backcolor)
|
|
17
|
+
css.backgroundColor = style.backcolor;
|
|
18
|
+
if (style.fontsize)
|
|
19
|
+
css.fontSize = style.fontsize;
|
|
20
|
+
if (style.fontname)
|
|
21
|
+
css.fontFamily = style.fontname;
|
|
22
|
+
if (style.align)
|
|
23
|
+
css.textAlign = style.align;
|
|
24
|
+
return css;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { getTextStyle };
|
|
28
|
+
//# sourceMappingURL=tableUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableUtils.js","sources":["../../../src/elements/table/tableUtils.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport type { TableCell, TableCellStyle } from '@openmaic/dsl';\n\nexport function getTextStyle(style?: TableCellStyle): CSSProperties {\n if (!style) return {};\n\n const css: CSSProperties = {};\n\n if (style.bold) css.fontWeight = 'bold';\n if (style.em) css.fontStyle = 'italic';\n if (style.underline) css.textDecoration = 'underline';\n if (style.strikethrough) {\n css.textDecoration = css.textDecoration ? `${css.textDecoration} line-through` : 'line-through';\n }\n if (style.color) css.color = style.color;\n if (style.backcolor) css.backgroundColor = style.backcolor;\n if (style.fontsize) css.fontSize = style.fontsize;\n if (style.fontname) css.fontFamily = style.fontname;\n if (style.align) css.textAlign = style.align;\n\n return css;\n}\n\nexport function formatText(text: string): string {\n return text.replace(/\\n/g, '<br/>').replace(/ /g, ' ');\n}\n\nexport function getHiddenCells(data: TableCell[][]): Set<string> {\n const hidden = new Set<string>();\n\n for (let rowIdx = 0; rowIdx < data.length; rowIdx++) {\n let realColIdx = 0;\n for (let colIdx = 0; colIdx < data[rowIdx].length; colIdx++) {\n while (hidden.has(`${rowIdx}_${realColIdx}`)) {\n realColIdx++;\n }\n\n const cell = data[rowIdx][colIdx];\n const colspan = cell.colspan ?? 1;\n const rowspan = cell.rowspan ?? 1;\n\n if (colspan > 1 || rowspan > 1) {\n for (let r = 0; r < rowspan; r++) {\n for (let c = 0; c < colspan; c++) {\n if (r === 0 && c === 0) continue;\n hidden.add(`${rowIdx + r}_${realColIdx + c}`);\n }\n }\n }\n\n realColIdx += colspan;\n }\n }\n\n return hidden;\n}\n"],"names":[],"mappings":"AAGM,SAAU,YAAY,CAAC,KAAsB,EAAA;AACjD,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,EAAE;IAErB,MAAM,GAAG,GAAkB,EAAE;IAE7B,IAAI,KAAK,CAAC,IAAI;AAAE,QAAA,GAAG,CAAC,UAAU,GAAG,MAAM;IACvC,IAAI,KAAK,CAAC,EAAE;AAAE,QAAA,GAAG,CAAC,SAAS,GAAG,QAAQ;IACtC,IAAI,KAAK,CAAC,SAAS;AAAE,QAAA,GAAG,CAAC,cAAc,GAAG,WAAW;AACrD,IAAA,IAAI,KAAK,CAAC,aAAa,EAAE;AACvB,QAAA,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,GAAG,CAAA,EAAG,GAAG,CAAC,cAAc,CAAA,aAAA,CAAe,GAAG,cAAc;IACjG;IACA,IAAI,KAAK,CAAC,KAAK;AAAE,QAAA,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK;IACxC,IAAI,KAAK,CAAC,SAAS;AAAE,QAAA,GAAG,CAAC,eAAe,GAAG,KAAK,CAAC,SAAS;IAC1D,IAAI,KAAK,CAAC,QAAQ;AAAE,QAAA,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ;IACjD,IAAI,KAAK,CAAC,QAAQ;AAAE,QAAA,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,QAAQ;IACnD,IAAI,KAAK,CAAC,KAAK;AAAE,QAAA,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK;AAE5C,IAAA,OAAO,GAAG;AACZ;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useElementShadow } from '../shared/useElementShadow.js';
|
|
4
|
+
import { ElementOutline } from '../shared/ElementOutline.js';
|
|
5
|
+
|
|
6
|
+
function BaseTextElement({ elementInfo, target }) {
|
|
7
|
+
const { shadowStyle } = useElementShadow(elementInfo.shadow);
|
|
8
|
+
const vAlign = elementInfo.vAlign ?? 'top';
|
|
9
|
+
const justifyContent = vAlign === 'middle' ? 'center' : vAlign === 'bottom' ? 'flex-end' : 'flex-start';
|
|
10
|
+
return (jsx("div", { className: "base-element-text", style: {
|
|
11
|
+
position: 'absolute',
|
|
12
|
+
top: `${elementInfo.top}px`,
|
|
13
|
+
left: `${elementInfo.left}px`,
|
|
14
|
+
width: `${elementInfo.width}px`,
|
|
15
|
+
height: `${elementInfo.height}px`,
|
|
16
|
+
}, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
17
|
+
width: '100%',
|
|
18
|
+
height: '100%',
|
|
19
|
+
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
20
|
+
// Fill the full text box and rotate it with the glyphs/outline.
|
|
21
|
+
backgroundColor: elementInfo.fill,
|
|
22
|
+
opacity: elementInfo.opacity,
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
justifyContent,
|
|
26
|
+
}, children: jsxs("div", { className: "element-content slide-renderer-prose", style: {
|
|
27
|
+
position: 'relative',
|
|
28
|
+
width: elementInfo.vertical ? 'auto' : '100%',
|
|
29
|
+
height: elementInfo.vertical ? '100%' : 'auto',
|
|
30
|
+
textShadow: shadowStyle,
|
|
31
|
+
lineHeight: elementInfo.lineHeight,
|
|
32
|
+
letterSpacing: elementInfo.wordSpace !== undefined ? `${elementInfo.wordSpace}px` : undefined,
|
|
33
|
+
color: elementInfo.defaultColor,
|
|
34
|
+
fontFamily: elementInfo.defaultFontName,
|
|
35
|
+
writingMode: elementInfo.vertical ? 'vertical-rl' : 'horizontal-tb',
|
|
36
|
+
...(elementInfo.paragraphSpace !== undefined
|
|
37
|
+
? { '--paragraphSpace': `${elementInfo.paragraphSpace}px` }
|
|
38
|
+
: null),
|
|
39
|
+
}, children: [jsx(ElementOutline, { width: elementInfo.width, height: elementInfo.height, outline: elementInfo.outline }), jsx("div", { className: "text ProseMirror-static", style: {
|
|
40
|
+
position: 'relative',
|
|
41
|
+
pointerEvents: target === 'thumbnail' ? 'none' : undefined,
|
|
42
|
+
}, dangerouslySetInnerHTML: { __html: elementInfo.content } })] }) }) }));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { BaseTextElement };
|
|
46
|
+
//# sourceMappingURL=BaseTextElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseTextElement.js","sources":["../../../src/elements/text/BaseTextElement.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties } from 'react';\nimport type { PPTTextElement } from '@openmaic/dsl';\nimport { useElementShadow } from '../shared/useElementShadow';\nimport { ElementOutline } from '../shared/ElementOutline';\n\nexport interface BaseTextElementProps {\n elementInfo: PPTTextElement;\n target?: string;\n}\n\nexport function BaseTextElement({ elementInfo, target }: BaseTextElementProps) {\n const { shadowStyle } = useElementShadow(elementInfo.shadow);\n\n const vAlign = elementInfo.vAlign ?? 'top';\n const justifyContent =\n vAlign === 'middle' ? 'center' : vAlign === 'bottom' ? 'flex-end' : 'flex-start';\n\n return (\n <div\n className=\"base-element-text\"\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n }}\n >\n <div\n className=\"rotate-wrapper\"\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n // Fill the full text box and rotate it with the glyphs/outline.\n backgroundColor: elementInfo.fill,\n opacity: elementInfo.opacity,\n display: 'flex',\n flexDirection: 'column',\n justifyContent,\n }}\n >\n <div\n className=\"element-content slide-renderer-prose\"\n style={{\n position: 'relative',\n width: elementInfo.vertical ? 'auto' : '100%',\n height: elementInfo.vertical ? '100%' : 'auto',\n textShadow: shadowStyle,\n lineHeight: elementInfo.lineHeight,\n letterSpacing:\n elementInfo.wordSpace !== undefined ? `${elementInfo.wordSpace}px` : undefined,\n color: elementInfo.defaultColor,\n fontFamily: elementInfo.defaultFontName,\n writingMode: elementInfo.vertical ? 'vertical-rl' : 'horizontal-tb',\n ...(elementInfo.paragraphSpace !== undefined\n ? ({ '--paragraphSpace': `${elementInfo.paragraphSpace}px` } as CSSProperties)\n : null),\n }}\n >\n <ElementOutline\n width={elementInfo.width}\n height={elementInfo.height}\n outline={elementInfo.outline}\n />\n <div\n className=\"text ProseMirror-static\"\n style={{\n position: 'relative',\n pointerEvents: target === 'thumbnail' ? 'none' : undefined,\n }}\n dangerouslySetInnerHTML={{ __html: elementInfo.content }}\n />\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;AAeE;;AAIA;AAIM;AACA;AACA;AACA;AACA;AACD;AAKG;AACA;AACA;;;;AAIA;AACA;;AAED;AAKG;;;AAGA;;AAEA;;;;AAKA;;;AAGD;AAUG;;AAED;AAOb;;"}
|
|
@@ -9,5 +9,7 @@ export interface BaseVideoElementProps {
|
|
|
9
9
|
* When omitted, the package renders a plain <video src controls preload="metadata">.
|
|
10
10
|
*/
|
|
11
11
|
renderVideo?: (element: PPTVideoElement) => ReactNode;
|
|
12
|
+
/** Enable pointer interaction for native controls or host-provided video UI. */
|
|
13
|
+
interactive?: boolean;
|
|
12
14
|
}
|
|
13
|
-
export declare function BaseVideoElement({ elementInfo, renderVideo }: BaseVideoElementProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function BaseVideoElement({ elementInfo, renderVideo, interactive, }: BaseVideoElementProps): import("react/jsx-runtime").JSX.Element;
|