mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-28 10:32:27 +08:00
25 lines
631 B
TypeScript
25 lines
631 B
TypeScript
import { defaultKeymap } from "@codemirror/commands";
|
|
import { EditorView, keymap, lineNumbers, type EditorViewConfig } from "@codemirror/view";
|
|
|
|
export default class CodeMirror extends EditorView {
|
|
constructor(config: EditorViewConfig) {
|
|
super({
|
|
...config,
|
|
extensions: [
|
|
keymap.of(defaultKeymap),
|
|
lineNumbers()
|
|
]
|
|
});
|
|
}
|
|
|
|
setText(content: string) {
|
|
this.dispatch({
|
|
changes: {
|
|
from: 0,
|
|
to: this.state.doc.length,
|
|
insert: content || "",
|
|
}
|
|
})
|
|
}
|
|
}
|