@jupyterlab/cells 4.0.0-alpha.2 → 4.0.0-alpha.21

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 (46) hide show
  1. package/lib/celldragutils.d.ts +1 -7
  2. package/lib/celldragutils.js +12 -13
  3. package/lib/celldragutils.js.map +1 -1
  4. package/lib/index.d.ts +1 -0
  5. package/lib/index.js +1 -0
  6. package/lib/index.js.map +1 -1
  7. package/lib/inputarea.d.ts +9 -19
  8. package/lib/inputarea.js +16 -29
  9. package/lib/inputarea.js.map +1 -1
  10. package/lib/model.d.ts +121 -79
  11. package/lib/model.js +179 -392
  12. package/lib/model.js.map +1 -1
  13. package/lib/placeholder.d.ts +23 -19
  14. package/lib/placeholder.js +30 -35
  15. package/lib/placeholder.js.map +1 -1
  16. package/lib/resizeHandle.d.ts +0 -1
  17. package/lib/resizeHandle.js +9 -11
  18. package/lib/resizeHandle.js.map +1 -1
  19. package/lib/searchprovider.d.ts +31 -0
  20. package/lib/searchprovider.js +359 -0
  21. package/lib/searchprovider.js.map +1 -0
  22. package/lib/testutils.d.ts +22 -0
  23. package/lib/testutils.js +48 -0
  24. package/lib/testutils.js.map +1 -0
  25. package/lib/widget.d.ts +226 -42
  26. package/lib/widget.js +672 -270
  27. package/lib/widget.js.map +1 -1
  28. package/package.json +36 -33
  29. package/src/celldragutils.ts +214 -0
  30. package/src/collapser.tsx +150 -0
  31. package/src/headerfooter.ts +52 -0
  32. package/src/index.ts +17 -0
  33. package/src/inputarea.ts +292 -0
  34. package/src/model.ts +845 -0
  35. package/src/placeholder.ts +125 -0
  36. package/src/resizeHandle.ts +96 -0
  37. package/src/searchprovider.ts +436 -0
  38. package/src/testutils.ts +57 -0
  39. package/src/widget.ts +2290 -0
  40. package/style/collapser.css +5 -4
  41. package/style/headerfooter.css +3 -3
  42. package/style/index.css +4 -2
  43. package/style/index.js +4 -2
  44. package/style/inputarea.css +19 -17
  45. package/style/placeholder.css +1 -1
  46. package/style/widget.css +85 -7
@@ -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,GAAG,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,uBAAuB,GAAG,2BAA2B,CAAC;AAE5D,MAAM,KAAW,aAAa,CAgK7B;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AE,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;IACH,YAAY,OAA2B;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAChC,MAAM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,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
  */
@@ -80,6 +115,10 @@ export interface ICodeCellModel extends ICellModel {
80
115
  * Clear execution, outputs, and related metadata
81
116
  */
82
117
  clearExecution(): void;
118
+ /**
119
+ * The code cell shared model
120
+ */
121
+ readonly sharedModel: ISharedCodeCell;
83
122
  }
84
123
  /**
85
124
  * The definition of a markdown cell.
@@ -113,23 +152,25 @@ export declare function isRawCellModel(model: ICellModel): model is IRawCellMode
113
152
  /**
114
153
  * An implementation of the cell model.
115
154
  */
116
- export declare class CellModel extends CodeEditor.Model implements ICellModel {
117
- /**
118
- * Construct a cell model from optional cell content.
119
- */
120
- 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;
121
158
  /**
122
159
  * The type of cell.
123
160
  */
124
- get type(): nbformat.CellType;
161
+ abstract get type(): nbformat.CellType;
125
162
  /**
126
163
  * A signal emitted when the state of the model changes.
127
164
  */
128
165
  readonly contentChanged: Signal<this, void>;
166
+ /**
167
+ * Signal emitted when cell metadata changes.
168
+ */
169
+ get metadataChanged(): ISignal<ICellModel, IMapChange>;
129
170
  /**
130
171
  * A signal emitted when a model state changes.
131
172
  */
132
- readonly stateChanged: Signal<this, IChangedArgs<any, any, string>>;
173
+ readonly stateChanged: Signal<this, IChangedArgs<any, any, "trusted" | "isDirty" | "executionCount">>;
133
174
  /**
134
175
  * The id for the cell.
135
176
  */
@@ -137,60 +178,55 @@ export declare class CellModel extends CodeEditor.Model implements ICellModel {
137
178
  /**
138
179
  * The metadata associated with the cell.
139
180
  */
140
- get metadata(): IObservableJSON;
181
+ get metadata(): Omit<nbformat.IBaseCellMetadata, 'trusted'>;
141
182
  /**
142
- * Get the trusted state of the model.
183
+ * The trusted state of the model.
143
184
  */
144
185
  get trusted(): boolean;
145
- /**
146
- * Set the trusted state of the model.
147
- */
148
186
  set trusted(newValue: boolean);
149
187
  /**
150
- * Serialize the model to JSON.
188
+ * Dispose of the resources held by the model.
151
189
  */
152
- toJSON(): nbformat.ICell;
190
+ dispose(): void;
153
191
  /**
154
192
  * Handle a change to the trusted state.
155
193
  *
156
194
  * The default implementation is a no-op.
157
195
  */
158
- onTrustedChanged(trusted: IObservableValue, args: ObservableValue.IChangedArgs): void;
196
+ onTrustedChanged(trusted: CellModel, args: ObservableValue.IChangedArgs): void;
159
197
  /**
160
- * When we initialize a cell model, we create a standalone model that cannot be shared in a YNotebook.
161
- * 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
162
199
  *
163
- * @param sharedModel
164
- * @param reinitialize Whether to reinitialize the shared model.
200
+ * @param key Metadata key
165
201
  */
166
- switchSharedModel(sharedModel: models.ISharedCodeCell, reinitialize?: boolean): void;
202
+ deleteMetadata(key: string): any;
167
203
  /**
168
- * 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
169
210
  */
170
- protected onModelDBMetadataChange(sender: IObservableJSON, event: IObservableJSON.IChangedArgs): void;
211
+ getMetadata(key: string): any;
171
212
  /**
172
- * Change the cell metadata for a given event.
213
+ * Set a metadata
173
214
  *
174
- * @param metadata The cell metadata.
175
- * @param event The event to handle.
215
+ * @param key Metadata key
216
+ * @param value Metadata value
176
217
  */
177
- private _changeCellMetadata;
218
+ setMetadata(key: string, value: any): void;
178
219
  /**
179
- * Handle a change to the cell shared model and reflect it in modelDB.
180
- * We update the modeldb metadata when the shared model changes.
181
- *
182
- * This method overrides the CodeEditor protected _onSharedModelChanged
183
- * so we first call super._onSharedModelChanged
184
- *
185
- * @override CodeEditor._onSharedModelChanged
220
+ * Serialize the model to JSON.
186
221
  */
187
- protected _onSharedModelChanged(sender: models.ISharedCodeCell, change: models.CellChange<models.ISharedBaseCellMetadata>): void;
188
- private _updateModelDBMetadata;
222
+ toJSON(): nbformat.ICell;
189
223
  /**
190
224
  * Handle a change to the observable value.
191
225
  */
192
226
  protected onGenericChange(): void;
193
- sharedModel: models.ISharedCell;
227
+ private _onMetadataChanged;
228
+ private _metadataChanged;
229
+ private _trusted;
194
230
  }
195
231
  /**
196
232
  * The namespace for `CellModel` statics.
@@ -199,37 +235,53 @@ export declare namespace CellModel {
199
235
  /**
200
236
  * The options used to initialize a `CellModel`.
201
237
  */
202
- interface IOptions {
238
+ interface IOptions<T extends ISharedCell> {
203
239
  /**
204
- * The source cell data.
240
+ * A unique identifier for the model.
205
241
  */
206
- cell?: nbformat.IBaseCell;
242
+ id?: string;
207
243
  /**
208
- * An IModelDB in which to store cell data.
244
+ * The cell shared model.
209
245
  */
210
- modelDB?: IModelDB;
246
+ sharedModel?: T;
211
247
  /**
212
- * A unique identifier for this cell.
248
+ * The cell type
213
249
  */
214
- id?: string;
250
+ cell_type?: string;
251
+ /**
252
+ * Whether the cell is trusted or not.
253
+ */
254
+ trusted?: boolean;
215
255
  }
216
256
  }
217
257
  /**
218
258
  * A base implementation for cell models with attachments.
219
259
  */
220
- export declare class AttachmentsCellModel extends CellModel {
260
+ export declare abstract class AttachmentsCellModel extends CellModel {
221
261
  /**
222
262
  * Construct a new cell with optional attachments.
223
263
  */
224
- constructor(options: AttachmentsCellModel.IOptions);
264
+ constructor(options: AttachmentsCellModel.IOptions<ISharedCell>);
225
265
  /**
226
266
  * Get the attachments of the model.
227
267
  */
228
268
  get attachments(): IAttachmentsModel;
269
+ /**
270
+ * Dispose of the resources held by the model.
271
+ */
272
+ dispose(): void;
229
273
  /**
230
274
  * Serialize the model to JSON.
231
275
  */
232
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;
233
285
  private _attachments;
234
286
  }
235
287
  /**
@@ -239,7 +291,7 @@ export declare namespace AttachmentsCellModel {
239
291
  /**
240
292
  * The options used to initialize a `AttachmentsCellModel`.
241
293
  */
242
- interface IOptions extends CellModel.IOptions {
294
+ interface IOptions<T extends ISharedCell> extends CellModel.IOptions<T> {
243
295
  /**
244
296
  * The factory for attachment model creation.
245
297
  */
@@ -272,6 +324,10 @@ export declare namespace AttachmentsCellModel {
272
324
  * An implementation of a raw cell model.
273
325
  */
274
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'>);
275
331
  /**
276
332
  * The type of the cell.
277
333
  */
@@ -286,9 +342,9 @@ export declare class RawCellModel extends AttachmentsCellModel {
286
342
  */
287
343
  export declare class MarkdownCellModel extends AttachmentsCellModel {
288
344
  /**
289
- * Construct a markdown cell model from optional cell content.
345
+ * Construct a markdown cell model from optional shared model.
290
346
  */
291
- constructor(options: CellModel.IOptions);
347
+ constructor(options?: Omit<AttachmentsCellModel.IOptions<ISharedMarkdownCell>, 'cell_type'>);
292
348
  /**
293
349
  * The type of the cell.
294
350
  */
@@ -305,8 +361,7 @@ export declare class CodeCellModel extends CellModel implements ICodeCellModel {
305
361
  /**
306
362
  * Construct a new code cell with optional original cell content.
307
363
  */
308
- constructor(options: CodeCellModel.IOptions);
309
- switchSharedModel(sharedModel: models.ISharedCodeCell, reinitialize?: boolean): void;
364
+ constructor(options?: CodeCellModel.IOptions);
310
365
  /**
311
366
  * The type of the cell.
312
367
  */
@@ -323,49 +378,36 @@ export declare class CodeCellModel extends CellModel implements ICodeCellModel {
323
378
  * result of the input code execution.
324
379
  */
325
380
  get isDirty(): boolean;
326
- /**
327
- * Set whether the cell is dirty or not.
328
- */
329
- private _setDirty;
330
- clearExecution(): void;
331
381
  /**
332
382
  * The cell outputs.
333
383
  */
334
384
  get outputs(): IOutputAreaModel;
385
+ readonly sharedModel: ISharedCodeCell;
386
+ clearExecution(): void;
335
387
  /**
336
388
  * Dispose of the resources held by the model.
337
389
  */
338
390
  dispose(): void;
339
391
  /**
340
- * Serialize the model to JSON.
392
+ * Handle a change to the trusted state.
341
393
  */
342
- toJSON(): nbformat.ICodeCell;
394
+ onTrustedChanged(trusted: CellModel, args: ObservableValue.IChangedArgs): void;
343
395
  /**
344
- * Handle a change to the trusted state.
396
+ * Serialize the model to JSON.
345
397
  */
346
- onTrustedChanged(trusted: IObservableValue, args: ObservableValue.IChangedArgs): void;
398
+ toJSON(): nbformat.ICodeCell;
347
399
  /**
348
400
  * Handle a change to the cell outputs modelDB and reflect it in the shared model.
349
401
  */
350
- protected onModelDBOutputsChange(sender: IOutputAreaModel, event: IOutputAreaModel.ChangedArgs): void;
402
+ protected onOutputsChange(sender: IOutputAreaModel, event: IOutputAreaModel.ChangedArgs): void;
351
403
  /**
352
404
  * Handle a change to the code cell value.
353
405
  */
354
- private _onValueChanged;
355
- /**
356
- * Handle a change to the output shared model and reflect it in modelDB.
357
- * We update the modeldb metadata when the nbcell changes.
358
- *
359
- * This method overrides the CellModel protected _onSharedModelChanged
360
- * so we first call super._onSharedModelChanged
361
- *
362
- * @override CellModel._onSharedModelChanged
363
- */
364
- protected _onSharedModelChanged(sender: models.ISharedCodeCell, change: models.CellChange<models.ISharedBaseCellMetadata>): void;
406
+ private _onSharedModelChanged;
365
407
  /**
366
- * Handle a change to the execution count.
408
+ * Set whether the cell is dirty or not.
367
409
  */
368
- private _onExecutionCountChanged;
410
+ private _setDirty;
369
411
  private _executedCode;
370
412
  private _isDirty;
371
413
  private _outputs;
@@ -377,7 +419,7 @@ export declare namespace CodeCellModel {
377
419
  /**
378
420
  * The options used to initialize a `CodeCellModel`.
379
421
  */
380
- interface IOptions extends CellModel.IOptions {
422
+ interface IOptions extends Omit<CellModel.IOptions<ISharedCodeCell>, 'cell_type'> {
381
423
  /**
382
424
  * The factory for output area model creation.
383
425
  */