@jupyter/docprovider 1.0.0-alpha.2 → 1.0.0-alpha.3

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.
package/lib/ydrive.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { DocumentChange, ISharedDocument, YDocument } from '@jupyter/ydoc';
1
2
  import { TranslationBundle } from '@jupyterlab/translation';
2
3
  import { Contents, Drive, User } from '@jupyterlab/services';
3
4
  /**
@@ -14,7 +15,7 @@ export declare class YDrive extends Drive {
14
15
  /**
15
16
  * SharedModel factory for the YDrive.
16
17
  */
17
- readonly sharedModelFactory: Contents.ISharedFactory;
18
+ readonly sharedModelFactory: SharedModelFactory;
18
19
  /**
19
20
  * Delete a file.
20
21
  *
@@ -77,3 +78,23 @@ export declare class YDrive extends Drive {
77
78
  private _trans;
78
79
  private _providers;
79
80
  }
81
+ /**
82
+ * Yjs sharedModel factory for real-time collaboration.
83
+ */
84
+ declare class SharedModelFactory implements Contents.ISharedFactory {
85
+ private _onCreate;
86
+ private _documentOptions;
87
+ constructor(_onCreate: (options: Contents.ISharedFactoryOptions, sharedModel: YDocument<DocumentChange>) => void);
88
+ /**
89
+ * Whether the IDrive supports real-time collaboration or not.
90
+ */
91
+ readonly collaborative = true;
92
+ setDocumentOptions(type: Contents.ContentType, value: Record<string, any>): void;
93
+ /**
94
+ * Create a new `ISharedDocument` instance.
95
+ *
96
+ * It should return `undefined` if the factory is not able to create a `ISharedDocument`.
97
+ */
98
+ createNew(options: Contents.ISharedFactoryOptions): ISharedDocument | undefined;
99
+ }
100
+ export {};
package/lib/ydrive.js CHANGED
@@ -151,6 +151,13 @@ class SharedModelFactory {
151
151
  * Whether the IDrive supports real-time collaboration or not.
152
152
  */
153
153
  this.collaborative = true;
154
+ this._documentOptions = new Map();
155
+ this._documentOptions.set('notebook', {
156
+ disableDocumentWideUndoRedo: true
157
+ });
158
+ }
159
+ setDocumentOptions(type, value) {
160
+ this._documentOptions.set(type, value);
154
161
  }
155
162
  /**
156
163
  * Create a new `ISharedDocument` instance.
@@ -171,7 +178,7 @@ class SharedModelFactory {
171
178
  sharedModel = new YFile();
172
179
  break;
173
180
  case 'notebook':
174
- sharedModel = new YNotebook();
181
+ sharedModel = new YNotebook(this._documentOptions.get('notebook'));
175
182
  break;
176
183
  //default:
177
184
  // FIXME we should request a registry for the proper sharedModel
package/lib/yprovider.js CHANGED
@@ -24,7 +24,11 @@ export class WebSocketProvider {
24
24
  if (event.code === 1003) {
25
25
  console.error('Document provider closed:', event.reason);
26
26
  showErrorMessage(this._trans.__('Session expired'), this._trans.__('The document session expired. You need to reload this browser tab.'), [Dialog.okButton({ label: this._trans.__('Reload') })])
27
- .then(r => window.location.reload())
27
+ .then((r) => {
28
+ if (r.button.accept) {
29
+ window.location.reload();
30
+ }
31
+ })
28
32
  .catch(e => window.location.reload());
29
33
  // Dispose shared model immediately. Better break the document model,
30
34
  // than overriding data on disk.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter/docprovider",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "JupyterLab - Document Provider",
5
5
  "homepage": "https://github.com/jupyterlab/jupyter_collaboration",
6
6
  "bugs": {