Skip to content

Commit cc8bfb5

Browse files
author
k.golikov
committed
Add loading for monaco editors
1 parent e159973 commit cc8bfb5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/pages/DiffEditorPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import PageContainer from '../components/pageContainer/PageContainer';
33
import { DiffEditor } from '@monaco-editor/react';
44
import useAppTheme from '../hooks/useAppTheme';
55
import { editor } from 'monaco-editor';
6+
import { Spin } from 'antd';
7+
8+
const loadingNode = <Spin size="large" />;
69

710
const options: editor.IDiffEditorConstructionOptions = {
811
originalEditable: true
@@ -13,7 +16,7 @@ const DiffEditorPage = () => {
1316

1417
return (
1518
<PageContainer title="Diff Editor">
16-
<DiffEditor theme={isDarkMode ? 'vs-dark' : 'light'} options={options} />
19+
<DiffEditor theme={isDarkMode ? 'vs-dark' : 'light'} options={options} loading={loadingNode} />
1720
</PageContainer>
1821
);
1922
};

src/pages/codeFormatterPage/CodeFormatterPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { FunctionComponent, useCallback, useRef, useState } from 'react';
22
import PageContainer from '../../components/pageContainer/PageContainer';
33
import useAppTheme from '../../hooks/useAppTheme';
44
import Editor, { OnMount } from '@monaco-editor/react';
5-
import { Button, Col, Row, Select } from 'antd';
5+
import { Button, Col, Row, Select, Spin } from 'antd';
66
import styles from './CodeFormatterPage.module.scss';
77
import classNames from 'classnames';
88
import MonacoLanguage, { monacoLanguages } from '../../types/MonacoLanguage';
@@ -45,6 +45,8 @@ import formatCode from '../../utils/formatCode';
4545
//
4646
// window.prettier = prettier;
4747

48+
const loadingNode = <Spin size="large" />;
49+
4850
const monacoOptions: editor.IStandaloneEditorConstructionOptions = {
4951
formatOnPaste: true
5052
};
@@ -114,6 +116,7 @@ const CodeFormatterPage: FunctionComponent = () => {
114116
onChange={handleCodeChange}
115117
options={monacoOptions}
116118
onMount={handleMonacoMount}
119+
loading={loadingNode}
117120
/>
118121
</div>
119122
</PageContainer>

0 commit comments

Comments
 (0)