mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-22 01:46:39 +00:00
* feat: v5 is in progress * feat: antdv5 is updated * fix: build is fixed * fix: default config is over written by custom one * chore: onchange handler is updated * chore: overflow is hidden in the layout * Update index.tsx * fix: import is fixed * chore: un used import is fixed * fix: dark mode is updated in service map * fix: config dropdown is updated * fix: logs types is updated * fix: copy clipboard notification is updated * chore: layout changes are updated * chore: colors is updated * chore: action width is updated Co-authored-by: Pranay Prateek <pranay@signoz.io> Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
45 lines
893 B
TypeScript
45 lines
893 B
TypeScript
import MEditor, { EditorProps } from '@monaco-editor/react';
|
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
|
import React from 'react';
|
|
|
|
function Editor({
|
|
value,
|
|
language,
|
|
onChange,
|
|
readOnly,
|
|
height,
|
|
options,
|
|
}: MEditorProps): JSX.Element {
|
|
const isDarkMode = useIsDarkMode();
|
|
return (
|
|
<MEditor
|
|
theme={isDarkMode ? 'vs-dark' : 'vs-light'}
|
|
language={language}
|
|
value={value}
|
|
options={{ fontSize: 16, automaticLayout: true, readOnly, ...options }}
|
|
height={height}
|
|
onChange={(newValue): void => {
|
|
if (typeof newValue === 'string') onChange(newValue);
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
interface MEditorProps {
|
|
value: string;
|
|
language?: string;
|
|
onChange: (value: string) => void;
|
|
readOnly?: boolean;
|
|
height?: string;
|
|
options?: EditorProps['options'];
|
|
}
|
|
|
|
Editor.defaultProps = {
|
|
language: 'yaml',
|
|
readOnly: false,
|
|
height: '40vh',
|
|
options: {},
|
|
};
|
|
|
|
export default Editor;
|