File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
apps/array/src/renderer/features/code-editor Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 11import { Box , Flex , SegmentedControl } from "@radix-ui/themes" ;
2- import { useMemo , useState } from "react" ;
2+ import { useMemo } from "react" ;
33import { useCodeMirror } from "../hooks/useCodeMirror" ;
44import { useEditorExtensions } from "../hooks/useEditorExtensions" ;
5-
6- type ViewMode = "split" | "unified" ;
5+ import { useDiffViewerStore , type ViewMode } from "../stores/diffViewerStore" ;
76
87interface CodeMirrorDiffEditorProps {
98 originalContent : string ;
@@ -18,7 +17,7 @@ export function CodeMirrorDiffEditor({
1817 filePath,
1918 onContentChange,
2019} : CodeMirrorDiffEditorProps ) {
21- const [ viewMode , setViewMode ] = useState < ViewMode > ( "split" ) ;
20+ const { viewMode, setViewMode } = useDiffViewerStore ( ) ;
2221 const extensions = useEditorExtensions ( filePath , true ) ;
2322 const options = useMemo (
2423 ( ) => ( {
Original file line number Diff line number Diff line change 1+ import { create } from "zustand" ;
2+ import { persist } from "zustand/middleware" ;
3+
4+ export type ViewMode = "split" | "unified" ;
5+
6+ interface DiffViewerStore {
7+ viewMode : ViewMode ;
8+ setViewMode : ( mode : ViewMode ) => void ;
9+ }
10+
11+ export const useDiffViewerStore = create < DiffViewerStore > ( ) (
12+ persist (
13+ ( set ) => ( {
14+ viewMode : "split" ,
15+ setViewMode : ( mode ) => set ( { viewMode : mode } ) ,
16+ } ) ,
17+ {
18+ name : "diff-viewer-storage" ,
19+ } ,
20+ ) ,
21+ ) ;
You can’t perform that action at this time.
0 commit comments