-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EuiCodeEditor: make it take a custom mode (#935)
* Allow mode prop to take object for custom mode * Adding mode to PropTypes * Adding note for mode prop type * Adding to CHANGELOG * Don't pass down mode prop to AceEditor if a custom mode is in use Otherwise, AceEditor will complain about wanting a string mode prop. * Implementing componentDidUpdate check
- Loading branch information
1 parent
4f1ccb0
commit fae538f
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { Component } from 'react'; | ||
import 'brace/mode/text'; | ||
|
||
import { | ||
EuiCodeEditor, | ||
} from '../../../../src/components'; | ||
|
||
const TextMode = window.ace.acequire('ace/mode/text').Mode; | ||
class MyCustomAceMode extends TextMode { | ||
// Your custom mode definition goes here. | ||
// See https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode | ||
} | ||
|
||
export default class extends Component { | ||
state = { | ||
value: '' | ||
}; | ||
|
||
render() { | ||
return ( | ||
<EuiCodeEditor | ||
mode={new MyCustomAceMode()} | ||
theme="github" | ||
width="100%" | ||
value={this.state.value} | ||
setOptions={{ fontSize: '14px' }} | ||
/> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters