Path: blob/master/src/packages/conat/project/api/editor.ts
1453 views
import type { NbconvertParams } from "@cocalc/util/jupyter/types";1import type { RunNotebookOptions } from "@cocalc/util/jupyter/nbgrader-types";2import type { Options as FormatterOptions } from "@cocalc/util/code-formatter";3import type { KernelSpec } from "@cocalc/util/jupyter/types";45export const editor = {6newFile: true,7jupyterStripNotebook: true,8jupyterNbconvert: true,9jupyterRunNotebook: true,10jupyterKernelLogo: true,11jupyterKernels: true,12formatterString: true,13printSageWS: true,14createTerminalService: true,15};1617export interface CreateTerminalOptions {18env?: { [key: string]: string };19command?: string;20args?: string[];21cwd?: string;22ephemeral?: boolean;23// path of the primary tab in the browser, e.g., if you open a.term it's a.term for all frames,24// and if you have term next to a.md (say), then it is a.md.25path: string;26}2728export interface Editor {29// Create a new file with the given name, possibly aware of templates.30// This was cc-new-file in the old smc_pyutils python library. This31// is in editor, since it's meant to be for creating a file aware of the32// context of our editors.33newFile: (path: string) => Promise<void>;3435jupyterStripNotebook: (path_ipynb: string) => Promise<string>;3637jupyterNbconvert: (opts: NbconvertParams) => Promise<void>;3839jupyterRunNotebook: (opts: RunNotebookOptions) => Promise<string>;4041jupyterKernelLogo: (42kernelName: string,43opts?: { noCache?: boolean },44) => Promise<{ filename: string; base64: string }>;4546jupyterKernels: (opts?: { noCache?: boolean }) => Promise<KernelSpec[]>;4748// returns a patch to transform str into formatted form.49formatterString: (opts: {50str: string;51options: FormatterOptions;52path?: string; // only used for CLANG53}) => Promise<string>;5455printSageWS: (opts) => Promise<string>;5657createTerminalService: (58termPath: string,59opts: CreateTerminalOptions,60) => Promise<void>;61}626364