@openmaic/renderer 0.1.7 → 0.1.8
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.
|
@@ -6,6 +6,13 @@ import { preservesPlainTextLineBreaks } from '../../utils/richText.js';
|
|
|
6
6
|
|
|
7
7
|
function BaseTextElement({ elementInfo, target, renderContent }) {
|
|
8
8
|
const { shadowStyle } = useElementShadow(elementInfo.shadow);
|
|
9
|
+
// Imported OOXML text carries its own bodyPr insets on the outer div.
|
|
10
|
+
// Adding the editor's default inset again shifts vertical text left and
|
|
11
|
+
// reduces the available line width for horizontal text.
|
|
12
|
+
const hasExplicitTextInsets = /^\s*<div\b[^>]*\sdata-pptx-text-insets\s*=\s*(["'])true\1/i.test(elementInfo.content);
|
|
13
|
+
// Legacy saved slides predate the marker. Retain their existing inset behavior.
|
|
14
|
+
const hasTextInsets = hasExplicitTextInsets ||
|
|
15
|
+
/^\s*<div\b[^>]*\bstyle\s*=\s*["'][^"']*\bpadding\s*:/i.test(elementInfo.content);
|
|
9
16
|
const vAlign = elementInfo.vAlign ?? 'top';
|
|
10
17
|
const justifyContent = vAlign === 'middle' ? 'center' : vAlign === 'bottom' ? 'flex-end' : 'flex-start';
|
|
11
18
|
const defaultContent = (jsx("div", { className: "text ProseMirror-static", style: {
|
|
@@ -32,7 +39,7 @@ function BaseTextElement({ elementInfo, target, renderContent }) {
|
|
|
32
39
|
}, children: jsxs("div", { className: "element-content slide-renderer-prose", style: {
|
|
33
40
|
position: 'relative',
|
|
34
41
|
boxSizing: 'border-box',
|
|
35
|
-
padding: '10px',
|
|
42
|
+
padding: hasTextInsets ? 0 : '10px',
|
|
36
43
|
overflowWrap: 'break-word',
|
|
37
44
|
width: elementInfo.vertical ? 'auto' : '100%',
|
|
38
45
|
height: elementInfo.vertical ? '100%' : 'auto',
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 // Imported OOXML text carries its own bodyPr insets on the outer div.\n // Adding the editor's default inset again shifts vertical text left and\n // reduces the available line width for horizontal text.\n const hasExplicitTextInsets = /^\\s*<div\\b[^>]*\\sdata-pptx-text-insets\\s*=\\s*([\"'])true\\1/i.test(\n elementInfo.content,\n );\n // Legacy saved slides predate the marker. Retain their existing inset behavior.\n const hasTextInsets =\n hasExplicitTextInsets ||\n /^\\s*<div\\b[^>]*\\bstyle\\s*=\\s*[\"'][^\"']*\\bpadding\\s*:/i.test(elementInfo.content);\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: hasTextInsets ? 0 : '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;;;;;;;;AAWF;AAEF;;;AAOM;;AAEA;;AAMN;AAIM;AACA;AACA;AACA;AACA;AACD;AAKG;AACA;AACA;;;;AAIA;AACA;;AAED;AAKG;AACA;;AAEA;;;AAGA;;AAEA;;;;AAKA;;;AAGD;AAYX;;"}
|
package/dist/styles.js
CHANGED
|
@@ -56,7 +56,10 @@ ${createTextProseStyles('.slide-renderer-prose')}
|
|
|
56
56
|
so multi-paragraph cells don't collapse into a single visual block. The
|
|
57
57
|
<p> margin reset above sets the baseline to 0; this rule re-adds spacing
|
|
58
58
|
only between adjacent siblings, leaving the first/last paragraph flush. */
|
|
59
|
-
|
|
59
|
+
/* The editor adds a ProseMirror wrapper with its own paragraph reset. Keep
|
|
60
|
+
the same gap there with enough specificity to beat that reset. */
|
|
61
|
+
.slide-renderer-cell-text p + p,
|
|
62
|
+
.slide-renderer-cell-text .ProseMirror p + p {
|
|
60
63
|
margin-top: 0.4em;
|
|
61
64
|
}
|
|
62
65
|
@keyframes slide-renderer-pulse {
|
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 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
|
|
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/* The editor adds a ProseMirror wrapper with its own paragraph reset. Keep\n the same gap there with enough specificity to beat that reset. */\n.slide-renderer-cell-text p + p,\n.slide-renderer-cell-text .ProseMirror 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|