mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 15:47:08 +00:00
Keep track of opened documents and prepare for undo/redo
This commit is contained in:
@@ -63,7 +63,6 @@ function Head({ simpleType, optional, node }: HeadProps) {
|
||||
</select>
|
||||
}
|
||||
if (type.kind === 'struct' && optional) {
|
||||
console.log(type, node)
|
||||
if (node && JsonObjectNode.is(node)) {
|
||||
return <button class="node-collapse open tooltipped tip-se" aria-label={locale('remove')}>
|
||||
{Octicon.trashcan}
|
||||
@@ -83,7 +82,7 @@ function Head({ simpleType, optional, node }: HeadProps) {
|
||||
{Octicon.plus_circle}
|
||||
</button>
|
||||
}
|
||||
console.warn('Unhandled head', type)
|
||||
// console.warn('Unhandled head', type)
|
||||
return <></>
|
||||
}
|
||||
|
||||
@@ -108,7 +107,7 @@ function Body({ simpleType, node }: BodyProps) {
|
||||
if (type.kind === 'byte' || type.kind === 'short' || type.kind === 'int' || type.kind === 'boolean') {
|
||||
return <></>
|
||||
}
|
||||
console.warn('Unhandled body', type, node)
|
||||
// console.warn('Unhandled body', type, node)
|
||||
return <></>
|
||||
}
|
||||
|
||||
@@ -124,8 +123,8 @@ function StructBody({ type, node }: StructBodyProps) {
|
||||
const dynamicFields = type.fields.filter(field =>
|
||||
field.key.kind === 'string')
|
||||
if (type.fields.length !== staticFields.length + dynamicFields.length) {
|
||||
console.warn('Missed struct fields', type.fields.filter(field =>
|
||||
!staticFields.includes(field) && !dynamicFields.includes(field)))
|
||||
// console.warn('Missed struct fields', type.fields.filter(field =>
|
||||
// !staticFields.includes(field) && !dynamicFields.includes(field)))
|
||||
}
|
||||
return <>
|
||||
{staticFields.map(field => {
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -78,7 +78,7 @@ export function SourcePanel({ spyglass, docAndNode, doCopy, doDownload, doImport
|
||||
if (!spyglass || !docAndNode) return
|
||||
try {
|
||||
const data = await parseSource(value, format)
|
||||
await spyglass.setFileContents(version, docAndNode.doc.uri, JSON.stringify(data))
|
||||
await spyglass.writeFile(version, docAndNode.doc.uri, JSON.stringify(data))
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
e.message = `Error importing: ${e.message}`
|
||||
|
||||
Reference in New Issue
Block a user