-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbundled.ts
28 lines (26 loc) · 901 Bytes
/
bundled.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { JSONSchema7 } from "json-schema";
import { json, jsonLanguage, jsonParseLinter } from "@codemirror/lang-json";
import { hoverTooltip } from "@codemirror/view";
import { jsonCompletion } from "../features/completion";
import { handleRefresh, jsonSchemaLinter } from "../features/validation";
import { jsonSchemaHover } from "../features/hover";
import { stateExtensions } from "../features/state";
import { linter } from "@codemirror/lint";
/**
* Full featured cm6 extension for json, including `@codemirror/lang-json`
* @group Bundled Codemirror Extensions
*/
export function jsonSchema(schema?: JSONSchema7) {
return [
json(),
linter(jsonParseLinter()),
linter(jsonSchemaLinter(), {
needsRefresh: handleRefresh,
}),
jsonLanguage.data.of({
autocomplete: jsonCompletion(),
}),
hoverTooltip(jsonSchemaHover()),
stateExtensions(schema),
];
}