Keep track of opened documents and prepare for undo/redo

This commit is contained in:
Misode
2024-10-22 15:43:02 +02:00
parent 9cb7f7297c
commit ea37eb168f
6 changed files with 68 additions and 30 deletions

View File

@@ -82,8 +82,11 @@ export function SchemaGenerator({ gen, allowedVersions }: Props) {
ignoreChange.current = true
data = file.data
}
if (data) {
await spyglass.writeFile(version, uri, JSON.stringify(data))
}
// TODO: if data is undefined, set to generator's default
const docAndNode = await spyglass.setFileContents(version, uri, data ? JSON.stringify(data) : undefined)
const docAndNode = await spyglass.getFile(version, uri, () => '{}')
Analytics.setGenerator(gen.id)
return docAndNode
}, [gen.id, version, sharedSnippetId, currentPreset, project.name, file?.id, spyglass])