mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	moved isNewNoteCreated into note_editor
This commit is contained in:
		
							parent
							
								
									0ec6d4baa8
								
							
						
					
					
						commit
						f6aae68063
					
				| @ -127,11 +127,17 @@ const noteEditor = (function() { | |||||||
|         noteTree.setCurrentNoteTreeBasedOnProtectedStatus(); |         noteTree.setCurrentNoteTreeBasedOnProtectedStatus(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     let isNewNoteCreated = false; | ||||||
|  | 
 | ||||||
|  |     function newNoteCreated() { | ||||||
|  |         isNewNoteCreated = true; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     async function loadNoteToEditor(noteId) { |     async function loadNoteToEditor(noteId) { | ||||||
|         currentNote = await $.get(baseApiUrl + 'notes/' + noteId); |         currentNote = await $.get(baseApiUrl + 'notes/' + noteId); | ||||||
| 
 | 
 | ||||||
|         if (noteTree.isNewNoteCreated()) { |         if (isNewNoteCreated) { | ||||||
|             noteTree.switchOffNewNoteCreated(); |             isNewNoteCreated = false; | ||||||
| 
 | 
 | ||||||
|             noteTitleEl.focus().select(); |             noteTitleEl.focus().select(); | ||||||
|         } |         } | ||||||
| @ -165,9 +171,7 @@ const noteEditor = (function() { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async function loadNote(noteId) { |     async function loadNote(noteId) { | ||||||
|         const note = await $.get(baseApiUrl + 'notes/' + noteId); |         return await $.get(baseApiUrl + 'notes/' + noteId); | ||||||
| 
 |  | ||||||
|         return note; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     $(document).ready(() => { |     $(document).ready(() => { | ||||||
| @ -199,6 +203,7 @@ const noteEditor = (function() { | |||||||
|         loadNote, |         loadNote, | ||||||
|         getCurrentNote, |         getCurrentNote, | ||||||
|         getCurrentNoteId, |         getCurrentNoteId, | ||||||
|         getCurrentNoteLoadTime |         getCurrentNoteLoadTime, | ||||||
|  |         newNoteCreated | ||||||
|     }; |     }; | ||||||
| })(); | })(); | ||||||
| @ -1,7 +1,6 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const noteTree = (function() { | const noteTree = (function() { | ||||||
|     const noteDetailEl = $('#note-detail'); |  | ||||||
|     const treeEl = $("#tree"); |     const treeEl = $("#tree"); | ||||||
|     const parentListEl = $("#parent-list"); |     const parentListEl = $("#parent-list"); | ||||||
| 
 | 
 | ||||||
| @ -15,12 +14,6 @@ const noteTree = (function() { | |||||||
|     let parentChildToNoteTreeId = {}; |     let parentChildToNoteTreeId = {}; | ||||||
|     let noteIdToTitle = {}; |     let noteIdToTitle = {}; | ||||||
| 
 | 
 | ||||||
|     function getNoteTreeIdFromKey(key) { |  | ||||||
|         const node = treeUtils.getNodeByKey(key); |  | ||||||
| 
 |  | ||||||
|         return node.note_tree_id; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     function getTreeLoadTime() { |     function getTreeLoadTime() { | ||||||
|         return treeLoadTime; |         return treeLoadTime; | ||||||
|     } |     } | ||||||
| @ -316,10 +309,6 @@ const noteTree = (function() { | |||||||
|                 if (toNode !== null) { |                 if (toNode !== null) { | ||||||
|                     treeChanges.moveToNode(node, toNode); |                     treeChanges.moveToNode(node, toNode); | ||||||
|                 } |                 } | ||||||
|             }, |  | ||||||
|             "return": node => { |  | ||||||
|                 // doesn't work :-/
 |  | ||||||
|                 noteDetailEl.summernote('focus'); |  | ||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
| @ -500,11 +489,6 @@ const noteTree = (function() { | |||||||
|         return treeEl.fancytree("getActiveNode"); |         return treeEl.fancytree("getActiveNode"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function getCurrentNoteTreeId() { |  | ||||||
|         const node = getCurrentNode(); |  | ||||||
|         return node.data.note_tree_id; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     function getCurrentNotePath() { |     function getCurrentNotePath() { | ||||||
|         const node = getCurrentNode(); |         const node = getCurrentNode(); | ||||||
| 
 | 
 | ||||||
| @ -580,20 +564,10 @@ const noteTree = (function() { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function createNewTopLevelNote() { |     async function createNewTopLevelNote() { | ||||||
|         let rootNode = treeEl.fancytree("getRootNode"); |         const rootNode = treeEl.fancytree("getRootNode"); | ||||||
| 
 | 
 | ||||||
|         createNote(rootNode, "root", "into"); |         await createNote(rootNode, "root", "into"); | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     let newNoteCreated = false; |  | ||||||
| 
 |  | ||||||
|     function isNewNoteCreated() { |  | ||||||
|         return newNoteCreated; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     function switchOffNewNoteCreated() { |  | ||||||
|         newNoteCreated = false; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async function createNote(node, parentNoteId, target, isProtected) { |     async function createNote(node, parentNoteId, target, isProtected) { | ||||||
| @ -633,7 +607,7 @@ const noteTree = (function() { | |||||||
| 
 | 
 | ||||||
|         noteIdToTitle[result.note_id] = newNoteName; |         noteIdToTitle[result.note_id] = newNoteName; | ||||||
| 
 | 
 | ||||||
|         newNoteCreated = true; |         noteEditor.newNoteCreated(); | ||||||
| 
 | 
 | ||||||
|         if (target === 'after') { |         if (target === 'after') { | ||||||
|             node.appendSibling(newNode).setActive(true); |             node.appendSibling(newNode).setActive(true); | ||||||
| @ -678,10 +652,8 @@ const noteTree = (function() { | |||||||
|         collapseTree, |         collapseTree, | ||||||
|         scrollToCurrentNote, |         scrollToCurrentNote, | ||||||
|         toggleSearch, |         toggleSearch, | ||||||
|         getNoteTreeIdFromKey, |  | ||||||
|         setCurrentNoteTreeBasedOnProtectedStatus, |         setCurrentNoteTreeBasedOnProtectedStatus, | ||||||
|         getCurrentNode, |         getCurrentNode, | ||||||
|         getCurrentNoteTreeId, |  | ||||||
|         activateNode, |         activateNode, | ||||||
|         getCurrentNotePath, |         getCurrentNotePath, | ||||||
|         getNoteTitle, |         getNoteTitle, | ||||||
| @ -689,8 +661,6 @@ const noteTree = (function() { | |||||||
|         getAutocompleteItems, |         getAutocompleteItems, | ||||||
|         setCurrentNoteTitle, |         setCurrentNoteTitle, | ||||||
|         createNewTopLevelNote, |         createNewTopLevelNote, | ||||||
|         createNote, |         createNote | ||||||
|         isNewNoteCreated, |  | ||||||
|         switchOffNewNoteCreated |  | ||||||
|     }; |     }; | ||||||
| })(); | })(); | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner