1
>
/*---------------------------------------------------------------------------------------------
notebookCommon.ts
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 { VSBuffer } from '../../../../base/common/buffer.js';
7
>
import { CancellationToken } from '../../../../base/common/cancellation.js';
8
>
import { IDiffResult } from '../../../../base/common/diff/diff.js';
9
>
import { Event } from '../../../../base/common/event.js';
10
>
import * as glob from '../../../../base/common/glob.js';
11
>
import { IMarkdownString } from '../../../../base/common/htmlContent.js';
12
>
import { Iterable } from '../../../../base/common/iterator.js';
13
>
import { IDisposable } from '../../../../base/common/lifecycle.js';
14
>
import { Mimes } from '../../../../base/common/mime.js';
15
>
import { Schemas } from '../../../../base/common/network.js';
16
>
import { basename } from '../../../../base/common/path.js';
17
>
import { isWindows } from '../../../../base/common/platform.js';
18
>
import { ISplice } from '../../../../base/common/sequence.js';
19
>
import { ThemeColor } from '../../../../base/common/themables.js';
20
>
import { URI, UriComponents } from '../../../../base/common/uri.js';
21
>
import { Range } from '../../../../editor/common/core/range.js';
22
>
import * as editorCommon from '../../../../editor/common/editorCommon.js';
23
>
import { Command, WorkspaceEditMetadata } from '../../../../editor/common/languages.js';
24
>
import { IReadonlyTextBuffer, ITextModel } from '../../../../editor/common/model.js';
25
>
import { IAccessibilityInformation } from '../../../../platform/accessibility/common/accessibility.js';
26
>
import { RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
27
>
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
28
>
import { IFileReadLimits } from '../../../../platform/files/common/files.js';
29
>
import { UndoRedoGroup } from '../../../../platform/undoRedo/common/undoRedo.js';
30
>
import { IRevertOptions, ISaveOptions, IUntypedEditorInput } from '../../../common/editor.js';
31
>
import { NotebookTextModel } from './model/notebookTextModel.js';
32
>
import { ICellExecutionError } from './notebookExecutionStateService.js';
33
>
import { INotebookTextModelLike } from './notebookKernelService.js';
34
>
import { ICellRange } from './notebookRange.js';
35
>
import { RegisteredEditorPriority } from '../../../services/editor/common/editorResolverService.js';
36
>
import { generateMetadataUri, generate as generateUri, extractCellOutputDetails, parseMetadataUri, parse as parseUri } from '../../../services/notebook/common/notebookDocumentService.js';
37
>
import { IWorkingCopyBackupMeta, IWorkingCopySaveEvent } from '../../../services/workingCopy/common/workingCopy.js';
38
>
import { SnapshotContext } from '../../../services/workingCopy/common/fileWorkingCopy.js';
39
>
40
>
export const NOTEBOOK_EDITOR_ID = 'workbench.editor.notebook';
41
>
export const NOTEBOOK_DIFF_EDITOR_ID = 'workbench.editor.notebookTextDiffEditor';
42
>
export const NOTEBOOK_MULTI_DIFF_EDITOR_ID = 'workbench.editor.notebookMultiTextDiffEditor';
43
>
export const INTERACTIVE_WINDOW_EDITOR_ID = 'workbench.editor.interactive';
44
>
export const REPL_EDITOR_ID = 'workbench.editor.repl';
45
>
export const NOTEBOOK_OUTPUT_EDITOR_ID = 'workbench.editor.notebookOutputEditor';
46
>
47
>
export const EXECUTE_REPL_COMMAND_ID = 'replNotebook.input.execute';
48
>
49
>
export enum CellKind {
50
>
Markup = 1,
51
>
Code = 2
52
>
}
53
>
54
>
export const NOTEBOOK_DISPLAY_ORDER: readonly string[] = [
55
>
'application/json',
56
>
'application/javascript',
57
>
'text/html',
58
>
'image/svg+xml',
59
>
Mimes.latex,
60
>
Mimes.markdown,
61
>
'image/png',
62
>
'image/jpeg',
63
>
Mimes.text
64
>
];
65
>
66
>
export const ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER: readonly string[] = [
67
>
Mimes.latex,
68
>
Mimes.markdown,
69
>
'application/json',
70
>
'text/html',
71
>
'image/svg+xml',
72
>
'image/png',
73
>
'image/jpeg',
74
>
Mimes.text,
75
>
];
76
>
77
>
/**
78
>
* A mapping of extension IDs who contain renderers, to notebook ids who they
79
>
* should be treated as the same in the renderer selection logic. This is used
80
>
* to prefer the 1st party Jupyter renderers even though they're in a separate
81
>
* extension, for instance. See #136247.
82
>
*/
83
>
export const RENDERER_EQUIVALENT_EXTENSIONS: ReadonlyMap<string, ReadonlySet<string>> = new Map([
84
>
['ms-toolsai.jupyter', new Set(['jupyter-notebook', 'interactive'])],
85
>
['ms-toolsai.jupyter-renderers', new Set(['jupyter-notebook', 'interactive'])],
86
>
]);
87
>
88
>
export const RENDERER_NOT_AVAILABLE = '_notAvailable';
89
>
90
>
export type ContributedNotebookRendererEntrypoint = string | { readonly extends: string; readonly path: string };
91
>
92
>
export enum NotebookRunState {
93
>
Running = 1,
94
>
Idle = 2
95
>
}
96
>
97
>
export type NotebookDocumentMetadata = Record<string, unknown>;
98
>
99
>
export enum NotebookCellExecutionState {
100
>
Unconfirmed = 1,
101
>
Pending = 2,
102
>
Executing = 3
103
>
}
104
>
export enum NotebookExecutionState {
105
>
Unconfirmed = 1,
106
>
Pending = 2,
107
>
Executing = 3
108
>
}
109
>
110
>
export interface INotebookCellPreviousExecutionResult {
111
>
executionOrder?: number;
112
>
success?: boolean;
113
>
duration?: number;
114
>
}
115
>
116
>
export interface NotebookCellMetadata {
117
>
/**
118
>
* custom metadata
119
>
*/
120
>
[key: string]: unknown;
121
>
}
122
>
123
>
export interface NotebookCellInternalMetadata {
124
>
/**
125
>
* Used only for diffing of Notebooks.
126
>
* This is not persisted and generally useful only when diffing two notebooks.
127
>
* Useful only after we've manually matched a few cells together so we know which cells are matching.
128
>
*/
129
>
internalId?: string;
130
>
executionId?: string;
131
>
executionOrder?: number;
132
>
lastRunSuccess?: boolean;
133
>
runStartTime?: number;
134
>
runStartTimeAdjustment?: number;
135
>
runEndTime?: number;
136
>
renderDuration?: { [key: string]: number };
137
>
error?: ICellExecutionError;
138
>
}
139
>
140
>
export interface NotebookCellCollapseState {
141
>
inputCollapsed?: boolean;
142
>
outputCollapsed?: boolean;
143
>
}
144
>
145
>
export interface NotebookCellDefaultCollapseConfig {
146
>
codeCell?: NotebookCellCollapseState;
147
>
markupCell?: NotebookCellCollapseState;
148
>
}
149
>
150
>
export type InteractiveWindowCollapseCodeCells = 'always' | 'never' | 'fromEditor';
151
>
152
>
export type TransientCellMetadata = { readonly [K in keyof NotebookCellMetadata]?: boolean };
153
>
export type CellContentMetadata = { readonly [K in keyof NotebookCellMetadata]?: boolean };
154
>
export type TransientDocumentMetadata = { readonly [K in keyof NotebookDocumentMetadata]?: boolean };
155
>
156
>
export interface TransientOptions {
157
>
readonly transientOutputs: boolean;
158
>
readonly transientCellMetadata: TransientCellMetadata;
159
>
readonly transientDocumentMetadata: TransientDocumentMetadata;
160
>
readonly cellContentMetadata: CellContentMetadata;
161
>
}
162
>
163
>
/** Note: enum values are used for sorting */
164
>
export const enum NotebookRendererMatch {
165
>
/** Renderer has a hard dependency on an available kernel */
166
>
WithHardKernelDependency = 0,
167
>
/** Renderer works better with an available kernel */
168
>
WithOptionalKernelDependency = 1,
169
>
/** Renderer is kernel-agnostic */
170
>
Pure = 2,
171
>
/** Renderer is for a different mimeType or has a hard dependency which is unsatisfied */
172
>
Never = 3,
173
>
}
174
>
175
>
/**
176
>
* Renderer messaging requirement. While this allows for 'optional' messaging,
177
>
* VS Code effectively treats it the same as true right now. "Partial
178
>
* activation" of extensions is a very tricky problem, which could allow
179
>
* solving this. But for now, optional is mostly only honored for aznb.
180
>
*/
181
>
export const enum RendererMessagingSpec {
182
>
Always = 'always',
183
>
Never = 'never',
184
>
Optional = 'optional',
185
>
}
186
>
187
>
export type NotebookRendererEntrypoint = { readonly extends: string | undefined; readonly path: URI };
188
>
189
>
export interface INotebookRendererInfo {
190
>
readonly id: string;
191
>
readonly displayName: string;
192
>
readonly entrypoint: NotebookRendererEntrypoint;
193
>
readonly extensionLocation: URI;
194
>
readonly extensionId: ExtensionIdentifier;
195
>
readonly messaging: RendererMessagingSpec;
196
>
197
>
readonly mimeTypes: readonly string[];
198
>
199
>
readonly isBuiltin: boolean;
200
>
201
>
matchesWithoutKernel(mimeType: string): NotebookRendererMatch;
202
>
matches(mimeType: string, kernelProvides: ReadonlyArray<string>): NotebookRendererMatch;
203
>
}
204
>
205
>
export interface INotebookStaticPreloadInfo {
206
>
readonly type: string;
207
>
readonly entrypoint: URI;
208
>
readonly extensionLocation: URI;
209
>
readonly localResourceRoots: readonly URI[];
210
>
}
211
>
212
>
export interface IOrderedMimeType {
213
>
mimeType: string;
214
>
rendererId: string;
215
>
isTrusted: boolean;
216
>
}
217
>
218
>
export interface IOutputItemDto {
219
>
readonly mime: string;
220
>
readonly data: VSBuffer;
221
>
}
222
>
223
>
export interface IOutputDto {
224
>
outputs: IOutputItemDto[];
225
>
outputId: string;
226
>
metadata?: Record<string, any>;
227
>
}
228
>
229
>
export interface ICellOutput {
230
>
readonly versionId: number;
231
>
outputs: IOutputItemDto[];
232
>
metadata?: Record<string, any>;
233
>
outputId: string;
234
>
/**
235
>
* Alternative output id that's reused when the output is updated.
236
>
*/
237
>
alternativeOutputId: string;
238
>
readonly onDidChangeData: Event<void>;
239
>
replaceData(items: IOutputDto): void;
240
>
appendData(items: IOutputItemDto[]): void;
241
>
appendedSinceVersion(versionId: number, mime: string): VSBuffer | undefined;
242
>
asDto(): IOutputDto;
243
>
bumpVersion(): void;
244
>
dispose(): void;
245
>
}
246
>
247
>
export interface CellInternalMetadataChangedEvent {
248
>
readonly lastRunSuccessChanged?: boolean;
249
>
}
250
>
251
>
export interface INotebookDocumentMetadataTextModel {
252
>
/**
253
>
* Notebook Metadata Uri.
254
>
*/
255
>
readonly uri: URI;
256
>
/**
257
>
* Triggered when the Notebook Metadata changes.
258
>
*/
259
>
readonly onDidChange: Event<void>;
260
>
readonly metadata: Readonly<NotebookDocumentMetadata>;
261
>
readonly textBuffer: IReadonlyTextBuffer;
262
>
/**
263
>
* Text representation of the Notebook Metadata
264
>
*/
265
>
getValue(): string;
266
>
getHash(): string;
267
>
}
268
>
269
>
export interface ICell {
270
>
readonly uri: URI;
271
>
handle: number;
272
>
language: string;
273
>
cellKind: CellKind;
274
>
outputs: ICellOutput[];
275
>
metadata: NotebookCellMetadata;
276
>
internalMetadata: NotebookCellInternalMetadata;
277
>
getHashValue(): number;
278
>
textBuffer: IReadonlyTextBuffer;
279
>
textModel?: ITextModel;
280
>
readonly onDidChangeTextModel: Event<void>;
281
>
getValue(): string;
282
>
readonly onDidChangeOutputs?: Event<NotebookCellOutputsSplice>;
283
>
readonly onDidChangeOutputItems?: Event<void>;
284
>
readonly onDidChangeLanguage: Event<string>;
285
>
readonly onDidChangeMetadata: Event<void>;
286
>
readonly onDidChangeInternalMetadata: Event<CellInternalMetadataChangedEvent>;
287
>
}
288
>
289
>
export interface INotebookSnapshotOptions {
290
>
context: SnapshotContext;
291
>
outputSizeLimit: number;
292
>
transientOptions?: TransientOptions;
293
>
}
294
>
295
>
export interface INotebookTextModel extends INotebookTextModelLike, IDisposable {
296
>
readonly notebookType: string;
297
>
readonly viewType: string;
298
>
metadata: NotebookDocumentMetadata;
299
>
readonly transientOptions: TransientOptions;
300
>
readonly uri: URI;
301
>
readonly versionId: number;
302
>
readonly length: number;
303
>
readonly cells: readonly ICell[];
304
>
reset(cells: ICellDto2[], metadata: NotebookDocumentMetadata, transientOptions: TransientOptions): void;
305
>
createSnapshot(options: INotebookSnapshotOptions): NotebookData;
306
>
restoreSnapshot(snapshot: NotebookData, transientOptions?: TransientOptions): void;
307
>
applyEdits(rawEdits: ICellEditOperation[], synchronous: boolean, beginSelectionState: ISelectionState | undefined, endSelectionsComputer: () => ISelectionState | undefined, undoRedoGroup: UndoRedoGroup | undefined, computeUndoRedo?: boolean): boolean;
308
>
readonly onDidChangeContent: Event<NotebookTextModelChangedEvent>;
309
>
readonly onWillDispose: Event<void>;
310
>
}
311
>
312
>
export type NotebookCellTextModelSplice<T> = [
313
>
start: number,
314
>
deleteCount: number,
315
>
newItems: T[]
316
>
];
317
>
318
>
export type NotebookCellOutputsSplice = {
319
>
start: number /* start */;
320
>
deleteCount: number /* delete count */;
321
>
newOutputs: ICellOutput[];
322
>
};
323
>
324
>
export interface IMainCellDto {
325
>
handle: number;
326
>
url: string;
327
>
source: string[];
328
>
eol: string;
329
>
versionId: number;
330
>
language: string;
331
>
cellKind: CellKind;
332
>
outputs: IOutputDto[];
333
>
metadata?: NotebookCellMetadata;
334
>
internalMetadata?: NotebookCellInternalMetadata;
335
>
}
336
>
337
>
export enum NotebookCellsChangeType {
338
>
ModelChange = 1,
339
>
Move = 2,
340
>
ChangeCellLanguage = 5,
341
>
Initialize = 6,
342
>
ChangeCellMetadata = 7,
343
>
Output = 8,
344
>
OutputItem = 9,
345
>
ChangeCellContent = 10,
346
>
ChangeDocumentMetadata = 11,
347
>
ChangeCellInternalMetadata = 12,
348
>
ChangeCellMime = 13,
349
>
Unknown = 100
350
>
}
351
>
352
>
export interface NotebookCellsInitializeEvent<T> {
353
>
readonly kind: NotebookCellsChangeType.Initialize;
354
>
readonly changes: NotebookCellTextModelSplice<T>[];
355
>
}
356
>
357
>
export interface NotebookCellContentChangeEvent {
358
>
readonly kind: NotebookCellsChangeType.ChangeCellContent;
359
>
readonly index: number;
360
>
}
361
>
362
>
export interface NotebookCellsModelChangedEvent<T> {
363
>
readonly kind: NotebookCellsChangeType.ModelChange;
364
>
readonly changes: NotebookCellTextModelSplice<T>[];
365
>
}
366
>
367
>
export interface NotebookCellsModelMoveEvent<T> {
368
>
readonly kind: NotebookCellsChangeType.Move;
369
>
readonly index: number;
370
>
readonly length: number;
371
>
readonly newIdx: number;
372
>
readonly cells: T[];
373
>
}
374
>
375
>
export interface NotebookOutputChangedEvent {
376
>
readonly kind: NotebookCellsChangeType.Output;
377
>
readonly index: number;
378
>
readonly outputs: IOutputDto[];
379
>
readonly append: boolean;
380
>
}
381
>
382
>
export interface NotebookOutputItemChangedEvent {
383
>
readonly kind: NotebookCellsChangeType.OutputItem;
384
>
readonly index: number;
385
>
readonly outputId: string;
386
>
readonly outputItems: IOutputItemDto[];
387
>
readonly append: boolean;
388
>
}
389
>
390
>
export interface NotebookCellsChangeLanguageEvent {
391
>
readonly kind: NotebookCellsChangeType.ChangeCellLanguage;
392
>
readonly index: number;
393
>
readonly language: string;
394
>
}
395
>
396
>
export interface NotebookCellsChangeMimeEvent {
397
>
readonly kind: NotebookCellsChangeType.ChangeCellMime;
398
>
readonly index: number;
399
>
readonly mime: string | undefined;
400
>
}
401
>
402
>
export interface NotebookCellsChangeMetadataEvent {
403
>
readonly kind: NotebookCellsChangeType.ChangeCellMetadata;
404
>
readonly index: number;
405
>
readonly metadata: NotebookCellMetadata;
406
>
}
407
>
408
>
export interface NotebookCellsChangeInternalMetadataEvent {
409
>
readonly kind: NotebookCellsChangeType.ChangeCellInternalMetadata;
410
>
readonly index: number;
411
>
readonly internalMetadata: NotebookCellInternalMetadata;
412
>
}
413
>
414
>
export interface NotebookDocumentChangeMetadataEvent {
415
>
readonly kind: NotebookCellsChangeType.ChangeDocumentMetadata;
416
>
readonly metadata: NotebookDocumentMetadata;
417
>
}
418
>
419
>
export interface NotebookDocumentUnknownChangeEvent {
420
>
readonly kind: NotebookCellsChangeType.Unknown;
421
>
}
422
>
423
>
export type NotebookRawContentEventDto = NotebookCellsInitializeEvent<IMainCellDto> | NotebookDocumentChangeMetadataEvent | NotebookCellContentChangeEvent | NotebookCellsModelChangedEvent<IMainCellDto> | NotebookCellsModelMoveEvent<IMainCellDto> | NotebookOutputChangedEvent | NotebookOutputItemChangedEvent | NotebookCellsChangeLanguageEvent | NotebookCellsChangeMimeEvent | NotebookCellsChangeMetadataEvent | NotebookCellsChangeInternalMetadataEvent | NotebookDocumentUnknownChangeEvent;
424
>
425
>
export type NotebookCellsChangedEventDto = {
426
>
readonly rawEvents: NotebookRawContentEventDto[];
427
>
readonly versionId: number;
428
>
};
429
>
430
>
export type NotebookRawContentEvent = (NotebookCellsInitializeEvent<ICell> | NotebookDocumentChangeMetadataEvent | NotebookCellContentChangeEvent | NotebookCellsModelChangedEvent<ICell> | NotebookCellsModelMoveEvent<ICell> | NotebookOutputChangedEvent | NotebookOutputItemChangedEvent | NotebookCellsChangeLanguageEvent | NotebookCellsChangeMimeEvent | NotebookCellsChangeMetadataEvent | NotebookCellsChangeInternalMetadataEvent | NotebookDocumentUnknownChangeEvent) & { transient: boolean };
431
>
432
>
export enum SelectionStateType {
433
>
Handle = 0,
434
>
Index = 1
435
>
}
436
>
437
>
export interface ISelectionHandleState {
438
>
kind: SelectionStateType.Handle;
439
>
primary: number | null;
440
>
selections: number[];
441
>
}
442
>
443
>
export interface ISelectionIndexState {
444
>
kind: SelectionStateType.Index;
445
>
focus: ICellRange;
446
>
selections: ICellRange[];
447
>
}
448
>
449
>
export type ISelectionState = ISelectionHandleState | ISelectionIndexState;
450
>
451
>
export type NotebookTextModelChangedEvent = {
452
>
readonly rawEvents: NotebookRawContentEvent[];
453
>
readonly versionId: number;
454
>
readonly synchronous: boolean | undefined;
455
>
readonly endSelectionState: ISelectionState | undefined;
456
>
};
457
>
458
>
export type NotebookTextModelWillAddRemoveEvent = {
459
>
readonly rawEvent: NotebookCellsModelChangedEvent<ICell>;
460
>
};
461
>
462
>
export const enum CellEditType {
463
>
Replace = 1,
464
>
Output = 2,
465
>
Metadata = 3,
466
>
CellLanguage = 4,
467
>
DocumentMetadata = 5,
468
>
Move = 6,
469
>
OutputItems = 7,
470
>
PartialMetadata = 8,
471
>
PartialInternalMetadata = 9,
472
>
}
473
>
474
>
export interface ICellDto2 {
475
>
source: string;
476
>
language: string;
477
>
mime: string | undefined;
478
>
cellKind: CellKind;
479
>
outputs: IOutputDto[];
480
>
metadata?: NotebookCellMetadata;
481
>
internalMetadata?: NotebookCellInternalMetadata;
482
>
collapseState?: NotebookCellCollapseState;
483
>
}
484
>
485
>
export interface ICellReplaceEdit {
486
>
editType: CellEditType.Replace;
487
>
index: number;
488
>
count: number;
489
>
cells: ICellDto2[];
490
>
}
491
>
492
>
export interface ICellOutputEdit {
493
>
editType: CellEditType.Output;
494
>
index: number;
495
>
outputs: IOutputDto[];
496
>
append?: boolean;
497
>
}
498
>
499
>
export interface ICellOutputEditByHandle {
500
>
editType: CellEditType.Output;
501
>
handle: number;
502
>
outputs: IOutputDto[];
503
>
append?: boolean;
504
>
}
505
>
506
>
export interface ICellOutputItemEdit {
507
>
editType: CellEditType.OutputItems;
508
>
outputId: string;
509
>
items: IOutputItemDto[];
510
>
append?: boolean;
511
>
}
512
>
513
>
export interface ICellMetadataEdit {
514
>
editType: CellEditType.Metadata;
515
>
index: number;
516
>
metadata: NotebookCellMetadata;
517
>
}
518
>
519
>
// These types are nullable because we need to use 'null' on the EH side so it is JSON-stringified
520
>
export type NullablePartialNotebookCellMetadata = {
521
>
[Key in keyof Partial<NotebookCellMetadata>]: NotebookCellMetadata[Key] | null
522
>
};
523
>
524
>
export interface ICellPartialMetadataEdit {
525
>
editType: CellEditType.PartialMetadata;
526
>
index: number;
527
>
metadata: NullablePartialNotebookCellMetadata;
528
>
}
529
>
530
>
export interface ICellPartialMetadataEditByHandle {
531
>
editType: CellEditType.PartialMetadata;
532
>
handle: number;
533
>
metadata: NullablePartialNotebookCellMetadata;
534
>
}
535
>
536
>
export type NullablePartialNotebookCellInternalMetadata = {
537
>
[Key in keyof Partial<NotebookCellInternalMetadata>]: NotebookCellInternalMetadata[Key] | null
538
>
};
539
>
export interface ICellPartialInternalMetadataEdit {
540
>
editType: CellEditType.PartialInternalMetadata;
541
>
index: number;
542
>
internalMetadata: NullablePartialNotebookCellInternalMetadata;
543
>
}
544
>
545
>
export interface ICellPartialInternalMetadataEditByHandle {
546
>
editType: CellEditType.PartialInternalMetadata;
547
>
handle: number;
548
>
internalMetadata: NullablePartialNotebookCellInternalMetadata;
549
>
}
550
>
551
>
export interface ICellLanguageEdit {
552
>
editType: CellEditType.CellLanguage;
553
>
index: number;
554
>
language: string;
555
>
}
556
>
557
>
export interface IDocumentMetadataEdit {
558
>
editType: CellEditType.DocumentMetadata;
559
>
metadata: NotebookDocumentMetadata;
560
>
}
561
>
562
>
export interface ICellMoveEdit {
563
>
editType: CellEditType.Move;
564
>
index: number;
565
>
length: number;
566
>
newIdx: number;
567
>
}
568
>
569
>
export type IImmediateCellEditOperation = ICellOutputEditByHandle | ICellPartialMetadataEditByHandle | ICellOutputItemEdit | ICellPartialInternalMetadataEdit | ICellPartialInternalMetadataEditByHandle | ICellPartialMetadataEdit;
570
>
export type ICellEditOperation = IImmediateCellEditOperation | ICellReplaceEdit | ICellOutputEdit | ICellMetadataEdit | ICellPartialMetadataEdit | ICellPartialInternalMetadataEdit | IDocumentMetadataEdit | ICellMoveEdit | ICellOutputItemEdit | ICellLanguageEdit;
571
>
572
>
573
>
export interface IWorkspaceNotebookCellEdit {
574
>
metadata?: WorkspaceEditMetadata;
575
>
resource: URI;
576
>
notebookVersionId: number | undefined;
577
>
cellEdit: ICellPartialMetadataEdit | IDocumentMetadataEdit | ICellReplaceEdit;
578
>
}
579
>
580
>
export interface IWorkspaceNotebookCellEditDto {
581
>
metadata?: WorkspaceEditMetadata;
582
>
resource: URI;
583
>
notebookVersionId: number | undefined;
584
>
cellEdit: ICellPartialMetadataEdit | IDocumentMetadataEdit | ICellReplaceEdit;
585
>
}
586
>
587
>
export interface NotebookData {
588
>
readonly cells: ICellDto2[];
589
>
readonly metadata: NotebookDocumentMetadata;
590
>
}
591
>
592
>
593
>
export interface INotebookContributionData {
594
>
extension?: ExtensionIdentifier;
595
>
providerDisplayName: string;
596
>
displayName: string;
597
>
filenamePattern: (string | glob.IRelativePattern | INotebookExclusiveDocumentFilter)[];
598
>
priority?: RegisteredEditorPriority;
599
>
}
600
>
601
>
export namespace NotebookMetadataUri {
602
>
export const scheme = Schemas.vscodeNotebookMetadata;
603
>
export function generate(notebook: URI): URI {
604
return generateMetadataUri(notebook);
605
}
607
return parseMetadataUri(metadata);
608
}
610
>
611
>
export namespace CellUri {
612
>
export const scheme = Schemas.vscodeNotebookCell;
613
>
export function generate(notebook: URI, handle: number): URI {
614
return generateUri(notebook, handle);
615
}
617
>
export function parse(cell: URI): { notebook: URI; handle: number } | undefined {
618
return parseUri(cell);
619
}
621
>
/**
622
>
* Generates a URI for a cell output in a notebook using the output ID.
623
>
* Used when URI should be opened as text in the editor.
624
>
*/
625
>
export function generateCellOutputUriWithId(notebook: URI, outputId?: string) {
626
return notebook.with({
627
scheme: Schemas.vscodeNotebookCellOutput,