mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-29 03:23:25 +08:00 
			
		
		
		
	clipboard is now owned by note tree
This commit is contained in:
		
							parent
							
								
									19c5404d02
								
							
						
					
					
						commit
						dfaa59b0a9
					
				| @ -4,23 +4,23 @@ const contextMenu = (function() { | ||||
|     const treeEl = $("#tree"); | ||||
| 
 | ||||
|     function pasteAfter(node) { | ||||
|         const subjectNode = getNodeByKey(glob.clipboardNoteId); | ||||
|         const subjectNode = getNodeByKey(noteTree.getClipboardNoteId()); | ||||
| 
 | ||||
|         moveAfterNode(subjectNode, node); | ||||
| 
 | ||||
|         glob.clipboardNoteId = null; | ||||
|         noteTree.setClipboardNoteId(null); | ||||
|     } | ||||
| 
 | ||||
|     function pasteInto(node) { | ||||
|         const subjectNode = getNodeByKey(glob.clipboardNoteId); | ||||
|         const subjectNode = getNodeByKey(noteTree.getClipboardNoteId()); | ||||
| 
 | ||||
|         moveToNode(subjectNode, node); | ||||
| 
 | ||||
|         glob.clipboardNoteId = null; | ||||
|         noteTree.setClipboardNoteId(null); | ||||
|     } | ||||
| 
 | ||||
|     function cut(node) { | ||||
|         glob.clipboardNoteId = node.key; | ||||
|         noteTree.setClipboardNoteId(node.key); | ||||
|     } | ||||
| 
 | ||||
|     const contextMenuSettings = { | ||||
| @ -42,8 +42,8 @@ const contextMenu = (function() { | ||||
|         beforeOpen: (event, ui) => { | ||||
|             const node = $.ui.fancytree.getNode(ui.target); | ||||
|             // Modify menu entries depending on node status
 | ||||
|             treeEl.contextmenu("enableEntry", "pasteAfter", glob.clipboardNoteId !== null); | ||||
|             treeEl.contextmenu("enableEntry", "pasteInto", glob.clipboardNoteId !== null); | ||||
|             treeEl.contextmenu("enableEntry", "pasteAfter", noteTree.getClipboardNoteId() !== null); | ||||
|             treeEl.contextmenu("enableEntry", "pasteInto", noteTree.getClipboardNoteId() !== null); | ||||
| 
 | ||||
|             // Activate node on right-click
 | ||||
|             node.setActive(); | ||||
|  | ||||
| @ -4,14 +4,22 @@ const noteTree = (function() { | ||||
|     const noteDetailEl = $('#note-detail'); | ||||
|     const treeEl = $("#tree"); | ||||
|     let treeLoadTime = null; | ||||
|     let clipboardNoteId = null; | ||||
| 
 | ||||
|     glob.allNoteIds = []; | ||||
|     glob.clipboardNoteId = null; | ||||
| 
 | ||||
|     function getTreeLoadTime() { | ||||
|         return treeLoadTime; | ||||
|     } | ||||
| 
 | ||||
|     function getClipboardNoteId() { | ||||
|         return clipboardNoteId; | ||||
|     } | ||||
| 
 | ||||
|     function setClipboardNoteId(cbNoteId) { | ||||
|         clipboardNoteId = cbNoteId; | ||||
|     } | ||||
| 
 | ||||
|     function prepareNoteTree(notes) { | ||||
|         for (const note of notes) { | ||||
|             glob.allNoteIds.push(note.note_id); | ||||
| @ -284,9 +292,11 @@ const noteTree = (function() { | ||||
| 
 | ||||
|     return { | ||||
|         getTreeLoadTime, | ||||
|         getClipboardNoteId, | ||||
|         setClipboardNoteId, | ||||
|         loadTree, | ||||
|         collapseTree, | ||||
|         scrollToCurrentNote, | ||||
|         toggleSearch | ||||
|         toggleSearch, | ||||
|     }; | ||||
| })(); | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner