import { press, insertText, takeCursor, textInput } from "../../takker/scrapbox-userscript-std/dom.ts"; import { Scrapbox } from "../../takker/scrapbox-jp%2Ftypes/userscript.ts"; declare const scrapbox: Scrapbox; textInput()!.addEventListener("keydown", async (e) => { if (e.key !== "Enter" || e.metaKey || e.altKey || !e.ctrlKey || e.shiftKey) return; if (scrapbox.Layout !== "page") return; const cursor = takeCursor() const line = cursor.getPosition().line; const cursorLine = scrapbox.Page.lines[line]; if (!("codeBlock" in cursorLine) || cursorLine.codeBlock.start || cursorLine.codeBlock.end) return; press("End") press("Enter"); cursor.setPosition({ line: cursor.getPosition().line, char: cursorLine.codeBlock.indent - 1 }); press("End", { shiftKey: true }); await insertText(`code:${cursorLine.codeBlock.filename ?? ""}`); press("Home"); press("Enter"); press("ArrowUp"); });