@@ -4,9 +4,10 @@ import { transformImageUrl, twoColumnFormatting } from '../utils';
44import rehypePrettyCode from 'rehype-pretty-code' ;
55import { usePrevious } from '../hooks/usePrevious' ;
66import { messageHandler } from '@estruyf/vscode/dist/client/webview' ;
7- import { WebViewMessages } from '../../constants' ;
7+ import { SlideTransition , WebViewMessages } from '../../constants' ;
88import { renderToString } from 'react-dom/server' ;
99import { convertTemplateToHtml } from '../../utils/convertTemplateToHtml' ;
10+ import { SlideMetadata } from '../../models' ;
1011
1112export interface IMarkdownProps {
1213 content ?: string ;
@@ -29,6 +30,7 @@ export const Markdown: React.FunctionComponent<IMarkdownProps> = ({
2930 const [ isReady , setIsReady ] = React . useState ( false ) ;
3031 const [ customTheme , setCustomTheme ] = React . useState < string | undefined > ( undefined ) ;
3132 const [ customLayout , setCustomLayout ] = React . useState < string | undefined > ( undefined ) ;
33+ const [ transition , setTransition ] = React . useState < SlideTransition | undefined > ( undefined ) ;
3234 const [ template , setTemplate ] = React . useState < string | undefined > ( undefined ) ;
3335
3436 const {
@@ -55,7 +57,7 @@ export const Markdown: React.FunctionComponent<IMarkdownProps> = ({
5557
5658 const prevMatter = usePrevious ( JSON . stringify ( matter ) ) ;
5759
58- const updateCustomLayout = React . useCallback ( ( layout : string , metadata : any ) => {
60+ const updateCustomLayout = React . useCallback ( ( metadata : SlideMetadata , layout ?: string ) => {
5961 if ( layout ) {
6062 messageHandler . request < string > ( WebViewMessages . toVscode . getFileContents , layout ) . then ( async ( templateHtml ) => {
6163 if ( templateHtml ) {
@@ -78,7 +80,7 @@ export const Markdown: React.FunctionComponent<IMarkdownProps> = ({
7880 }
7981 } , [ content , markdown ] ) ;
8082
81- const updateCustomThemePath = React . useCallback ( ( customThemePath : string ) => {
83+ const updateCustomThemePath = React . useCallback ( ( customThemePath ? : string ) => {
8284 if ( ! customThemePath ) {
8385 setCustomTheme ( undefined ) ;
8486 return ;
@@ -108,10 +110,11 @@ export const Markdown: React.FunctionComponent<IMarkdownProps> = ({
108110 setIsReady ( false ) ;
109111 setCustomLayout ( undefined ) ;
110112 setCustomTheme ( undefined ) ;
113+ setTransition ( matter ?. transition || undefined ) ;
111114 setTemplate ( undefined ) ;
112115
113116 const cLayout = matter ?. customLayout || undefined ;
114- updateCustomLayout ( cLayout , matter ) ;
117+ updateCustomLayout ( matter , cLayout ) ;
115118
116119 updateTheme ( matter ?. theme || "default" ) ;
117120 updateLayout ( cLayout || matter ?. layout || "default" ) ;
@@ -151,7 +154,7 @@ export const Markdown: React.FunctionComponent<IMarkdownProps> = ({
151154 < >
152155 { customTheme && < link href = { customTheme } rel = "stylesheet" /> }
153156
154- < div className = ' slide__content__custom' dangerouslySetInnerHTML = { { __html : template } } />
157+ < div className = { ` slide__content__custom ${ transition } ` } dangerouslySetInnerHTML = { { __html : template } } />
155158 </ >
156159 ) ;
157160 }
@@ -160,7 +163,7 @@ export const Markdown: React.FunctionComponent<IMarkdownProps> = ({
160163 < >
161164 { customTheme && < link href = { customTheme } rel = "stylesheet" /> }
162165
163- < div className = ' slide__content__inner' > { markdown } </ div >
166+ < div className = { ` slide__content__inner ${ transition } ` } > { markdown } </ div >
164167 </ >
165168 ) ;
166169} ;
0 commit comments