@@ -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 } ;
@@ -1243,29 +1249,34 @@ export const ClipboardPanel = () => {
12431249 < Popover
12441250 position = { Position . BOTTOM }
12451251 content = {
1246- < Menu >
1247- { availableNodeTypes . map ( ( type ) => (
1248- < MenuItem
1249- key = { type }
1250- active = { selectedNodeType === type }
1251- onClick = { ( ) => setSelectedNodeType ( type ) }
1252- text = {
1253- < span className = "flex items-center gap-2" >
1254- { type !== "All" && (
1255- < span
1256- className = "inline-block h-3 w-3 shrink-0 rounded-full"
1257- style = { {
1258- backgroundColor :
1259- nodeTypeColorMap [ type ] || "#000000" ,
1260- } }
1261- />
1262- ) }
1263- { type }
1264- </ span >
1265- }
1266- />
1267- ) ) }
1268- </ Menu >
1252+ < div
1253+ onPointerDown = { ( e ) => e . stopPropagation ( ) }
1254+ style = { { pointerEvents : "all" } }
1255+ >
1256+ < Menu >
1257+ { availableNodeTypes . map ( ( type ) => (
1258+ < MenuItem
1259+ key = { type }
1260+ active = { selectedNodeType === type }
1261+ onClick = { ( ) => setSelectedNodeType ( type ) }
1262+ text = {
1263+ < span className = "flex items-center gap-2" >
1264+ { type !== "All" && (
1265+ < span
1266+ className = "inline-block h-3 w-3 shrink-0 rounded-full"
1267+ style = { {
1268+ backgroundColor :
1269+ nodeTypeColorMap [ type ] || "#000000" ,
1270+ } }
1271+ />
1272+ ) }
1273+ { type }
1274+ </ span >
1275+ }
1276+ />
1277+ ) ) }
1278+ </ Menu >
1279+ </ div >
12691280 }
12701281 >
12711282 < Button
0 commit comments