@@ -895,6 +895,24 @@ const parseAndRebuildDataProps = () => {
895
895
} ;
896
896
} ;
897
897
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
+
898
916
export default function LayoutRenderer ( {
899
917
runApp,
900
918
runProcessor,
@@ -904,7 +922,12 @@ export default function LayoutRenderer({
904
922
} ) {
905
923
const memoizedRemarkPlugins = useMemo ( ( ) => [ remarkGfm ] , [ ] ) ;
906
924
const memoizedRehypePlugins = useMemo (
907
- ( ) => [ rehypeRaw , parseAndRebuildSxProps , parseAndRebuildDataProps ] ,
925
+ ( ) => [
926
+ rehypeRaw ,
927
+ parseAndRebuildSxProps ,
928
+ parseAndRebuildDataProps ,
929
+ parseAndRebuildPTags ,
930
+ ] ,
908
931
[ ] ,
909
932
) ;
910
933
const memoizedRunApp = useCallback ( runApp , [ runApp ] ) ;
@@ -926,6 +949,22 @@ export default function LayoutRenderer({
926
949
"promptly-web-browser-embed" : memo ( ( { node, ...props } ) => {
927
950
return < RemoteBrowserEmbed wsUrl = { props ?. wsurl } /> ;
928
951
} ) ,
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
+ ) ,
929
968
"pa-layout" : memo (
930
969
( { node, ...props } ) => {
931
970
return < Box { ...props } > { props . children } </ Box > ;
0 commit comments