/**
* MonacoViewer wraps the Monaco editor for both the read-only code preview
* and the editable editor pane. It is the only module importing Monaco, and
* is meant to be lazy-loaded (see CodeView / EditorPane).
*
* @example
*
*/
import Editor, { type OnChange, type OnMount } from "@monaco-editor/react";
import "../monaco-setup";
import { useTheme } from "../theme";
interface MonacoViewerProps {
content: string;
language: string;
readOnly?: boolean;
/** Called with the new text on every edit (editable mode). */
onChange?: OnChange;
/** Gives access to the editor instance (key bindings, focus). */
onMount?: OnMount;
}
export default function MonacoViewer({
content,
language,
readOnly = false,
onChange,
onMount,
}: MonacoViewerProps) {
// Monaco has its own palettes; pick the one matching the app theme.
const theme =
useTheme((state) => state.theme) === "dark" ? "vs-dark" : "light";
return (
);
}