Something went wrong. Try again.
a tool for shared writing and social publishing
Something went wrong. Try again.
770 B · 32 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233import { useEditorStates } from "src/state/useEditorState";
export function deleteFootnoteFromBlock( footnoteEntityID: string, blockID: string, rep: any,) { if (!rep) return;
let editorState = useEditorStates.getState().editorStates[blockID]; if (editorState?.view) { let view = editorState.view; let { doc } = view.state; let tr = view.state.tr; let found = false; doc.descendants((node, pos) => { if ( found || node.type.name !== "footnote" || node.attrs.footnoteEntityID !== footnoteEntityID ) return; found = true; tr.delete(pos, pos + node.nodeSize); }); if (found) { view.dispatch(tr); } }
rep.mutate.deleteFootnote({ footnoteEntityID, blockID });}