| 1 |
/** |
| 2 |
* External dependencies |
| 3 |
*/ |
| 4 |
import AceEditor from 'react-ace'; |
| 5 |
import 'ace-builds/src-noconflict/mode-css'; |
| 6 |
import 'ace-builds/src-noconflict/mode-javascript'; |
| 7 |
import 'ace-builds/src-noconflict/snippets/css'; |
| 8 |
import 'ace-builds/src-noconflict/snippets/javascript'; |
| 9 |
import 'ace-builds/src-noconflict/snippets/text'; |
| 10 |
import 'ace-builds/src-noconflict/ext-language_tools'; |
| 11 |
|
| 12 |
/** |
| 13 |
* WordPress dependencies |
| 14 |
*/ |
| 15 |
const { Component } = wp.element; |
| 16 |
|
| 17 |
/** |
| 18 |
* Component Class |
| 19 |
*/ |
| 20 |
export default class CodeEditor extends Component { |
| 21 |
render() { |
| 22 |
return ( |
| 23 |
<AceEditor |
| 24 |
className="ghostkit-component-code-editor" |
| 25 |
theme="textmate" |
| 26 |
onLoad={(editor) => { |
| 27 |
editor.renderer.setScrollMargin(16, 16, 16, 16); |
| 28 |
editor.renderer.setPadding(16); |
| 29 |
}} |
| 30 |
fontSize={12} |
| 31 |
showPrintMargin |
| 32 |
showGutter |
| 33 |
highlightActiveLine={false} |
| 34 |
width="100%" |
| 35 |
setOptions={{ |
| 36 |
enableBasicAutocompletion: true, |
| 37 |
enableLiveAutocompletion: true, |
| 38 |
enableSnippets: true, |
| 39 |
showLineNumbers: true, |
| 40 |
printMargin: false, |
| 41 |
tabSize: 2, |
| 42 |
}} |
| 43 |
editorProps={{ |
| 44 |
$blockScrolling: Infinity, |
| 45 |
}} |
| 46 |
{...this.props} |
| 47 |
/> |
| 48 |
); |
| 49 |
} |
| 50 |
} |
| 51 |
|