mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 15:02:28 +08:00
Panel Inspect: use monaco for json display (#25251)
This commit is contained in:
29
packages/grafana-ui/src/components/Monaco/CodeEditorLazy.tsx
Normal file
29
packages/grafana-ui/src/components/Monaco/CodeEditorLazy.tsx
Normal file
@ -0,0 +1,29 @@
|
||||
import React from 'react';
|
||||
import { useAsyncDependency } from '../../utils/useAsyncDependency';
|
||||
import { ErrorWithStack, LoadingPlaceholder } from '..';
|
||||
import { CodeEditorProps } from './CodeEditor';
|
||||
|
||||
export type CodeEditorChangeHandler = (value: string) => void;
|
||||
|
||||
export const CodeEditor: React.FC<CodeEditorProps> = props => {
|
||||
const { loading, error, dependency } = useAsyncDependency(
|
||||
import(/* webpackChunkName: "code-editor" */ './CodeEditor')
|
||||
);
|
||||
|
||||
if (loading) {
|
||||
return <LoadingPlaceholder text={'Loading...'} />;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<ErrorWithStack
|
||||
title="Code editor failed to load"
|
||||
error={error}
|
||||
errorInfo={{ componentStack: error?.stack || '' }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const CodeEditor = dependency.default;
|
||||
return <CodeEditor {...props} />;
|
||||
};
|
Reference in New Issue
Block a user