Skip to content

Commit b2bc859

Browse files
committed
update readme for latest releases
1 parent 40eb780 commit b2bc859

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
Codemirror extensions that add on `@codemirror/lang-json`'s and `codemirror-json5`'s grammars to add JSONSchema support!
1+
Codemirror 6 extensions that provide full [JSON Schema](https://json-schema.org/) support for `@codemirror/lang-json` & `codemirror-json5` language modes
2+
3+
<a href="https://npmjs.com/codemirror-json-schema">
4+
<img alt="npm" src="https://img.shields.io/npm/dm/codemirror-json-schema?label=npm%20downloads">
5+
</a>
26

37
![screenshot of the examples with json4 and json5 support enabled](./dev/public/example.png)
48

59
## Features
610

7-
It's at a very early stage, but usable.
11+
This is now a full-featured library for both json4 (aka json) and json5, but the APIs may still have breakages.
12+
13+
So far mostly tested with standard json4 schema specs. See
814

915
### json4
1016

11-
-`lint`s: validates json against schema
12-
-`hint`s: provides code completion (no complex types yet)
13-
-`info`s: provides hover tooltip
17+
- ✅ validates json
18+
-autocompletion
19+
-hover tooltips from schema
1420

1521
### json5
1622

17-
-`lint`s: validates json against schema
18-
-`info`s: provides hover tooltip
23+
- ✅ validates json5
24+
- ✅ autocompletion
25+
- ✅ hover tooltips
1926

2027
## Usage
2128

@@ -87,7 +94,8 @@ npm install --save codemirror-json5 codemirror-json-schema @codemirror/language
8794
```ts
8895
import { EditorState } from "@codemirror/state";
8996
import { linter } from "@codemirror/lint";
90-
import { json5, json5ParseLinter } from "codemirror-json5";
97+
import { json5, json5ParseLinter, json5Language } from "codemirror-json5";
98+
import { jsonCompletion } from "codemirror-json-schema";
9199
import {
92100
json5SchemaLinter,
93101
json5SchemaHover,
@@ -109,11 +117,14 @@ const json5State = EditorState.create({
109117
linter(json5ParseLinter()),
110118
linter(json5SchemaLinter(schema)),
111119
hoverTooltip(json5SchemaHover(schema)),
120+
json5Language.data.of({
121+
autocomplete: jsonCompletion(schema),
122+
}),
112123
],
113124
});
114125
```
115126

116-
### Demo
127+
### Complete demo
117128

118129
You can start with the [deployed example](https://github.com/acao/cm6-json-schema/blob/main/dev/index.ts) to see a more comprehensive setup.
119130

@@ -123,20 +134,22 @@ For more information, see the [API Docs](./docs/)
123134

124135
## Current Constraints:
125136

126-
- only linting & hover is available for `oneOf`, `anyOf`, `allOf` and other [schema combination methods](https://json-schema.org/understanding-json-schema/reference/combining.html)
127137
- it only works with one json schema instance at a time, and doesn't yet fetch remote schemas. schema service coming soon!
128138
- currently only tested with standard schemas using json4 spec. results may vary
129-
- doesn't provide insert text on completion yet
130-
- currently you can override the rendering of a hover. we plan to add the same for validation errors and autocomplete
139+
- doesn't place cursor inside known insert text yet
140+
- currently you can only override the texts and rendering of a hover. we plan to add the same for validation errors and autocomplete
141+
- json5 properties on autocompletion selection will insert surrounding double quotes, but we plan to make it insert without delimiters
131142

132143
## Inspiration
133144

134-
`monaco-json` and `monaco-yaml` both provide these features, and I want the nascent codemirror 6 to have them as well!
145+
`monaco-json` and `monaco-yaml` both provide json schema features for json, cson and yaml, and we want the nascent codemirror 6 to have them as well!
135146

136-
also, json5 is slowly growing in usage, and it needs full language support!
147+
Also, json5 is slowly growing in usage, and it needs full language support for the browser!
137148

138149
## Our Goals
139150

140151
- working GeoJSON spec linter & completion
141152
- working variables json mode for `cm6-graphql`, ala `monaco-graphql`
153+
- json5 support for `graphiql` as a plugin!
154+
- perhaps use @lezer to make a json5 language service for monaco-editor + json5?
142155
- json5 + json4 json schema features for all!

dev/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@
5454
display: grid;
5555
grid-auto-columns: 50%;
5656
grid-template-areas: "a a";
57+
gap: 1rem;
5758
}
5859
@media screen and (max-width: 768px) {
5960
.grid-row {
6061
grid-auto-columns: 100%;
6162
grid-template-areas: "a" "b";
63+
gap: 0;
6264
}
6365
}
6466
</style>
@@ -68,12 +70,10 @@ <h1><code>codemirror-json-schema</code> demo</h1>
6870
<div class="grid-row">
6971
<div>
7072
<h2><code>package.json</code> demo</h2>
71-
<p>Supports simple completion, linting, hover</p>
7273
<div id="editor"></div>
7374
</div>
7475
<div>
7576
<h2><code>package.json5</code> demo</h2>
76-
<p>Supports linting, hover</p>
7777
<div id="editor-json5"></div>
7878
</div>
7979
</div>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "codemirror-json-schema",
33
"license": "MIT",
44
"version": "0.3.1",
5-
"description": "A JSONSchema enabled mode for codemirror 6, for both json4 and json5, inspired by monaco-json",
5+
"description": "Codemirror 6 extensions that provide full JSONSchema support for `@codemirror/lang-json` and `codemirror-json5`",
66
"contributors": [
77
{
88
"name": "Samuel Imolorhe",

0 commit comments

Comments
 (0)