import { Mousetrap } from "../takker99%2FScrapBindings/mod.ts"; import { useStatusBar, addTextInputEventListener, removeTextInputEventListener, } from "../scrapbox-userscript-std/dom.ts"; import { config, task } from "../takker99%2FScrapBindings-settings/config.ts"; import { Scrapbox } from "../scrapbox-jp%2Ftypes/userscript.ts"; declare const scrapbox: Scrapbox; const { render } = useStatusBar(); let animationId: number| undefined; const onSequenceUpdate = (text: string) => { if(animationId !== undefined) cancelAnimationFrame(animationId); animationId = requestAnimationFrame(() => render( { type: "text", text, } )); }; export const scrapBindings = new Mousetrap( { addEventListener: addTextInputEventListener, removeEventListener: removeTextInputEventListener, }, { onSequenceUpdate, }, ); const errors = scrapBindings.bind({ ...config, ...(scrapbox.Project.name === "takker-memex" ? task : {}), }); if(errors.size > 0) { alert([...errors.entries()].map( ([seq, messages]) => `${seq}:\n${ messages.map((message) => `- ${message}`).join("\n") }` ).join("\n")); }