mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 15:26:33 +00:00
feat(code-editor): add editor state handling to CodeEditor component
This commit is contained in:
parent
5cabdda667
commit
c0d0021b6c
@ -33,7 +33,7 @@ const Editor = dynamic(
|
|||||||
export default function CodeEditor() {
|
export default function CodeEditor() {
|
||||||
const { resolvedTheme } = useTheme();
|
const { resolvedTheme } = useTheme();
|
||||||
const { fontSize, lineHeight } = useCodeEditorOption();
|
const { fontSize, lineHeight } = useCodeEditorOption();
|
||||||
const { language, languageClient, setLanguageClient } = useCodeEditorState();
|
const { language, languageClient, setEditor, setLanguageClient } = useCodeEditorState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (languageClient) {
|
if (languageClient) {
|
||||||
@ -44,7 +44,9 @@ export default function CodeEditor() {
|
|||||||
const serverConfig = SUPPORTED_LANGUAGE_SERVERS.find((s) => s.id === language);
|
const serverConfig = SUPPORTED_LANGUAGE_SERVERS.find((s) => s.id === language);
|
||||||
|
|
||||||
if (serverConfig) {
|
if (serverConfig) {
|
||||||
const lspUrl = `${serverConfig.protocol}://${serverConfig.hostname}${serverConfig.port ? `:${serverConfig.port}` : ''}${serverConfig.path || ''}`
|
const lspUrl = `${serverConfig.protocol}://${serverConfig.hostname}${
|
||||||
|
serverConfig.port ? `:${serverConfig.port}` : ""
|
||||||
|
}${serverConfig.path || ""}`;
|
||||||
const url = normalizeUrl(lspUrl);
|
const url = normalizeUrl(lspUrl);
|
||||||
const webSocket = new WebSocket(url);
|
const webSocket = new WebSocket(url);
|
||||||
|
|
||||||
@ -107,6 +109,9 @@ export default function CodeEditor() {
|
|||||||
beforeMount={(monaco) => {
|
beforeMount={(monaco) => {
|
||||||
shikiToMonaco(highlighter, monaco);
|
shikiToMonaco(highlighter, monaco);
|
||||||
}}
|
}}
|
||||||
|
onMount={(editor, monaco) => {
|
||||||
|
setEditor(editor);
|
||||||
|
}}
|
||||||
// onValidate={(markers) => {
|
// onValidate={(markers) => {
|
||||||
// markers.forEach((marker) => {
|
// markers.forEach((marker) => {
|
||||||
// console.log(marker.severity);
|
// console.log(marker.severity);
|
||||||
|
Loading…
Reference in New Issue
Block a user