@@ -46,7 +46,6 @@ import AutocompleteInput from "roamjs-components/components/AutocompleteInput";
4646import { Result } from "roamjs-components/types/query-builder" ;
4747import fuzzy from "fuzzy" ;
4848import getAllReferencesOnPage from "~/utils/getAllReferencesOnPage" ;
49- import isDiscourseNode from "~/utils/isDiscourseNode" ;
5049import {
5150 DiscourseNodeShape ,
5251 DEFAULT_STYLE_PROPS ,
@@ -441,7 +440,7 @@ const ClipboardPageSection = ({
441440} ) => {
442441 const [ isOpen , setIsOpen ] = useState ( true ) ;
443442 const [ discourseNodes , setDiscourseNodes ] = useState <
444- Array < { uid : string ; text : string } >
443+ Array < { uid : string ; text : string ; type : string } >
445444 > ( [ ] ) ;
446445 const [ isLoading , setIsLoading ] = useState ( false ) ;
447446 const [ openSections , setOpenSections ] = useState < Record < string , boolean > > ( { } ) ;
@@ -465,9 +464,17 @@ const ClipboardPageSection = ({
465464 setIsLoading ( true ) ;
466465 try {
467466 const referencedPages = await getAllReferencesOnPage ( page . text ) ;
468- const nodes = referencedPages . filter ( ( refPage ) =>
469- isDiscourseNode ( refPage . uid ) ,
470- ) ;
467+ const nodes = referencedPages . flatMap ( ( refPage ) => {
468+ const discourseNode = findDiscourseNode ( { uid : refPage . uid } ) ;
469+ if ( ! discourseNode || discourseNode . backedBy === "default" ) return [ ] ;
470+ return [
471+ {
472+ uid : refPage . uid ,
473+ text : refPage . text ,
474+ type : discourseNode . text ,
475+ } ,
476+ ] ;
477+ } ) ;
471478 setDiscourseNodes ( nodes ) ;
472479 } catch ( error ) {
473480 internalError ( {
@@ -546,11 +553,10 @@ const ClipboardPageSection = ({
546553 const groupedNodes = useMemo ( ( ) => {
547554 const groups : NodeGroup [ ] = discourseNodes . map ( ( node ) => {
548555 const shapes = shapesByUid . get ( node . uid ) ?? [ ] ;
549- const discourseNode = findDiscourseNode ( { uid : node . uid } ) ;
550556 return {
551557 uid : node . uid ,
552558 text : node . text ,
553- type : discourseNode ? discourseNode . text : "Unknown" ,
559+ type : node . type ,
554560 shapes,
555561 isDuplicate : shapes . length > 1 ,
556562 } ;
@@ -1244,29 +1250,34 @@ export const ClipboardPanel = () => {
12441250 < Popover
12451251 position = { Position . BOTTOM }
12461252 content = {
1247- < Menu >
1248- { availableNodeTypes . map ( ( type ) => (
1249- < MenuItem
1250- key = { type }
1251- active = { selectedNodeType === type }
1252- onClick = { ( ) => setSelectedNodeType ( type ) }
1253- text = {
1254- < span className = "flex items-center gap-2" >
1255- { type !== "All" && (
1256- < span
1257- className = "inline-block h-3 w-3 shrink-0 rounded-full"
1258- style = { {
1259- backgroundColor :
1260- nodeTypeColorMap [ type ] || "#000000" ,
1261- } }
1262- />
1263- ) }
1264- { type }
1265- </ span >
1266- }
1267- />
1268- ) ) }
1269- </ Menu >
1253+ < div
1254+ onPointerDown = { ( e ) => e . stopPropagation ( ) }
1255+ style = { { pointerEvents : "all" } }
1256+ >
1257+ < Menu >
1258+ { availableNodeTypes . map ( ( type ) => (
1259+ < MenuItem
1260+ key = { type }
1261+ active = { selectedNodeType === type }
1262+ onClick = { ( ) => setSelectedNodeType ( type ) }
1263+ text = {
1264+ < span className = "flex items-center gap-2" >
1265+ { type !== "All" && (
1266+ < span
1267+ className = "inline-block h-3 w-3 shrink-0 rounded-full"
1268+ style = { {
1269+ backgroundColor :
1270+ nodeTypeColorMap [ type ] || "#000000" ,
1271+ } }
1272+ />
1273+ ) }
1274+ { type }
1275+ </ span >
1276+ }
1277+ />
1278+ ) ) }
1279+ </ Menu >
1280+ </ div >
12701281 }
12711282 >
12721283 < Button
0 commit comments