Skip to content

Commit 6674ba2

Browse files
authored
Handle string source coming from shared drive (#686)
1 parent 03f8567 commit 6674ba2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/schema/src/doc.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,20 @@ export class JupyterCadDoc
7575
return { objects, options, metadata, outputs };
7676
}
7777

78-
setSource(value: JSONObject | string): void {
79-
if (!value) {
78+
setSource(source: JSONObject | string): void {
79+
if (!source) {
8080
return;
8181
}
82+
let value: JSONObject;
83+
84+
if (typeof source === 'string') {
85+
value = JSON.parse(source);
86+
} else {
87+
value = source;
88+
}
89+
8290
this.transact(() => {
83-
const objects = value['objects'] ?? [];
91+
const objects = (value['objects'] ?? []) as any[];
8492
objects.forEach(obj => {
8593
this._objects.push([new Y.Map(Object.entries(obj))]);
8694
});

0 commit comments

Comments
 (0)