@@ -895,6 +895,24 @@ const parseAndRebuildDataProps = () => {
895895 } ;
896896} ;
897897
898+ // A rephype plugin to replace p tags that are simply wrapped around pa-* elements with the pa-* element
899+ const parseAndRebuildPTags = ( ) => {
900+ return ( tree ) => {
901+ visit ( tree , ( node , index , parent ) => {
902+ if ( node && isElement ( node ) && node . tagName === "p" ) {
903+ if (
904+ node . children &&
905+ node . children . length === 1 &&
906+ isElement ( node . children [ 0 ] ) &&
907+ node . children [ 0 ] . tagName . startsWith ( "pa-" )
908+ ) {
909+ parent . children [ index ] = node . children [ 0 ] ;
910+ }
911+ }
912+ } ) ;
913+ } ;
914+ } ;
915+
898916export default function LayoutRenderer ( {
899917 runApp,
900918 runProcessor,
@@ -904,7 +922,12 @@ export default function LayoutRenderer({
904922} ) {
905923 const memoizedRemarkPlugins = useMemo ( ( ) => [ remarkGfm ] , [ ] ) ;
906924 const memoizedRehypePlugins = useMemo (
907- ( ) => [ rehypeRaw , parseAndRebuildSxProps , parseAndRebuildDataProps ] ,
925+ ( ) => [
926+ rehypeRaw ,
927+ parseAndRebuildSxProps ,
928+ parseAndRebuildDataProps ,
929+ parseAndRebuildPTags ,
930+ ] ,
908931 [ ] ,
909932 ) ;
910933 const memoizedRunApp = useCallback ( runApp , [ runApp ] ) ;
@@ -926,6 +949,22 @@ export default function LayoutRenderer({
926949 "promptly-web-browser-embed" : memo ( ( { node, ...props } ) => {
927950 return < RemoteBrowserEmbed wsUrl = { props ?. wsurl } /> ;
928951 } ) ,
952+ "pa-video-embed" : memo (
953+ ( { node, ...props } ) => {
954+ return (
955+ < Box sx = { props . sx || { } } >
956+ < iframe
957+ src = { props . src }
958+ width = { props . width || "100%" }
959+ height = { props . height || "100%" }
960+ allowFullScreen
961+ title = { props . title }
962+ />
963+ </ Box >
964+ ) ;
965+ } ,
966+ ( prev , next ) => prev . props === next . props ,
967+ ) ,
929968 "pa-layout" : memo (
930969 ( { node, ...props } ) => {
931970 return < Box { ...props } > { props . children } </ Box > ;
0 commit comments