1
0
silverbullet/web/syscalls/space.ts

20 lines
677 B
TypeScript
Raw Normal View History

import { Editor } from "../editor.tsx";
import { SysCallMapping } from "../../plugos/system.ts";
2023-01-13 14:41:29 +00:00
import commonSpaceSyscalls from "../../common/syscalls/space.ts";
2022-04-03 16:12:16 +00:00
export function spaceSyscalls(editor: Editor): SysCallMapping {
2023-01-13 14:41:29 +00:00
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);
2022-04-03 16:12:16 +00:00
};
2023-01-13 14:41:29 +00:00
return syscalls;
2022-04-03 16:12:16 +00:00
}