Skip to content

Commit 0898926

Browse files
committed
address PR comment
1 parent 0858366 commit 0898926

2 files changed

Lines changed: 43 additions & 30 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ local/*
4040
.cursor/debug.log
4141
apps/tldraw-sync-worker/tsconfig.tsbuildinfo
4242
apps/tldraw-sync-worker/.wrangler/*
43+
.claude/*
44+
CLAUDE.md

apps/roam/src/components/canvas/Clipboard.tsx

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import AutocompleteInput from "roamjs-components/components/AutocompleteInput";
4646
import { Result } from "roamjs-components/types/query-builder";
4747
import fuzzy from "fuzzy";
4848
import getAllReferencesOnPage from "~/utils/getAllReferencesOnPage";
49-
import isDiscourseNode from "~/utils/isDiscourseNode";
5049
import {
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

Comments
 (0)