diff --git a/src/app/dashboard/[subdomain]/editor/page.tsx b/src/app/dashboard/[subdomain]/editor/page.tsx
index ac6ee476..c1e0baa1 100644
--- a/src/app/dashboard/[subdomain]/editor/page.tsx
+++ b/src/app/dashboard/[subdomain]/editor/page.tsx
@@ -208,8 +208,7 @@ export default function SubdomainEditor() {
const createOrUpdatePage = useCreateOrUpdatePage()
const isMobileLayout = useIsMobileLayout()
- const [isRendering, setIsRendering] = useState(false)
- const [previewVisible, setPreviewVisible] = useState(true)
+ const [isRendering, setIsRendering] = useState(!isMobileLayout)
const savePage = async (published: boolean) => {
const check = await checkPageSlug({
@@ -559,7 +558,7 @@ export default function SubdomainEditor() {
: "min-w-[840px] h-screen "
}`}
>
-
+
-
-
{
- setCurrentScrollArea("editor")
- }}
- />
- {((!isMobileLayout && previewVisible) ||
- (isMobileLayout && !isRendering)) && (
+
+ {!(isMobileLayout && isRendering) && (
+
{
+ setCurrentScrollArea("editor")
+ }}
+ className={cn("flex-1", isRendering ? "border-r" : "")}
+ />
+ )}
+ {!isMobileLayout && (
+
+
setIsRendering(!isRendering)}
+ >
+ {isRendering ? (
+
+ ) : (
+
+ )}
+
+
+ )}
+ {isRendering && (
)}
-
- {!isMobileLayout && (
-
-
setPreviewVisible(!previewVisible)}
- >
- {previewVisible ? (
-
- ) : (
-
- )}
-
-
- )}
{!isMobileLayout && (
diff --git a/src/components/ui/CodeMirror.tsx b/src/components/ui/CodeMirror.tsx
index a8876d4e..e03bd4e0 100644
--- a/src/components/ui/CodeMirror.tsx
+++ b/src/components/ui/CodeMirror.tsx
@@ -22,7 +22,6 @@ import {
import { useIsDark } from "~/hooks/useDarkMode"
import { useGetState } from "~/hooks/useGetState"
import { useIsUnmounted } from "~/hooks/useLifecycle"
-import { useIsMobileLayout } from "~/hooks/useMobileLayout"
import { cn } from "~/lib/utils"
const LoadingHolder = () => {
@@ -67,7 +66,6 @@ const LazyCodeMirrorEditor = forwardRef<
const editorElementRef = useRef
(null)
const isUnmounted = useIsUnmounted()
const { t } = useTranslation("dashboard")
- const isMobileLayout = useIsMobileLayout()
const [cmEditor, setCmEditor] = useState(null)
const isDark = useIsDark()
@@ -237,15 +235,7 @@ const LazyCodeMirrorEditor = forwardRef<
{loading && }
>
diff --git a/src/hooks/useCodemirrorTheme.ts b/src/hooks/useCodemirrorTheme.ts
index da7ab439..c6015ec6 100644
--- a/src/hooks/useCodemirrorTheme.ts
+++ b/src/hooks/useCodemirrorTheme.ts
@@ -7,7 +7,6 @@ import { EditorView } from "@codemirror/view"
import { githubLight } from "@ddietr/codemirror-themes/theme/github-light"
import { useIsUnmounted } from "./useLifecycle"
-import { useIsMobileLayout } from "./useMobileLayout"
export const monospaceFonts = `"OperatorMonoSSmLig Nerd Font","Cascadia Code PL","FantasqueSansMono Nerd Font","operator mono","Fira code Retina","Fira code","Consolas", Monaco, "Hannotate SC", monospace, -apple-system`
@@ -40,7 +39,6 @@ export const useCodeMirrorAutoToggleTheme = (
}
export const useCodeMirrorStyle = (view: EditorView | null) => {
- const isMobileLayout = useIsMobileLayout()
const isUnmounted = useIsUnmounted()
const once = useRef(false)
const getStyle = () => {
@@ -50,7 +48,7 @@ export const useCodeMirrorStyle = (view: EditorView | null) => {
fontSize: "1rem",
overflow: "auto",
height: "100%",
- padding: isMobileLayout ? "0 1.25rem" : "unset",
+ padding: "0 1.25rem",
},
".cm-content": {
paddingBottom: "600px",
@@ -70,7 +68,7 @@ export const useCodeMirrorStyle = (view: EditorView | null) => {
view.dispatch({
effects: [extensionMap.style.reconfigure(EditorView.theme(getStyle()))],
})
- }, [view, isMobileLayout])
+ }, [view])
if (isUnmounted()) return
if (!once.current) {