Skip to content

Commit 640bb37

Browse files
committed
feat: add packages for handling yaml
1 parent ac390d1 commit 640bb37

File tree

6 files changed

+241
-130
lines changed

6 files changed

+241
-130
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
"test": "vitest"
1212
},
1313
"dependencies": {
14-
"@codemirror/lang-json": "^6.0.1",
14+
"@codemirror/lang-json": "^6.0.2",
15+
"@codemirror/lang-yaml": "^6.1.2",
1516
"@codemirror/language": "^6.11.0",
1617
"@codemirror/lint": "^6.8.5",
18+
"@modyfi/vite-plugin-yaml": "^1.1.1",
1719
"@stoplight/better-ajv-errors": "^1.0.3",
1820
"@stoplight/spectral-core": "^1.20.0",
1921
"@stoplight/spectral-formats": "^1.8.2",

pnpm-lock.yaml

Lines changed: 79 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/CodeEditor.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
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';
34
import ReactCodeMirror, { EditorSelection, Extension, ReactCodeMirrorRef } from '@uiw/react-codemirror';
45
import clsx from 'clsx';
56
import { FC, useEffect, useRef, useState } from 'react';
67
import { Diagnostic, Spec, SpecInput, SpecLinter } from '../types';
78
import { formatDocument, groupBySource, handleResponse } from '../util';
89

9-
const EXTENSIONS: Extension[] = [json(), linter(jsonParseLinter()), lintGutter()];
10+
const EXTENSIONS: Extension[] = [yaml()];
1011

1112
interface Props {
1213
spec: Spec;
@@ -55,30 +56,31 @@ const CodeEditor: FC<Props> = ({ spec, uri }) => {
5556
<div className="flex h-full">
5657
<div className="w-[50%] min-w-[400px] overflow-auto">
5758
<ReactCodeMirror
59+
theme={'dark'}
5860
ref={codeMirrorRef}
5961
value={content}
6062
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+
// }
6567

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+
// });
7678

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+
// }}
8284
/>
8385
</div>
8486
<div className="flex-1 overflow-auto p-4 bg-sky-100 text-sm">

src/specs/publiccode/example.json

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)