|
4 | 4 | * MIT License
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -import { ISharedNotebook, IYText, YNotebook } from '@jupyter/ydoc'; |
| 7 | +import { type ISharedNotebook, type IYText, YNotebook } from '@jupyter/ydoc'; |
8 | 8 | import type { ISessionContext } from '@jupyterlab/apputils';
|
9 | 9 | import type { Cell, CodeCell, ICellModel } from '@jupyterlab/cells';
|
10 | 10 | import { type IEditorServices } from '@jupyterlab/codeeditor';
|
@@ -78,6 +78,7 @@ import { Lumino } from '../lumino';
|
78 | 78 | import { Loader } from '../utils';
|
79 | 79 | import type { DatalayerNotebookExtension } from './Notebook';
|
80 | 80 | import addNotebookCommands from './NotebookCommands';
|
| 81 | +import { remoteUserCursors } from '@jupyter/collaboration'; |
81 | 82 |
|
82 | 83 | const COMPLETER_TIMEOUT_MILLISECONDS = 1000;
|
83 | 84 | const DEFAULT_EXTENSIONS = new Array<DatalayerNotebookExtension>();
|
@@ -891,30 +892,36 @@ class CommonFeatures {
|
891 | 892 | themes.addTheme(theme);
|
892 | 893 | }
|
893 | 894 |
|
894 |
| - const editorExtensions = () => { |
895 |
| - const registry = new EditorExtensionRegistry(); |
896 |
| - for (const extensionFactory of EditorExtensionRegistry.getDefaultExtensions( |
897 |
| - { themes } |
898 |
| - )) { |
899 |
| - registry.addExtension(extensionFactory); |
| 895 | + const editorExtensions = new EditorExtensionRegistry(); |
| 896 | + for (const extensionFactory of EditorExtensionRegistry.getDefaultExtensions( |
| 897 | + { themes } |
| 898 | + )) { |
| 899 | + editorExtensions.addExtension(extensionFactory); |
| 900 | + } |
| 901 | + editorExtensions.addExtension({ |
| 902 | + name: 'shared-model-binding', |
| 903 | + factory: options => { |
| 904 | + const sharedModel = options.model.sharedModel as IYText; |
| 905 | + return EditorExtensionRegistry.createImmutableExtension( |
| 906 | + ybinding({ |
| 907 | + ytext: sharedModel.ysource, |
| 908 | + undoManager: sharedModel.undoManager ?? undefined, |
| 909 | + }) |
| 910 | + ); |
| 911 | + }, |
| 912 | + }); |
| 913 | + editorExtensions.addExtension({ |
| 914 | + name: 'remote-user-cursors', |
| 915 | + factory(options) { |
| 916 | + const { awareness, ysource: ytext } = options.model.sharedModel as any; |
| 917 | + return EditorExtensionRegistry.createImmutableExtension( |
| 918 | + remoteUserCursors({ awareness, ytext }) |
| 919 | + ); |
900 | 920 | }
|
901 |
| - registry.addExtension({ |
902 |
| - name: 'shared-model-binding', |
903 |
| - factory: options => { |
904 |
| - const sharedModel = options.model.sharedModel as IYText; |
905 |
| - return EditorExtensionRegistry.createImmutableExtension( |
906 |
| - ybinding({ |
907 |
| - ytext: sharedModel.ysource, |
908 |
| - undoManager: sharedModel.undoManager ?? undefined, |
909 |
| - }) |
910 |
| - ); |
911 |
| - }, |
912 |
| - }); |
913 |
| - return registry; |
914 |
| - }; |
| 921 | + }) |
915 | 922 |
|
916 | 923 | const factoryService = new CodeMirrorEditorFactory({
|
917 |
| - extensions: editorExtensions(), |
| 924 | + extensions: editorExtensions, |
918 | 925 | languages: languages,
|
919 | 926 | });
|
920 | 927 | this._editorServices = {
|
|
0 commit comments