2022-03-16 23:24:27 +05:30
|
|
|
import MEditor from '@monaco-editor/react';
|
|
|
|
|
import React from 'react';
|
2021-11-22 11:49:09 +05:30
|
|
|
|
2022-04-25 22:41:46 +05:30
|
|
|
function Editor({
|
|
|
|
|
value,
|
|
|
|
|
language = 'yaml',
|
|
|
|
|
onChange,
|
2022-04-27 22:21:57 +05:30
|
|
|
readOnly = false,
|
2022-04-25 22:41:46 +05:30
|
|
|
}: EditorProps): JSX.Element {
|
2022-03-16 23:24:27 +05:30
|
|
|
return (
|
|
|
|
|
<MEditor
|
|
|
|
|
theme="vs-dark"
|
2022-04-25 22:41:46 +05:30
|
|
|
language={language}
|
|
|
|
|
value={value}
|
2022-04-27 22:21:57 +05:30
|
|
|
options={{ fontSize: 16, automaticLayout: true, readOnly }}
|
2022-03-22 12:10:31 +05:30
|
|
|
height="40vh"
|
2022-03-23 19:03:05 +05:30
|
|
|
onChange={(newValue): void => {
|
2022-04-25 22:41:46 +05:30
|
|
|
if (newValue) {
|
|
|
|
|
onChange(newValue);
|
2022-03-23 19:03:05 +05:30
|
|
|
}
|
|
|
|
|
}}
|
2022-03-16 23:24:27 +05:30
|
|
|
/>
|
|
|
|
|
);
|
2022-03-22 12:10:31 +05:30
|
|
|
}
|
2021-11-22 11:49:09 +05:30
|
|
|
|
|
|
|
|
interface EditorProps {
|
2022-04-25 22:41:46 +05:30
|
|
|
value: string;
|
|
|
|
|
language?: string;
|
|
|
|
|
onChange: (value: string) => void;
|
2022-04-27 22:21:57 +05:30
|
|
|
readOnly?: boolean;
|
2021-11-22 11:49:09 +05:30
|
|
|
}
|
|
|
|
|
|
2022-04-22 20:03:08 +05:30
|
|
|
Editor.defaultProps = {
|
2022-04-25 22:41:46 +05:30
|
|
|
language: undefined,
|
2022-04-27 22:21:57 +05:30
|
|
|
readOnly: false,
|
2022-04-22 20:03:08 +05:30
|
|
|
};
|
|
|
|
|
|
2021-11-22 11:49:09 +05:30
|
|
|
export default Editor;
|