|
@@ -33,12 +33,19 @@ import {
|
|
completionKeymap,
|
|
completionKeymap,
|
|
} from '@codemirror/autocomplete';
|
|
} from '@codemirror/autocomplete';
|
|
import { lintKeymap } from '@codemirror/lint';
|
|
import { lintKeymap } from '@codemirror/lint';
|
|
|
|
+import {
|
|
|
|
+ DEFAULT_CODE_VALUE,
|
|
|
|
+ DEFAULT_FOLD_LINE_RANGES,
|
|
|
|
+} from '@/pages/play/Constants';
|
|
|
|
|
|
import {
|
|
import {
|
|
lineNumbers,
|
|
lineNumbers,
|
|
highlightActiveLineGutter,
|
|
highlightActiveLineGutter,
|
|
} from '../language/extensions/gutter';
|
|
} from '../language/extensions/gutter';
|
|
-import { customFoldGutter } from '../language/extensions/fold';
|
|
|
|
|
|
+import {
|
|
|
|
+ customFoldGutter,
|
|
|
|
+ foldByLineRanges,
|
|
|
|
+} from '../language/extensions/fold';
|
|
|
|
|
|
const basicSetup = () => [
|
|
const basicSetup = () => [
|
|
lineNumbers(),
|
|
lineNumbers(),
|
|
@@ -107,6 +114,10 @@ export const useCodeMirror = (props: UseCodeMirrorProps) => {
|
|
state: startState,
|
|
state: startState,
|
|
parent: container,
|
|
parent: container,
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ if (value === DEFAULT_CODE_VALUE) {
|
|
|
|
+ foldByLineRanges(editorView, DEFAULT_FOLD_LINE_RANGES);
|
|
|
|
+ }
|
|
setView(editorView);
|
|
setView(editorView);
|
|
}
|
|
}
|
|
|
|
|