PromucFlow_constructor/app/client/src/components/propertyControls/CodeEditorControl.tsx
Apeksha Bhosale 4825ce2a2a
Show JS eval errors in evaluated value pane and debugger (#4463)
Co-authored-by: jsartisan <pawankumar2901@gmail.com>
Co-authored-by: hetunandu <hetu@appsmith.com>
2021-05-26 18:02:43 +05:30

53 lines
1.4 KiB
TypeScript

import React, { ChangeEvent } from "react";
import BaseControl, { ControlProps } from "./BaseControl";
import CodeEditor from "components/editorComponents/CodeEditor";
import { EventOrValueHandler } from "redux-form";
import {
EditorModes,
EditorSize,
TabBehaviour,
} from "components/editorComponents/CodeEditor/EditorConfig";
class CodeEditorControl extends BaseControl<ControlProps> {
render() {
const {
dataTreePath,
evaluatedValue,
expected,
propertyValue,
useValidationMessage,
} = this.props;
const props: Partial<ControlProps> = {};
if (dataTreePath) props.dataTreePath = dataTreePath;
if (evaluatedValue) props.evaluatedValue = evaluatedValue;
if (expected) props.expected = expected;
return (
<CodeEditor
additionalDynamicData={this.props.additionalAutoComplete}
input={{ value: propertyValue, onChange: this.onChange }}
mode={EditorModes.TEXT_WITH_BINDING}
size={EditorSize.EXTENDED}
tabBehaviour={TabBehaviour.INDENT}
theme={this.props.theme}
useValidationMessage={useValidationMessage}
{...props}
/>
);
}
onChange: EventOrValueHandler<ChangeEvent<any>> = (
value: string | ChangeEvent,
) => {
this.updateProperty(this.props.propertyName, value);
};
static getControlType() {
return "CODE_EDITOR";
}
}
export default CodeEditorControl;