@@ -25,50 +25,21 @@ import { CONTEXT_OVERLAY_SUGGESTION } from "~/utils/predefinedSelections";
2525import { USE_REIFIED_RELATIONS } from "~/data/userSettings" ;
2626import { getSetting } from "~/utils/extensionSettings" ;
2727import { strictQueryForReifiedBlocks } from "~/utils/createReifiedBlock" ;
28- import internalError from "~/utils/internalError" ;
28+ import {
29+ RenderRoamBlock ,
30+ RenderRoamPage ,
31+ RenderRoamBlockString ,
32+ } from "~/utils/roamReactComponents" ;
2933
3034const EXTRA_ROW_TYPES = [ "context" , "discourse" ] as const ;
3135type ExtraRowType = ( typeof EXTRA_ROW_TYPES ) [ number ] | null ;
3236
3337const ExtraContextRow = ( { uid } : { uid : string } ) => {
34- const containerRef = useRef < HTMLDivElement > ( null ) ;
35-
36- useEffect ( ( ) => {
37- if ( ! containerRef . current ) return ;
38- if ( getPageTitleByPageUid ( uid ) ) {
39- window . roamAlphaAPI . ui . components
40- . renderPage ( {
41- uid,
42- el : containerRef . current ,
43- // eslint-disable-next-line @typescript-eslint/naming-convention
44- "hide-mentions?" : true ,
45- } )
46- . catch ( ( error ) => {
47- internalError ( {
48- error,
49- type : "Results Table: Extra Context Row" ,
50- context : { uid } ,
51- } ) ;
52- } ) ;
53- } else {
54- window . roamAlphaAPI . ui . components
55- . renderBlock ( {
56- uid,
57- el : containerRef . current ,
58- // eslint-disable-next-line @typescript-eslint/naming-convention
59- "zoom-path?" : true ,
60- } )
61- . catch ( ( error ) => {
62- internalError ( {
63- error,
64- type : "Results Table: Extra Context Row" ,
65- context : { uid } ,
66- } ) ;
67- } ) ;
68- }
69- } , [ containerRef , uid ] ) ;
70-
71- return < div ref = { containerRef } /> ;
38+ return getPageTitleByPageUid ( uid ) ? (
39+ < RenderRoamPage uid = { uid } hideMentions />
40+ ) : (
41+ < RenderRoamBlock uid = { uid } zoomPath />
42+ ) ;
7243} ;
7344
7445const dragImage = document . createElement ( "img" ) ;
@@ -181,30 +152,12 @@ export const CellEmbed = ({
181152 viewValue ?: string ;
182153} ) => {
183154 const title = getPageTitleByPageUid ( uid ) ;
184- const contentRef = useRef ( null ) ;
185- useEffect ( ( ) => {
186- const el = contentRef . current ;
187- const open =
188- viewValue === "open" ? true : viewValue === "closed" ? false : undefined ;
189- if ( el ) {
190- window . roamAlphaAPI . ui . components
191- . renderBlock ( {
192- uid,
193- el,
194- // eslint-disable-next-line @typescript-eslint/naming-convention
195- "open?" : open ,
196- } )
197- . catch ( ( error ) => {
198- internalError ( {
199- error,
200- type : "Results Table: Cell Embed" ,
201- context : { uid } ,
202- } ) ;
203- } ) ;
204- }
205- } , [ contentRef , uid , viewValue ] ) ;
155+ const open =
156+ viewValue === "open" ? true : viewValue === "closed" ? false : undefined ;
206157 return (
207- < div ref = { contentRef } className = { title ? "page-embed" : "block-embed" } />
158+ < div className = { title ? "page-embed" : "block-embed" } >
159+ < RenderRoamBlock uid = { uid } open = { open } />
160+ </ div >
208161 ) ;
209162} ;
210163
@@ -215,29 +168,14 @@ export const CellRender = ({
215168 content : string ;
216169 uid : string ;
217170} ) => {
218- const contentRef = useRef < HTMLSpanElement > ( null ) ;
219171 const isPage = ! ! getPageTitleByPageUid ( uid ) ;
220172 const displayString = isPage ? `[[${ content } ]]` : content ;
221173
222- useEffect ( ( ) => {
223- const el = contentRef . current ;
224- if ( el && displayString ) {
225- window . roamAlphaAPI . ui . components
226- . renderString ( {
227- el,
228- string : displayString ,
229- } )
230- . catch ( ( error ) => {
231- internalError ( {
232- error,
233- type : "Results Table: Cell Render" ,
234- context : { displayString } ,
235- } ) ;
236- } ) ;
237- }
238- } , [ displayString ] ) ;
239-
240- return < span ref = { contentRef } className = "roamjs-query-link-cell" /> ;
174+ return (
175+ < span className = "roamjs-query-link-cell" >
176+ < RenderRoamBlockString string = { displayString } />
177+ </ span >
178+ ) ;
241179} ;
242180
243181type ResultRowProps = {
0 commit comments