mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
25 lines
758 B
TypeScript
25 lines
758 B
TypeScript
import { default as CodeMirror, type ReactCodeMirrorProps } from "@uiw/react-codemirror";
|
|
|
|
import { useBknd } from "ui/client/bknd";
|
|
|
|
export default function CodeEditor({ editable, basicSetup, ...props }: ReactCodeMirrorProps) {
|
|
const b = useBknd();
|
|
const theme = b.app.getAdminConfig().color_scheme;
|
|
const _basicSetup: Partial<ReactCodeMirrorProps["basicSetup"]> = !editable
|
|
? {
|
|
...(typeof basicSetup === "object" ? basicSetup : {}),
|
|
highlightActiveLine: false,
|
|
highlightActiveLineGutter: false
|
|
}
|
|
: basicSetup;
|
|
|
|
return (
|
|
<CodeMirror
|
|
theme={theme === "dark" ? "dark" : "light"}
|
|
editable={editable}
|
|
basicSetup={_basicSetup}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|