mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-29 03:23:25 +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 TypeWidget from "./type_widget.js";
|
||||||
import CodeMirror, { type EditorConfig } from "@triliumnext/codemirror";
|
import CodeMirror, { type EditorConfig } from "@triliumnext/codemirror";
|
||||||
|
|
||||||
@ -26,6 +27,7 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
|
|||||||
async #initEditor() {
|
async #initEditor() {
|
||||||
this.codeEditor = new CodeMirror({
|
this.codeEditor = new CodeMirror({
|
||||||
parent: this.$editor[0],
|
parent: this.$editor[0],
|
||||||
|
lineWrapping: options.is("codeLineWrapEnabled"),
|
||||||
...this.getExtraOpts()
|
...this.getExtraOpts()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@ type ContentChangedListener = () => void;
|
|||||||
|
|
||||||
export interface EditorConfig extends EditorViewConfig {
|
export interface EditorConfig extends EditorViewConfig {
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
lineWrapping?: boolean;
|
||||||
onContentChanged?: ContentChangedListener;
|
onContentChanged?: ContentChangedListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +38,10 @@ export default class CodeMirror extends EditorView {
|
|||||||
extensions.push(placeholder(config.placeholder));
|
extensions.push(placeholder(config.placeholder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.lineWrapping) {
|
||||||
|
extensions.push(EditorView.lineWrapping);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.onContentChanged) {
|
if (config.onContentChanged) {
|
||||||
extensions.push(EditorView.updateListener.of((v) => this.#onDocumentUpdated(v)));
|
extensions.push(EditorView.updateListener.of((v) => this.#onDocumentUpdated(v)));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user