@theia/notebook 1.67.0-next.13 → 1.67.0-next.56

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 (244) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -7
  3. package/src/browser/contributions/notebook-actions-contribution.ts +25 -22
  4. package/src/browser/contributions/notebook-cell-actions-contribution.ts +20 -9
  5. package/src/browser/contributions/notebook-label-provider-contribution.ts +2 -1
  6. package/src/browser/contributions/notebook-outline-contribution.ts +8 -6
  7. package/src/browser/contributions/notebook-status-bar-contribution.ts +4 -6
  8. package/src/browser/index.ts +1 -0
  9. package/src/browser/notebook-cell-open-handler.ts +3 -3
  10. package/src/browser/notebook-editor-split-contribution.ts +51 -0
  11. package/src/browser/notebook-editor-widget-factory.ts +11 -1
  12. package/src/browser/notebook-editor-widget.tsx +18 -3
  13. package/src/browser/notebook-frontend-module.ts +5 -0
  14. package/src/browser/notebook-open-handler.ts +19 -11
  15. package/src/browser/notebook-types.ts +1 -0
  16. package/src/browser/service/notebook-context-manager.ts +17 -9
  17. package/src/browser/view/notebook-cell-editor.tsx +13 -5
  18. package/src/browser/view/notebook-cell-list-view.tsx +15 -12
  19. package/src/browser/view/notebook-cell-toolbar-factory.tsx +5 -4
  20. package/src/browser/view/notebook-code-cell-view.tsx +6 -1
  21. package/src/browser/view/notebook-markdown-cell-view.tsx +27 -7
  22. package/src/browser/view-model/notebook-cell-model.ts +8 -41
  23. package/src/browser/view-model/notebook-model.ts +2 -33
  24. package/src/browser/view-model/notebook-view-model.ts +138 -0
  25. package/lib/browser/contributions/cell-operations.d.ts +0 -8
  26. package/lib/browser/contributions/cell-operations.d.ts.map +0 -1
  27. package/lib/browser/contributions/cell-operations.js +0 -45
  28. package/lib/browser/contributions/cell-operations.js.map +0 -1
  29. package/lib/browser/contributions/notebook-actions-contribution.d.ts +0 -48
  30. package/lib/browser/contributions/notebook-actions-contribution.d.ts.map +0 -1
  31. package/lib/browser/contributions/notebook-actions-contribution.js +0 -341
  32. package/lib/browser/contributions/notebook-actions-contribution.js.map +0 -1
  33. package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts +0 -66
  34. package/lib/browser/contributions/notebook-cell-actions-contribution.d.ts.map +0 -1
  35. package/lib/browser/contributions/notebook-cell-actions-contribution.js +0 -512
  36. package/lib/browser/contributions/notebook-cell-actions-contribution.js.map +0 -1
  37. package/lib/browser/contributions/notebook-color-contribution.d.ts +0 -6
  38. package/lib/browser/contributions/notebook-color-contribution.d.ts.map +0 -1
  39. package/lib/browser/contributions/notebook-color-contribution.js +0 -247
  40. package/lib/browser/contributions/notebook-color-contribution.js.map +0 -1
  41. package/lib/browser/contributions/notebook-context-keys.d.ts +0 -44
  42. package/lib/browser/contributions/notebook-context-keys.d.ts.map +0 -1
  43. package/lib/browser/contributions/notebook-context-keys.js +0 -108
  44. package/lib/browser/contributions/notebook-context-keys.js.map +0 -1
  45. package/lib/browser/contributions/notebook-label-provider-contribution.d.ts +0 -19
  46. package/lib/browser/contributions/notebook-label-provider-contribution.d.ts.map +0 -1
  47. package/lib/browser/contributions/notebook-label-provider-contribution.js +0 -85
  48. package/lib/browser/contributions/notebook-label-provider-contribution.js.map +0 -1
  49. package/lib/browser/contributions/notebook-outline-contribution.d.ts +0 -28
  50. package/lib/browser/contributions/notebook-outline-contribution.d.ts.map +0 -1
  51. package/lib/browser/contributions/notebook-outline-contribution.js +0 -113
  52. package/lib/browser/contributions/notebook-outline-contribution.js.map +0 -1
  53. package/lib/browser/contributions/notebook-output-action-contribution.d.ts +0 -16
  54. package/lib/browser/contributions/notebook-output-action-contribution.d.ts.map +0 -1
  55. package/lib/browser/contributions/notebook-output-action-contribution.js +0 -83
  56. package/lib/browser/contributions/notebook-output-action-contribution.js.map +0 -1
  57. package/lib/browser/contributions/notebook-status-bar-contribution.d.ts +0 -12
  58. package/lib/browser/contributions/notebook-status-bar-contribution.d.ts.map +0 -1
  59. package/lib/browser/contributions/notebook-status-bar-contribution.js +0 -63
  60. package/lib/browser/contributions/notebook-status-bar-contribution.js.map +0 -1
  61. package/lib/browser/contributions/notebook-undo-redo-handler.d.ts +0 -10
  62. package/lib/browser/contributions/notebook-undo-redo-handler.d.ts.map +0 -1
  63. package/lib/browser/contributions/notebook-undo-redo-handler.js +0 -49
  64. package/lib/browser/contributions/notebook-undo-redo-handler.js.map +0 -1
  65. package/lib/browser/index.d.ts +0 -13
  66. package/lib/browser/index.d.ts.map +0 -1
  67. package/lib/browser/index.js +0 -31
  68. package/lib/browser/index.js.map +0 -1
  69. package/lib/browser/notebook-cell-open-handler.d.ts +0 -10
  70. package/lib/browser/notebook-cell-open-handler.d.ts.map +0 -1
  71. package/lib/browser/notebook-cell-open-handler.js +0 -51
  72. package/lib/browser/notebook-cell-open-handler.js.map +0 -1
  73. package/lib/browser/notebook-cell-resource-resolver.d.ts +0 -26
  74. package/lib/browser/notebook-cell-resource-resolver.d.ts.map +0 -1
  75. package/lib/browser/notebook-cell-resource-resolver.js +0 -109
  76. package/lib/browser/notebook-cell-resource-resolver.js.map +0 -1
  77. package/lib/browser/notebook-editor-widget-factory.d.ts +0 -19
  78. package/lib/browser/notebook-editor-widget-factory.d.ts.map +0 -1
  79. package/lib/browser/notebook-editor-widget-factory.js +0 -93
  80. package/lib/browser/notebook-editor-widget-factory.js.map +0 -1
  81. package/lib/browser/notebook-editor-widget.d.ts +0 -99
  82. package/lib/browser/notebook-editor-widget.d.ts.map +0 -1
  83. package/lib/browser/notebook-editor-widget.js +0 -323
  84. package/lib/browser/notebook-editor-widget.js.map +0 -1
  85. package/lib/browser/notebook-frontend-module.d.ts +0 -5
  86. package/lib/browser/notebook-frontend-module.d.ts.map +0 -1
  87. package/lib/browser/notebook-frontend-module.js +0 -112
  88. package/lib/browser/notebook-frontend-module.js.map +0 -1
  89. package/lib/browser/notebook-open-handler.d.ts +0 -23
  90. package/lib/browser/notebook-open-handler.d.ts.map +0 -1
  91. package/lib/browser/notebook-open-handler.js +0 -113
  92. package/lib/browser/notebook-open-handler.js.map +0 -1
  93. package/lib/browser/notebook-output-utils.d.ts +0 -13
  94. package/lib/browser/notebook-output-utils.d.ts.map +0 -1
  95. package/lib/browser/notebook-output-utils.js +0 -112
  96. package/lib/browser/notebook-output-utils.js.map +0 -1
  97. package/lib/browser/notebook-renderer-registry.d.ts +0 -25
  98. package/lib/browser/notebook-renderer-registry.d.ts.map +0 -1
  99. package/lib/browser/notebook-renderer-registry.js +0 -72
  100. package/lib/browser/notebook-renderer-registry.js.map +0 -1
  101. package/lib/browser/notebook-type-registry.d.ts +0 -12
  102. package/lib/browser/notebook-type-registry.d.ts.map +0 -1
  103. package/lib/browser/notebook-type-registry.js +0 -60
  104. package/lib/browser/notebook-type-registry.js.map +0 -1
  105. package/lib/browser/notebook-types.d.ts +0 -130
  106. package/lib/browser/notebook-types.d.ts.map +0 -1
  107. package/lib/browser/notebook-types.js +0 -28
  108. package/lib/browser/notebook-types.js.map +0 -1
  109. package/lib/browser/renderers/cell-output-webview.d.ts +0 -26
  110. package/lib/browser/renderers/cell-output-webview.d.ts.map +0 -1
  111. package/lib/browser/renderers/cell-output-webview.js +0 -21
  112. package/lib/browser/renderers/cell-output-webview.js.map +0 -1
  113. package/lib/browser/service/notebook-cell-editor-service.d.ts +0 -23
  114. package/lib/browser/service/notebook-cell-editor-service.d.ts.map +0 -1
  115. package/lib/browser/service/notebook-cell-editor-service.js +0 -89
  116. package/lib/browser/service/notebook-cell-editor-service.js.map +0 -1
  117. package/lib/browser/service/notebook-cell-status-bar-service.d.ts +0 -39
  118. package/lib/browser/service/notebook-cell-status-bar-service.d.ts.map +0 -1
  119. package/lib/browser/service/notebook-cell-status-bar-service.js +0 -69
  120. package/lib/browser/service/notebook-cell-status-bar-service.js.map +0 -1
  121. package/lib/browser/service/notebook-clipboard-service.d.ts +0 -10
  122. package/lib/browser/service/notebook-clipboard-service.d.ts.map +0 -1
  123. package/lib/browser/service/notebook-clipboard-service.js +0 -42
  124. package/lib/browser/service/notebook-clipboard-service.js.map +0 -1
  125. package/lib/browser/service/notebook-context-manager.d.ts +0 -26
  126. package/lib/browser/service/notebook-context-manager.d.ts.map +0 -1
  127. package/lib/browser/service/notebook-context-manager.js +0 -131
  128. package/lib/browser/service/notebook-context-manager.js.map +0 -1
  129. package/lib/browser/service/notebook-editor-widget-service.d.ts +0 -27
  130. package/lib/browser/service/notebook-editor-widget-service.d.ts.map +0 -1
  131. package/lib/browser/service/notebook-editor-widget-service.js +0 -124
  132. package/lib/browser/service/notebook-editor-widget-service.js.map +0 -1
  133. package/lib/browser/service/notebook-execution-service.d.ts +0 -25
  134. package/lib/browser/service/notebook-execution-service.d.ts.map +0 -1
  135. package/lib/browser/service/notebook-execution-service.js +0 -150
  136. package/lib/browser/service/notebook-execution-service.js.map +0 -1
  137. package/lib/browser/service/notebook-execution-state-service.d.ts +0 -78
  138. package/lib/browser/service/notebook-execution-state-service.d.ts.map +0 -1
  139. package/lib/browser/service/notebook-execution-state-service.js +0 -247
  140. package/lib/browser/service/notebook-execution-state-service.js.map +0 -1
  141. package/lib/browser/service/notebook-kernel-history-service.d.ts +0 -28
  142. package/lib/browser/service/notebook-kernel-history-service.d.ts.map +0 -1
  143. package/lib/browser/service/notebook-kernel-history-service.js +0 -116
  144. package/lib/browser/service/notebook-kernel-history-service.js.map +0 -1
  145. package/lib/browser/service/notebook-kernel-quick-pick-service.d.ts +0 -61
  146. package/lib/browser/service/notebook-kernel-quick-pick-service.d.ts.map +0 -1
  147. package/lib/browser/service/notebook-kernel-quick-pick-service.js +0 -425
  148. package/lib/browser/service/notebook-kernel-quick-pick-service.js.map +0 -1
  149. package/lib/browser/service/notebook-kernel-service.d.ts +0 -125
  150. package/lib/browser/service/notebook-kernel-service.d.ts.map +0 -1
  151. package/lib/browser/service/notebook-kernel-service.js +0 -268
  152. package/lib/browser/service/notebook-kernel-service.js.map +0 -1
  153. package/lib/browser/service/notebook-model-resolver-service.d.ts +0 -28
  154. package/lib/browser/service/notebook-model-resolver-service.d.ts.map +0 -1
  155. package/lib/browser/service/notebook-model-resolver-service.js +0 -157
  156. package/lib/browser/service/notebook-model-resolver-service.js.map +0 -1
  157. package/lib/browser/service/notebook-monaco-text-model-service.d.ts +0 -21
  158. package/lib/browser/service/notebook-monaco-text-model-service.d.ts.map +0 -1
  159. package/lib/browser/service/notebook-monaco-text-model-service.js +0 -73
  160. package/lib/browser/service/notebook-monaco-text-model-service.js.map +0 -1
  161. package/lib/browser/service/notebook-options.d.ts +0 -30
  162. package/lib/browser/service/notebook-options.d.ts.map +0 -1
  163. package/lib/browser/service/notebook-options.js +0 -130
  164. package/lib/browser/service/notebook-options.js.map +0 -1
  165. package/lib/browser/service/notebook-renderer-messaging-service.d.ts +0 -35
  166. package/lib/browser/service/notebook-renderer-messaging-service.d.ts.map +0 -1
  167. package/lib/browser/service/notebook-renderer-messaging-service.js +0 -100
  168. package/lib/browser/service/notebook-renderer-messaging-service.js.map +0 -1
  169. package/lib/browser/service/notebook-service.d.ts +0 -68
  170. package/lib/browser/service/notebook-service.d.ts.map +0 -1
  171. package/lib/browser/service/notebook-service.js +0 -184
  172. package/lib/browser/service/notebook-service.js.map +0 -1
  173. package/lib/browser/view/notebook-cell-editor.d.ts +0 -44
  174. package/lib/browser/view/notebook-cell-editor.d.ts.map +0 -1
  175. package/lib/browser/view/notebook-cell-editor.js +0 -267
  176. package/lib/browser/view/notebook-cell-editor.js.map +0 -1
  177. package/lib/browser/view/notebook-cell-list-view.d.ts +0 -56
  178. package/lib/browser/view/notebook-cell-list-view.d.ts.map +0 -1
  179. package/lib/browser/view/notebook-cell-list-view.js +0 -222
  180. package/lib/browser/view/notebook-cell-list-view.js.map +0 -1
  181. package/lib/browser/view/notebook-cell-toolbar-factory.d.ts +0 -33
  182. package/lib/browser/view/notebook-cell-toolbar-factory.d.ts.map +0 -1
  183. package/lib/browser/view/notebook-cell-toolbar-factory.js +0 -110
  184. package/lib/browser/view/notebook-cell-toolbar-factory.js.map +0 -1
  185. package/lib/browser/view/notebook-cell-toolbar.d.ts +0 -25
  186. package/lib/browser/view/notebook-cell-toolbar.d.ts.map +0 -1
  187. package/lib/browser/view/notebook-cell-toolbar.js +0 -51
  188. package/lib/browser/view/notebook-cell-toolbar.js.map +0 -1
  189. package/lib/browser/view/notebook-code-cell-view.d.ts +0 -91
  190. package/lib/browser/view/notebook-code-cell-view.d.ts.map +0 -1
  191. package/lib/browser/view/notebook-code-cell-view.js +0 -333
  192. package/lib/browser/view/notebook-code-cell-view.js.map +0 -1
  193. package/lib/browser/view/notebook-find-widget.d.ts +0 -63
  194. package/lib/browser/view/notebook-find-widget.d.ts.map +0 -1
  195. package/lib/browser/view/notebook-find-widget.js +0 -225
  196. package/lib/browser/view/notebook-find-widget.js.map +0 -1
  197. package/lib/browser/view/notebook-main-toolbar.d.ts +0 -53
  198. package/lib/browser/view/notebook-main-toolbar.d.ts.map +0 -1
  199. package/lib/browser/view/notebook-main-toolbar.js +0 -184
  200. package/lib/browser/view/notebook-main-toolbar.js.map +0 -1
  201. package/lib/browser/view/notebook-markdown-cell-view.d.ts +0 -26
  202. package/lib/browser/view/notebook-markdown-cell-view.d.ts.map +0 -1
  203. package/lib/browser/view/notebook-markdown-cell-view.js +0 -198
  204. package/lib/browser/view/notebook-markdown-cell-view.js.map +0 -1
  205. package/lib/browser/view/notebook-viewport-service.d.ts +0 -17
  206. package/lib/browser/view/notebook-viewport-service.d.ts.map +0 -1
  207. package/lib/browser/view/notebook-viewport-service.js +0 -61
  208. package/lib/browser/view/notebook-viewport-service.js.map +0 -1
  209. package/lib/browser/view-model/notebook-cell-model.d.ts +0 -149
  210. package/lib/browser/view-model/notebook-cell-model.d.ts.map +0 -1
  211. package/lib/browser/view-model/notebook-cell-model.js +0 -391
  212. package/lib/browser/view-model/notebook-cell-model.js.map +0 -1
  213. package/lib/browser/view-model/notebook-cell-output-model.d.ts +0 -17
  214. package/lib/browser/view-model/notebook-cell-output-model.d.ts.map +0 -1
  215. package/lib/browser/view-model/notebook-cell-output-model.js +0 -87
  216. package/lib/browser/view-model/notebook-cell-output-model.js.map +0 -1
  217. package/lib/browser/view-model/notebook-model.d.ts +0 -93
  218. package/lib/browser/view-model/notebook-model.d.ts.map +0 -1
  219. package/lib/browser/view-model/notebook-model.js +0 -468
  220. package/lib/browser/view-model/notebook-model.js.map +0 -1
  221. package/lib/common/index.d.ts +0 -3
  222. package/lib/common/index.d.ts.map +0 -1
  223. package/lib/common/index.js +0 -21
  224. package/lib/common/index.js.map +0 -1
  225. package/lib/common/notebook-common.d.ts +0 -227
  226. package/lib/common/notebook-common.d.ts.map +0 -1
  227. package/lib/common/notebook-common.js +0 -151
  228. package/lib/common/notebook-common.js.map +0 -1
  229. package/lib/common/notebook-preferences.d.ts +0 -15
  230. package/lib/common/notebook-preferences.d.ts.map +0 -1
  231. package/lib/common/notebook-preferences.js +0 -89
  232. package/lib/common/notebook-preferences.js.map +0 -1
  233. package/lib/common/notebook-protocol.d.ts +0 -21
  234. package/lib/common/notebook-protocol.d.ts.map +0 -1
  235. package/lib/common/notebook-protocol.js +0 -18
  236. package/lib/common/notebook-protocol.js.map +0 -1
  237. package/lib/common/notebook-range.d.ts +0 -14
  238. package/lib/common/notebook-range.d.ts.map +0 -1
  239. package/lib/common/notebook-range.js +0 -18
  240. package/lib/common/notebook-range.js.map +0 -1
  241. package/lib/node/notebook-backend-module.d.ts +0 -4
  242. package/lib/node/notebook-backend-module.d.ts.map +0 -1
  243. package/lib/node/notebook-backend-module.js +0 -23
  244. package/lib/node/notebook-backend-module.js.map +0 -1
@@ -30,6 +30,7 @@ import { NotebookEditorWidget } from '../notebook-editor-widget';
30
30
  import { NotebookCellModel } from '../view-model/notebook-cell-model';
31
31
  import { CellKind, NotebookCellsChangeType } from '../../common';
32
32
  import { NotebookExecutionStateService } from './notebook-execution-state-service';
33
+ import { NotebookViewModel } from '../view-model/notebook-view-model';
33
34
 
34
35
  @injectable()
35
36
  export class NotebookContextManager {
@@ -53,6 +54,8 @@ export class NotebookContextManager {
53
54
 
54
55
  protected cellContexts: Map<number, Record<string, unknown>> = new Map();
55
56
 
57
+ protected notebookViewModel: NotebookViewModel;
58
+
56
59
  init(widget: NotebookEditorWidget): void {
57
60
  this._context = widget.node;
58
61
  this.scopedStore = this.contextKeyService.createScoped(widget.node);
@@ -61,6 +64,8 @@ export class NotebookContextManager {
61
64
 
62
65
  this.scopedStore.setContext(NOTEBOOK_VIEW_TYPE, widget?.notebookType);
63
66
 
67
+ this.notebookViewModel = widget.viewModel;
68
+
64
69
  // Kernel related keys
65
70
  const kernel = widget?.model ? this.notebookKernelService.getSelectedNotebookKernel(widget.model) : undefined;
66
71
  this.scopedStore.setContext(NOTEBOOK_KERNEL_SELECTED, !!kernel);
@@ -81,9 +86,9 @@ export class NotebookContextManager {
81
86
  this.scopedStore.setContext(NOTEBOOK_HAS_OUTPUTS, !!widget.model?.cells.find(cell => cell.outputs.length > 0));
82
87
 
83
88
  // Cell Selection related keys
84
- this.scopedStore.setContext(NOTEBOOK_CELL_FOCUSED, !!widget.model?.selectedCell);
85
- this.selectedCellChanged(widget.model?.selectedCell);
86
- widget.model?.onDidChangeSelectedCell(e => {
89
+ this.scopedStore.setContext(NOTEBOOK_CELL_FOCUSED, !!widget.viewModel.selectedCell);
90
+ this.selectedCellChanged(widget.viewModel.selectedCell);
91
+ widget.viewModel.onDidChangeSelectedCell(e => {
87
92
  this.selectedCellChanged(e.cell);
88
93
  this.scopedStore.setContext(NOTEBOOK_CELL_FOCUSED, !!e);
89
94
  });
@@ -108,12 +113,15 @@ export class NotebookContextManager {
108
113
  this.scopedStore.setContext(NOTEBOOK_CELL_TYPE, cell ? cell.cellKind === CellKind.Code ? 'code' : 'markdown' : undefined);
109
114
 
110
115
  if (cell) {
111
- this.scopedStore.setContext(NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, cell.editing);
112
- this.scopedStore.setContext(NOTEBOOK_CELL_EDITABLE, cell.cellKind === CellKind.Markup && !cell.editing);
113
- this.cellDisposables.push(cell.onDidRequestCellEditChange(cellEdit => {
114
- this.scopedStore.setContext(NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, cellEdit);
115
- this.scopedStore.setContext(NOTEBOOK_CELL_EDITABLE, cell.cellKind === CellKind.Markup && !cellEdit);
116
- }));
116
+ const cellViewModel = this.notebookViewModel.cellViewModels.get(cell.handle);
117
+ this.scopedStore.setContext(NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, cellViewModel?.editing);
118
+ this.scopedStore.setContext(NOTEBOOK_CELL_EDITABLE, cell.cellKind === CellKind.Markup && !cellViewModel?.editing);
119
+ if (cellViewModel) {
120
+ this.cellDisposables.push(cellViewModel.onDidRequestCellEditChange(cellEdit => {
121
+ this.scopedStore.setContext(NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, cellEdit);
122
+ this.scopedStore.setContext(NOTEBOOK_CELL_EDITABLE, cell.cellKind === CellKind.Markup && !cellEdit);
123
+ }));
124
+ }
117
125
  }
118
126
  }
119
127
 
@@ -31,9 +31,11 @@ import { ModelDecorationOptions } from '@theia/monaco-editor-core/esm/vs/editor/
31
31
  import { IModelDeltaDecoration, OverviewRulerLane, TrackedRangeStickiness } from '@theia/monaco-editor-core/esm/vs/editor/common/model';
32
32
  import { animationFrame } from '@theia/core/lib/browser';
33
33
  import { NotebookCellEditorService } from '../service/notebook-cell-editor-service';
34
+ import { NotebookViewModel } from '../view-model/notebook-view-model';
34
35
 
35
36
  interface CellEditorProps {
36
37
  notebookModel: NotebookModel;
38
+ notebookViewModel: NotebookViewModel;
37
39
  cell: NotebookCellModel;
38
40
  monacoServices: MonacoEditorServices;
39
41
  notebookContextManager: NotebookContextManager;
@@ -89,8 +91,14 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
89
91
  protected resizeObserver?: ResizeObserver;
90
92
 
91
93
  override componentDidMount(): void {
94
+ const cellViewModel = this.props.notebookViewModel.cellViewModels.get(this.props.cell.handle);
95
+
96
+ if (!cellViewModel) {
97
+ throw new Error('CellViewModel not found for cell ' + this.props.cell.handle);
98
+ }
99
+
92
100
  this.disposeEditor();
93
- this.toDispose.push(this.props.cell.onWillFocusCellEditor(focusRequest => {
101
+ this.toDispose.push(cellViewModel.onWillFocusCellEditor(focusRequest => {
94
102
  this.editor?.getControl().focus();
95
103
  const lineCount = this.editor?.getControl().getModel()?.getLineCount();
96
104
  if (focusRequest && lineCount !== undefined) {
@@ -104,7 +112,7 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
104
112
  this.props.notebookContextManager.scopedStore.setContext(NOTEBOOK_CELL_CURSOR_LAST_LINE, currentLine === lineCount);
105
113
  }));
106
114
 
107
- this.toDispose.push(this.props.cell.onWillBlurCellEditor(() => this.blurEditor()));
115
+ this.toDispose.push(cellViewModel.onWillBlurCellEditor(() => this.blurEditor()));
108
116
 
109
117
  this.toDispose.push(this.props.cell.onDidChangeEditorOptions(options => {
110
118
  this.editor?.getControl().updateOptions(options);
@@ -121,7 +129,7 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
121
129
 
122
130
  this.toDispose.push(this.props.cell.onDidSelectFindMatch(match => this.centerEditorInView()));
123
131
 
124
- this.toDispose.push(this.props.notebookModel.onDidChangeSelectedCell(e => {
132
+ this.toDispose.push(this.props.notebookViewModel.onDidChangeSelectedCell(e => {
125
133
  if (e.cell !== this.props.cell && this.editor?.getControl().hasTextFocus()) {
126
134
  this.blurEditor();
127
135
  }
@@ -201,7 +209,7 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
201
209
  notebookModel.cellDirtyChanged(cell, true);
202
210
  }));
203
211
  this.toDispose.push(this.editor.getControl().onDidFocusEditorText(() => {
204
- this.props.notebookModel.setSelectedCell(cell, false);
212
+ this.props.notebookViewModel.setSelectedCell(cell, false);
205
213
  this.props.notebookCellEditorService.editorFocusChanged(this.editor);
206
214
  }));
207
215
  this.toDispose.push(this.editor.getControl().onDidBlurEditorText(() => {
@@ -231,7 +239,7 @@ export class CellEditor extends React.Component<CellEditorProps, {}> {
231
239
  }));
232
240
  this.props.notebookCellEditorService.editorCreated(uri, this.editor);
233
241
  this.setMatches();
234
- if (notebookModel.selectedCell === cell) {
242
+ if (this.props.notebookViewModel.selectedCell === cell) {
235
243
  this.editor.getControl().focus();
236
244
  }
237
245
  }
@@ -23,6 +23,7 @@ import { CommandMenu, CommandRegistry, DisposableCollection, MenuModelRegistry,
23
23
  import { NotebookCommands, NotebookMenus } from '../contributions/notebook-actions-contribution';
24
24
  import { NotebookCellActionContribution } from '../contributions/notebook-cell-actions-contribution';
25
25
  import { NotebookContextManager } from '../service/notebook-context-manager';
26
+ import { NotebookViewModel } from '../view-model/notebook-view-model';
26
27
 
27
28
  export interface CellRenderer {
28
29
  render(notebookData: NotebookModel, cell: NotebookCellModel, index: number): React.ReactNode
@@ -42,6 +43,7 @@ export function observeCellHeight(ref: HTMLDivElement | null, cell: NotebookCell
42
43
  interface CellListProps {
43
44
  renderers: Map<CellKind, CellRenderer>;
44
45
  notebookModel: NotebookModel;
46
+ notebookViewModel: NotebookViewModel;
45
47
  notebookContext: NotebookContextManager;
46
48
  toolbarRenderer: NotebookCellToolbarFactory;
47
49
  commandRegistry: CommandRegistry;
@@ -63,18 +65,18 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
63
65
 
64
66
  constructor(props: CellListProps) {
65
67
  super(props);
66
- this.state = { selectedCell: props.notebookModel.selectedCell, dragOverIndicator: undefined, scrollIntoView: true };
68
+ this.state = { selectedCell: props.notebookViewModel.selectedCell, dragOverIndicator: undefined, scrollIntoView: true };
67
69
  this.toDispose.push(props.notebookModel.onDidAddOrRemoveCell(e => {
68
70
  if (e.newCellIds && e.newCellIds.length > 0) {
69
71
  this.setState({
70
72
  ...this.state,
71
- selectedCell: this.props.notebookModel.cells.find(model => model.handle === e.newCellIds![e.newCellIds!.length - 1]),
73
+ selectedCell: props.notebookViewModel.selectedCell,
72
74
  scrollIntoView: true
73
75
  });
74
76
  } else {
75
77
  this.setState({
76
78
  ...this.state,
77
- selectedCell: this.props.notebookModel.cells.find(cell => cell === this.state.selectedCell),
79
+ selectedCell: props.notebookViewModel.selectedCell,
78
80
  scrollIntoView: false
79
81
  });
80
82
  }
@@ -87,7 +89,7 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
87
89
  }
88
90
  }));
89
91
 
90
- this.toDispose.push(props.notebookModel.onDidChangeSelectedCell(e => {
92
+ this.toDispose.push(props.notebookViewModel.onDidChangeSelectedCell(e => {
91
93
  this.setState({
92
94
  ...this.state,
93
95
  selectedCell: e.cell,
@@ -103,7 +105,7 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
103
105
  let hasCellFocus = false;
104
106
  let hasFocus = false;
105
107
  if (this.cellListRef.current.contains(document.activeElement)) {
106
- if (this.props.notebookModel.selectedCell) {
108
+ if (this.props.notebookViewModel.selectedCell) {
107
109
  hasCellFocus = true;
108
110
  }
109
111
  hasFocus = true;
@@ -121,8 +123,9 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
121
123
  override render(): React.ReactNode {
122
124
  return <ul className='theia-notebook-cell-list' ref={this.cellListRef} onDragStart={e => this.onDragStart(e)}>
123
125
  {this.props.notebookModel.getVisibleCells()
124
- .map((cell, index) =>
125
- <React.Fragment key={'cell-' + cell.handle}>
126
+ .map((cell, index) => {
127
+ const cellViewModel = this.props.notebookViewModel.cellViewModels.get(cell.handle);
128
+ return <React.Fragment key={'cell-' + cell.handle}>
126
129
  <NotebookCellDivider
127
130
  menuRegistry={this.props.menuRegistry}
128
131
  isVisible={() => this.isEnabled()}
@@ -143,14 +146,14 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
143
146
  ref={ref => {
144
147
  if (ref && cell === this.state.selectedCell && this.state.scrollIntoView) {
145
148
  ref.scrollIntoView({ block: 'nearest' });
146
- if (cell.cellKind === CellKind.Markup && !cell.editing) {
149
+ if (cell.cellKind === CellKind.Markup && !cellViewModel?.editing) {
147
150
  ref.focus();
148
151
  }
149
152
  }
150
153
  }}
151
154
  onClick={e => {
152
155
  this.setState({ ...this.state, selectedCell: cell });
153
- this.props.notebookModel.setSelectedCell(cell, false);
156
+ this.props.notebookViewModel.setSelectedCell(cell, false);
154
157
  }}
155
158
  >
156
159
  <div className='theia-notebook-cell-sidebar'>
@@ -162,13 +165,13 @@ export class NotebookCellListView extends React.Component<CellListProps, Noteboo
162
165
  </div>
163
166
  {this.state.selectedCell === cell &&
164
167
  this.props.toolbarRenderer.renderCellToolbar(NotebookCellActionContribution.ACTION_MENU, cell, {
165
- contextMenuArgs: () => [cell], commandArgs: () => [this.props.notebookModel]
168
+ contextMenuArgs: () => [cell], commandArgs: () => [this.props.notebookModel, cell]
166
169
  })
167
170
  }
168
171
  </li>
169
172
  <CellDropIndicator visible={this.shouldRenderDragOverIndicator(cell, 'bottom')} />
170
- </React.Fragment>
171
- )
173
+ </React.Fragment>;
174
+ })
172
175
  }
173
176
  <NotebookCellDivider
174
177
  menuRegistry={this.props.menuRegistry}
@@ -74,15 +74,16 @@ export class NotebookCellToolbarFactory {
74
74
  this.toDisposeOnRender = new DisposableCollection();
75
75
  const inlineItems: NotebookCellToolbarItem[] = [];
76
76
  const menu = this.menuRegistry.getMenu(menuItemPath);
77
+
78
+ this.toDisposeOnRender.push(this.notebookContextManager.scopedStore?.onDidChangeContext(() => {
79
+ this.onDidChangeContextEmitter.fire();
80
+ }));
81
+
77
82
  if (menu) {
78
83
  for (const menuNode of menu.children) {
79
-
80
84
  const itemPath = [...menuItemPath, menuNode.id];
81
85
  if (menuNode.isVisible(itemPath, this.notebookContextManager.getCellContext(cell.handle), this.notebookContextManager.context, itemOptions.commandArgs?.() ?? [])) {
82
86
  if (RenderedMenuNode.is(menuNode)) {
83
- if (menuNode.onDidChange) {
84
- this.toDisposeOnRender.push(menuNode.onDidChange(() => this.onDidChangeContextEmitter.fire()));
85
- }
86
87
  inlineItems.push(this.createToolbarItem(itemPath, menuNode, itemOptions));
87
88
  }
88
89
  }
@@ -38,6 +38,7 @@ import { NotebookCellEditorService } from '../service/notebook-cell-editor-servi
38
38
  import { CellOutputWebview } from '../renderers/cell-output-webview';
39
39
  import { NotebookCellStatusBarItem, NotebookCellStatusBarItemList, NotebookCellStatusBarService } from '../service/notebook-cell-status-bar-service';
40
40
  import { LabelParser } from '@theia/core/lib/browser/label-parser';
41
+ import { NotebookViewModel } from '../view-model/notebook-view-model';
41
42
 
42
43
  @injectable()
43
44
  export class NotebookCodeCellRenderer implements CellRenderer {
@@ -83,10 +84,14 @@ export class NotebookCodeCellRenderer implements CellRenderer {
83
84
  @inject(LabelParser)
84
85
  protected readonly labelParser: LabelParser;
85
86
 
87
+ @inject(NotebookViewModel)
88
+ protected readonly notebookViewModel: NotebookViewModel;
89
+
86
90
  render(notebookModel: NotebookModel, cell: NotebookCellModel, handle: number): React.ReactNode {
87
91
  return <div className='theia-notebook-cell-with-sidebar' ref={ref => observeCellHeight(ref, cell)}>
88
92
  <div className='theia-notebook-cell-editor-container'>
89
93
  <CellEditor notebookModel={notebookModel} cell={cell}
94
+ notebookViewModel={this.notebookViewModel}
90
95
  monacoServices={this.monacoServices}
91
96
  notebookContextManager={this.notebookContextManager}
92
97
  notebookViewportService={this.notebookViewportService}
@@ -97,7 +102,7 @@ export class NotebookCodeCellRenderer implements CellRenderer {
97
102
  executionStateService={this.executionStateService}
98
103
  cellStatusBarService={this.notebookCellStatusBarService}
99
104
  labelParser={this.labelParser}
100
- onClick={() => cell.requestFocusEditor()} />
105
+ onClick={() => this.notebookViewModel.cellViewModels.get(cell.handle)?.requestFocusEditor()} />
101
106
  </div >
102
107
  </div >;
103
108
  }
@@ -32,6 +32,7 @@ import * as mark from 'advanced-mark.js';
32
32
  import { NotebookCellEditorService } from '../service/notebook-cell-editor-service';
33
33
  import { NotebookCellStatusBarService } from '../service/notebook-cell-status-bar-service';
34
34
  import { LabelParser } from '@theia/core/lib/browser/label-parser';
35
+ import { NotebookViewModel } from '../view-model/notebook-view-model';
35
36
 
36
37
  @injectable()
37
38
  export class NotebookMarkdownCellRenderer implements CellRenderer {
@@ -59,6 +60,9 @@ export class NotebookMarkdownCellRenderer implements CellRenderer {
59
60
  @inject(LabelParser)
60
61
  protected readonly labelParser: LabelParser;
61
62
 
63
+ @inject(NotebookViewModel)
64
+ protected readonly notebookViewModel: NotebookViewModel;
65
+
62
66
  render(notebookModel: NotebookModel, cell: NotebookCellModel): React.ReactNode {
63
67
  return <MarkdownCell
64
68
  markdownRenderer={this.markdownRenderer}
@@ -67,6 +71,7 @@ export class NotebookMarkdownCellRenderer implements CellRenderer {
67
71
  notebookOptionsService={this.notebookOptionsService}
68
72
  cell={cell}
69
73
  notebookModel={notebookModel}
74
+ notebookViewModel={this.notebookViewModel}
70
75
  notebookContextManager={this.notebookContextManager}
71
76
  notebookCellEditorService={this.notebookCellEditorService}
72
77
  notebookCellStatusBarService={this.notebookCellStatusBarService}
@@ -95,6 +100,7 @@ interface MarkdownCellProps {
95
100
  commandRegistry: CommandRegistry;
96
101
  cell: NotebookCellModel;
97
102
  notebookModel: NotebookModel;
103
+ notebookViewModel: NotebookViewModel;
98
104
  notebookContextManager: NotebookContextManager;
99
105
  notebookOptionsService: NotebookOptionsService;
100
106
  notebookCellEditorService: NotebookCellEditorService;
@@ -103,17 +109,30 @@ interface MarkdownCellProps {
103
109
  }
104
110
 
105
111
  function MarkdownCell({
106
- markdownRenderer, monacoServices, cell, notebookModel, notebookContextManager,
112
+ markdownRenderer, monacoServices, cell, notebookModel, notebookViewModel, notebookContextManager,
107
113
  notebookOptionsService, commandRegistry, notebookCellEditorService, notebookCellStatusBarService,
108
114
  labelParser
109
115
  }: MarkdownCellProps): React.JSX.Element {
110
- const [editMode, setEditMode] = React.useState(cell.editing);
116
+ const [editMode, setEditMode] = React.useState(notebookViewModel.cellViewModels.get(cell.handle)?.editing || false);
117
+ const [, forceUpdate] = React.useReducer(x => x + 1, 0);
111
118
  let empty = false;
112
119
 
113
120
  React.useEffect(() => {
114
- const listener = cell.onDidRequestCellEditChange(cellEdit => setEditMode(cellEdit));
115
- return () => listener.dispose();
116
- }, [editMode]);
121
+ if (!editMode) {
122
+ const listener = cell.onDidChangeContent(type => {
123
+ if (type === 'content') {
124
+ forceUpdate();
125
+ }
126
+ });
127
+ return () => listener.dispose();
128
+ }
129
+ }, [editMode, cell]);
130
+
131
+ React.useEffect(() => {
132
+ const cellViewModel = notebookViewModel.cellViewModels.get(cell.handle);
133
+ const listener = cellViewModel?.onDidRequestCellEditChange(cellEdit => setEditMode(cellEdit));
134
+ return () => listener?.dispose();
135
+ }, [editMode, notebookViewModel, cell]);
117
136
 
118
137
  React.useEffect(() => {
119
138
  if (!editMode) {
@@ -156,6 +175,7 @@ function MarkdownCell({
156
175
  return editMode ?
157
176
  (<div className='theia-notebook-markdown-editor-container' key="code" ref={ref => observeCellHeight(ref, cell)}>
158
177
  <CellEditor notebookModel={notebookModel} cell={cell}
178
+ notebookViewModel={notebookViewModel}
159
179
  monacoServices={monacoServices}
160
180
  notebookContextManager={notebookContextManager}
161
181
  notebookCellEditorService={notebookCellEditorService}
@@ -164,10 +184,10 @@ function MarkdownCell({
164
184
  commandRegistry={commandRegistry}
165
185
  cellStatusBarService={notebookCellStatusBarService}
166
186
  labelParser={labelParser}
167
- onClick={() => cell.requestFocusEditor()} />
187
+ onClick={() => notebookViewModel.cellViewModels.get(cell.handle)?.requestFocusEditor()} />
168
188
  </div >) :
169
189
  (<div className='theia-notebook-markdown-content' key="markdown"
170
- onDoubleClick={() => cell.requestEdit()}
190
+ onDoubleClick={() => notebookViewModel.cellViewModels.get(cell.handle)?.requestEdit()}
171
191
  ref={node => {
172
192
  node?.replaceChildren(...markdownContent);
173
193
  observeCellHeight(node, cell);
@@ -38,8 +38,6 @@ import { Range } from '@theia/core/shared/vscode-languageserver-protocol';
38
38
  export const NotebookCellModelFactory = Symbol('NotebookModelFactory');
39
39
  export type NotebookCellModelFactory = (props: NotebookCellModelProps) => NotebookCellModel;
40
40
 
41
- export type CellEditorFocusRequest = number | 'lastLine' | undefined;
42
-
43
41
  export function createNotebookCellModelContainer(parent: interfaces.Container, props: NotebookCellModelProps): interfaces.Container {
44
42
  const child = parent.createChild();
45
43
 
@@ -109,15 +107,6 @@ export class NotebookCellModel implements NotebookCell, Disposable {
109
107
  protected readonly onDidChangeLanguageEmitter = new Emitter<string>();
110
108
  readonly onDidChangeLanguage = this.onDidChangeLanguageEmitter.event;
111
109
 
112
- protected readonly onDidRequestCellEditChangeEmitter = new Emitter<boolean>();
113
- readonly onDidRequestCellEditChange = this.onDidRequestCellEditChangeEmitter.event;
114
-
115
- protected readonly onWillFocusCellEditorEmitter = new Emitter<CellEditorFocusRequest>();
116
- readonly onWillFocusCellEditor = this.onWillFocusCellEditorEmitter.event;
117
-
118
- protected readonly onWillBlurCellEditorEmitter = new Emitter<void>();
119
- readonly onWillBlurCellEditor = this.onWillBlurCellEditorEmitter.event;
120
-
121
110
  protected readonly onDidChangeEditorOptionsEmitter = new Emitter<MonacoEditor.IOptions>();
122
111
  readonly onDidChangeEditorOptions = this.onDidChangeEditorOptionsEmitter.event;
123
112
 
@@ -165,7 +154,7 @@ export class NotebookCellModel implements NotebookCell, Disposable {
165
154
 
166
155
  protected _metadata: NotebookCellMetadata;
167
156
 
168
- protected toDispose = new DisposableCollection();
157
+ toDispose = new DisposableCollection();
169
158
 
170
159
  protected _internalMetadata: NotebookCellInternalMetadata;
171
160
 
@@ -190,6 +179,10 @@ export class NotebookCellModel implements NotebookCell, Disposable {
190
179
  return this.textModel && !this.textModel.isDisposed() ? this.textModel.getText() : this.source;
191
180
  }
192
181
 
182
+ get isTextModelWritable(): boolean {
183
+ return !this.textModel || !this.textModel.readOnly;
184
+ }
185
+
193
186
  get source(): string {
194
187
  return this.props.source;
195
188
  }
@@ -231,11 +224,6 @@ export class NotebookCellModel implements NotebookCell, Disposable {
231
224
  return this.props.cellKind;
232
225
  }
233
226
 
234
- protected _editing: boolean = false;
235
- get editing(): boolean {
236
- return this._editing;
237
- }
238
-
239
227
  protected _editorOptions: MonacoEditor.IOptions = {};
240
228
  get editorOptions(): Readonly<MonacoEditor.IOptions> {
241
229
  return this._editorOptions;
@@ -309,28 +297,6 @@ export class NotebookCellModel implements NotebookCell, Disposable {
309
297
  this.toDispose.dispose();
310
298
  }
311
299
 
312
- requestEdit(): void {
313
- if (!this.textModel || !this.textModel.readOnly) {
314
- this._editing = true;
315
- this.onDidRequestCellEditChangeEmitter.fire(true);
316
- }
317
- }
318
-
319
- requestStopEdit(): void {
320
- this._editing = false;
321
- this.onDidRequestCellEditChangeEmitter.fire(false);
322
- }
323
-
324
- requestFocusEditor(focusRequest?: CellEditorFocusRequest): void {
325
- this.requestEdit();
326
- this.onWillFocusCellEditorEmitter.fire(focusRequest);
327
- }
328
-
329
- requestBlurEditor(): void {
330
- this.requestStopEdit();
331
- this.onWillBlurCellEditorEmitter.fire();
332
- }
333
-
334
300
  requestCenterEditor(): void {
335
301
  this.onDidRequestCenterEditorEmitter.fire();
336
302
  }
@@ -404,6 +370,7 @@ export class NotebookCellModel implements NotebookCell, Disposable {
404
370
  this.toDispose.push(ref);
405
371
  this.toDispose.push(this.textModel.onDidChangeContent(e => {
406
372
  this.props.source = e.model.getText();
373
+ this.onDidChangeContentEmitter.fire('content');
407
374
  }));
408
375
  return ref.object;
409
376
  }
@@ -422,8 +389,8 @@ export class NotebookCellModel implements NotebookCell, Disposable {
422
389
  }
423
390
 
424
391
  findMatches(options: NotebookEditorFindMatchOptions): NotebookEditorFindMatch[] {
425
- if (this.cellKind === CellKind.Markup && !this.editing) {
426
- return this.onMarkdownFind?.(options) ?? [];
392
+ if (this.cellKind === CellKind.Markup && this.onMarkdownFind) {
393
+ return this.onMarkdownFind(options) ?? [];
427
394
  }
428
395
  if (!this.textModel) {
429
396
  return [];
@@ -58,11 +58,6 @@ export interface NotebookModelProps {
58
58
  serializer: NotebookSerializer;
59
59
  }
60
60
 
61
- export interface SelectedCellChangeEvent {
62
- cell: NotebookCellModel | undefined;
63
- scrollIntoView: boolean;
64
- }
65
-
66
61
  @injectable()
67
62
  export class NotebookModel implements Saveable, Disposable {
68
63
 
@@ -81,9 +76,6 @@ export class NotebookModel implements Saveable, Disposable {
81
76
  protected readonly onContentChangedEmitter = new Emitter<void>();
82
77
  readonly onContentChanged = this.onContentChangedEmitter.event;
83
78
 
84
- protected readonly onDidChangeSelectedCellEmitter = new Emitter<SelectedCellChangeEvent>();
85
- readonly onDidChangeSelectedCell = this.onDidChangeSelectedCellEmitter.event;
86
-
87
79
  protected readonly onDidDisposeEmitter = new Emitter<void>();
88
80
  readonly onDidDispose = this.onDidDisposeEmitter.event;
89
81
 
@@ -136,7 +128,6 @@ export class NotebookModel implements Saveable, Disposable {
136
128
  return this._selectedText;
137
129
  }
138
130
 
139
- selectedCell?: NotebookCellModel;
140
131
  protected dirtyCells: NotebookCellModel[] = [];
141
132
 
142
133
  cells: NotebookCellModel[];
@@ -179,7 +170,6 @@ export class NotebookModel implements Saveable, Disposable {
179
170
  this.onDidSaveNotebookEmitter.dispose();
180
171
  this.onDidAddOrRemoveCellEmitter.dispose();
181
172
  this.onDidChangeContentEmitter.dispose();
182
- this.onDidChangeSelectedCellEmitter.dispose();
183
173
  this.cells.forEach(cell => cell.dispose());
184
174
  this.onDidDisposeEmitter.fire();
185
175
  }
@@ -271,21 +261,11 @@ export class NotebookModel implements Saveable, Disposable {
271
261
  }
272
262
  }
273
263
 
274
- setSelectedCell(cell: NotebookCellModel, scrollIntoView?: boolean): void {
275
- if (this.selectedCell !== cell) {
276
- this.selectedCell = cell;
277
- this.onDidChangeSelectedCellEmitter.fire({ cell, scrollIntoView: scrollIntoView ?? true });
278
- }
279
- }
280
-
281
264
  private addCellOutputListeners(cells: NotebookCellModel[]): void {
282
265
  for (const cell of cells) {
283
266
  cell.onDidChangeOutputs(() => {
284
267
  this.dirty = true;
285
268
  });
286
- cell.onDidRequestCellEditChange(() => {
287
- this.onContentChangedEmitter.fire();
288
- });
289
269
  }
290
270
  }
291
271
 
@@ -318,11 +298,9 @@ export class NotebookModel implements Saveable, Disposable {
318
298
  this.cellDirtyChanged(cell, true);
319
299
  }
320
300
 
321
- let scrollIntoView = true;
322
301
  switch (edit.editType) {
323
302
  case CellEditType.Replace:
324
303
  this.replaceCells(edit.index, edit.count, edit.cells, computeUndoRedo, true);
325
- scrollIntoView = edit.cells.length > 0;
326
304
  break;
327
305
  case CellEditType.Output: {
328
306
  if (edit.append) {
@@ -362,11 +340,6 @@ export class NotebookModel implements Saveable, Disposable {
362
340
  this.moveCellToIndex(cellIndex, edit.length, edit.newIdx, computeUndoRedo);
363
341
  break;
364
342
  }
365
-
366
- // if selected cell is affected update it because it can potentially have been replaced
367
- if (cell === this.selectedCell) {
368
- this.setSelectedCell(this.cells[Math.min(cellIndex, this.cells.length - 1)], scrollIntoView);
369
- }
370
343
  }
371
344
 
372
345
  this.fireContentChange();
@@ -377,7 +350,7 @@ export class NotebookModel implements Saveable, Disposable {
377
350
  this.onContentChangedEmitter.fire();
378
351
  }
379
352
 
380
- protected replaceCells(start: number, deleteCount: number, newCells: CellData[], computeUndoRedo: boolean, requestEdit: boolean): void {
353
+ protected replaceCells(start: number, deleteCount: number, newCells: CellData[], computeUndoRedo: boolean, externalEvent: boolean): void {
381
354
  const cells = newCells.map(cell => {
382
355
  const handle = this.nextHandle++;
383
356
  return this.cellModelFactory({
@@ -420,12 +393,8 @@ export class NotebookModel implements Saveable, Disposable {
420
393
  );
421
394
  }
422
395
 
423
- this.onDidAddOrRemoveCellEmitter.fire({ rawEvent: { kind: NotebookCellsChangeType.ModelChange, changes }, newCellIds: cells.map(cell => cell.handle) });
396
+ this.onDidAddOrRemoveCellEmitter.fire({ rawEvent: { kind: NotebookCellsChangeType.ModelChange, changes }, newCellIds: cells.map(cell => cell.handle), externalEvent });
424
397
  this.onDidChangeContentEmitter.queue({ kind: NotebookCellsChangeType.ModelChange, changes });
425
- if (cells.length > 0 && requestEdit) {
426
- this.setSelectedCell(cells[cells.length - 1]);
427
- cells[cells.length - 1].requestEdit();
428
- }
429
398
  }
430
399
 
431
400
  protected changeCellInternalMetadataPartial(cell: NotebookCellModel, internalMetadata: NullablePartialNotebookCellInternalMetadata): void {