import { useEditorStates } from "src/state/useEditorState";
import { useUIState } from "src/useUIState";
import { useReplicache } from "src/replicache";
import { useEntitySetContext } from "components/EntitySetProvider";
import { insertFootnote } from "components/Blocks/TextBlock/insertFootnote";
import { TooltipButton } from "components/Buttons";
import { Props } from "components/Icons/Props";
import { ToolbarButton } from ".";
export function FootnoteButton() {
let rep = useReplicache();
let entity_set = useEntitySetContext();
let focusedBlock = useUIState((s) => s.focusedEntity);
return (
{
e.preventDefault();
if (!focusedBlock || focusedBlock.entityType !== "block") return;
let editorState =
useEditorStates.getState().editorStates[focusedBlock.entityID];
if (!editorState?.view || !rep.rep) return;
await insertFootnote(
editorState.view,
focusedBlock.entityID,
rep.rep,
entity_set.set,
);
}}
>
);
}
function FootnoteIcon(props: Props) {
return (
);
}