@openmaic/renderer 0.0.5 → 0.1.1
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/README.md +14 -1
- package/dist/SlideCanvas.d.ts +14 -1
- package/dist/SlideCanvas.js +17 -7
- package/dist/SlideCanvas.js.map +1 -1
- package/dist/SlideElement.d.ts +10 -2
- package/dist/SlideElement.js +16 -5
- package/dist/SlideElement.js.map +1 -1
- package/dist/elements/audio/BaseAudioElement.d.ts +10 -0
- package/dist/elements/audio/BaseAudioElement.js +71 -0
- package/dist/elements/audio/BaseAudioElement.js.map +1 -0
- package/dist/elements/image/BaseImageElement.js +1 -1
- package/dist/elements/image/BaseImageElement.js.map +1 -1
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.js +2 -0
- package/dist/elements/index.js.map +1 -1
- package/dist/elements/shape/BaseShapeElement.d.ts +4 -1
- package/dist/elements/shape/BaseShapeElement.js +21 -18
- package/dist/elements/shape/BaseShapeElement.js.map +1 -1
- package/dist/elements/table/BaseTableElement.d.ts +3 -1
- package/dist/elements/table/BaseTableElement.js +3 -2
- package/dist/elements/table/BaseTableElement.js.map +1 -1
- package/dist/elements/table/StaticTable.js +1 -3
- package/dist/elements/table/StaticTable.js.map +1 -1
- package/dist/elements/text/BaseTextElement.d.ts +3 -1
- package/dist/elements/text/BaseTextElement.js +11 -5
- package/dist/elements/text/BaseTextElement.js.map +1 -1
- package/dist/elements/video/BaseVideoElement.js +1 -1
- package/dist/elements/video/BaseVideoElement.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/styles.d.ts +5 -6
- package/dist/styles.js +24 -5
- package/dist/styles.js.map +1 -1
- package/dist/utils/richText.d.ts +1 -0
- package/dist/utils/richText.js +12 -0
- package/dist/utils/richText.js.map +1 -0
- package/package.json +2 -6
- package/dist/editing/EditableSlideCanvas.d.ts +0 -26
- package/dist/editing/EditableSlideCanvas.js +0 -352
- package/dist/editing/EditableSlideCanvas.js.map +0 -1
- package/dist/editing/core/drag.d.ts +0 -108
- package/dist/editing/core/drag.js +0 -119
- package/dist/editing/core/drag.js.map +0 -1
- package/dist/editing/core/geometry.d.ts +0 -48
- package/dist/editing/core/geometry.js +0 -186
- package/dist/editing/core/geometry.js.map +0 -1
- package/dist/editing/core/intent.d.ts +0 -39
- package/dist/editing/core/intent.js +0 -35
- package/dist/editing/core/intent.js.map +0 -1
- package/dist/editing/core/line-drag.d.ts +0 -19
- package/dist/editing/core/line-drag.js +0 -163
- package/dist/editing/core/line-drag.js.map +0 -1
- package/dist/editing/core/marquee.d.ts +0 -56
- package/dist/editing/core/marquee.js +0 -74
- package/dist/editing/core/marquee.js.map +0 -1
- package/dist/editing/core/resize.d.ts +0 -121
- package/dist/editing/core/resize.js +0 -392
- package/dist/editing/core/resize.js.map +0 -1
- package/dist/editing/core/rotate.d.ts +0 -37
- package/dist/editing/core/rotate.js +0 -74
- package/dist/editing/core/rotate.js.map +0 -1
- package/dist/editing/core/selection.d.ts +0 -68
- package/dist/editing/core/selection.js +0 -108
- package/dist/editing/core/selection.js.map +0 -1
- package/dist/editing/core/snapping.d.ts +0 -54
- package/dist/editing/core/snapping.js +0 -96
- package/dist/editing/core/snapping.js.map +0 -1
- package/dist/editing/handles/BorderLine.d.ts +0 -15
- package/dist/editing/handles/BorderLine.js +0 -17
- package/dist/editing/handles/BorderLine.js.map +0 -1
- package/dist/editing/handles/LineHandles.d.ts +0 -28
- package/dist/editing/handles/LineHandles.js +0 -51
- package/dist/editing/handles/LineHandles.js.map +0 -1
- package/dist/editing/handles/MarqueeBox.d.ts +0 -19
- package/dist/editing/handles/MarqueeBox.js +0 -26
- package/dist/editing/handles/MarqueeBox.js.map +0 -1
- package/dist/editing/handles/ResizeHandles.d.ts +0 -31
- package/dist/editing/handles/ResizeHandles.js +0 -44
- package/dist/editing/handles/ResizeHandles.js.map +0 -1
- package/dist/editing/handles/RotateHandle.d.ts +0 -26
- package/dist/editing/handles/RotateHandle.js +0 -52
- package/dist/editing/handles/RotateHandle.js.map +0 -1
- package/dist/editing/handles/SelectionOverlay.d.ts +0 -18
- package/dist/editing/handles/SelectionOverlay.js +0 -35
- package/dist/editing/handles/SelectionOverlay.js.map +0 -1
- package/dist/editing/index.d.ts +0 -3
- package/dist/editing/index.js +0 -4
- package/dist/editing/index.js.map +0 -1
- package/dist/editing/types.d.ts +0 -107
- package/dist/editing/types.js +0 -7
- package/dist/editing/types.js.map +0 -1
- package/dist/editing/useEditGesture.d.ts +0 -46
- package/dist/editing/useEditGesture.js +0 -217
- package/dist/editing/useEditGesture.js.map +0 -1
- package/dist/editing/useLineHandleGesture.d.ts +0 -35
- package/dist/editing/useLineHandleGesture.js +0 -112
- package/dist/editing/useLineHandleGesture.js.map +0 -1
- package/dist/editing/useMarqueeGesture.d.ts +0 -43
- package/dist/editing/useMarqueeGesture.js +0 -157
- package/dist/editing/useMarqueeGesture.js.map +0 -1
- package/dist/editing/useResizeGesture.d.ts +0 -43
- package/dist/editing/useResizeGesture.js +0 -137
- package/dist/editing/useResizeGesture.js.map +0 -1
- package/dist/editing/useRotateGesture.d.ts +0 -47
- package/dist/editing/useRotateGesture.js +0 -128
- package/dist/editing/useRotateGesture.js.map +0 -1
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { StaticTable } from './StaticTable.js';
|
|
4
4
|
|
|
5
|
-
function BaseTableElement({ elementInfo, target }) {
|
|
5
|
+
function BaseTableElement({ elementInfo, target, renderContent }) {
|
|
6
|
+
const defaultContent = jsx(StaticTable, { elementInfo: elementInfo });
|
|
6
7
|
return (jsx("div", { className: "base-element-table", style: {
|
|
7
8
|
position: 'absolute',
|
|
8
9
|
top: `${elementInfo.top}px`,
|
|
@@ -14,7 +15,7 @@ function BaseTableElement({ elementInfo, target }) {
|
|
|
14
15
|
width: '100%',
|
|
15
16
|
height: '100%',
|
|
16
17
|
transform: `rotate(${elementInfo.rotate}deg)`,
|
|
17
|
-
}, children: jsx("div", { className: "element-content", style: { width: '100%', height: '100%' }, children:
|
|
18
|
+
}, children: jsx("div", { className: "element-content", style: { width: '100%', height: '100%' }, children: renderContent?.(elementInfo, defaultContent) ?? defaultContent }) }) }));
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export { BaseTableElement };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseTableElement.js","sources":["../../../src/elements/table/BaseTableElement.tsx"],"sourcesContent":["'use client';\n\nimport type { PPTTableElement } from '@openmaic/dsl';\nimport { StaticTable } from './StaticTable';\n\nexport interface BaseTableElementProps {\n elementInfo: PPTTableElement;\n target?: string;\n}\n\nexport function BaseTableElement({ elementInfo, target }: BaseTableElementProps) {\n return (\n <div\n className=\"base-element-table\"\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n pointerEvents: target === 'thumbnail' ? 'none' : undefined,\n }}\n >\n <div\n className=\"rotate-wrapper\"\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n }}\n >\n <div className=\"element-content\" style={{ width: '100%', height: '100%' }}>\n
|
|
1
|
+
{"version":3,"file":"BaseTableElement.js","sources":["../../../src/elements/table/BaseTableElement.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport type { PPTTableElement } from '@openmaic/dsl';\nimport { StaticTable } from './StaticTable';\n\nexport interface BaseTableElementProps {\n elementInfo: PPTTableElement;\n target?: string;\n renderContent?: (element: PPTTableElement, defaultContent: ReactNode) => ReactNode;\n}\n\nexport function BaseTableElement({ elementInfo, target, renderContent }: BaseTableElementProps) {\n const defaultContent = <StaticTable elementInfo={elementInfo} />;\n return (\n <div\n className=\"base-element-table\"\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n pointerEvents: target === 'thumbnail' ? 'none' : undefined,\n }}\n >\n <div\n className=\"rotate-wrapper\"\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n }}\n >\n <div className=\"element-content\" style={{ width: '100%', height: '100%' }}>\n {renderContent?.(elementInfo, defaultContent) ?? defaultContent}\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;AAYM;;AAEJ;AAIM;AACA;AACA;AACA;AACA;;AAED;AAKG;AACA;AACA;AACD;AAQT;;"}
|
|
@@ -99,9 +99,7 @@ function StaticTable({ elementInfo }) {
|
|
|
99
99
|
? 'flex-start'
|
|
100
100
|
: cell.vAlign === 'bottom'
|
|
101
101
|
? 'flex-end'
|
|
102
|
-
:
|
|
103
|
-
? 'center'
|
|
104
|
-
: undefined,
|
|
102
|
+
: 'center',
|
|
105
103
|
},
|
|
106
104
|
// cell.text is already final HTML (transformParsedToSlides
|
|
107
105
|
// escapes text + converts \n/spaces and keeps <p> positioning
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticTable.js","sources":["../../../src/elements/table/StaticTable.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo, type CSSProperties } from 'react';\nimport type { PPTTableElement, TableCellBorder } from '@openmaic/dsl';\nimport { getTableSubThemeColor } from '../../utils/element';\nimport { getTextStyle } from './tableUtils';\n\nfunction cellBorderCss(b?: TableCellBorder): string | undefined {\n if (!b || b.width <= 0) return undefined;\n const style = b.style === 'dashed' || b.style === 'dotted' ? b.style : 'solid';\n return `${b.width}px ${style} ${b.color}`;\n}\n\ninterface StaticTableProps {\n elementInfo: PPTTableElement;\n}\n\nexport function StaticTable({ elementInfo }: StaticTableProps) {\n const { width, data, colWidths, cellMinHeight, rowHeights, outline, theme } = elementInfo;\n\n const [subThemeDark, subThemeLight] = useMemo(() => {\n if (!theme) return ['', ''];\n return getTableSubThemeColor(theme.color);\n }, [theme]);\n\n const borderStyle = useMemo(() => {\n if (!outline) return 'none';\n const w = outline.width ?? 1;\n const c = outline.color ?? '#000';\n const s = outline.style === 'dashed' ? 'dashed' : 'solid';\n return `${w}px ${s} ${c}`;\n }, [outline]);\n\n const getCellBg = (\n rowIdx: number,\n colIdx: number,\n cellBackcolor?: string,\n ): string | undefined => {\n if (cellBackcolor) return cellBackcolor;\n if (!theme) return undefined;\n\n const rowCount = data.length;\n const colCount = data[0]?.length ?? 0;\n\n if (theme.rowHeader && rowIdx === 0) return theme.color;\n if (theme.rowFooter && rowIdx === rowCount - 1) return theme.color;\n if (theme.colHeader && colIdx === 0) return subThemeDark;\n if (theme.colFooter && colIdx === colCount - 1) return subThemeDark;\n\n const effectiveRow = theme.rowHeader ? rowIdx - 1 : rowIdx;\n if (effectiveRow >= 0 && effectiveRow % 2 === 0) return subThemeLight;\n\n return undefined;\n };\n\n const getHeaderTextColor = (rowIdx: number): string | undefined => {\n if (!theme) return undefined;\n const rowCount = data.length;\n if (theme.rowHeader && rowIdx === 0) return '#fff';\n if (theme.rowFooter && rowIdx === rowCount - 1) return '#fff';\n return undefined;\n };\n\n return (\n <table\n className=\"slide-renderer-prose\"\n style={{\n width: '100%',\n height: '100%',\n borderCollapse: 'collapse',\n tableLayout: 'fixed',\n }}\n >\n <colgroup>\n {colWidths.map((w, i) => (\n <col key={i} style={{ width: `${w * width}px` }} />\n ))}\n </colgroup>\n <tbody>\n {data.map((row, rowIdx) => (\n <tr key={rowIdx} style={{ height: `${rowHeights?.[rowIdx] ?? cellMinHeight}px` }}>\n {row.map((cell, colIdx) => {\n // parser side (transformParsedToSlides) 已经把 hMerge/vMerge\n // continuation 单元格剔除了,data[r] 只剩 top-left cells;浏览器\n // 的 HTML table layout 通过 td.colSpan/rowSpan 自动算正确位置,\n // 不需要再手动算 hiddenCells(旧实现用 data-index 比对 grid-coord\n // key,混了两种坐标系,把 colspan 跨过的 grid-coord 等于另一格\n // 的 data-index 时会误隐藏,slide 26 表头 \"权重\"/\"好\" 就是中招)。\n const bgColor = getCellBg(rowIdx, colIdx, cell.style?.backcolor);\n const headerColor = getHeaderTextColor(rowIdx);\n const textStyle = getTextStyle(cell.style);\n\n if (headerColor && !cell.style?.color) {\n textStyle.color = headerColor;\n }\n\n // 单元格自带逐边描边时按边渲染(未定义的边不画);否则回退到\n // 表级 outline 套四边的旧行为,保留真·网格表格的表现。\n const cellBorders = cell.borders;\n const borderCss: CSSProperties =\n cellBorders &&\n (cellBorders.top || cellBorders.bottom || cellBorders.left || cellBorders.right)\n ? {\n borderTop: cellBorderCss(cellBorders.top) ?? 'none',\n borderBottom: cellBorderCss(cellBorders.bottom) ?? 'none',\n borderLeft: cellBorderCss(cellBorders.left) ?? 'none',\n borderRight: cellBorderCss(cellBorders.right) ?? 'none',\n }\n : { border: borderStyle };\n\n return (\n <td\n key={cell.id}\n colSpan={cell.colspan > 1 ? cell.colspan : undefined}\n rowSpan={cell.rowspan > 1 ? cell.rowspan : undefined}\n style={{\n ...borderCss,\n backgroundColor: bgColor,\n ...textStyle,\n }}\n >\n <div\n className=\"slide-renderer-cell-text\"\n style={{\n minHeight: `${(rowHeights?.[rowIdx] ?? cellMinHeight) - 4}px`,\n padding: cell.padding,\n display: 'flex',\n flexDirection: 'column',\n lineHeight: 1,\n justifyContent:\n cell.vAlign === 'top'\n ? 'flex-start'\n : cell.vAlign === 'bottom'\n ? 'flex-end'\n :
|
|
1
|
+
{"version":3,"file":"StaticTable.js","sources":["../../../src/elements/table/StaticTable.tsx"],"sourcesContent":["'use client';\n\nimport { useMemo, type CSSProperties } from 'react';\nimport type { PPTTableElement, TableCellBorder } from '@openmaic/dsl';\nimport { getTableSubThemeColor } from '../../utils/element';\nimport { getTextStyle } from './tableUtils';\n\nfunction cellBorderCss(b?: TableCellBorder): string | undefined {\n if (!b || b.width <= 0) return undefined;\n const style = b.style === 'dashed' || b.style === 'dotted' ? b.style : 'solid';\n return `${b.width}px ${style} ${b.color}`;\n}\n\ninterface StaticTableProps {\n elementInfo: PPTTableElement;\n}\n\nexport function StaticTable({ elementInfo }: StaticTableProps) {\n const { width, data, colWidths, cellMinHeight, rowHeights, outline, theme } = elementInfo;\n\n const [subThemeDark, subThemeLight] = useMemo(() => {\n if (!theme) return ['', ''];\n return getTableSubThemeColor(theme.color);\n }, [theme]);\n\n const borderStyle = useMemo(() => {\n if (!outline) return 'none';\n const w = outline.width ?? 1;\n const c = outline.color ?? '#000';\n const s = outline.style === 'dashed' ? 'dashed' : 'solid';\n return `${w}px ${s} ${c}`;\n }, [outline]);\n\n const getCellBg = (\n rowIdx: number,\n colIdx: number,\n cellBackcolor?: string,\n ): string | undefined => {\n if (cellBackcolor) return cellBackcolor;\n if (!theme) return undefined;\n\n const rowCount = data.length;\n const colCount = data[0]?.length ?? 0;\n\n if (theme.rowHeader && rowIdx === 0) return theme.color;\n if (theme.rowFooter && rowIdx === rowCount - 1) return theme.color;\n if (theme.colHeader && colIdx === 0) return subThemeDark;\n if (theme.colFooter && colIdx === colCount - 1) return subThemeDark;\n\n const effectiveRow = theme.rowHeader ? rowIdx - 1 : rowIdx;\n if (effectiveRow >= 0 && effectiveRow % 2 === 0) return subThemeLight;\n\n return undefined;\n };\n\n const getHeaderTextColor = (rowIdx: number): string | undefined => {\n if (!theme) return undefined;\n const rowCount = data.length;\n if (theme.rowHeader && rowIdx === 0) return '#fff';\n if (theme.rowFooter && rowIdx === rowCount - 1) return '#fff';\n return undefined;\n };\n\n return (\n <table\n className=\"slide-renderer-prose\"\n style={{\n width: '100%',\n height: '100%',\n borderCollapse: 'collapse',\n tableLayout: 'fixed',\n }}\n >\n <colgroup>\n {colWidths.map((w, i) => (\n <col key={i} style={{ width: `${w * width}px` }} />\n ))}\n </colgroup>\n <tbody>\n {data.map((row, rowIdx) => (\n <tr key={rowIdx} style={{ height: `${rowHeights?.[rowIdx] ?? cellMinHeight}px` }}>\n {row.map((cell, colIdx) => {\n // parser side (transformParsedToSlides) 已经把 hMerge/vMerge\n // continuation 单元格剔除了,data[r] 只剩 top-left cells;浏览器\n // 的 HTML table layout 通过 td.colSpan/rowSpan 自动算正确位置,\n // 不需要再手动算 hiddenCells(旧实现用 data-index 比对 grid-coord\n // key,混了两种坐标系,把 colspan 跨过的 grid-coord 等于另一格\n // 的 data-index 时会误隐藏,slide 26 表头 \"权重\"/\"好\" 就是中招)。\n const bgColor = getCellBg(rowIdx, colIdx, cell.style?.backcolor);\n const headerColor = getHeaderTextColor(rowIdx);\n const textStyle = getTextStyle(cell.style);\n\n if (headerColor && !cell.style?.color) {\n textStyle.color = headerColor;\n }\n\n // 单元格自带逐边描边时按边渲染(未定义的边不画);否则回退到\n // 表级 outline 套四边的旧行为,保留真·网格表格的表现。\n const cellBorders = cell.borders;\n const borderCss: CSSProperties =\n cellBorders &&\n (cellBorders.top || cellBorders.bottom || cellBorders.left || cellBorders.right)\n ? {\n borderTop: cellBorderCss(cellBorders.top) ?? 'none',\n borderBottom: cellBorderCss(cellBorders.bottom) ?? 'none',\n borderLeft: cellBorderCss(cellBorders.left) ?? 'none',\n borderRight: cellBorderCss(cellBorders.right) ?? 'none',\n }\n : { border: borderStyle };\n\n return (\n <td\n key={cell.id}\n colSpan={cell.colspan > 1 ? cell.colspan : undefined}\n rowSpan={cell.rowspan > 1 ? cell.rowspan : undefined}\n style={{\n ...borderCss,\n backgroundColor: bgColor,\n ...textStyle,\n }}\n >\n <div\n className=\"slide-renderer-cell-text\"\n style={{\n minHeight: `${(rowHeights?.[rowIdx] ?? cellMinHeight) - 4}px`,\n padding: cell.padding,\n display: 'flex',\n flexDirection: 'column',\n lineHeight: 1,\n justifyContent:\n cell.vAlign === 'top'\n ? 'flex-start'\n : cell.vAlign === 'bottom'\n ? 'flex-end'\n : 'center',\n }}\n // cell.text is already final HTML (transformParsedToSlides\n // escapes text + converts \\n/spaces and keeps <p> positioning\n // styles). Do NOT run formatText here — its space→ \n // replacement corrupts style attributes like\n // `margin-left: calc(42px + 0.25em)` → the title indent is\n // lost and collides with the cell's left icon (slide 5).\n dangerouslySetInnerHTML={{ __html: cell.text }}\n />\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"],"names":[],"mappings":";;;;;;AAOA;AACE;AAAwB;;;AAG1B;AAMM;AACJ;;AAGE;AAAY;AACZ;AACF;AAEA;AACE;AAAc;AACd;AACA;AACA;AACA;AACF;;AAOE;AAAmB;AACnB;AAAY;AAEZ;;AAGA;;;;AAEA;AAAqC;;AACW;AAEhD;;AACiD;AAEjD;AACF;AAEA;AACE;AAAY;AACZ;AACA;AAAqC;;AACW;AAChD;AACF;AAEA;AAIM;AACA;AACA;AACA;AACD;;;;;;;AAiBO;AACA;;;AAIE;;;;AAKF;;AAGE;AACE;;;;;AAKG;AACH;AAEJ;AAMM;AACA;AACA;AACD;AAKG;;AAEA;AACA;AACA;AACA;AAEI;AACA;AACE;AACA;AACP;;;;;;;AAOD;;AAUpB;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { PPTTextElement } from '@openmaic/dsl';
|
|
2
3
|
export interface BaseTextElementProps {
|
|
3
4
|
elementInfo: PPTTextElement;
|
|
4
5
|
target?: string;
|
|
6
|
+
renderContent?: (element: PPTTextElement, defaultContent: ReactNode) => ReactNode;
|
|
5
7
|
}
|
|
6
|
-
export declare function BaseTextElement({ elementInfo, target }: BaseTextElementProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function BaseTextElement({ elementInfo, target, renderContent }: BaseTextElementProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useElementShadow } from '../shared/useElementShadow.js';
|
|
4
4
|
import { ElementOutline } from '../shared/ElementOutline.js';
|
|
5
|
+
import { preservesPlainTextLineBreaks } from '../../utils/richText.js';
|
|
5
6
|
|
|
6
|
-
function BaseTextElement({ elementInfo, target }) {
|
|
7
|
+
function BaseTextElement({ elementInfo, target, renderContent }) {
|
|
7
8
|
const { shadowStyle } = useElementShadow(elementInfo.shadow);
|
|
8
9
|
const vAlign = elementInfo.vAlign ?? 'top';
|
|
9
10
|
const justifyContent = vAlign === 'middle' ? 'center' : vAlign === 'bottom' ? 'flex-end' : 'flex-start';
|
|
11
|
+
const defaultContent = (jsx("div", { className: "text ProseMirror-static", style: {
|
|
12
|
+
position: 'relative',
|
|
13
|
+
pointerEvents: target === 'thumbnail' ? 'none' : undefined,
|
|
14
|
+
whiteSpace: preservesPlainTextLineBreaks(elementInfo.content) ? 'pre-line' : undefined,
|
|
15
|
+
}, dangerouslySetInnerHTML: { __html: elementInfo.content } }));
|
|
10
16
|
return (jsx("div", { className: "base-element-text", style: {
|
|
11
17
|
position: 'absolute',
|
|
12
18
|
top: `${elementInfo.top}px`,
|
|
@@ -25,6 +31,9 @@ function BaseTextElement({ elementInfo, target }) {
|
|
|
25
31
|
justifyContent,
|
|
26
32
|
}, children: jsxs("div", { className: "element-content slide-renderer-prose", style: {
|
|
27
33
|
position: 'relative',
|
|
34
|
+
boxSizing: 'border-box',
|
|
35
|
+
padding: '10px',
|
|
36
|
+
overflowWrap: 'break-word',
|
|
28
37
|
width: elementInfo.vertical ? 'auto' : '100%',
|
|
29
38
|
height: elementInfo.vertical ? '100%' : 'auto',
|
|
30
39
|
textShadow: shadowStyle,
|
|
@@ -36,10 +45,7 @@ function BaseTextElement({ elementInfo, target }) {
|
|
|
36
45
|
...(elementInfo.paragraphSpace !== undefined
|
|
37
46
|
? { '--paragraphSpace': `${elementInfo.paragraphSpace}px` }
|
|
38
47
|
: null),
|
|
39
|
-
}, children: [jsx(ElementOutline, { width: elementInfo.width, height: elementInfo.height, outline: elementInfo.outline }),
|
|
40
|
-
position: 'relative',
|
|
41
|
-
pointerEvents: target === 'thumbnail' ? 'none' : undefined,
|
|
42
|
-
}, dangerouslySetInnerHTML: { __html: elementInfo.content } })] }) }) }));
|
|
48
|
+
}, children: [jsx(ElementOutline, { width: elementInfo.width, height: elementInfo.height, outline: elementInfo.outline }), renderContent?.(elementInfo, defaultContent) ?? defaultContent] }) }) }));
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
export { BaseTextElement };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseTextElement.js","sources":["../../../src/elements/text/BaseTextElement.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties } from 'react';\nimport type { PPTTextElement } from '@openmaic/dsl';\nimport { useElementShadow } from '../shared/useElementShadow';\nimport { ElementOutline } from '../shared/ElementOutline';\n\nexport interface BaseTextElementProps {\n elementInfo: PPTTextElement;\n target?: string;\n}\n\nexport function BaseTextElement({ elementInfo, target }: BaseTextElementProps) {\n const { shadowStyle } = useElementShadow(elementInfo.shadow);\n\n const vAlign = elementInfo.vAlign ?? 'top';\n const justifyContent =\n vAlign === 'middle' ? 'center' : vAlign === 'bottom' ? 'flex-end' : 'flex-start';\n\n return (\n <div\n className=\"base-element-text\"\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n }}\n >\n <div\n className=\"rotate-wrapper\"\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n // Fill the full text box and rotate it with the glyphs/outline.\n backgroundColor: elementInfo.fill,\n opacity: elementInfo.opacity,\n display: 'flex',\n flexDirection: 'column',\n justifyContent,\n }}\n >\n <div\n className=\"element-content slide-renderer-prose\"\n style={{\n position: 'relative',\n width: elementInfo.vertical ? 'auto' : '100%',\n height: elementInfo.vertical ? '100%' : 'auto',\n textShadow: shadowStyle,\n lineHeight: elementInfo.lineHeight,\n letterSpacing:\n elementInfo.wordSpace !== undefined ? `${elementInfo.wordSpace}px` : undefined,\n color: elementInfo.defaultColor,\n fontFamily: elementInfo.defaultFontName,\n writingMode: elementInfo.vertical ? 'vertical-rl' : 'horizontal-tb',\n ...(elementInfo.paragraphSpace !== undefined\n ? ({ '--paragraphSpace': `${elementInfo.paragraphSpace}px` } as CSSProperties)\n : null),\n }}\n >\n <ElementOutline\n width={elementInfo.width}\n height={elementInfo.height}\n outline={elementInfo.outline}\n />\n
|
|
1
|
+
{"version":3,"file":"BaseTextElement.js","sources":["../../../src/elements/text/BaseTextElement.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode } from 'react';\nimport type { PPTTextElement } from '@openmaic/dsl';\nimport { useElementShadow } from '../shared/useElementShadow';\nimport { ElementOutline } from '../shared/ElementOutline';\nimport { preservesPlainTextLineBreaks } from '../../utils/richText';\n\nexport interface BaseTextElementProps {\n elementInfo: PPTTextElement;\n target?: string;\n renderContent?: (element: PPTTextElement, defaultContent: ReactNode) => ReactNode;\n}\n\nexport function BaseTextElement({ elementInfo, target, renderContent }: BaseTextElementProps) {\n const { shadowStyle } = useElementShadow(elementInfo.shadow);\n\n const vAlign = elementInfo.vAlign ?? 'top';\n const justifyContent =\n vAlign === 'middle' ? 'center' : vAlign === 'bottom' ? 'flex-end' : 'flex-start';\n const defaultContent = (\n <div\n className=\"text ProseMirror-static\"\n style={{\n position: 'relative',\n pointerEvents: target === 'thumbnail' ? 'none' : undefined,\n whiteSpace: preservesPlainTextLineBreaks(elementInfo.content) ? 'pre-line' : undefined,\n }}\n dangerouslySetInnerHTML={{ __html: elementInfo.content }}\n />\n );\n\n return (\n <div\n className=\"base-element-text\"\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n }}\n >\n <div\n className=\"rotate-wrapper\"\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n // Fill the full text box and rotate it with the glyphs/outline.\n backgroundColor: elementInfo.fill,\n opacity: elementInfo.opacity,\n display: 'flex',\n flexDirection: 'column',\n justifyContent,\n }}\n >\n <div\n className=\"element-content slide-renderer-prose\"\n style={{\n position: 'relative',\n boxSizing: 'border-box',\n padding: '10px',\n overflowWrap: 'break-word',\n width: elementInfo.vertical ? 'auto' : '100%',\n height: elementInfo.vertical ? '100%' : 'auto',\n textShadow: shadowStyle,\n lineHeight: elementInfo.lineHeight,\n letterSpacing:\n elementInfo.wordSpace !== undefined ? `${elementInfo.wordSpace}px` : undefined,\n color: elementInfo.defaultColor,\n fontFamily: elementInfo.defaultFontName,\n writingMode: elementInfo.vertical ? 'vertical-rl' : 'horizontal-tb',\n ...(elementInfo.paragraphSpace !== undefined\n ? ({ '--paragraphSpace': `${elementInfo.paragraphSpace}px` } as CSSProperties)\n : null),\n }}\n >\n <ElementOutline\n width={elementInfo.width}\n height={elementInfo.height}\n outline={elementInfo.outline}\n />\n {renderContent?.(elementInfo, defaultContent) ?? defaultContent}\n </div>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;AAcM;;AAGJ;;;AAOM;;AAEA;;AAMN;AAIM;AACA;AACA;AACA;AACA;AACD;AAKG;AACA;AACA;;;;AAIA;AACA;;AAED;AAKG;AACA;AACA;AACA;;;AAGA;;AAEA;;;;AAKA;;;AAGD;AAYX;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
function BaseVideoElement({ elementInfo, renderVideo, interactive = true, }) {
|
|
5
|
-
return (jsx("div", { className: "element-content", "data-video-element": true, style: {
|
|
5
|
+
return (jsx("div", { className: "base-element-video element-content", "data-video-element": true, style: {
|
|
6
6
|
position: 'absolute',
|
|
7
7
|
top: `${elementInfo.top}px`,
|
|
8
8
|
left: `${elementInfo.left}px`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseVideoElement.js","sources":["../../../src/elements/video/BaseVideoElement.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport type { PPTVideoElement } from '@openmaic/dsl';\n\nexport interface BaseVideoElementProps {\n elementInfo: PPTVideoElement;\n /**\n * Optional render slot: replace the default <video> with custom content.\n * Lets consumers inject placeholders, retry UI, lazy media resolvers, or\n * controlled playback bound to their own orchestration state.\n * When omitted, the package renders a plain <video src controls preload=\"metadata\">.\n */\n renderVideo?: (element: PPTVideoElement) => ReactNode;\n /** Enable pointer interaction for native controls or host-provided video UI. */\n interactive?: boolean;\n}\n\nexport function BaseVideoElement({\n elementInfo,\n renderVideo,\n interactive = true,\n}: BaseVideoElementProps) {\n return (\n <div\n className=\"element-content\"\n data-video-element\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n pointerEvents: interactive ? 'auto' : 'none',\n }}\n onClick={interactive ? (e) => e.stopPropagation() : undefined}\n onPointerDown={interactive ? (e) => e.stopPropagation() : undefined}\n >\n <div\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n }}\n >\n {renderVideo ? (\n renderVideo(elementInfo)\n ) : elementInfo.src || elementInfo.poster ? (\n // Render <video> when we have either a playable src OR just a\n // poster/preview frame. A PPTX「视频」often has no decodable src in\n // this pipeline but does carry a preview image; rendering\n // <video poster> still shows that frame on the live canvas (instead\n // of falling through to the gray play-icon placeholder — slide 34).\n // Snapshot capture of the poster frame is handled in slideToPng\n // (html2canvas can't draw <video> directly).\n <video\n style={{ width: '100%', height: '100%', objectFit: 'contain' }}\n {...(elementInfo.src ? { src: elementInfo.src } : {})}\n poster={elementInfo.poster}\n preload=\"metadata\"\n controls={!!elementInfo.src}\n />\n ) : (\n <div\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'rgba(0, 0, 0, 0.1)',\n borderRadius: '4px',\n }}\n >\n <svg\n style={{ width: '48px', height: '48px', color: '#9ca3af' }}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.5}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polygon points=\"5 3 19 12 5 21 5 3\" />\n </svg>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;AAkBM;AAKJ;AAKM;AACA;AACA;AACA;AACA;;AAED;AAMG;AACA;AACA;;;;;;;;;AAaA;AAUI;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBd;;"}
|
|
1
|
+
{"version":3,"file":"BaseVideoElement.js","sources":["../../../src/elements/video/BaseVideoElement.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport type { PPTVideoElement } from '@openmaic/dsl';\n\nexport interface BaseVideoElementProps {\n elementInfo: PPTVideoElement;\n /**\n * Optional render slot: replace the default <video> with custom content.\n * Lets consumers inject placeholders, retry UI, lazy media resolvers, or\n * controlled playback bound to their own orchestration state.\n * When omitted, the package renders a plain <video src controls preload=\"metadata\">.\n */\n renderVideo?: (element: PPTVideoElement) => ReactNode;\n /** Enable pointer interaction for native controls or host-provided video UI. */\n interactive?: boolean;\n}\n\nexport function BaseVideoElement({\n elementInfo,\n renderVideo,\n interactive = true,\n}: BaseVideoElementProps) {\n return (\n <div\n className=\"base-element-video element-content\"\n data-video-element\n style={{\n position: 'absolute',\n top: `${elementInfo.top}px`,\n left: `${elementInfo.left}px`,\n width: `${elementInfo.width}px`,\n height: `${elementInfo.height}px`,\n pointerEvents: interactive ? 'auto' : 'none',\n }}\n onClick={interactive ? (e) => e.stopPropagation() : undefined}\n onPointerDown={interactive ? (e) => e.stopPropagation() : undefined}\n >\n <div\n style={{\n width: '100%',\n height: '100%',\n transform: `rotate(${elementInfo.rotate}deg)`,\n }}\n >\n {renderVideo ? (\n renderVideo(elementInfo)\n ) : elementInfo.src || elementInfo.poster ? (\n // Render <video> when we have either a playable src OR just a\n // poster/preview frame. A PPTX「视频」often has no decodable src in\n // this pipeline but does carry a preview image; rendering\n // <video poster> still shows that frame on the live canvas (instead\n // of falling through to the gray play-icon placeholder — slide 34).\n // Snapshot capture of the poster frame is handled in slideToPng\n // (html2canvas can't draw <video> directly).\n <video\n style={{ width: '100%', height: '100%', objectFit: 'contain' }}\n {...(elementInfo.src ? { src: elementInfo.src } : {})}\n poster={elementInfo.poster}\n preload=\"metadata\"\n controls={!!elementInfo.src}\n />\n ) : (\n <div\n style={{\n width: '100%',\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'rgba(0, 0, 0, 0.1)',\n borderRadius: '4px',\n }}\n >\n <svg\n style={{ width: '48px', height: '48px', color: '#9ca3af' }}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.5}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polygon points=\"5 3 19 12 5 21 5 3\" />\n </svg>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;AAkBM;AAKJ;AAKM;AACA;AACA;AACA;AACA;;AAED;AAMG;AACA;AACA;;;;;;;;;AAaA;AAUI;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBd;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export { useSlideBackgroundStyle } from './hooks/useSlideBackgroundStyle';
|
|
|
6
6
|
export { useViewportSize, type ViewportStyles, type UseViewportSizeOptions, type UseViewportSizeResult, } from './hooks/useViewportSize';
|
|
7
7
|
export { findElementGeometry, findNearestCorner, getElementPercentageGeometry, type PercentageGeometry, } from './utils/geometry';
|
|
8
8
|
export { cn } from './utils/cn';
|
|
9
|
+
export { getElementRange, getLineElementPath, getTableSubThemeColor } from './utils/element';
|
|
9
10
|
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,6 @@ export { useSlideBackgroundStyle } from './hooks/useSlideBackgroundStyle.js';
|
|
|
9
9
|
export { useViewportSize } from './hooks/useViewportSize.js';
|
|
10
10
|
export { findElementGeometry, findNearestCorner, getElementPercentageGeometry } from './utils/geometry.js';
|
|
11
11
|
export { cn } from './utils/cn.js';
|
|
12
|
+
export { getElementRange, getLineElementPath, getTableSubThemeColor } from './utils/element.js';
|
|
12
13
|
export * from '@openmaic/dsl';
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
package/dist/styles.d.ts
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
* keyframes, pseudo-classes). Rendered once via `<style>` at the top of
|
|
4
4
|
* `<SlideCanvas>` so the package stays self-contained without Tailwind.
|
|
5
5
|
*
|
|
6
|
-
* The `.slide-renderer-prose` rules
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `--paragraphSpace` CSS variable, which is unset when undefined in data.
|
|
6
|
+
* The `.slide-renderer-prose` rules undo host and user-agent defaults so the
|
|
7
|
+
* slide JSON is the single source of truth. Paragraph spacing comes from the
|
|
8
|
+
* `--paragraphSpace` CSS variable. List rules restore semantic markers that
|
|
9
|
+
* host resets such as Tailwind Preflight remove.
|
|
11
10
|
*/
|
|
12
|
-
export declare const SLIDE_RENDERER_STYLES = "\n.slide-renderer-prose p {\n margin-top: 0;\n margin-bottom: var(--paragraphSpace, 0);\n}\n.slide-renderer-prose p:last-child {\n margin-bottom: 0;\n}\n.slide-renderer-prose .katex-display {\n margin: 0 !important;\n}\n/* Table cell inner container \u2014 matches the classroom (Vue) .cell-text design:\n tight base line-height, and a small spacing between adjacent <p> siblings\n so multi-paragraph cells don't collapse into a single visual block. The\n <p> margin reset above sets the baseline to 0; this rule re-adds spacing\n only between adjacent siblings, leaving the first/last paragraph flush. */\n.slide-renderer-cell-text p + p {\n margin-top: 0.4em;\n}\n@keyframes slide-renderer-pulse {\n 50% { opacity: 0.5; }\n}\n@keyframes slide-renderer-ping {\n 75%, 100% { transform: scale(2); opacity: 0; }\n}\n@keyframes slide-renderer-code-cursor-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0; }\n}\n.slide-renderer-pulse {\n animation: slide-renderer-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n}\n.slide-renderer-ping {\n animation: slide-renderer-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n}\n";
|
|
11
|
+
export declare const SLIDE_RENDERER_STYLES = "\n.slide-renderer-prose p {\n margin-top: 0;\n margin-bottom: var(--paragraphSpace, 0);\n}\n.slide-renderer-prose p:last-child {\n margin-bottom: 0;\n}\n.slide-renderer-prose p:empty::before {\n content: '\\00a0';\n}\n.slide-renderer-prose .katex-display {\n margin: 0 !important;\n}\n.slide-renderer-prose ul {\n list-style-position: outside !important;\n padding-inline-start: 1.5rem !important;\n}\n.slide-renderer-prose ul:not([style*=\"list-style-type\"]) {\n list-style-type: disc !important;\n}\n.slide-renderer-prose ol {\n list-style-position: outside !important;\n padding-inline-start: 1.5rem !important;\n}\n.slide-renderer-prose ol:not([style*=\"list-style-type\"]) {\n list-style-type: decimal !important;\n}\n.slide-renderer-prose li {\n display: list-item !important;\n}\n/* Table cell inner container \u2014 matches the classroom (Vue) .cell-text design:\n tight base line-height, and a small spacing between adjacent <p> siblings\n so multi-paragraph cells don't collapse into a single visual block. The\n <p> margin reset above sets the baseline to 0; this rule re-adds spacing\n only between adjacent siblings, leaving the first/last paragraph flush. */\n.slide-renderer-cell-text p + p {\n margin-top: 0.4em;\n}\n@keyframes slide-renderer-pulse {\n 50% { opacity: 0.5; }\n}\n@keyframes slide-renderer-ping {\n 75%, 100% { transform: scale(2); opacity: 0; }\n}\n@keyframes slide-renderer-code-cursor-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0; }\n}\n.slide-renderer-pulse {\n animation: slide-renderer-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n}\n.slide-renderer-ping {\n animation: slide-renderer-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n}\n";
|
package/dist/styles.js
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
* keyframes, pseudo-classes). Rendered once via `<style>` at the top of
|
|
4
4
|
* `<SlideCanvas>` so the package stays self-contained without Tailwind.
|
|
5
5
|
*
|
|
6
|
-
* The `.slide-renderer-prose` rules
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `--paragraphSpace` CSS variable, which is unset when undefined in data.
|
|
6
|
+
* The `.slide-renderer-prose` rules undo host and user-agent defaults so the
|
|
7
|
+
* slide JSON is the single source of truth. Paragraph spacing comes from the
|
|
8
|
+
* `--paragraphSpace` CSS variable. List rules restore semantic markers that
|
|
9
|
+
* host resets such as Tailwind Preflight remove.
|
|
11
10
|
*/
|
|
12
11
|
const SLIDE_RENDERER_STYLES = `
|
|
13
12
|
.slide-renderer-prose p {
|
|
@@ -17,9 +16,29 @@ const SLIDE_RENDERER_STYLES = `
|
|
|
17
16
|
.slide-renderer-prose p:last-child {
|
|
18
17
|
margin-bottom: 0;
|
|
19
18
|
}
|
|
19
|
+
.slide-renderer-prose p:empty::before {
|
|
20
|
+
content: '\\00a0';
|
|
21
|
+
}
|
|
20
22
|
.slide-renderer-prose .katex-display {
|
|
21
23
|
margin: 0 !important;
|
|
22
24
|
}
|
|
25
|
+
.slide-renderer-prose ul {
|
|
26
|
+
list-style-position: outside !important;
|
|
27
|
+
padding-inline-start: 1.5rem !important;
|
|
28
|
+
}
|
|
29
|
+
.slide-renderer-prose ul:not([style*="list-style-type"]) {
|
|
30
|
+
list-style-type: disc !important;
|
|
31
|
+
}
|
|
32
|
+
.slide-renderer-prose ol {
|
|
33
|
+
list-style-position: outside !important;
|
|
34
|
+
padding-inline-start: 1.5rem !important;
|
|
35
|
+
}
|
|
36
|
+
.slide-renderer-prose ol:not([style*="list-style-type"]) {
|
|
37
|
+
list-style-type: decimal !important;
|
|
38
|
+
}
|
|
39
|
+
.slide-renderer-prose li {
|
|
40
|
+
display: list-item !important;
|
|
41
|
+
}
|
|
23
42
|
/* Table cell inner container — matches the classroom (Vue) .cell-text design:
|
|
24
43
|
tight base line-height, and a small spacing between adjacent <p> siblings
|
|
25
44
|
so multi-paragraph cells don't collapse into a single visual block. The
|
package/dist/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../src/styles.ts"],"sourcesContent":["/**\n * Package-level CSS rules that can't be expressed inline (descendant selectors,\n * keyframes, pseudo-classes). Rendered once via `<style>` at the top of\n * `<SlideCanvas>` so the package stays self-contained without Tailwind.\n *\n * The `.slide-renderer-prose` rules
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../src/styles.ts"],"sourcesContent":["/**\n * Package-level CSS rules that can't be expressed inline (descendant selectors,\n * keyframes, pseudo-classes). Rendered once via `<style>` at the top of\n * `<SlideCanvas>` so the package stays self-contained without Tailwind.\n *\n * The `.slide-renderer-prose` rules undo host and user-agent defaults so the\n * slide JSON is the single source of truth. Paragraph spacing comes from the\n * `--paragraphSpace` CSS variable. List rules restore semantic markers that\n * host resets such as Tailwind Preflight remove.\n */\nexport const SLIDE_RENDERER_STYLES = `\n.slide-renderer-prose p {\n margin-top: 0;\n margin-bottom: var(--paragraphSpace, 0);\n}\n.slide-renderer-prose p:last-child {\n margin-bottom: 0;\n}\n.slide-renderer-prose p:empty::before {\n content: '\\\\00a0';\n}\n.slide-renderer-prose .katex-display {\n margin: 0 !important;\n}\n.slide-renderer-prose ul {\n list-style-position: outside !important;\n padding-inline-start: 1.5rem !important;\n}\n.slide-renderer-prose ul:not([style*=\"list-style-type\"]) {\n list-style-type: disc !important;\n}\n.slide-renderer-prose ol {\n list-style-position: outside !important;\n padding-inline-start: 1.5rem !important;\n}\n.slide-renderer-prose ol:not([style*=\"list-style-type\"]) {\n list-style-type: decimal !important;\n}\n.slide-renderer-prose li {\n display: list-item !important;\n}\n/* Table cell inner container — matches the classroom (Vue) .cell-text design:\n tight base line-height, and a small spacing between adjacent <p> siblings\n so multi-paragraph cells don't collapse into a single visual block. The\n <p> margin reset above sets the baseline to 0; this rule re-adds spacing\n only between adjacent siblings, leaving the first/last paragraph flush. */\n.slide-renderer-cell-text p + p {\n margin-top: 0.4em;\n}\n@keyframes slide-renderer-pulse {\n 50% { opacity: 0.5; }\n}\n@keyframes slide-renderer-ping {\n 75%, 100% { transform: scale(2); opacity: 0; }\n}\n@keyframes slide-renderer-code-cursor-blink {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0; }\n}\n.slide-renderer-pulse {\n animation: slide-renderer-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n}\n.slide-renderer-ping {\n animation: slide-renderer-ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n}\n`;\n"],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AACI,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function preservesPlainTextLineBreaks(content: string): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `content` is an HTML-string contract. Only markup-free values can safely use
|
|
3
|
+
* `white-space: pre-line`: a newline between rich HTML block tags is source
|
|
4
|
+
* formatting, not visible slide content.
|
|
5
|
+
*/
|
|
6
|
+
const HTML_MARKUP_PATTERN = /<\/?[a-z][^>]*>|<![^>]*>/i;
|
|
7
|
+
function preservesPlainTextLineBreaks(content) {
|
|
8
|
+
return !HTML_MARKUP_PATTERN.test(content);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { preservesPlainTextLineBreaks };
|
|
12
|
+
//# sourceMappingURL=richText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"richText.js","sources":["../../src/utils/richText.ts"],"sourcesContent":["/**\n * `content` is an HTML-string contract. Only markup-free values can safely use\n * `white-space: pre-line`: a newline between rich HTML block tags is source\n * formatting, not visible slide content.\n */\nconst HTML_MARKUP_PATTERN = /<\\/?[a-z][^>]*>|<![^>]*>/i;\n\nexport function preservesPlainTextLineBreaks(content: string): boolean {\n return !HTML_MARKUP_PATTERN.test(content);\n}\n"],"names":[],"mappings":"AAAA;;;;AAIG;AACH,MAAM,mBAAmB,GAAG,2BAA2B;AAEjD,SAAU,4BAA4B,CAAC,OAAe,EAAA;AAC1D,IAAA,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC;AAC3C;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmaic/renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React component for rendering PPTist-style Slide JSON, extracted from OpenMAIC.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
"types": "./dist/snapshot/index.d.ts",
|
|
24
24
|
"import": "./dist/snapshot/index.js"
|
|
25
25
|
},
|
|
26
|
-
"./editing": {
|
|
27
|
-
"types": "./dist/editing/index.d.ts",
|
|
28
|
-
"import": "./dist/editing/index.js"
|
|
29
|
-
},
|
|
30
26
|
"./fonts.css": "./fonts.css"
|
|
31
27
|
},
|
|
32
28
|
"files": [
|
|
@@ -79,7 +75,7 @@
|
|
|
79
75
|
"lucide-react": "^0.562.0",
|
|
80
76
|
"tailwind-merge": "^3.4.0",
|
|
81
77
|
"tinycolor2": "^1.6.0",
|
|
82
|
-
"@openmaic/dsl": "^0.
|
|
78
|
+
"@openmaic/dsl": "^0.9.0"
|
|
83
79
|
},
|
|
84
80
|
"devDependencies": {
|
|
85
81
|
"@rollup/plugin-commonjs": "^28.0.1",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type EditableSlideCanvasProps } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* EditableSlideCanvas — the renderer v2 editing surface. It renders the
|
|
4
|
-
* controlled document through the v1 read-only {@link SlideCanvas} (whose
|
|
5
|
-
* render path is left untouched) and layers its own interaction surface on top:
|
|
6
|
-
* a per-element hit layer that arms drag/click gestures, and a
|
|
7
|
-
* {@link SelectionOverlay} driven by the controlled `selection`.
|
|
8
|
-
*
|
|
9
|
-
* Gestures are owned by {@link useEditGesture}: pointer-down + drag produces a
|
|
10
|
-
* live working copy for 60fps feedback and, on pointer-up past a small
|
|
11
|
-
* threshold, emits exactly one `element.update` intent via `onElementsChange`;
|
|
12
|
-
* a click with no movement reports selection via `onSelectionChange` only.
|
|
13
|
-
* Alignment guides are computed but not drawn in this PR.
|
|
14
|
-
*
|
|
15
|
-
* The interaction layer is a sibling overlay (same origin, positions scaled by
|
|
16
|
-
* `canvasScale`) so the v1 fill/render contract is preserved unmodified. When
|
|
17
|
-
* `scale` is omitted the canvas auto-fits: the overlay reads the SAME
|
|
18
|
-
* `fitScale` SlideCanvas uses (both measure the same box — see the inner
|
|
19
|
-
* wrapper below), so overlay and elements stay aligned at auto-fit.
|
|
20
|
-
* `renderImage`/`renderVideo`/`className`/`style` pass through.
|
|
21
|
-
*
|
|
22
|
-
* The interaction hit layer is only mounted when a mutation/selection callback
|
|
23
|
-
* is provided; with neither, the canvas renders read-only (no pointer-capturing
|
|
24
|
-
* hit targets), matching the Stage-0 inert-without-callbacks contract.
|
|
25
|
-
*/
|
|
26
|
-
export declare function EditableSlideCanvas(props: EditableSlideCanvasProps): import("react/jsx-runtime").JSX.Element;
|