mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-27 01:51:34 +08:00
chore(code): reintroduce line wrapping
This commit is contained in:
parent
9867cd83c4
commit
2628132350
@ -1,3 +1,4 @@
|
||||
import options from "../../services/options.js";
|
||||
import TypeWidget from "./type_widget.js";
|
||||
import CodeMirror, { type EditorConfig } from "@triliumnext/codemirror";
|
||||
|
||||
@ -26,6 +27,7 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
|
||||
async #initEditor() {
|
||||
this.codeEditor = new CodeMirror({
|
||||
parent: this.$editor[0],
|
||||
lineWrapping: options.is("codeLineWrapEnabled"),
|
||||
...this.getExtraOpts()
|
||||
});
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ type ContentChangedListener = () => void;
|
||||
|
||||
export interface EditorConfig extends EditorViewConfig {
|
||||
placeholder?: string;
|
||||
lineWrapping?: boolean;
|
||||
onContentChanged?: ContentChangedListener;
|
||||
}
|
||||
|
||||
@ -37,6 +38,10 @@ export default class CodeMirror extends EditorView {
|
||||
extensions.push(placeholder(config.placeholder));
|
||||
}
|
||||
|
||||
if (config.lineWrapping) {
|
||||
extensions.push(EditorView.lineWrapping);
|
||||
}
|
||||
|
||||
if (config.onContentChanged) {
|
||||
extensions.push(EditorView.updateListener.of((v) => this.#onDocumentUpdated(v)));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user