@@ -45,6 +45,7 @@ import { getSetting } from "~/utils/extensionSettings";
4545import DiscourseContextOverlay from "~/components/DiscourseContextOverlay" ;
4646import { getDiscourseNodeColors } from "~/utils/getDiscourseNodeColors" ;
4747import { render as renderToast } from "roamjs-components/components/Toast" ;
48+ import { RenderRoamBlockString } from "~/utils/roamReactComponents" ;
4849
4950const escapeRegExp = ( s : string ) => s . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, "\\$&" ) ;
5051
@@ -445,10 +446,6 @@ export class BaseDiscourseNodeUtil extends BaseBoxShapeUtil<DiscourseNodeShape>
445446
446447 const isEditing = this . editor . getEditingShapeId ( ) === shape . id ;
447448 // eslint-disable-next-line react-hooks/rules-of-hooks
448- const contentRef = useRef < HTMLDivElement > ( null ) ;
449- // eslint-disable-next-line react-hooks/rules-of-hooks
450- const [ loaded , setLoaded ] = useState ( "" ) ;
451- // eslint-disable-next-line react-hooks/rules-of-hooks
452449 const [ overlayMounted , setOverlayMounted ] = useState ( false ) ;
453450 // eslint-disable-next-line react-hooks/rules-of-hooks
454451 const dialogRenderedRef = useRef ( false ) ;
@@ -479,24 +476,9 @@ export class BaseDiscourseNodeUtil extends BaseBoxShapeUtil<DiscourseNodeShape>
479476 return null ;
480477 } , [ shape . type , shape . props . uid ] ) ;
481478
482- // eslint-disable-next-line react-hooks/rules-of-hooks
483- useEffect ( ( ) => {
484- if (
485- shape . props . uid !== loaded &&
486- ! isPageUid ( shape . props . uid ) &&
487- contentRef . current &&
488- isLiveBlock ( shape . props . uid )
489- ) {
490- window . roamAlphaAPI . ui . components . renderBlock ( {
491- el : contentRef . current ,
492- uid : shape . props . uid ,
493- } ) ;
494- // TODO: resize shape props once this is rendered
495- setLoaded ( shape . props . uid ) ;
496- }
497- } , [ setLoaded , loaded , contentRef , shape . props . uid ] ) ;
498-
499479 const { backgroundColor, textColor } = this . getColors ( ) ;
480+ const showEmbeddedRoamBlock =
481+ ! isPageUid ( shape . props . uid ) && isLiveBlock ( shape . props . uid ) ;
500482
501483 // eslint-disable-next-line react-hooks/rules-of-hooks
502484 useEffect ( ( ) => {
@@ -737,7 +719,6 @@ export class BaseDiscourseNodeUtil extends BaseBoxShapeUtil<DiscourseNodeShape>
737719 ) : null }
738720
739721 < div
740- ref = { contentRef }
741722 className = "relative"
742723 style = { {
743724 ...DEFAULT_STYLE_PROPS ,
@@ -760,10 +741,21 @@ export class BaseDiscourseNodeUtil extends BaseBoxShapeUtil<DiscourseNodeShape>
760741 />
761742 </ div >
762743 ) }
763- { alias
764- ? new RegExp ( alias ) . exec ( shape . props . title ) ?. [ 1 ] ||
765- shape . props . title
766- : shape . props . title }
744+ { showEmbeddedRoamBlock ? (
745+ < div className = "w-full min-w-0" >
746+ < RenderRoamBlockString
747+ key = { shape . props . uid }
748+ string = {
749+ getTextByBlockUid ( shape . props . uid ) || shape . props . title
750+ }
751+ />
752+ </ div >
753+ ) : alias ? (
754+ new RegExp ( alias ) . exec ( shape . props . title ) ?. [ 1 ] ||
755+ shape . props . title
756+ ) : (
757+ shape . props . title
758+ ) }
767759 </ div >
768760 </ div >
769761 </ HTMLContainer >
0 commit comments