@opensumi/ide-editor 3.3.1-next-1725432779.0 → 3.3.1-next-1725433243.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/lib/browser/editor-collection.service.d.ts +1 -1
  2. package/lib/browser/editor-collection.service.d.ts.map +1 -1
  3. package/lib/browser/editor-collection.service.js +2 -2
  4. package/lib/browser/editor-collection.service.js.map +1 -1
  5. package/lib/browser/editor.module.less +1 -0
  6. package/lib/browser/editor.view.d.ts +4 -2
  7. package/lib/browser/editor.view.d.ts.map +1 -1
  8. package/lib/browser/editor.view.js +6 -16
  9. package/lib/browser/editor.view.js.map +1 -1
  10. package/lib/browser/index.d.ts.map +1 -1
  11. package/lib/browser/index.js +5 -0
  12. package/lib/browser/index.js.map +1 -1
  13. package/lib/browser/notebook.service.d.ts +20 -0
  14. package/lib/browser/notebook.service.d.ts.map +1 -0
  15. package/lib/browser/notebook.service.js +24 -0
  16. package/lib/browser/notebook.service.js.map +1 -0
  17. package/lib/browser/workbench-editor.service.d.ts +6 -1
  18. package/lib/browser/workbench-editor.service.d.ts.map +1 -1
  19. package/lib/browser/workbench-editor.service.js +118 -71
  20. package/lib/browser/workbench-editor.service.js.map +1 -1
  21. package/lib/common/editor.d.ts +1 -1
  22. package/lib/common/editor.d.ts.map +1 -1
  23. package/lib/common/index.d.ts +4 -3
  24. package/lib/common/index.d.ts.map +1 -1
  25. package/lib/common/index.js +4 -3
  26. package/lib/common/index.js.map +1 -1
  27. package/lib/common/language.d.ts +1 -0
  28. package/lib/common/language.d.ts.map +1 -1
  29. package/lib/common/notebook.d.ts +169 -0
  30. package/lib/common/notebook.d.ts.map +1 -0
  31. package/lib/common/notebook.js +26 -0
  32. package/lib/common/notebook.js.map +1 -0
  33. package/package.json +14 -14
  34. package/src/browser/editor-collection.service.ts +2 -2
  35. package/src/browser/editor.module.less +1 -0
  36. package/src/browser/editor.view.tsx +174 -183
  37. package/src/browser/index.ts +6 -0
  38. package/src/browser/notebook.service.ts +19 -0
  39. package/src/browser/workbench-editor.service.ts +105 -70
  40. package/src/common/editor.ts +1 -1
  41. package/src/common/index.ts +4 -3
  42. package/src/common/language.ts +1 -0
  43. package/src/common/notebook.ts +196 -0
@@ -1,3 +1,5 @@
1
+ import { observable } from 'mobx';
2
+
1
3
  import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
2
4
  import {
3
5
  AppConfig,
@@ -16,7 +18,6 @@ import {
16
18
  toMarkdown,
17
19
  } from '@opensumi/ide-core-browser';
18
20
  import { ResourceContextKey } from '@opensumi/ide-core-browser/lib/contextkey/resource';
19
- import { IDimension } from '@opensumi/ide-core-browser/lib/dom/resize-observer';
20
21
  import { IMergeEditorEditor, MergeEditorInputData } from '@opensumi/ide-core-browser/lib/monaco/merge-editor-widget';
21
22
  import {
22
23
  CUSTOM_EDITOR_SCHEME,
@@ -41,6 +42,7 @@ import {
41
42
  StorageProvider,
42
43
  URI,
43
44
  WithEventBus,
45
+ debounce,
44
46
  formatLocalize,
45
47
  getDebugLogger,
46
48
  isDefined,
@@ -278,7 +280,7 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
278
280
  createEditorGroup(): EditorGroup {
279
281
  const editorGroup = this.injector.get(EditorGroup, [this.generateRandomEditorGroupName(), this.editorGroupIdGen++]);
280
282
  this.editorGroups.push(editorGroup);
281
- editorGroup.addDispose([
283
+ const currentWatchDisposer = new Disposable(
282
284
  editorGroup.onDidEditorGroupBodyChanged(() => {
283
285
  if (editorGroup === this.currentEditorGroup) {
284
286
  if (!editorGroup.currentOpenType && editorGroup.currentResource) {
@@ -297,15 +299,25 @@ export class WorkbenchEditorServiceImpl extends WithEventBus implements Workbenc
297
299
  }
298
300
  }
299
301
  }),
300
- editorGroup.onDidEditorGroupTabChanged(() => {
301
- this.saveOpenedResourceState();
302
- }),
303
- editorGroup.onCurrentEditorCursorChange((e) => {
304
- if (this._currentEditorGroup === editorGroup) {
305
- this._onCursorChange.fire(e);
306
- }
307
- }),
308
- ]);
302
+ );
303
+ editorGroup.addDispose({
304
+ dispose: () => {
305
+ currentWatchDisposer.dispose();
306
+ },
307
+ });
308
+ const groupChangeDisposer = editorGroup.onDidEditorGroupTabChanged(() => {
309
+ this.saveOpenedResourceState();
310
+ });
311
+ editorGroup.addDispose({
312
+ dispose: () => {
313
+ groupChangeDisposer.dispose();
314
+ },
315
+ });
316
+ editorGroup.onCurrentEditorCursorChange((e) => {
317
+ if (this._currentEditorGroup === editorGroup) {
318
+ this._onCursorChange.fire(e);
319
+ }
320
+ });
309
321
 
310
322
  return editorGroup;
311
323
  }
@@ -677,25 +689,25 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
677
689
  /**
678
690
  * 当编辑器的tab部分发生变更
679
691
  */
680
- _onDidEditorGroupTabChanged = this.registerDispose(new EventEmitter<void>());
692
+ _onDidEditorGroupTabChanged = new EventEmitter<void>();
681
693
  onDidEditorGroupTabChanged: Event<void> = this._onDidEditorGroupTabChanged.event;
682
694
 
683
695
  /**
684
696
  * 当编辑器的tab部分发生变更
685
697
  */
686
- _onDidEditorGroupTabOperation = this.registerDispose(new EventEmitter<IResourceTabOperation>());
698
+ _onDidEditorGroupTabOperation = new EventEmitter<IResourceTabOperation>();
687
699
  onDidEditorGroupTabOperation: Event<IResourceTabOperation> = this._onDidEditorGroupTabOperation.event;
688
700
 
689
701
  /**
690
702
  * 当编辑器的主体部分发生变更
691
703
  */
692
- _onDidEditorGroupBodyChanged = this.registerDispose(new EventEmitter<void>());
704
+ _onDidEditorGroupBodyChanged = new EventEmitter<void>();
693
705
  onDidEditorGroupBodyChanged: Event<void> = this._onDidEditorGroupBodyChanged.event;
694
706
 
695
707
  /**
696
708
  * 当编辑器有内容处于加载状态
697
709
  */
698
- _onDidEditorGroupContentLoading = this.registerDispose(new EventEmitter<IResource>());
710
+ _onDidEditorGroupContentLoading = new EventEmitter<IResource>();
699
711
  onDidEditorGroupContentLoading: Event<IResource> = this._onDidEditorGroupContentLoading.event;
700
712
 
701
713
  /**
@@ -721,6 +733,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
721
733
 
722
734
  private cachedResourcesOpenTypes = new Map<string, IEditorOpenType[]>();
723
735
 
736
+ @observable.shallow
724
737
  availableOpenTypes: IEditorOpenType[] = [];
725
738
 
726
739
  activeComponents = new Map<IEditorComponent, IResource[]>();
@@ -731,6 +744,8 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
731
744
 
732
745
  private holdDocumentModelRefs: Map<string, IEditorDocumentModelRef> = new Map();
733
746
 
747
+ private readonly toDispose: monaco.IDisposable[] = [];
748
+
734
749
  private _contextKeyService: IContextKeyService;
735
750
 
736
751
  private _resourceContext: ResourceContextKey;
@@ -748,8 +763,12 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
748
763
  private _prevDomHeight = 0;
749
764
  private _prevDomWidth = 0;
750
765
 
766
+ private _codeEditorPendingLayout = false;
767
+ private _diffEditorPendingLayout = false;
768
+ private _mergeEditorPendingLayout = false;
769
+
751
770
  // 当前为EditorComponent,且monaco光标变化时触发
752
- private _onCurrentEditorCursorChange = this.registerDispose(new EventEmitter<CursorStatus>());
771
+ private _onCurrentEditorCursorChange = new EventEmitter<CursorStatus>();
753
772
  public onCurrentEditorCursorChange = this._onCurrentEditorCursorChange.event;
754
773
 
755
774
  private resourceOpenHistory: URI[] = [];
@@ -776,28 +795,28 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
776
795
 
777
796
  constructor(public readonly name: string, public readonly groupId: number) {
778
797
  super();
779
-
780
- this.addDispose(
781
- this.eventBus.onDirective(
782
- ResizeEvent.createDirective(getSlotLocation('@opensumi/ide-editor', this.config.layoutConfig)),
783
- () => {
784
- this.layoutEditors();
785
- },
786
- ),
787
- );
788
- this.addDispose(
789
- this.eventBus.on(GridResizeEvent, (e: GridResizeEvent) => {
790
- if (e.payload.gridId === this.grid.uid) {
791
- this.layoutEditors();
798
+ let toDispose: IDisposable | undefined;
799
+ this.eventBus.onDirective(
800
+ ResizeEvent.createDirective(getSlotLocation('@opensumi/ide-editor', this.config.layoutConfig)),
801
+ () => {
802
+ if (toDispose) {
803
+ toDispose.dispose();
792
804
  }
793
- }),
794
- );
795
- this.addDispose(
796
- this.eventBus.on(EditorComponentDisposeEvent, (e: EditorComponentDisposeEvent) => {
797
- this.activeComponents.delete(e.payload);
798
- this.activateComponentsProps.delete(e.payload);
799
- }),
805
+
806
+ toDispose = fastdom.mutate(() => {
807
+ this._layoutEditorWorker();
808
+ });
809
+ },
800
810
  );
811
+ this.eventBus.on(GridResizeEvent, (e: GridResizeEvent) => {
812
+ if (e.payload.gridId === this.grid.uid) {
813
+ this.doLayoutEditors();
814
+ }
815
+ });
816
+ this.eventBus.on(EditorComponentDisposeEvent, (e: EditorComponentDisposeEvent) => {
817
+ this.activeComponents.delete(e.payload);
818
+ this.activateComponentsProps.delete(e.payload);
819
+ });
801
820
 
802
821
  this.listenToExplorerAutoRevealConfig();
803
822
  }
@@ -806,8 +825,10 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
806
825
  private listenToExplorerAutoRevealConfig() {
807
826
  this.explorerAutoRevealConfig = !!this.preferenceService.get<boolean>('explorer.autoReveal');
808
827
  this.disposables.push(
809
- this.preferenceService.onSpecificPreferenceChange('explorer.autoReveal', (change) => {
810
- this.explorerAutoRevealConfig = change.newValue;
828
+ this.preferenceService.onPreferenceChanged((change) => {
829
+ if (change.preferenceName === 'explorer.autoReveal') {
830
+ this.explorerAutoRevealConfig = change.newValue;
831
+ }
811
832
  }),
812
833
  );
813
834
  }
@@ -839,32 +860,49 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
839
860
  layoutEditors() {
840
861
  fastdom.measure(() => {
841
862
  if (this._domNode) {
842
- this._prevDomWidth = this._domNode.offsetWidth;
843
- this._prevDomHeight = this._domNode.offsetHeight;
844
- this.doLayoutEditors(
845
- {
846
- width: this._prevDomWidth,
847
- height: this._prevDomHeight,
848
- },
849
- true,
850
- );
863
+ const currentWidth = this._domNode.offsetWidth;
864
+ const currentHeight = this._domNode.offsetHeight;
865
+ if (currentWidth !== this._prevDomWidth || currentHeight !== this._prevDomHeight) {
866
+ this.doLayoutEditors();
867
+ }
868
+ this._prevDomWidth = currentWidth;
869
+ this._prevDomHeight = currentHeight;
851
870
  }
852
871
  });
853
872
  }
854
873
 
855
- private doLayoutEditors(e: IDimension, postponeRendering?: boolean) {
874
+ private _layoutEditorWorker() {
856
875
  if (this.codeEditor) {
857
876
  if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
858
- this.codeEditor.layout(e, postponeRendering);
877
+ this.codeEditor.layout();
878
+ this._codeEditorPendingLayout = false;
879
+ } else {
880
+ this._codeEditorPendingLayout = true;
859
881
  }
860
882
  }
861
883
  if (this.diffEditor) {
862
884
  if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
863
- this.diffEditor.layout(e, postponeRendering);
885
+ this.diffEditor.layout();
886
+ this._diffEditorPendingLayout = false;
887
+ } else {
888
+ this._diffEditorPendingLayout = true;
889
+ }
890
+ }
891
+ if (this.mergeEditor) {
892
+ if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.mergeEditor) {
893
+ // this.mergeEditor.layout();
894
+ this._mergeEditorPendingLayout = false;
895
+ } else {
896
+ this._mergeEditorPendingLayout = true;
864
897
  }
865
898
  }
866
899
  }
867
900
 
901
+ @debounce(16 * 5)
902
+ doLayoutEditors() {
903
+ this._layoutEditorWorker();
904
+ }
905
+
868
906
  setContextKeys() {
869
907
  if (!this._resourceContext) {
870
908
  const getLanguageFromModel = (uri: URI) => {
@@ -1103,21 +1141,19 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
1103
1141
  );
1104
1142
 
1105
1143
  setTimeout(() => {
1106
- fastdom.mutate(() => {
1107
- this.codeEditor.layout();
1108
- });
1144
+ this.codeEditor.layout();
1109
1145
  });
1110
1146
  this.addDispose(
1111
1147
  this.codeEditor.onRefOpen(() => {
1112
1148
  this.codeEditor.layout();
1113
1149
  }),
1114
1150
  );
1115
- this.addDispose(
1151
+ this.toDispose.push(
1116
1152
  this.codeEditor.onCursorPositionChanged((e) => {
1117
1153
  this._onCurrentEditorCursorChange.fire(e);
1118
1154
  }),
1119
1155
  );
1120
- this.addDispose(
1156
+ this.toDispose.push(
1121
1157
  this.codeEditor.onSelectionsChanged((e) => {
1122
1158
  if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
1123
1159
  this.eventBus.fire(
@@ -1132,7 +1168,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
1132
1168
  }
1133
1169
  }),
1134
1170
  );
1135
- this.addDispose(
1171
+ this.toDispose.push(
1136
1172
  this.codeEditor.onVisibleRangesChanged((e) => {
1137
1173
  if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
1138
1174
  this.eventBus.fire(
@@ -1146,7 +1182,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
1146
1182
  }
1147
1183
  }),
1148
1184
  );
1149
- this.addDispose(
1185
+ this.toDispose.push(
1150
1186
  this.codeEditor.onConfigurationChanged(() => {
1151
1187
  if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.code) {
1152
1188
  this.eventBus.fire(
@@ -1189,15 +1225,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
1189
1225
  },
1190
1226
  );
1191
1227
  setTimeout(() => {
1192
- fastdom.mutate(() => {
1193
- this.diffEditor.layout();
1194
- });
1195
- });
1196
-
1197
- this.diffEditor.onRefOpen(() => {
1198
- fastdom.mutate(() => {
1199
- this.diffEditor.layout();
1200
- });
1228
+ this.diffEditor.layout();
1201
1229
  });
1202
1230
 
1203
1231
  this.addDiffEditorEventListeners(this.diffEditor.originalEditor, 'original');
@@ -1222,7 +1250,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
1222
1250
  }
1223
1251
 
1224
1252
  private addDiffEditorEventListeners(editor: IEditor, side?: 'modified' | 'original') {
1225
- this.addDispose(
1253
+ this.toDispose.push(
1226
1254
  editor.onSelectionsChanged((e) => {
1227
1255
  if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
1228
1256
  this.eventBus.fire(
@@ -1239,7 +1267,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
1239
1267
  }),
1240
1268
  );
1241
1269
 
1242
- this.addDispose(
1270
+ this.toDispose.push(
1243
1271
  editor.onVisibleRangesChanged((e) => {
1244
1272
  if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
1245
1273
  this.eventBus.fire(
@@ -1254,7 +1282,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
1254
1282
  }),
1255
1283
  );
1256
1284
 
1257
- this.addDispose(
1285
+ this.toDispose.push(
1258
1286
  editor.onConfigurationChanged(() => {
1259
1287
  if (this.currentOpenType && this.currentOpenType.type === EditorOpenType.diff) {
1260
1288
  this.eventBus.fire(
@@ -1810,7 +1838,13 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
1810
1838
  this._currentOpenType = activeOpenType;
1811
1839
  this.notifyBodyChanged();
1812
1840
 
1813
- this.layoutEditors();
1841
+ if (
1842
+ (!this._codeEditorPendingLayout && activeOpenType.type === EditorOpenType.code) ||
1843
+ (!this._diffEditorPendingLayout && activeOpenType.type === EditorOpenType.diff) ||
1844
+ (!this._mergeEditorPendingLayout && activeOpenType.type === EditorOpenType.mergeEditor)
1845
+ ) {
1846
+ this.doLayoutEditors();
1847
+ }
1814
1848
 
1815
1849
  this.cachedResourcesActiveOpenTypes.set(resource.uri.toString(), activeOpenType);
1816
1850
  }
@@ -2208,6 +2242,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
2208
2242
  super.dispose();
2209
2243
  this.codeEditor && this.codeEditor.dispose();
2210
2244
  this.diffEditor && this.diffEditor.dispose();
2245
+ this.toDispose.forEach((disposable) => disposable.dispose());
2211
2246
  this.eventBus.fire(
2212
2247
  new EditorGroupDisposeEvent({
2213
2248
  group: this,
@@ -310,7 +310,7 @@ export interface IDiffEditor extends IDisposable {
310
310
 
311
311
  modifiedEditor: IEditor;
312
312
 
313
- layout(dimension?: IDimension, postponeRendering?: boolean): void;
313
+ layout(): void;
314
314
 
315
315
  focus(): void;
316
316
 
@@ -1,7 +1,8 @@
1
+ export * from './components';
1
2
  export * from './doc-cache';
2
3
  export * from './editor';
3
- export * from './resource';
4
4
  export * from './language';
5
- export * from './utils';
6
5
  export * from './language-status';
7
- export * from './components';
6
+ export * from './notebook';
7
+ export * from './resource';
8
+ export * from './utils';
@@ -201,6 +201,7 @@ export interface LanguageFilter {
201
201
  scheme?: string;
202
202
  pattern?: string | IRelativePattern;
203
203
  hasAccessToAllModels?: boolean;
204
+ notebookType?: string;
204
205
  }
205
206
 
206
207
  export type LanguageSelector = string | LanguageFilter | (string | LanguageFilter)[];
@@ -0,0 +1,196 @@
1
+ import { Event, IRange, UriComponents } from '@opensumi/ide-core-common';
2
+
3
+ export enum NotebookCellsChangeType {
4
+ ModelChange = 1,
5
+ Move = 2,
6
+ ChangeCellLanguage = 5,
7
+ Initialize = 6,
8
+ ChangeCellMetadata = 7,
9
+ Output = 8,
10
+ OutputItem = 9,
11
+ ChangeCellContent = 10,
12
+ ChangeDocumentMetadata = 11,
13
+ ChangeCellInternalMetadata = 12,
14
+ ChangeCellMime = 13,
15
+ Unknown = 100,
16
+ }
17
+
18
+ export type NotebookCellTextModelSplice<T> = [start: number, deleteCount: number, newItems: T[]];
19
+
20
+ /**
21
+ * [start, end]
22
+ */
23
+ export interface ICellRange {
24
+ /**
25
+ * zero based index
26
+ */
27
+ start: number;
28
+
29
+ /**
30
+ * zero based index
31
+ */
32
+ end: number;
33
+ }
34
+
35
+ export enum CellKind {
36
+ Markup = 1,
37
+ Code = 2,
38
+ }
39
+
40
+ export interface NotebookCellMetadata {
41
+ /**
42
+ * custom metadata
43
+ */
44
+ [key: string]: unknown;
45
+ }
46
+
47
+ export interface ICellExecutionError {
48
+ message: string;
49
+ stack: string | undefined;
50
+ uri: UriComponents;
51
+ location: IRange | undefined;
52
+ }
53
+
54
+ export type NotebookDocumentMetadata = Record<string, unknown>;
55
+ export interface NotebookCellInternalMetadata {
56
+ executionId?: string;
57
+ executionOrder?: number;
58
+ lastRunSuccess?: boolean;
59
+ runStartTime?: number;
60
+ runStartTimeAdjustment?: number;
61
+ runEndTime?: number;
62
+ renderDuration?: { [key: string]: number };
63
+ error?: ICellExecutionError;
64
+ }
65
+
66
+ export interface NotebookOutputItemDto {
67
+ readonly mime: string;
68
+ readonly valueBytes: Buffer;
69
+ }
70
+
71
+ export interface NotebookOutputDto {
72
+ items: NotebookOutputItemDto[];
73
+ outputId: string;
74
+ metadata?: Record<string, any>;
75
+ }
76
+
77
+ export interface NotebookCellDto {
78
+ handle: number;
79
+ uri: UriComponents;
80
+ eol: string;
81
+ source: string[];
82
+ language: string;
83
+ mime?: string;
84
+ cellKind: CellKind;
85
+ outputs: NotebookOutputDto[];
86
+ metadata?: NotebookCellMetadata;
87
+ internalMetadata?: NotebookCellInternalMetadata;
88
+ }
89
+
90
+ export interface NotebookCellDataDto {
91
+ source: string;
92
+ language: string;
93
+ mime: string | undefined;
94
+ cellKind: CellKind;
95
+ outputs: NotebookOutputDto[];
96
+ metadata?: NotebookCellMetadata;
97
+ internalMetadata?: NotebookCellInternalMetadata;
98
+ }
99
+
100
+ export interface NotebookDataDto {
101
+ readonly cells: NotebookCellDataDto[];
102
+ readonly metadata: NotebookDocumentMetadata;
103
+ }
104
+
105
+ export interface NotebookCellsChangeLanguageEvent {
106
+ readonly kind: NotebookCellsChangeType.ChangeCellLanguage;
107
+ readonly index: number;
108
+ readonly language: string;
109
+ }
110
+
111
+ export interface NotebookCellsChangeMimeEvent {
112
+ readonly kind: NotebookCellsChangeType.ChangeCellMime;
113
+ readonly index: number;
114
+ readonly mime: string | undefined;
115
+ }
116
+
117
+ export interface NotebookCellsChangeMetadataEvent {
118
+ readonly kind: NotebookCellsChangeType.ChangeCellMetadata;
119
+ readonly index: number;
120
+ readonly metadata: NotebookCellMetadata;
121
+ }
122
+
123
+ export interface NotebookCellsChangeInternalMetadataEvent {
124
+ readonly kind: NotebookCellsChangeType.ChangeCellInternalMetadata;
125
+ readonly index: number;
126
+ readonly internalMetadata: NotebookCellInternalMetadata;
127
+ }
128
+
129
+ export interface NotebookCellContentChangeEvent {
130
+ readonly kind: NotebookCellsChangeType.ChangeCellContent;
131
+ readonly index: number;
132
+ }
133
+
134
+ export type NotebookRawContentEventDto =
135
+ | {
136
+ readonly kind: NotebookCellsChangeType.ModelChange;
137
+ readonly changes: NotebookCellTextModelSplice<NotebookCellDto>[];
138
+ }
139
+ | {
140
+ readonly kind: NotebookCellsChangeType.Move;
141
+ readonly index: number;
142
+ readonly length: number;
143
+ readonly newIdx: number;
144
+ }
145
+ | {
146
+ readonly kind: NotebookCellsChangeType.Output;
147
+ readonly index: number;
148
+ readonly outputs: NotebookOutputDto[];
149
+ }
150
+ | {
151
+ readonly kind: NotebookCellsChangeType.OutputItem;
152
+ readonly index: number;
153
+ readonly outputId: string;
154
+ readonly outputItems: NotebookOutputItemDto[];
155
+ readonly append: boolean;
156
+ }
157
+ | NotebookCellsChangeLanguageEvent
158
+ | NotebookCellsChangeMimeEvent
159
+ | NotebookCellsChangeMetadataEvent
160
+ | NotebookCellsChangeInternalMetadataEvent
161
+ | NotebookCellContentChangeEvent;
162
+
163
+ export interface NotebookCellsChangedEventDto {
164
+ readonly rawEvents: NotebookRawContentEventDto[];
165
+ readonly versionId: number;
166
+ }
167
+
168
+ export interface INotebookModelAddedData {
169
+ uri: UriComponents;
170
+ versionId: number;
171
+ cells: NotebookCellDto[];
172
+ viewType: string;
173
+ metadata?: NotebookDocumentMetadata;
174
+ }
175
+
176
+ export interface NotebookDocumentChangeDto {
177
+ uri: UriComponents;
178
+ event: NotebookCellsChangedEventDto;
179
+ isDirty: boolean;
180
+ metadata?: NotebookDocumentMetadata;
181
+ }
182
+
183
+ export const INotebookService = Symbol('INotebookService');
184
+
185
+ export interface INotebookService {
186
+ createNotebook: (data?: NotebookDataDto) => Promise<{ uri: UriComponents }>;
187
+ openNotebook: (uriComponents: UriComponents) => Promise<{ uri: UriComponents }>;
188
+ saveNotebook: (uriComponents: UriComponents) => Promise<boolean>;
189
+
190
+ onDidOpenNotebookDocument: Event<INotebookModelAddedData>;
191
+ onDidCloseNotebookDocument: Event<UriComponents>;
192
+ onDidSaveNotebookDocument: Event<UriComponents>;
193
+ onDidChangeNotebookDocument: Event<NotebookDocumentChangeDto>;
194
+ }
195
+
196
+ export const notebookCellScheme = 'vscode-notebook-cell';