feat(editor): update loading state with padding and refactor dynamic import

This commit is contained in:
cfngc4594 2025-03-04 21:26:51 +08:00
parent 0c1ecbcff2
commit d89a45daa8

View File

@ -11,6 +11,7 @@ import { connectToLanguageServer } from "@/lib/language-server";
import { LanguageServerMetadata } from "@/types/language-server"; import { LanguageServerMetadata } from "@/types/language-server";
import type { MonacoLanguageClient } from "monaco-languageclient"; import type { MonacoLanguageClient } from "monaco-languageclient";
// Dynamically import Monaco Editor with SSR disabled
const Editor = dynamic( const Editor = dynamic(
async () => { async () => {
await import("vscode"); await import("vscode");
@ -21,7 +22,11 @@ const Editor = dynamic(
}, },
{ {
ssr: false, ssr: false,
loading: () => <Skeleton className="h-full w-full rounded-3xl" /> loading: () => (
<div className="h-full w-full p-2">
<Skeleton className="h-full w-full rounded-3xl" />
</div>
),
} }
); );
@ -112,7 +117,11 @@ export default function CoreEditorLsp({
beforeMount={handleEditorWillMount} beforeMount={handleEditorWillMount}
onMount={handleEditorDidMount} onMount={handleEditorDidMount}
options={editorConfig} options={editorConfig}
loading={<Skeleton className="h-full w-full rounded-3xl" />} loading={
<div className="h-full w-full p-2">
<Skeleton className="h-full w-full rounded-3xl" />
</div>
}
/> />
); );
} }