@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.
Files changed (175) hide show
  1. package/DESIGN.md +7 -1
  2. package/README.md +11 -3
  3. package/dist/SlideCanvas.d.ts +12 -1
  4. package/dist/SlideCanvas.js +105 -0
  5. package/dist/SlideCanvas.js.map +1 -0
  6. package/dist/SlideElement.d.ts +3 -2
  7. package/dist/SlideElement.js +60 -0
  8. package/dist/SlideElement.js.map +1 -0
  9. package/dist/context.d.ts +2 -1
  10. package/dist/context.js +27 -0
  11. package/dist/context.js.map +1 -0
  12. package/dist/editing/EditableSlideCanvas.d.ts +26 -0
  13. package/dist/editing/EditableSlideCanvas.js +352 -0
  14. package/dist/editing/EditableSlideCanvas.js.map +1 -0
  15. package/dist/editing/core/drag.d.ts +108 -0
  16. package/dist/editing/core/drag.js +119 -0
  17. package/dist/editing/core/drag.js.map +1 -0
  18. package/dist/editing/core/geometry.d.ts +48 -0
  19. package/dist/editing/core/geometry.js +186 -0
  20. package/dist/editing/core/geometry.js.map +1 -0
  21. package/dist/editing/core/intent.d.ts +39 -0
  22. package/dist/editing/core/intent.js +35 -0
  23. package/dist/editing/core/intent.js.map +1 -0
  24. package/dist/editing/core/line-drag.d.ts +19 -0
  25. package/dist/editing/core/line-drag.js +163 -0
  26. package/dist/editing/core/line-drag.js.map +1 -0
  27. package/dist/editing/core/marquee.d.ts +56 -0
  28. package/dist/editing/core/marquee.js +74 -0
  29. package/dist/editing/core/marquee.js.map +1 -0
  30. package/dist/editing/core/resize.d.ts +121 -0
  31. package/dist/editing/core/resize.js +392 -0
  32. package/dist/editing/core/resize.js.map +1 -0
  33. package/dist/editing/core/rotate.d.ts +37 -0
  34. package/dist/editing/core/rotate.js +74 -0
  35. package/dist/editing/core/rotate.js.map +1 -0
  36. package/dist/editing/core/selection.d.ts +68 -0
  37. package/dist/editing/core/selection.js +108 -0
  38. package/dist/editing/core/selection.js.map +1 -0
  39. package/dist/editing/core/snapping.d.ts +54 -0
  40. package/dist/editing/core/snapping.js +96 -0
  41. package/dist/editing/core/snapping.js.map +1 -0
  42. package/dist/editing/handles/BorderLine.d.ts +15 -0
  43. package/dist/editing/handles/BorderLine.js +17 -0
  44. package/dist/editing/handles/BorderLine.js.map +1 -0
  45. package/dist/editing/handles/LineHandles.d.ts +28 -0
  46. package/dist/editing/handles/LineHandles.js +51 -0
  47. package/dist/editing/handles/LineHandles.js.map +1 -0
  48. package/dist/editing/handles/MarqueeBox.d.ts +19 -0
  49. package/dist/editing/handles/MarqueeBox.js +26 -0
  50. package/dist/editing/handles/MarqueeBox.js.map +1 -0
  51. package/dist/editing/handles/ResizeHandles.d.ts +31 -0
  52. package/dist/editing/handles/ResizeHandles.js +44 -0
  53. package/dist/editing/handles/ResizeHandles.js.map +1 -0
  54. package/dist/editing/handles/RotateHandle.d.ts +26 -0
  55. package/dist/editing/handles/RotateHandle.js +52 -0
  56. package/dist/editing/handles/RotateHandle.js.map +1 -0
  57. package/dist/editing/handles/SelectionOverlay.d.ts +18 -0
  58. package/dist/editing/handles/SelectionOverlay.js +35 -0
  59. package/dist/editing/handles/SelectionOverlay.js.map +1 -0
  60. package/dist/editing/index.d.ts +3 -0
  61. package/dist/editing/index.js +4 -0
  62. package/dist/editing/index.js.map +1 -0
  63. package/dist/editing/types.d.ts +107 -0
  64. package/dist/editing/types.js +7 -0
  65. package/dist/editing/types.js.map +1 -0
  66. package/dist/editing/useEditGesture.d.ts +46 -0
  67. package/dist/editing/useEditGesture.js +217 -0
  68. package/dist/editing/useEditGesture.js.map +1 -0
  69. package/dist/editing/useLineHandleGesture.d.ts +35 -0
  70. package/dist/editing/useLineHandleGesture.js +112 -0
  71. package/dist/editing/useLineHandleGesture.js.map +1 -0
  72. package/dist/editing/useMarqueeGesture.d.ts +43 -0
  73. package/dist/editing/useMarqueeGesture.js +157 -0
  74. package/dist/editing/useMarqueeGesture.js.map +1 -0
  75. package/dist/editing/useResizeGesture.d.ts +43 -0
  76. package/dist/editing/useResizeGesture.js +137 -0
  77. package/dist/editing/useResizeGesture.js.map +1 -0
  78. package/dist/editing/useRotateGesture.d.ts +47 -0
  79. package/dist/editing/useRotateGesture.js +128 -0
  80. package/dist/editing/useRotateGesture.js.map +1 -0
  81. package/dist/effects/HighlightOverlay.js +44 -0
  82. package/dist/effects/HighlightOverlay.js.map +1 -0
  83. package/dist/effects/LaserOverlay.js +40 -0
  84. package/dist/effects/LaserOverlay.js.map +1 -0
  85. package/dist/effects/SpotlightOverlay.d.ts +3 -1
  86. package/dist/effects/SpotlightOverlay.js +99 -0
  87. package/dist/effects/SpotlightOverlay.js.map +1 -0
  88. package/dist/effects/ZoomWrapper.js +19 -0
  89. package/dist/effects/ZoomWrapper.js.map +1 -0
  90. package/dist/elements/chart/BaseChartElement.js +22 -0
  91. package/dist/elements/chart/BaseChartElement.js.map +1 -0
  92. package/dist/elements/chart/Chart.js +83 -0
  93. package/dist/elements/chart/Chart.js.map +1 -0
  94. package/dist/elements/chart/chartOption.js +178 -0
  95. package/dist/elements/chart/chartOption.js.map +1 -0
  96. package/dist/elements/code/BaseCodeElement.js +525 -0
  97. package/dist/elements/code/BaseCodeElement.js.map +1 -0
  98. package/dist/elements/image/BaseImageElement.d.ts +4 -4
  99. package/dist/elements/image/BaseImageElement.js +76 -0
  100. package/dist/elements/image/BaseImageElement.js.map +1 -0
  101. package/dist/elements/image/ImageOutline.js +30 -0
  102. package/dist/elements/image/ImageOutline.js.map +1 -0
  103. package/dist/elements/image/clipPaths.js +130 -0
  104. package/dist/elements/image/clipPaths.js.map +1 -0
  105. package/dist/elements/image/useClipImage.js +40 -0
  106. package/dist/elements/image/useClipImage.js.map +1 -0
  107. package/dist/elements/image/useFilter.d.ts +1 -0
  108. package/dist/elements/image/useFilter.js +35 -0
  109. package/dist/elements/image/useFilter.js.map +1 -0
  110. package/dist/elements/index.js +14 -9
  111. package/dist/elements/index.js.map +1 -1
  112. package/dist/elements/latex/BaseLatexElement.js +94 -0
  113. package/dist/elements/latex/BaseLatexElement.js.map +1 -0
  114. package/dist/elements/line/BaseLineElement.js +72 -0
  115. package/dist/elements/line/BaseLineElement.js.map +1 -0
  116. package/dist/elements/line/LinePointMarker.js +19 -0
  117. package/dist/elements/line/LinePointMarker.js.map +1 -0
  118. package/dist/elements/shape/BaseShapeElement.js +174 -0
  119. package/dist/elements/shape/BaseShapeElement.js.map +1 -0
  120. package/dist/elements/shape/GradientDefs.js +11 -0
  121. package/dist/elements/shape/GradientDefs.js.map +1 -0
  122. package/dist/elements/shape/PatternDefs.js +8 -0
  123. package/dist/elements/shape/PatternDefs.js.map +1 -0
  124. package/dist/elements/shared/ElementOutline.js +13 -0
  125. package/dist/elements/shared/ElementOutline.js.map +1 -0
  126. package/dist/elements/shared/useElementFill.js +15 -0
  127. package/dist/elements/shared/useElementFill.js.map +1 -0
  128. package/dist/elements/shared/useElementFlip.js +18 -0
  129. package/dist/elements/shared/useElementFlip.js.map +1 -0
  130. package/dist/elements/shared/useElementOutline.js +19 -0
  131. package/dist/elements/shared/useElementOutline.js.map +1 -0
  132. package/dist/elements/shared/useElementShadow.js +15 -0
  133. package/dist/elements/shared/useElementShadow.js.map +1 -0
  134. package/dist/elements/table/BaseTableElement.js +21 -0
  135. package/dist/elements/table/BaseTableElement.js.map +1 -0
  136. package/dist/elements/table/StaticTable.js +117 -0
  137. package/dist/elements/table/StaticTable.js.map +1 -0
  138. package/dist/elements/table/tableUtils.js +28 -0
  139. package/dist/elements/table/tableUtils.js.map +1 -0
  140. package/dist/elements/text/BaseTextElement.js +46 -0
  141. package/dist/elements/text/BaseTextElement.js.map +1 -0
  142. package/dist/elements/video/BaseVideoElement.d.ts +3 -1
  143. package/dist/elements/video/BaseVideoElement.js +36 -0
  144. package/dist/elements/video/BaseVideoElement.js.map +1 -0
  145. package/dist/hooks/useSlideBackgroundStyle.js +43 -0
  146. package/dist/hooks/useSlideBackgroundStyle.js.map +1 -0
  147. package/dist/hooks/useViewportSize.d.ts +2 -0
  148. package/dist/hooks/useViewportSize.js +71 -0
  149. package/dist/hooks/useViewportSize.js.map +1 -0
  150. package/dist/index.js +11 -31
  151. package/dist/index.js.map +1 -1
  152. package/dist/snapshot/index.d.ts +1 -0
  153. package/dist/snapshot/index.js +93 -28
  154. package/dist/snapshot/index.js.map +1 -1
  155. package/dist/snapshot/katex-fonts-embed.d.ts +10 -0
  156. package/dist/snapshot/katex-fonts-embed.js +13 -0
  157. package/dist/snapshot/katex-fonts-embed.js.map +1 -0
  158. package/dist/snapshot/measure.d.ts +32 -0
  159. package/dist/snapshot/measure.js +129 -0
  160. package/dist/snapshot/measure.js.map +1 -0
  161. package/dist/styles.js +50 -0
  162. package/dist/styles.js.map +1 -0
  163. package/dist/types/effects.d.ts +2 -0
  164. package/dist/utils/cn.js +9 -0
  165. package/dist/utils/cn.js.map +1 -0
  166. package/dist/utils/element.js +85 -0
  167. package/dist/utils/element.js.map +1 -0
  168. package/dist/utils/geometry.d.ts +2 -2
  169. package/dist/utils/geometry.js +44 -0
  170. package/dist/utils/geometry.js.map +1 -0
  171. package/package.json +19 -4
  172. package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js +0 -1742
  173. package/dist/chunks/BaseCodeElement-Bh-Bfdz6.js.map +0 -1
  174. package/dist/chunks/SlideCanvas-BwlcjqMl.js +0 -469
  175. package/dist/chunks/SlideCanvas-BwlcjqMl.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseImageElement.js","sources":["../../../src/elements/image/BaseImageElement.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode } from 'react';\nimport type { PPTImageElement } from '@openmaic/dsl';\nimport { useElementShadow } from '../shared/useElementShadow';\nimport { useElementFlip } from '../shared/useElementFlip';\nimport { useClipImage } from './useClipImage';\nimport { useFilter } from './useFilter';\nimport { ImageOutline } from './ImageOutline';\n\nexport interface BaseImageElementProps {\n elementInfo: PPTImageElement;\n /**\n * Optional render slot: replace the default <img> with custom content.\n * The slot receives `(element, resolvedSrc, defaultContent)` and is responsible\n * for selecting placeholders, retry UI, or the renderer's prepared image.\n * Its return value is authoritative, including `null`.\n */\n renderImage?: (\n element: PPTImageElement,\n resolvedSrc: string,\n defaultContent: ReactNode,\n ) => ReactNode;\n}\n\nexport function BaseImageElement({ elementInfo, renderImage }: BaseImageElementProps) {\n const { shadowStyle } = useElementShadow(elementInfo.shadow);\n const { flipStyle } = useElementFlip(elementInfo.flipH, elementInfo.flipV);\n const { clipShape, imgPosition } = useClipImage(elementInfo);\n const { filter } = useFilter(elementInfo.filters);\n\n const src = elementInfo.src;\n\n // Soft-edge feather (a:softEdge): fade the image alpha to transparent over\n // `softEdge` px at every edge. Two intersecting linear-gradient masks feather\n // all four sides (corners get both). html2canvas-pro ignores CSS masks, so\n // slideToPng bakes the same feather into pixels via the data-soft-edge hook.\n const softEdge =\n elementInfo.softEdge && elementInfo.softEdge > 0 ? elementInfo.softEdge : undefined;\n const softEdgeMaskStyle: CSSProperties = softEdge\n ? (() => {\n const grad = (dir: string) =>\n `linear-gradient(${dir}, transparent 0, #000 ${softEdge}px, #000 calc(100% - ${softEdge}px), transparent 100%)`;\n const mask = `${grad('to right')}, ${grad('to bottom')}`;\n return {\n maskImage: mask,\n WebkitMaskImage: mask,\n maskComposite: 'intersect',\n WebkitMaskComposite: 'source-in',\n maskRepeat: 'no-repeat',\n WebkitMaskRepeat: 'no-repeat',\n } as CSSProperties;\n })()\n : {};\n const defaultContent = src ? (\n <>\n <img\n src={src}\n draggable={false}\n data-soft-edge={softEdge || undefined}\n style={{\n position: 'absolute',\n top: imgPosition.top,\n left: imgPosition.left,\n width: imgPosition.width,\n height: imgPosition.height,\n maxWidth: 'none',\n maxHeight: 'none',\n filter,\n ...softEdgeMaskStyle,\n }}\n alt=\"\"\n onDragStart={(e) => e.preventDefault()}\n />\n {elementInfo.colorMask && (\n <div\n style={{\n position: 'absolute',\n inset: 0,\n backgroundColor: elementInfo.colorMask,\n }}\n />\n )}\n </>\n ) : null;\n\n return (\n <div\n className=\"element-content\"\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 style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n }}\n >\n <div\n style={{\n position: 'relative',\n width: '100%',\n height: '100%',\n filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',\n transform: flipStyle,\n }}\n >\n <ImageOutline elementInfo={elementInfo} />\n\n <div\n style={{\n position: 'relative',\n width: '100%',\n height: '100%',\n overflow: 'hidden',\n clipPath: clipShape.style,\n pointerEvents: renderImage ? 'auto' : undefined,\n }}\n >\n {renderImage ? renderImage(elementInfo, src, defaultContent) : defaultContent}\n </div>\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AA2BE;;;AAIA;;;;;;;;AAUM;AAEA;;AAEE;AACA;AACA;AACA;AACA;AACA;;AAEJ;;;AASI;;;;;AAKA;AACA;;AAEA;;AAQE;AACA;;AAED;AAMT;AAIM;AACA;AACA;AACA;AACA;;AAKE;AACA;AACA;;AAKE;AACA;AACA;;AAEA;;AAOE;AACA;AACA;AACA;;;;AAWd;;"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useElementOutline } from '../shared/useElementOutline.js';
4
+ import { useClipImage } from './useClipImage.js';
5
+
6
+ function ImageRectOutline({ width, height, outline, radius = '0' }) {
7
+ const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);
8
+ if (!outline)
9
+ return null;
10
+ 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 }) }));
11
+ }
12
+ function ImageEllipseOutline({ width, height, outline }) {
13
+ const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);
14
+ if (!outline)
15
+ return null;
16
+ 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 }) }));
17
+ }
18
+ function ImagePolygonOutline({ width, height, createPath, outline }) {
19
+ const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);
20
+ if (!outline)
21
+ return null;
22
+ 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 }) }));
23
+ }
24
+ function ImageOutline({ elementInfo }) {
25
+ const { clipShape } = useClipImage(elementInfo);
26
+ 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 }))] }));
27
+ }
28
+
29
+ export { ImageOutline };
30
+ //# sourceMappingURL=ImageOutline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageOutline.js","sources":["../../../src/elements/image/ImageOutline.tsx"],"sourcesContent":["'use client';\n\nimport type { PPTElementOutline, PPTImageElement } from '@openmaic/dsl';\nimport { useElementOutline } from '../shared/useElementOutline';\nimport { useClipImage } from './useClipImage';\n\nexport interface ImageOutlineProps {\n elementInfo: PPTImageElement;\n}\n\ninterface ImageRectOutlineProps {\n width: number;\n height: number;\n outline?: PPTElementOutline;\n radius?: string;\n}\n\nfunction ImageRectOutline({ width, height, outline, radius = '0' }: ImageRectOutlineProps) {\n const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);\n if (!outline) return null;\n return (\n <svg\n style={{ position: 'absolute', top: 0, left: 0, zIndex: 2, overflow: 'visible' }}\n width={width}\n height={height}\n >\n <rect\n vectorEffect=\"non-scaling-stroke\"\n strokeLinecap=\"butt\"\n strokeMiterlimit=\"8\"\n fill=\"transparent\"\n rx={radius}\n ry={radius}\n width={width}\n height={height}\n stroke={outlineColor}\n strokeWidth={outlineWidth}\n strokeDasharray={strokeDashArray}\n />\n </svg>\n );\n}\n\ninterface ImageEllipseOutlineProps {\n width: number;\n height: number;\n outline?: PPTElementOutline;\n}\n\nfunction ImageEllipseOutline({ width, height, outline }: ImageEllipseOutlineProps) {\n const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);\n if (!outline) return null;\n return (\n <svg\n style={{ position: 'absolute', top: 0, left: 0, zIndex: 2, overflow: 'visible' }}\n width={width}\n height={height}\n >\n <ellipse\n vectorEffect=\"non-scaling-stroke\"\n strokeLinecap=\"butt\"\n strokeMiterlimit=\"8\"\n fill=\"transparent\"\n cx={width / 2}\n cy={height / 2}\n rx={width / 2}\n ry={height / 2}\n stroke={outlineColor}\n strokeWidth={outlineWidth}\n strokeDasharray={strokeDashArray}\n />\n </svg>\n );\n}\n\ninterface ImagePolygonOutlineProps {\n width: number;\n height: number;\n createPath: (width: number, height: number) => string;\n outline?: PPTElementOutline;\n}\n\nfunction ImagePolygonOutline({ width, height, createPath, outline }: ImagePolygonOutlineProps) {\n const { outlineWidth, outlineColor, strokeDashArray } = useElementOutline(outline);\n if (!outline) return null;\n return (\n <svg\n style={{ position: 'absolute', top: 0, left: 0, zIndex: 2, 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={createPath(width, height)}\n stroke={outlineColor}\n strokeWidth={outlineWidth}\n strokeDasharray={strokeDashArray}\n />\n </svg>\n );\n}\n\nexport function ImageOutline({ elementInfo }: ImageOutlineProps) {\n const { clipShape } = useClipImage(elementInfo);\n\n return (\n <div className=\"image-outline\">\n {clipShape.type === 'rect' && (\n <ImageRectOutline\n width={elementInfo.width}\n height={elementInfo.height}\n radius={clipShape.radius}\n outline={elementInfo.outline}\n />\n )}\n {clipShape.type === 'ellipse' && (\n <ImageEllipseOutline\n width={elementInfo.width}\n height={elementInfo.height}\n outline={elementInfo.outline}\n />\n )}\n {clipShape.type === 'polygon' && clipShape.createPath && (\n <ImagePolygonOutline\n width={elementInfo.width}\n height={elementInfo.height}\n outline={elementInfo.outline}\n createPath={clipShape.createPath}\n />\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AAiBA;AACE;AACA;AAAc;AACd;AAqBF;AAQA;AACE;AACA;AAAc;AACd;AAqBF;AASA;AACE;AACA;AAAc;AACd;AAkBF;AAEM;;;AA8BN;;"}
@@ -0,0 +1,130 @@
1
+ var ClipPathTypes;
2
+ (function (ClipPathTypes) {
3
+ ClipPathTypes["RECT"] = "rect";
4
+ ClipPathTypes["ELLIPSE"] = "ellipse";
5
+ ClipPathTypes["POLYGON"] = "polygon";
6
+ })(ClipPathTypes || (ClipPathTypes = {}));
7
+ const CLIPPATHS = {
8
+ rect: {
9
+ name: '矩形',
10
+ type: ClipPathTypes.RECT,
11
+ radius: '0',
12
+ style: '',
13
+ },
14
+ rect2: {
15
+ name: '矩形2',
16
+ type: ClipPathTypes.POLYGON,
17
+ style: 'polygon(0% 0%, 80% 0%, 100% 20%, 100% 100%, 0 100%)',
18
+ createPath: (width, height) => `M 0 0 L ${width * 0.8} 0 L ${width} ${height * 0.2} L ${width} ${height} L 0 ${height} Z`,
19
+ },
20
+ rect3: {
21
+ name: '矩形3',
22
+ type: ClipPathTypes.POLYGON,
23
+ style: 'polygon(0% 0%, 80% 0%, 100% 20%, 100% 100%, 20% 100%, 0% 80%)',
24
+ 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`,
25
+ },
26
+ roundRect: {
27
+ name: '圆角矩形',
28
+ type: ClipPathTypes.RECT,
29
+ radius: '10px',
30
+ style: 'inset(0 round 10px)',
31
+ },
32
+ ellipse: {
33
+ name: '圆形',
34
+ type: ClipPathTypes.ELLIPSE,
35
+ style: 'ellipse(50% 50% at 50% 50%)',
36
+ },
37
+ triangle: {
38
+ name: '三角形',
39
+ type: ClipPathTypes.POLYGON,
40
+ style: 'polygon(50% 0%, 0% 100%, 100% 100%)',
41
+ createPath: (width, height) => `M ${width * 0.5} 0 L 0 ${height} L ${width} ${height} Z`,
42
+ },
43
+ triangle2: {
44
+ name: '三角形2',
45
+ type: ClipPathTypes.POLYGON,
46
+ style: 'polygon(50% 100%, 0% 0%, 100% 0%)',
47
+ createPath: (width, height) => `M ${width * 0.5} ${height} L 0 0 L ${width} 0 Z`,
48
+ },
49
+ triangle3: {
50
+ name: '三角形3',
51
+ type: ClipPathTypes.POLYGON,
52
+ style: 'polygon(0% 0%, 0% 100%, 100% 100%)',
53
+ createPath: (width, height) => `M 0 0 L 0 ${height} L ${width} ${height} Z`,
54
+ },
55
+ rhombus: {
56
+ name: '菱形',
57
+ type: ClipPathTypes.POLYGON,
58
+ style: 'polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)',
59
+ createPath: (width, height) => `M ${width * 0.5} 0 L ${width} ${height * 0.5} L ${width * 0.5} ${height} L 0 ${height * 0.5} Z`,
60
+ },
61
+ pentagon: {
62
+ name: '五边形',
63
+ type: ClipPathTypes.POLYGON,
64
+ style: 'polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)',
65
+ 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`,
66
+ },
67
+ hexagon: {
68
+ name: '六边形',
69
+ type: ClipPathTypes.POLYGON,
70
+ style: 'polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%)',
71
+ 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`,
72
+ },
73
+ heptagon: {
74
+ name: '七边形',
75
+ type: ClipPathTypes.POLYGON,
76
+ style: 'polygon(50% 0%, 90% 20%, 100% 60%, 75% 100%, 25% 100%, 0% 60%, 10% 20%)',
77
+ 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`,
78
+ },
79
+ octagon: {
80
+ name: '八边形',
81
+ type: ClipPathTypes.POLYGON,
82
+ style: 'polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)',
83
+ 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`,
84
+ },
85
+ chevron: {
86
+ name: 'V形',
87
+ type: ClipPathTypes.POLYGON,
88
+ style: 'polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 25% 50%, 0% 0%)',
89
+ 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`,
90
+ },
91
+ point: {
92
+ name: '点',
93
+ type: ClipPathTypes.POLYGON,
94
+ style: 'polygon(0% 0%, 75% 0%, 100% 50%, 75% 100%, 0% 100%)',
95
+ 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`,
96
+ },
97
+ arrow: {
98
+ name: '箭头',
99
+ type: ClipPathTypes.POLYGON,
100
+ style: 'polygon(0% 20%, 60% 20%, 60% 0%, 100% 50%, 60% 100%, 60% 80%, 0% 80%)',
101
+ 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`,
102
+ },
103
+ parallelogram: {
104
+ name: '平行四边形',
105
+ type: ClipPathTypes.POLYGON,
106
+ style: 'polygon(30% 0%, 100% 0%, 70% 100%, 0% 100%)',
107
+ createPath: (width, height) => `M ${width * 0.3} 0 L ${width} 0 L ${width * 0.7} ${height} L 0 ${height} Z`,
108
+ },
109
+ parallelogram2: {
110
+ name: '平行四边形2',
111
+ type: ClipPathTypes.POLYGON,
112
+ style: 'polygon(30% 100%, 100% 100%, 70% 0%, 0% 0%)',
113
+ createPath: (width, height) => `M ${width * 0.3} ${height} L ${width} ${height} L ${width * 0.7} 0 L 0 0 Z`,
114
+ },
115
+ trapezoid: {
116
+ name: '梯形',
117
+ type: ClipPathTypes.POLYGON,
118
+ style: 'polygon(25% 0%, 75% 0%, 100% 100%, 0% 100%)',
119
+ createPath: (width, height) => `M ${width * 0.25} 0 L ${width * 0.75} 0 L ${width} ${height} L 0 ${height} Z`,
120
+ },
121
+ trapezoid2: {
122
+ name: '梯形2',
123
+ type: ClipPathTypes.POLYGON,
124
+ style: 'polygon(0% 0%, 100% 0%, 75% 100%, 25% 100%)',
125
+ createPath: (width, height) => `M 0 0 L ${width} 0 L ${width * 0.75} ${height} L ${width * 0.25} ${height} Z`,
126
+ },
127
+ };
128
+
129
+ export { CLIPPATHS, ClipPathTypes };
130
+ //# sourceMappingURL=clipPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipPaths.js","sources":["../../../src/elements/image/clipPaths.ts"],"sourcesContent":["export const enum ClipPathTypes {\n RECT = 'rect',\n ELLIPSE = 'ellipse',\n POLYGON = 'polygon',\n}\n\nexport interface ClipPathDef {\n name: string;\n type: ClipPathTypes;\n style: string;\n radius?: string;\n createPath?: (width: number, height: number) => string;\n}\n\nexport const CLIPPATHS: Record<string, ClipPathDef> = {\n rect: {\n name: '矩形',\n type: ClipPathTypes.RECT,\n radius: '0',\n style: '',\n },\n rect2: {\n name: '矩形2',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(0% 0%, 80% 0%, 100% 20%, 100% 100%, 0 100%)',\n createPath: (width, height) =>\n `M 0 0 L ${width * 0.8} 0 L ${width} ${height * 0.2} L ${width} ${height} L 0 ${height} Z`,\n },\n rect3: {\n name: '矩形3',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(0% 0%, 80% 0%, 100% 20%, 100% 100%, 20% 100%, 0% 80%)',\n createPath: (width, height) =>\n `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`,\n },\n roundRect: {\n name: '圆角矩形',\n type: ClipPathTypes.RECT,\n radius: '10px',\n style: 'inset(0 round 10px)',\n },\n ellipse: {\n name: '圆形',\n type: ClipPathTypes.ELLIPSE,\n style: 'ellipse(50% 50% at 50% 50%)',\n },\n triangle: {\n name: '三角形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(50% 0%, 0% 100%, 100% 100%)',\n createPath: (width, height) => `M ${width * 0.5} 0 L 0 ${height} L ${width} ${height} Z`,\n },\n triangle2: {\n name: '三角形2',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(50% 100%, 0% 0%, 100% 0%)',\n createPath: (width, height) => `M ${width * 0.5} ${height} L 0 0 L ${width} 0 Z`,\n },\n triangle3: {\n name: '三角形3',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(0% 0%, 0% 100%, 100% 100%)',\n createPath: (width, height) => `M 0 0 L 0 ${height} L ${width} ${height} Z`,\n },\n rhombus: {\n name: '菱形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)',\n createPath: (width, height) =>\n `M ${width * 0.5} 0 L ${width} ${height * 0.5} L ${width * 0.5} ${height} L 0 ${height * 0.5} Z`,\n },\n pentagon: {\n name: '五边形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)',\n createPath: (width, height) =>\n `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`,\n },\n hexagon: {\n name: '六边形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%)',\n createPath: (width, height) =>\n `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`,\n },\n heptagon: {\n name: '七边形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(50% 0%, 90% 20%, 100% 60%, 75% 100%, 25% 100%, 0% 60%, 10% 20%)',\n createPath: (width, height) =>\n `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`,\n },\n octagon: {\n name: '八边形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)',\n createPath: (width, height) =>\n `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`,\n },\n chevron: {\n name: 'V形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 25% 50%, 0% 0%)',\n createPath: (width, height) =>\n `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`,\n },\n point: {\n name: '点',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(0% 0%, 75% 0%, 100% 50%, 75% 100%, 0% 100%)',\n createPath: (width, height) =>\n `M 0 0 L ${width * 0.75} 0 L ${width} ${height * 0.5} L ${width * 0.75} ${height} L 0 ${height} Z`,\n },\n arrow: {\n name: '箭头',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(0% 20%, 60% 20%, 60% 0%, 100% 50%, 60% 100%, 60% 80%, 0% 80%)',\n createPath: (width, height) =>\n `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`,\n },\n parallelogram: {\n name: '平行四边形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(30% 0%, 100% 0%, 70% 100%, 0% 100%)',\n createPath: (width, height) =>\n `M ${width * 0.3} 0 L ${width} 0 L ${width * 0.7} ${height} L 0 ${height} Z`,\n },\n parallelogram2: {\n name: '平行四边形2',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(30% 100%, 100% 100%, 70% 0%, 0% 0%)',\n createPath: (width, height) =>\n `M ${width * 0.3} ${height} L ${width} ${height} L ${width * 0.7} 0 L 0 0 Z`,\n },\n trapezoid: {\n name: '梯形',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(25% 0%, 75% 0%, 100% 100%, 0% 100%)',\n createPath: (width, height) =>\n `M ${width * 0.25} 0 L ${width * 0.75} 0 L ${width} ${height} L 0 ${height} Z`,\n },\n trapezoid2: {\n name: '梯形2',\n type: ClipPathTypes.POLYGON,\n style: 'polygon(0% 0%, 100% 0%, 75% 100%, 25% 100%)',\n createPath: (width, height) =>\n `M 0 0 L ${width} 0 L ${width * 0.75} ${height} L ${width * 0.25} ${height} Z`,\n },\n};\n"],"names":[],"mappings":"IAAkB;AAAlB,CAAA,UAAkB,aAAa,EAAA;AAC7B,IAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,aAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACrB,CAAC,EAJiB,aAAa,KAAb,aAAa,GAAA,EAAA,CAAA,CAAA;AAcxB,MAAM,SAAS,GAAgC;AACpD,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,aAAa,CAAC,IAAI;AACxB,QAAA,MAAM,EAAE,GAAG;AACX,QAAA,KAAK,EAAE,EAAE;AACV,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,aAAa,CAAC,OAAO;AAC3B,QAAA,KAAK,EAAE,qDAAqD;QAC5D,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KACxB,CAAA,QAAA,EAAW,KAAK,GAAG,GAAG,QAAQ,KAAK,CAAA,CAAA,EAAI,MAAM,GAAG,GAAG,CAAA,GAAA,EAAM,KAAK,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,EAAQ,MAAM,CAAA,EAAA,CAAI;AAC7F,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,aAAa,CAAC,OAAO;AAC3B,QAAA,KAAK,EAAE,+DAA+D;AACtE,QAAA,UAAU,EAAE,CAAC,K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EAAQ,KAAK,GAAG,IAAI,CAAA,KAAA,EAAQ,KAAK,CAAA,CAAA,EAAI,MAAM,CAAA,KAAA,EAAQ,MAAM,CAAA,EAAA,CAAI;AACjF,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,aAAa,CAAC,OAAO;AAC3B,QAAA,KAAK,EAAE,6CAA6C;QACpD,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KACxB,CAAA,QAAA,EAAW,KAAK,CAAA,KAAA,EAAQ,KAAK,GAAG,IAAI,IAAI,MAAM,CAAA,GAAA,EAAM,KAAK,GAAG,IAAI,CAAA,CAAA,EAAI,MAAM,CAAA,EAAA,CAAI;AACjF,KAAA;;;;;"}
@@ -0,0 +1,40 @@
1
+ import { useMemo } from 'react';
2
+ import { ClipPathTypes, CLIPPATHS } from './clipPaths.js';
3
+
4
+ function useClipImage(element) {
5
+ const clipShape = useMemo(() => {
6
+ let _clipShape = CLIPPATHS.rect;
7
+ if (element.clip) {
8
+ const shape = element.clip.shape || ClipPathTypes.RECT;
9
+ _clipShape = CLIPPATHS[shape] ?? CLIPPATHS.rect;
10
+ }
11
+ if (_clipShape.radius !== undefined && element.radius !== undefined) {
12
+ _clipShape = {
13
+ ..._clipShape,
14
+ radius: `${element.radius}px`,
15
+ style: `inset(0 round ${element.radius}px)`,
16
+ };
17
+ }
18
+ return _clipShape;
19
+ }, [element.clip, element.radius]);
20
+ const imgPosition = useMemo(() => {
21
+ if (!element.clip || !element.clip.range) {
22
+ return { top: '0', left: '0', width: '100%', height: '100%' };
23
+ }
24
+ const [start, end] = element.clip.range;
25
+ const widthScale = (end[0] - start[0]) / 100;
26
+ const heightScale = (end[1] - start[1]) / 100;
27
+ const left = start[0] / widthScale;
28
+ const top = start[1] / heightScale;
29
+ return {
30
+ left: -left + '%',
31
+ top: -top + '%',
32
+ width: 100 / widthScale + '%',
33
+ height: 100 / heightScale + '%',
34
+ };
35
+ }, [element.clip]);
36
+ return { clipShape, imgPosition };
37
+ }
38
+
39
+ export { useClipImage };
40
+ //# sourceMappingURL=useClipImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useClipImage.js","sources":["../../../src/elements/image/useClipImage.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { PPTImageElement } from '@openmaic/dsl';\nimport { CLIPPATHS, ClipPathTypes } from './clipPaths';\n\nexport function useClipImage(element: PPTImageElement) {\n const clipShape = useMemo(() => {\n let _clipShape = CLIPPATHS.rect;\n\n if (element.clip) {\n const shape = element.clip.shape || ClipPathTypes.RECT;\n _clipShape = CLIPPATHS[shape] ?? CLIPPATHS.rect;\n }\n if (_clipShape.radius !== undefined && element.radius !== undefined) {\n _clipShape = {\n ..._clipShape,\n radius: `${element.radius}px`,\n style: `inset(0 round ${element.radius}px)`,\n };\n }\n\n return _clipShape;\n }, [element.clip, element.radius]);\n\n const imgPosition = useMemo(() => {\n if (!element.clip || !element.clip.range) {\n return { top: '0', left: '0', width: '100%', height: '100%' };\n }\n\n const [start, end] = element.clip.range;\n\n const widthScale = (end[0] - start[0]) / 100;\n const heightScale = (end[1] - start[1]) / 100;\n const left = start[0] / widthScale;\n const top = start[1] / heightScale;\n\n return {\n left: -left + '%',\n top: -top + '%',\n width: 100 / widthScale + '%',\n height: 100 / heightScale + '%',\n };\n }, [element.clip]);\n\n return { clipShape, imgPosition };\n}\n"],"names":[],"mappings":";;;AAIM,SAAU,YAAY,CAAC,OAAwB,EAAA;AACnD,IAAA,MAAM,SAAS,GAAG,OAAO,CAAC,MAAK;AAC7B,QAAA,IAAI,UAAU,GAAG,SAAS,CAAC,IAAI;AAE/B,QAAA,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC,IAAI;YACtD,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,IAAI;QACjD;AACA,QAAA,IAAI,U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A,MAAM,EAAE,GAAG,GAAG,WAAW,GAAG,GAAG;SAChC;AACH,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAElB,IAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE;AACnC;;;;"}
@@ -2,3 +2,4 @@ import type { ImageElementFilters } from '@openmaic/dsl';
2
2
  export declare function useFilter(filters?: ImageElementFilters): {
3
3
  filter: string;
4
4
  };
5
+ export declare function imageFiltersToCss(filters?: ImageElementFilters): string;
@@ -0,0 +1,35 @@
1
+ import { useMemo } from 'react';
2
+
3
+ const FILTER_UNITS = {
4
+ blur: 'px',
5
+ brightness: '%',
6
+ contrast: '%',
7
+ grayscale: '%',
8
+ saturate: '%',
9
+ 'hue-rotate': 'deg',
10
+ sepia: '%',
11
+ invert: '%',
12
+ opacity: '%',
13
+ };
14
+ function useFilter(filters) {
15
+ const filter = useMemo(() => {
16
+ return imageFiltersToCss(filters);
17
+ }, [filters]);
18
+ return { filter };
19
+ }
20
+ function imageFiltersToCss(filters) {
21
+ if (!filters)
22
+ return '';
23
+ const parts = [];
24
+ for (const [name, value] of Object.entries(filters)) {
25
+ if (value === undefined || value === null || value === '')
26
+ continue;
27
+ const unit = FILTER_UNITS[name] ?? '';
28
+ const rendered = unit && !value.endsWith(unit) ? `${value}${unit}` : value;
29
+ parts.push(`${name}(${rendered})`);
30
+ }
31
+ return parts.join(' ');
32
+ }
33
+
34
+ export { imageFiltersToCss, useFilter };
35
+ //# sourceMappingURL=useFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFilter.js","sources":["../../../src/elements/image/useFilter.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { ImageElementFilterKeys, ImageElementFilters } from '@openmaic/dsl';\n\nconst FILTER_UNITS: Record<ImageElementFilterKeys, string> = {\n blur: 'px',\n brightness: '%',\n contrast: '%',\n grayscale: '%',\n saturate: '%',\n 'hue-rotate': 'deg',\n sepia: '%',\n invert: '%',\n opacity: '%',\n};\n\nexport function useFilter(filters?: ImageElementFilters) {\n const filter = useMemo(() => {\n return imageFiltersToCss(filters);\n }, [filters]);\n\n return { filter };\n}\n\nexport function imageFiltersToCss(filters?: ImageElementFilters): string {\n if (!filters) return '';\n const parts: string[] = [];\n for (const [name, value] of Object.entries(filters) as [ImageElementFilterKeys, string][]) {\n if (value === undefined || value === null || value === '') continue;\n const unit = FILTER_UNITS[name] ?? '';\n const rendered = unit && !value.endsWith(unit) ? `${value}${unit}` : value;\n parts.push(`${name}(${rendered})`);\n }\n return parts.join(' ');\n}\n"],"names":[],"mappings":";;AAGA,MAAM,YAAY,GAA2C;AAC3D,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,UAAU,EAAE,GAAG;AACf,IAAA,QAAQ,EAAE,GAAG;AACb,IAAA,SAAS,EAAE,GAAG;AACd,IAAA,QAAQ,EAAE,GAAG;AACb,IAAA,YAAY,EAAE,KAAK;AACnB,IAAA,KAAK,EAAE,GAAG;AACV,IAAA,MAAM,EAAE,GAAG;AACX,IAAA,OAAO,EAAE,GAAG;CACb;AAEK,SAAU,SAAS,CAAC,OAA6B,EAAA;AACrD,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAK;AAC1B,QAAA,OAAO,iBAAiB,CAAC,OAAO,CAAC;AACnC,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAEb,OAAO,EAAE,MAAM,EAAE;AACnB;AAEM,SAAU,iBAAiB,CAAC,OAA6B,EAAA;AAC7D,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,EAAE;IACvB,MAAM,KAAK,GAAa,EAAE;AAC1B,IAAA,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAuC,EAAE;QACzF,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;YAAE;QAC3D,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE;QACrC,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAA,EAAG,KAAK,CAAA,EAAG,IAAI,EAAE,GAAG,KAAK;QAC1E,KAAK,CAAC,IAAI,CAAC,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,CAAG,CAAC;IACpC;AACA,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;AACxB;;;;"}
@@ -1,10 +1,15 @@
1
- export { B as BaseChartElement, a as BaseCodeElement, b as BaseImageElement, c as BaseLatexElement, d as BaseLineElement, e as BaseShapeElement, f as BaseTableElement, g as BaseTextElement, h as BaseVideoElement, E as ElementOutline, u as useElementFill, i as useElementFlip, j as useElementOutline, k as useElementShadow } from '../chunks/BaseCodeElement-Bh-Bfdz6.js';
2
- import 'react/jsx-runtime';
3
- import 'react';
4
- import 'tinycolor2';
5
- import 'echarts/core';
6
- import 'echarts/charts';
7
- import 'echarts/components';
8
- import 'echarts/renderers';
9
- import 'motion/react';
1
+ export { BaseTextElement } from './text/BaseTextElement.js';
2
+ export { BaseShapeElement } from './shape/BaseShapeElement.js';
3
+ export { BaseImageElement } from './image/BaseImageElement.js';
4
+ export { BaseLineElement } from './line/BaseLineElement.js';
5
+ export { BaseChartElement } from './chart/BaseChartElement.js';
6
+ export { BaseLatexElement } from './latex/BaseLatexElement.js';
7
+ export { BaseTableElement } from './table/BaseTableElement.js';
8
+ export { BaseVideoElement } from './video/BaseVideoElement.js';
9
+ export { BaseCodeElement } from './code/BaseCodeElement.js';
10
+ export { ElementOutline } from './shared/ElementOutline.js';
11
+ export { useElementFill } from './shared/useElementFill.js';
12
+ export { useElementOutline } from './shared/useElementOutline.js';
13
+ export { useElementShadow } from './shared/useElementShadow.js';
14
+ export { useElementFlip } from './shared/useElementFlip.js';
10
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,94 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useRef, useState, useCallback, useLayoutEffect, useEffect } from 'react';
4
+
5
+ function BaseLatexElement({ elementInfo }) {
6
+ return (jsx("div", { className: "base-element-latex", 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
+ }, children: jsx("div", { className: "rotate-wrapper", style: {
13
+ width: '100%',
14
+ height: '100%',
15
+ transform: `rotate(${elementInfo.rotate}deg)`,
16
+ }, children: jsx("div", { className: "element-content", style: {
17
+ position: 'relative',
18
+ width: '100%',
19
+ height: '100%',
20
+ // KaTeX glyphs inherit `color`; apply the formula's resolved color
21
+ // (e.g. 蓝色权重) so it isn't forced to the browser default.
22
+ ...(elementInfo.color ? { color: elementInfo.color } : {}),
23
+ }, 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 }) }) }));
24
+ }
25
+ const ALIGN_MAP = {
26
+ left: 'flex-start',
27
+ center: 'center',
28
+ right: 'flex-end',
29
+ };
30
+ function KatexContent({ html, width, height, align = 'center', }) {
31
+ const innerRef = useRef(null);
32
+ const [scale, setScale] = useState(1);
33
+ // Measure the formula's natural size and shrink-to-fit its box. Extracted so
34
+ // it can run both synchronously on mount (useLayoutEffect) and again once the
35
+ // KaTeX fonts finish loading (useEffect below).
36
+ //
37
+ // KaTeX lays out large delimiters (\left\{, \begin{cases}) using the metrics of
38
+ // its `KaTeX_Size1`–`Size4` faces. Those woff2 files load asynchronously, so a
39
+ // first measure on a cold export runs against the fallback font — the brace is
40
+ // sized wrong and the piecewise body (`cases`) desynchronizes from it (the bug
41
+ // reported as "大括号后面的分段函数与大括号错位"). Re-measuring after
42
+ // `document.fonts.ready` snaps the scale back to the real glyph metrics before
43
+ // the off-screen snapshot captures the frame.
44
+ const measure = useCallback(() => {
45
+ if (!innerRef.current)
46
+ return;
47
+ const naturalW = innerRef.current.scrollWidth;
48
+ const naturalH = innerRef.current.scrollHeight;
49
+ if (naturalW > 0 && naturalH > 0) {
50
+ // Cap at 1: only ever shrink the formula to fit its box, never enlarge.
51
+ // A short formula sitting in a large frame (e.g. slide 29 的右侧推理框)
52
+ // would otherwise get scaled up to fill the box and render huge.
53
+ setScale(Math.min(width / naturalW, height / naturalH, 1));
54
+ }
55
+ }, [width, height]);
56
+ useLayoutEffect(() => {
57
+ measure();
58
+ }, [measure, html]);
59
+ useEffect(() => {
60
+ const fonts = typeof document !== 'undefined' ? document.fonts : undefined;
61
+ if (!fonts)
62
+ return;
63
+ let cancelled = false;
64
+ // Re-measure once the font set settles (initial + any subsequent face that
65
+ // finishes decoding), so the fit-scale reflects the real KaTeX_Size metrics.
66
+ fonts.ready.then(() => {
67
+ if (!cancelled)
68
+ measure();
69
+ });
70
+ const onLoadingDone = () => measure();
71
+ fonts.addEventListener?.('loadingdone', onLoadingDone);
72
+ return () => {
73
+ cancelled = true;
74
+ fonts.removeEventListener?.('loadingdone', onLoadingDone);
75
+ };
76
+ }, [measure, html]);
77
+ const justify = ALIGN_MAP[align];
78
+ const origin = align === 'left' ? 'left center' : align === 'right' ? 'right center' : 'center center';
79
+ return (jsx("div", { style: {
80
+ width,
81
+ height,
82
+ overflow: 'hidden',
83
+ display: 'flex',
84
+ alignItems: 'center',
85
+ justifyContent: justify,
86
+ }, children: jsx("div", { ref: innerRef, className: "slide-renderer-prose", style: {
87
+ transformOrigin: origin,
88
+ transform: `scale(${scale})`,
89
+ whiteSpace: 'nowrap',
90
+ }, dangerouslySetInnerHTML: { __html: html } }) }));
91
+ }
92
+
93
+ export { BaseLatexElement };
94
+ //# sourceMappingURL=BaseLatexElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseLatexElement.js","sources":["../../../src/elements/latex/BaseLatexElement.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useRef, useState, useLayoutEffect } from 'react';\nimport type { PPTLatexElement } from '@openmaic/dsl';\n\nexport interface BaseLatexElementProps {\n elementInfo: PPTLatexElement;\n}\n\nexport function BaseLatexElement({ elementInfo }: BaseLatexElementProps) {\n return (\n <div\n className=\"base-element-latex\"\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 // KaTeX glyphs inherit `color`; apply the formula's resolved color\n // (e.g. 蓝色权重) so it isn't forced to the browser default.\n ...(elementInfo.color ? { color: elementInfo.color } : {}),\n }}\n >\n {elementInfo.html ? (\n <KatexContent\n html={elementInfo.html}\n width={elementInfo.width}\n height={elementInfo.height}\n align={elementInfo.align}\n />\n ) : elementInfo.path && elementInfo.viewBox ? (\n <svg\n overflow=\"visible\"\n width={elementInfo.width}\n height={elementInfo.height}\n stroke={elementInfo.color}\n strokeWidth={elementInfo.strokeWidth}\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{ transformOrigin: '0 0', overflow: 'visible' }}\n >\n <g\n transform={`scale(${elementInfo.width / elementInfo.viewBox[0]}, ${\n elementInfo.height / elementInfo.viewBox[1]\n }) translate(0,0) matrix(1,0,0,1,0,0)`}\n >\n <path d={elementInfo.path} />\n </g>\n </svg>\n ) : null}\n </div>\n </div>\n </div>\n );\n}\n\nconst ALIGN_MAP = {\n left: 'flex-start',\n center: 'center',\n right: 'flex-end',\n} as const;\n\nfunction KatexContent({\n html,\n width,\n height,\n align = 'center',\n}: {\n html: string;\n width: number;\n height: number;\n align?: 'left' | 'center' | 'right';\n}) {\n const innerRef = useRef<HTMLDivElement>(null);\n const [scale, setScale] = useState(1);\n\n // Measure the formula's natural size and shrink-to-fit its box. Extracted so\n // it can run both synchronously on mount (useLayoutEffect) and again once the\n // KaTeX fonts finish loading (useEffect below).\n //\n // KaTeX lays out large delimiters (\\left\\{, \\begin{cases}) using the metrics of\n // its `KaTeX_Size1`–`Size4` faces. Those woff2 files load asynchronously, so a\n // first measure on a cold export runs against the fallback font — the brace is\n // sized wrong and the piecewise body (`cases`) desynchronizes from it (the bug\n // reported as \"大括号后面的分段函数与大括号错位\"). Re-measuring after\n // `document.fonts.ready` snaps the scale back to the real glyph metrics before\n // the off-screen snapshot captures the frame.\n const measure = useCallback(() => {\n if (!innerRef.current) return;\n const naturalW = innerRef.current.scrollWidth;\n const naturalH = innerRef.current.scrollHeight;\n if (naturalW > 0 && naturalH > 0) {\n // Cap at 1: only ever shrink the formula to fit its box, never enlarge.\n // A short formula sitting in a large frame (e.g. slide 29 的右侧推理框)\n // would otherwise get scaled up to fill the box and render huge.\n setScale(Math.min(width / naturalW, height / naturalH, 1));\n }\n }, [width, height]);\n\n useLayoutEffect(() => {\n measure();\n }, [measure, html]);\n\n useEffect(() => {\n const fonts = typeof document !== 'undefined' ? document.fonts : undefined;\n if (!fonts) return;\n let cancelled = false;\n // Re-measure once the font set settles (initial + any subsequent face that\n // finishes decoding), so the fit-scale reflects the real KaTeX_Size metrics.\n fonts.ready.then(() => {\n if (!cancelled) measure();\n });\n const onLoadingDone = () => measure();\n fonts.addEventListener?.('loadingdone', onLoadingDone);\n return () => {\n cancelled = true;\n fonts.removeEventListener?.('loadingdone', onLoadingDone);\n };\n }, [measure, html]);\n\n const justify = ALIGN_MAP[align];\n const origin =\n align === 'left' ? 'left center' : align === 'right' ? 'right center' : 'center center';\n\n return (\n <div\n style={{\n width,\n height,\n overflow: 'hidden',\n display: 'flex',\n alignItems: 'center',\n justifyContent: justify,\n }}\n >\n <div\n ref={innerRef}\n className=\"slide-renderer-prose\"\n style={{\n transformOrigin: origin,\n transform: `scale(${scale})`,\n whiteSpace: 'nowrap',\n }}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AASM;AACJ;AAIM;AACA;AACA;AACA;AACA;AACD;AAKG;AACA;AACA;AACD;AAKG;AACA;AACA;;;AAGA;AACD;AAkCX;AAEA;AACE;AACA;AACA;;AAGF;AAWE;;;;;;;;;;;;;AAcA;;;AAEE;AACA;;;;;AAKE;;AAEJ;;AAGE;AACF;;AAGE;AACA;;;;;AAIA;AACE;AAAgB;AAClB;AACA;;AAEA;;;AAGA;AACF;AAEA;;;;;AASM;AACA;AACA;AACA;;AAOE;;AAEA;;AAMV;;"}
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { useRef, useState, useMemo, useEffect } from 'react';
4
+ import { getLineElementPath } from '../../utils/element.js';
5
+ import { useElementShadow } from '../shared/useElementShadow.js';
6
+ import { LinePointMarker } from './LinePointMarker.js';
7
+
8
+ const DRAW_ANIMATION_MS = 600;
9
+ function BaseLineElement({ elementInfo, animate }) {
10
+ const { shadowStyle } = useElementShadow(elementInfo.shadow);
11
+ const pathRef = useRef(null);
12
+ const [drawComplete, setDrawComplete] = useState(!animate);
13
+ const svgWidth = useMemo(() => {
14
+ const width = Math.abs(elementInfo.start[0] - elementInfo.end[0]);
15
+ return width < 24 ? 24 : width;
16
+ }, [elementInfo.start, elementInfo.end]);
17
+ const svgHeight = useMemo(() => {
18
+ const height = Math.abs(elementInfo.start[1] - elementInfo.end[1]);
19
+ return height < 24 ? 24 : height;
20
+ }, [elementInfo.start, elementInfo.end]);
21
+ const lineDashArray = useMemo(() => {
22
+ const size = elementInfo.width;
23
+ if (elementInfo.style === 'dashed')
24
+ return size <= 8 ? `${size * 5} ${size * 2.5}` : `${size * 5} ${size * 1.5}`;
25
+ if (elementInfo.style === 'dotted')
26
+ return size <= 8 ? `${size * 1.8} ${size * 1.6}` : `${size * 1.5} ${size * 1.2}`;
27
+ return '0 0';
28
+ }, [elementInfo.width, elementInfo.style]);
29
+ const path = useMemo(() => getLineElementPath(elementInfo), [elementInfo]);
30
+ useEffect(() => {
31
+ if (!animate)
32
+ return;
33
+ const pathEl = pathRef.current;
34
+ if (!pathEl)
35
+ return;
36
+ const length = pathEl.getTotalLength();
37
+ if (length === 0) {
38
+ const t = setTimeout(() => setDrawComplete(true), 0);
39
+ return () => clearTimeout(t);
40
+ }
41
+ pathEl.style.strokeDasharray = `${length}`;
42
+ pathEl.style.strokeDashoffset = `${length}`;
43
+ pathEl.style.transition = 'none';
44
+ pathEl.getBoundingClientRect();
45
+ pathEl.style.transition = `stroke-dashoffset ${DRAW_ANIMATION_MS}ms ease-out`;
46
+ pathEl.style.strokeDashoffset = '0';
47
+ const timer = setTimeout(() => {
48
+ pathEl.style.transition = 'none';
49
+ pathEl.style.strokeDasharray = '';
50
+ pathEl.style.strokeDashoffset = '';
51
+ setDrawComplete(true);
52
+ }, DRAW_ANIMATION_MS + 50);
53
+ return () => clearTimeout(timer);
54
+ }, [animate]);
55
+ return (jsx("div", { className: "base-element-line", style: {
56
+ position: 'absolute',
57
+ top: `${elementInfo.top}px`,
58
+ left: `${elementInfo.left}px`,
59
+ }, children: jsx("div", { className: "element-content", style: {
60
+ position: 'relative',
61
+ width: '100%',
62
+ height: '100%',
63
+ filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',
64
+ }, 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]
65
+ ? `url(#${elementInfo.id}-${elementInfo.points[0]}-start)`
66
+ : '', markerEnd: drawComplete && elementInfo.points[1]
67
+ ? `url(#${elementInfo.id}-${elementInfo.points[1]}-end)`
68
+ : '' })] }) }) }));
69
+ }
70
+
71
+ export { BaseLineElement };
72
+ //# sourceMappingURL=BaseLineElement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseLineElement.js","sources":["../../../src/elements/line/BaseLineElement.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo, useRef, useState, useEffect } from 'react';\nimport type { PPTLineElement } from '@openmaic/dsl';\nimport { getLineElementPath } from '../../utils/element';\nimport { useElementShadow } from '../shared/useElementShadow';\nimport { LinePointMarker } from './LinePointMarker';\n\nexport interface BaseLineElementProps {\n elementInfo: PPTLineElement;\n animate?: boolean;\n}\n\nconst DRAW_ANIMATION_MS = 600;\n\nexport function BaseLineElement({ elementInfo, animate }: BaseLineElementProps) {\n const { shadowStyle } = useElementShadow(elementInfo.shadow);\n const pathRef = useRef<SVGPathElement>(null);\n const [drawComplete, setDrawComplete] = useState(!animate);\n\n const svgWidth = useMemo(() => {\n const width = Math.abs(elementInfo.start[0] - elementInfo.end[0]);\n return width < 24 ? 24 : width;\n }, [elementInfo.start, elementInfo.end]);\n\n const svgHeight = useMemo(() => {\n const height = Math.abs(elementInfo.start[1] - elementInfo.end[1]);\n return height < 24 ? 24 : height;\n }, [elementInfo.start, elementInfo.end]);\n\n const lineDashArray = useMemo(() => {\n const size = elementInfo.width;\n if (elementInfo.style === 'dashed')\n return size <= 8 ? `${size * 5} ${size * 2.5}` : `${size * 5} ${size * 1.5}`;\n if (elementInfo.style === 'dotted')\n return size <= 8 ? `${size * 1.8} ${size * 1.6}` : `${size * 1.5} ${size * 1.2}`;\n return '0 0';\n }, [elementInfo.width, elementInfo.style]);\n\n const path = useMemo(() => getLineElementPath(elementInfo), [elementInfo]);\n\n useEffect(() => {\n if (!animate) return;\n const pathEl = pathRef.current;\n if (!pathEl) return;\n\n const length = pathEl.getTotalLength();\n if (length === 0) {\n const t = setTimeout(() => setDrawComplete(true), 0);\n return () => clearTimeout(t);\n }\n\n pathEl.style.strokeDasharray = `${length}`;\n pathEl.style.strokeDashoffset = `${length}`;\n pathEl.style.transition = 'none';\n pathEl.getBoundingClientRect();\n pathEl.style.transition = `stroke-dashoffset ${DRAW_ANIMATION_MS}ms ease-out`;\n pathEl.style.strokeDashoffset = '0';\n\n const timer = setTimeout(() => {\n pathEl.style.transition = 'none';\n pathEl.style.strokeDasharray = '';\n pathEl.style.strokeDashoffset = '';\n setDrawComplete(true);\n }, DRAW_ANIMATION_MS + 50);\n\n return () => clearTimeout(timer);\n }, [animate]);\n\n return (\n <div\n className=\"base-element-line\"\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n }}\n >\n <div\n className=\"element-content\"\n style={{\n position: 'relative',\n width: '100%',\n height: '100%',\n filter: shadowStyle ? `drop-shadow(${shadowStyle})` : '',\n }}\n >\n <svg\n overflow=\"visible\"\n width={svgWidth}\n height={svgHeight}\n style={{ transformOrigin: '0 0', overflow: 'visible' }}\n >\n <defs>\n {elementInfo.points[0] && (\n <LinePointMarker\n id={elementInfo.id}\n position=\"start\"\n type={elementInfo.points[0]}\n color={elementInfo.color}\n baseSize={elementInfo.width}\n />\n )}\n {elementInfo.points[1] && (\n <LinePointMarker\n id={elementInfo.id}\n position=\"end\"\n type={elementInfo.points[1]}\n color={elementInfo.color}\n baseSize={elementInfo.width}\n />\n )}\n </defs>\n <path\n ref={pathRef}\n d={path}\n stroke={elementInfo.color}\n strokeWidth={elementInfo.width}\n strokeDasharray={lineDashArray}\n fill=\"none\"\n markerStart={\n drawComplete && elementInfo.points[0]\n ? `url(#${elementInfo.id}-${elementInfo.points[0]}-start)`\n : ''\n }\n markerEnd={\n drawComplete && elementInfo.points[1]\n ? `url(#${elementInfo.id}-${elementInfo.points[1]}-end)`\n : ''\n }\n />\n </svg>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;AAaA;;;AAIE;;AAGA;;;;AAKA;;;;AAKA;AACE;AACA;;AAEA;;AAEA;;AAGF;;AAGE;;AACA;AACA;;AAEA;AACA;AACE;AACA;;;;AAKF;;;AAGA;AAEA;AACE;AACA;AACA;;AAEF;AAEA;AACF;AAEA;AAIM;AACA;AACA;AACD;AAKG;AACA;AACA;;AAED;AAqCO;AACA;AAIA;AACA;AAOhB;;"}
@@ -0,0 +1,19 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const pathMap = {
4
+ dot: 'm0 5a5 5 0 1 0 10 0a5 5 0 1 0 -10 0z',
5
+ arrow: 'M0,0 L10,5 0,10 Z',
6
+ };
7
+ const rotateMap = {
8
+ 'arrow-start': 180,
9
+ 'arrow-end': 0,
10
+ };
11
+ function LinePointMarker({ id, position, type, baseSize, color }) {
12
+ const path = pathMap[type];
13
+ const rotate = rotateMap[`${type}-${position}`] || 0;
14
+ const size = baseSize < 2 ? 2 : baseSize;
15
+ 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)` }) }));
16
+ }
17
+
18
+ export { LinePointMarker };
19
+ //# sourceMappingURL=LinePointMarker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinePointMarker.js","sources":["../../../src/elements/line/LinePointMarker.tsx"],"sourcesContent":["import type { LinePoint } from '@openmaic/dsl';\n\ntype NonEmptyLinePoint = Exclude<LinePoint, ''>;\n\ninterface LinePointMarkerProps {\n id: string;\n position: 'start' | 'end';\n type: NonEmptyLinePoint;\n baseSize: number;\n color?: string;\n}\n\nconst pathMap: Record<NonEmptyLinePoint, string> = {\n dot: 'm0 5a5 5 0 1 0 10 0a5 5 0 1 0 -10 0z',\n arrow: 'M0,0 L10,5 0,10 Z',\n};\n\nconst rotateMap: Record<string, number> = {\n 'arrow-start': 180,\n 'arrow-end': 0,\n};\n\nexport function LinePointMarker({ id, position, type, baseSize, color }: LinePointMarkerProps) {\n const path = pathMap[type];\n const rotate = rotateMap[`${type}-${position}`] || 0;\n const size = baseSize < 2 ? 2 : baseSize;\n\n return (\n <marker\n id={`${id}-${type}-${position}`}\n markerUnits=\"userSpaceOnUse\"\n orient=\"auto\"\n markerWidth={size * 3}\n markerHeight={size * 3}\n refX={size * 1.5}\n refY={size * 1.5}\n >\n <path\n d={path}\n fill={color}\n transform={`scale(${size * 0.3}, ${size * 0.3}) rotate(${rotate}, 5, 5)`}\n />\n </marker>\n );\n}\n"],"names":["_jsx"],"mappings":";;AAYA,MAAM,OAAO,GAAsC;AACjD,IAAA,GAAG,EAAE,sCAAsC;AAC3C,IAAA,KAAK,EAAE,mBAAmB;CAC3B;AAED,MAAM,SAAS,GAA2B;AACxC,IAAA,aAAa,EAAE,GAAG;AAClB,IAAA,WAAW,EAAE,CAAC;CACf;AAEK,SAAU,eAAe,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAwB,EAAA;AAC3F,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAA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