diff --git a/.changeset/silly-oranges-worry.md b/.changeset/silly-oranges-worry.md deleted file mode 100644 index da16fa5..0000000 --- a/.changeset/silly-oranges-worry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"codemirror-json-schema": minor ---- - -Added YAML support, switched back to markdown for messages, provide markdown rendering, and fix some autocompletion issues diff --git a/CHANGELOG.md b/CHANGELOG.md index 54ed22c..6186c2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # codemirror-json-schema +## 0.7.0 + +### Minor Changes + +- [#85](https://github.com/acao/codemirror-json-schema/pull/85) [`c694451`](https://github.com/acao/codemirror-json-schema/commit/c6944518e72aef0a2b81952dff6bc0114b8c6be0) Thanks [@imolorhe](https://github.com/imolorhe)! - Added YAML support, switched back to markdown for messages, provide markdown rendering, and fix some autocompletion issues + ## 0.6.1 ### Patch Changes diff --git a/docs/README.md b/docs/README.md index ae22127..4a01911 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,7 +4,499 @@ codemirror-json-schema ## Table of contents -### Modules +### Bundled Codemirror Extensions -- [index](modules/index.md) -- [json5](modules/json5.md) +- [jsonSchema](README.md#jsonschema) + +### Codemirror Extensions + +- [jsonCompletion](README.md#jsoncompletion) +- [jsonSchemaHover](README.md#jsonschemahover) +- [jsonSchemaLinter](README.md#jsonschemalinter) + +### Utilities + +- [getJsonPointers](README.md#getjsonpointers) +- [jsonPointerForPosition](README.md#jsonpointerforposition) +- [parseJSONDocument](README.md#parsejsondocument) +- [parseJSONDocumentState](README.md#parsejsondocumentstate) + +### Functions + +- [getJSONSchema](README.md#getjsonschema) +- [getJsonPointerAt](README.md#getjsonpointerat) +- [handleRefresh](README.md#handlerefresh) +- [resolveTokenName](README.md#resolvetokenname) +- [stateExtensions](README.md#stateextensions) +- [updateSchema](README.md#updateschema) + +### Interfaces + +- [JSONValidationOptions](interfaces/JSONValidationOptions.md) + +### Type Aliases + +- [CursorData](README.md#cursordata) +- [FoundCursorData](README.md#foundcursordata) +- [HoverOptions](README.md#hoveroptions) +- [JSONPartialPointerData](README.md#jsonpartialpointerdata) +- [JSONPointerData](README.md#jsonpointerdata) +- [JSONPointersMap](README.md#jsonpointersmap) + +### Variables + +- [schemaStateField](README.md#schemastatefield) + +## Bundled Codemirror Extensions + +### jsonSchema + +▸ **jsonSchema**(`schema?`): `Extension`[] + +Full featured cm6 extension for json, including `@codemirror/lang-json` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `schema?` | `JSONSchema7` | + +#### Returns + +`Extension`[] + +#### Defined in + +[bundled.ts:15](https://github.com/acao/codemirror-json-schema/blob/c694451/src/bundled.ts#L15) + +## Codemirror Extensions + +### jsonCompletion + +▸ **jsonCompletion**(`opts?`): (`ctx`: `CompletionContext`) => `CompletionResult` \| `never`[] + +provides a JSON schema enabled autocomplete extension for codemirror + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `opts` | `JSONCompletionOptions` | + +#### Returns + +`fn` + +▸ (`ctx`): `CompletionResult` \| `never`[] + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `ctx` | `CompletionContext` | + +##### Returns + +`CompletionResult` \| `never`[] + +#### Defined in + +[json-completion.ts:936](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-completion.ts#L936) + +___ + +### jsonSchemaHover + +▸ **jsonSchemaHover**(`options?`): (`view`: `EditorView`, `pos`: `number`, `side`: `Side`) => `Promise`<``null`` \| `Tooltip`\> + +provides a JSON schema enabled tooltip extension for codemirror + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`HoverOptions`](README.md#hoveroptions) | + +#### Returns + +`fn` + +▸ (`view`, `pos`, `side`): `Promise`<``null`` \| `Tooltip`\> + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `view` | `EditorView` | +| `pos` | `number` | +| `side` | `Side` | + +##### Returns + +`Promise`<``null`` \| `Tooltip`\> + +#### Defined in + +[json-hover.ts:45](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-hover.ts#L45) + +___ + +### jsonSchemaLinter + +▸ **jsonSchemaLinter**(`options?`): (`view`: `EditorView`) => `Diagnostic`[] + +Helper for simpler class instantiaton + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `options?` | [`JSONValidationOptions`](interfaces/JSONValidationOptions.md) | + +#### Returns + +`fn` + +▸ (`view`): `Diagnostic`[] + +##### Parameters + +| Name | Type | +| :------ | :------ | +| `view` | `EditorView` | + +##### Returns + +`Diagnostic`[] + +#### Defined in + +[json-validation.ts:58](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-validation.ts#L58) + +## Utilities + +### getJsonPointers + +▸ **getJsonPointers**(`state`, `mode`): [`JSONPointersMap`](README.md#jsonpointersmap) + +retrieve a Map of all the json pointers in a document + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `state` | `EditorState` | +| `mode` | `JSONMode` | + +#### Returns + +[`JSONPointersMap`](README.md#jsonpointersmap) + +#### Defined in + +[utils/jsonPointers.ts:85](https://github.com/acao/codemirror-json-schema/blob/c694451/src/utils/jsonPointers.ts#L85) + +___ + +### jsonPointerForPosition + +▸ **jsonPointerForPosition**(`state`, `pos`, `side?`, `mode`): `string` + +retrieve a JSON pointer for a given position in the editor + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `state` | `EditorState` | `undefined` | +| `pos` | `number` | `undefined` | +| `side` | `Side` | `-1` | +| `mode` | `JSONMode` | `undefined` | + +#### Returns + +`string` + +#### Defined in + +[utils/jsonPointers.ts:68](https://github.com/acao/codemirror-json-schema/blob/c694451/src/utils/jsonPointers.ts#L68) + +___ + +### parseJSONDocument + +▸ **parseJSONDocument**(`jsonString`): `Object` + +Mimics the behavior of `json-source-map`'s `parseJSONDocument` function using codemirror EditorState + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `jsonString` | `string` | + +#### Returns + +`Object` + +| Name | Type | +| :------ | :------ | +| `data` | `any` | +| `pointers` | [`JSONPointersMap`](README.md#jsonpointersmap) | + +#### Defined in + +[utils/parseJSONDocument.ts:24](https://github.com/acao/codemirror-json-schema/blob/c694451/src/utils/parseJSONDocument.ts#L24) + +___ + +### parseJSONDocumentState + +▸ **parseJSONDocumentState**(`state`): `Object` + +Return parsed data and json pointers for a given codemirror EditorState + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `state` | `EditorState` | + +#### Returns + +`Object` + +| Name | Type | +| :------ | :------ | +| `data` | `any` | +| `pointers` | [`JSONPointersMap`](README.md#jsonpointersmap) | + +#### Defined in + +[utils/parseJSONDocument.ts:10](https://github.com/acao/codemirror-json-schema/blob/c694451/src/utils/parseJSONDocument.ts#L10) + +## Functions + +### getJSONSchema + +▸ **getJSONSchema**(`state`): `void` \| `JSONSchema7` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `state` | `EditorState` | + +#### Returns + +`void` \| `JSONSchema7` + +#### Defined in + +[state.ts:25](https://github.com/acao/codemirror-json-schema/blob/c694451/src/state.ts#L25) + +___ + +### getJsonPointerAt + +▸ **getJsonPointerAt**(`docText`, `node`, `mode`): `string` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `docText` | `Text` | +| `node` | `SyntaxNode` | +| `mode` | `JSONMode` | + +#### Returns + +`string` + +#### Defined in + +[utils/jsonPointers.ts:31](https://github.com/acao/codemirror-json-schema/blob/c694451/src/utils/jsonPointers.ts#L31) + +___ + +### handleRefresh + +▸ **handleRefresh**(`vu`): `boolean` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `vu` | `ViewUpdate` | + +#### Returns + +`boolean` + +#### Defined in + +[json-validation.ts:48](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-validation.ts#L48) + +___ + +### resolveTokenName + +▸ **resolveTokenName**(`nodeName`, `mode`): `string` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodeName` | `string` | +| `mode` | `JSONMode` | + +#### Returns + +`string` + +#### Defined in + +[utils/jsonPointers.ts:18](https://github.com/acao/codemirror-json-schema/blob/c694451/src/utils/jsonPointers.ts#L18) + +___ + +### stateExtensions + +▸ **stateExtensions**(`schema?`): `Extension`[] + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `schema?` | `JSONSchema7` | + +#### Returns + +`Extension`[] + +#### Defined in + +[state.ts:29](https://github.com/acao/codemirror-json-schema/blob/c694451/src/state.ts#L29) + +___ + +### updateSchema + +▸ **updateSchema**(`view`, `schema?`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `view` | `EditorView` | +| `schema?` | `JSONSchema7` | + +#### Returns + +`void` + +#### Defined in + +[state.ts:19](https://github.com/acao/codemirror-json-schema/blob/c694451/src/state.ts#L19) + +## Type Aliases + +### CursorData + +Ƭ **CursorData**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `pointer` | `string` | +| `schema?` | `JsonSchema` | + +#### Defined in + +[json-hover.ts:18](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-hover.ts#L18) + +___ + +### FoundCursorData + +Ƭ **FoundCursorData**: `Required`<[`CursorData`](README.md#cursordata)\> + +#### Defined in + +[json-hover.ts:20](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-hover.ts#L20) + +___ + +### HoverOptions + +Ƭ **HoverOptions**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `formatHover?` | (`data`: `HoverTexts`) => `HTMLElement` | +| `getHoverTexts?` | (`data`: [`FoundCursorData`](README.md#foundcursordata)) => `HoverTexts` | +| `mode?` | `JSONMode` | +| `parser?` | (`text`: `string`) => `any` | + +#### Defined in + +[json-hover.ts:24](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-hover.ts#L24) + +___ + +### JSONPartialPointerData + +Ƭ **JSONPartialPointerData**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `keyFrom` | `number` | +| `keyTo` | `number` | + +#### Defined in + +[types.ts:6](https://github.com/acao/codemirror-json-schema/blob/c694451/src/types.ts#L6) + +___ + +### JSONPointerData + +Ƭ **JSONPointerData**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `keyFrom` | `number` | +| `keyTo` | `number` | +| `valueFrom` | `number` | +| `valueTo` | `number` | + +#### Defined in + +[types.ts:11](https://github.com/acao/codemirror-json-schema/blob/c694451/src/types.ts#L11) + +___ + +### JSONPointersMap + +Ƭ **JSONPointersMap**: `Map`<`string`, [`JSONPointerData`](README.md#jsonpointerdata) \| [`JSONPartialPointerData`](README.md#jsonpartialpointerdata)\> + +#### Defined in + +[types.ts:20](https://github.com/acao/codemirror-json-schema/blob/c694451/src/types.ts#L20) + +## Variables + +### schemaStateField + +• `Const` **schemaStateField**: `StateField`<`void` \| `JSONSchema7`\> + +#### Defined in + +[state.ts:6](https://github.com/acao/codemirror-json-schema/blob/c694451/src/state.ts#L6) diff --git a/docs/interfaces/JSONValidationOptions.md b/docs/interfaces/JSONValidationOptions.md new file mode 100644 index 0000000..d73a464 --- /dev/null +++ b/docs/interfaces/JSONValidationOptions.md @@ -0,0 +1,79 @@ +[codemirror-json-schema](../README.md) / JSONValidationOptions + +# Interface: JSONValidationOptions + +## Table of contents + +### Utilities + +- [jsonParser](JSONValidationOptions.md#jsonparser) + +### Properties + +- [formatError](JSONValidationOptions.md#formaterror) +- [mode](JSONValidationOptions.md#mode) + +## Utilities + +### jsonParser + +• `Optional` **jsonParser**: (`state`: `EditorState`) => { `data`: `any` ; `pointers`: [`JSONPointersMap`](../README.md#jsonpointersmap) } + +#### Type declaration + +▸ (`state`): `Object` + +Return parsed data and json pointers for a given codemirror EditorState + +##### Parameters + +| Name | Type | +| :------ | :------------ | +| `state` | `EditorState` | + +##### Returns + +`Object` + +| Name | Type | +| :--------- | :------------------------------------------------ | +| `data` | `any` | +| `pointers` | [`JSONPointersMap`](../README.md#jsonpointersmap) | + +#### Defined in + +[json-validation.ts:43](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-validation.ts#L43) + +## Properties + +### formatError + +• `Optional` **formatError**: (`error`: `JsonError`) => `string` + +#### Type declaration + +▸ (`error`): `string` + +##### Parameters + +| Name | Type | +| :------ | :---------- | +| `error` | `JsonError` | + +##### Returns + +`string` + +#### Defined in + +[json-validation.ts:42](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-validation.ts#L42) + +--- + +### mode + +• `Optional` **mode**: `JSONMode` + +#### Defined in + +[json-validation.ts:41](https://github.com/acao/codemirror-json-schema/blob/c694451/src/json-validation.ts#L41) diff --git a/docs/modules/index.md b/docs/modules/index.md deleted file mode 100644 index 226eee4..0000000 --- a/docs/modules/index.md +++ /dev/null @@ -1,502 +0,0 @@ -[codemirror-json-schema](../README.md) / index - -# Module: index - -## Table of contents - -### Bundled Codemirror Extensions - -- [jsonSchema](index.md#jsonschema) - -### Codemirror Extensions - -- [jsonCompletion](index.md#jsoncompletion) -- [jsonSchemaHover](index.md#jsonschemahover) -- [jsonSchemaLinter](index.md#jsonschemalinter) - -### Utilities - -- [getJsonPointers](index.md#getjsonpointers) -- [jsonPointerForPosition](index.md#jsonpointerforposition) -- [parseJSONDocument](index.md#parsejsondocument) -- [parseJSONDocumentState](index.md#parsejsondocumentstate) - -### Functions - -- [getJSONSchema](index.md#getjsonschema) -- [getJsonPointerAt](index.md#getjsonpointerat) -- [handleRefresh](index.md#handlerefresh) -- [stateExtensions](index.md#stateextensions) -- [updateSchema](index.md#updateschema) - -### Type Aliases - -- [CursorData](index.md#cursordata) -- [FoundCursorData](index.md#foundcursordata) -- [HoverOptions](index.md#hoveroptions) -- [JSONMode](index.md#jsonmode) -- [JSONPartialPointerData](index.md#jsonpartialpointerdata) -- [JSONPointerData](index.md#jsonpointerdata) -- [JSONPointersMap](index.md#jsonpointersmap) -- [JSONValidationOptions](index.md#jsonvalidationoptions) - -### Variables - -- [schemaStateField](index.md#schemastatefield) - -## Bundled Codemirror Extensions - -### jsonSchema - -▸ **jsonSchema**(`schema?`): `Extension`[] - -Full featured cm6 extension for json, including `@codemirror/lang-json` - -#### Parameters - -| Name | Type | -| :-------- | :------------ | -| `schema?` | `JSONSchema7` | - -#### Returns - -`Extension`[] - -#### Defined in - -[bundled.ts:15](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/bundled.ts#L15) - -## Codemirror Extensions - -### jsonCompletion - -▸ **jsonCompletion**(`opts?`): (`ctx`: `CompletionContext`) => `CompletionResult` \| `never`[] - -provides a JSON schema enabled autocomplete extension for codemirror - -#### Parameters - -| Name | Type | -| :----- | :---------------------- | -| `opts` | `JSONCompletionOptions` | - -#### Returns - -`fn` - -▸ (`ctx`): `CompletionResult` \| `never`[] - -##### Parameters - -| Name | Type | -| :---- | :------------------ | -| `ctx` | `CompletionContext` | - -##### Returns - -`CompletionResult` \| `never`[] - -#### Defined in - -[json-completion.ts:808](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-completion.ts#L808) - ---- - -### jsonSchemaHover - -▸ **jsonSchemaHover**(`options?`): (`view`: `EditorView`, `pos`: `number`, `side`: `Side`) => `Promise`<`null` \| `Tooltip`\> - -provides a JSON schema enabled tooltip extension for codemirror - -#### Parameters - -| Name | Type | -| :--------- | :-------------------------------------- | -| `options?` | [`HoverOptions`](index.md#hoveroptions) | - -#### Returns - -`fn` - -▸ (`view`, `pos`, `side`): `Promise`<`null` \| `Tooltip`\> - -##### Parameters - -| Name | Type | -| :----- | :----------- | -| `view` | `EditorView` | -| `pos` | `number` | -| `side` | `Side` | - -##### Returns - -`Promise`<`null` \| `Tooltip`\> - -#### Defined in - -[json-hover.ts:42](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-hover.ts#L42) - ---- - -### jsonSchemaLinter - -▸ **jsonSchemaLinter**(`options?`): (`view`: `EditorView`) => `Diagnostic`[] - -Helper for simpler class instantiaton - -#### Parameters - -| Name | Type | -| :--------- | :-------------------------------------------------------- | -| `options?` | [`JSONValidationOptions`](index.md#jsonvalidationoptions) | - -#### Returns - -`fn` - -▸ (`view`): `Diagnostic`[] - -##### Parameters - -| Name | Type | -| :----- | :----------- | -| `view` | `EditorView` | - -##### Returns - -`Diagnostic`[] - -#### Defined in - -[json-validation.ts:43](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-validation.ts#L43) - -## Utilities - -### getJsonPointers - -▸ **getJsonPointers**(`state`, `mode?`): [`JSONPointersMap`](index.md#jsonpointersmap) - -retrieve a Map of all the json pointers in a document - -#### Parameters - -| Name | Type | Default value | -| :------ | :------------------------------ | :------------ | -| `state` | `EditorState` | `undefined` | -| `mode` | [`JSONMode`](index.md#jsonmode) | `"json4"` | - -#### Returns - -[`JSONPointersMap`](index.md#jsonpointersmap) - -#### Defined in - -[utils/jsonPointers.ts:57](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/utils/jsonPointers.ts#L57) - ---- - -### jsonPointerForPosition - -▸ **jsonPointerForPosition**(`state`, `pos`, `side?`): `string` - -retrieve a JSON pointer for a given position in the editor - -#### Parameters - -| Name | Type | Default value | -| :------ | :------------ | :------------ | -| `state` | `EditorState` | `undefined` | -| `pos` | `number` | `undefined` | -| `side` | `Side` | `-1` | - -#### Returns - -`string` - -#### Defined in - -[utils/jsonPointers.ts:45](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/utils/jsonPointers.ts#L45) - ---- - -### parseJSONDocument - -▸ **parseJSONDocument**(`jsonString`): `Object` - -Mimics the behavior of `json-source-map`'s `parseJSONDocument` function using codemirror EditorState - -#### Parameters - -| Name | Type | -| :----------- | :------- | -| `jsonString` | `string` | - -#### Returns - -`Object` - -| Name | Type | -| :--------- | :-------------------------------------------- | -| `data` | `any` | -| `pointers` | [`JSONPointersMap`](index.md#jsonpointersmap) | - -#### Defined in - -[utils/parseJSONDocument.ts:23](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/utils/parseJSONDocument.ts#L23) - ---- - -### parseJSONDocumentState - -▸ **parseJSONDocumentState**(`state`): `Object` - -Return parsed data and json pointers for a given codemirror EditorState - -#### Parameters - -| Name | Type | -| :------ | :------------ | -| `state` | `EditorState` | - -#### Returns - -`Object` - -| Name | Type | -| :--------- | :-------------------------------------------- | -| `data` | `any` | -| `pointers` | [`JSONPointersMap`](index.md#jsonpointersmap) | - -#### Defined in - -[utils/parseJSONDocument.ts:9](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/utils/parseJSONDocument.ts#L9) - -## Functions - -### getJSONSchema - -▸ **getJSONSchema**(`state`): `void` \| `JSONSchema7` - -#### Parameters - -| Name | Type | -| :------ | :------------ | -| `state` | `EditorState` | - -#### Returns - -`void` \| `JSONSchema7` - -#### Defined in - -[state.ts:25](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/state.ts#L25) - ---- - -### getJsonPointerAt - -▸ **getJsonPointerAt**(`docText`, `node`): `string` - -#### Parameters - -| Name | Type | -| :-------- | :----------- | -| `docText` | `Text` | -| `node` | `SyntaxNode` | - -#### Returns - -`string` - -#### Defined in - -[utils/jsonPointers.ts:12](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/utils/jsonPointers.ts#L12) - ---- - -### handleRefresh - -▸ **handleRefresh**(`vu`): `boolean` - -#### Parameters - -| Name | Type | -| :--- | :----------- | -| `vu` | `ViewUpdate` | - -#### Returns - -`boolean` - -#### Defined in - -[json-validation.ts:33](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-validation.ts#L33) - ---- - -### stateExtensions - -▸ **stateExtensions**(`schema?`): `Extension`[] - -#### Parameters - -| Name | Type | -| :-------- | :------------ | -| `schema?` | `JSONSchema7` | - -#### Returns - -`Extension`[] - -#### Defined in - -[state.ts:29](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/state.ts#L29) - ---- - -### updateSchema - -▸ **updateSchema**(`view`, `schema?`): `void` - -#### Parameters - -| Name | Type | -| :-------- | :------------ | -| `view` | `EditorView` | -| `schema?` | `JSONSchema7` | - -#### Returns - -`void` - -#### Defined in - -[state.ts:19](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/state.ts#L19) - -## Type Aliases - -### CursorData - -Ƭ **CursorData**: `Object` - -#### Type declaration - -| Name | Type | -| :-------- | :----------- | -| `pointer` | `string` | -| `schema?` | `JsonSchema` | - -#### Defined in - -[json-hover.ts:16](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-hover.ts#L16) - ---- - -### FoundCursorData - -Ƭ **FoundCursorData**: `Required`<[`CursorData`](index.md#cursordata)\> - -#### Defined in - -[json-hover.ts:18](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-hover.ts#L18) - ---- - -### HoverOptions - -Ƭ **HoverOptions**: `Object` - -#### Type declaration - -| Name | Type | -| :--------------- | :---------------------------------------------------------------------- | -| `formatHover?` | (`data`: `HoverTexts`) => `HTMLElement` | -| `getHoverTexts?` | (`data`: [`FoundCursorData`](index.md#foundcursordata)) => `HoverTexts` | -| `parser?` | (`text`: `string`) => `any` | - -#### Defined in - -[json-hover.ts:22](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-hover.ts#L22) - ---- - -### JSONMode - -Ƭ **JSONMode**: `"json4"` \| `"json5"` - -#### Defined in - -[utils/jsonPointers.ts:8](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/utils/jsonPointers.ts#L8) - ---- - -### JSONPartialPointerData - -Ƭ **JSONPartialPointerData**: `Object` - -#### Type declaration - -| Name | Type | -| :-------- | :------- | -| `keyFrom` | `number` | -| `keyTo` | `number` | - -#### Defined in - -[types.ts:4](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/types.ts#L4) - ---- - -### JSONPointerData - -Ƭ **JSONPointerData**: `Object` - -#### Type declaration - -| Name | Type | -| :---------- | :------- | -| `keyFrom` | `number` | -| `keyTo` | `number` | -| `valueFrom` | `number` | -| `valueTo` | `number` | - -#### Defined in - -[types.ts:9](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/types.ts#L9) - ---- - -### JSONPointersMap - -Ƭ **JSONPointersMap**: `Map`<`string`, [`JSONPointerData`](index.md#jsonpointerdata) \| [`JSONPartialPointerData`](index.md#jsonpartialpointerdata)\> - -#### Defined in - -[types.ts:18](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/types.ts#L18) - ---- - -### JSONValidationOptions - -Ƭ **JSONValidationOptions**: `Object` - -#### Type declaration - -| Name | Type | -| :------------- | :----------------------------------------------------------------- | -| `formatError?` | (`error`: `JsonError`) => `string` | -| `jsonParser?` | typeof [`parseJSONDocumentState`](index.md#parsejsondocumentstate) | - -#### Defined in - -[json-validation.ts:26](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-validation.ts#L26) - -## Variables - -### schemaStateField - -• `Const` **schemaStateField**: `StateField`<`void` \| `JSONSchema7`\> - -#### Defined in - -[state.ts:6](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/state.ts#L6) diff --git a/docs/modules/json5.md b/docs/modules/json5.md deleted file mode 100644 index 101afc1..0000000 --- a/docs/modules/json5.md +++ /dev/null @@ -1,200 +0,0 @@ -[codemirror-json-schema](../README.md) / json5 - -# Module: json5 - -## Table of contents - -### Bundled Codemirror Extensions - -- [json5Schema](json5.md#json5schema) - -### Codemirror Extensions - -- [json5Completion](json5.md#json5completion) -- [json5SchemaHover](json5.md#json5schemahover) -- [json5SchemaLinter](json5.md#json5schemalinter) - -### Utilities - -- [parseJSON5Document](json5.md#parsejson5document) -- [parseJSON5DocumentState](json5.md#parsejson5documentstate) - -## Bundled Codemirror Extensions - -### json5Schema - -▸ **json5Schema**(`schema?`): `Extension`[] - -Full featured cm6 extension for json5, including `codemirror-json5` - -#### Parameters - -| Name | Type | -| :-------- | :------------ | -| `schema?` | `JSONSchema7` | - -#### Returns - -`Extension`[] - -#### Defined in - -[json5-bundled.ts:16](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json5-bundled.ts#L16) - -## Codemirror Extensions - -### json5Completion - -▸ **json5Completion**(`opts?`): (`ctx`: `CompletionContext`) => `CompletionResult` \| `never`[] - -provides a JSON schema enabled autocomplete extension for codemirror and json5 - -#### Parameters - -| Name | Type | -| :----- | :----------------------------------------- | -| `opts` | `Omit`<`JSONCompletionOptions`, `"mode"`\> | - -#### Returns - -`fn` - -▸ (`ctx`): `CompletionResult` \| `never`[] - -##### Parameters - -| Name | Type | -| :---- | :------------------ | -| `ctx` | `CompletionContext` | - -##### Returns - -`CompletionResult` \| `never`[] - -#### Defined in - -[json-completion.ts:819](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json-completion.ts#L819) - ---- - -### json5SchemaHover - -▸ **json5SchemaHover**(`options?`): (`view`: `EditorView`, `pos`: `number`, `side`: `Side`) => `Promise`<`null` \| `Tooltip`\> - -Instantiates a JSONHover instance with the JSON5 mode - -#### Parameters - -| Name | Type | -| :--------- | :-------------------------------------- | -| `options?` | [`HoverOptions`](index.md#hoveroptions) | - -#### Returns - -`fn` - -▸ (`view`, `pos`, `side`): `Promise`<`null` \| `Tooltip`\> - -##### Parameters - -| Name | Type | -| :----- | :----------- | -| `view` | `EditorView` | -| `pos` | `number` | -| `side` | `Side` | - -##### Returns - -`Promise`<`null` \| `Tooltip`\> - -#### Defined in - -[json5-hover.ts:13](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json5-hover.ts#L13) - ---- - -### json5SchemaLinter - -▸ **json5SchemaLinter**(`options?`): (`view`: `EditorView`) => `Diagnostic`[] - -Instantiates a JSONValidation instance with the JSON5 mode - -#### Parameters - -| Name | Type | -| :--------- | :-------------------------------------------------------- | -| `options?` | [`JSONValidationOptions`](index.md#jsonvalidationoptions) | - -#### Returns - -`fn` - -▸ (`view`): `Diagnostic`[] - -##### Parameters - -| Name | Type | -| :----- | :----------- | -| `view` | `EditorView` | - -##### Returns - -`Diagnostic`[] - -#### Defined in - -[json5-validation.ts:12](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/json5-validation.ts#L12) - -## Utilities - -### parseJSON5Document - -▸ **parseJSON5Document**(`jsonString`): `Object` - -Mimics the behavior of `json-source-map`'s `parseJSONDocument` function, for json5! - -#### Parameters - -| Name | Type | -| :----------- | :------- | -| `jsonString` | `string` | - -#### Returns - -`Object` - -| Name | Type | -| :--------- | :-------------------------------------------- | -| `data` | `any` | -| `pointers` | [`JSONPointersMap`](index.md#jsonpointersmap) | - -#### Defined in - -[utils/parseJSON5Document.ts:28](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/utils/parseJSON5Document.ts#L28) - ---- - -### parseJSON5DocumentState - -▸ **parseJSON5DocumentState**(`state`): `Object` - -Return parsed data and json5 pointers for a given codemirror EditorState - -#### Parameters - -| Name | Type | -| :------ | :------------ | -| `state` | `EditorState` | - -#### Returns - -`Object` - -| Name | Type | -| :--------- | :-------------------------------------------- | -| `data` | `any` | -| `pointers` | [`JSONPointersMap`](index.md#jsonpointersmap) | - -#### Defined in - -[utils/parseJSON5Document.ts:14](https://github.com/acao/codemirror-json-schema/blob/efd54f0/src/utils/parseJSON5Document.ts#L14) diff --git a/package.json b/package.json index d1db0b9..3d6bc27 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "codemirror-json-schema", "license": "MIT", - "version": "0.6.1", + "version": "0.7.0", "description": "Codemirror 6 extensions that provide full JSONSchema support for `@codemirror/lang-json` and `codemirror-json5`", "contributors": [ {