|
1 | | -import { json, jsonParseLinter } from '@codemirror/lang-json'; |
2 | | -import { forEachDiagnostic, linter, lintGutter, setDiagnosticsEffect } from '@codemirror/lint'; |
| 1 | +// import { json, jsonParseLinter } from '@codemirror/lang-json'; |
| 2 | +import { yaml } from '@codemirror/lang-yaml'; |
| 3 | +// import { forEachDiagnostic, linter, lintGutter, setDiagnosticsEffect } from '@codemirror/lint'; |
3 | 4 | import ReactCodeMirror, { EditorSelection, Extension, ReactCodeMirrorRef } from '@uiw/react-codemirror'; |
4 | 5 | import clsx from 'clsx'; |
5 | 6 | import { FC, useEffect, useRef, useState } from 'react'; |
6 | 7 | import { Diagnostic, Spec, SpecInput, SpecLinter } from '../types'; |
7 | 8 | import { formatDocument, groupBySource, handleResponse } from '../util'; |
8 | 9 |
|
9 | | -const EXTENSIONS: Extension[] = [json(), linter(jsonParseLinter()), lintGutter()]; |
| 10 | +const EXTENSIONS: Extension[] = [yaml()]; |
10 | 11 |
|
11 | 12 | interface Props { |
12 | 13 | spec: Spec; |
@@ -55,30 +56,31 @@ const CodeEditor: FC<Props> = ({ spec, uri }) => { |
55 | 56 | <div className="flex h-full"> |
56 | 57 | <div className="w-[50%] min-w-[400px] overflow-auto"> |
57 | 58 | <ReactCodeMirror |
| 59 | + theme={'dark'} |
58 | 60 | ref={codeMirrorRef} |
59 | 61 | value={content} |
60 | 62 | extensions={[...EXTENSIONS, ...linters.map(l => l.linter)]} |
61 | | - onUpdate={viewUpdate => { |
62 | | - if (error) { |
63 | | - return; |
64 | | - } |
| 63 | + // onUpdate={viewUpdate => { |
| 64 | + // if (error) { |
| 65 | + // return; |
| 66 | + // } |
65 | 67 |
|
66 | | - viewUpdate.transactions.forEach(transaction => { |
67 | | - transaction.effects.forEach(effect => { |
68 | | - if (effect.is(setDiagnosticsEffect)) { |
69 | | - const diagnostics: Diagnostic[] = []; |
70 | | - forEachDiagnostic(viewUpdate.state, d => diagnostics.push(d)); |
71 | | - setDiagnostics(groupBySource(diagnostics)); |
72 | | - setChecking(false); |
73 | | - } |
74 | | - }); |
75 | | - }); |
| 68 | + // viewUpdate.transactions.forEach(transaction => { |
| 69 | + // transaction.effects.forEach(effect => { |
| 70 | + // if (effect.is(setDiagnosticsEffect)) { |
| 71 | + // const diagnostics: Diagnostic[] = []; |
| 72 | + // forEachDiagnostic(viewUpdate.state, d => diagnostics.push(d)); |
| 73 | + // setDiagnostics(groupBySource(diagnostics)); |
| 74 | + // setChecking(false); |
| 75 | + // } |
| 76 | + // }); |
| 77 | + // }); |
76 | 78 |
|
77 | | - if (viewUpdate.docChanged) { |
78 | | - setContent(viewUpdate.state.doc.toString()); |
79 | | - setChecking(true); |
80 | | - } |
81 | | - }} |
| 79 | + // if (viewUpdate.docChanged) { |
| 80 | + // setContent(viewUpdate.state.doc.toString()); |
| 81 | + // setChecking(true); |
| 82 | + // } |
| 83 | + // }} |
82 | 84 | /> |
83 | 85 | </div> |
84 | 86 | <div className="flex-1 overflow-auto p-4 bg-sky-100 text-sm"> |
|
0 commit comments