|
1 | 1 | import React, { useMemo, useRef } from "react"; |
2 | 2 | import { defaultKeymap, indentWithTab } from "@codemirror/commands"; |
3 | 3 | import { foldKeymap } from "@codemirror/language"; |
4 | | -import { lintGutter } from "@codemirror/lint"; |
5 | 4 | import { EditorState, Extension } from "@codemirror/state"; |
6 | 5 | import { DOMEventHandlers, EditorView, KeyBinding, keymap, Rect, ViewUpdate } from "@codemirror/view"; |
7 | 6 | import { minimalSetup } from "codemirror"; |
@@ -29,6 +28,7 @@ import { |
29 | 28 | adaptedHighlightSpecialChars, |
30 | 29 | adaptedLineNumbers, |
31 | 30 | adaptedPlaceholder, |
| 31 | + adaptedLintGutter, |
32 | 32 | } from "./tests/codemirrorTestHelper"; |
33 | 33 | import { ExtensionCreator } from "./types"; |
34 | 34 |
|
@@ -212,7 +212,7 @@ export const CodeEditor = ({ |
212 | 212 | return []; |
213 | 213 | } |
214 | 214 |
|
215 | | - const values = [lintGutter()]; |
| 215 | + const values = [adaptedLintGutter()]; |
216 | 216 |
|
217 | 217 | const linters = ModeLinterMap.get(mode); |
218 | 218 | if (linters) { |
@@ -320,24 +320,26 @@ export const CodeEditor = ({ |
320 | 320 | parent: parent.current, |
321 | 321 | }); |
322 | 322 |
|
323 | | - if (height) { |
324 | | - view.dom.style.height = typeof height === "string" ? height : `${height}px`; |
325 | | - } |
| 323 | + if (view?.dom) { |
| 324 | + if (height) { |
| 325 | + view.dom.style.height = typeof height === "string" ? height : `${height}px`; |
| 326 | + } |
326 | 327 |
|
327 | | - if (disabled) { |
328 | | - view.dom.className += ` ${eccgui}-disabled`; |
329 | | - } |
| 328 | + if (disabled) { |
| 329 | + view.dom.className += ` ${eccgui}-disabled`; |
| 330 | + } |
330 | 331 |
|
331 | | - if (intent) { |
332 | | - view.dom.className += ` ${eccgui}-intent--${intent}`; |
333 | | - } |
| 332 | + if (intent) { |
| 333 | + view.dom.className += ` ${eccgui}-intent--${intent}`; |
| 334 | + } |
334 | 335 |
|
335 | | - if (autoFocus) { |
336 | | - view.focus(); |
337 | | - } |
| 336 | + if (autoFocus) { |
| 337 | + view.focus(); |
| 338 | + } |
338 | 339 |
|
339 | | - if (setEditorView) { |
340 | | - setEditorView(view); |
| 340 | + if (setEditorView) { |
| 341 | + setEditorView(view); |
| 342 | + } |
341 | 343 | } |
342 | 344 |
|
343 | 345 | return () => { |
|
0 commit comments