1
0
silverbullet/web/syscalls/space.ts
2023-01-13 15:41:29 +01:00

20 lines
677 B
TypeScript

import { Editor } from "../editor.tsx";
import { SysCallMapping } from "../../plugos/system.ts";
import commonSpaceSyscalls from "../../common/syscalls/space.ts";
export function spaceSyscalls(editor: Editor): SysCallMapping {
const syscalls = commonSpaceSyscalls(editor.space);
syscalls["space.deletePage"] = async (_ctx, name: string) => {
// If we're deleting the current page, navigate to the index page
if (editor.currentPage === name) {
await editor.navigate("");
}
// Remove page from open pages in editor
editor.openPages.delete(name);
console.log("Deleting page");
await editor.space.deletePage(name);
};
return syscalls;
}