@@ -3,9 +3,9 @@ import { javascript } from "@codemirror/lang-javascript";
33import { markdown } from "@codemirror/lang-markdown" ;
44import { css } from "@codemirror/lang-css" ;
55import { html } from "@codemirror/lang-html" ;
6+ import { foldGutter , type LanguageSupport } from "@codemirror/language" ;
67import { EditorView } from "@codemirror/view" ;
7- import { LanguageSupport } from "@codemirror/language" ;
8- import CodeMirror from "@uiw/react-codemirror" ;
8+ import CodeMirror , { type BasicSetupOptions } from "@uiw/react-codemirror" ;
99import { useEffect , useRef , useState , useMemo , type FC } from "react" ;
1010import { useExplorer , type Language } from "@/hooks/use-explorer" ;
1111import { mergeClassNames , debounce } from "@/lib/utils" ;
@@ -27,6 +27,15 @@ const languageExtensions: Record<
2727 html : ( ) => html ( ) ,
2828} ;
2929
30+ const foldGutterExtension = foldGutter ( {
31+ closedText : "▸" ,
32+ openText : "▾" ,
33+ } ) ;
34+
35+ const basicSetup : BasicSetupOptions = {
36+ foldGutter : false ,
37+ } ;
38+
3039type EditorProperties = {
3140 ariaLabel : string ;
3241 readOnly ?: boolean ;
@@ -56,6 +65,7 @@ export const Editor: FC<EditorProperties> = ({
5665 const editorExtensions = useMemo (
5766 ( ) => [
5867 activeLanguageExtension ,
68+ foldGutterExtension ,
5969 wrap ? EditorView . lineWrapping : [ ] ,
6070 EditorView . contentAttributes . of ( { "aria-label" : ariaLabel } ) ,
6171 ESLintPlaygroundTheme ,
@@ -181,6 +191,7 @@ export const Editor: FC<EditorProperties> = ({
181191 extensions = { editorExtensions }
182192 onChange = { debouncedOnChange }
183193 readOnly = { readOnly }
194+ basicSetup = { basicSetup }
184195 />
185196 </ div >
186197 ) ;
0 commit comments