({
className,
language,
onChange,
value,
readOnly,
...props
}: CodeEditorProps)
| 11 | } |
| 12 | |
| 13 | export default function CodeEditor({ |
| 14 | className, |
| 15 | language, |
| 16 | onChange, |
| 17 | value, |
| 18 | readOnly, |
| 19 | ...props |
| 20 | }: CodeEditorProps) { |
| 21 | const handleEditorDidMount = ( |
| 22 | editor: editor.IStandaloneCodeEditor, |
| 23 | monaco: Monaco, |
| 24 | ) => { |
| 25 | monaco.editor.defineTheme("custom", { |
| 26 | base: "vs", |
| 27 | inherit: true, |
| 28 | rules: [], |
| 29 | colors: { |
| 30 | "editor.lineHighlightBackground": "#e8f7ff", |
| 31 | "editorLineNumber.foreground": "#5A5A5A", |
| 32 | }, |
| 33 | }); |
| 34 | monaco.editor.setTheme("custom"); |
| 35 | }; |
| 36 | |
| 37 | return ( |
| 38 | <ReactMonacoEditor |
| 39 | {...(language && { language })} |
| 40 | onMount={handleEditorDidMount} |
| 41 | onChange={ |
| 42 | onChange ? (value, _ev) => onChange(value || "") : undefined |
| 43 | } |
| 44 | theme="custom" |
| 45 | options={{ |
| 46 | tabSize: 2, |
| 47 | minimap: { enabled: false }, |
| 48 | scrollbar: { |
| 49 | verticalScrollbarSize: 5, |
| 50 | horizontalScrollbarSize: 5, |
| 51 | }, |
| 52 | renderLineHighlight: "all", |
| 53 | inlineSuggest: { enabled: false }, |
| 54 | suggestOnTriggerCharacters: false, |
| 55 | quickSuggestions: false, |
| 56 | wordBasedSuggestions: "off", |
| 57 | suggest: { preview: false }, |
| 58 | readOnly: readOnly, |
| 59 | }} |
| 60 | width="100%" |
| 61 | wrapperProps={{ className: "editor-wrapper" }} |
| 62 | value={value || ""} |
| 63 | {...props} |
| 64 | /> |
| 65 | ); |
| 66 | } |
nothing calls this directly
no outgoing calls
no test coverage detected