Skip to content

Commit bb03411

Browse files
committed
moved CellEditOperation from common to browser
Signed-off-by: Jonah Iden <[email protected]>
1 parent c8b9969 commit bb03411

File tree

5 files changed

+66
-65
lines changed

5 files changed

+66
-65
lines changed

packages/notebook/src/browser/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ export * from './service/notebook-execution-state-service';
2424
export * from './service/notebook-model-resolver-service';
2525
export * from './service/notebook-renderer-messaging-service';
2626
export * from './renderers/cell-output-webview';
27+
export * from './notebook-types';

packages/notebook/src/browser/notebook-types.ts

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
// *****************************************************************************
1616

1717
import {
18-
CellData, CellOutput, CellOutputItem, CellRange, NotebookCellContentChangeEvent,
18+
CellData, CellEditType, CellMetadataEdit, CellOutput, CellOutputItem, CellRange, NotebookCellContentChangeEvent,
19+
NotebookCellInternalMetadata,
1920
NotebookCellsChangeInternalMetadataEvent,
2021
NotebookCellsChangeLanguageEvent,
2122
NotebookCellsChangeMetadataEvent,
@@ -104,3 +105,62 @@ export interface NotebookModelWillAddRemoveEvent {
104105
readonly newCellIds?: number[];
105106
readonly rawEvent: NotebookCellsModelChangedEvent<CellData>;
106107
};
108+
109+
export interface CellOutputEdit {
110+
editType: CellEditType.Output;
111+
index: number;
112+
outputs: CellOutput[];
113+
append?: boolean;
114+
}
115+
116+
export interface CellOutputEditByHandle {
117+
editType: CellEditType.Output;
118+
handle: number;
119+
outputs: CellOutput[];
120+
append?: boolean;
121+
}
122+
123+
export interface CellOutputItemEdit {
124+
editType: CellEditType.OutputItems;
125+
items: CellOutputItem[];
126+
outputId: string;
127+
append?: boolean;
128+
}
129+
130+
export interface CellLanguageEdit {
131+
editType: CellEditType.CellLanguage;
132+
index: number;
133+
language: string;
134+
}
135+
136+
export interface DocumentMetadataEdit {
137+
editType: CellEditType.DocumentMetadata;
138+
metadata: NotebookDocumentMetadata;
139+
}
140+
141+
export interface CellMoveEdit {
142+
editType: CellEditType.Move;
143+
index: number;
144+
length: number;
145+
newIdx: number;
146+
}
147+
148+
export interface CellReplaceEdit {
149+
editType: CellEditType.Replace;
150+
index: number;
151+
count: number;
152+
cells: CellData[];
153+
}
154+
155+
export type ImmediateCellEditOperation = CellOutputEditByHandle | CellOutputItemEdit | CellPartialInternalMetadataEditByHandle; // add more later on
156+
export type CellEditOperation = ImmediateCellEditOperation | CellReplaceEdit | CellOutputEdit |
157+
CellMetadataEdit | CellLanguageEdit | DocumentMetadataEdit | CellMoveEdit; // add more later on
158+
159+
export type NullablePartialNotebookCellInternalMetadata = {
160+
[Key in keyof Partial<NotebookCellInternalMetadata>]: NotebookCellInternalMetadata[Key] | null
161+
};
162+
export interface CellPartialInternalMetadataEditByHandle {
163+
editType: CellEditType.PartialInternalMetadata;
164+
handle: number;
165+
internalMetadata: NullablePartialNotebookCellInternalMetadata;
166+
}

packages/notebook/src/browser/service/notebook-execution-state-service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import { inject, injectable } from '@theia/core/shared/inversify';
2323
import { NotebookService } from './notebook-service';
2424
import {
2525
CellEditType, CellExecuteOutputEdit, CellExecuteOutputItemEdit, CellExecutionUpdateType,
26-
CellUri, CellPartialInternalMetadataEditByHandle, NotebookCellExecutionState, CellEditOperation, NotebookCellInternalMetadata
26+
CellUri, NotebookCellExecutionState, NotebookCellInternalMetadata
2727
} from '../../common';
28+
import { CellPartialInternalMetadataEditByHandle, CellEditOperation } from '../notebook-types';
2829
import { NotebookModel } from '../view-model/notebook-model';
2930
import { v4 } from 'uuid';
3031

packages/notebook/src/browser/view-model/notebook-model.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
import { Disposable, Emitter, URI } from '@theia/core';
1818
import { Saveable, SaveOptions } from '@theia/core/lib/browser';
1919
import {
20-
CellData,
21-
CellEditOperation, CellEditType, CellUri, NotebookCellInternalMetadata,
20+
CellData, CellEditType, CellUri, NotebookCellInternalMetadata,
2221
NotebookCellsChangeType, NotebookCellTextModelSplice, NotebookData,
2322
NotebookDocumentMetadata,
24-
NullablePartialNotebookCellInternalMetadata
2523
} from '../../common';
26-
import { NotebookContentChangedEvent, NotebookModelWillAddRemoveEvent } from '../notebook-types';
24+
import { NotebookContentChangedEvent, NotebookModelWillAddRemoveEvent, CellEditOperation, NullablePartialNotebookCellInternalMetadata } from '../notebook-types';
2725
import { NotebookSerializer } from '../service/notebook-service';
2826
import { FileService } from '@theia/filesystem/lib/browser/file-service';
2927
import { NotebookCellModel, NotebookCellModelFactory } from './notebook-cell-model';

packages/notebook/src/common/notebook-common.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ export interface CellData {
9797
collapseState?: NotebookCellCollapseState;
9898
}
9999

100-
export interface CellReplaceEdit {
101-
editType: CellEditType.Replace;
102-
index: number;
103-
count: number;
104-
cells: CellData[];
105-
}
106-
107100
export interface NotebookDocumentMetadataEdit {
108101
editType: CellEditType.DocumentMetadata;
109102
metadata: NotebookDocumentMetadata;
@@ -221,51 +214,12 @@ export interface CellExecutionStateUpdateDto {
221214
isPaused?: boolean;
222215
}
223216

224-
export interface CellOutputEdit {
225-
editType: CellEditType.Output;
226-
index: number;
227-
outputs: CellOutput[];
228-
append?: boolean;
229-
}
230-
231-
export interface CellOutputEditByHandle {
232-
editType: CellEditType.Output;
233-
handle: number;
234-
outputs: CellOutput[];
235-
append?: boolean;
236-
}
237-
238-
export interface CellOutputItemEdit {
239-
editType: CellEditType.OutputItems;
240-
items: CellOutputItem[];
241-
outputId: string;
242-
append?: boolean;
243-
}
244-
245217
export interface CellMetadataEdit {
246218
editType: CellEditType.Metadata;
247219
index: number;
248220
metadata: NotebookCellMetadata;
249221
}
250222

251-
export interface CellLanguageEdit {
252-
editType: CellEditType.CellLanguage;
253-
index: number;
254-
language: string;
255-
}
256-
257-
export interface DocumentMetadataEdit {
258-
editType: CellEditType.DocumentMetadata;
259-
metadata: NotebookDocumentMetadata;
260-
}
261-
262-
export interface CellMoveEdit {
263-
editType: CellEditType.Move;
264-
index: number;
265-
length: number;
266-
newIdx: number;
267-
}
268-
269223
export const enum CellEditType {
270224
Replace = 1,
271225
Output = 2,
@@ -278,19 +232,6 @@ export const enum CellEditType {
278232
PartialInternalMetadata = 9,
279233
}
280234

281-
export type ImmediateCellEditOperation = CellOutputEditByHandle | CellOutputItemEdit | CellPartialInternalMetadataEditByHandle; // add more later on
282-
export type CellEditOperation = ImmediateCellEditOperation | CellReplaceEdit | CellOutputEdit |
283-
CellMetadataEdit | CellLanguageEdit | DocumentMetadataEdit | CellMoveEdit; // add more later on
284-
285-
export type NullablePartialNotebookCellInternalMetadata = {
286-
[Key in keyof Partial<NotebookCellInternalMetadata>]: NotebookCellInternalMetadata[Key] | null
287-
};
288-
export interface CellPartialInternalMetadataEditByHandle {
289-
editType: CellEditType.PartialInternalMetadata;
290-
handle: number;
291-
internalMetadata: NullablePartialNotebookCellInternalMetadata;
292-
}
293-
294235
export interface NotebookKernelSourceAction {
295236
readonly label: string;
296237
readonly description?: string;

0 commit comments

Comments
 (0)