Hello!
I’m new to codemirror, and wanting to get something basic going before I start tweaking themes / language / grammar etc, but I’m having issues getting the editor styles to load – I understand they are supposed to be included with the JS, but I haven’t found any examples on the Styling docs.
This is what I have so far:
import { autocompletion } from '@codemirror/autocomplete';
import { basicSetup } from '@codemirror/basic-setup';
import { closeBrackets } from '@codemirror/closebrackets';
import { foldGutter } from '@codemirror/fold';
import { history } from '@codemirror/history';
import { javascript } from '@codemirror/lang-javascript';
import { markdown } from '@codemirror/lang-markdown';
import { bracketMatching } from '@codemirror/matchbrackets';
import { EditorState } from '@codemirror/state';
import { oneDark } from '@codemirror/theme-one-dark';
import { EditorView } from '@codemirror/view';
export default function newEditor(
element: HTMLElement,
value: string,
updateText: (text: string) => void
) {
let updateListener = EditorView.updateListener.of(({ state, docChanged }) => {
if (docChanged) {
updateText(state.doc.toString());
}
});
let view = new EditorView({
state: EditorState.create({
doc: value,
extensions: [
...basicSetup,
updateListener,
foldGutter(),
history(),
bracketMatching(),
closeBrackets(),
autocompletion(),
// javascript(),
markdown(),
oneDark,
],
}),
parent: element,
});
return view;
}
But when rendered, it looks like this:
I know the editor is mounting, because the updateListener
extension in here correctly fires when I change text.
I’m probably missing something obvious, but I haven’t been able to narrow it down yet