@jupyterlab/cells 4.0.0-alpha.8 → 4.0.0-beta.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.
@@ -1,9 +1,3 @@
1
- /**
2
- * This module contains some utility functions to operate on cells. This
3
- * could be shared by widgets that contain cells, like the CodeConsole or
4
- * Notebook widgets.
5
- */
6
- import { IterableOrArrayLike } from '@lumino/algorithm';
7
1
  import { Cell } from './widget';
8
2
  import * as nbformat from '@jupyterlab/nbformat';
9
3
  export declare namespace CellDragUtils {
@@ -21,7 +15,7 @@ export declare namespace CellDragUtils {
21
15
  * @returns index of the cell we're looking for. Returns -1 if
22
16
  * the cell is not founds
23
17
  */
24
- function findCell(node: HTMLElement, cells: IterableOrArrayLike<Cell>, isCellNode: (node: HTMLElement) => boolean): number;
18
+ function findCell(node: HTMLElement, cells: Iterable<Cell>, isCellNode: (node: HTMLElement) => boolean): number;
25
19
  /**
26
20
  * Detect which part of the cell triggered the MouseEvent
27
21
  *
@@ -2,12 +2,6 @@
2
2
  | Copyright (c) Jupyter Development Team.
3
3
  | Distributed under the terms of the Modified BSD License.
4
4
  |----------------------------------------------------------------------------*/
5
- /**
6
- * This module contains some utility functions to operate on cells. This
7
- * could be shared by widgets that contain cells, like the CodeConsole or
8
- * Notebook widgets.
9
- */
10
- import { each } from '@lumino/algorithm';
11
5
  import { h, VirtualDOM } from '@lumino/virtualdom';
12
6
  /**
13
7
  * Constants for drag
@@ -55,12 +49,13 @@ export var CellDragUtils;
55
49
  let cellIndex = -1;
56
50
  while (node && node.parentElement) {
57
51
  if (isCellNode(node)) {
58
- each(cells, (cell, index) => {
52
+ let index = -1;
53
+ for (const cell of cells) {
59
54
  if (cell.node === node) {
60
- cellIndex = index;
61
- return false;
55
+ cellIndex = ++index;
56
+ break;
62
57
  }
63
- });
58
+ }
64
59
  break;
65
60
  }
66
61
  node = node.parentElement;
@@ -75,12 +70,13 @@ export var CellDragUtils;
75
70
  * @param target - The DOM node which triggered the MouseEvent
76
71
  */
77
72
  function detectTargetArea(cell, target) {
73
+ var _a, _b;
78
74
  let targetArea;
79
75
  if (cell) {
80
- if (cell.editorWidget.node.contains(target)) {
76
+ if ((_a = cell.editorWidget) === null || _a === void 0 ? void 0 : _a.node.contains(target)) {
81
77
  targetArea = 'input';
82
78
  }
83
- else if (cell.promptNode.contains(target)) {
79
+ else if ((_b = cell.promptNode) === null || _b === void 0 ? void 0 : _b.contains(target)) {
84
80
  targetArea = 'prompt';
85
81
  }
86
82
  else {
@@ -128,7 +124,10 @@ export var CellDragUtils;
128
124
  else {
129
125
  promptNumber = '';
130
126
  }
131
- const cellContent = activeCell.model.value.text.split('\n')[0].slice(0, 26);
127
+ const cellContent = activeCell.model.sharedModel
128
+ .getSource()
129
+ .split('\n')[0]
130
+ .slice(0, 26);
132
131
  if (count > 1) {
133
132
  if (promptNumber !== '') {
134
133
  return VirtualDOM.realize(h.div(h.div({ className: DRAG_IMAGE_CLASS }, h.span({ className: CELL_DRAG_PROMPT_CLASS }, '[' + promptNumber + ']:'), h.span({ className: CELL_DRAG_CONTENT_CLASS }, cellContent)), h.div({ className: CELL_DRAG_MULTIPLE_BACK }, '')));
@@ -1 +1 @@
1
- {"version":3,"file":"celldragutils.js","sourceRoot":"","sources":["../src/celldragutils.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAE/E;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAuB,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;GAEG;AAEH;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB;;GAEG;AACH,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAExC;;GAEG;AACH,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAE5D;;GAEG;AACH,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAEvD;;GAEG;AACH,MAAM,sBAAsB,GAA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E,EACrC,GAAG,GAAG,YAAY,GAAG,IAAI,CAC1B,EACD,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,EAAE,WAAW,CAAC,CAC5D,CACF,CACF,CAAC;aACH;iBAAM;gBACL,OAAO,UAAU,CAAC,OAAO,CACvB,CAAC,CAAC,GAAG,CACH,CAAC,CAAC,GAAG,CACH,EAAE,SAAS,EAAE,GAAG,gBAAgB,IAAI,uBAAuB,EAAE,EAAE,EAC/D,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,sBAAsB,EAAE,CAAC,EAC7C,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,EAAE,WAAW,CAAC,CAC5D,CACF,CACF,CAAC;aACH;SACF;IACH,CAAC;IA1Ee,iCAAmB,sBA0ElC,CAAA;AACH,CAAC,EApKgB,aAAa,KAAb,aAAa,QAoK7B"}
package/lib/index.d.ts CHANGED
@@ -8,4 +8,5 @@ export * from './headerfooter';
8
8
  export * from './inputarea';
9
9
  export * from './model';
10
10
  export * from './placeholder';
11
+ export * from './searchprovider';
11
12
  export * from './widget';
package/lib/index.js CHANGED
@@ -12,5 +12,6 @@ export * from './headerfooter';
12
12
  export * from './inputarea';
13
13
  export * from './model';
14
14
  export * from './placeholder';
15
+ export * from './searchprovider';
15
16
  export * from './widget';
16
17
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
@@ -32,6 +32,10 @@ export declare class InputArea extends Widget {
32
32
  * Get the prompt node used by the cell.
33
33
  */
34
34
  get promptNode(): HTMLElement;
35
+ /**
36
+ * Get the rendered input area widget, if any.
37
+ */
38
+ get renderedInput(): Widget;
35
39
  /**
36
40
  * Render an input instead of the text editor.
37
41
  */
@@ -66,18 +70,12 @@ export declare namespace InputArea {
66
70
  model: ICellModel;
67
71
  /**
68
72
  * The content factory used by the widget to create children.
69
- *
70
- * Defaults to one that uses CodeMirror.
71
- */
72
- contentFactory?: IContentFactory;
73
- /**
74
- * Whether to send an update request to the editor when it is shown.
75
73
  */
76
- updateOnShow?: boolean;
74
+ contentFactory: IContentFactory;
77
75
  /**
78
- * Whether this input area is a placeholder for future rendering.
76
+ * Editor options
79
77
  */
80
- placeholder?: boolean;
78
+ editorOptions?: Omit<CodeEditor.IOptions, 'host' | 'model'>;
81
79
  }
82
80
  /**
83
81
  * An input area widget content factory.
@@ -107,7 +105,7 @@ export declare namespace InputArea {
107
105
  /**
108
106
  * Construct a `ContentFactory`.
109
107
  */
110
- constructor(options?: ContentFactory.IOptions);
108
+ constructor(options: ContentFactory.IOptions);
111
109
  /**
112
110
  * Return the `CodeEditor.Factory` being used.
113
111
  */
@@ -132,17 +130,9 @@ export declare namespace InputArea {
132
130
  * If this is not passed, a default CodeMirror editor factory
133
131
  * will be used.
134
132
  */
135
- editorFactory?: CodeEditor.Factory;
133
+ editorFactory: CodeEditor.Factory;
136
134
  }
137
135
  }
138
- /**
139
- * The default editor factory singleton based on CodeMirror.
140
- */
141
- const defaultEditorFactory: CodeEditor.Factory;
142
- /**
143
- * The default `ContentFactory` instance.
144
- */
145
- const defaultContentFactory: ContentFactory;
146
136
  }
147
137
  /** ****************************************************************************
148
138
  * InputPrompt
package/lib/inputarea.js CHANGED
@@ -5,7 +5,6 @@
5
5
  import { PanelLayout } from '@lumino/widgets';
6
6
  import { Widget } from '@lumino/widgets';
7
7
  import { CodeEditorWrapper } from '@jupyterlab/codeeditor';
8
- import { CodeMirrorEditorFactory } from '@jupyterlab/codemirror';
9
8
  /**
10
9
  * The class name added to input area widgets.
11
10
  */
@@ -35,25 +34,22 @@ export class InputArea extends Widget {
35
34
  constructor(options) {
36
35
  super();
37
36
  this.addClass(INPUT_AREA_CLASS);
38
- const model = (this.model = options.model);
39
- const contentFactory = (this.contentFactory =
40
- options.contentFactory || InputArea.defaultContentFactory);
37
+ const { contentFactory, editorOptions, model } = options;
38
+ this.model = model;
39
+ this.contentFactory = contentFactory;
41
40
  // Prompt
42
41
  const prompt = (this._prompt = contentFactory.createInputPrompt());
43
42
  prompt.addClass(INPUT_AREA_PROMPT_CLASS);
44
43
  // Editor
45
- const editorOptions = {
46
- model,
44
+ const editor = (this._editor = new CodeEditorWrapper({
47
45
  factory: contentFactory.editorFactory,
48
- updateOnShow: options.updateOnShow
49
- };
50
- const editor = (this._editor = new CodeEditorWrapper(editorOptions));
46
+ model,
47
+ editorOptions
48
+ }));
51
49
  editor.addClass(INPUT_AREA_EDITOR_CLASS);
52
50
  const layout = (this.layout = new PanelLayout());
53
51
  layout.addWidget(prompt);
54
- if (!options.placeholder) {
55
- layout.addWidget(editor);
56
- }
52
+ layout.addWidget(editor);
57
53
  }
58
54
  /**
59
55
  * Get the CodeEditorWrapper used by the cell.
@@ -73,6 +69,12 @@ export class InputArea extends Widget {
73
69
  get promptNode() {
74
70
  return this._prompt.node;
75
71
  }
72
+ /**
73
+ * Get the rendered input area widget, if any.
74
+ */
75
+ get renderedInput() {
76
+ return this._rendered;
77
+ }
76
78
  /**
77
79
  * Render an input instead of the text editor.
78
80
  */
@@ -127,8 +129,8 @@ export class InputArea extends Widget {
127
129
  /**
128
130
  * Construct a `ContentFactory`.
129
131
  */
130
- constructor(options = {}) {
131
- this._editor = options.editorFactory || InputArea.defaultEditorFactory;
132
+ constructor(options) {
133
+ this._editor = options.editorFactory;
132
134
  }
133
135
  /**
134
136
  * Return the `CodeEditor.Factory` being used.
@@ -144,21 +146,6 @@ export class InputArea extends Widget {
144
146
  }
145
147
  }
146
148
  InputArea.ContentFactory = ContentFactory;
147
- /**
148
- * A function to create the default CodeMirror editor factory.
149
- */
150
- function _createDefaultEditorFactory() {
151
- const editorServices = new CodeMirrorEditorFactory();
152
- return editorServices.newInlineEditor;
153
- }
154
- /**
155
- * The default editor factory singleton based on CodeMirror.
156
- */
157
- InputArea.defaultEditorFactory = _createDefaultEditorFactory();
158
- /**
159
- * The default `ContentFactory` instance.
160
- */
161
- InputArea.defaultContentFactory = new ContentFactory({});
162
149
  })(InputArea || (InputArea = {}));
163
150
  /**
164
151
  * The default input prompt implementation.
@@ -1 +1 @@
1
- {"version":3,"file":"inputarea.js","sourceRoot":"","sources":["../src/inputarea.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAc,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAIjE;;GAEG;AACH,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAExC;;GAEG;AACH,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAEtD;;GAEG;AACH,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAE5C;;GAEG;AACH,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAEtD;;gFAEgF;AAEhF;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAM;IACnC;;OAEG;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BAAiB;YACf,OAAO,IAAI,WAAW,EAAE,CAAC;QAC3B,CAAC;KAGF;IAvBY,wBAAc,iBAuB1B,CAAA;AAmBH,CAAC,EAzFgB,SAAS,KAAT,SAAS,QAyFzB;AAgBD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAM;IACrC;;OAEG;IACH;QACE,KAAK,EAAE,CAAC;QAmBF,oBAAe,GAAkB,IAAI,CAAC;QAlB5C,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IACD,IAAI,cAAc,CAAC,KAAoB;QACrC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;SAC7B;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;SAC9C;IACH,CAAC;CAGF"}
package/lib/model.d.ts CHANGED
@@ -3,9 +3,9 @@ import { IAttachmentsModel } from '@jupyterlab/attachments';
3
3
  import { CodeEditor } from '@jupyterlab/codeeditor';
4
4
  import { IChangedArgs } from '@jupyterlab/coreutils';
5
5
  import * as nbformat from '@jupyterlab/nbformat';
6
- import * as models from '@jupyterlab/shared-models';
7
- import { IModelDB, IObservableJSON, IObservableValue, ObservableValue } from '@jupyterlab/observables';
6
+ import { ObservableValue } from '@jupyterlab/observables';
8
7
  import { IOutputAreaModel } from '@jupyterlab/outputarea';
8
+ import { IMapChange, ISharedCell, ISharedCodeCell, ISharedMarkdownCell, ISharedRawCell } from '@jupyter/ydoc';
9
9
  /**
10
10
  * The definition of a model object for a cell.
11
11
  */
@@ -25,16 +25,51 @@ export interface ICellModel extends CodeEditor.IModel {
25
25
  /**
26
26
  * A signal emitted when a model state changes.
27
27
  */
28
- readonly stateChanged: ISignal<ICellModel, IChangedArgs<any>>;
28
+ readonly stateChanged: ISignal<ICellModel, IChangedArgs<boolean, boolean, any>>;
29
29
  /**
30
30
  * Whether the cell is trusted.
31
31
  */
32
32
  trusted: boolean;
33
33
  /**
34
34
  * The metadata associated with the cell.
35
+ *
36
+ * ### Notes
37
+ * This is a copy of the metadata. Changing a part of it
38
+ * won't affect the model.
39
+ * As this returns a copy of all metadata, it is advised to
40
+ * use `getMetadata` to speed up the process of getting a single key.
41
+ */
42
+ readonly metadata: Omit<nbformat.IBaseCellMetadata, 'trusted'>;
43
+ /**
44
+ * Signal emitted when cell metadata changes.
45
+ */
46
+ readonly metadataChanged: ISignal<ICellModel, IMapChange>;
47
+ /**
48
+ * The cell shared model.
35
49
  */
36
- readonly metadata: IObservableJSON;
37
- readonly sharedModel: models.ISharedCell & models.ISharedText;
50
+ readonly sharedModel: ISharedCell;
51
+ /**
52
+ * Delete a metadata.
53
+ *
54
+ * @param key Metadata key
55
+ */
56
+ deleteMetadata(key: string): void;
57
+ /**
58
+ * Get a metadata
59
+ *
60
+ * ### Notes
61
+ * This returns a copy of the key value.
62
+ *
63
+ * @param key Metadata key
64
+ */
65
+ getMetadata(key: string): any;
66
+ /**
67
+ * Set a metadata
68
+ *
69
+ * @param key Metadata key
70
+ * @param value Metadata value
71
+ */
72
+ setMetadata(key: string, value: any): void;
38
73
  /**
39
74
  * Serialize the model to JSON.
40
75
  */
@@ -83,7 +118,7 @@ export interface ICodeCellModel extends ICellModel {
83
118
  /**
84
119
  * The code cell shared model
85
120
  */
86
- sharedModel: models.ISharedCodeCell;
121
+ readonly sharedModel: ISharedCodeCell;
87
122
  }
88
123
  /**
89
124
  * The definition of a markdown cell.
@@ -117,23 +152,25 @@ export declare function isRawCellModel(model: ICellModel): model is IRawCellMode
117
152
  /**
118
153
  * An implementation of the cell model.
119
154
  */
120
- export declare class CellModel extends CodeEditor.Model implements ICellModel {
121
- /**
122
- * Construct a cell model from optional cell content.
123
- */
124
- constructor(options: CellModel.IOptions);
155
+ export declare abstract class CellModel extends CodeEditor.Model implements ICellModel {
156
+ constructor(options?: CellModel.IOptions<ISharedCell>);
157
+ readonly sharedModel: ISharedCell;
125
158
  /**
126
159
  * The type of cell.
127
160
  */
128
- get type(): nbformat.CellType;
161
+ abstract get type(): nbformat.CellType;
129
162
  /**
130
163
  * A signal emitted when the state of the model changes.
131
164
  */
132
165
  readonly contentChanged: Signal<this, void>;
166
+ /**
167
+ * Signal emitted when cell metadata changes.
168
+ */
169
+ get metadataChanged(): ISignal<ICellModel, IMapChange>;
133
170
  /**
134
171
  * A signal emitted when a model state changes.
135
172
  */
136
- readonly stateChanged: Signal<this, IChangedArgs<any, any, string>>;
173
+ readonly stateChanged: Signal<this, IChangedArgs<any, any, "trusted" | "isDirty" | "executionCount">>;
137
174
  /**
138
175
  * The id for the cell.
139
176
  */
@@ -141,60 +178,55 @@ export declare class CellModel extends CodeEditor.Model implements ICellModel {
141
178
  /**
142
179
  * The metadata associated with the cell.
143
180
  */
144
- get metadata(): IObservableJSON;
181
+ get metadata(): Omit<nbformat.IBaseCellMetadata, 'trusted'>;
145
182
  /**
146
- * Get the trusted state of the model.
183
+ * The trusted state of the model.
147
184
  */
148
185
  get trusted(): boolean;
149
- /**
150
- * Set the trusted state of the model.
151
- */
152
186
  set trusted(newValue: boolean);
153
187
  /**
154
- * Serialize the model to JSON.
188
+ * Dispose of the resources held by the model.
155
189
  */
156
- toJSON(): nbformat.ICell;
190
+ dispose(): void;
157
191
  /**
158
192
  * Handle a change to the trusted state.
159
193
  *
160
194
  * The default implementation is a no-op.
161
195
  */
162
- onTrustedChanged(trusted: IObservableValue, args: ObservableValue.IChangedArgs): void;
196
+ onTrustedChanged(trusted: CellModel, args: ObservableValue.IChangedArgs): void;
163
197
  /**
164
- * When we initialize a cell model, we create a standalone model that cannot be shared in a YNotebook.
165
- * Call this function to re-initialize the local representation based on a fresh shared model (e.g. models.YFile or models.YCodeCell).
198
+ * Delete a metadata
166
199
  *
167
- * @param sharedModel
168
- * @param reinitialize Whether to reinitialize the shared model.
200
+ * @param key Metadata key
169
201
  */
170
- switchSharedModel(sharedModel: models.ISharedCodeCell, reinitialize?: boolean): void;
202
+ deleteMetadata(key: string): any;
171
203
  /**
172
- * Handle a change to the cell metadata modelDB and reflect it in the shared model.
204
+ * Get a metadata
205
+ *
206
+ * ### Notes
207
+ * This returns a copy of the key value.
208
+ *
209
+ * @param key Metadata key
173
210
  */
174
- protected onModelDBMetadataChange(sender: IObservableJSON, event: IObservableJSON.IChangedArgs): void;
211
+ getMetadata(key: string): any;
175
212
  /**
176
- * Change the cell metadata for a given event.
213
+ * Set a metadata
177
214
  *
178
- * @param metadata The cell metadata.
179
- * @param event The event to handle.
215
+ * @param key Metadata key
216
+ * @param value Metadata value
180
217
  */
181
- private _changeCellMetadata;
218
+ setMetadata(key: string, value: any): void;
182
219
  /**
183
- * Handle a change to the cell shared model and reflect it in modelDB.
184
- * We update the modeldb metadata when the shared model changes.
185
- *
186
- * This method overrides the CodeEditor protected _onSharedModelChanged
187
- * so we first call super._onSharedModelChanged
188
- *
189
- * @override CodeEditor._onSharedModelChanged
220
+ * Serialize the model to JSON.
190
221
  */
191
- protected _onSharedModelChanged(sender: models.ISharedCodeCell, change: models.CellChange<models.ISharedBaseCellMetadata>): void;
192
- private _updateModelDBMetadata;
222
+ toJSON(): nbformat.ICell;
193
223
  /**
194
224
  * Handle a change to the observable value.
195
225
  */
196
226
  protected onGenericChange(): void;
197
- sharedModel: models.ISharedCell;
227
+ private _onMetadataChanged;
228
+ private _metadataChanged;
229
+ private _trusted;
198
230
  }
199
231
  /**
200
232
  * The namespace for `CellModel` statics.
@@ -203,37 +235,53 @@ export declare namespace CellModel {
203
235
  /**
204
236
  * The options used to initialize a `CellModel`.
205
237
  */
206
- interface IOptions {
238
+ interface IOptions<T extends ISharedCell> {
207
239
  /**
208
- * The source cell data.
240
+ * A unique identifier for the model.
209
241
  */
210
- cell?: nbformat.IBaseCell;
242
+ id?: string;
211
243
  /**
212
- * An IModelDB in which to store cell data.
244
+ * The cell shared model.
213
245
  */
214
- modelDB?: IModelDB;
246
+ sharedModel?: T;
215
247
  /**
216
- * A unique identifier for this cell.
248
+ * The cell type
217
249
  */
218
- id?: string;
250
+ cell_type?: string;
251
+ /**
252
+ * Whether the cell is trusted or not.
253
+ */
254
+ trusted?: boolean;
219
255
  }
220
256
  }
221
257
  /**
222
258
  * A base implementation for cell models with attachments.
223
259
  */
224
- export declare class AttachmentsCellModel extends CellModel {
260
+ export declare abstract class AttachmentsCellModel extends CellModel {
225
261
  /**
226
262
  * Construct a new cell with optional attachments.
227
263
  */
228
- constructor(options: AttachmentsCellModel.IOptions);
264
+ constructor(options: AttachmentsCellModel.IOptions<ISharedCell>);
229
265
  /**
230
266
  * Get the attachments of the model.
231
267
  */
232
268
  get attachments(): IAttachmentsModel;
269
+ /**
270
+ * Dispose of the resources held by the model.
271
+ */
272
+ dispose(): void;
233
273
  /**
234
274
  * Serialize the model to JSON.
235
275
  */
236
276
  toJSON(): nbformat.IRawCell | nbformat.IMarkdownCell;
277
+ /**
278
+ * Handle a change to the cell outputs modelDB and reflect it in the shared model.
279
+ */
280
+ private _onAttachmentsChange;
281
+ /**
282
+ * Handle a change to the code cell value.
283
+ */
284
+ private _onSharedModelChanged;
237
285
  private _attachments;
238
286
  }
239
287
  /**
@@ -243,7 +291,7 @@ export declare namespace AttachmentsCellModel {
243
291
  /**
244
292
  * The options used to initialize a `AttachmentsCellModel`.
245
293
  */
246
- interface IOptions extends CellModel.IOptions {
294
+ interface IOptions<T extends ISharedCell> extends CellModel.IOptions<T> {
247
295
  /**
248
296
  * The factory for attachment model creation.
249
297
  */
@@ -276,6 +324,10 @@ export declare namespace AttachmentsCellModel {
276
324
  * An implementation of a raw cell model.
277
325
  */
278
326
  export declare class RawCellModel extends AttachmentsCellModel {
327
+ /**
328
+ * Construct a raw cell model from optional shared model.
329
+ */
330
+ constructor(options?: Omit<AttachmentsCellModel.IOptions<ISharedRawCell>, 'cell_type'>);
279
331
  /**
280
332
  * The type of the cell.
281
333
  */
@@ -290,9 +342,9 @@ export declare class RawCellModel extends AttachmentsCellModel {
290
342
  */
291
343
  export declare class MarkdownCellModel extends AttachmentsCellModel {
292
344
  /**
293
- * Construct a markdown cell model from optional cell content.
345
+ * Construct a markdown cell model from optional shared model.
294
346
  */
295
- constructor(options: CellModel.IOptions);
347
+ constructor(options?: Omit<AttachmentsCellModel.IOptions<ISharedMarkdownCell>, 'cell_type'>);
296
348
  /**
297
349
  * The type of the cell.
298
350
  */
@@ -309,8 +361,7 @@ export declare class CodeCellModel extends CellModel implements ICodeCellModel {
309
361
  /**
310
362
  * Construct a new code cell with optional original cell content.
311
363
  */
312
- constructor(options: CodeCellModel.IOptions);
313
- switchSharedModel(sharedModel: models.ISharedCodeCell, reinitialize?: boolean): void;
364
+ constructor(options?: CodeCellModel.IOptions);
314
365
  /**
315
366
  * The type of the cell.
316
367
  */
@@ -327,50 +378,36 @@ export declare class CodeCellModel extends CellModel implements ICodeCellModel {
327
378
  * result of the input code execution.
328
379
  */
329
380
  get isDirty(): boolean;
330
- /**
331
- * Set whether the cell is dirty or not.
332
- */
333
- private _setDirty;
334
- clearExecution(): void;
335
381
  /**
336
382
  * The cell outputs.
337
383
  */
338
384
  get outputs(): IOutputAreaModel;
385
+ readonly sharedModel: ISharedCodeCell;
386
+ clearExecution(): void;
339
387
  /**
340
388
  * Dispose of the resources held by the model.
341
389
  */
342
390
  dispose(): void;
343
391
  /**
344
- * Serialize the model to JSON.
392
+ * Handle a change to the trusted state.
345
393
  */
346
- toJSON(): nbformat.ICodeCell;
394
+ onTrustedChanged(trusted: CellModel, args: ObservableValue.IChangedArgs): void;
347
395
  /**
348
- * Handle a change to the trusted state.
396
+ * Serialize the model to JSON.
349
397
  */
350
- onTrustedChanged(trusted: IObservableValue, args: ObservableValue.IChangedArgs): void;
398
+ toJSON(): nbformat.ICodeCell;
351
399
  /**
352
400
  * Handle a change to the cell outputs modelDB and reflect it in the shared model.
353
401
  */
354
- protected onModelDBOutputsChange(sender: IOutputAreaModel, event: IOutputAreaModel.ChangedArgs): void;
402
+ protected onOutputsChange(sender: IOutputAreaModel, event: IOutputAreaModel.ChangedArgs): void;
355
403
  /**
356
404
  * Handle a change to the code cell value.
357
405
  */
358
- private _onValueChanged;
359
- /**
360
- * Handle a change to the output shared model and reflect it in modelDB.
361
- * We update the modeldb metadata when the nbcell changes.
362
- *
363
- * This method overrides the CellModel protected _onSharedModelChanged
364
- * so we first call super._onSharedModelChanged
365
- *
366
- * @override CellModel._onSharedModelChanged
367
- */
368
- protected _onSharedModelChanged(sender: models.ISharedCodeCell, change: models.CellChange<models.ISharedBaseCellMetadata>): void;
406
+ private _onSharedModelChanged;
369
407
  /**
370
- * Handle a change to the execution count.
408
+ * Set whether the cell is dirty or not.
371
409
  */
372
- private _onExecutionCountChanged;
373
- sharedModel: models.ISharedCodeCell;
410
+ private _setDirty;
374
411
  private _executedCode;
375
412
  private _isDirty;
376
413
  private _outputs;
@@ -382,7 +419,7 @@ export declare namespace CodeCellModel {
382
419
  /**
383
420
  * The options used to initialize a `CodeCellModel`.
384
421
  */
385
- interface IOptions extends CellModel.IOptions {
422
+ interface IOptions extends Omit<CellModel.IOptions<ISharedCodeCell>, 'cell_type'> {
386
423
  /**
387
424
  * The factory for output area model creation.
388
425
  */