flowgram.ai/apps/docs/components/tsx-editor.tsx
chenjiawei.inizio cbefaa54fb
chore: add license header (#432)
* chore: add license-header

* chore: add precommit

* chore: add license header

* fix: only js & shell style
2025-07-01 11:53:02 +00:00

40 lines
850 B
TypeScript

/**
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
* SPDX-License-Identifier: MIT
*/
import { useMemo } from 'react';
import { useDark } from '@rspress/core/runtime';
import {
SandpackProvider,
SandpackLayout,
SandpackCodeEditor,
SandpackPreview,
} from '@codesandbox/sandpack-react';
export const TsxEditor = ({ value }: { value: string }) => {
const dark = useDark();
const theme = useMemo(() => (dark ? 'dark' : 'light'), [dark]);
return (
<SandpackProvider
template="react"
theme={theme}
files={{
'App.js': value,
}}
onChange={(v) => {
console.log('debugger', v);
}}
>
<SandpackLayout>
<SandpackPreview />
</SandpackLayout>
<SandpackLayout>
<SandpackCodeEditor />
</SandpackLayout>
</SandpackProvider>
);
};