mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	chore(code): reintroduce line wrapping
This commit is contained in:
		@@ -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)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user