UNPKG

@limetech/lime-elements

Version:
43 lines (42 loc) 970 B
import React from 'react'; export class CodeEditor extends React.Component { constructor(props) { super(props); this.props = props; this.handleChange = this.handleChange.bind(this); } render() { const props = this.props; let value = '{}'; try { value = JSON.stringify(props.formData, null, ' '); } catch (_a) { // N/A } return React.createElement('limel-code-editor', { value: value, language: 'json', lineNumbers: true, fold: true, lint: true, onChange: this.handleChange, }); } handleChange(event) { const props = this.props; event.stopPropagation(); if (!props.onChange) { return; } try { const value = JSON.parse(event.nativeEvent.detail); props.onChange(value); props.onValidate(); } catch (_a) { props.onValidate('Should be a valid JSON document'); } } } //# sourceMappingURL=code-editor.js.map