| 1 |
// eslint-disable-next-line simple-import-sort/imports |
| 2 |
import AceEditor from 'react-ace'; |
| 3 |
import 'ace-builds/src-noconflict/mode-css'; |
| 4 |
import 'ace-builds/src-noconflict/mode-javascript'; |
| 5 |
import 'ace-builds/src-noconflict/snippets/css'; |
| 6 |
import 'ace-builds/src-noconflict/snippets/javascript'; |
| 7 |
import 'ace-builds/src-noconflict/snippets/text'; |
| 8 |
import 'ace-builds/src-noconflict/ext-language_tools'; |
| 9 |
|
| 10 |
/** |
| 11 |
* Component Class |
| 12 |
* |
| 13 |
* @param props |
| 14 |
*/ |
| 15 |
export default function CodeEditor(props) { |
| 16 |
const { setOptions = {}, editorProps = {}, ...restProps } = props; |
| 17 |
|
| 18 |
return ( |
| 19 |
<AceEditor |
| 20 |
className="ghostkit-component-code-editor" |
| 21 |
theme="textmate" |
| 22 |
onLoad={(editor) => { |
| 23 |
editor.renderer.setScrollMargin(16, 16, 16, 16); |
| 24 |
editor.renderer.setPadding(16); |
| 25 |
}} |
| 26 |
fontSize={12} |
| 27 |
showPrintMargin |
| 28 |
showGutter |
| 29 |
highlightActiveLine={false} |
| 30 |
width="100%" |
| 31 |
setOptions={{ |
| 32 |
enableBasicAutocompletion: true, |
| 33 |
enableLiveAutocompletion: true, |
| 34 |
enableSnippets: true, |
| 35 |
showLineNumbers: true, |
| 36 |
printMargin: false, |
| 37 |
tabSize: 2, |
| 38 |
|
| 39 |
// When worker is enabled, a lot of errors displayed in the console. |
| 40 |
useWorker: false, |
| 41 |
|
| 42 |
...setOptions, |
| 43 |
}} |
| 44 |
editorProps={{ |
| 45 |
$blockScrolling: Infinity, |
| 46 |
...editorProps, |
| 47 |
}} |
| 48 |
{...restProps} |
| 49 |
/> |
| 50 |
); |
| 51 |
} |
| 52 |
|