diff --git a/src/Playground.tsx b/src/Playground.tsx index 73c4652..c54734e 100644 --- a/src/Playground.tsx +++ b/src/Playground.tsx @@ -141,7 +141,7 @@ const PlayGround = (props: { return; } try { - setResult({ output: props.convert(code) }); + setResult({ output: props.convert(code), langugage: 'javascript' }); } catch (error: any) { setResult({ error: error.message }); } diff --git a/src/ShowResult.tsx b/src/ShowResult.tsx index 02c6dc4..a3a9cf9 100644 --- a/src/ShowResult.tsx +++ b/src/ShowResult.tsx @@ -2,6 +2,17 @@ import Editor from '@monaco-editor/react'; import './ShowResult.css'; import { Result } from './types'; +function getResultValue(result: Result) { + if(result.langugage === 'javascript') { + return result.output; + } + return JSON.stringify(result.output, null, 2); +} + +function getCodeLanguage(result: Result) { + return result.langugage || 'json'; +} + const ShowResult = (props: { result?: Result }) => { const result = props.result; if (!result) { @@ -15,8 +26,8 @@ const ShowResult = (props: { result?: Result }) => { } return ( ); diff --git a/src/types.ts b/src/types.ts index fe4ffeb..83eea00 100644 --- a/src/types.ts +++ b/src/types.ts @@ -37,4 +37,5 @@ export const DEFAULT_BINDINGS = `const bindings = { export type Result = { output?: any; error?: string; + langugage?: string; };