Skip to content

Commit b670398

Browse files
Merge pull request #1 from davidbrochart/set-source
Fix ydoc loading
2 parents 955abbb + 93c20b7 commit b670398

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ micromamba create -n my-jupyter-shared-drive
77
micromamba activate my-jupyter-shared-drive
88
micromamba install pip nodejs
99
git clone https://github.com/davidbrochart/my-jupyter-shared-drive
10-
cd my jupyter-shared-drive
10+
cd my-jupyter-shared-drive
1111
pip install -e .
1212
pip install jupyterlab
1313
jupyter labextension develop --overwrite .

packages/my-shared-docprovider-extension/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"watch:labextension": "jupyter labextension watch ."
5454
},
5555
"dependencies": {
56+
"@jupyter/collaborative-drive": "^3.1.0",
5657
"@jupyter/my-shared-docprovider": "^0.1.0",
5758
"@jupyterlab/filebrowser": "^4.2.0"
5859
},
@@ -87,6 +88,10 @@
8788
"bundled": false,
8889
"singleton": true
8990
},
91+
"@jupyter/collaborative-drive": {
92+
"bundled": true,
93+
"singleton": true
94+
},
9095
"@jupyter/my-shared-drive": {
9196
"bundled": false,
9297
"singleton": true

packages/my-shared-docprovider/src/drive.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ export class MySharedDrive extends Drive implements ICollaborativeDrive {
158158
translator: this._trans
159159
});
160160

161-
super.get(options.path, { content: true }).then(model => { sharedModel.source = model.content; });
161+
super.get(options.path, { content: true }).then(model => {
162+
provider.setSource(model.content);
163+
});
162164

163165
const key = `${options.format}:${options.contentType}:${options.path}`;
164166
this._providers.set(key, provider);

packages/my-shared-docprovider/src/yprovider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class MyProvider implements IDocumentProvider {
2929
this._contentType = options.contentType;
3030
this._format = options.format;
3131
this._awareness = options.model.awareness;
32+
this._model = options.model;
3233

3334
const user = options.user;
3435

@@ -38,7 +39,10 @@ export class MyProvider implements IDocumentProvider {
3839
})
3940
.catch(e => console.error(e));
4041
user.userChanged.connect(this._onUserChanged, this);
42+
}
4143

44+
setSource(value: any): void {
45+
this._model.setSource(value);
4246
this._ready.resolve();
4347
}
4448

@@ -82,6 +86,7 @@ export class MyProvider implements IDocumentProvider {
8286
private _format: string;
8387
private _isDisposed: boolean;
8488
private _ready = new PromiseDelegate<void>();
89+
private _model: YDocument<DocumentChange>;
8590
}
8691

8792
/**

yarn.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ __metadata:
17541754
languageName: node
17551755
linkType: hard
17561756

1757-
"@jupyter/collaborative-drive@npm:^3.0.0":
1757+
"@jupyter/collaborative-drive@npm:^3.0.0, @jupyter/collaborative-drive@npm:^3.1.0":
17581758
version: 3.1.0
17591759
resolution: "@jupyter/collaborative-drive@npm:3.1.0"
17601760
dependencies:
@@ -1793,6 +1793,7 @@ __metadata:
17931793
version: 0.0.0-use.local
17941794
resolution: "@jupyter/my-shared-docprovider-extension@workspace:packages/my-shared-docprovider-extension"
17951795
dependencies:
1796+
"@jupyter/collaborative-drive": ^3.1.0
17961797
"@jupyter/my-shared-docprovider": ^0.1.0
17971798
"@jupyterlab/builder": ^4.0.5
17981799
"@jupyterlab/filebrowser": ^4.2.0

0 commit comments

Comments
 (0)