2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								import  hoistedNoteService  from  "../services/hoisted_note.js" ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  treeService  from  "../services/tree.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  utils  from  "../services/utils.js" ;  
						 
					
						
							
								
									
										
										
										
											2022-08-05 16:44:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  contextMenu  from  "../menus/context_menu.js" ;  
						 
					
						
							
								
									
										
										
										
											2021-04-16 23:01:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  froca  from  "../services/froca.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-02-17 19:42:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  branchService  from  "../services/branches.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  ws  from  "../services/ws.js" ;  
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:35:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  NoteContextAwareWidget  from  "./note_context_aware_widget.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  server  from  "../services/server.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-02-03 20:07:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  noteCreateService  from  "../services/note_create.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-02-14 20:18:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  toastService  from  "../services/toast.js" ;  
						 
					
						
							
								
									
										
										
										
											2022-12-01 13:07:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  appContext  from  "../components/app_context.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  keyboardActionsService  from  "../services/keyboard_actions.js" ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  clipboard  from  "../services/clipboard.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  protectedSessionService  from  "../services/protected_session.js" ;  
						 
					
						
							
								
									
										
										
										
											2022-09-13 23:36:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  linkService  from  "../services/link.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  options  from  "../services/options.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-09-23 22:45:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  protectedSessionHolder  from  "../services/protected_session_holder.js" ;  
						 
					
						
							
								
									
										
										
										
											2022-11-25 15:29:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  dialogService  from  "../services/dialog.js" ;  
						 
					
						
							
								
									
										
										
										
											2022-12-01 00:17:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  shortcutService  from  "../services/shortcuts.js" ;  
						 
					
						
							
								
									
										
										
										
											2024-09-13 22:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  {  t  }  from  "../services/i18n.js" ;  
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  TPL  =  ` 
  
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< div  class = "tree-wrapper" >  
						 
					
						
							
								
									
										
										
										
											2020-01-12 20:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < style > 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    . tree - wrapper  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 20:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        flex - grow :  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        flex - shrink :  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        flex - basis :  60 % ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        font - family :  var ( -- tree - font - family ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        font - size :  var ( -- tree - font - size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        position :  relative ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        min - height :  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    . tree  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        height :  100 % ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        overflow :  auto ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-08 23:25:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        padding - bottom :  35 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 23:20:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        padding - top :  5 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 20:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-27 23:17:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 20:26:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    . tree - actions  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        background - color :  var ( -- launcher - pane - background - color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        z - index :  100 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        position :  absolute ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        bottom :  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        display :  flex ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        align - items :  flex - end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        justify - content :  flex - end ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-24 14:46:09 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        right :  17 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-24 15:17:17 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        border - radius :  7 px ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        border :  1 px  solid  var ( -- main - border - color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 20:26:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2021-05-27 23:17:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    button . tree - floating - button  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-24 15:17:17 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        margin :  1 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-27 23:17:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        font - size :  1.5 em ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 20:26:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        padding :  5 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-27 23:17:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        max - height :  34 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-06 22:15:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        color :  var ( -- launcher - pane - text - color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-01 23:19:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        background - color :  var ( -- button - background - color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-27 23:17:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        border - radius :  var ( -- button - border - radius ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        border :  1 px  solid  transparent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    button . tree - floating - button : hover  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        border :  1 px  solid  var ( -- button - border - color ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    . collapse - tree - button  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        right :  100 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 20:40:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    . scroll - to - active - note - button  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-27 23:17:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        right :  55 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 20:40:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    . tree - settings - button  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 22:02:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        right :  10 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    . tree - settings - popup  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        display :  none ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        position :  absolute ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        background - color :  var ( -- accented - background - color ) ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        border :  1 px  solid  var ( -- main - border - color ) ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        padding :  20 px ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        z - index :  1000 ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-27 23:17:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        width :  340 px ;  
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 22:02:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        border - radius :  10 px ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-05 16:44:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    . tree  . hidden - node - is - hidden  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        display :  none ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 20:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < / s t y l e > 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2021-05-27 23:17:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = "tree" > < / d i v > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 20:26:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < div  class = "tree-actions" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < button  class = "tree-floating-button bx bx-layer-minus collapse-tree-button"  
							 
						 
					
						
							
								
									
										
										
										
											2024-09-13 22:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                title = "${t(" note _tree . collapse - title ")}"  
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 20:26:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                data - trigger - command = "collapseTree" > < / b u t t o n > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < button  class = "tree-floating-button bx bx-crosshair scroll-to-active-note-button"  
							 
						 
					
						
							
								
									
										
										
										
											2024-09-13 22:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                title = "${t(" note _tree . scroll - active - title ")}"  
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 20:26:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                data - trigger - command = "scrollToActiveNote" > < / b u t t o n > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        
							 
						 
					
						
							
								
									
										
										
										
											2024-09-09 20:30:35 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < button  class = "tree-floating-button bx bxs-tree tree-settings-button"  
							 
						 
					
						
							
								
									
										
										
										
											2024-09-13 22:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                title = "${t(" note _tree . tree - settings - title ")}" > < / b u t t o n > 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-09 20:26:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < / d i v > 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 20:40:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < div  class = "tree-settings-popup" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = "form-check" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < label  class = "form-check-label" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < input  class = "form-check-input hide-archived-notes"  type = "checkbox"  value = "" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            
							 
						 
					
						
							
								
									
										
										
										
											2024-09-13 22:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $ { t ( "note_tree.hide-archived-notes" ) } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            < / l a b e l > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / d i v > 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < div  class = "form-check" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < label  class = "form-check-label" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < input  class = "form-check-input auto-collapse-note-tree"  type = "checkbox"  value = "" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                
							 
						 
					
						
							
								
									
										
										
										
											2024-09-13 22:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $ { t ( "note_tree.automatically-collapse-notes" ) } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                < span  class = "bx bx-info-circle"  
							 
						 
					
						
							
								
									
										
										
										
											2024-09-13 22:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                      title = "${t(" note _tree . automatically - collapse - notes - title ")}" > < / s p a n > 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            < / l a b e l > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < / d i v > 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < br / > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
									
										
										
										
											2024-09-13 22:22:16 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        < button  class = "btn btn-sm btn-primary save-tree-settings-button"  type = "submit" > $ { t ( "note_tree.save-changes" ) } < / b u t t o n > 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    < / d i v > 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 20:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< / d i v >  
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								` ;
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 23:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  MAX _SEARCH _RESULTS _IN _TREE  =  100 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-13 00:12:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// this has to be hanged on the actual elements to effectively intercept and stop click event
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  cancelClickPropagation  =  e  =>  e . stopPropagation ( ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:35:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								export  default  class  NoteTreeWidget  extends  NoteContextAwareWidget  {  
						 
					
						
							
								
									
										
										
										
											2022-12-11 13:54:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    constructor ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        super ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 13:54:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . treeName  =  "main" ;  // legacy value
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 20:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    doRender ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-08 21:54:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $widget  =  $ ( TPL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $tree  =  this . $widget . find ( '.tree' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 20:37:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $treeActions  =  this . $widget . find ( ".tree-actions" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 19:58:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $tree . on ( "mousedown" ,  ".unhoist-button" ,  ( )  =>  hoistedNoteService . unhoist ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . $tree . on ( "mousedown" ,  ".refresh-search-button" ,  e  =>  this . refreshSearch ( e ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . $tree . on ( "mousedown" ,  ".add-note-button" ,  e  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 23:13:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  node  =  $ . ui . fancytree . getNode ( e ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-03 22:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  parentNotePath  =  treeService . getNotePath ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 23:13:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-03 22:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            noteCreateService . createNote ( parentNotePath ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 23:13:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                isProtected :  node . data . isProtected 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 19:58:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $tree . on ( "mousedown" ,  ".enter-workspace-button" ,  e  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-29 22:32:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  node  =  $ . ui . fancytree . getNode ( e ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . triggerCommand ( 'hoistNote' ,  { noteId :  node . data . noteId } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 11:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // fancytree doesn't support middle click, so this is a way to support it
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $tree . on ( 'mousedown' ,  '.fancytree-title' ,  e  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            if  ( e . which  ===  2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  node  =  $ . ui . fancytree . getNode ( e ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 20:57:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  notePath  =  treeService . getNotePath ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( notePath )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-24 23:24:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    appContext . tabManager . openTabWithNoteWithHoisting ( notePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 20:57:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                e . stopPropagation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                e . preventDefault ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 20:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $treeSettingsPopup  =  this . $widget . find ( '.tree-settings-popup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . $hideArchivedNotesCheckbox  =  this . $treeSettingsPopup . find ( '.hide-archived-notes' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $autoCollapseNoteTree  =  this . $treeSettingsPopup . find ( '.auto-collapse-note-tree' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . $treeSettingsButton  =  this . $widget . find ( '.tree-settings-button' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . $treeSettingsButton . on ( "click" ,  e  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( this . $treeSettingsPopup . is ( ":visible" ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                this . $treeSettingsPopup . hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . $hideArchivedNotesCheckbox . prop ( "checked" ,  this . hideArchivedNotes ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . $autoCollapseNoteTree . prop ( "checked" ,  this . autoCollapseNoteTree ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 20:37:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  top  =  this . $treeActions [ 0 ] . offsetTop  -  ( this . $treeSettingsPopup . outerHeight ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  left  =  Math . max ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                this . $treeActions [ 0 ] . offsetLeft  -  this . $treeSettingsPopup . outerWidth ( )  +  this . $treeActions . outerWidth ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . $treeSettingsPopup . css ( { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-23 20:37:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                top , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                left 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) . show ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 13:52:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $treeSettingsPopup . on ( "click" ,  e  =>  { e . stopPropagation ( ) ; } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 13:52:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $ ( document ) . on ( 'click' ,  ( )  =>  this . $treeSettingsPopup . hide ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $saveTreeSettingsButton  =  this . $treeSettingsPopup . find ( '.save-tree-settings-button' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . $saveTreeSettingsButton . on ( 'click' ,  async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            await  this . setHideArchivedNotes ( this . $hideArchivedNotesCheckbox . prop ( "checked" ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            await  this . setAutoCollapseNoteTree ( this . $autoCollapseNoteTree . prop ( "checked" ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . $treeSettingsPopup . hide ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . reloadTreeFromCache ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 21:27:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // note tree starts initializing already during render which is atypical
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Promise . all ( [ options . initializedPromise ,  froca . initializedPromise ] ) . then ( ( )  =>  this . initFancyTree ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 20:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-22 22:28:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . setupNoteTitleTooltip ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-22 22:28:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    setupNoteTitleTooltip ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // the following will dynamically set tree item's tooltip if the whole item's text is not currently visible
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // if the whole text is visible then no tooltip is show since that's unnecessarily distracting
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // see https://github.com/zadam/trilium/pull/1120 for discussion
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // code inspired by https://gist.github.com/jtsternberg/c272d7de5b967cec2d3d
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  isEnclosing  =  ( $container ,  $sub )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  conOffset  =  $container . offset ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  conDistanceFromTop  =  conOffset . top  +  $container . outerHeight ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-22 22:28:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  conDistanceFromLeft  =  conOffset . left  +  $container . outerWidth ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  subOffset  =  $sub . offset ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  subDistanceFromTop  =  subOffset . top  +  $sub . outerHeight ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-22 22:28:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  subDistanceFromLeft  =  subOffset . left  +  $sub . outerWidth ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  conDistanceFromTop  >  subDistanceFromTop 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                &&  conOffset . top  <  subOffset . top 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                &&  conDistanceFromLeft  >  subDistanceFromLeft 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                &&  conOffset . left  <  subOffset . left ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . $tree . on ( "mouseenter" ,  "span.fancytree-title" ,  e  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            e . currentTarget . title  =  isEnclosing ( this . $tree ,  $ ( e . currentTarget ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ?  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                :  e . currentTarget . innerText ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    get  hideArchivedNotes ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 15:19:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  options . is ( ` hideArchivedNotes_ ${ this . treeName } ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async  setHideArchivedNotes ( val )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 15:19:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  options . save ( ` hideArchivedNotes_ ${ this . treeName } ` ,  val . toString ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    get  autoCollapseNoteTree ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  options . is ( "autoCollapseNoteTree" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async  setAutoCollapseNoteTree ( val )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  options . save ( "autoCollapseNoteTree" ,  val . toString ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    initFancyTree ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  treeData  =  [ this . prepareRootNode ( ) ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $tree . fancytree ( { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:06:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            titlesTabbable :  true , 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            keyboard :  true , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-22 23:05:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            extensions :  [ "dnd5" ,  "clones" ,  "filter" ] , 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            source :  treeData , 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-09 23:20:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            scrollOfs :  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                top :  100 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                bottom :  100 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-09 23:20:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            scrollParent :  this . $tree , 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            minExpandLevel :  2 ,  // root can't be collapsed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            click :  ( event ,  data )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                this . activityDetected ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  targetType  =  data . targetType ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  node  =  data . node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 13:57:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( node . isSelected ( )  &&  targetType  ===  'icon' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    this . triggerCommand ( 'openBulkActionsDialog' ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        selectedOrActiveNoteIds :  this . getSelectedOrActiveNoteIds ( node ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                else  if  ( targetType  ===  'title'  ||  targetType  ===  'icon' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( event . shiftKey )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 09:42:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  activeNode  =  this . getActiveNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( activeNode . getParent ( )  !==  node . getParent ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        this . clearSelectedNodes ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        function  selectInBetween ( first ,  second )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            for  ( let  i  =  0 ;  first  &&  first  !==  second  &&  i  <  10000 ;  i ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                first . setSelected ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                first  =  first . getNextSibling ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            second . setSelected ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( activeNode . getIndex ( )  <  node . getIndex ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            selectInBetween ( activeNode ,  node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            selectInBetween ( node ,  activeNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        node . setFocus ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 23:16:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    else  if  ( ( ! utils . isMac ( )  &&  event . ctrlKey )  ||  ( utils . isMac ( )  &&  event . metaKey ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 20:57:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  notePath  =  treeService . getNotePath ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-24 23:24:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        appContext . tabManager . openTabWithNoteWithHoisting ( notePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 09:42:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    else  if  ( event . altKey )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        node . setSelected ( ! node . isSelected ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        node . setFocus ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-01 15:19:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    else  if  ( data . node . isActive ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        // this is important for single column mobile view, otherwise it's not possible to see again previously displayed note
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        this . tree . reactivate ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        node . setActive ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 22:52:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            beforeActivate :  ( event ,  { node } )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-15 09:48:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // hidden subtree is hidden hackily - we want it to be present in the tree so that we can switch to it
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // without reloading the whole tree, but we want it to be hidden when hoisted to root. FancyTree allows
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // filtering the display only by ascendant - i.e. if the root is visible, all the descendants are as well.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // We solve it by hiding the hidden subtree via CSS (class "hidden-node-is-hidden"),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // but then we need to prevent activating it, e.g. by keyboard
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:01:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( hoistedNoteService . getHoistedNoteId ( )  ===  '_hidden' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // if we're hoisted in hidden subtree, we want to avoid crossing to "visible" tree,
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 22:52:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    // which could happen via UP key from hidden root
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  node . data . noteId  !==  'root' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:01:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // we're not hoisted to hidden subtree, the only way to cross is via DOWN key to the hidden root
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 22:52:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                return  node . data . noteId  !==  '_hidden' ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-05 16:44:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            activate :  async  ( event ,  data )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // click event won't propagate so let's close context menu manually
 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-29 11:28:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                contextMenu . hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 20:38:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                this . clearSelectedNodes ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 20:57:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  notePath  =  treeService . getNotePath ( data . node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:35:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  activeNoteContext  =  appContext . tabManager . getActiveContext ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:26:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                await  activeNoteContext . setNote ( notePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            expand :  ( event ,  data )  =>  this . setExpanded ( data . node . data . branchId ,  true ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            collapse :  ( event ,  data )  =>  this . setExpanded ( data . node . data . branchId ,  false ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-22 23:05:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            filter :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                counter :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                mode :  "hide" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                autoExpand :  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            dnd5 :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                autoExpandMS :  600 , 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-28 21:19:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                preventLazyParents :  false , 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                dragStart :  ( node ,  data )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 16:11:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( [ 'root' ,  '_hidden' ,  '_lbRoot' ,  '_lbAvailableLaunchers' ,  '_lbVisibleLaunchers' ] . includes ( node . data . noteId ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ||  node . data . noteId . startsWith ( "_options" ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-26 14:57:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-11 15:09:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    const  notes  =  this . getSelectedOrActiveNodes ( node ) . map ( node  =>  ( { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        noteId :  node . data . noteId , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 10:30:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        branchId :  node . data . branchId , 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        title :  node . title 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-28 22:07:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-13 23:36:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( notes . length  ===  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-27 10:38:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        linkService . createLink ( notes [ 0 ] . noteId ,  { referenceLink :  true ,  autoConvertToImage :  true } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-13 23:36:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            . then ( $link  =>  data . dataTransfer . setData ( "text/html" ,  $link [ 0 ] . outerHTML ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-27 10:38:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        Promise . all ( notes . map ( note  =>  linkService . createLink ( note . noteId ,  { referenceLink :  true ,  autoConvertToImage :  true } ) ) ) . then ( links  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-13 23:36:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            const  $list  =  $ ( "<ul>" ) . append ( ... links . map ( $link  =>  $ ( "<li>" ) . append ( $link ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            data . dataTransfer . setData ( "text/html" ,  $list [ 0 ] . outerHTML ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    data . dataTransfer . setData ( "text" ,  JSON . stringify ( notes ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    return  true ;  // allow dragging to start
 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-26 14:57:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                dragEnter :  ( node ,  data )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( node . data . noteType  ===  'search' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 16:11:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    }  else  if  ( node . data . noteId  ===  '_lbRoot' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-26 14:57:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 16:11:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    }  else  if  ( node . data . noteId . startsWith ( '_options' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-08 15:29:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 10:16:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    }  else  if  ( node . data . noteType  ===  'launcher' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-26 14:57:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  [ 'before' ,  'after' ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-24 07:22:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    }  else  if  ( [ '_lbAvailableLaunchers' ,  '_lbVisibleLaunchers' ] . includes ( node . data . noteId ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return  [ 'over' ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-26 14:57:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                dragDrop :  async  ( node ,  data )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( ( data . hitMode  ===  'over'  &&  node . data . noteType  ===  'search' )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        ( [ 'after' ,  'before' ] . includes ( data . hitMode ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-05 22:08:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            &&  ( node . data . noteId  ===  hoistedNoteService . getHoistedNoteId ( )  ||  node . getParent ( ) . data . noteType  ===  'search' ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-16 19:53:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        await  dialogService . info ( "Dropping notes into this location is not allowed." ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    const  dataTransfer  =  data . dataTransfer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( dataTransfer  &&  dataTransfer . files  &&  dataTransfer . files . length  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        const  files  =  [ ... dataTransfer . files ] ;  // chrome has issue that dataTransfer.files empties after async operation
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-09 22:32:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  importService  =  await  import ( '../services/import.js' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-08 00:02:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        importService . uploadFiles ( 'notes' ,  node . data . noteId ,  files ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            safeImport :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            shrinkImages :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            textImportedAsText :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            codeImportedAsCode :  true , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 16:15:00 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            explodeArchives :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            replaceUnderscoresWithSpaces :  true 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 10:30:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  jsonStr  =  dataTransfer . getData ( "text" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        let  notes  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            notes  =  JSON . parse ( jsonStr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        catch  ( e )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-17 23:04:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            logError ( ` Cannot parse JSON ' ${ jsonStr } ' into notes for drop ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 10:30:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        // This function MUST be defined to enable dropping of items on the tree.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        // data.hitMode is 'before', 'after', or 'over'.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 10:30:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  selectedBranchIds  =  notes . map ( note  =>  note . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( data . hitMode  ===  "before" )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 19:42:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            branchService . moveBeforeBranch ( selectedBranchIds ,  node . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        }  else  if  ( data . hitMode  ===  "after" )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 19:42:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            branchService . moveAfterBranch ( selectedBranchIds ,  node . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        }  else  if  ( data . hitMode  ===  "over" )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 10:30:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            branchService . moveToParentNote ( selectedBranchIds ,  node . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-04 22:16:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            throw  new  Error ( ` Unknown hitMode ' ${ data . hitMode } ' ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            lazyLoad :  ( event ,  data )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 12:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  { noteId ,  noteType }  =  data . node . data ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( noteType  ===  'search' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    const  notePath  =  treeService . getNotePath ( data . node . getParent ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // this is a search cycle (search note is a descendant of its own search result)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( notePath . includes ( noteId ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        data . result  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    data . result  =  froca . loadSearchNote ( noteId ) . then ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        const  note  =  froca . getNoteFromCache ( noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 23:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        let  childNoteIds  =  note . getChildNoteIds ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 22:01:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        if  ( note . type  ===  'search'  &&  childNoteIds . length  >  MAX _SEARCH _RESULTS _IN _TREE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 23:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            childNoteIds  =  childNoteIds . slice ( 0 ,  MAX _SEARCH _RESULTS _IN _TREE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  froca . getNotes ( childNoteIds ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 23:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } ) . then ( ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        const  note  =  froca . getNoteFromCache ( noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 23:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return  this . prepareChildren ( note ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    data . result  =  froca . loadSubTree ( noteId ) . then ( note  =>  this . prepareChildren ( note ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            clones :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                highlightActiveClones :  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 22:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            enhanceTitle :  async  function  ( event ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  node  =  data . node ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 23:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ! node . data . noteId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // if there's "non-note" node, then don't enhance
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // this can happen for e.g. "Load error!" node
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-26 21:28:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  note  =  await  froca . getNote ( node . data . noteId ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-26 21:11:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 16:26:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( ! note )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-26 21:11:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:35:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  activeNoteContext  =  appContext . tabManager . getActiveContext ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-06 19:58:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 22:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  $span  =  $ ( node . span ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-15 23:05:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $span . find ( '.tree-item-button' ) . remove ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 23:13:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:26:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  isHoistedNote  =  activeNoteContext  &&  activeNoteContext . hoistedNoteId  ===  note . noteId  &&  note . noteId  !==  'root' ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-07 20:55:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( note . hasLabel ( 'workspace' )  &&  ! isHoistedNote )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-13 00:12:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    const  $enterWorkspaceButton  =  $ ( '<span class="tree-item-button enter-workspace-button bx bx-door-open" title="Hoist this note (workspace)"></span>' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        . on ( "click" ,  cancelClickPropagation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-29 22:32:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $span . append ( $enterWorkspaceButton ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 23:13:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( note . type  ===  'search' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-13 00:12:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    const  $refreshSearchButton  =  $ ( '<span class="tree-item-button refresh-search-button bx bx-refresh" title="Refresh saved search results"></span>' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        . on ( "click" ,  cancelClickPropagation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 23:13:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $span . append ( $refreshSearchButton ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-09 16:04:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( ! [ 'search' ,  'launcher' ] . includes ( note . type )  &&  ! note . isOptions ( )  &&  ! note . isLaunchBarConfig ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-13 00:12:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    const  $createChildNoteButton  =  $ ( '<span class="tree-item-button add-note-button bx bx-plus" title="Create child note"></span>' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        . on ( "click" ,  cancelClickPropagation ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 22:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 23:13:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    $span . append ( $createChildNoteButton ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 22:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 22:28:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( isHoistedNote )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    const  $unhoistButton  =  $ ( '<span class="tree-item-button unhoist-button bx bx-door-open" title="Unhoist"></span>' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        . on ( "click" ,  cancelClickPropagation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $span . append ( $unhoistButton ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 22:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-30 23:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // this is done to automatically lazy load all expanded notes after tree load
 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            loadChildren :  ( event ,  data )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:15:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                data . node . visit ( ( subNode )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // Load all lazy/unloaded child nodes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // (which will trigger `loadChildren` recursively)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( subNode . isUndefined ( )  &&  subNode . isExpanded ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        subNode . load ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 17:29:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 13:57:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            select :  ( event ,  { node } )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 16:57:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( hoistedNoteService . getHoistedNoteId ( )  ===  'root' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    &&  node . data . noteId  ===  '_hidden' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    &&  node . isSelected ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // hidden is hackily hidden from the tree via CSS when root is hoisted
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // make sure it's not selected by mistake, it could be e.g. deleted by mistake otherwise
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    node . setSelected ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 13:57:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $ ( node . span ) . find ( ".fancytree-custom-icon" ) . attr ( "title" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    node . isSelected ( )  ?  "Apply bulk actions on selected notes"  :  "" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 22:12:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! utils . isMobile ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . getHotKeys ( ) . then ( hotKeys  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                for  ( const  key  in  hotKeys )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    const  handler  =  hotKeys [ key ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $ ( this . tree . $container ) . on ( 'keydown' ,  null ,  key ,  evt  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        const  node  =  this . tree . getActiveNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return  handler ( node ,  evt ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        // return false from the handler will stop default handling.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $tree . on ( 'contextmenu' ,  '.fancytree-node' ,  e  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  node  =  $ . ui . fancytree . getNode ( e ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-16 16:00:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  note  =  froca . getNoteFromCache ( node . data . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-16 16:00:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( note . isLaunchBarConfig ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                import ( "../menus/launcher_context_menu.js" ) . then ( ( { default :  LauncherContextMenu } )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    const  launcherContextMenu  =  new  LauncherContextMenu ( this ,  node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    launcherContextMenu . show ( e ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-05 16:44:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                import ( "../menus/tree_context_menu.js" ) . then ( ( { default :  TreeContextMenu } )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    const  treeContextMenu  =  new  TreeContextMenu ( this ,  node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    treeContextMenu . show ( e ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  false ;  // blocks default browser right click menu
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . tree  =  $ . ui . fancytree . getTree ( this . $tree ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    prepareRootNode ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 13:09:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  this . prepareNode ( froca . getBranch ( 'none_root' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-03 13:35:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *  @ param  { FNote }  parentNote 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    prepareChildren ( parentNote )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        utils . assertArguments ( parentNote ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  noteList  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  hideArchivedNotes  =  this . hideArchivedNotes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 20:07:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        let  childBranches  =  parentNote . getFilteredChildBranches ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 23:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-06 20:31:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( parentNote . type  ===  'search'  &&  childBranches . length  >  MAX _SEARCH _RESULTS _IN _TREE )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 23:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            childBranches  =  childBranches . slice ( 0 ,  MAX _SEARCH _RESULTS _IN _TREE ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  branch  of  childBranches )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( hideArchivedNotes )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  note  =  branch . getNoteFromCache ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( note . hasLabel ( 'archived' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  node  =  this . prepareNode ( branch ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 20:15:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                noteList . push ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  noteList ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  updateNode ( node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  note  =  froca . getNoteFromCache ( node . data . noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  branch  =  froca . getBranch ( node . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-17 20:59:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! note )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-14 22:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            console . log ( ` Node update not possible because note ' ${ node . data . noteId } ' was not found. ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-17 20:59:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-14 22:21:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  if  ( ! branch )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            console . log ( ` Node update not possible because branch ' ${ node . data . branchId } ' was not found. ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-17 20:59:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 15:19:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  title  =  ` ${ branch . prefix  ?  ( ` ${ branch . prefix }  -  ` )  :  "" } ${ note . title } ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-24 22:29:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        node . data . isProtected  =  note . isProtected ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        node . data . noteType  =  note . type ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 20:07:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        node . folder  =  note . isFolder ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        node . icon  =  note . getIcon ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-24 22:29:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        node . extraClasses  =  this . getExtraClasses ( note ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        node . title  =  utils . escapeHtml ( title ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( node . isExpanded ( )  !==  branch . isExpanded )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            await  node . setExpanded ( branch . isExpanded ,  { noEvents :  true ,  noAnimation :  true } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-24 22:29:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-24 14:39:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        node . renderTitle ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-24 22:29:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-03 13:35:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *  @ param  { FBranch }  branch 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-17 23:13:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *  @ param  { boolean }  forceLazy 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-28 14:29:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    prepareNode ( branch ,  forceLazy  =  false )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  note  =  branch . getNoteFromCache ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! note )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-25 20:15:12 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            console . warn ( ` Branch ' ${ branch . branchId } ' has no child note ' ${ branch . noteId } ' ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 15:19:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  title  =  ` ${ branch . prefix  ?  ( ` ${ branch . prefix }  -  ` )  :  "" } ${ note . title } ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-13 20:07:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  isFolder  =  note . isFolder ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:59:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  node  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            noteId :  note . noteId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            parentNoteId :  branch . parentNoteId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            branchId :  branch . branchId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            isProtected :  note . isProtected , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            noteType :  note . type , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            title :  utils . escapeHtml ( title ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            extraClasses :  this . getExtraClasses ( note ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:52:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            icon :  note . getIcon ( isFolder ) , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            refKey :  note . noteId , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 12:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            lazy :  true , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:59:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            folder :  isFolder , 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-23 22:52:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            expanded :  branch . isExpanded  &&  note . type  !==  'search' , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            key :  utils . randomString ( 12 )  // this should prevent some "duplicate key" errors
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-28 14:29:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( isFolder  &&  node . expanded  &&  ! forceLazy )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            node . children  =  this . prepareChildren ( note ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getExtraClasses ( note )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        utils . assertArguments ( note ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  extraClasses  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( note . isProtected )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            extraClasses . push ( "protected" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-22 15:01:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( note . isShared ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            extraClasses . push ( "shared" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-17 22:26:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( note . getParentNoteIds ( ) . length  >  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 13:16:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  realClones  =  note . getParentNoteIds ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 22:27:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                . map ( noteId  =>  froca . notes [ noteId ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                . filter ( note  =>  ! ! note ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 13:16:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                . filter ( note  => 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-24 12:26:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    ! [ '_share' ,  '_lbBookmarks' ] . includes ( note . noteId ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 13:16:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    &&  note . type  !==  'search' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 22:27:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 13:16:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( realClones . length  >  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 22:27:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                extraClasses . push ( "multiple-parents" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  cssClass  =  note . getCssClass ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( cssClass )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            extraClasses . push ( cssClass ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        extraClasses . push ( utils . getNoteTypeClass ( note . type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( note . mime )  {  // some notes should not have mime type (e.g. render)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            extraClasses . push ( utils . getMimeTypeClass ( note . mime ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( note . hasLabel ( 'archived' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            extraClasses . push ( "archived" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 14:19:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  colorClass  =  note . getColorClass ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( colorClass )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            extraClasses . push ( colorClass ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 00:28:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  extraClasses . join ( " " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-24 14:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {FancytreeNode[]} */ 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    getSelectedNodes ( stopOnParents  =  false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  this . tree . getSelectedNodes ( stopOnParents ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-24 14:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {FancytreeNode[]} */ 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    getSelectedOrActiveNodes ( node  =  null )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 10:32:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  nodes  =  this . getSelectedNodes ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 10:32:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // the node you start dragging should be included even if not selected
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( node  &&  ! nodes . find ( n  =>  n . key  ===  node . key ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            nodes . push ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 10:32:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( nodes . length  ===  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            nodes . push ( this . getActiveNode ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-13 16:57:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // hidden subtree is hackily hidden via CSS when hoisted to root
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // make sure it's never selected for e.g. deletion in such a case
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nodes . filter ( node  =>  hoistedNoteService . getHoistedNoteId ( )  !==  'root' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                               ||  node . data . noteId  !==  '_hidden' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:15:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  setExpandedStatusForSubtree ( node ,  isExpanded )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 20:57:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  hoistedNoteId  =  hoistedNoteService . getHoistedNoteId ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-21 22:08:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            node  =  this . getNodesByNoteId ( hoistedNoteId ) [ 0 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:15:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  { branchIds }  =  await  server . put ( ` branches/ ${ node . data . branchId } /expanded-subtree/ ${ isExpanded  ?  1  :  0 } ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-30 23:09:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        froca . getBranches ( branchIds ,  true ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 23:08:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            . forEach ( branch  =>  branch . isExpanded  =  ! ! isExpanded ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:15:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  this . batchUpdate ( async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            await  node . load ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 11:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node . data . noteId  !==  hoistedNoteService . getHoistedNoteId ( ) )  {  // hoisted note should always be expanded
 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-29 23:33:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                await  node . setExpanded ( isExpanded ,  { noEvents :  true ,  noAnimation :  true } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:52:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-24 22:59:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 23:11:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  this . filterHoistedBranch ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-13 15:09:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 21:24:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // don't activate the active note, see discussion in https://github.com/zadam/trilium/issues/3664
 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:15:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  expandTree ( node  =  null )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  this . setExpandedStatusForSubtree ( node ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-03 13:15:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  collapseTree ( node  =  null )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  this . setExpandedStatusForSubtree ( node ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-11 21:19:56 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 09:12:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    collapseTreeEvent ( )  { this . collapseTree ( ) ; } 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 20:40:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 23:38:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *  @ returns  { FancytreeNode | null } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getActiveNode ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  this . tree . getActiveNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 22:14:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *  focused  &  not  active  node  can  happen  during  multiselection  where  the  node  is  selected 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  but  not  activated  ( its  content  is  not  displayed  in  the  detail ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 23:38:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     *  @ returns  { FancytreeNode | null } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 10:35:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getFocusedNode ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  this . tree . getFocusNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    clearSelectedNodes ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  selectedNode  of  this . getSelectedNodes ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            selectedNode . setSelected ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-16 21:19:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  scrollToActiveNoteEvent ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:35:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  activeContext  =  appContext . tabManager . getActiveContext ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( activeContext  &&  activeContext . notePath )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-27 23:05:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . tree . $container . focus ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:06:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . tree . setFocus ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  node  =  await  this . expandToNote ( activeContext . notePath ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-17 23:17:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                await  node . makeVisible ( { scrollIntoView :  true } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                node . setActive ( true ,  { noEvents :  true ,  noFocus :  false } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-31 22:35:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  focusTreeEvent ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . tree . $container . focus ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . tree . setFocus ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-24 14:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {FancytreeNode} */ 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 23:43:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  getNodeFromPath ( notePath ,  expand  =  false ,  logErrors  =  true )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        utils . assertArguments ( notePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-28 19:46:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        /** @let {FancytreeNode} */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  parentNode  =  this . getNodesByNoteId ( 'root' ) [ 0 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-06 20:31:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        let  resolvedNotePathSegments  =  await  treeService . resolveNotePathToSegments ( notePath ,  this . hoistedNoteId ,  logErrors ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! resolvedNotePathSegments )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 23:43:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( logErrors )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 21:05:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                logError ( "Could not find run path for notePath:" ,  notePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 23:43:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-06 20:31:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        resolvedNotePathSegments  =  resolvedNotePathSegments . slice ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( const  childNoteId  of  resolvedNotePathSegments )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // we expand only after hoisted note since before then nodes are not actually present in the tree
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( parentNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ! parentNode . isLoaded ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    await  parentNode . load ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( expand )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( ! parentNode . isExpanded ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        await  parentNode . setExpanded ( true ,  { noAnimation :  true } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:06:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 11:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    // although the previous line should set the expanded status, it seems to happen asynchronously,
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:06:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    // so we need to make sure it is set properly before calling updateNode which uses this flag
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    const  branch  =  froca . getBranch ( parentNode . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 11:06:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    branch . isExpanded  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                await  this . updateNode ( parentNode ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                let  foundChildNode  =  this . findChildNode ( parentNode ,  childNoteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-15 21:04:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( ! foundChildNode )  {  // note might be recently created, so we'll force reload and try again
 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    await  parentNode . load ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    foundChildNode  =  this . findChildNode ( parentNode ,  childNoteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( ! foundChildNode )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 23:43:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        if  ( logErrors )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 11:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            // besides real errors, this can be also caused by hiding of e.g. included images
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-15 21:04:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            // these are real notes with real notePath, user can display them in a detail,
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-30 23:12:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            // but they don't have a node in the tree
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            const  childNote  =  await  froca . getNote ( childNoteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-17 23:17:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            if  ( ! childNote  ||  childNote . type  !==  'image' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                ws . logError ( ` Can't find node for child node of noteId= ${ childNoteId }  for parent of noteId= ${ parentNode . data . noteId }  and hoistedNoteId= ${ hoistedNoteService . getHoistedNoteId ( ) } , requested path is  ${ notePath } ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 23:43:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                parentNode  =  foundChildNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  parentNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-24 14:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {FancytreeNode} */ 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    findChildNode ( parentNode ,  childNoteId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  parentNode . getChildren ( ) . find ( childNode  =>  childNode . data . noteId  ===  childNoteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-24 14:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {FancytreeNode} */ 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 23:43:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  expandToNote ( notePath ,  logErrors  =  true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  this . getNodeFromPath ( notePath ,  true ,  logErrors ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-24 14:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {FancytreeNode[]} */ 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-24 22:37:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    getNodesByBranch ( branch )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        utils . assertArguments ( branch ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-24 22:37:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  this . getNodesByNoteId ( branch . noteId ) . filter ( node  =>  node . data . branchId  ===  branch . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-24 14:53:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    /** @returns {FancytreeNode[]} */ 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 11:15:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    getNodesByNoteId ( noteId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        utils . assertArguments ( noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  list  =  this . tree . getNodesByRef ( noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  list  ?  list  :  [ ] ;  // if no nodes with this refKey are found, fancy tree returns null
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 21:13:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    isEnabled ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:26:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  ! ! this . noteContext ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-09 21:13:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-18 20:49:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  refresh ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-06 22:17:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . toggleInt ( this . isEnabled ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-05 21:51:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . $treeSettingsPopup . hide ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-08 21:54:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . activityDetected ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-18 18:01:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  oldActiveNode  =  this . getActiveNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 21:50:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  newActiveNode  =  this . noteContext ? . notePath 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 23:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            &&  ( ! treeService . isNotePathInHiddenSubtree ( this . noteContext . notePath )  ||  await  hoistedNoteService . isHoistedInHiddenSubtree ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 21:50:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            &&  await  this . getNodeFromPath ( this . noteContext . notePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-04 21:44:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 21:50:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( newActiveNode  !==  oldActiveNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            let  oldActiveNodeFocused  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( oldActiveNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                oldActiveNodeFocused  =  oldActiveNode . hasFocus ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-18 18:01:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-18 21:50:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                oldActiveNode . setActive ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                oldActiveNode . setFocus ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-18 18:01:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( newActiveNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( ! newActiveNode . isVisible ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:26:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    await  this . expandToNote ( this . noteContext . notePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-18 18:01:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-04 21:44:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                newActiveNode . setActive ( true ,  { noEvents :  true ,  noFocus :  ! oldActiveNodeFocused } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-12 22:25:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                newActiveNode . makeVisible ( { scrollIntoView :  true } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-18 18:01:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-22 23:05:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 23:11:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . filterHoistedBranch ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-18 18:01:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-27 23:13:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  refreshSearch ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  activeNode  =  $ . ui . fancytree . getNode ( e ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-14 20:18:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        activeNode . load ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-29 23:33:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        activeNode . setExpanded ( true ,  { noAnimation :  true } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-14 20:18:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-20 02:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        toastService . showMessage ( t ( "note_tree.saved-search-note-refreshed" ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-14 20:18:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  batchUpdate ( cb )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // disable rendering during update for increased performance
 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-30 23:09:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . tree . enableUpdate ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            await  cb ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        finally  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-30 23:09:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . tree . enableUpdate ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    activityDetected ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( this . autoCollapseTimeoutId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            clearTimeout ( this . autoCollapseTimeoutId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . autoCollapseTimeoutId  =  setTimeout ( ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 20:11:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! this . autoCollapseNoteTree )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            / * 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 11:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								             *  We ' re  collapsing  notes  after  a  period  of  inactivity  to  "cleanup"  the  tree  -  users  rarely 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								             *  collapse  the  notes  and  the  tree  becomes  unusuably  large . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								             *  Some  context :  https : //github.com/zadam/trilium/issues/1192
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								             * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  noteIdsToKeepExpanded  =  new  Set ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:26:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                appContext . tabManager . getNoteContexts ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    . map ( nc  =>  nc . notePathArray ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    . flat ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            let  noneCollapsedYet  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . tree . getRootNode ( ) . visit ( node  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( node . isExpanded ( )  &&  ! noteIdsToKeepExpanded . has ( node . data . noteId ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    node . setExpanded ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( noneCollapsedYet )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-20 02:06:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        toastService . showMessage ( t ( "note_tree.auto-collapsing-notes-after-inactivity" ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        noneCollapsedYet  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-13 15:09:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 23:11:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . filterHoistedBranch ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ,  600  *  1000 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-28 22:52:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  entitiesReloadedEvent ( { loadResults } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 20:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . activityDetected ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-16 22:57:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( loadResults . isEmptyForTree ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  activeNode  =  this . getActiveNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  activeNodeFocused  =  activeNode ? . hasFocus ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  activeNotePath  =  activeNode  ?  treeService . getNotePath ( activeNode )  :  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  refreshCtx  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            noteIdsToUpdate :  new  Set ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            noteIdsToReload :  new  Set ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-08 23:10:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . # processAttributeRows ( loadResults . getAttributeRows ( ) ,  refreshCtx ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 22:54:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  {  movedActiveNode ,  parentsOfAddedNodes  }  =  await  this . # processBranchRows ( loadResults . getBranchRows ( ) ,  refreshCtx ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  noteId  of  loadResults . getNoteIds ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            refreshCtx . noteIdsToUpdate . add ( noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  this . # executeTreeUpdates ( refreshCtx ,  loadResults ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  this . # setActiveNode ( activeNotePath ,  activeNodeFocused ,  movedActiveNode ,  parentsOfAddedNodes ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( refreshCtx . noteIdsToReload . size  >  0  ||  refreshCtx . noteIdsToUpdate . size  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // workaround for https://github.com/mar10/fancytree/issues/1054
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 23:11:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . filterHoistedBranch ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-26 11:41:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    # processAttributeRows ( attributeRows ,  refreshCtx )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  attrRow  of  attributeRows )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 23:48:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  dirtyingLabels  =  [ 'iconClass' ,  'cssClass' ,  'workspace' ,  'workspaceIconClass' ,  'color' ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 23:11:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( attrRow . type  ===  'label'  &&  dirtyingLabels . includes ( attrRow . name ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( attrRow . isInheritable )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    refreshCtx . noteIdsToReload . add ( attrRow . noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    refreshCtx . noteIdsToUpdate . add ( attrRow . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  if  ( attrRow . type  ===  'label'  &&  attrRow . name  ===  'archived' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  note  =  froca . getNoteFromCache ( attrRow . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 19:26:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( note )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // change of archived status can mean the note should not be displayed in the tree at all
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    // depending on the value of this.hideArchivedNotes
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    for  ( const  parentNote  of  note . getParentNotes ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        refreshCtx . noteIdsToReload . add ( parentNote . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 19:26:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  if  ( attrRow . type  ===  'relation'  &&  ( attrRow . name  ===  'template'  ||  attrRow . name  ===  'inherit' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // missing handling of things inherited from template
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                refreshCtx . noteIdsToReload . add ( attrRow . noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  if  ( attrRow . type  ===  'relation'  &&  attrRow . name  ===  'imageLink' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                const  note  =  froca . getNoteFromCache ( attrRow . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-27 23:27:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( note  &&  note . getChildNoteIds ( ) . includes ( attrRow . value ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-10 18:20:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    // there's a new /deleted imageLink between note and its image child - which can show/hide
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 11:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    // the image (if there is an imageLink relation between parent and child,
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-09 23:15:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    // then it is assumed to be "contained" in the note and thus does not have to be displayed in the tree)
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    refreshCtx . noteIdsToReload . add ( attrRow . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-27 23:27:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async  # processBranchRows ( branchRows ,  refreshCtx )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  allBranchesDeleted  =  branchRows . every ( branchRow  =>  ! ! branchRow . isDeleted ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // activeNode is supposed to be moved when we find out activeNode is deleted but not all branches are deleted. save it for fixing activeNodePath after all nodes loaded.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  movedActiveNode  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  parentsOfAddedNodes  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( const  branchRow  of  branchRows )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 16:26:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( branchRow . parentNoteId  ===  '_share' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-22 16:02:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // all shared notes have a sign in the tree, even the descendants of shared notes
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                refreshCtx . noteIdsToReload . add ( branchRow . noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-22 16:02:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // adding noteId itself to update all potential clones
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                refreshCtx . noteIdsToUpdate . add ( branchRow . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-22 16:02:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-25 21:16:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-19 08:58:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( branchRow . isDeleted )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                for  ( const  node  of  this . getNodesByBranch ( branchRow ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 20:57:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( node . isActive ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        if  ( allBranchesDeleted )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            const  newActiveNode  =  node . getNextSibling ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                ||  node . getPrevSibling ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                ||  node . getParent ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            if  ( newActiveNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                newActiveNode . setActive ( true ,  { noEvents :  true ,  noFocus :  true } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            movedActiveNode  =  node ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-12 22:25:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 12:30:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-02 12:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( node . getParent ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        node . remove ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-12 22:25:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    refreshCtx . noteIdsToUpdate . add ( branchRow . parentNoteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 12:30:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-19 08:58:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-05 16:26:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                for  ( const  parentNode  of  this . getNodesByNoteId ( branchRow . parentNoteId ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    parentsOfAddedNodes . push ( parentNode ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 22:47:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( parentNode . isFolder ( )  &&  ! parentNode . isLoaded ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 01:11:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    const  note  =  await  froca . getNote ( branchRow . noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    const  frocaBranch  =  froca . getBranch ( branchRow . branchId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    const  foundNode  =  ( parentNode . getChildren ( )  ||  [ ] ) . find ( child  =>  child . data . noteId  ===  branchRow . noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( foundNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        // the branch already exists in the tree
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( branchRow . isExpanded  !==  foundNode . isExpanded ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            refreshCtx . noteIdsToReload . add ( frocaBranch . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 01:11:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-28 14:29:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        // make sure it's loaded
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-23 23:30:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        // we're forcing lazy since it's not clear if the whole required subtree is in froca
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-24 22:59:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        parentNode . addChildren ( [ this . prepareNode ( frocaBranch ,  true ) ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-05 00:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-19 08:58:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        if  ( frocaBranch . isExpanded  &&  note . hasChildren ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            refreshCtx . noteIdsToReload . add ( frocaBranch . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-19 08:58:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-05 00:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        this . sortChildren ( parentNode ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-14 22:48:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        // this might be a first child which would force an icon change
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        refreshCtx . noteIdsToUpdate . add ( branchRow . parentNoteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            movedActiveNode , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            parentsOfAddedNodes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  # executeTreeUpdates ( refreshCtx ,  loadResults )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  this . batchUpdate ( async  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            for  ( const  noteId  of  refreshCtx . noteIdsToReload )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                for  ( const  node  of  this . getNodesByNoteId ( noteId ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 18:56:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    await  node . load ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    refreshCtx . noteIdsToUpdate . add ( noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-29 21:38:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            for  ( const  parentNoteId  of  loadResults . getNoteReorderings ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                for  ( const  node  of  this . getNodesByNoteId ( parentNoteId ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    if  ( node . isLoaded ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-05 00:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        this . sortChildren ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 12:30:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 12:30:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 11:18:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // for some reason, node update cannot be in the batchUpdate() block (node is not re-rendered)
 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( const  noteId  of  refreshCtx . noteIdsToUpdate )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 18:56:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            for  ( const  node  of  this . getNodesByNoteId ( noteId ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                await  this . updateNode ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  # setActiveNode ( activeNotePath ,  activeNodeFocused ,  movedActiveNode ,  parentsOfAddedNodes )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( movedActiveNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for  ( const  parentNode  of  parentsOfAddedNodes )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                const  foundNode  =  ( parentNode . getChildren ( )  ||  [ ] ) . find ( child  =>  child . data . noteId  ===  movedActiveNode . data . noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( foundNode )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    activeNotePath  =  treeService . getNotePath ( foundNode ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-13 10:28:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 18:56:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! activeNotePath )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        let  node  =  await  this . expandToNote ( activeNotePath ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( node  &&  node . data . noteId  !==  treeService . getNoteIdFromUrl ( activeNotePath ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // if the active note has been moved elsewhere then it won't be found by the path,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // so we switch to the alternative of trying to find it by noteId
 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  notesById  =  this . getNodesByNoteId ( treeService . getNoteIdFromUrl ( activeNotePath ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 22:54:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-03 08:58:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // if there are multiple clones, then we'd rather not activate anyone
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            node  =  notesById . length  ===  1  ?  notesById [ 0 ]  :  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-18 10:08:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-21 22:03:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( activeNodeFocused )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // needed by Firefox: https://github.com/zadam/trilium/issues/1865
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . tree . $container . focus ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 12:30:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-28 23:08:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  node . setActive ( true ,  { noEvents :  true ,  noFocus :  ! activeNodeFocused } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-12 12:30:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-19 18:05:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-05 00:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    sortChildren ( node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        node . sortChildren ( ( nodeA ,  nodeB )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  branchA  =  froca . branches [ nodeA . data . branchId ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  branchB  =  froca . branches [ nodeB . data . branchId ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-05 00:07:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! branchA  ||  ! branchB )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  branchA . notePosition  -  branchB . notePosition ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 22:05:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    setExpanded ( branchId ,  isExpanded )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        utils . assertArguments ( branchId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  branch  =  froca . getBranch ( branchId ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 21:08:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! branch )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 21:05:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( branchId  &&  branchId . startsWith ( 'virt' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // in case of virtual branches there's nothing to update
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                logError ( ` Cannot find branch= ${ branchId } ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 21:08:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        branch . isExpanded  =  isExpanded ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-04 22:05:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        server . put ( ` branches/ ${ branchId } /expanded/ ${ isExpanded  ?  1  :  0 } ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-01 22:29:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  reloadTreeFromCache ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  activeNode  =  this . getActiveNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-10 20:57:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  activeNotePath  =  activeNode  !==  null  ?  treeService . getNotePath ( activeNode )  :  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-26 16:50:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  rootNode  =  this . prepareRootNode ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-30 23:58:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  this . batchUpdate ( async  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            await  this . tree . reload ( [ rootNode ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 23:11:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  this . filterHoistedBranch ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-13 11:25:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( activeNotePath )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            const  node  =  await  this . getNodeFromPath ( activeNotePath ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-05 23:35:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                await  node . setActive ( true ,  { noEvents :  true ,  noFocus :  true } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:26:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  hoistedNoteChangedEvent ( { ntxId } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-22 12:42:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( this . isNoteContext ( ntxId ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 23:11:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            await  this . filterHoistedBranch ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-22 23:05:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 23:11:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  filterHoistedBranch ( forceUpdate  =  false )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 22:47:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! this . noteContext )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-28 19:46:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 22:47:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  hoistedNotePath  =  await  treeService . resolveNotePath ( this . noteContext . hoistedNoteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-06 23:11:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! forceUpdate  &&  this . lastFilteredHoistedNotePath  ===  hoistedNotePath )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // no need to re-filter if the hoisting did not change
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // (helps with flickering on simple note change with large subtrees)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . lastFilteredHoistedNotePath  =  hoistedNotePath ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 22:47:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  this . getNodeFromPath ( hoistedNotePath ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( this . noteContext . hoistedNoteId  ===  'root' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . tree . clearFilter ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-05 16:44:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            this . toggleHiddenNode ( false ) ;  // show everything but the hidden subtree
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-21 22:47:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // hack when hoisted note is cloned then it could be filtered multiple times while we want only 1
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . tree . filterBranches ( node  => 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                node . data . noteId  ===  this . noteContext . hoistedNoteId  // optimization to not having always resolve the node path
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                &&  treeService . getNotePath ( node )  ===  hoistedNotePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-05 16:44:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            this . toggleHiddenNode ( true ) ;  // hoisting will handle hidden note visibility
 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-22 23:05:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-05 16:44:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    toggleHiddenNode ( show )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 16:11:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  hiddenNode  =  this . getNodesByNoteId ( '_hidden' ) [ 0 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-05 16:44:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $ ( hiddenNode . li ) . toggleClass ( "hidden-node-is-hidden" ,  ! show ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    frocaReloadedEvent ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-01 22:29:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . reloadTreeFromCache ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-24 15:44:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-15 10:41:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  getHotKeys ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  actions  =  await  keyboardActionsService . getActionsForScope ( 'note-tree' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-24 23:33:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  hotKeyMap  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( const  action  of  actions )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            for  ( const  shortcut  of  action . effectiveShortcuts )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 00:17:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                hotKeyMap [ shortcutService . normalizeShortcut ( shortcut ) ]  =  node  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-05 23:00:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    const  notePath  =  treeService . getNotePath ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    this . triggerCommand ( action . actionName ,  { node ,  notePath } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-17 22:49:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 22:38:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  hotKeyMap ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @ param  { FancytreeNode }  node 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getSelectedOrActiveBranchIds ( node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  nodes  =  this . getSelectedOrActiveNodes ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nodes . map ( node  =>  node . data . branchId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 13:57:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    / * * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @ param  { FancytreeNode }  node 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    getSelectedOrActiveNoteIds ( node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  nodes  =  this . getSelectedOrActiveNodes ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nodes . map ( node  =>  node . data . noteId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  deleteNotesCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-17 23:03:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  branchIds  =  this . getSelectedOrActiveBranchIds ( node ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            . filter ( branchId  =>  ! branchId . startsWith ( 'virt-' ) ) ;  // search results can't be deleted
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! branchIds . length )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 19:42:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        await  branchService . deleteNotes ( branchIds ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . clearSelectedNodes ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-23 21:00:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    canBeMovedUpOrDown ( node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( node . data . noteId  ===  'root' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  parentNote  =  froca . getNoteFromCache ( node . getParent ( ) . data . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-23 21:00:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-05 23:17:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  ! parentNote ? . hasLabel ( 'sorted' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-23 21:00:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    moveNoteUpCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-23 21:00:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! this . canBeMovedUpOrDown ( node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  beforeNode  =  node . getPrevSibling ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( beforeNode  !==  null )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 19:42:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            branchService . moveBeforeBranch ( [ node . data . branchId ] ,  beforeNode . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    moveNoteDownCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-23 21:00:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! this . canBeMovedUpOrDown ( node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  afterNode  =  node . getNextSibling ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-23 21:00:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( afterNode  !==  null )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 19:42:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            branchService . moveAfterBranch ( [ node . data . branchId ] ,  afterNode . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    moveNoteUpInHierarchyCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-17 19:42:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        branchService . moveNodeUpInHierarchy ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    moveNoteDownInHierarchyCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  toNode  =  node . getPrevSibling ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( toNode  !==  null )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 22:33:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            branchService . moveToParentNote ( [ node . data . branchId ] ,  toNode . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    addNoteAboveToSelectionCommand ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  node  =  this . getFocusedNode ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node . isActive ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            node . setSelected ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  prevSibling  =  node . getPrevSibling ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( prevSibling )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            prevSibling . setActive ( true ,  { noEvents :  true } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( prevSibling . isSelected ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                node . setSelected ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            prevSibling . setSelected ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    addNoteBelowToSelectionCommand ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  node  =  this . getFocusedNode ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node . isActive ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            node . setSelected ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  nextSibling  =  node . getNextSibling ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( nextSibling )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            nextSibling . setActive ( true ,  { noEvents :  true } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( nextSibling . isSelected ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                node . setSelected ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            nextSibling . setSelected ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-30 23:09:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    expandSubtreeCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-29 23:13:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . expandTree ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    collapseSubtreeCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . collapseTree ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 19:43:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  recentChangesInSubtreeCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-14 22:55:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . triggerCommand ( "showRecentChanges" ,  { ancestorNoteId :  node . data . noteId } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-29 19:43:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    selectAllNotesInParentCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  child  of  node . getParent ( ) . getChildren ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            child . setSelected ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    copyNotesToClipboardCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        clipboard . copy ( this . getSelectedOrActiveBranchIds ( node ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    cutNotesToClipboardCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        clipboard . cut ( this . getSelectedOrActiveBranchIds ( node ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pasteNotesFromClipboardCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 22:33:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clipboard . pasteInto ( node . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 13:39:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    pasteNotesAfterFromClipboardCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clipboard . pasteAfter ( node . data . branchId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async  exportNoteCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  notePath  =  treeService . getNotePath ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-16 15:04:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . triggerCommand ( "showExportDialog" ,  { notePath ,  defaultType :  "subtree" } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    async  importIntoNoteCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-16 14:21:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        this . triggerCommand ( "showImportDialog" ,  { noteId :  node . data . noteId } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    editNoteTitleCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-28 00:11:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        appContext . triggerCommand ( 'focusOnTitle' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:14:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    protectSubtreeCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-26 16:37:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        protectedSessionService . protectNote ( node . data . noteId ,  true ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unprotectSubtreeCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-26 16:37:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        protectedSessionService . protectNote ( node . data . noteId ,  false ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-19 14:06:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    duplicateSubtreeCommand ( { node } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-23 22:45:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        const  nodesToDuplicate  =  this . getSelectedOrActiveNodes ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( const  nodeToDuplicate  of  nodesToDuplicate )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  note  =  froca . getNoteFromCache ( nodeToDuplicate . data . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-23 22:45:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( note . isProtected  &&  ! protectedSessionHolder . isProtectedSessionAvailable ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-16 22:57:37 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            const  branch  =  froca . getBranch ( nodeToDuplicate . data . branchId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-23 22:45:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-19 14:06:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            noteCreateService . duplicateSubtree ( nodeToDuplicate . data . noteId ,  branch . parentNoteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-23 22:45:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-16 22:56:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    moveShortcutToVisibleCommand ( { node ,  selectedOrActiveBranchIds } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 16:11:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        branchService . moveToParentNote ( selectedOrActiveBranchIds ,  '_lbVisibleLaunchers' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    moveShortcutToAvailableCommand ( { node ,  selectedOrActiveBranchIds } )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-21 16:11:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        branchService . moveToParentNote ( selectedOrActiveBranchIds ,  '_lbAvailableLaunchers' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 16:46:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    addNoteLauncherCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . createLauncherNote ( node ,  'note' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 16:46:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    addScriptLauncherCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . createLauncherNote ( node ,  'script' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 23:13:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 16:46:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    addWidgetLauncherCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . createLauncherNote ( node ,  'customWidget' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 16:46:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    addSpacerLauncherCommand ( { node } )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        this . createLauncherNote ( node ,  'spacer' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 16:46:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    async  createLauncherNote ( node ,  launcherType )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        const  resp  =  await  server . post ( ` special-notes/launchers/ ${ node . data . noteId } / ${ launcherType } ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! resp . success )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 15:23:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            toastService . showError ( resp . message ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 15:34:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        await  ws . waitForMaxKnownEntityChangeId ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        appContext . tabManager . getActiveContext ( ) . setNote ( resp . note . noteId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:23:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-12 10:52:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}