| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  | import FlexContainer from "./containers/flex_container.js"; | 
					
						
							| 
									
										
										
										
											2022-08-02 17:33:52 +02:00
										 |  |  | import utils from "../services/utils.js"; | 
					
						
							|  |  |  | import attributeService from "../services/attributes.js"; | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default class NoteWrapperWidget extends FlexContainer { | 
					
						
							|  |  |  |     constructor() { | 
					
						
							|  |  |  |         super('column'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.css("flex-grow", "1") | 
					
						
							|  |  |  |             .collapsible(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setNoteContextEvent({noteContext}) { | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  |         this.noteContext = noteContext; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.refresh(); | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  |     noteSwitchedAndActivatedEvent() { | 
					
						
							|  |  |  |         this.refresh(); | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  |     noteSwitchedEvent() { | 
					
						
							|  |  |  |         this.refresh(); | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  |     activeContextChangedEvent() { | 
					
						
							|  |  |  |         this.refresh(); | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  |     refresh() { | 
					
						
							| 
									
										
										
										
											2022-09-07 23:39:35 +02:00
										 |  |  |         const isHiddenExt = this.isHiddenExt(); // preserve through class reset
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-02 17:33:52 +02:00
										 |  |  |         this.$widget.removeClass(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-07 23:39:35 +02:00
										 |  |  |         this.toggleExt(!isHiddenExt); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.$widget.addClass("component note-split"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  |         const note = this.noteContext?.note; | 
					
						
							| 
									
										
										
										
											2022-08-02 17:33:52 +02:00
										 |  |  |         if (!note) { | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  |         this.$widget.toggleClass("full-content-width", | 
					
						
							| 
									
										
										
										
											2024-12-01 17:25:19 +02:00
										 |  |  |             ['image', 'mermaid', 'book', 'render', 'canvas', 'webView', 'mindMap'].includes(note.type) | 
					
						
							| 
									
										
										
										
											2023-06-29 00:14:12 +02:00
										 |  |  |             || !!note?.isLabelTruthy('fullContentWidth') | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  |         ); | 
					
						
							| 
									
										
										
										
											2022-08-02 17:33:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         this.$widget.addClass(note.getCssClass()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.$widget.addClass(utils.getNoteTypeClass(note.type)); | 
					
						
							|  |  |  |         this.$widget.addClass(utils.getMimeTypeClass(note.mime)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.$widget.toggleClass("protected", note.isProtected); | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     async entitiesReloadedEvent({loadResults}) { | 
					
						
							| 
									
										
										
										
											2022-08-02 17:33:52 +02:00
										 |  |  |         // listening on changes of note.type and CSS class
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const noteId = this.noteContext?.noteId; | 
					
						
							|  |  |  |         if (loadResults.isNoteReloaded(noteId) | 
					
						
							| 
									
										
										
										
											2023-06-05 16:12:02 +02:00
										 |  |  |             || loadResults.getAttributeRows().find(attr => attr.type === 'label' && attr.name === 'cssClass' && attributeService.isAffecting(attr, this.noteContext?.note))) { | 
					
						
							| 
									
										
										
										
											2022-08-02 17:33:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-22 14:24:47 +02:00
										 |  |  |             this.refresh(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-11-24 21:27:55 +01:00
										 |  |  | } |