Setups a Codemirror view to look and behave like a log console.
npm install @gdquest/codemirror-consoleconsole() extensionThis extension setup a Codemirror view to look and behave like a log console.
- applies codemirror minimalSetup
- makes the view read-only;
- automatically snap to the bottom of the feed (unless scrolled);
- line wraps content.
``javascript
import { EditorView } from "@codemirror/view";
import { console } from "@gdquest/codemirror-console";
new EditorView({
extensions: [console()],
});
`
helperThis function highlights a line by adding the .cm-console-error class to the line. This is customizable with a theme, but the base color is red.
`javascript
import { EditorView } from "@codemirror/view";
import { consoleErrorLine } from "@gdquest/codemirror-console";
const view = new EditorView({
doc: "Good line\nError line\nGood line",
});
consoleErrorLine(view, 2);
``