@openmaic/renderer 0.0.1 → 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 +19 -4
- package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js +0 -1742
- package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js.map +0 -1
- package/dist/chunks/SlideCanvas-BwlcjqMl.js +0 -469
- package/dist/chunks/SlideCanvas-BwlcjqMl.js.map +0 -1
|
@@ -1,1742 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useMemo, useRef, useState, useEffect, useLayoutEffect, useCallback } from 'react';
|
|
3
|
-
import tinycolor from 'tinycolor2';
|
|
4
|
-
import * as echarts from 'echarts/core';
|
|
5
|
-
import { BarChart, LineChart, PieChart, ScatterChart, RadarChart } from 'echarts/charts';
|
|
6
|
-
import { LegendComponent } from 'echarts/components';
|
|
7
|
-
import { SVGRenderer } from 'echarts/renderers';
|
|
8
|
-
import { AnimatePresence, motion } from 'motion/react';
|
|
9
|
-
|
|
10
|
-
function useElementShadow(shadow) {
|
|
11
|
-
const shadowStyle = useMemo(() => {
|
|
12
|
-
if (shadow) {
|
|
13
|
-
const { h, v, blur, color } = shadow;
|
|
14
|
-
return `${h}px ${v}px ${blur}px ${color}`;
|
|
15
|
-
}
|
|
16
|
-
return '';
|
|
17
|
-
}, [shadow]);
|
|
18
|
-
return { shadowStyle };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function useElementFlip(flipH, flipV) {
|
|
22
|
-
const flipStyle = useMemo(() => {
|
|
23
|
-
let style = '';
|
|
24
|
-
if (flipH && flipV)
|
|
25
|
-
style = 'rotateX(180deg) rotateY(180deg)';
|
|
26
|
-
else if (flipV)
|
|
27
|
-
style = 'rotateX(180deg)';
|
|
28
|
-
else if (flipH)
|
|
29
|
-
style = 'rotateY(180deg)';
|
|
30
|
-
return style;
|
|
31
|
-
}, [flipH, flipV]);
|
|
32
|
-
return { flipStyle };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var ClipPathTypes;
|
|
36
|
-
(function (ClipPathTypes) {
|
|
37
|
-
ClipPathTypes["RECT"] = "rect";
|
|
38
|
-
ClipPathTypes["ELLIPSE"] = "ellipse";
|
|
39
|
-
ClipPathTypes["POLYGON"] = "polygon";
|
|
40
|
-
})(ClipPathTypes || (ClipPathTypes = {}));
|
|
41
|
-
const CLIPPATHS = {
|
|
42
|
-
rect: {
|
|
43
|
-
name: '矩形',
|
|
44
|
-
type: ClipPathTypes.RECT,
|
|
45
|
-
radius: '0',
|
|
46
|
-
style: '',
|
|
47
|
-
},
|
|
48
|
-
rect2: {
|
|
49
|
-
name: '矩形2',
|
|
50
|
-
type: ClipPathTypes.POLYGON,
|
|
51
|
-
style: 'polygon(0% 0%, 80% 0%, 100% 20%, 100% 100%, 0 100%)',
|
|
52
|
-
createPath: (width, height) => `M 0 0 L ${width * 0.8} 0 L ${width} ${height * 0.2} L ${width} ${height} L 0 ${height} Z`,
|
|
53
|
-
},
|
|
54
|
-
rect3: {
|
|
55
|
-
name: '矩形3',
|
|
56
|
-
type: ClipPathTypes.POLYGON,
|
|
57
|
-
style: 'polygon(0% 0%, 80% 0%, 100% 20%, 100% 100%, 20% 100%, 0% 80%)',
|
|
58
|
-
createPath: (width, height) => `M 0 0 L ${width * 0.8} 0 L ${width} ${height * 0.2} L ${width} ${height} L ${width * 0.2} ${height} L 0 ${height * 0.8} Z`,
|
|
59
|
-
},
|
|
60
|
-
roundRect: {
|
|
61
|
-
name: '圆角矩形',
|
|
62
|
-
type: ClipPathTypes.RECT,
|
|
63
|
-
radius: '10px',
|
|
64
|
-
style: 'inset(0 round 10px)',
|
|
65
|
-
},
|
|
66
|
-
ellipse: {
|
|
67
|
-
name: '圆形',
|
|
68
|
-
type: ClipPathTypes.ELLIPSE,
|
|
69
|
-
style: 'ellipse(50% 50% at 50% 50%)',
|
|
70
|
-
},
|
|
71
|
-
triangle: {
|
|
72
|
-
name: '三角形',
|
|
73
|
-
type: ClipPathTypes.POLYGON,
|
|
74
|
-
style: 'polygon(50% 0%, 0% 100%, 100% 100%)',
|
|
75
|
-
createPath: (width, height) => `M ${width * 0.5} 0 L 0 ${height} L ${width} ${height} Z`,
|
|
76
|
-
},
|
|
77
|
-
triangle2: {
|
|
78
|
-
name: '三角形2',
|
|
79
|
-
type: ClipPathTypes.POLYGON,
|
|
80
|
-
style: 'polygon(50% 100%, 0% 0%, 100% 0%)',
|
|
81
|
-
createPath: (width, height) => `M ${width * 0.5} ${height} L 0 0 L ${width} 0 Z`,
|
|
82
|
-
},
|
|
83
|
-
triangle3: {
|
|
84
|
-
name: '三角形3',
|
|
85
|
-
type: ClipPathTypes.POLYGON,
|
|
86
|
-
style: 'polygon(0% 0%, 0% 100%, 100% 100%)',
|
|
87
|
-
createPath: (width, height) => `M 0 0 L 0 ${height} L ${width} ${height} Z`,
|
|
88
|
-
},
|
|
89
|
-
rhombus: {
|
|
90
|
-
name: '菱形',
|
|
91
|
-
type: ClipPathTypes.POLYGON,
|
|
92
|
-
style: 'polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)',
|
|
93
|
-
createPath: (width, height) => `M ${width * 0.5} 0 L ${width} ${height * 0.5} L ${width * 0.5} ${height} L 0 ${height * 0.5} Z`,
|
|
94
|
-
},
|
|
95
|
-
pentagon: {
|
|
96
|
-
name: '五边形',
|
|
97
|
-
type: ClipPathTypes.POLYGON,
|
|
98
|
-
style: 'polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)',
|
|
99
|
-
createPath: (width, height) => `M ${width * 0.5} 0 L ${width} ${0.38 * height} L ${0.82 * width} ${height} L ${0.18 * width} ${height} L 0 ${0.38 * height} Z`,
|
|
100
|
-
},
|
|
101
|
-
hexagon: {
|
|
102
|
-
name: '六边形',
|
|
103
|
-
type: ClipPathTypes.POLYGON,
|
|
104
|
-
style: 'polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%)',
|
|
105
|
-
createPath: (width, height) => `M ${width * 0.2} 0 L ${width * 0.8} 0 L ${width} ${height * 0.5} L ${width * 0.8} ${height} L ${width * 0.2} ${height} L 0 ${height * 0.5} Z`,
|
|
106
|
-
},
|
|
107
|
-
heptagon: {
|
|
108
|
-
name: '七边形',
|
|
109
|
-
type: ClipPathTypes.POLYGON,
|
|
110
|
-
style: 'polygon(50% 0%, 90% 20%, 100% 60%, 75% 100%, 25% 100%, 0% 60%, 10% 20%)',
|
|
111
|
-
createPath: (width, height) => `M ${width * 0.5} 0 L ${width * 0.9} ${height * 0.2} L ${width} ${height * 0.6} L ${width * 0.75} ${height} L ${width * 0.25} ${height} L 0 ${height * 0.6} L ${width * 0.1} ${height * 0.2} Z`,
|
|
112
|
-
},
|
|
113
|
-
octagon: {
|
|
114
|
-
name: '八边形',
|
|
115
|
-
type: ClipPathTypes.POLYGON,
|
|
116
|
-
style: 'polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)',
|
|
117
|
-
createPath: (width, height) => `M ${width * 0.3} 0 L ${width * 0.7} 0 L ${width} ${height * 0.3} L ${width} ${height * 0.7} L ${width * 0.7} ${height} L ${width * 0.3} ${height} L 0 ${height * 0.7} L 0 ${height * 0.3} Z`,
|
|
118
|
-
},
|
|
119
|
-
chevron: {
|
|
120
|
-
name: 'V形',
|
|
121
|
-
type: ClipPathTypes.POLYGON,
|
|
122
|
-
style: 'polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 25% 50%, 0% 0%)',
|
|
123
|
-
createPath: (width, height) => `M ${width * 0.75} 0 L ${width} ${height * 0.5} L ${width * 0.75} ${height} L 0 ${height} L ${width * 0.25} ${height * 0.5} L 0 0 Z`,
|
|
124
|
-
},
|
|
125
|
-
point: {
|
|
126
|
-
name: '点',
|
|
127
|
-
type: ClipPathTypes.POLYGON,
|
|
128
|
-
style: 'polygon(0% 0%, 75% 0%, 100% 50%, 75% 100%, 0% 100%)',
|
|
129
|
-
createPath: (width, height) => `M 0 0 L ${width * 0.75} 0 L ${width} ${height * 0.5} L ${width * 0.75} ${height} L 0 ${height} Z`,
|
|
130
|
-
},
|
|
131
|
-
arrow: {
|
|
132
|
-
name: '箭头',
|
|
133
|
-
type: ClipPathTypes.POLYGON,
|
|
134
|
-
style: 'polygon(0% 20%, 60% 20%, 60% 0%, 100% 50%, 60% 100%, 60% 80%, 0% 80%)',
|
|
135
|
-
createPath: (width, height) => `M 0 ${height * 0.2} L ${width * 0.6} ${height * 0.2} L ${width * 0.6} 0 L ${width} ${height * 0.5} L ${width * 0.6} ${height} L ${width * 0.6} ${height * 0.8} L 0 ${height * 0.8} Z`,
|
|
136
|
-
},
|
|
137
|
-
parallelogram: {
|
|
138
|
-
name: '平行四边形',
|
|
139
|
-
type: ClipPathTypes.POLYGON,
|
|
140
|
-
style: 'polygon(30% 0%, 100% 0%, 70% 100%, 0% 100%)',
|
|
141
|
-
createPath: (width, height) => `M ${width * 0.3} 0 L ${width} 0 L ${width * 0.7} ${height} L 0 ${height} Z`,
|
|
142
|
-
},
|
|
143
|
-
parallelogram2: {
|
|
144
|
-
name: '平行四边形2',
|
|
145
|
-
type: ClipPathTypes.POLYGON,
|
|
146
|
-
style: 'polygon(30% 100%, 100% 100%, 70% 0%, 0% 0%)',
|
|
147
|
-
createPath: (width, height) => `M ${width * 0.3} ${height} L ${width} ${height} L ${width * 0.7} 0 L 0 0 Z`,
|
|
148
|
-
},
|
|
149
|
-
trapezoid: {
|
|
150
|
-
name: '梯形',
|
|
151
|
-
type: ClipPathTypes.POLYGON,
|
|
152
|
-
style: 'polygon(25% 0%, 75% 0%, 100% 100%, 0% 100%)',
|
|
153
|
-
createPath: (width, height) => `M ${width * 0.25} 0 L ${width * 0.75} 0 L ${width} ${height} L 0 ${height} Z`,
|
|
154
|
-
},
|
|
155
|
-
trapezoid2: {
|
|
156
|
-
name: '梯形2',
|
|
157
|
-
type: ClipPathTypes.POLYGON,
|
|
158
|
-
style: 'polygon(0% 0%, 100% 0%, 75% 100%, 25% 100%)',
|
|
159
|
-
createPath: (width, height) => `M 0 0 L ${width} 0 L ${width * 0.75} ${height} L ${width * 0.25} ${height} Z`,
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
function useClipImage(element) {
|
|
164
|
-
const clipShape = useMemo(() => {
|
|
165
|
-
let _clipShape = CLIPPATHS.rect;
|
|
166
|
-
if (element.clip) {
|
|
167
|
-
const shape = element.clip.shape || ClipPathTypes.RECT;
|
|
168
|
-
_clipShape = CLIPPATHS[shape] ?? CLIPPATHS.rect;
|
|
169
|
-
}
|
|
170
|
-
if (_clipShape.radius !== undefined && element.radius) {
|
|
171
|
-
_clipShape = {
|
|
172
|
-
..._clipShape,
|
|
173
|
-
radius: `${element.radius}px`,
|
|
174
|
-
style: `inset(0 round ${element.radius}px)`,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return _clipShape;
|
|
178
|
-
}, [element.clip, element.radius]);
|
|
179
|
-
const imgPosition = useMemo(() => {
|
|
180
|
-
if (!element.clip || !element.clip.range) {
|
|
181
|
-
return { top: '0', left: '0', width: '100%', height: '100%' };
|
|
182
|
-
}
|
|
183
|
-
const [start, end] = element.clip.range;
|
|
184
|
-
const widthScale = (end[0] - start[0]) / 100;
|
|
185
|
-
const heightScale = (end[1] - start[1]) / 100;
|
|
186
|
-
const left = start[0] / widthScale;
|
|
187
|
-
const top = start[1] / heightScale;
|
|
188
|
-
return {
|
|
189
|
-
left: -left + '%',
|
|
190
|
-
top: -top + '%',
|
|
191
|
-
width: 100 / widthScale + '%',
|
|
192
|
-
height: 100 / heightScale + '%',
|
|
193
|
-
};
|
|
194
|
-
}, [element.clip]);
|
|
195
|
-
return { clipShape, imgPosition };
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const FILTER_UNITS = {
|
|
199
|
-
blur: 'px',
|
|
200
|
-
brightness: '%',
|
|
201
|
-
contrast: '%',
|
|
202
|
-
grayscale: '%',
|
|
203
|
-
saturate: '%',
|
|
204
|
-
'hue-rotate': 'deg',
|
|
205
|
-
sepia: '%',
|
|
206
|
-
invert: '%',
|
|
207
|
-
opacity: '%',
|
|
208
|
-
};
|
|
209
|
-
function useFilter(filters) {
|
|
210
|
-
const filter = useMemo(() => {
|
|
211
|
-
if (!filters)
|
|
212
|
-
return '';
|
|
213
|
-
const parts = [];
|
|
214
|
-
for (const [name, value] of Object.entries(filters)) {
|
|
215
|
-
if (value === undefined || value === null || value === '')
|
|
216
|
-
continue;
|
|
217
|
-
const unit = FILTER_UNITS[name] ?? '';
|
|
218
|
-
parts.push(`${name}(${value}${unit})`);
|
|
219
|
-
}
|
|
220
|
-
return parts.join(' ');
|
|
221
|
-
}, [filters]);
|
|
222
|
-
return { filter };
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function useElementOutline(outline) {
|
|
226
|
-
const outlineWidth = useMemo(() => outline?.width ?? 0, [outline?.width]);
|
|
227
|
-
const outlineStyle = useMemo(() => outline?.style || 'solid', [outline?.style]);
|
|
228
|
-
const outlineColor = useMemo(() => outline?.color || '#d14424', [outline?.color]);
|
|
229
|
-
const strokeDashArray = useMemo(() => {
|
|
230
|
-
const size = outlineWidth;
|
|
231
|
-
if (outlineStyle === 'dashed')
|
|
232
|
-
return size <= 6 ? `${size * 4.5} ${size * 2}` : `${size * 4} ${size * 1.5}`;
|
|
233
|
-
if (outlineStyle === 'dotted')
|
|
234
|
-
return size <= 6 ? `${size * 1.8} ${size * 1.6}` : `${size * 1.5} ${size * 1.2}`;
|
|
235
|
-
return '0 0';
|
|
236
|
-
}, [outlineWidth, outlineStyle]);
|
|
237
|
-
return { outlineWidth, outlineStyle, outlineColor, strokeDashArray };
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function ImageRectOutline({ width, height, outline, radius = '0' }) {
|
|
241
|
-
const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);
|
|
242
|
-
if (!outline)
|
|
243
|
-
return null;
|
|
244
|
-
return (jsx("svg", { style: { position: 'absolute', top: 0, left: 0, zIndex: 2, overflow: 'visible' }, width: width, height: height, children: jsx("rect", { vectorEffect: "non-scaling-stroke", strokeLinecap: "butt", strokeMiterlimit: "8", fill: "transparent", rx: radius, ry: radius, width: width, height: height, stroke: outlineColor, strokeWidth: outlineWidth, strokeDasharray: strokeDashArray }) }));
|
|
245
|
-
}
|
|
246
|
-
function ImageEllipseOutline({ width, height, outline }) {
|
|
247
|
-
const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);
|
|
248
|
-
if (!outline)
|
|
249
|
-
return null;
|
|
250
|
-
return (jsx("svg", { style: { position: 'absolute', top: 0, left: 0, zIndex: 2, overflow: 'visible' }, width: width, height: height, children: jsx("ellipse", { vectorEffect: "non-scaling-stroke", strokeLinecap: "butt", strokeMiterlimit: "8", fill: "transparent", cx: width / 2, cy: height / 2, rx: width / 2, ry: height / 2, stroke: outlineColor, strokeWidth: outlineWidth, strokeDasharray: strokeDashArray }) }));
|
|
251
|
-
}
|
|
252
|
-
function ImagePolygonOutline({ width, height, createPath, outline }) {
|
|
253
|
-
const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);
|
|
254
|
-
if (!outline)
|
|
255
|
-
return null;
|
|
256
|
-
return (jsx("svg", { style: { position: 'absolute', top: 0, left: 0, zIndex: 2, overflow: 'visible' }, width: width, height: height, children: jsx("path", { vectorEffect: "non-scaling-stroke", strokeLinecap: "butt", strokeMiterlimit: "8", fill: "transparent", d: createPath(width, height), stroke: outlineColor, strokeWidth: outlineWidth, strokeDasharray: strokeDashArray }) }));
|
|
257
|
-
}
|
|
258
|
-
function ImageOutline({ elementInfo }) {
|
|
259
|
-
const { clipShape } = useClipImage(elementInfo);
|
|
260
|
-
return (jsxs("div", { className: "image-outline", children: [clipShape.type === 'rect' && (jsx(ImageRectOutline, { width: elementInfo.width, height: elementInfo.height, radius: clipShape.radius, outline: elementInfo.outline })), clipShape.type === 'ellipse' && (jsx(ImageEllipseOutline, { width: elementInfo.width, height: elementInfo.height, outline: elementInfo.outline })), clipShape.type === 'polygon' && clipShape.createPath && (jsx(ImagePolygonOutline, { width: elementInfo.width, height: elementInfo.height, outline: elementInfo.outline, createPath: clipShape.createPath }))] }));
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function BaseImageElement({ elementInfo, renderImage }) {
|
|
264
|
-
const { shadowStyle } = useElementShadow(elementInfo.shadow);
|
|
265
|
-
const { flipStyle } = useElementFlip(elementInfo.flipH, elementInfo.flipV);
|
|
266
|
-
const { clipShape, imgPosition } = useClipImage(elementInfo);
|
|
267
|
-
const { filter } = useFilter(elementInfo.filters);
|
|
268
|
-
const src = elementInfo.src;
|
|
269
|
-
// Soft-edge feather (a:softEdge): fade the image alpha to transparent over
|
|
270
|
-
// `softEdge` px at every edge. Two intersecting linear-gradient masks feather
|
|
271
|
-
// all four sides (corners get both). html2canvas-pro ignores CSS masks, so
|
|
272
|
-
// slideToPng bakes the same feather into pixels via the data-soft-edge hook.
|
|
273
|
-
const softEdge = elementInfo.softEdge && elementInfo.softEdge > 0 ? elementInfo.softEdge : undefined;
|
|
274
|
-
const softEdgeMaskStyle = softEdge
|
|
275
|
-
? (() => {
|
|
276
|
-
const grad = (dir) => `linear-gradient(${dir}, transparent 0, #000 ${softEdge}px, #000 calc(100% - ${softEdge}px), transparent 100%)`;
|
|
277
|
-
const mask = `${grad('to right')}, ${grad('to bottom')}`;
|
|
278
|
-
return {
|
|
279
|
-
maskImage: mask,
|
|
280
|
-
WebkitMaskImage: mask,
|
|
281
|
-
maskComposite: 'intersect',
|
|
282
|
-
WebkitMaskComposite: 'source-in',
|
|
283
|
-
maskRepeat: 'no-repeat',
|
|
284
|
-
WebkitMaskRepeat: 'no-repeat',
|
|
285
|
-
};
|
|
286
|
-
})()
|
|
287
|
-
: {};
|
|
288
|
-
return (jsx("div", { className: "element-content", style: {
|
|
289
|
-
position: 'absolute',
|
|
290
|
-
top: `${elementInfo.top}px`,
|
|
291
|
-
left: `${elementInfo.left}px`,
|
|
292
|
-
width: `${elementInfo.width}px`,
|
|
293
|
-
height: `${elementInfo.height}px`,
|
|
294
|
-
}, children: jsx("div", { style: {
|
|
295
|
-
width: '100%',
|
|
296
|
-
height: '100%',
|
|
297
|
-
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
298
|
-
}, children: jsxs("div", { style: {
|
|
299
|
-
position: 'relative',
|
|
300
|
-
width: '100%',
|
|
301
|
-
height: '100%',
|
|
302
|
-
filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',
|
|
303
|
-
transform: flipStyle,
|
|
304
|
-
}, children: [jsx(ImageOutline, { elementInfo: elementInfo }), jsx("div", { style: {
|
|
305
|
-
position: 'relative',
|
|
306
|
-
width: '100%',
|
|
307
|
-
height: '100%',
|
|
308
|
-
overflow: 'hidden',
|
|
309
|
-
clipPath: clipShape.style,
|
|
310
|
-
}, children: renderImage ? (renderImage(elementInfo, src)) : src ? (jsxs(Fragment, { children: [jsx("img", { src: src, draggable: false, "data-soft-edge": softEdge || undefined, style: {
|
|
311
|
-
position: 'absolute',
|
|
312
|
-
top: imgPosition.top,
|
|
313
|
-
left: imgPosition.left,
|
|
314
|
-
width: imgPosition.width,
|
|
315
|
-
height: imgPosition.height,
|
|
316
|
-
maxWidth: 'none',
|
|
317
|
-
maxHeight: 'none',
|
|
318
|
-
filter,
|
|
319
|
-
...softEdgeMaskStyle,
|
|
320
|
-
}, alt: "", onDragStart: (e) => e.preventDefault() }), elementInfo.colorMask && (jsx("div", { style: {
|
|
321
|
-
position: 'absolute',
|
|
322
|
-
inset: 0,
|
|
323
|
-
backgroundColor: elementInfo.colorMask,
|
|
324
|
-
} }))] })) : null })] }) }) }));
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function ElementOutline({ width, height, outline }) {
|
|
328
|
-
const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);
|
|
329
|
-
if (!outline)
|
|
330
|
-
return null;
|
|
331
|
-
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 }) }));
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function BaseTextElement({ elementInfo, target }) {
|
|
335
|
-
const { shadowStyle } = useElementShadow(elementInfo.shadow);
|
|
336
|
-
const vAlign = elementInfo.vAlign ?? 'top';
|
|
337
|
-
const justifyContent = vAlign === 'middle' ? 'center' : vAlign === 'bottom' ? 'flex-end' : 'flex-start';
|
|
338
|
-
return (jsx("div", { className: "base-element-text", style: {
|
|
339
|
-
position: 'absolute',
|
|
340
|
-
top: `${elementInfo.top}px`,
|
|
341
|
-
left: `${elementInfo.left}px`,
|
|
342
|
-
width: `${elementInfo.width}px`,
|
|
343
|
-
height: `${elementInfo.height}px`,
|
|
344
|
-
// PowerPoint fills the entire shape rectangle with its solid/gradient
|
|
345
|
-
// fill, regardless of how much vertical room the text actually
|
|
346
|
-
// occupies. The inner .element-content div has height: auto so flex
|
|
347
|
-
// alignment can park the text at top/middle/bottom — but if the
|
|
348
|
-
// background lived there, a tall shape with short text (e.g. the 22
|
|
349
|
-
// empty paragraphs that author full-bleed black slide backgrounds in
|
|
350
|
-
// some decks) would only fill the content height and the slide's own
|
|
351
|
-
// background would bleed through below.
|
|
352
|
-
backgroundColor: elementInfo.fill,
|
|
353
|
-
opacity: elementInfo.opacity,
|
|
354
|
-
}, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
355
|
-
width: '100%',
|
|
356
|
-
height: '100%',
|
|
357
|
-
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
358
|
-
display: 'flex',
|
|
359
|
-
flexDirection: 'column',
|
|
360
|
-
justifyContent,
|
|
361
|
-
}, children: jsxs("div", { className: "element-content slide-renderer-prose", style: {
|
|
362
|
-
position: 'relative',
|
|
363
|
-
width: elementInfo.vertical ? 'auto' : '100%',
|
|
364
|
-
height: elementInfo.vertical ? '100%' : 'auto',
|
|
365
|
-
textShadow: shadowStyle,
|
|
366
|
-
lineHeight: elementInfo.lineHeight,
|
|
367
|
-
letterSpacing: elementInfo.wordSpace !== undefined ? `${elementInfo.wordSpace}px` : undefined,
|
|
368
|
-
color: elementInfo.defaultColor,
|
|
369
|
-
fontFamily: elementInfo.defaultFontName,
|
|
370
|
-
writingMode: elementInfo.vertical ? 'vertical-rl' : 'horizontal-tb',
|
|
371
|
-
...(elementInfo.paragraphSpace !== undefined
|
|
372
|
-
? { '--paragraphSpace': `${elementInfo.paragraphSpace}px` }
|
|
373
|
-
: null),
|
|
374
|
-
}, children: [jsx(ElementOutline, { width: elementInfo.width, height: elementInfo.height, outline: elementInfo.outline }), jsx("div", { className: "text ProseMirror-static", style: {
|
|
375
|
-
position: 'relative',
|
|
376
|
-
pointerEvents: target === 'thumbnail' ? 'none' : undefined,
|
|
377
|
-
}, dangerouslySetInnerHTML: { __html: elementInfo.content } })] }) }) }));
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
function useElementFill(element, source) {
|
|
381
|
-
const fill = useMemo(() => {
|
|
382
|
-
if (element.pattern)
|
|
383
|
-
return `url(#${source}-pattern-${element.id})`;
|
|
384
|
-
if (element.gradient)
|
|
385
|
-
return `url(#${source}-gradient-${element.id})`;
|
|
386
|
-
return element.fill || 'none';
|
|
387
|
-
}, [element.pattern, element.gradient, element.fill, element.id, source]);
|
|
388
|
-
return { fill };
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
function GradientDefs({ id, type, colors, rotate = 0 }) {
|
|
392
|
-
if (type === 'linear') {
|
|
393
|
-
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))) }));
|
|
394
|
-
}
|
|
395
|
-
return (jsx("radialGradient", { id: id, children: colors.map((item, index) => (jsx("stop", { offset: `${item.pos}%`, stopColor: item.color }, index))) }));
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
function PatternDefs({ id, src }) {
|
|
399
|
-
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" }) }));
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Bounding box of a path's coordinates (path/viewBox space). Uses control
|
|
404
|
-
* points for curves (a safe superset). Handles the commands our shapes emit
|
|
405
|
-
* (M/L/C/Q/S/H/V/A/T/Z, absolute). Returns null if no coordinates.
|
|
406
|
-
*/
|
|
407
|
-
function pathCoordBBox(d) {
|
|
408
|
-
const tokens = d.match(/[a-zA-Z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi);
|
|
409
|
-
if (!tokens)
|
|
410
|
-
return null;
|
|
411
|
-
let i = 0;
|
|
412
|
-
let cmd = '';
|
|
413
|
-
let minX = Infinity;
|
|
414
|
-
let minY = Infinity;
|
|
415
|
-
let maxX = -Infinity;
|
|
416
|
-
let maxY = -Infinity;
|
|
417
|
-
const addX = (x) => {
|
|
418
|
-
if (x < minX)
|
|
419
|
-
minX = x;
|
|
420
|
-
if (x > maxX)
|
|
421
|
-
maxX = x;
|
|
422
|
-
};
|
|
423
|
-
const addY = (y) => {
|
|
424
|
-
if (y < minY)
|
|
425
|
-
minY = y;
|
|
426
|
-
if (y > maxY)
|
|
427
|
-
maxY = y;
|
|
428
|
-
};
|
|
429
|
-
const num = () => parseFloat(tokens[i++]);
|
|
430
|
-
while (i < tokens.length) {
|
|
431
|
-
// Path commands are single letters. Use an anchored test so number tokens
|
|
432
|
-
// in scientific notation (e.g. "4.74e-16") aren't misread as commands.
|
|
433
|
-
if (/^[a-zA-Z]$/.test(tokens[i])) {
|
|
434
|
-
cmd = tokens[i];
|
|
435
|
-
i++;
|
|
436
|
-
}
|
|
437
|
-
const c = cmd.toUpperCase();
|
|
438
|
-
if (c === 'M' || c === 'L' || c === 'T') {
|
|
439
|
-
addX(num());
|
|
440
|
-
addY(num());
|
|
441
|
-
}
|
|
442
|
-
else if (c === 'C') {
|
|
443
|
-
addX(num());
|
|
444
|
-
addY(num());
|
|
445
|
-
addX(num());
|
|
446
|
-
addY(num());
|
|
447
|
-
addX(num());
|
|
448
|
-
addY(num());
|
|
449
|
-
}
|
|
450
|
-
else if (c === 'Q' || c === 'S') {
|
|
451
|
-
addX(num());
|
|
452
|
-
addY(num());
|
|
453
|
-
addX(num());
|
|
454
|
-
addY(num());
|
|
455
|
-
}
|
|
456
|
-
else if (c === 'H') {
|
|
457
|
-
addX(num());
|
|
458
|
-
}
|
|
459
|
-
else if (c === 'V') {
|
|
460
|
-
addY(num());
|
|
461
|
-
}
|
|
462
|
-
else if (c === 'A') {
|
|
463
|
-
num();
|
|
464
|
-
num();
|
|
465
|
-
num();
|
|
466
|
-
num();
|
|
467
|
-
num();
|
|
468
|
-
addX(num());
|
|
469
|
-
addY(num());
|
|
470
|
-
}
|
|
471
|
-
else if (c === 'Z') ;
|
|
472
|
-
else {
|
|
473
|
-
i++; // unknown token, skip to avoid infinite loop
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
if (!Number.isFinite(minX) ||
|
|
477
|
-
!Number.isFinite(minY) ||
|
|
478
|
-
!Number.isFinite(maxX) ||
|
|
479
|
-
!Number.isFinite(maxY)) {
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
|
-
return { minX, minY, maxX, maxY };
|
|
483
|
-
}
|
|
484
|
-
function BaseShapeElement({ elementInfo }) {
|
|
485
|
-
const { fill } = useElementFill(elementInfo, 'base');
|
|
486
|
-
const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(elementInfo.outline);
|
|
487
|
-
const { shadowStyle } = useElementShadow(elementInfo.shadow);
|
|
488
|
-
const { flipStyle } = useElementFlip(elementInfo.flipH, elementInfo.flipV);
|
|
489
|
-
const text = elementInfo.text || {
|
|
490
|
-
content: '',
|
|
491
|
-
align: 'middle',
|
|
492
|
-
defaultFontName: 'Microsoft YaHei',
|
|
493
|
-
defaultColor: '#333333',
|
|
494
|
-
};
|
|
495
|
-
const justifyContent = text.align === 'top' ? 'flex-start' : text.align === 'bottom' ? 'flex-end' : 'center';
|
|
496
|
-
return (jsx("div", { className: "base-element-shape", style: {
|
|
497
|
-
position: 'absolute',
|
|
498
|
-
top: `${elementInfo.top}px`,
|
|
499
|
-
left: `${elementInfo.left}px`,
|
|
500
|
-
width: `${elementInfo.width}px`,
|
|
501
|
-
height: `${elementInfo.height}px`,
|
|
502
|
-
}, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
503
|
-
width: '100%',
|
|
504
|
-
height: '100%',
|
|
505
|
-
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
506
|
-
}, children: jsxs("div", { className: "element-content", style: {
|
|
507
|
-
position: 'relative',
|
|
508
|
-
width: '100%',
|
|
509
|
-
height: '100%',
|
|
510
|
-
opacity: elementInfo.opacity,
|
|
511
|
-
filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',
|
|
512
|
-
transform: flipStyle,
|
|
513
|
-
color: text.defaultColor,
|
|
514
|
-
fontFamily: text.defaultFontName,
|
|
515
|
-
}, children: [(() => {
|
|
516
|
-
// The shape's path can extend OUTSIDE its width×height box (e.g.
|
|
517
|
-
// curved connectors whose extreme adj values bulge the curve far
|
|
518
|
-
// past the bbox). A browser shows that via overflow:visible, but
|
|
519
|
-
// html2canvas-pro rasterizes each SVG to its width×height viewport
|
|
520
|
-
// and CLIPS the overflow — turning connector arcs into stubs in the
|
|
521
|
-
// exported PNG. Fix: grow the SVG viewport to contain the full path
|
|
522
|
-
// bbox and offset it back, so the geometry renders in the exact same
|
|
523
|
-
// place but nothing falls outside the captured viewport.
|
|
524
|
-
const sx = elementInfo.width / (elementInfo.viewBox[0] || elementInfo.width || 1);
|
|
525
|
-
const sy = elementInfo.height / (elementInfo.viewBox[1] || elementInfo.height || 1);
|
|
526
|
-
const bbox = pathCoordBBox(elementInfo.path);
|
|
527
|
-
const CAP = 4000; // guard against pathological coords blowing up the SVG
|
|
528
|
-
let padL = 0;
|
|
529
|
-
let padT = 0;
|
|
530
|
-
let padR = 0;
|
|
531
|
-
let padB = 0;
|
|
532
|
-
if (bbox) {
|
|
533
|
-
padL = Math.min(CAP, Math.max(0, -bbox.minX * sx));
|
|
534
|
-
padT = Math.min(CAP, Math.max(0, -bbox.minY * sy));
|
|
535
|
-
padR = Math.min(CAP, Math.max(0, bbox.maxX * sx - elementInfo.width));
|
|
536
|
-
padB = Math.min(CAP, Math.max(0, bbox.maxY * sy - elementInfo.height));
|
|
537
|
-
}
|
|
538
|
-
return (jsxs("svg", { overflow: "visible", width: elementInfo.width + padL + padR, height: elementInfo.height + padT + padB, style: {
|
|
539
|
-
position: 'absolute',
|
|
540
|
-
left: -padL,
|
|
541
|
-
top: -padT,
|
|
542
|
-
transformOrigin: '0 0',
|
|
543
|
-
overflow: 'visible',
|
|
544
|
-
display: 'block',
|
|
545
|
-
}, 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 }) })] }));
|
|
546
|
-
})(), jsx("div", { className: "shape-text", style: {
|
|
547
|
-
position: 'absolute',
|
|
548
|
-
inset: 0,
|
|
549
|
-
display: 'flex',
|
|
550
|
-
flexDirection: 'column',
|
|
551
|
-
justifyContent,
|
|
552
|
-
overflowWrap: 'break-word',
|
|
553
|
-
lineHeight: text.lineHeight,
|
|
554
|
-
letterSpacing: `${text.wordSpace || 0}px`,
|
|
555
|
-
// PowerPoint/WPS 在 group flipH/flipV 时只镜像几何与位置,文字字形保持
|
|
556
|
-
// 正向。父层 element-content 已应用 flipStyle 镜像 SVG path;这里给文字
|
|
557
|
-
// 叠加同一个 flipStyle,两次 flip 抵消,让文字保持正向。
|
|
558
|
-
transform: flipStyle,
|
|
559
|
-
}, children: jsx("div", { className: "ProseMirror-static slide-renderer-prose", style: {
|
|
560
|
-
// @ts-expect-error CSS custom properties
|
|
561
|
-
'--paragraphSpace': `${text.paragraphSpace === undefined ? 5 : text.paragraphSpace}px`,
|
|
562
|
-
}, dangerouslySetInnerHTML: { __html: text.content } }) })] }) }) }));
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
const getRectRotatedRange = (element) => {
|
|
566
|
-
const { left, top, width, height, rotate = 0 } = element;
|
|
567
|
-
const radius = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) / 2;
|
|
568
|
-
const auxiliaryAngle = (Math.atan(height / width) * 180) / Math.PI;
|
|
569
|
-
const tlbraRadian = ((180 - rotate - auxiliaryAngle) * Math.PI) / 180;
|
|
570
|
-
const trblaRadian = ((auxiliaryAngle - rotate) * Math.PI) / 180;
|
|
571
|
-
const middleLeft = left + width / 2;
|
|
572
|
-
const middleTop = top + height / 2;
|
|
573
|
-
const xAxis = [
|
|
574
|
-
middleLeft + radius * Math.cos(tlbraRadian),
|
|
575
|
-
middleLeft + radius * Math.cos(trblaRadian),
|
|
576
|
-
middleLeft - radius * Math.cos(tlbraRadian),
|
|
577
|
-
middleLeft - radius * Math.cos(trblaRadian),
|
|
578
|
-
];
|
|
579
|
-
const yAxis = [
|
|
580
|
-
middleTop - radius * Math.sin(tlbraRadian),
|
|
581
|
-
middleTop - radius * Math.sin(trblaRadian),
|
|
582
|
-
middleTop + radius * Math.sin(tlbraRadian),
|
|
583
|
-
middleTop + radius * Math.sin(trblaRadian),
|
|
584
|
-
];
|
|
585
|
-
return {
|
|
586
|
-
xRange: [Math.min(...xAxis), Math.max(...xAxis)],
|
|
587
|
-
yRange: [Math.min(...yAxis), Math.max(...yAxis)],
|
|
588
|
-
};
|
|
589
|
-
};
|
|
590
|
-
const getElementRange = (element) => {
|
|
591
|
-
let minX, maxX, minY, maxY;
|
|
592
|
-
if (element.type === 'line') {
|
|
593
|
-
minX = element.left;
|
|
594
|
-
maxX = element.left + Math.max(element.start[0], element.end[0]);
|
|
595
|
-
minY = element.top;
|
|
596
|
-
maxY = element.top + Math.max(element.start[1], element.end[1]);
|
|
597
|
-
}
|
|
598
|
-
else if ('rotate' in element && element.rotate) {
|
|
599
|
-
const { left, top, width, height, rotate } = element;
|
|
600
|
-
const { xRange, yRange } = getRectRotatedRange({ left, top, width, height, rotate });
|
|
601
|
-
minX = xRange[0];
|
|
602
|
-
maxX = xRange[1];
|
|
603
|
-
minY = yRange[0];
|
|
604
|
-
maxY = yRange[1];
|
|
605
|
-
}
|
|
606
|
-
else {
|
|
607
|
-
minX = element.left;
|
|
608
|
-
maxX = element.left + element.width;
|
|
609
|
-
minY = element.top;
|
|
610
|
-
maxY = element.top + element.height;
|
|
611
|
-
}
|
|
612
|
-
return { minX, maxX, minY, maxY };
|
|
613
|
-
};
|
|
614
|
-
const getTableSubThemeColor = (themeColor) => {
|
|
615
|
-
const rgba = tinycolor(themeColor);
|
|
616
|
-
return [rgba.setAlpha(0.3).toRgbString(), rgba.setAlpha(0.1).toRgbString()];
|
|
617
|
-
};
|
|
618
|
-
const getLineElementPath = (element) => {
|
|
619
|
-
const startArr = Array.isArray(element.start) ? element.start : [0, 0];
|
|
620
|
-
const endArr = Array.isArray(element.end) ? element.end : [100, 100];
|
|
621
|
-
const start = startArr.join(',');
|
|
622
|
-
const end = endArr.join(',');
|
|
623
|
-
if (element.broken) {
|
|
624
|
-
const mid = element.broken.join(',');
|
|
625
|
-
return `M${start} L${mid} L${end}`;
|
|
626
|
-
}
|
|
627
|
-
else if (element.broken2) {
|
|
628
|
-
const { minX, maxX, minY, maxY } = getElementRange(element);
|
|
629
|
-
if (maxX - minX >= maxY - minY)
|
|
630
|
-
return `M${start} L${element.broken2[0]},${startArr[1]} L${element.broken2[0]},${endArr[1]} ${end}`;
|
|
631
|
-
return `M${start} L${startArr[0]},${element.broken2[1]} L${endArr[0]},${element.broken2[1]} ${end}`;
|
|
632
|
-
}
|
|
633
|
-
else if (element.curve) {
|
|
634
|
-
const mid = element.curve.join(',');
|
|
635
|
-
return `M${start} Q${mid} ${end}`;
|
|
636
|
-
}
|
|
637
|
-
else if (element.cubic) {
|
|
638
|
-
const [c1, c2] = element.cubic;
|
|
639
|
-
const p1 = c1.join(',');
|
|
640
|
-
const p2 = c2.join(',');
|
|
641
|
-
return `M${start} C${p1} ${p2} ${end}`;
|
|
642
|
-
}
|
|
643
|
-
return `M${start} L${end}`;
|
|
644
|
-
};
|
|
645
|
-
|
|
646
|
-
const pathMap = {
|
|
647
|
-
dot: 'm0 5a5 5 0 1 0 10 0a5 5 0 1 0 -10 0z',
|
|
648
|
-
arrow: 'M0,0 L10,5 0,10 Z',
|
|
649
|
-
};
|
|
650
|
-
const rotateMap = {
|
|
651
|
-
'arrow-start': 180,
|
|
652
|
-
'arrow-end': 0,
|
|
653
|
-
};
|
|
654
|
-
function LinePointMarker({ id, position, type, baseSize, color }) {
|
|
655
|
-
const path = pathMap[type];
|
|
656
|
-
const rotate = rotateMap[`${type}-${position}`] || 0;
|
|
657
|
-
const size = baseSize < 2 ? 2 : baseSize;
|
|
658
|
-
return (jsx("marker", { id: `${id}-${type}-${position}`, markerUnits: "userSpaceOnUse", orient: "auto", markerWidth: size * 3, markerHeight: size * 3, refX: size * 1.5, refY: size * 1.5, children: jsx("path", { d: path, fill: color, transform: `scale(${size * 0.3}, ${size * 0.3}) rotate(${rotate}, 5, 5)` }) }));
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
const DRAW_ANIMATION_MS = 600;
|
|
662
|
-
function BaseLineElement({ elementInfo, animate }) {
|
|
663
|
-
const { shadowStyle } = useElementShadow(elementInfo.shadow);
|
|
664
|
-
const pathRef = useRef(null);
|
|
665
|
-
const [drawComplete, setDrawComplete] = useState(!animate);
|
|
666
|
-
const svgWidth = useMemo(() => {
|
|
667
|
-
const width = Math.abs(elementInfo.start[0] - elementInfo.end[0]);
|
|
668
|
-
return width < 24 ? 24 : width;
|
|
669
|
-
}, [elementInfo.start, elementInfo.end]);
|
|
670
|
-
const svgHeight = useMemo(() => {
|
|
671
|
-
const height = Math.abs(elementInfo.start[1] - elementInfo.end[1]);
|
|
672
|
-
return height < 24 ? 24 : height;
|
|
673
|
-
}, [elementInfo.start, elementInfo.end]);
|
|
674
|
-
const lineDashArray = useMemo(() => {
|
|
675
|
-
const size = elementInfo.width;
|
|
676
|
-
if (elementInfo.style === 'dashed')
|
|
677
|
-
return size <= 8 ? `${size * 5} ${size * 2.5}` : `${size * 5} ${size * 1.5}`;
|
|
678
|
-
if (elementInfo.style === 'dotted')
|
|
679
|
-
return size <= 8 ? `${size * 1.8} ${size * 1.6}` : `${size * 1.5} ${size * 1.2}`;
|
|
680
|
-
return '0 0';
|
|
681
|
-
}, [elementInfo.width, elementInfo.style]);
|
|
682
|
-
const path = useMemo(() => getLineElementPath(elementInfo), [elementInfo]);
|
|
683
|
-
useEffect(() => {
|
|
684
|
-
if (!animate)
|
|
685
|
-
return;
|
|
686
|
-
const pathEl = pathRef.current;
|
|
687
|
-
if (!pathEl)
|
|
688
|
-
return;
|
|
689
|
-
const length = pathEl.getTotalLength();
|
|
690
|
-
if (length === 0) {
|
|
691
|
-
const t = setTimeout(() => setDrawComplete(true), 0);
|
|
692
|
-
return () => clearTimeout(t);
|
|
693
|
-
}
|
|
694
|
-
pathEl.style.strokeDasharray = `${length}`;
|
|
695
|
-
pathEl.style.strokeDashoffset = `${length}`;
|
|
696
|
-
pathEl.style.transition = 'none';
|
|
697
|
-
pathEl.getBoundingClientRect();
|
|
698
|
-
pathEl.style.transition = `stroke-dashoffset ${DRAW_ANIMATION_MS}ms ease-out`;
|
|
699
|
-
pathEl.style.strokeDashoffset = '0';
|
|
700
|
-
const timer = setTimeout(() => {
|
|
701
|
-
pathEl.style.transition = 'none';
|
|
702
|
-
pathEl.style.strokeDasharray = '';
|
|
703
|
-
pathEl.style.strokeDashoffset = '';
|
|
704
|
-
setDrawComplete(true);
|
|
705
|
-
}, DRAW_ANIMATION_MS + 50);
|
|
706
|
-
return () => clearTimeout(timer);
|
|
707
|
-
}, [animate]);
|
|
708
|
-
return (jsx("div", { className: "base-element-line", style: {
|
|
709
|
-
position: 'absolute',
|
|
710
|
-
top: `${elementInfo.top}px`,
|
|
711
|
-
left: `${elementInfo.left}px`,
|
|
712
|
-
}, children: jsx("div", { className: "element-content", style: {
|
|
713
|
-
position: 'relative',
|
|
714
|
-
width: '100%',
|
|
715
|
-
height: '100%',
|
|
716
|
-
filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',
|
|
717
|
-
}, children: jsxs("svg", { overflow: "visible", width: svgWidth, height: svgHeight, style: { transformOrigin: '0 0', overflow: 'visible' }, children: [jsxs("defs", { children: [elementInfo.points[0] && (jsx(LinePointMarker, { id: elementInfo.id, position: "start", type: elementInfo.points[0], color: elementInfo.color, baseSize: elementInfo.width })), elementInfo.points[1] && (jsx(LinePointMarker, { id: elementInfo.id, position: "end", type: elementInfo.points[1], color: elementInfo.color, baseSize: elementInfo.width }))] }), jsx("path", { ref: pathRef, d: path, stroke: elementInfo.color, strokeWidth: elementInfo.width, strokeDasharray: lineDashArray, fill: "none", markerStart: drawComplete && elementInfo.points[0]
|
|
718
|
-
? `url(#${elementInfo.id}-${elementInfo.points[0]}-start)`
|
|
719
|
-
: '', markerEnd: drawComplete && elementInfo.points[1]
|
|
720
|
-
? `url(#${elementInfo.id}-${elementInfo.points[1]}-end)`
|
|
721
|
-
: '' })] }) }) }));
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmooth, stack, }) => {
|
|
725
|
-
const textStyle = textColor ? { color: textColor } : {};
|
|
726
|
-
const axisLine = textColor ? { lineStyle: { color: textColor } } : undefined;
|
|
727
|
-
const axisLabel = textColor ? { color: textColor } : undefined;
|
|
728
|
-
const splitLine = lineColor ? { lineStyle: { color: lineColor } } : {};
|
|
729
|
-
if (!Array.isArray(data?.series) || data.series.length === 0) {
|
|
730
|
-
return null;
|
|
731
|
-
}
|
|
732
|
-
const legend = data.series.length > 1 ? { top: 'bottom', textStyle } : undefined;
|
|
733
|
-
if (type === 'bar') {
|
|
734
|
-
return {
|
|
735
|
-
color: themeColors,
|
|
736
|
-
textStyle,
|
|
737
|
-
legend,
|
|
738
|
-
xAxis: { type: 'category', data: data.labels, axisLine, axisLabel },
|
|
739
|
-
yAxis: { type: 'value', axisLine, axisLabel, splitLine },
|
|
740
|
-
series: data.series.map((item, index) => {
|
|
741
|
-
const seriesItem = {
|
|
742
|
-
data: item,
|
|
743
|
-
name: data.legends[index],
|
|
744
|
-
type: 'bar',
|
|
745
|
-
label: { show: true },
|
|
746
|
-
itemStyle: { borderRadius: [2, 2, 0, 0] },
|
|
747
|
-
};
|
|
748
|
-
if (stack)
|
|
749
|
-
seriesItem.stack = 'A';
|
|
750
|
-
return seriesItem;
|
|
751
|
-
}),
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
if (type === 'column') {
|
|
755
|
-
return {
|
|
756
|
-
color: themeColors,
|
|
757
|
-
textStyle,
|
|
758
|
-
legend,
|
|
759
|
-
yAxis: { type: 'category', data: data.labels, axisLine, axisLabel },
|
|
760
|
-
xAxis: { type: 'value', axisLine, axisLabel, splitLine },
|
|
761
|
-
series: data.series.map((item, index) => {
|
|
762
|
-
const seriesItem = {
|
|
763
|
-
data: item,
|
|
764
|
-
name: data.legends[index],
|
|
765
|
-
type: 'bar',
|
|
766
|
-
label: { show: true },
|
|
767
|
-
itemStyle: { borderRadius: [0, 2, 2, 0] },
|
|
768
|
-
};
|
|
769
|
-
if (stack)
|
|
770
|
-
seriesItem.stack = 'A';
|
|
771
|
-
return seriesItem;
|
|
772
|
-
}),
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
if (type === 'line') {
|
|
776
|
-
return {
|
|
777
|
-
color: themeColors,
|
|
778
|
-
textStyle,
|
|
779
|
-
legend,
|
|
780
|
-
xAxis: { type: 'category', data: data.labels, axisLine, axisLabel },
|
|
781
|
-
yAxis: { type: 'value', axisLine, axisLabel, splitLine },
|
|
782
|
-
series: data.series.map((item, index) => {
|
|
783
|
-
const seriesItem = {
|
|
784
|
-
data: item,
|
|
785
|
-
name: data.legends[index],
|
|
786
|
-
type: 'line',
|
|
787
|
-
smooth: lineSmooth,
|
|
788
|
-
label: { show: true },
|
|
789
|
-
};
|
|
790
|
-
if (stack)
|
|
791
|
-
seriesItem.stack = 'A';
|
|
792
|
-
return seriesItem;
|
|
793
|
-
}),
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
if (type === 'pie') {
|
|
797
|
-
const series0 = data.series[0];
|
|
798
|
-
if (!Array.isArray(series0))
|
|
799
|
-
return null;
|
|
800
|
-
return {
|
|
801
|
-
color: themeColors,
|
|
802
|
-
textStyle,
|
|
803
|
-
legend: { top: 'bottom', textStyle },
|
|
804
|
-
series: [
|
|
805
|
-
{
|
|
806
|
-
data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),
|
|
807
|
-
label: textColor ? { color: textColor } : {},
|
|
808
|
-
type: 'pie',
|
|
809
|
-
radius: '70%',
|
|
810
|
-
emphasis: {
|
|
811
|
-
itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' },
|
|
812
|
-
label: { show: true, fontSize: 14, fontWeight: 'bold' },
|
|
813
|
-
},
|
|
814
|
-
},
|
|
815
|
-
],
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
if (type === 'ring') {
|
|
819
|
-
const series0 = data.series[0];
|
|
820
|
-
if (!Array.isArray(series0))
|
|
821
|
-
return null;
|
|
822
|
-
return {
|
|
823
|
-
color: themeColors,
|
|
824
|
-
textStyle,
|
|
825
|
-
legend: { top: 'bottom', textStyle },
|
|
826
|
-
series: [
|
|
827
|
-
{
|
|
828
|
-
data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),
|
|
829
|
-
label: textColor ? { color: textColor } : {},
|
|
830
|
-
type: 'pie',
|
|
831
|
-
radius: ['40%', '70%'],
|
|
832
|
-
padAngle: 1,
|
|
833
|
-
avoidLabelOverlap: false,
|
|
834
|
-
itemStyle: { borderRadius: 4 },
|
|
835
|
-
emphasis: { label: { show: true, fontSize: 14, fontWeight: 'bold' } },
|
|
836
|
-
},
|
|
837
|
-
],
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
if (type === 'area') {
|
|
841
|
-
return {
|
|
842
|
-
color: themeColors,
|
|
843
|
-
textStyle,
|
|
844
|
-
legend,
|
|
845
|
-
xAxis: { type: 'category', boundaryGap: false, data: data.labels, axisLine, axisLabel },
|
|
846
|
-
yAxis: { type: 'value', axisLine, axisLabel, splitLine },
|
|
847
|
-
series: data.series.map((item, index) => {
|
|
848
|
-
const seriesItem = {
|
|
849
|
-
data: item,
|
|
850
|
-
name: data.legends[index],
|
|
851
|
-
type: 'line',
|
|
852
|
-
areaStyle: {},
|
|
853
|
-
label: { show: true },
|
|
854
|
-
};
|
|
855
|
-
if (stack)
|
|
856
|
-
seriesItem.stack = 'A';
|
|
857
|
-
return seriesItem;
|
|
858
|
-
}),
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
if (type === 'radar') {
|
|
862
|
-
return {
|
|
863
|
-
color: themeColors,
|
|
864
|
-
textStyle,
|
|
865
|
-
legend,
|
|
866
|
-
radar: {
|
|
867
|
-
indicator: data.labels.map((item) => ({ name: item })),
|
|
868
|
-
splitLine,
|
|
869
|
-
axisLine: lineColor ? { lineStyle: { color: lineColor } } : undefined,
|
|
870
|
-
},
|
|
871
|
-
series: [
|
|
872
|
-
{
|
|
873
|
-
data: data.series.map((item, index) => ({ value: item, name: data.legends[index] })),
|
|
874
|
-
type: 'radar',
|
|
875
|
-
},
|
|
876
|
-
],
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
if (type === 'scatter') {
|
|
880
|
-
const series0 = data.series[0];
|
|
881
|
-
if (!Array.isArray(series0))
|
|
882
|
-
return null;
|
|
883
|
-
const formatedData = [];
|
|
884
|
-
for (let i = 0; i < series0.length; i++) {
|
|
885
|
-
const x = series0[i];
|
|
886
|
-
const y = data.series[1]?.[i] ?? x;
|
|
887
|
-
formatedData.push([x, y]);
|
|
888
|
-
}
|
|
889
|
-
return {
|
|
890
|
-
color: themeColors,
|
|
891
|
-
textStyle,
|
|
892
|
-
xAxis: { axisLine, axisLabel, splitLine },
|
|
893
|
-
yAxis: { axisLine, axisLabel, splitLine },
|
|
894
|
-
series: [{ symbolSize: 12, data: formatedData, type: 'scatter' }],
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
return null;
|
|
898
|
-
};
|
|
899
|
-
|
|
900
|
-
echarts.use([
|
|
901
|
-
BarChart,
|
|
902
|
-
LineChart,
|
|
903
|
-
PieChart,
|
|
904
|
-
ScatterChart,
|
|
905
|
-
RadarChart,
|
|
906
|
-
LegendComponent,
|
|
907
|
-
SVGRenderer,
|
|
908
|
-
]);
|
|
909
|
-
function Chart({ width: _width, height: _height, type, data, themeColors: rawThemeColors, textColor, lineColor, options, }) {
|
|
910
|
-
const chartRef = useRef(null);
|
|
911
|
-
const chartInstance = useRef(null);
|
|
912
|
-
const themeColors = useMemo(() => {
|
|
913
|
-
let colors = [];
|
|
914
|
-
if (rawThemeColors.length >= 10) {
|
|
915
|
-
colors = rawThemeColors;
|
|
916
|
-
}
|
|
917
|
-
else if (rawThemeColors.length === 1) {
|
|
918
|
-
colors = tinycolor(rawThemeColors[0])
|
|
919
|
-
.analogous(10)
|
|
920
|
-
.map((color) => color.toRgbString());
|
|
921
|
-
}
|
|
922
|
-
else {
|
|
923
|
-
const len = rawThemeColors.length;
|
|
924
|
-
const supplement = tinycolor(rawThemeColors[len - 1])
|
|
925
|
-
.analogous(10 + 1 - len)
|
|
926
|
-
.map((color) => color.toRgbString());
|
|
927
|
-
colors = [...rawThemeColors.slice(0, len - 1), ...supplement];
|
|
928
|
-
}
|
|
929
|
-
return colors;
|
|
930
|
-
}, [rawThemeColors]);
|
|
931
|
-
const updateOption = useMemo(() => {
|
|
932
|
-
return () => {
|
|
933
|
-
if (!chartInstance.current)
|
|
934
|
-
return;
|
|
935
|
-
const option = getChartOption({
|
|
936
|
-
type,
|
|
937
|
-
data,
|
|
938
|
-
themeColors,
|
|
939
|
-
textColor,
|
|
940
|
-
lineColor,
|
|
941
|
-
lineSmooth: options?.lineSmooth || false,
|
|
942
|
-
stack: options?.stack || false,
|
|
943
|
-
});
|
|
944
|
-
if (option) {
|
|
945
|
-
chartInstance.current.setOption(option, true);
|
|
946
|
-
}
|
|
947
|
-
};
|
|
948
|
-
}, [type, data, themeColors, textColor, lineColor, options]);
|
|
949
|
-
useEffect(() => {
|
|
950
|
-
if (!chartRef.current)
|
|
951
|
-
return;
|
|
952
|
-
chartInstance.current = echarts.init(chartRef.current, null, { renderer: 'svg' });
|
|
953
|
-
updateOption();
|
|
954
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
955
|
-
chartInstance.current?.resize();
|
|
956
|
-
});
|
|
957
|
-
resizeObserver.observe(chartRef.current);
|
|
958
|
-
return () => {
|
|
959
|
-
resizeObserver.disconnect();
|
|
960
|
-
chartInstance.current?.dispose();
|
|
961
|
-
chartInstance.current = null;
|
|
962
|
-
};
|
|
963
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- Init-only effect
|
|
964
|
-
}, []);
|
|
965
|
-
useEffect(() => {
|
|
966
|
-
updateOption();
|
|
967
|
-
}, [updateOption]);
|
|
968
|
-
return jsx("div", { ref: chartRef, className: "chart", style: { width: '100%', height: '100%' } });
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
function BaseChartElement({ elementInfo, target }) {
|
|
972
|
-
return (jsx("div", { className: "base-element-chart", style: {
|
|
973
|
-
position: 'absolute',
|
|
974
|
-
top: `${elementInfo.top}px`,
|
|
975
|
-
left: `${elementInfo.left}px`,
|
|
976
|
-
width: `${elementInfo.width}px`,
|
|
977
|
-
height: `${elementInfo.height}px`,
|
|
978
|
-
pointerEvents: target === 'thumbnail' ? 'none' : undefined,
|
|
979
|
-
}, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
980
|
-
width: '100%',
|
|
981
|
-
height: '100%',
|
|
982
|
-
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
983
|
-
}, children: jsxs("div", { className: "element-content", style: { width: '100%', height: '100%', backgroundColor: elementInfo.fill }, children: [jsx(ElementOutline, { width: elementInfo.width, height: elementInfo.height, outline: elementInfo.outline }), jsx(Chart, { width: elementInfo.width, height: elementInfo.height, type: elementInfo.chartType, data: elementInfo.data, themeColors: elementInfo.themeColors, textColor: elementInfo.textColor, lineColor: elementInfo.lineColor, options: elementInfo.options })] }) }) }));
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
function BaseLatexElement({ elementInfo }) {
|
|
987
|
-
return (jsx("div", { className: "base-element-latex", style: {
|
|
988
|
-
position: 'absolute',
|
|
989
|
-
top: `${elementInfo.top}px`,
|
|
990
|
-
left: `${elementInfo.left}px`,
|
|
991
|
-
width: `${elementInfo.width}px`,
|
|
992
|
-
height: `${elementInfo.height}px`,
|
|
993
|
-
}, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
994
|
-
width: '100%',
|
|
995
|
-
height: '100%',
|
|
996
|
-
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
997
|
-
}, children: jsx("div", { className: "element-content", style: {
|
|
998
|
-
position: 'relative',
|
|
999
|
-
width: '100%',
|
|
1000
|
-
height: '100%',
|
|
1001
|
-
// KaTeX glyphs inherit `color`; apply the formula's resolved color
|
|
1002
|
-
// (e.g. 蓝色权重) so it isn't forced to the browser default.
|
|
1003
|
-
...(elementInfo.color ? { color: elementInfo.color } : {}),
|
|
1004
|
-
}, children: elementInfo.html ? (jsx(KatexContent, { html: elementInfo.html, width: elementInfo.width, height: elementInfo.height, align: elementInfo.align })) : elementInfo.path && elementInfo.viewBox ? (jsx("svg", { overflow: "visible", width: elementInfo.width, height: elementInfo.height, stroke: elementInfo.color, strokeWidth: elementInfo.strokeWidth, fill: "none", strokeLinecap: "round", strokeLinejoin: "round", style: { transformOrigin: '0 0', overflow: 'visible' }, children: jsx("g", { transform: `scale(${elementInfo.width / elementInfo.viewBox[0]}, ${elementInfo.height / elementInfo.viewBox[1]}) translate(0,0) matrix(1,0,0,1,0,0)`, children: jsx("path", { d: elementInfo.path }) }) })) : null }) }) }));
|
|
1005
|
-
}
|
|
1006
|
-
const ALIGN_MAP = {
|
|
1007
|
-
left: 'flex-start',
|
|
1008
|
-
center: 'center',
|
|
1009
|
-
right: 'flex-end',
|
|
1010
|
-
};
|
|
1011
|
-
function KatexContent({ html, width, height, align = 'center', }) {
|
|
1012
|
-
const innerRef = useRef(null);
|
|
1013
|
-
const [scale, setScale] = useState(1);
|
|
1014
|
-
useLayoutEffect(() => {
|
|
1015
|
-
if (!innerRef.current)
|
|
1016
|
-
return;
|
|
1017
|
-
const naturalW = innerRef.current.scrollWidth;
|
|
1018
|
-
const naturalH = innerRef.current.scrollHeight;
|
|
1019
|
-
if (naturalW > 0 && naturalH > 0) {
|
|
1020
|
-
// Cap at 1: only ever shrink the formula to fit its box, never enlarge.
|
|
1021
|
-
// A short formula sitting in a large frame (e.g. slide 29 的右侧推理框)
|
|
1022
|
-
// would otherwise get scaled up to fill the box and render huge.
|
|
1023
|
-
setScale(Math.min(width / naturalW, height / naturalH, 1));
|
|
1024
|
-
}
|
|
1025
|
-
}, [html, width, height]);
|
|
1026
|
-
const justify = ALIGN_MAP[align];
|
|
1027
|
-
const origin = align === 'left' ? 'left center' : align === 'right' ? 'right center' : 'center center';
|
|
1028
|
-
return (jsx("div", { style: {
|
|
1029
|
-
width,
|
|
1030
|
-
height,
|
|
1031
|
-
overflow: 'hidden',
|
|
1032
|
-
display: 'flex',
|
|
1033
|
-
alignItems: 'center',
|
|
1034
|
-
justifyContent: justify,
|
|
1035
|
-
}, children: jsx("div", { ref: innerRef, className: "slide-renderer-prose", style: {
|
|
1036
|
-
transformOrigin: origin,
|
|
1037
|
-
transform: `scale(${scale})`,
|
|
1038
|
-
whiteSpace: 'nowrap',
|
|
1039
|
-
}, dangerouslySetInnerHTML: { __html: html } }) }));
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
function getTextStyle(style) {
|
|
1043
|
-
if (!style)
|
|
1044
|
-
return {};
|
|
1045
|
-
const css = {};
|
|
1046
|
-
if (style.bold)
|
|
1047
|
-
css.fontWeight = 'bold';
|
|
1048
|
-
if (style.em)
|
|
1049
|
-
css.fontStyle = 'italic';
|
|
1050
|
-
if (style.underline)
|
|
1051
|
-
css.textDecoration = 'underline';
|
|
1052
|
-
if (style.strikethrough) {
|
|
1053
|
-
css.textDecoration = css.textDecoration ? `${css.textDecoration} line-through` : 'line-through';
|
|
1054
|
-
}
|
|
1055
|
-
if (style.color)
|
|
1056
|
-
css.color = style.color;
|
|
1057
|
-
if (style.backcolor)
|
|
1058
|
-
css.backgroundColor = style.backcolor;
|
|
1059
|
-
if (style.fontsize)
|
|
1060
|
-
css.fontSize = style.fontsize;
|
|
1061
|
-
if (style.fontname)
|
|
1062
|
-
css.fontFamily = style.fontname;
|
|
1063
|
-
if (style.align)
|
|
1064
|
-
css.textAlign = style.align;
|
|
1065
|
-
return css;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
function cellBorderCss(b) {
|
|
1069
|
-
if (!b || b.width <= 0)
|
|
1070
|
-
return undefined;
|
|
1071
|
-
const style = b.style === 'dashed' || b.style === 'dotted' ? b.style : 'solid';
|
|
1072
|
-
return `${b.width}px ${style} ${b.color}`;
|
|
1073
|
-
}
|
|
1074
|
-
function StaticTable({ elementInfo }) {
|
|
1075
|
-
const { width, data, colWidths, cellMinHeight, rowHeights, outline, theme } = elementInfo;
|
|
1076
|
-
const [subThemeDark, subThemeLight] = useMemo(() => {
|
|
1077
|
-
if (!theme)
|
|
1078
|
-
return ['', ''];
|
|
1079
|
-
return getTableSubThemeColor(theme.color);
|
|
1080
|
-
}, [theme]);
|
|
1081
|
-
const borderStyle = useMemo(() => {
|
|
1082
|
-
if (!outline)
|
|
1083
|
-
return 'none';
|
|
1084
|
-
const w = outline.width ?? 1;
|
|
1085
|
-
const c = outline.color ?? '#000';
|
|
1086
|
-
const s = outline.style === 'dashed' ? 'dashed' : 'solid';
|
|
1087
|
-
return `${w}px ${s} ${c}`;
|
|
1088
|
-
}, [outline]);
|
|
1089
|
-
const getCellBg = (rowIdx, colIdx, cellBackcolor) => {
|
|
1090
|
-
if (cellBackcolor)
|
|
1091
|
-
return cellBackcolor;
|
|
1092
|
-
if (!theme)
|
|
1093
|
-
return undefined;
|
|
1094
|
-
const rowCount = data.length;
|
|
1095
|
-
const colCount = data[0]?.length ?? 0;
|
|
1096
|
-
if (theme.rowHeader && rowIdx === 0)
|
|
1097
|
-
return theme.color;
|
|
1098
|
-
if (theme.rowFooter && rowIdx === rowCount - 1)
|
|
1099
|
-
return theme.color;
|
|
1100
|
-
if (theme.colHeader && colIdx === 0)
|
|
1101
|
-
return subThemeDark;
|
|
1102
|
-
if (theme.colFooter && colIdx === colCount - 1)
|
|
1103
|
-
return subThemeDark;
|
|
1104
|
-
const effectiveRow = theme.rowHeader ? rowIdx - 1 : rowIdx;
|
|
1105
|
-
if (effectiveRow >= 0 && effectiveRow % 2 === 0)
|
|
1106
|
-
return subThemeLight;
|
|
1107
|
-
return undefined;
|
|
1108
|
-
};
|
|
1109
|
-
const getHeaderTextColor = (rowIdx) => {
|
|
1110
|
-
if (!theme)
|
|
1111
|
-
return undefined;
|
|
1112
|
-
const rowCount = data.length;
|
|
1113
|
-
if (theme.rowHeader && rowIdx === 0)
|
|
1114
|
-
return '#fff';
|
|
1115
|
-
if (theme.rowFooter && rowIdx === rowCount - 1)
|
|
1116
|
-
return '#fff';
|
|
1117
|
-
return undefined;
|
|
1118
|
-
};
|
|
1119
|
-
return (jsxs("table", { className: "slide-renderer-prose", style: {
|
|
1120
|
-
width: '100%',
|
|
1121
|
-
borderCollapse: 'collapse',
|
|
1122
|
-
tableLayout: 'fixed',
|
|
1123
|
-
}, 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) => {
|
|
1124
|
-
// parser side (transformParsedToSlides) 已经把 hMerge/vMerge
|
|
1125
|
-
// continuation 单元格剔除了,data[r] 只剩 top-left cells;浏览器
|
|
1126
|
-
// 的 HTML table layout 通过 td.colSpan/rowSpan 自动算正确位置,
|
|
1127
|
-
// 不需要再手动算 hiddenCells(旧实现用 data-index 比对 grid-coord
|
|
1128
|
-
// key,混了两种坐标系,把 colspan 跨过的 grid-coord 等于另一格
|
|
1129
|
-
// 的 data-index 时会误隐藏,slide 26 表头 "权重"/"好" 就是中招)。
|
|
1130
|
-
const bgColor = getCellBg(rowIdx, colIdx, cell.style?.backcolor);
|
|
1131
|
-
const headerColor = getHeaderTextColor(rowIdx);
|
|
1132
|
-
const textStyle = getTextStyle(cell.style);
|
|
1133
|
-
if (headerColor && !cell.style?.color) {
|
|
1134
|
-
textStyle.color = headerColor;
|
|
1135
|
-
}
|
|
1136
|
-
// 单元格自带逐边描边时按边渲染(未定义的边不画);否则回退到
|
|
1137
|
-
// 表级 outline 套四边的旧行为,保留真·网格表格的表现。
|
|
1138
|
-
const cellBorders = cell.borders;
|
|
1139
|
-
const borderCss = cellBorders &&
|
|
1140
|
-
(cellBorders.top || cellBorders.bottom || cellBorders.left || cellBorders.right)
|
|
1141
|
-
? {
|
|
1142
|
-
borderTop: cellBorderCss(cellBorders.top) ?? 'none',
|
|
1143
|
-
borderBottom: cellBorderCss(cellBorders.bottom) ?? 'none',
|
|
1144
|
-
borderLeft: cellBorderCss(cellBorders.left) ?? 'none',
|
|
1145
|
-
borderRight: cellBorderCss(cellBorders.right) ?? 'none',
|
|
1146
|
-
}
|
|
1147
|
-
: { border: borderStyle };
|
|
1148
|
-
return (jsx("td", { colSpan: cell.colspan > 1 ? cell.colspan : undefined, rowSpan: cell.rowspan > 1 ? cell.rowspan : undefined, style: {
|
|
1149
|
-
...borderCss,
|
|
1150
|
-
backgroundColor: bgColor,
|
|
1151
|
-
...textStyle,
|
|
1152
|
-
}, children: jsx("div", { className: "slide-renderer-cell-text", style: {
|
|
1153
|
-
minHeight: `${(rowHeights?.[rowIdx] ?? cellMinHeight) - 4}px`,
|
|
1154
|
-
padding: cell.padding,
|
|
1155
|
-
display: 'flex',
|
|
1156
|
-
flexDirection: 'column',
|
|
1157
|
-
lineHeight: 1,
|
|
1158
|
-
justifyContent: cell.vAlign === 'top'
|
|
1159
|
-
? 'flex-start'
|
|
1160
|
-
: cell.vAlign === 'bottom'
|
|
1161
|
-
? 'flex-end'
|
|
1162
|
-
: cell.vAlign === 'middle'
|
|
1163
|
-
? 'center'
|
|
1164
|
-
: undefined,
|
|
1165
|
-
},
|
|
1166
|
-
// cell.text is already final HTML (transformParsedToSlides
|
|
1167
|
-
// escapes text + converts \n/spaces and keeps <p> positioning
|
|
1168
|
-
// styles). Do NOT run formatText here — its space→
|
|
1169
|
-
// replacement corrupts style attributes like
|
|
1170
|
-
// `margin-left: calc(42px + 0.25em)` → the title indent is
|
|
1171
|
-
// lost and collides with the cell's left icon (slide 5).
|
|
1172
|
-
dangerouslySetInnerHTML: { __html: cell.text } }) }, cell.id));
|
|
1173
|
-
}) }, rowIdx))) })] }));
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
function BaseTableElement({ elementInfo, target }) {
|
|
1177
|
-
return (jsx("div", { className: "base-element-table", style: {
|
|
1178
|
-
position: 'absolute',
|
|
1179
|
-
top: `${elementInfo.top}px`,
|
|
1180
|
-
left: `${elementInfo.left}px`,
|
|
1181
|
-
width: `${elementInfo.width}px`,
|
|
1182
|
-
height: `${elementInfo.height}px`,
|
|
1183
|
-
pointerEvents: target === 'thumbnail' ? 'none' : undefined,
|
|
1184
|
-
}, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
1185
|
-
width: '100%',
|
|
1186
|
-
height: '100%',
|
|
1187
|
-
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
1188
|
-
}, children: jsx("div", { className: "element-content", style: { width: '100%', height: '100%' }, children: jsx(StaticTable, { elementInfo: elementInfo }) }) }) }));
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
function BaseVideoElement({ elementInfo, renderVideo }) {
|
|
1192
|
-
return (jsx("div", { className: "element-content", "data-video-element": true, style: {
|
|
1193
|
-
position: 'absolute',
|
|
1194
|
-
top: `${elementInfo.top}px`,
|
|
1195
|
-
left: `${elementInfo.left}px`,
|
|
1196
|
-
width: `${elementInfo.width}px`,
|
|
1197
|
-
height: `${elementInfo.height}px`,
|
|
1198
|
-
}, onClick: (e) => e.stopPropagation(), onPointerDown: (e) => e.stopPropagation(), children: jsx("div", { style: {
|
|
1199
|
-
width: '100%',
|
|
1200
|
-
height: '100%',
|
|
1201
|
-
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
1202
|
-
}, children: renderVideo ? (renderVideo(elementInfo)) : elementInfo.src || elementInfo.poster ? (
|
|
1203
|
-
// Render <video> when we have either a playable src OR just a
|
|
1204
|
-
// poster/preview frame. A PPTX「视频」often has no decodable src in
|
|
1205
|
-
// this pipeline but does carry a preview image; rendering
|
|
1206
|
-
// <video poster> still shows that frame on the live canvas (instead
|
|
1207
|
-
// of falling through to the gray play-icon placeholder — slide 34).
|
|
1208
|
-
// Snapshot capture of the poster frame is handled in slideToPng
|
|
1209
|
-
// (html2canvas can't draw <video> directly).
|
|
1210
|
-
jsx("video", { style: { width: '100%', height: '100%', objectFit: 'contain' }, ...(elementInfo.src ? { src: elementInfo.src } : {}), poster: elementInfo.poster, preload: "metadata", controls: !!elementInfo.src })) : (jsx("div", { style: {
|
|
1211
|
-
width: '100%',
|
|
1212
|
-
height: '100%',
|
|
1213
|
-
display: 'flex',
|
|
1214
|
-
alignItems: 'center',
|
|
1215
|
-
justifyContent: 'center',
|
|
1216
|
-
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
1217
|
-
borderRadius: '4px',
|
|
1218
|
-
}, children: jsx("svg", { style: { width: '48px', height: '48px', color: '#9ca3af' }, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round", children: jsx("polygon", { points: "5 3 19 12 5 21 5 3" }) }) })) }) }));
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
// ==================== Shiki Singleton ====================
|
|
1222
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1223
|
-
let highlighterPromise = null;
|
|
1224
|
-
function getHighlighter() {
|
|
1225
|
-
if (!highlighterPromise) {
|
|
1226
|
-
highlighterPromise = import('shiki').then(({ createHighlighter }) => createHighlighter({
|
|
1227
|
-
themes: ['github-light'],
|
|
1228
|
-
langs: [
|
|
1229
|
-
'python',
|
|
1230
|
-
'javascript',
|
|
1231
|
-
'typescript',
|
|
1232
|
-
'json',
|
|
1233
|
-
'go',
|
|
1234
|
-
'rust',
|
|
1235
|
-
'java',
|
|
1236
|
-
'c',
|
|
1237
|
-
'cpp',
|
|
1238
|
-
'html',
|
|
1239
|
-
'css',
|
|
1240
|
-
'bash',
|
|
1241
|
-
'sql',
|
|
1242
|
-
'yaml',
|
|
1243
|
-
'markdown',
|
|
1244
|
-
'jsx',
|
|
1245
|
-
'tsx',
|
|
1246
|
-
],
|
|
1247
|
-
}));
|
|
1248
|
-
}
|
|
1249
|
-
return highlighterPromise;
|
|
1250
|
-
}
|
|
1251
|
-
// ==================== Helpers ====================
|
|
1252
|
-
function parseShikiLines(html) {
|
|
1253
|
-
const codeMatch = html.match(/<code>([\s\S]*?)<\/code>/);
|
|
1254
|
-
if (!codeMatch)
|
|
1255
|
-
return [];
|
|
1256
|
-
const parts = codeMatch[1].split('<span class="line">');
|
|
1257
|
-
const lines = [];
|
|
1258
|
-
for (const part of parts) {
|
|
1259
|
-
if (!part)
|
|
1260
|
-
continue;
|
|
1261
|
-
const endIdx = part.lastIndexOf('</span>');
|
|
1262
|
-
if (endIdx !== -1) {
|
|
1263
|
-
lines.push(part.substring(0, endIdx));
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
return lines;
|
|
1267
|
-
}
|
|
1268
|
-
// ==================== Typing Easing ====================
|
|
1269
|
-
const STUTTER_COUNT = 5;
|
|
1270
|
-
const STUTTER_AMOUNT = 0.04;
|
|
1271
|
-
const LINE_GAP_MS = 120;
|
|
1272
|
-
const TAB_SIZE = 4;
|
|
1273
|
-
function visualLength(s) {
|
|
1274
|
-
let len = 0;
|
|
1275
|
-
for (const ch of s) {
|
|
1276
|
-
len += ch === '\t' ? TAB_SIZE : 1;
|
|
1277
|
-
}
|
|
1278
|
-
return len;
|
|
1279
|
-
}
|
|
1280
|
-
function getTypingCharCount(content) {
|
|
1281
|
-
const trimmed = content.replace(/^[\t ]+/, '');
|
|
1282
|
-
return trimmed.length;
|
|
1283
|
-
}
|
|
1284
|
-
function computeRevealSteps(content) {
|
|
1285
|
-
const total = visualLength(content);
|
|
1286
|
-
if (total === 0)
|
|
1287
|
-
return [1];
|
|
1288
|
-
const trimmed = content.replace(/^[\t ]+/, '');
|
|
1289
|
-
const indentPart = content.slice(0, content.length - trimmed.length);
|
|
1290
|
-
let cumVisual = 0;
|
|
1291
|
-
for (const ch of indentPart) {
|
|
1292
|
-
cumVisual += ch === '\t' ? TAB_SIZE : 1;
|
|
1293
|
-
}
|
|
1294
|
-
const steps = [cumVisual / total];
|
|
1295
|
-
for (const ch of trimmed) {
|
|
1296
|
-
cumVisual += ch === '\t' ? TAB_SIZE : 1;
|
|
1297
|
-
steps.push(cumVisual / total);
|
|
1298
|
-
}
|
|
1299
|
-
return steps;
|
|
1300
|
-
}
|
|
1301
|
-
function humanTypingEase(t) {
|
|
1302
|
-
const eased = 0.5 - 0.5 * Math.cos(Math.PI * t);
|
|
1303
|
-
const stutter = Math.sin(t * Math.PI * STUTTER_COUNT) * STUTTER_AMOUNT * 4 * t * (1 - t);
|
|
1304
|
-
return Math.min(Math.max(eased + stutter, 0), 1);
|
|
1305
|
-
}
|
|
1306
|
-
// ==================== TypingReveal ====================
|
|
1307
|
-
function TypingReveal({ html, durationMs, revealSteps, onComplete, }) {
|
|
1308
|
-
const typingUnitCount = revealSteps.length - 1;
|
|
1309
|
-
const [revealPct, setRevealPct] = useState(revealSteps[0]);
|
|
1310
|
-
const rafRef = useRef(0);
|
|
1311
|
-
const startRef = useRef(0);
|
|
1312
|
-
useEffect(() => {
|
|
1313
|
-
if (typingUnitCount <= 0) {
|
|
1314
|
-
const t = setTimeout(() => {
|
|
1315
|
-
setRevealPct(1);
|
|
1316
|
-
onComplete();
|
|
1317
|
-
}, 0);
|
|
1318
|
-
return () => clearTimeout(t);
|
|
1319
|
-
}
|
|
1320
|
-
startRef.current = performance.now();
|
|
1321
|
-
const tick = (now) => {
|
|
1322
|
-
const elapsed = now - startRef.current;
|
|
1323
|
-
const linearT = Math.min(elapsed / durationMs, 1);
|
|
1324
|
-
const easedProgress = humanTypingEase(linearT);
|
|
1325
|
-
const stepIdx = Math.min(Math.floor(easedProgress * (typingUnitCount + 1)), typingUnitCount);
|
|
1326
|
-
setRevealPct(revealSteps[stepIdx]);
|
|
1327
|
-
if (linearT < 1) {
|
|
1328
|
-
rafRef.current = requestAnimationFrame(tick);
|
|
1329
|
-
}
|
|
1330
|
-
else {
|
|
1331
|
-
setRevealPct(1);
|
|
1332
|
-
onComplete();
|
|
1333
|
-
}
|
|
1334
|
-
};
|
|
1335
|
-
rafRef.current = requestAnimationFrame(tick);
|
|
1336
|
-
return () => cancelAnimationFrame(rafRef.current);
|
|
1337
|
-
}, [durationMs, typingUnitCount, revealSteps, onComplete]);
|
|
1338
|
-
return (jsxs("span", { style: { position: 'relative', display: 'inline-block' }, children: [jsx("span", { style: {
|
|
1339
|
-
clipPath: `inset(0 ${(1 - revealPct) * 100}% 0 0)`,
|
|
1340
|
-
}, dangerouslySetInnerHTML: { __html: html } }), revealPct < 1 && (jsx("span", { style: {
|
|
1341
|
-
position: 'absolute',
|
|
1342
|
-
top: 0,
|
|
1343
|
-
width: '2px',
|
|
1344
|
-
backgroundColor: '#1f2937',
|
|
1345
|
-
left: `${revealPct * 100}%`,
|
|
1346
|
-
height: '1.1em',
|
|
1347
|
-
animation: 'slide-renderer-code-cursor-blink 0.6s step-end infinite',
|
|
1348
|
-
} }))] }));
|
|
1349
|
-
}
|
|
1350
|
-
// ==================== CodeLineRow ====================
|
|
1351
|
-
function getTypingDuration(content) {
|
|
1352
|
-
return Math.max(getTypingCharCount(content) * 40, 250);
|
|
1353
|
-
}
|
|
1354
|
-
const REPLACE_SELECT_MS = 350;
|
|
1355
|
-
function CodeLineRow({ line, lineNumber, highlightedHtml, showLineNumbers, animState, animate, typingDelay, }) {
|
|
1356
|
-
const isNewLine = animate && !!animState && animState.type !== 'replaced';
|
|
1357
|
-
const isReplace = animate && animState?.type === 'replaced';
|
|
1358
|
-
const [mounted, setMounted] = useState(!isNewLine || typingDelay === 0);
|
|
1359
|
-
useEffect(() => {
|
|
1360
|
-
if (isNewLine && typingDelay > 0) {
|
|
1361
|
-
const timer = setTimeout(() => setMounted(true), typingDelay);
|
|
1362
|
-
return () => clearTimeout(timer);
|
|
1363
|
-
}
|
|
1364
|
-
}, [isNewLine, typingDelay]);
|
|
1365
|
-
const [typing, setTyping] = useState(isNewLine && typingDelay === 0);
|
|
1366
|
-
useEffect(() => {
|
|
1367
|
-
if (mounted && isNewLine) {
|
|
1368
|
-
const t = setTimeout(() => setTyping(true), 0);
|
|
1369
|
-
return () => clearTimeout(t);
|
|
1370
|
-
}
|
|
1371
|
-
}, [mounted, isNewLine]);
|
|
1372
|
-
const handleTypingComplete = useCallback(() => {
|
|
1373
|
-
setTyping(false);
|
|
1374
|
-
}, []);
|
|
1375
|
-
const prevHtmlRef = useRef(highlightedHtml);
|
|
1376
|
-
const [replacePhase, setReplacePhase] = useState('idle');
|
|
1377
|
-
const [oldHtml, setOldHtml] = useState(null);
|
|
1378
|
-
useEffect(() => {
|
|
1379
|
-
if (isReplace && prevHtmlRef.current !== highlightedHtml) {
|
|
1380
|
-
setOldHtml(prevHtmlRef.current);
|
|
1381
|
-
setReplacePhase('select');
|
|
1382
|
-
const timer = setTimeout(() => {
|
|
1383
|
-
setReplacePhase('type');
|
|
1384
|
-
setTyping(true);
|
|
1385
|
-
setOldHtml(null);
|
|
1386
|
-
prevHtmlRef.current = highlightedHtml;
|
|
1387
|
-
}, REPLACE_SELECT_MS);
|
|
1388
|
-
return () => clearTimeout(timer);
|
|
1389
|
-
}
|
|
1390
|
-
prevHtmlRef.current = highlightedHtml;
|
|
1391
|
-
}, [isReplace, highlightedHtml]);
|
|
1392
|
-
const [highlight, setHighlight] = useState(() => {
|
|
1393
|
-
if (!animState)
|
|
1394
|
-
return null;
|
|
1395
|
-
if (animState.type === 'inserted')
|
|
1396
|
-
return 'rgba(34, 197, 94, 0.12)';
|
|
1397
|
-
return null;
|
|
1398
|
-
});
|
|
1399
|
-
useEffect(() => {
|
|
1400
|
-
if (animState?.type === 'inserted') {
|
|
1401
|
-
const t = setTimeout(() => setHighlight('rgba(34, 197, 94, 0.12)'), 0);
|
|
1402
|
-
return () => clearTimeout(t);
|
|
1403
|
-
}
|
|
1404
|
-
}, [animState]);
|
|
1405
|
-
const [highlightFading, setHighlightFading] = useState(false);
|
|
1406
|
-
useEffect(() => {
|
|
1407
|
-
if (!highlight || highlightFading || typing)
|
|
1408
|
-
return;
|
|
1409
|
-
const fadeTimer = setTimeout(() => setHighlightFading(true), 0);
|
|
1410
|
-
const clearTimer = setTimeout(() => {
|
|
1411
|
-
setHighlight(null);
|
|
1412
|
-
setHighlightFading(false);
|
|
1413
|
-
}, 2000);
|
|
1414
|
-
return () => {
|
|
1415
|
-
clearTimeout(fadeTimer);
|
|
1416
|
-
clearTimeout(clearTimer);
|
|
1417
|
-
};
|
|
1418
|
-
}, [highlight, typing, highlightFading]);
|
|
1419
|
-
const typingDuration = getTypingDuration(line.content);
|
|
1420
|
-
const revealSteps = useMemo(() => computeRevealSteps(line.content), [line.content]);
|
|
1421
|
-
if (!mounted)
|
|
1422
|
-
return null;
|
|
1423
|
-
let bgColor = highlight || 'transparent';
|
|
1424
|
-
if (replacePhase === 'select')
|
|
1425
|
-
bgColor = 'rgba(59, 130, 246, 0.18)';
|
|
1426
|
-
let contentNode;
|
|
1427
|
-
if (replacePhase === 'select' && oldHtml) {
|
|
1428
|
-
contentNode = jsx("span", { dangerouslySetInnerHTML: { __html: oldHtml } });
|
|
1429
|
-
}
|
|
1430
|
-
else if (typing) {
|
|
1431
|
-
contentNode = (jsx(TypingReveal, { html: highlightedHtml, durationMs: typingDuration, revealSteps: revealSteps, onComplete: handleTypingComplete }));
|
|
1432
|
-
}
|
|
1433
|
-
else {
|
|
1434
|
-
contentNode = jsx("span", { dangerouslySetInnerHTML: { __html: highlightedHtml } });
|
|
1435
|
-
}
|
|
1436
|
-
return (jsxs(motion.div, { initial: isNewLine ? { opacity: 0, height: 0 } : false, animate: {
|
|
1437
|
-
opacity: 1,
|
|
1438
|
-
height: 'auto',
|
|
1439
|
-
backgroundColor: bgColor,
|
|
1440
|
-
transition: {
|
|
1441
|
-
duration: 0.3,
|
|
1442
|
-
ease: [0.16, 1, 0.3, 1],
|
|
1443
|
-
backgroundColor: { duration: 0.4 },
|
|
1444
|
-
},
|
|
1445
|
-
}, exit: {
|
|
1446
|
-
backgroundColor: 'rgba(59, 130, 246, 0.18)',
|
|
1447
|
-
height: 0,
|
|
1448
|
-
opacity: 0,
|
|
1449
|
-
transition: {
|
|
1450
|
-
backgroundColor: { duration: 0 },
|
|
1451
|
-
height: { duration: 0, delay: 0.3 },
|
|
1452
|
-
opacity: { duration: 0, delay: 0.3 },
|
|
1453
|
-
},
|
|
1454
|
-
}, style: {
|
|
1455
|
-
display: 'flex',
|
|
1456
|
-
lineHeight: 1.6,
|
|
1457
|
-
fontSize: 'inherit',
|
|
1458
|
-
overflow: 'hidden',
|
|
1459
|
-
}, children: [showLineNumbers && (jsx("span", { style: {
|
|
1460
|
-
flexShrink: 0,
|
|
1461
|
-
textAlign: 'right',
|
|
1462
|
-
paddingRight: '16px',
|
|
1463
|
-
paddingLeft: '8px',
|
|
1464
|
-
width: '3.5em',
|
|
1465
|
-
color: '#9ca3af',
|
|
1466
|
-
userSelect: 'none',
|
|
1467
|
-
}, children: lineNumber })), jsx("span", { style: { flex: 1, paddingRight: '16px', whiteSpace: 'pre', tabSize: 4 }, children: contentNode })] }));
|
|
1468
|
-
}
|
|
1469
|
-
// ==================== BaseCodeElement ====================
|
|
1470
|
-
function BaseCodeElement({ elementInfo, animate }) {
|
|
1471
|
-
const { language, lines, fileName, showLineNumbers = true, fontSize = 14 } = elementInfo;
|
|
1472
|
-
const wrapperRef = useRef(null);
|
|
1473
|
-
const codeBodyRef = useRef(null);
|
|
1474
|
-
useEffect(() => {
|
|
1475
|
-
const el = codeBodyRef.current;
|
|
1476
|
-
if (!el)
|
|
1477
|
-
return;
|
|
1478
|
-
let dragging = false;
|
|
1479
|
-
let startX = 0;
|
|
1480
|
-
let startY = 0;
|
|
1481
|
-
let startScrollLeft = 0;
|
|
1482
|
-
let startScrollTop = 0;
|
|
1483
|
-
let activePointer = null;
|
|
1484
|
-
const endDrag = () => {
|
|
1485
|
-
if (activePointer !== null && el.hasPointerCapture(activePointer)) {
|
|
1486
|
-
el.releasePointerCapture(activePointer);
|
|
1487
|
-
}
|
|
1488
|
-
dragging = false;
|
|
1489
|
-
activePointer = null;
|
|
1490
|
-
el.style.cursor = 'grab';
|
|
1491
|
-
};
|
|
1492
|
-
const onPointerDown = (e) => {
|
|
1493
|
-
if (e.button !== 0)
|
|
1494
|
-
return;
|
|
1495
|
-
dragging = true;
|
|
1496
|
-
activePointer = e.pointerId;
|
|
1497
|
-
startX = e.clientX;
|
|
1498
|
-
startY = e.clientY;
|
|
1499
|
-
startScrollLeft = el.scrollLeft;
|
|
1500
|
-
startScrollTop = el.scrollTop;
|
|
1501
|
-
el.setPointerCapture(e.pointerId);
|
|
1502
|
-
el.style.cursor = 'grabbing';
|
|
1503
|
-
};
|
|
1504
|
-
const onPointerMove = (e) => {
|
|
1505
|
-
if (!dragging || e.pointerId !== activePointer)
|
|
1506
|
-
return;
|
|
1507
|
-
el.scrollLeft = startScrollLeft - (e.clientX - startX);
|
|
1508
|
-
el.scrollTop = startScrollTop - (e.clientY - startY);
|
|
1509
|
-
};
|
|
1510
|
-
const onPointerEnd = (e) => {
|
|
1511
|
-
if (e.pointerId !== activePointer)
|
|
1512
|
-
return;
|
|
1513
|
-
endDrag();
|
|
1514
|
-
};
|
|
1515
|
-
const onLostCapture = () => {
|
|
1516
|
-
endDrag();
|
|
1517
|
-
};
|
|
1518
|
-
const onWheel = (e) => {
|
|
1519
|
-
e.stopPropagation();
|
|
1520
|
-
};
|
|
1521
|
-
el.style.cursor = 'grab';
|
|
1522
|
-
el.addEventListener('pointerdown', onPointerDown);
|
|
1523
|
-
el.addEventListener('pointermove', onPointerMove);
|
|
1524
|
-
el.addEventListener('pointerup', onPointerEnd);
|
|
1525
|
-
el.addEventListener('pointercancel', onPointerEnd);
|
|
1526
|
-
el.addEventListener('lostpointercapture', onLostCapture);
|
|
1527
|
-
el.addEventListener('wheel', onWheel, { passive: true });
|
|
1528
|
-
return () => {
|
|
1529
|
-
endDrag();
|
|
1530
|
-
el.removeEventListener('pointerdown', onPointerDown);
|
|
1531
|
-
el.removeEventListener('pointermove', onPointerMove);
|
|
1532
|
-
el.removeEventListener('pointerup', onPointerEnd);
|
|
1533
|
-
el.removeEventListener('pointercancel', onPointerEnd);
|
|
1534
|
-
el.removeEventListener('lostpointercapture', onLostCapture);
|
|
1535
|
-
el.removeEventListener('wheel', onWheel);
|
|
1536
|
-
};
|
|
1537
|
-
}, []);
|
|
1538
|
-
useEffect(() => {
|
|
1539
|
-
const el = wrapperRef.current;
|
|
1540
|
-
if (!el)
|
|
1541
|
-
return;
|
|
1542
|
-
const stopWheelOutsideBody = (e) => {
|
|
1543
|
-
const body = codeBodyRef.current;
|
|
1544
|
-
if (body && body.contains(e.target))
|
|
1545
|
-
return;
|
|
1546
|
-
e.stopPropagation();
|
|
1547
|
-
};
|
|
1548
|
-
el.addEventListener('wheel', stopWheelOutsideBody);
|
|
1549
|
-
return () => el.removeEventListener('wheel', stopWheelOutsideBody);
|
|
1550
|
-
}, []);
|
|
1551
|
-
const stopPointer = useCallback((e) => {
|
|
1552
|
-
e.stopPropagation();
|
|
1553
|
-
}, []);
|
|
1554
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1555
|
-
const [highlighter, setHighlighter] = useState(null);
|
|
1556
|
-
const prevLinesRef = useRef([]);
|
|
1557
|
-
const isFirstRenderRef = useRef(true);
|
|
1558
|
-
const [animStates, setAnimStates] = useState(() => new Map());
|
|
1559
|
-
useEffect(() => {
|
|
1560
|
-
const states = new Map();
|
|
1561
|
-
if (animate) {
|
|
1562
|
-
if (isFirstRenderRef.current) {
|
|
1563
|
-
isFirstRenderRef.current = false;
|
|
1564
|
-
lines.forEach((line, i) => {
|
|
1565
|
-
states.set(line.id, { type: 'typing', timestamp: i * 80 });
|
|
1566
|
-
});
|
|
1567
|
-
}
|
|
1568
|
-
else {
|
|
1569
|
-
const prevIds = new Set(prevLinesRef.current.map((l) => l.id));
|
|
1570
|
-
for (const line of lines) {
|
|
1571
|
-
if (!prevIds.has(line.id)) {
|
|
1572
|
-
states.set(line.id, { type: 'inserted', timestamp: 0 });
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
for (const line of lines) {
|
|
1576
|
-
const prev = prevLinesRef.current.find((p) => p.id === line.id);
|
|
1577
|
-
if (prev && prev.content !== line.content) {
|
|
1578
|
-
states.set(line.id, { type: 'replaced', timestamp: 0 });
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
prevLinesRef.current = lines;
|
|
1583
|
-
}
|
|
1584
|
-
const t = setTimeout(() => setAnimStates(states), 0);
|
|
1585
|
-
return () => clearTimeout(t);
|
|
1586
|
-
}, [lines, animate]);
|
|
1587
|
-
useEffect(() => {
|
|
1588
|
-
getHighlighter().then(setHighlighter);
|
|
1589
|
-
}, []);
|
|
1590
|
-
const highlightedLines = useMemo(() => {
|
|
1591
|
-
if (!highlighter)
|
|
1592
|
-
return null;
|
|
1593
|
-
const code = lines.map((l) => l.content).join('\n');
|
|
1594
|
-
let lang = language;
|
|
1595
|
-
try {
|
|
1596
|
-
highlighter.getLoadedLanguages();
|
|
1597
|
-
}
|
|
1598
|
-
catch {
|
|
1599
|
-
lang = 'text';
|
|
1600
|
-
}
|
|
1601
|
-
try {
|
|
1602
|
-
const html = highlighter.codeToHtml(code, { lang, theme: 'github-light' });
|
|
1603
|
-
const parsed = parseShikiLines(html);
|
|
1604
|
-
return lines.map((line, i) => ({
|
|
1605
|
-
id: line.id,
|
|
1606
|
-
html: parsed[i] || escapeHtml(line.content),
|
|
1607
|
-
}));
|
|
1608
|
-
}
|
|
1609
|
-
catch {
|
|
1610
|
-
return lines.map((line) => ({
|
|
1611
|
-
id: line.id,
|
|
1612
|
-
html: escapeHtml(line.content),
|
|
1613
|
-
}));
|
|
1614
|
-
}
|
|
1615
|
-
}, [highlighter, lines, language]);
|
|
1616
|
-
const fallbackLines = useMemo(() => {
|
|
1617
|
-
return lines.map((line) => ({
|
|
1618
|
-
id: line.id,
|
|
1619
|
-
html: escapeHtml(line.content),
|
|
1620
|
-
}));
|
|
1621
|
-
}, [lines]);
|
|
1622
|
-
const lineHtmlMap = highlightedLines || fallbackLines;
|
|
1623
|
-
const typingDelays = useMemo(() => {
|
|
1624
|
-
const delays = new Map();
|
|
1625
|
-
let cumulative = 0;
|
|
1626
|
-
for (const line of lines) {
|
|
1627
|
-
if (animStates.has(line.id)) {
|
|
1628
|
-
delays.set(line.id, cumulative);
|
|
1629
|
-
cumulative += getTypingDuration(line.content) + LINE_GAP_MS;
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
return delays;
|
|
1633
|
-
}, [lines, animStates]);
|
|
1634
|
-
const langDisplay = LANG_DISPLAY_NAMES[language] || language;
|
|
1635
|
-
return (jsx("div", { ref: wrapperRef, className: "base-element-code", style: {
|
|
1636
|
-
position: 'absolute',
|
|
1637
|
-
top: `${elementInfo.top}px`,
|
|
1638
|
-
left: `${elementInfo.left}px`,
|
|
1639
|
-
width: `${elementInfo.width}px`,
|
|
1640
|
-
height: `${elementInfo.height}px`,
|
|
1641
|
-
}, onPointerDown: stopPointer, onClick: stopPointer, children: jsx("div", { className: "rotate-wrapper", style: {
|
|
1642
|
-
width: '100%',
|
|
1643
|
-
height: '100%',
|
|
1644
|
-
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
1645
|
-
}, children: jsxs("div", { className: "element-content", style: {
|
|
1646
|
-
width: '100%',
|
|
1647
|
-
height: '100%',
|
|
1648
|
-
display: 'flex',
|
|
1649
|
-
flexDirection: 'column',
|
|
1650
|
-
overflow: 'hidden',
|
|
1651
|
-
borderRadius: '8px',
|
|
1652
|
-
border: '1px solid #d1d5db',
|
|
1653
|
-
background: '#fafbfc',
|
|
1654
|
-
boxShadow: '0 2px 6px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05)',
|
|
1655
|
-
fontFamily: '"JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", ui-monospace, SFMono-Regular, "Liberation Mono", Menlo, Monaco, Consolas, monospace',
|
|
1656
|
-
fontSize: `${fontSize}px`,
|
|
1657
|
-
}, children: [jsxs("div", { style: {
|
|
1658
|
-
display: 'flex',
|
|
1659
|
-
alignItems: 'center',
|
|
1660
|
-
justifyContent: 'space-between',
|
|
1661
|
-
flexShrink: 0,
|
|
1662
|
-
paddingLeft: '12px',
|
|
1663
|
-
paddingRight: '12px',
|
|
1664
|
-
height: '32px',
|
|
1665
|
-
background: '#f8f9fa',
|
|
1666
|
-
borderBottom: '1px solid #e5e7eb',
|
|
1667
|
-
}, children: [jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' }, children: [jsxs("div", { style: { display: 'flex', gap: '6px' }, children: [jsx("div", { style: {
|
|
1668
|
-
width: '10px',
|
|
1669
|
-
height: '10px',
|
|
1670
|
-
borderRadius: '9999px',
|
|
1671
|
-
background: '#ff5f57',
|
|
1672
|
-
} }), jsx("div", { style: {
|
|
1673
|
-
width: '10px',
|
|
1674
|
-
height: '10px',
|
|
1675
|
-
borderRadius: '9999px',
|
|
1676
|
-
background: '#febc2e',
|
|
1677
|
-
} }), jsx("div", { style: {
|
|
1678
|
-
width: '10px',
|
|
1679
|
-
height: '10px',
|
|
1680
|
-
borderRadius: '9999px',
|
|
1681
|
-
background: '#28c840',
|
|
1682
|
-
} })] }), fileName && (jsx("span", { style: {
|
|
1683
|
-
marginLeft: '8px',
|
|
1684
|
-
overflow: 'hidden',
|
|
1685
|
-
textOverflow: 'ellipsis',
|
|
1686
|
-
whiteSpace: 'nowrap',
|
|
1687
|
-
color: '#6b7280',
|
|
1688
|
-
fontSize: '11px',
|
|
1689
|
-
letterSpacing: '0.01em',
|
|
1690
|
-
}, children: fileName }))] }), jsx("span", { style: {
|
|
1691
|
-
color: '#9ca3af',
|
|
1692
|
-
fontSize: '10px',
|
|
1693
|
-
textTransform: 'uppercase',
|
|
1694
|
-
letterSpacing: '0.05em',
|
|
1695
|
-
fontWeight: 500,
|
|
1696
|
-
}, children: langDisplay })] }), jsx("div", { ref: codeBodyRef, style: {
|
|
1697
|
-
flex: 1,
|
|
1698
|
-
overflow: 'auto',
|
|
1699
|
-
paddingTop: '8px',
|
|
1700
|
-
paddingBottom: '8px',
|
|
1701
|
-
background: '#fafbfc',
|
|
1702
|
-
color: '#24292e',
|
|
1703
|
-
userSelect: 'none',
|
|
1704
|
-
WebkitUserSelect: 'none',
|
|
1705
|
-
touchAction: 'none',
|
|
1706
|
-
}, children: jsx("div", { style: { minWidth: 'max-content' }, children: jsx(AnimatePresence, { initial: false, mode: "popLayout", children: lineHtmlMap.map((lineData, index) => {
|
|
1707
|
-
const line = lines[index];
|
|
1708
|
-
if (!line)
|
|
1709
|
-
return null;
|
|
1710
|
-
return (jsx(CodeLineRow, { line: line, lineNumber: index + 1, highlightedHtml: lineData.html, showLineNumbers: showLineNumbers, animState: animStates.get(line.id), animate: !!animate, typingDelay: typingDelays.get(line.id) ?? 0 }, line.id));
|
|
1711
|
-
}) }) }) })] }) }) }));
|
|
1712
|
-
}
|
|
1713
|
-
// ==================== Utilities ====================
|
|
1714
|
-
function escapeHtml(text) {
|
|
1715
|
-
return text
|
|
1716
|
-
.replace(/&/g, '&')
|
|
1717
|
-
.replace(/</g, '<')
|
|
1718
|
-
.replace(/>/g, '>')
|
|
1719
|
-
.replace(/"/g, '"');
|
|
1720
|
-
}
|
|
1721
|
-
const LANG_DISPLAY_NAMES = {
|
|
1722
|
-
python: 'Python',
|
|
1723
|
-
javascript: 'JavaScript',
|
|
1724
|
-
typescript: 'TypeScript',
|
|
1725
|
-
json: 'JSON',
|
|
1726
|
-
go: 'Go',
|
|
1727
|
-
rust: 'Rust',
|
|
1728
|
-
java: 'Java',
|
|
1729
|
-
c: 'C',
|
|
1730
|
-
cpp: 'C++',
|
|
1731
|
-
html: 'HTML',
|
|
1732
|
-
css: 'CSS',
|
|
1733
|
-
bash: 'Bash',
|
|
1734
|
-
sql: 'SQL',
|
|
1735
|
-
yaml: 'YAML',
|
|
1736
|
-
markdown: 'Markdown',
|
|
1737
|
-
jsx: 'JSX',
|
|
1738
|
-
tsx: 'TSX',
|
|
1739
|
-
};
|
|
1740
|
-
|
|
1741
|
-
export { BaseChartElement as B, ElementOutline as E, BaseCodeElement as a, BaseImageElement as b, BaseLatexElement as c, BaseLineElement as d, BaseShapeElement as e, BaseTableElement as f, BaseTextElement as g, BaseVideoElement as h, useElementFlip as i, useElementOutline as j, useElementShadow as k, useElementFill as u };
|
|
1742
|
-
//# sourceMappingURL=BaseCodeElement-Bh-Bfdz6.js.map
|