@openmaic/renderer 0.1.1 → 0.1.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.
@@ -1,18 +1,22 @@
1
1
  const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmooth, stack, }) => {
2
2
  const textStyle = textColor ? { color: textColor } : {};
3
3
  const axisLine = textColor ? { lineStyle: { color: textColor } } : undefined;
4
- const axisLabel = textColor ? { color: textColor } : undefined;
4
+ const axisLabel = { show: true, color: textColor ?? '#333333' };
5
5
  const splitLine = lineColor ? { lineStyle: { color: lineColor } } : {};
6
- if (!Array.isArray(data?.series) || data.series.length === 0) {
6
+ if (!Array.isArray(data?.series) || data.series.length === 0 || !Array.isArray(data.labels)) {
7
7
  return null;
8
8
  }
9
+ const categoryAxisLabel = {
10
+ ...axisLabel,
11
+ interval: data.labels.length <= 8 ? 0 : 'auto',
12
+ };
9
13
  const legend = data.series.length > 1 ? { top: 'bottom', textStyle } : undefined;
10
14
  if (type === 'bar') {
11
15
  return {
12
16
  color: themeColors,
13
17
  textStyle,
14
18
  legend,
15
- xAxis: { type: 'category', data: data.labels, axisLine, axisLabel },
19
+ xAxis: { type: 'category', data: data.labels, axisLine, axisLabel: categoryAxisLabel },
16
20
  yAxis: { type: 'value', axisLine, axisLabel, splitLine },
17
21
  series: data.series.map((item, index) => {
18
22
  const seriesItem = {
@@ -33,7 +37,7 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
33
37
  color: themeColors,
34
38
  textStyle,
35
39
  legend,
36
- yAxis: { type: 'category', data: data.labels, axisLine, axisLabel },
40
+ yAxis: { type: 'category', data: data.labels, axisLine, axisLabel: categoryAxisLabel },
37
41
  xAxis: { type: 'value', axisLine, axisLabel, splitLine },
38
42
  series: data.series.map((item, index) => {
39
43
  const seriesItem = {
@@ -54,7 +58,7 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
54
58
  color: themeColors,
55
59
  textStyle,
56
60
  legend,
57
- xAxis: { type: 'category', data: data.labels, axisLine, axisLabel },
61
+ xAxis: { type: 'category', data: data.labels, axisLine, axisLabel: categoryAxisLabel },
58
62
  yAxis: { type: 'value', axisLine, axisLabel, splitLine },
59
63
  series: data.series.map((item, index) => {
60
64
  const seriesItem = {
@@ -119,7 +123,13 @@ const getChartOption = ({ type, data, themeColors, textColor, lineColor, lineSmo
119
123
  color: themeColors,
120
124
  textStyle,
121
125
  legend,
122
- xAxis: { type: 'category', boundaryGap: false, data: data.labels, axisLine, axisLabel },
126
+ xAxis: {
127
+ type: 'category',
128
+ boundaryGap: false,
129
+ data: data.labels,
130
+ axisLine,
131
+ axisLabel: categoryAxisLabel,
132
+ },
123
133
  yAxis: { type: 'value', axisLine, axisLabel, splitLine },
124
134
  series: data.series.map((item, index) => {
125
135
  const seriesItem = {
@@ -1 +1 @@
1
- {"version":3,"file":"chartOption.js","sources":["../../../src/elements/chart/chartOption.ts"],"sourcesContent":["import type { ComposeOption } from 'echarts/core';\nimport type {\n BarSeriesOption,\n LineSeriesOption,\n PieSeriesOption,\n ScatterSeriesOption,\n RadarSeriesOption,\n} from 'echarts/charts';\nimport type { ChartData, ChartType } from '@openmaic/dsl';\n\ntype EChartOption = ComposeOption<\n BarSeriesOption | LineSeriesOption | PieSeriesOption | ScatterSeriesOption | RadarSeriesOption\n>;\n\nexport interface ChartOptionPayload {\n type: ChartType;\n data: ChartData;\n themeColors: string[];\n textColor?: string;\n lineColor?: string;\n lineSmooth?: boolean;\n stack?: boolean;\n}\n\nexport const getChartOption = ({\n type,\n data,\n themeColors,\n textColor,\n lineColor,\n lineSmooth,\n stack,\n}: ChartOptionPayload): EChartOption | null => {\n const textStyle = textColor ? { color: textColor } : {};\n\n const axisLine = textColor ? { lineStyle: { color: textColor } } : undefined;\n const axisLabel = textColor ? { color: textColor } : undefined;\n const splitLine = lineColor ? { lineStyle: { color: lineColor } } : {};\n\n if (!Array.isArray(data?.series) || data.series.length === 0) {\n return null;\n }\n\n const legend = data.series.length > 1 ? { top: 'bottom' as const, textStyle } : undefined;\n\n if (type === 'bar') {\n return {\n color: themeColors,\n textStyle,\n legend,\n xAxis: { type: 'category', data: data.labels, axisLine, axisLabel },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: data.series.map((item, index) => {\n const seriesItem: BarSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'bar',\n label: { show: true },\n itemStyle: { borderRadius: [2, 2, 0, 0] },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'column') {\n return {\n color: themeColors,\n textStyle,\n legend,\n yAxis: { type: 'category', data: data.labels, axisLine, axisLabel },\n xAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: data.series.map((item, index) => {\n const seriesItem: BarSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'bar',\n label: { show: true },\n itemStyle: { borderRadius: [0, 2, 2, 0] },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'line') {\n return {\n color: themeColors,\n textStyle,\n legend,\n xAxis: { type: 'category', data: data.labels, axisLine, axisLabel },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: data.series.map((item, index) => {\n const seriesItem: LineSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'line',\n smooth: lineSmooth,\n label: { show: true },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'pie') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n return {\n color: themeColors,\n textStyle,\n legend: { top: 'bottom' as const, textStyle },\n series: [\n {\n data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),\n label: textColor ? { color: textColor } : {},\n type: 'pie',\n radius: '70%',\n emphasis: {\n itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' },\n label: { show: true, fontSize: 14, fontWeight: 'bold' },\n },\n },\n ],\n };\n }\n if (type === 'ring') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n return {\n color: themeColors,\n textStyle,\n legend: { top: 'bottom' as const, textStyle },\n series: [\n {\n data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),\n label: textColor ? { color: textColor } : {},\n type: 'pie',\n radius: ['40%', '70%'],\n padAngle: 1,\n avoidLabelOverlap: false,\n itemStyle: { borderRadius: 4 },\n emphasis: { label: { show: true, fontSize: 14, fontWeight: 'bold' } },\n },\n ],\n };\n }\n if (type === 'area') {\n return {\n color: themeColors,\n textStyle,\n legend,\n xAxis: { type: 'category', boundaryGap: false, data: data.labels, axisLine, axisLabel },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: data.series.map((item, index) => {\n const seriesItem: LineSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'line',\n areaStyle: {},\n label: { show: true },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'radar') {\n return {\n color: themeColors,\n textStyle,\n legend,\n radar: {\n indicator: data.labels.map((item) => ({ name: item })),\n splitLine,\n axisLine: lineColor ? { lineStyle: { color: lineColor } } : undefined,\n },\n series: [\n {\n data: data.series.map((item, index) => ({ value: item, name: data.legends[index] })),\n type: 'radar',\n },\n ],\n };\n }\n if (type === 'scatter') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n const formatedData: number[][] = [];\n for (let i = 0; i < series0.length; i++) {\n const x = series0[i];\n const y = data.series[1]?.[i] ?? x;\n formatedData.push([x, y]);\n }\n\n return {\n color: themeColors,\n textStyle,\n xAxis: { axisLine, axisLabel, splitLine },\n yAxis: { axisLine, axisLabel, splitLine },\n series: [{ symbolSize: 12, data: formatedData, type: 'scatter' }],\n };\n }\n\n return null;\n};\n"],"names":[],"mappings":"MAwBa,cAAc,GAAG,CAAC,EAC7B,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,SAAS,EACT,SAAS,EACT,UAAU,EACV,KAAK,GACc,KAAyB;AAC5C,IAA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file":"chartOption.js","sources":["../../../src/elements/chart/chartOption.ts"],"sourcesContent":["import type { ComposeOption } from 'echarts/core';\nimport type {\n BarSeriesOption,\n LineSeriesOption,\n PieSeriesOption,\n ScatterSeriesOption,\n RadarSeriesOption,\n} from 'echarts/charts';\nimport type { ChartData, ChartType } from '@openmaic/dsl';\n\ntype EChartOption = ComposeOption<\n BarSeriesOption | LineSeriesOption | PieSeriesOption | ScatterSeriesOption | RadarSeriesOption\n>;\n\nexport interface ChartOptionPayload {\n type: ChartType;\n data: ChartData;\n themeColors: string[];\n textColor?: string;\n lineColor?: string;\n lineSmooth?: boolean;\n stack?: boolean;\n}\n\nexport const getChartOption = ({\n type,\n data,\n themeColors,\n textColor,\n lineColor,\n lineSmooth,\n stack,\n}: ChartOptionPayload): EChartOption | null => {\n const textStyle = textColor ? { color: textColor } : {};\n\n const axisLine = textColor ? { lineStyle: { color: textColor } } : undefined;\n const axisLabel = { show: true, color: textColor ?? '#333333' };\n const splitLine = lineColor ? { lineStyle: { color: lineColor } } : {};\n\n if (!Array.isArray(data?.series) || data.series.length === 0 || !Array.isArray(data.labels)) {\n return null;\n }\n const categoryAxisLabel = {\n ...axisLabel,\n interval: data.labels.length <= 8 ? 0 : ('auto' as const),\n };\n\n const legend = data.series.length > 1 ? { top: 'bottom' as const, textStyle } : undefined;\n\n if (type === 'bar') {\n return {\n color: themeColors,\n textStyle,\n legend,\n xAxis: { type: 'category', data: data.labels, axisLine, axisLabel: categoryAxisLabel },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: data.series.map((item, index) => {\n const seriesItem: BarSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'bar',\n label: { show: true },\n itemStyle: { borderRadius: [2, 2, 0, 0] },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'column') {\n return {\n color: themeColors,\n textStyle,\n legend,\n yAxis: { type: 'category', data: data.labels, axisLine, axisLabel: categoryAxisLabel },\n xAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: data.series.map((item, index) => {\n const seriesItem: BarSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'bar',\n label: { show: true },\n itemStyle: { borderRadius: [0, 2, 2, 0] },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'line') {\n return {\n color: themeColors,\n textStyle,\n legend,\n xAxis: { type: 'category', data: data.labels, axisLine, axisLabel: categoryAxisLabel },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: data.series.map((item, index) => {\n const seriesItem: LineSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'line',\n smooth: lineSmooth,\n label: { show: true },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'pie') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n return {\n color: themeColors,\n textStyle,\n legend: { top: 'bottom' as const, textStyle },\n series: [\n {\n data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),\n label: textColor ? { color: textColor } : {},\n type: 'pie',\n radius: '70%',\n emphasis: {\n itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' },\n label: { show: true, fontSize: 14, fontWeight: 'bold' },\n },\n },\n ],\n };\n }\n if (type === 'ring') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n return {\n color: themeColors,\n textStyle,\n legend: { top: 'bottom' as const, textStyle },\n series: [\n {\n data: series0.map((item, index) => ({ value: item, name: data.labels[index] })),\n label: textColor ? { color: textColor } : {},\n type: 'pie',\n radius: ['40%', '70%'],\n padAngle: 1,\n avoidLabelOverlap: false,\n itemStyle: { borderRadius: 4 },\n emphasis: { label: { show: true, fontSize: 14, fontWeight: 'bold' } },\n },\n ],\n };\n }\n if (type === 'area') {\n return {\n color: themeColors,\n textStyle,\n legend,\n xAxis: {\n type: 'category',\n boundaryGap: false,\n data: data.labels,\n axisLine,\n axisLabel: categoryAxisLabel,\n },\n yAxis: { type: 'value', axisLine, axisLabel, splitLine },\n series: data.series.map((item, index) => {\n const seriesItem: LineSeriesOption = {\n data: item,\n name: data.legends[index],\n type: 'line',\n areaStyle: {},\n label: { show: true },\n };\n if (stack) seriesItem.stack = 'A';\n return seriesItem;\n }),\n };\n }\n if (type === 'radar') {\n return {\n color: themeColors,\n textStyle,\n legend,\n radar: {\n indicator: data.labels.map((item) => ({ name: item })),\n splitLine,\n axisLine: lineColor ? { lineStyle: { color: lineColor } } : undefined,\n },\n series: [\n {\n data: data.series.map((item, index) => ({ value: item, name: data.legends[index] })),\n type: 'radar',\n },\n ],\n };\n }\n if (type === 'scatter') {\n const series0 = data.series[0];\n if (!Array.isArray(series0)) return null;\n const formatedData: number[][] = [];\n for (let i = 0; i < series0.length; i++) {\n const x = series0[i];\n const y = data.series[1]?.[i] ?? x;\n formatedData.push([x, y]);\n }\n\n return {\n color: themeColors,\n textStyle,\n xAxis: { axisLine, axisLabel, splitLine },\n yAxis: { axisLine, axisLabel, splitLine },\n series: [{ symbolSize: 12, data: formatedData, type: 'scatter' }],\n };\n }\n\n return null;\n};\n"],"names":[],"mappings":"MAwBa,cAAc,GAAG,CAAC,EAC7B,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,SAAS,EACT,SAAS,EACT,UAAU,EACV,KAAK,GACc,KAAyB;AAC5C,IAAA,MAAM,SAAS,GAAG,SAAS,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE;AAEvD,IAAA,MAAM,QAAQ,GAAG,SAAS,GAAG,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,SAAS;AAC5E,IAAA,MAAM,SAAS,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,IAAI,SAAS,EAAE;AAC/D,IAAA,MAAM,SAAS,GAAG,SAAS,GAAG,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE;AAE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findNearestCorner, getElementPercentageGeometry, type PercentageGeometry, } from './utils/geometry';
8
8
  export { cn } from './utils/cn';
9
9
  export { getElementRange, getLineElementPath, getTableSubThemeColor } from './utils/element';
10
+ export { createTextProseStyles } from './styles';
10
11
  export * from './types';
package/dist/index.js CHANGED
@@ -10,5 +10,6 @@ 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
12
  export { getElementRange, getLineElementPath, getTableSubThemeColor } from './utils/element.js';
13
+ export { createTextProseStyles } from './styles.js';
13
14
  export * from '@openmaic/dsl';
14
15
  //# 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
@@ -8,4 +8,12 @@
8
8
  * `--paragraphSpace` CSS variable. List rules restore semantic markers that
9
9
  * host resets such as Tailwind Preflight remove.
10
10
  */
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";
11
+ /**
12
+ * Generates the reset rules that define rich-text geometry inside a slide.
13
+ *
14
+ * Both the static renderer and the ProseMirror editor need these exact rules:
15
+ * keeping the selector configurable lets them share one layout contract while
16
+ * retaining their different DOM roots.
17
+ */
18
+ export declare function createTextProseStyles(selector: string): string;
19
+ export declare const SLIDE_RENDERER_STYLES: string;
package/dist/styles.js CHANGED
@@ -8,37 +8,49 @@
8
8
  * `--paragraphSpace` CSS variable. List rules restore semantic markers that
9
9
  * host resets such as Tailwind Preflight remove.
10
10
  */
11
- const SLIDE_RENDERER_STYLES = `
12
- .slide-renderer-prose p {
11
+ /**
12
+ * Generates the reset rules that define rich-text geometry inside a slide.
13
+ *
14
+ * Both the static renderer and the ProseMirror editor need these exact rules:
15
+ * keeping the selector configurable lets them share one layout contract while
16
+ * retaining their different DOM roots.
17
+ */
18
+ function createTextProseStyles(selector) {
19
+ return `
20
+ ${selector} p {
13
21
  margin-top: 0;
14
22
  margin-bottom: var(--paragraphSpace, 0);
15
23
  }
16
- .slide-renderer-prose p:last-child {
24
+ ${selector} p:last-child {
17
25
  margin-bottom: 0;
18
26
  }
19
- .slide-renderer-prose p:empty::before {
27
+ ${selector} p:empty::before {
20
28
  content: '\\00a0';
21
29
  }
22
- .slide-renderer-prose .katex-display {
30
+ ${selector} .katex-display {
23
31
  margin: 0 !important;
24
32
  }
25
- .slide-renderer-prose ul {
33
+ ${selector} ul {
26
34
  list-style-position: outside !important;
27
35
  padding-inline-start: 1.5rem !important;
28
36
  }
29
- .slide-renderer-prose ul:not([style*="list-style-type"]) {
37
+ ${selector} ul:not([style*="list-style-type"]) {
30
38
  list-style-type: disc !important;
31
39
  }
32
- .slide-renderer-prose ol {
40
+ ${selector} ol {
33
41
  list-style-position: outside !important;
34
42
  padding-inline-start: 1.5rem !important;
35
43
  }
36
- .slide-renderer-prose ol:not([style*="list-style-type"]) {
44
+ ${selector} ol:not([style*="list-style-type"]) {
37
45
  list-style-type: decimal !important;
38
46
  }
39
- .slide-renderer-prose li {
47
+ ${selector} li {
40
48
  display: list-item !important;
41
49
  }
50
+ `;
51
+ }
52
+ const SLIDE_RENDERER_STYLES = `
53
+ ${createTextProseStyles('.slide-renderer-prose')}
42
54
  /* Table cell inner container — matches the classroom (Vue) .cell-text design:
43
55
  tight base line-height, and a small spacing between adjacent <p> siblings
44
56
  so multi-paragraph cells don't collapse into a single visual block. The
@@ -65,5 +77,5 @@ const SLIDE_RENDERER_STYLES = `
65
77
  }
66
78
  `;
67
79
 
68
- export { SLIDE_RENDERER_STYLES };
80
+ export { SLIDE_RENDERER_STYLES, createTextProseStyles };
69
81
  //# sourceMappingURL=styles.js.map
@@ -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 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
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 */\n/**\n * Generates the reset rules that define rich-text geometry inside a slide.\n *\n * Both the static renderer and the ProseMirror editor need these exact rules:\n * keeping the selector configurable lets them share one layout contract while\n * retaining their different DOM roots.\n */\nexport function createTextProseStyles(selector: string): string {\n return `\n${selector} p {\n margin-top: 0;\n margin-bottom: var(--paragraphSpace, 0);\n}\n${selector} p:last-child {\n margin-bottom: 0;\n}\n${selector} p:empty::before {\n content: '\\\\00a0';\n}\n${selector} .katex-display {\n margin: 0 !important;\n}\n${selector} ul {\n list-style-position: outside !important;\n padding-inline-start: 1.5rem !important;\n}\n${selector} ul:not([style*=\"list-style-type\"]) {\n list-style-type: disc !important;\n}\n${selector} ol {\n list-style-position: outside !important;\n padding-inline-start: 1.5rem !important;\n}\n${selector} ol:not([style*=\"list-style-type\"]) {\n list-style-type: decimal !important;\n}\n${selector} li {\n display: list-item !important;\n}\n`;\n}\n\nexport const SLIDE_RENDERER_STYLES = `\n${createTextProseStyles('.slide-renderer-prose')}\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;AACH;;;;;;AAMG;AACG,SAAU,qBAAqB,CAAC,QAAgB,EAAA;IACpD,OAAO;EACP,QAAQ,CAAA;;;;EAIR,QAAQ,CAAA;;;EAGR,QAAQ,CAAA;;;EAGR,QAAQ,CAAA;;;EAGR,QAAQ,CAAA;;;;EAIR,QAAQ,CAAA;;;EAGR,QAAQ,CAAA;;;;EAIR,QAAQ,CAAA;;;EAGR,QAAQ,CAAA;;;CAGT;AACD;AAEO,MAAM,qBAAqB,GAAG;EACnC,qBAAqB,CAAC,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmaic/renderer",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "React component for rendering PPTist-style Slide JSON, extracted from OpenMAIC.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -75,7 +75,7 @@
75
75
  "lucide-react": "^0.562.0",
76
76
  "tailwind-merge": "^3.4.0",
77
77
  "tinycolor2": "^1.6.0",
78
- "@openmaic/dsl": "^0.9.0"
78
+ "@openmaic/dsl": "^0.10.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@rollup/plugin-commonjs": "^28.0.1",