Skip to content

Commit ba64cb7

Browse files
authored
CodeMirror Migration - Part 3 (#552)
* feat: support markdown in hover doc * feat: render markdown in completion items * feat: add plugin theme * fix: pass theme to autocomp ext * feat: provide styles for autocomplete * feat: reload completion config * feat: add dark mode theme * fix: tooltip styles * feat: reskin completion and hover to mimic vscode * feat: move autocompletion style to CSS module * feat: lazy-load editor * fix: workspace file * fix: tests
1 parent f8a5300 commit ba64cb7

File tree

19 files changed

+842
-157
lines changed

19 files changed

+842
-157
lines changed

web/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@eslint/js": "^9.0.0",
2020
"@fluentui/react": "^8.122.8",
2121
"@fluentui/react-icons": "^2.0.271",
22+
"@lezer/highlight": "^1.2.3",
2223
"@monaco-editor/loader": "^1.4.0",
2324
"@monaco-editor/react": "^4.6.0",
2425
"@replit/codemirror-emacs": "^6.1.0",
@@ -67,6 +68,7 @@
6768
"file-saver": "^2.0.5",
6869
"globals": "^15.0.0",
6970
"jsdom": "^25.0.1",
71+
"markdown-it": "^14.1.1",
7072
"monaco-editor": "^0.45.0",
7173
"monaco-vim": "^0.3.4",
7274
"prettier": "^3.2.4",
@@ -121,5 +123,8 @@
121123
"last 1 firefox version",
122124
"last 1 safari version"
123125
]
126+
},
127+
"devDependencies": {
128+
"@types/markdown-it": "^14"
124129
}
125130
}

web/src/components/features/workspace/CMCodeEditor/CodeEditorContainer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,5 @@ export const CodeEditorContainer: React.FC = () => {
191191
/>
192192
)
193193
}
194+
195+
export default CodeEditorContainer
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react'
2+
3+
import { Spinner, SpinnerSize } from '@fluentui/react'
4+
import { FlexContainer } from '../FlexContainer'
5+
6+
const styles = {
7+
flex: '1 1 0%',
8+
overflow: 'hidden',
9+
display: 'flex',
10+
'align-items': 'center',
11+
'justify-content': 'center',
12+
}
13+
14+
const CodeEditorContainer = React.lazy(() => import('./CodeEditorContainer'))
15+
16+
const CodeEditorPreloader: React.FC = () => (
17+
<div style={styles}>
18+
<Spinner key="spinner" label="Loading editor..." size={SpinnerSize.large} labelPosition="bottom" />
19+
</div>
20+
)
21+
22+
/**
23+
* Lazy-loading wrapper for code editor container
24+
*/
25+
export const LazyCodeEditorContainer: React.FC = () => {
26+
return (
27+
<React.Suspense fallback={<CodeEditorPreloader />}>
28+
<CodeEditorContainer />
29+
</React.Suspense>
30+
)
31+
}

web/src/components/features/workspace/Workspace/LazyLoadedWorkspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { lazy } from 'react'
22
import { SuspenseBoundary } from '~/components/elements/misc/SuspenseBoundary'
33

4-
const LazyWorkspace = lazy(async () => await import('./Workspace.tsx'))
4+
const LazyWorkspace = lazy(async () => await import('./Workspace'))
55

66
export const LazyLoadedWorkspace: React.FC = () => (
77
<SuspenseBoundary errorLabel="Failed to load workspace" preloaderText="Loading workspace...">

web/src/components/features/workspace/Workspace/Workspace.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { dispatchCreateFile, dispatchRemoveFile, dispatchImportFile, newFileSele
77
import { TabView } from '~/components/elements/tabs/TabView'
88
import type { TabBarAction, TabIconStyles } from '~/components/elements/tabs/types'
99

10-
import { CodeEditorContainer } from '../CMCodeEditor/CodeEditorContainer'
11-
import { FlexContainer } from '../FlexContainer'
10+
import { LazyCodeEditorContainer } from '../CMCodeEditor/LazyCodeEditorContainer'
1211
import { NewFileModal } from '../NewFileModal'
1312
import { ContentPlaceholder } from '../ContentPlaceholder'
1413
import { newEmptyFileContent } from './utils'
@@ -109,7 +108,7 @@ const Workspace: React.FC = () => {
109108
disabled={(snippet?.loading ?? false) || !!snippet?.error}
110109
>
111110
{tabs?.length ? (
112-
<CodeEditorContainer />
111+
<LazyCodeEditorContainer />
113112
) : (
114113
<ContentPlaceholder
115114
isLoading={snippet?.loading}

web/src/components/layout/Header/Header.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ class HeaderContainer extends ThemeableComponent<Props, HeaderState> {
201201
private onSettingsClose(changes: SettingsChanges) {
202202
if (changes.monaco) {
203203
// Update monaco state if some of its settings were changed
204-
console.log(changes.monaco)
205204
this.props.dispatch(newMonacoParamsChangeDispatcher(changes.monaco))
206205
}
207206

web/src/components/pages/PlaygroundPage/PlaygroundPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import styles from './PlaygroundPage.module.css'
1010
import { SuspenseBoundary } from '~/components/elements/misc/SuspenseBoundary'
1111
import { LazyAnnouncementBanner } from '~/components/layout/AnnouncementBanner'
1212

13-
const LazyPlaygroundContent = lazy(async () => await import('./PlaygroundContainer.tsx'))
13+
const LazyPlaygroundContent = lazy(async () => await import('./PlaygroundContainer'))
1414

1515
interface PageParams {
1616
snippetID: string

0 commit comments

Comments
 (0)