2020-01-02 13:36:35 +00:00
|
|
|
import React, { ChangeEvent } from "react";
|
2019-11-05 05:09:50 +00:00
|
|
|
import BaseControl, { ControlProps } from "./BaseControl";
|
2020-07-01 10:01:07 +00:00
|
|
|
import CodeEditor from "components/editorComponents/CodeEditor";
|
2020-01-02 13:36:35 +00:00
|
|
|
import { EventOrValueHandler } from "redux-form";
|
2020-07-01 10:01:07 +00:00
|
|
|
import {
|
|
|
|
|
EditorModes,
|
|
|
|
|
EditorSize,
|
|
|
|
|
TabBehaviour,
|
|
|
|
|
} from "components/editorComponents/CodeEditor/EditorConfig";
|
|
|
|
|
|
2019-11-05 05:09:50 +00:00
|
|
|
class CodeEditorControl extends BaseControl<ControlProps> {
|
|
|
|
|
render() {
|
2020-06-04 13:49:22 +00:00
|
|
|
const {
|
|
|
|
|
dataTreePath,
|
2020-06-10 12:16:50 +00:00
|
|
|
evaluatedValue,
|
2021-05-13 08:35:39 +00:00
|
|
|
expected,
|
|
|
|
|
propertyValue,
|
2021-03-24 12:12:24 +00:00
|
|
|
useValidationMessage,
|
2020-06-04 13:49:22 +00:00
|
|
|
} = this.props;
|
2021-05-26 12:32:43 +00:00
|
|
|
|
2020-07-07 08:49:22 +00:00
|
|
|
const props: Partial<ControlProps> = {};
|
2021-05-26 12:32:43 +00:00
|
|
|
|
2020-07-07 08:49:22 +00:00
|
|
|
if (dataTreePath) props.dataTreePath = dataTreePath;
|
|
|
|
|
if (evaluatedValue) props.evaluatedValue = evaluatedValue;
|
|
|
|
|
if (expected) props.expected = expected;
|
2020-06-10 12:16:50 +00:00
|
|
|
|
2019-11-05 05:09:50 +00:00
|
|
|
return (
|
2020-07-01 10:01:07 +00:00
|
|
|
<CodeEditor
|
2021-05-26 12:32:43 +00:00
|
|
|
additionalDynamicData={this.props.additionalAutoComplete}
|
2020-02-26 12:44:56 +00:00
|
|
|
input={{ value: propertyValue, onChange: this.onChange }}
|
2020-07-01 10:01:07 +00:00
|
|
|
mode={EditorModes.TEXT_WITH_BINDING}
|
2021-04-28 10:28:39 +00:00
|
|
|
size={EditorSize.EXTENDED}
|
2020-07-01 10:01:07 +00:00
|
|
|
tabBehaviour={TabBehaviour.INDENT}
|
2021-04-28 10:28:39 +00:00
|
|
|
theme={this.props.theme}
|
|
|
|
|
useValidationMessage={useValidationMessage}
|
2020-07-07 08:49:22 +00:00
|
|
|
{...props}
|
2020-02-26 12:44:56 +00:00
|
|
|
/>
|
2019-11-05 05:09:50 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-02 13:36:35 +00:00
|
|
|
onChange: EventOrValueHandler<ChangeEvent<any>> = (
|
|
|
|
|
value: string | ChangeEvent,
|
|
|
|
|
) => {
|
2019-11-05 05:09:50 +00:00
|
|
|
this.updateProperty(this.props.propertyName, value);
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-14 05:35:16 +00:00
|
|
|
static getControlType() {
|
2019-11-05 05:09:50 +00:00
|
|
|
return "CODE_EDITOR";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default CodeEditorControl;
|