Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/conat/project/api/editor.ts
1453 views
1
import type { NbconvertParams } from "@cocalc/util/jupyter/types";
2
import type { RunNotebookOptions } from "@cocalc/util/jupyter/nbgrader-types";
3
import type { Options as FormatterOptions } from "@cocalc/util/code-formatter";
4
import type { KernelSpec } from "@cocalc/util/jupyter/types";
5
6
export const editor = {
7
newFile: true,
8
jupyterStripNotebook: true,
9
jupyterNbconvert: true,
10
jupyterRunNotebook: true,
11
jupyterKernelLogo: true,
12
jupyterKernels: true,
13
formatterString: true,
14
printSageWS: true,
15
createTerminalService: true,
16
};
17
18
export interface CreateTerminalOptions {
19
env?: { [key: string]: string };
20
command?: string;
21
args?: string[];
22
cwd?: string;
23
ephemeral?: boolean;
24
// path of the primary tab in the browser, e.g., if you open a.term it's a.term for all frames,
25
// and if you have term next to a.md (say), then it is a.md.
26
path: string;
27
}
28
29
export interface Editor {
30
// Create a new file with the given name, possibly aware of templates.
31
// This was cc-new-file in the old smc_pyutils python library. This
32
// is in editor, since it's meant to be for creating a file aware of the
33
// context of our editors.
34
newFile: (path: string) => Promise<void>;
35
36
jupyterStripNotebook: (path_ipynb: string) => Promise<string>;
37
38
jupyterNbconvert: (opts: NbconvertParams) => Promise<void>;
39
40
jupyterRunNotebook: (opts: RunNotebookOptions) => Promise<string>;
41
42
jupyterKernelLogo: (
43
kernelName: string,
44
opts?: { noCache?: boolean },
45
) => Promise<{ filename: string; base64: string }>;
46
47
jupyterKernels: (opts?: { noCache?: boolean }) => Promise<KernelSpec[]>;
48
49
// returns a patch to transform str into formatted form.
50
formatterString: (opts: {
51
str: string;
52
options: FormatterOptions;
53
path?: string; // only used for CLANG
54
}) => Promise<string>;
55
56
printSageWS: (opts) => Promise<string>;
57
58
createTerminalService: (
59
termPath: string,
60
opts: CreateTerminalOptions,
61
) => Promise<void>;
62
}
63
64