mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	setup cssClass for both note tab and content, #524
This commit is contained in:
		
							parent
							
								
									93c0469aa0
								
							
						
					
					
						commit
						79d779dee8
					
				@ -229,7 +229,7 @@ async function loadNoteDetail(origNotePath, options = {}) {
 | 
			
		||||
 | 
			
		||||
    if (activate) {
 | 
			
		||||
        // will also trigger showTab via event
 | 
			
		||||
        tabRow.setCurrentTab(ctx.tab);
 | 
			
		||||
        tabRow.setCurrentTab(ctx.$tab[0]);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -38,8 +38,8 @@ class TabContext {
 | 
			
		||||
     */
 | 
			
		||||
    constructor(tabRow) {
 | 
			
		||||
        this.tabRow = tabRow;
 | 
			
		||||
        this.tab = this.tabRow.addTab();
 | 
			
		||||
        this.tabId = this.tab.getAttribute('data-tab-id');
 | 
			
		||||
        this.$tab = $(this.tabRow.addTab());
 | 
			
		||||
        this.tabId = this.$tab.attr('data-tab-id');
 | 
			
		||||
 | 
			
		||||
        this.$tabContent = $(".note-tab-content-template").clone();
 | 
			
		||||
        this.$tabContent.removeClass('note-tab-content-template');
 | 
			
		||||
@ -80,7 +80,7 @@ class TabContext {
 | 
			
		||||
        this.noteId = note.noteId;
 | 
			
		||||
        this.notePath = notePath;
 | 
			
		||||
        this.note = note;
 | 
			
		||||
        this.tabRow.updateTab(this.tab, {title: note.title});
 | 
			
		||||
        this.tabRow.updateTab(this.$tab[0], {title: note.title});
 | 
			
		||||
 | 
			
		||||
        this.attributes.invalidateAttributes();
 | 
			
		||||
 | 
			
		||||
@ -90,16 +90,31 @@ class TabContext {
 | 
			
		||||
        this.$unprotectButton.toggleClass("active", !this.note.isProtected);
 | 
			
		||||
        this.$unprotectButton.prop("disabled", !this.note.isProtected || !protectedSessionHolder.isProtectedSessionAvailable());
 | 
			
		||||
 | 
			
		||||
        this.setupClasses();
 | 
			
		||||
 | 
			
		||||
        console.log(`Switched tab ${this.tabId} to ${this.noteId}`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    setupClasses() {
 | 
			
		||||
        for (const clazz of Array.from(this.$tab[0].classList)) { // create copy to safely iterate over while removing classes
 | 
			
		||||
            if (clazz !== 'note-tab') {
 | 
			
		||||
                this.$tab.removeClass(clazz);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        for (const clazz of Array.from(this.$tabContent[0].classList)) { // create copy to safely iterate over while removing classes
 | 
			
		||||
            if (clazz.startsWith("type-") || clazz.startsWith("mime-")) {
 | 
			
		||||
            if (clazz !== 'note-tab-content') {
 | 
			
		||||
                this.$tabContent.removeClass(clazz);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        this.$tab.addClass(this.note.cssClass);
 | 
			
		||||
        this.$tab.addClass(utils.getNoteTypeClass(this.note.type));
 | 
			
		||||
        this.$tab.addClass(utils.getMimeTypeClass(this.note.mime));
 | 
			
		||||
 | 
			
		||||
        this.$tabContent.addClass(this.note.cssClass);
 | 
			
		||||
        this.$tabContent.addClass(utils.getNoteTypeClass(this.note.type));
 | 
			
		||||
        this.$tabContent.addClass(utils.getMimeTypeClass(this.note.mime));
 | 
			
		||||
 | 
			
		||||
        console.log(`Switched tab ${this.tabId} to ${this.noteId}`);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getComponent() {
 | 
			
		||||
 | 
			
		||||
@ -126,6 +126,7 @@ ul.fancytree-container {
 | 
			
		||||
    display: flex;
 | 
			
		||||
    flex-direction: column;
 | 
			
		||||
    min-height: 200px;
 | 
			
		||||
    word-break: break-all; /* otherwise CKEditor fails miserably on super long lines */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.note-detail-component {
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,8 @@ async function getNote(req) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    note.cssClass = (await note.getLabels("cssClass")).map(label => label.value).join(" ");
 | 
			
		||||
 | 
			
		||||
    return note;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user