mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-25 08:06:51 +00:00
Fix some errors and make others visible
This commit is contained in:
@@ -12,15 +12,22 @@ type SourcePanelProps = {
|
||||
doCopy?: number,
|
||||
doDownload?: number,
|
||||
doImport?: number,
|
||||
onError: (message: string) => unknown,
|
||||
}
|
||||
export function SourcePanel({ lang, name, model, doCopy, doDownload, doImport }: SourcePanelProps) {
|
||||
export function SourcePanel({ lang, name, model, doCopy, doDownload, doImport, onError }: SourcePanelProps) {
|
||||
const loc = locale.bind(null, lang)
|
||||
const source = useRef<HTMLTextAreaElement>(null)
|
||||
const download = useRef<HTMLAnchorElement>(null)
|
||||
|
||||
|
||||
useModel(model, model => {
|
||||
const data = model.schema.hook(transformOutput, new ModelPath(model), model.data)
|
||||
source.current.value = JSON.stringify(data, null, 2) + '\n'
|
||||
try {
|
||||
const data = model.schema.hook(transformOutput, new ModelPath(model), model.data)
|
||||
source.current.value = JSON.stringify(data, null, 2) + '\n'
|
||||
} catch (e) {
|
||||
onError(`Error getting JSON output: ${e.message}`)
|
||||
console.error(e)
|
||||
source.current.value = ''
|
||||
}
|
||||
})
|
||||
|
||||
const onImport = () => {
|
||||
|
||||
Reference in New Issue
Block a user