-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCodeEditor.tsx
56 lines (50 loc) · 1.23 KB
/
CodeEditor.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use client'
import React from 'react';
// import dynamic from 'next/dynamic';
import MonacoEditor from 'react-monaco-editor';
import { CodeEditorProps } from '@/types/webappTypes/componentsTypes';
// const MonacoEditor = dynamic(import('react-monaco-editor'), { ssr: false });
const CodeEditor = ({
code,
setCode
}: CodeEditorProps) => {
const handleEditorChange = (newCode: string, event: any) => {
setCode(newCode);
};
const options = {
autoIndent: 'full',
contextmenu: true,
fontFamily: 'monospace',
fontSize: 13,
lineHeight: 24,
hideCursorInOverviewRuler: true,
matchBrackets: 'always',
minimap: {
enabled: true,
},
scrollbar: {
horizontalSliderSize: 4,
verticalSliderSize: 18,
},
selectOnLineNumbers: true,
roundedSelection: false,
readOnly: false,
cursorStyle: 'line',
automaticLayout: true,
};
return (
<div className='w-full rounded-[6px] overflow-hidden'>
<MonacoEditor
width="800"
height="400"
language="javascript"
theme="vs-dark"
value={code}
defaultValue={code}
// options={options}
onChange={handleEditorChange}
/>
</div>
)
}
export default CodeEditor