solorice/vscodium/extensions/ms-toolsai.jupyter-2022.3.1000901801/vscode.proposed.notebookEditorEdit.d.ts
2022-04-28 21:17:01 +03:00

54 lines
2.2 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
// https://github.com/microsoft/vscode/issues/106744
// todo@API add NotebookEdit-type which handles all these cases?
// export class NotebookEdit {
// range: NotebookRange;
// newCells: NotebookCellData[];
// newMetadata?: NotebookDocumentMetadata;
// constructor(range: NotebookRange, newCells: NotebookCellData)
// }
// export class NotebookCellEdit {
// newMetadata?: NotebookCellMetadata;
// }
// export interface WorkspaceEdit {
// set(uri: Uri, edits: TextEdit[] | NotebookEdit[]): void
// }
export interface WorkspaceEdit {
// todo@API add NotebookEdit-type which handles all these cases?
replaceNotebookMetadata(uri: Uri, value: { [key: string]: any }): void;
replaceNotebookCells(uri: Uri, range: NotebookRange, cells: NotebookCellData[], metadata?: WorkspaceEditEntryMetadata): void;
replaceNotebookCellMetadata(uri: Uri, index: number, cellMetadata: { [key: string]: any }, metadata?: WorkspaceEditEntryMetadata): void;
}
export interface NotebookEditorEdit {
replaceMetadata(value: { [key: string]: any }): void;
replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
replaceCellMetadata(index: number, metadata: { [key: string]: any }): void;
}
export interface NotebookEditor {
/**
* Perform an edit on the notebook associated with this notebook editor.
*
* The given callback-function is invoked with an {@link NotebookEditorEdit edit-builder} which must
* be used to make edits. Note that the edit-builder is only valid while the
* callback executes.
*
* @param callback A function which can create edits using an {@link NotebookEditorEdit edit-builder}.
* @return A promise that resolves with a value indicating if the edits could be applied.
*/
// @jrieken REMOVE maybe
edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
}
}