Skip to content

Commit 606b609

Browse files
authoredFeb 17, 2024
Merge pull request #4320 from cpinitiative/flicker_fix
fix flicker
2 parents 0017e45 + 490920b commit 606b609

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed
 

‎src/components/Editor/BaseEditor.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import MonacoEditor from '@monaco-editor/react';
2+
import React from 'react';
3+
export default function BaseEditor(props) {
4+
// prevents light/dark mode flicker
5+
const darkMode = document.documentElement.classList.contains('dark');
6+
return <MonacoEditor {...props} theme={darkMode ? 'vs-dark' : 'light'} />;
7+
}

‎src/components/Editor/EditorPage.tsx

-8
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ export default function EditorPage(props: PageProps): JSX.Element {
9393
<EditorTopNav />
9494

9595
{typeof window !== 'undefined' && (
96-
// <React.Suspense
97-
// fallback={
98-
// <div className="text-center mt-6 font-bold text-2xl">
99-
// Loading
100-
// </div>
101-
// }
102-
// >
10396
<StyledSplit
10497
className="h-full relative flex-1 overflow-hidden"
10598
onDrag={() => {
@@ -123,7 +116,6 @@ export default function EditorPage(props: PageProps): JSX.Element {
123116
</div>
124117
</div>
125118
</StyledSplit>
126-
// </React.Suspense>
127119
)}
128120
</div>
129121
</Layout>

‎src/components/Editor/MainEditorInterface.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import {
1818
import { DarkModeContext } from '../../context/DarkModeContext';
1919
import EditorTabBar from './EditorTabBar';
2020
import { conf as mdxConf, language as mdxLang } from './mdx-lang';
21-
22-
const Editor = React.lazy(() => import('@monaco-editor/react'));
21+
const Editor = React.lazy(() => import('./BaseEditor'));
2322

2423
export const MainEditorInterface = ({ className }): JSX.Element => {
2524
const activeFile = useAtomValue(activeFileAtom);

0 commit comments

Comments
 (0)