Something went wrong. Try again.
a tool for shared writing and social publishing
Something went wrong. Try again.
1.2 kB · 38 lines
TSX
123456789101112131415161718192021222324252627282930313233343536373839import { 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";
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} editable={permissions.write} onDelete={ permissions.write ? () => { deleteFootnoteFromBlock( fn.footnoteEntityID, fn.blockID, rep.rep, ); } : undefined } /> ))} </FootnoteSectionLayout> );}