feat(editor): cite references from the finding edit form only

This commit is contained in:
bchanot committed 2026-11-14 14:11:13 +01:00
1 parent afc1051313
commit f0e49fd447
16 files changed
+519 -395

No files matched your search

@@ -0,0 +1,27 @@
import { create } from 'zustand'
import type { ElementKey } from '@faunosteo/core-wasm/types'
/** The citations an open edit form holds, for the side sheet opened from that form. */
interface CitationDraft {
key: ElementKey
ids: readonly string[]
}
interface CitationDraftStore {
draft: CitationDraft | null
publish: (draft: CitationDraft | null) => void
}
export const useCitationDraft = create<CitationDraftStore>((set) => ({
draft: null,
publish: (draft) => set({ draft }),
}))
/** The ids the sheet of `key` lists instead of the document's, null when none are staged. */
export function draftIdsFor(
draft: CitationDraft | null,
key: ElementKey,
): readonly string[] | null {
if (!draft || JSON.stringify(draft.key) !== JSON.stringify(key)) return null
return draft.ids
}