2025-03-20 07:15:37 +00:00
|
|
|
"use client";
|
|
|
|
|
2025-06-13 06:03:17 +00:00
|
|
|
import { useEffect } from "react";
|
|
|
|
import { CoreEditor } from "@/components/core-editor";
|
|
|
|
import { useProblemEditorStore } from "@/stores/problem-editor";
|
|
|
|
import type { LanguageServerConfig, Template } from "@/generated/client";
|
|
|
|
|
|
|
|
interface ProblemEditorProps {
|
|
|
|
problemId: string;
|
|
|
|
templates: Template[];
|
|
|
|
languageServerConfigs?: LanguageServerConfig[];
|
|
|
|
}
|
2025-03-20 07:15:37 +00:00
|
|
|
|
2025-06-13 06:03:17 +00:00
|
|
|
export const ProblemEditor = ({
|
|
|
|
problemId,
|
|
|
|
templates,
|
|
|
|
languageServerConfigs,
|
|
|
|
}: ProblemEditorProps) => {
|
2025-03-23 10:50:07 +00:00
|
|
|
const {
|
2025-06-13 06:03:17 +00:00
|
|
|
language,
|
|
|
|
value,
|
|
|
|
path,
|
|
|
|
setProblem,
|
|
|
|
setValue,
|
2025-03-23 10:50:07 +00:00
|
|
|
setEditor,
|
2025-06-13 06:03:17 +00:00
|
|
|
setLspWebSocket,
|
2025-03-25 05:08:29 +00:00
|
|
|
setMarkers,
|
2025-06-13 06:03:17 +00:00
|
|
|
} = useProblemEditorStore();
|
2025-03-23 10:50:07 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
2025-06-13 06:03:17 +00:00
|
|
|
setProblem(problemId, templates);
|
|
|
|
}, [problemId, setProblem, templates]);
|
2025-03-20 07:15:37 +00:00
|
|
|
|
|
|
|
return (
|
2025-06-13 06:03:17 +00:00
|
|
|
<CoreEditor
|
|
|
|
language={language}
|
|
|
|
value={value}
|
|
|
|
path={path}
|
|
|
|
languageServerConfigs={languageServerConfigs}
|
|
|
|
onEditorReady={setEditor}
|
|
|
|
onLspWebSocketReady={setLspWebSocket}
|
|
|
|
onMarkersReady={setMarkers}
|
|
|
|
onChange={setValue}
|
2025-03-20 07:15:37 +00:00
|
|
|
/>
|
|
|
|
);
|
2025-06-13 06:03:17 +00:00
|
|
|
};
|