src/vs/workbench/contrib/notebook/common/services/notebookWorkerServiceImpl.ts/NotebookEditorModelManager/_beginModelSync
class NotebookEditorModelManager:	private _beginModelSync(resource: URI): void {
		let model = this._notebookService.listNotebookDocuments().find(document => document.uri.toString() === resource.toString());
		if (!model) {
			return;
		}

		let modelUrl = resource.toString();

		this._proxy.acceptNewModel(
			model.uri.toString(),
			{
				cells: model.cells.map(cell => ({
					handle: cell.handle,
					uri: cell.uri,
					source: cell.getValue(),
					eol: cell.textBuffer.getEOL(),
					language: cell.language,
					mime: cell.mime,
					cellKind: cell.cellKind,
					outputs: cell.outputs.map(op => ({ outputId: op.outputId, outputs: op.outputs })),
					metadata: cell.metadata,
					internalMetadata: cell.internalMetadata,
				})),
				metadata: model.metadata
			}
		);

		const toDispose = new DisposableStore();

		const cellToDto = (cell: NotebookCellTextModel): IMainCellDto => {
			return {
				handle: cell.handle,
				uri: cell.uri,
				source: cell.textBuffer.getLinesContent(),
				eol: cell.textBuffer.getEOL(),
				language: cell.language,
				cellKind: cell.cellKind,
				outputs: cell.outputs,
				metadata: cell.metadata,
				internalMetadata: cell.internalMetadata,
			};
		};

		toDispose.add(model.onDidChangeContent((event) => {
			const dto = event.rawEvents.map(e => {
				const data =
					e.kind === NotebookCellsChangeType.ModelChange || e.kind === NotebookCellsChangeType.Initialize
						? {
							kind: e.kind,
							versionId: event.versionId,
							changes: e.changes.map(diff => [diff[0], diff[1], diff[2].map(cell => cellToDto(cell as NotebookCellTextModel))] as [number, number, IMainCellDto[]])
						}
						: (
							e.kind === NotebookCellsChangeType.Move
								? {
									kind: e.kind,
									index: e.index,
									length: e.length,
									newIdx: e.newIdx,
									versionId: event.versionId,
									cells: e.cells.map(cell => cellToDto(cell as NotebookCellTextModel))
								}
								: e
						);

				return data;
			});

			this._proxy.acceptModelChanged(modelUrl.toString(), {
				rawEvents: dto,
				versionId: event.versionId
			});
		}));

		toDispose.add(model.onWillDispose(() => {
			this._stopModelSync(modelUrl);
		}));
		toDispose.add(toDisposable(() => {
			this._proxy.acceptRemovedModel(modelUrl);
		}));

		this._syncedModels[modelUrl] = toDispose;
	}