File
Blob: src/client/components/page-mention/candidates.ts
| 1 | import { selectActiveWorkspacePages, useWorkspaceReplicaStore } from "@/client/stores/workspace-replica"; |
| 2 | import type { PageMentionCandidate } from "./types"; |
| 3 | |
| 4 | export function getInsertablePageMentionCandidates( |
| 5 | workspaceId: string | undefined, |
| 6 | excludePageId: string | undefined, |
| 7 | ): PageMentionCandidate[] { |
| 8 | if (!workspaceId) return []; |
| 9 | const pages = selectActiveWorkspacePages(useWorkspaceReplicaStore.getState(), workspaceId); |
| 10 | const candidates: PageMentionCandidate[] = []; |
| 11 | for (const page of pages) { |
| 12 | if (page.id === excludePageId) continue; |
| 13 | candidates.push({ |
| 14 | pageId: page.id, |
| 15 | title: page.title || "Untitled", |
| 16 | icon: page.icon, |
| 17 | }); |
| 18 | } |
| 19 | return candidates; |
| 20 | } |