Something went wrong. Try again.
a tool for shared writing and social publishing
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445import { useFootnoteContext } from "./FootnoteContext";import { FootnoteEditor } from "./FootnoteEditor";import { useReplicache } from "src/replicache";import { useEntitySetContext } from "components/EntitySetProvider";import { deleteFootnoteFromBlock } from "./deleteFootnoteFromBlock";import { FootnoteSectionLayout } from "./FootnoteItemLayout";import { EditorFootnoteSourcePreview } from "./FootnoteSourcePreview";
export function FootnoteSection(props: { hiddenOnDesktop?: boolean }) { let { footnotes } = useFootnoteContext(); let { permissions } = useEntitySetContext(); let rep = useReplicache();
if (footnotes.length === 0) return null;
return ( <FootnoteSectionLayout className={props.hiddenOnDesktop ? "xl:hidden" : ""}> {footnotes.map((fn) => ( <FootnoteEditor key={fn.footnoteEntityID} footnoteEntityID={fn.footnoteEntityID} index={fn.index} sourcePreview={{ footnoteID: fn.footnoteEntityID, sourceSelector: `.footnote-ref[data-footnote-id="${CSS.escape(fn.footnoteEntityID)}"]`, content: <EditorFootnoteSourcePreview blockID={fn.blockID} />, }} editable={permissions.write} onDelete={ permissions.write ? () => { deleteFootnoteFromBlock( fn.footnoteEntityID, fn.blockID, rep.rep, ); } : undefined } /> ))} </FootnoteSectionLayout> );}