mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 09:29:04 +08:00
feat: monaco editor is updated (#851)
This commit is contained in:
parent
4337ab5cd0
commit
a238123eb2
@ -22,6 +22,7 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons": "^4.6.2",
|
"@ant-design/icons": "^4.6.2",
|
||||||
|
"@monaco-editor/react": "^4.3.1",
|
||||||
"@grafana/data": "^8.4.3",
|
"@grafana/data": "^8.4.3",
|
||||||
"@testing-library/jest-dom": "^5.11.4",
|
"@testing-library/jest-dom": "^5.11.4",
|
||||||
"@testing-library/react": "^11.1.0",
|
"@testing-library/react": "^11.1.0",
|
||||||
@ -52,7 +53,6 @@
|
|||||||
"less": "^4.1.2",
|
"less": "^4.1.2",
|
||||||
"less-loader": "^10.2.0",
|
"less-loader": "^10.2.0",
|
||||||
"mini-css-extract-plugin": "2.4.5",
|
"mini-css-extract-plugin": "2.4.5",
|
||||||
"monaco-editor": "^0.30.0",
|
|
||||||
"react": "17.0.0",
|
"react": "17.0.0",
|
||||||
"react-dom": "17.0.0",
|
"react-dom": "17.0.0",
|
||||||
"react-force-graph": "^1.41.0",
|
"react-force-graph": "^1.41.0",
|
||||||
|
@ -1,41 +1,16 @@
|
|||||||
import * as monaco from 'monaco-editor';
|
import MEditor from '@monaco-editor/react';
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { Container } from './styles';
|
|
||||||
|
|
||||||
const Editor = ({ value }: EditorProps): JSX.Element => {
|
const Editor = ({ value }: EditorProps): JSX.Element => {
|
||||||
const divEl = useRef<HTMLDivElement>(null);
|
return (
|
||||||
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor>();
|
<MEditor
|
||||||
|
theme="vs-dark"
|
||||||
useEffect(() => {
|
defaultLanguage="yaml"
|
||||||
let editor = editorRef.current;
|
value={value.current}
|
||||||
|
options={{ fontSize: 16, automaticLayout: true }}
|
||||||
if (divEl.current) {
|
height={'40vh'}
|
||||||
editor = monaco.editor.create(divEl.current, {
|
/>
|
||||||
value: value.current || '',
|
);
|
||||||
useShadowDOM: true,
|
|
||||||
theme: 'vs-dark',
|
|
||||||
automaticLayout: true,
|
|
||||||
fontSize: 16,
|
|
||||||
minimap: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
language: 'yaml',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
editor?.getModel()?.onDidChangeContent(() => {
|
|
||||||
value.current = editor?.getValue() || '';
|
|
||||||
});
|
|
||||||
|
|
||||||
return (): void => {
|
|
||||||
if (editor) {
|
|
||||||
editor.dispose();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, [value]);
|
|
||||||
|
|
||||||
return <Container ref={divEl} />;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
interface EditorProps {
|
interface EditorProps {
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
export const Container = styled.div`
|
|
||||||
&&& {
|
|
||||||
min-height: 40vh;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
`;
|
|
3755
frontend/yarn.lock
3755
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user