mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	fixes for indentation and keyboard shortcuts
This commit is contained in:
		
							parent
							
								
									d8b7763dea
								
							
						
					
					
						commit
						93d0e0aa2d
					
				@ -171,6 +171,20 @@ const noteEditor = (function() {
 | 
			
		||||
        return editor;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function focus() {
 | 
			
		||||
        const note = getCurrentNote();
 | 
			
		||||
 | 
			
		||||
        if (note.detail.type === 'text') {
 | 
			
		||||
            noteDetailEl.focus();
 | 
			
		||||
        }
 | 
			
		||||
        else if (note.detail.type === 'code') {
 | 
			
		||||
            codeEditor.focus();
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            throwError('Unrecognized type: ' + note.detail.type);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $(document).ready(() => {
 | 
			
		||||
        noteTitleEl.on('input', () => {
 | 
			
		||||
            noteChanged();
 | 
			
		||||
@ -192,19 +206,17 @@ const noteEditor = (function() {
 | 
			
		||||
                console.error(error);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
        CodeMirror.keyMap.default["Shift-Tab"] = "indentLess";
 | 
			
		||||
        CodeMirror.keyMap.default["Tab"] = "indentMore";
 | 
			
		||||
 | 
			
		||||
        codeEditor = CodeMirror($("#note-detail-code")[0], {
 | 
			
		||||
            value: "",
 | 
			
		||||
            viewportMargin: Infinity
 | 
			
		||||
            viewportMargin: Infinity,
 | 
			
		||||
            indentUnit: 4,
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        codeEditor.on('change', noteChanged);
 | 
			
		||||
 | 
			
		||||
        codeEditor.setOption("extraKeys", {
 | 
			
		||||
            'Ctrl-.': function(cm) {
 | 
			
		||||
                noteTree.scrollToCurrentNote();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        // so that tab jumps from note title (which has tabindex 1)
 | 
			
		||||
        noteDetailEl.attr("tabindex", 2);
 | 
			
		||||
    });
 | 
			
		||||
@ -222,6 +234,7 @@ const noteEditor = (function() {
 | 
			
		||||
        getCurrentNote,
 | 
			
		||||
        getCurrentNoteId,
 | 
			
		||||
        newNoteCreated,
 | 
			
		||||
        getEditor
 | 
			
		||||
        getEditor,
 | 
			
		||||
        focus
 | 
			
		||||
    };
 | 
			
		||||
})();
 | 
			
		||||
@ -4,7 +4,6 @@ const noteTree = (function() {
 | 
			
		||||
    const treeEl = $("#tree");
 | 
			
		||||
    const parentListEl = $("#parent-list");
 | 
			
		||||
    const parentListListEl = $("#parent-list-list");
 | 
			
		||||
    const noteDetailEl = $("#note-detail");
 | 
			
		||||
 | 
			
		||||
    let startNotePath = null;
 | 
			
		||||
    let notesTreeMap = {};
 | 
			
		||||
@ -504,7 +503,9 @@ const noteTree = (function() {
 | 
			
		||||
                return false;
 | 
			
		||||
            },
 | 
			
		||||
            "return": node => {
 | 
			
		||||
                noteDetailEl.focus();
 | 
			
		||||
                noteEditor.focus();
 | 
			
		||||
 | 
			
		||||
                return false;
 | 
			
		||||
            },
 | 
			
		||||
            "backspace": node => {
 | 
			
		||||
                if (!isTopLevelNode(node)) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user