PromucFlow_constructor/app/client/src/components/propertyControls/CodeEditorControl.tsx

53 lines
1.4 KiB
TypeScript
Raw Normal View History

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-01-02 13:36:35 +00:00
import { EventOrValueHandler } from "redux-form";
import {
EditorModes,
EditorSize,
TabBehaviour,
} from "components/editorComponents/CodeEditor/EditorConfig";
fix: Improve CodeMirror rendering performance using idleCallback (#13676) * working editor wrapper * updated other property controls * fix tablefilter_spec unit test * autofocus on editor * update font styles * show lint errors * add syntax highlighting * fix import issue * fix input height * use lazy and suspense * wip * update code clean up * update input style * fix select widget issue * fix build issue * fix import issue and linting css * update lint error method * add polyfill for idle callback * fix undo aggregate helper changes * rename CodeEditor component * fix tests add delay before code mirror * undo name change * rename lazy editor * add comments and update aggregate helper * fix cypress helper * fix testJsonText command * update aggregate helper * add wait to allow time to load * fix filepicker issue * fix currency input test * fix unit tests * update aggregate helper * fix table property tests * fix test * fix command * update json text command * updated command ii * update iii * update iv * add force click * check for wrapper * fix for objects * fix test iv * fix test v * fix tests vi * fix tests vi * fix variable naming issue * fix tests vii * remove wait from wrapper click * fix tests viii * fix recheck wrapper availability * fix updateCodeInput command * fix undo while loop * fix ix * fix each loop * removed EnableAllCodeEditors * updated tests * Upated wait * updated some more tests * updated wait time * updated common method * updated all related common methods * update state name and add callback timeout * updated test * updated the test * fix use while loop and update count * update click func * fix use get instead of find * fix on click action command * remove comments * fix: update import statements * add force click to widget command * update wrapper ui * fix auto load code editor * update editor wrapper ui * fix lineheight adjustment * refactor editor wrapper * update style import * fix ascetic style import * fix font style * fix wrapper height * update color for code block * fix min height of content wrapper * remove error linting and editor wrapper * remove unused variable * remove unused imports * fix font color for objects * update styles for placeholders * remove console log * remove react syntax highlighter * cancel idlecallback on unmount * Delay input foucs Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: apple <nandan@thinkify.io> Co-authored-by: Satish Gandham <satish@appsmith.com>
2022-07-20 09:26:12 +00:00
import CodeEditor from "components/editorComponents/LazyCodeEditorWrapper";
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,
expected,
propertyValue,
useValidationMessage,
2020-06-04 13:49:22 +00:00
} = this.props;
const props: Partial<ControlProps> = {};
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 (
<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}
/>
2019-11-05 05:09:50 +00:00
);
}
2020-01-02 13:36:35 +00:00
onChange: EventOrValueHandler<ChangeEvent<any>> = (
value: string | ChangeEvent,
) => {
this.updateProperty(this.props.propertyName, value, true);
2019-11-05 05:09:50 +00:00
};
static getControlType() {
2019-11-05 05:09:50 +00:00
return "CODE_EDITOR";
}
}
export default CodeEditorControl;