mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-18 23:59:43 +01:00
Co-authored-by: Johannes Rieken <jrieken@microsoft.com> Co-authored-by: Alexandru Dima <alexdima@microsoft.com>
42 lines
2.1 KiB
TypeScript
42 lines
2.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { Emitter } from '../../../base/common/event.js';
|
|
import { URI, UriComponents } from '../../../base/common/uri.js';
|
|
import * as extHostProtocol from './extHost.protocol.js';
|
|
import { ExtHostNotebookController } from './extHostNotebook.js';
|
|
import { NotebookDocumentMetadata } from '../../contrib/notebook/common/notebookCommon.js';
|
|
import { SerializableObjectWithBuffers } from '../../services/extensions/common/proxyIdentifier.js';
|
|
import type * as vscode from 'vscode';
|
|
|
|
export class ExtHostNotebookDocuments implements extHostProtocol.ExtHostNotebookDocumentsShape {
|
|
|
|
private readonly _onDidSaveNotebookDocument = new Emitter<vscode.NotebookDocument>();
|
|
readonly onDidSaveNotebookDocument = this._onDidSaveNotebookDocument.event;
|
|
|
|
private readonly _onDidChangeNotebookDocument = new Emitter<vscode.NotebookDocumentChangeEvent>();
|
|
readonly onDidChangeNotebookDocument = this._onDidChangeNotebookDocument.event;
|
|
|
|
constructor(
|
|
private readonly _notebooksAndEditors: ExtHostNotebookController,
|
|
) { }
|
|
|
|
$acceptModelChanged(uri: UriComponents, event: SerializableObjectWithBuffers<extHostProtocol.NotebookCellsChangedEventDto>, isDirty: boolean, newMetadata?: NotebookDocumentMetadata): void {
|
|
const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri));
|
|
const e = document.acceptModelChanged(event.value, isDirty, newMetadata);
|
|
this._onDidChangeNotebookDocument.fire(e);
|
|
}
|
|
|
|
$acceptDirtyStateChanged(uri: UriComponents, isDirty: boolean): void {
|
|
const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri));
|
|
document.acceptDirty(isDirty);
|
|
}
|
|
|
|
$acceptModelSaved(uri: UriComponents): void {
|
|
const document = this._notebooksAndEditors.getNotebookDocument(URI.revive(uri));
|
|
this._onDidSaveNotebookDocument.fire(document.apiNotebook);
|
|
}
|
|
}
|