| 129 | } satisfies JSONSchema7 |
| 130 | |
| 131 | function createEditorState( |
| 132 | doc: string, |
| 133 | theme: 'light' | 'dark', |
| 134 | schema: JSONSchema7, |
| 135 | ) { |
| 136 | const maybeDark = theme === 'dark' ? [oneDark] : [] |
| 137 | return EditorState.create({ |
| 138 | doc, |
| 139 | extensions: [ |
| 140 | [...basicSetup], |
| 141 | json(), |
| 142 | ...maybeDark, |
| 143 | lintGutter(), |
| 144 | linter(jsonParseLinter(), { |
| 145 | delay: 300, |
| 146 | }), |
| 147 | linter(jsonSchemaLinter(), { |
| 148 | needsRefresh: handleRefresh, |
| 149 | }), |
| 150 | jsonLanguage.data.of({ |
| 151 | autocomplete: jsonCompletion(), |
| 152 | }), |
| 153 | hoverTooltip(jsonSchemaHover()), |
| 154 | stateExtensions(schema), |
| 155 | ], |
| 156 | }) |
| 157 | } |