From 11c562eb98f7ae81f50fdb76f9bdaacf91f7f7c2 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Wed, 21 Jan 2026 10:46:43 +0800 Subject: [PATCH] refactor: move --- .../workspace/artifacts/artifact-file-detail.tsx | 2 +- .../components/{ai-elements => workspace}/code-editor.tsx | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) rename frontend/src/components/{ai-elements => workspace}/code-editor.tsx (90%) diff --git a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx index 38ddab7..ae98c87 100644 --- a/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx +++ b/frontend/src/components/workspace/artifacts/artifact-file-detail.tsx @@ -16,7 +16,6 @@ import { ArtifactHeader, ArtifactTitle, } from "@/components/ai-elements/artifact"; -import { CodeEditor } from "@/components/ai-elements/code-editor"; import { Select, SelectItem } from "@/components/ui/select"; import { SelectContent, @@ -25,6 +24,7 @@ import { SelectValue, } from "@/components/ui/select"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; +import { CodeEditor } from "@/components/workspace/code-editor"; import { useArtifactContent } from "@/core/artifacts/hooks"; import { urlOfArtifact } from "@/core/artifacts/utils"; import { useI18n } from "@/core/i18n/hooks"; diff --git a/frontend/src/components/ai-elements/code-editor.tsx b/frontend/src/components/workspace/code-editor.tsx similarity index 90% rename from frontend/src/components/ai-elements/code-editor.tsx rename to frontend/src/components/workspace/code-editor.tsx index 21707bd..345dcfc 100644 --- a/frontend/src/components/ai-elements/code-editor.tsx +++ b/frontend/src/components/workspace/code-editor.tsx @@ -48,10 +48,7 @@ export function CodeEditor({ autoFocus?: boolean; settings?: any; }) { - const { theme = "system", systemTheme = "light" } = useTheme(); - - const currentTheme = - theme === "system" ? systemTheme : (theme as "dark" | "light"); + const { resolvedTheme } = useTheme(); const extensions = useMemo(() => { return [ @@ -81,7 +78,7 @@ export function CodeEditor({ "h-full overflow-auto font-mono [&_.cm-editor]:h-full [&_.cm-focused]:outline-none!", "px-2 py-0! [&_.cm-line]:px-2! [&_.cm-line]:py-0!", )} - theme={currentTheme === "dark" ? customDarkTheme : customLightTheme} + theme={resolvedTheme === "dark" ? customDarkTheme : customLightTheme} extensions={extensions} basicSetup={{ foldGutter: settings?.foldGutter ?? false,