mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	if parent note is encrypted, then child note will be created as encrypted as well
This commit is contained in:
		
							parent
							
								
									9ba958205d
								
							
						
					
					
						commit
						adf18132fb
					
				| @ -125,7 +125,8 @@ def createChild(parent_note_id): | ||||
|         'date_created': now, | ||||
|         'date_modified': now, | ||||
|         'icon_info': 'pencil', | ||||
|         'is_finished': 0 | ||||
|         'is_finished': 0, | ||||
|         'encryption': note['encryption'] | ||||
|     }) | ||||
| 
 | ||||
|     insert("notes_tree", { | ||||
|  | ||||
| @ -141,6 +141,10 @@ setInterval(function() { | ||||
|     } | ||||
| }, 5000); | ||||
| 
 | ||||
| function isEncryptionAvailable() { | ||||
|     return globalEncryptionKey !== null; | ||||
| } | ||||
| 
 | ||||
| function getAes() { | ||||
|     globalLastEncryptionOperationDate = new Date(); | ||||
| 
 | ||||
|  | ||||
| @ -101,23 +101,32 @@ function createNewTopLevelNote() { | ||||
| 
 | ||||
| let newNoteCreated = false; | ||||
| 
 | ||||
| function createNote(node, parentKey, target) { | ||||
|     let newNoteName = "new note"; | ||||
| function createNote(node, parentKey, target, encryption) { | ||||
|     // if encryption isn't available (user didn't enter password yet), then note is created as unencrypted
 | ||||
|     // but this is quite weird since user doesn't see where the note is being created so it shouldn't occur often
 | ||||
|     if (!encryption || !isEncryptionAvailable()) { | ||||
|         encryption = 0; | ||||
|     } | ||||
| 
 | ||||
|     const newNoteName = "new note"; | ||||
|     const newNoteNameEncryptedIfNecessary = encryption > 0 ? encryptString(newNoteName) : newNoteName; | ||||
| 
 | ||||
|     $.ajax({ | ||||
|         url: baseUrl + 'notes/' + parentKey + '/children' , | ||||
|         type: 'POST', | ||||
|         data: JSON.stringify({ | ||||
|             note_title: newNoteName, | ||||
|             note_title: newNoteNameEncryptedIfNecessary, | ||||
|             target: target, | ||||
|             target_note_id: node.key | ||||
|             target_note_id: node.key, | ||||
|             encryption: encryption | ||||
|         }), | ||||
|         contentType: "application/json", | ||||
|         success: function(result) { | ||||
|             let newNode = { | ||||
|                 "title": newNoteName, | ||||
|                 "key": result.note_id, | ||||
|                 "note_id": result.note_id | ||||
|                 title: newNoteName, | ||||
|                 key: result.note_id, | ||||
|                 note_id: result.note_id, | ||||
|                 encryption: encryption | ||||
|             }; | ||||
| 
 | ||||
|             globalAllNoteIds.push(result.note_id); | ||||
|  | ||||
| @ -70,14 +70,19 @@ function getParentKey(node) { | ||||
|     return (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key; | ||||
| } | ||||
| 
 | ||||
| function getParentEncryption(node) { | ||||
|     return node.getParent() === null ? 0 : node.getParent().data.encryption; | ||||
| } | ||||
| 
 | ||||
| const keybindings = { | ||||
|     "insert": function(node) { | ||||
|         const parentKey = getParentKey(node); | ||||
|         const encryption = getParentEncryption(node); | ||||
| 
 | ||||
|         createNote(node, parentKey, 'after'); | ||||
|         createNote(node, parentKey, 'after', encryption); | ||||
|     }, | ||||
|     "ctrl+insert": function(node) { | ||||
|         createNote(node, node.key, 'into'); | ||||
|         createNote(node, node.key, 'into', node.data.encryption); | ||||
|     }, | ||||
|     "del": function(node) { | ||||
|         deleteNode(node); | ||||
| @ -330,8 +335,9 @@ $(function(){ | ||||
| 
 | ||||
|                 if (ui.cmd === "insertNoteHere") { | ||||
|                     const parentKey = getParentKey(node); | ||||
|                     const encryption = getParentEncryption(node); | ||||
| 
 | ||||
|                     createNote(node, parentKey, 'after'); | ||||
|                     createNote(node, parentKey, 'after', encryption); | ||||
|                 } | ||||
|                 else if (ui.cmd === "insertChildNote") { | ||||
|                     createNote(node, node.key, 'into'); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner