-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EuiCodeEditor: make it take a custom mode #935
EuiCodeEditor: make it take a custom mode #935
Conversation
/** | ||
* Use string for a built-in mode or object for a custom mode | ||
*/ | ||
mode: PropTypes.oneOfType([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When passing mode
as an object, react-ace's own proptype fails: Failed prop type: Invalid prop mode
of type object
supplied to ReactAce
, expected string
. The code editor's render function should be updated to pass mode
as undefined
if it is custom.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8b6523e.
this.aceEditor.editor.getSession().setMode(this.props.mode); | ||
} | ||
|
||
componentDidMount() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also add componentDidUpdate
and compare old props.mode with new props.mode, updating the session if the old & new modes differ and if the new mode is a custom object (switching to a string is handled internally by react-ace).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 1b1b3db.
Otherwise, AceEditor will complain about wanting a string mode prop.
@chandlerprall Thanks for catching those issues. I've fixed both of them now and this PR is ready for your 👀 again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; pulled branch & debugged the existing and new code editor examples to ensure values & program flow were as expected.
Thanks @ycombinator for the change! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha, real quick could you modify the CHANGELOG.md to include this feature add?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still LGTM, changelog was part of the original PR... I was blind
Resolves #933.
Allows the
mode
prop in theEuiCodeEditor
component to take anobject
representing a custom Ace mode.To test this PR
Run this PR along with EUIFication: Grok Debugger kibana#20027.
In Kibana, open Dev Tools > Grok Debugger
In the Grok Pattern field (which uses a custom mode), enter:
Verify that the syntax highlighting changes once you finish typing.