mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	add a button to temporarily hide TOC, closes #3555
This commit is contained in:
		| @@ -15,6 +15,8 @@ class NoteContext extends Component { | ||||
|         this.ntxId = ntxId || utils.randomString(4); | ||||
|         this.hoistedNoteId = hoistedNoteId; | ||||
|         this.mainNtxId = mainNtxId; | ||||
|  | ||||
|         this.resetViewScope(); | ||||
|     } | ||||
|  | ||||
|     setEmpty() { | ||||
| @@ -27,6 +29,8 @@ class NoteContext extends Component { | ||||
|             noteContext: this, | ||||
|             notePath: this.notePath | ||||
|         }); | ||||
|  | ||||
|         this.resetViewScope(); | ||||
|     } | ||||
|  | ||||
|     isEmpty() { | ||||
| @@ -47,7 +51,7 @@ class NoteContext extends Component { | ||||
|         this.notePath = resolvedNotePath; | ||||
|         ({noteId: this.noteId, parentNoteId: this.parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(resolvedNotePath)); | ||||
|  | ||||
|         this.readOnlyTemporarilyDisabled = false; | ||||
|         this.resetViewScope(); | ||||
|  | ||||
|         this.saveToRecentNotes(resolvedNotePath); | ||||
|  | ||||
| @@ -60,6 +64,14 @@ class NoteContext extends Component { | ||||
|             }); | ||||
|         } | ||||
|  | ||||
|         await this.setHoistedNoteIfNeeded(); | ||||
|  | ||||
|         if (utils.isMobile()) { | ||||
|             this.triggerCommand('setActiveScreen', {screen: 'detail'}); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     async setHoistedNoteIfNeeded() { | ||||
|         if (this.hoistedNoteId === 'root' | ||||
|             && this.notePath.startsWith("root/_hidden") | ||||
|             && !this.note.hasLabel("keepCurrentHoisting") | ||||
| @@ -76,10 +88,6 @@ class NoteContext extends Component { | ||||
|  | ||||
|             await this.setHoistedNoteId(hoistedNoteId); | ||||
|         } | ||||
|  | ||||
|         if (utils.isMobile()) { | ||||
|             this.triggerCommand('setActiveScreen', {screen: 'detail'}); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     getSubContexts() { | ||||
| @@ -201,7 +209,7 @@ class NoteContext extends Component { | ||||
|     } | ||||
|  | ||||
|     async isReadOnly() { | ||||
|         if (this.readOnlyTemporarilyDisabled) { | ||||
|         if (this.viewScope.readOnlyTemporarilyDisabled) { | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
| @@ -277,6 +285,13 @@ class NoteContext extends Component { | ||||
|             ntxId: this.ntxId | ||||
|         })); | ||||
|     } | ||||
|  | ||||
|     resetViewScope() { | ||||
|         // view scope contains data specific to one note context and one "view". | ||||
|         // it is used to e.g. make read-only note temporarily editable or to hide TOC | ||||
|         // this is reset after navigating to a different note | ||||
|         this.viewScope = {}; | ||||
|     } | ||||
| } | ||||
|  | ||||
| export default NoteContext; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user