Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/imageCarousel/browser/imageCarouselEditorInput.ts
13401 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { EditorInput } from '../../../common/editor/editorInput.js';
7
import { EditorInputCapabilities, IUntypedEditorInput } from '../../../common/editor.js';
8
import { URI } from '../../../../base/common/uri.js';
9
import { Schemas } from '../../../../base/common/network.js';
10
import { IImageCarouselCollection } from './imageCarouselTypes.js';
11
12
export class ImageCarouselEditorInput extends EditorInput {
13
static readonly ID = 'workbench.input.imageCarousel';
14
15
private _resource: URI;
16
private _name: string;
17
18
override get capabilities(): EditorInputCapabilities {
19
return super.capabilities | EditorInputCapabilities.Singleton | EditorInputCapabilities.RequiresModal;
20
}
21
22
constructor(
23
public readonly collection: IImageCarouselCollection,
24
public readonly startIndex: number = 0
25
) {
26
super();
27
this._resource = URI.from({
28
scheme: Schemas.vscodeImageCarousel,
29
path: `/${encodeURIComponent(collection.id)}`,
30
});
31
this._name = collection.title;
32
}
33
34
get typeId(): string {
35
return ImageCarouselEditorInput.ID;
36
}
37
38
get resource(): URI {
39
return this._resource;
40
}
41
42
override getName(): string {
43
return this._name;
44
}
45
46
setName(name: string): void {
47
if (this._name !== name) {
48
this._name = name;
49
this._onDidChangeLabel.fire();
50
}
51
}
52
53
override matches(other: EditorInput | IUntypedEditorInput): boolean {
54
if (other instanceof ImageCarouselEditorInput) {
55
return other.collection.id === this.collection.id;
56
}
57
return false;
58
}
59
}
60
61