Path: blob/main/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';6import { URI } from '../../../../base/common/uri.js';7import { IResolvedNotebookEditorModel, NotebookEditorModelCreationOptions } from './notebookCommon.js';8import { IReference } from '../../../../base/common/lifecycle.js';9import { Event, IWaitUntil } from '../../../../base/common/event.js';10import { NotebookTextModel } from './model/notebookTextModel.js';1112export const INotebookEditorModelResolverService = createDecorator<INotebookEditorModelResolverService>('INotebookModelResolverService');1314/**15* A notebook file can only be opened ONCE per notebook type.16* This event fires when a file is already open as type A17* and there is request to open it as type B. Listeners must18* do cleanup (close editor, release references) or the request fails19*/20export interface INotebookConflictEvent extends IWaitUntil {21resource: URI;22viewType: string;23}2425export interface IUntitledNotebookResource {26/**27* Depending on the value of `untitledResource` will28* resolve a untitled notebook that:29* - gets a unique name if `undefined` (e.g. `Untitled-1')30* - uses the resource directly if the scheme is `untitled:`31* - converts any other resource scheme to `untitled:` and will32* assume an associated file path33*34* Untitled notebook editors with associated path behave slightly35* different from other untitled editors:36* - they are dirty right when opening37* - they will not ask for a file path when saving but use the associated path38*/39untitledResource: URI | undefined;40}4142export interface INotebookEditorModelResolverService {43readonly _serviceBrand: undefined;4445readonly onDidSaveNotebook: Event<URI>;46readonly onDidChangeDirty: Event<IResolvedNotebookEditorModel>;4748readonly onWillFailWithConflict: Event<INotebookConflictEvent>;4950isDirty(resource: URI): boolean;5152createUntitledNotebookTextModel(viewType: string): Promise<NotebookTextModel>;5354resolve(resource: URI, viewType?: string, creationOptions?: NotebookEditorModelCreationOptions): Promise<IReference<IResolvedNotebookEditorModel>>;55resolve(resource: IUntitledNotebookResource, viewType: string, creationOtions?: NotebookEditorModelCreationOptions): Promise<IReference<IResolvedNotebookEditorModel>>;56}575859