Debian Codegraph @

frontend/src/reports/editor/index.ts

raw
1 import type { LanguageSupport } from "@codemirror/language";
2
3 import { get } from "../../api";
4 import type { SourceFile } from "../../api/validators";
5 import { getBeancountLanguageSupport } from "../../codemirror/beancount";
6 import { _ } from "../../i18n";
7 import { Route } from "../route";
8 import Editor from "./Editor.svelte";
9
10 export interface EditorReportProps {
11 source: SourceFile;
12 beancount_language_support: LanguageSupport;
13 }
14
15 export const editor = new Route<EditorReportProps>(
16 "editor",
17 Editor,
18 async (url: URL) =>
19 Promise.all([
20 get("source", {
21 filename: url.searchParams.get("file_path") ?? "",
22 }),
23 getBeancountLanguageSupport(),
24 ]).then(([source, beancount_language_support]) => ({
25 source,
26 beancount_language_support,
27 })),
28 () => _("Editor"),
29 );