-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: attempt to fix eslint import recognition * fix: fix lint issues * feat: restructure code editor component * feat: restructure CodeEditor component * feat: use type safe connector for CodeEditor
- Loading branch information
Showing
19 changed files
with
237 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
web/src/components/features/workspace/CodeEditor/autocomplete/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as monaco from 'monaco-editor' | ||
import type { IAPIClient } from '~/services/api' | ||
|
||
import { GoCompletionItemProvider } from './provider' | ||
|
||
let alreadyRegistered = false | ||
export const registerGoLanguageProvider = (client: IAPIClient) => { | ||
if (alreadyRegistered) { | ||
console.warn('Go Language provider was already registered') | ||
return | ||
} | ||
|
||
alreadyRegistered = true | ||
return monaco.languages.registerCompletionItemProvider('go', new GoCompletionItemProvider(client)) | ||
} |
24 changes: 24 additions & 0 deletions
24
web/src/components/features/workspace/CodeEditor/autocomplete/parse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Matches package (and method name) | ||
const COMPL_REGEXP = /([a-zA-Z0-9_]+)(\.([A-Za-z0-9_]+))?$/ | ||
const R_GROUP_PKG = 1 | ||
const R_GROUP_METHOD = 3 | ||
|
||
export const parseExpression = (expr: string) => { | ||
COMPL_REGEXP.lastIndex = 0 // Reset regex state | ||
const m = COMPL_REGEXP.exec(expr) | ||
if (!m) { | ||
return null | ||
} | ||
|
||
const varName = m[R_GROUP_PKG] | ||
const propValue = m[R_GROUP_METHOD] | ||
|
||
if (!propValue) { | ||
return { value: varName } | ||
} | ||
|
||
return { | ||
packageName: varName, | ||
value: propValue, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
web/src/components/features/workspace/CodeEditor/loader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { loader } from '@monaco-editor/react' | ||
import * as monaco from 'monaco-editor' | ||
|
||
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' | ||
|
||
let loaderConfigured = false | ||
export const configureMonacoLoader = () => { | ||
if (loaderConfigured) { | ||
return | ||
} | ||
|
||
loader.config({ monaco }) | ||
loaderConfigured = true | ||
} | ||
|
||
self.MonacoEnvironment = { | ||
getWorker: () => { | ||
return new EditorWorker() | ||
}, | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.