We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 03f8567 commit 6674ba2Copy full SHA for 6674ba2
packages/schema/src/doc.ts
@@ -75,12 +75,20 @@ export class JupyterCadDoc
75
return { objects, options, metadata, outputs };
76
}
77
78
- setSource(value: JSONObject | string): void {
79
- if (!value) {
+ setSource(source: JSONObject | string): void {
+ if (!source) {
80
return;
81
82
+ let value: JSONObject;
83
+
84
+ if (typeof source === 'string') {
85
+ value = JSON.parse(source);
86
+ } else {
87
+ value = source;
88
+ }
89
90
this.transact(() => {
- const objects = value['objects'] ?? [];
91
+ const objects = (value['objects'] ?? []) as any[];
92
objects.forEach(obj => {
93
this._objects.push([new Y.Map(Object.entries(obj))]);
94
});
0 commit comments