mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	Merge remote-tracking branch 'origin/stable'
This commit is contained in:
		@@ -24,7 +24,6 @@ import NoteRevisionsWidget from "../widgets/collapsible_widgets/note_revisions.j
 | 
				
			|||||||
import SimilarNotesWidget from "../widgets/collapsible_widgets/similar_notes.js";
 | 
					import SimilarNotesWidget from "../widgets/collapsible_widgets/similar_notes.js";
 | 
				
			||||||
import WhatLinksHereWidget from "../widgets/collapsible_widgets/what_links_here.js";
 | 
					import WhatLinksHereWidget from "../widgets/collapsible_widgets/what_links_here.js";
 | 
				
			||||||
import SidePaneToggles from "../widgets/side_pane_toggles.js";
 | 
					import SidePaneToggles from "../widgets/side_pane_toggles.js";
 | 
				
			||||||
import appContext from "../services/app_context.js";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const RIGHT_PANE_CSS = `
 | 
					const RIGHT_PANE_CSS = `
 | 
				
			||||||
<style>
 | 
					<style>
 | 
				
			||||||
@@ -117,6 +116,7 @@ export default class DesktopMainWindowLayout {
 | 
				
			|||||||
                .hideInZenMode())
 | 
					                .hideInZenMode())
 | 
				
			||||||
            .child(new FlexContainer('row')
 | 
					            .child(new FlexContainer('row')
 | 
				
			||||||
                .collapsible()
 | 
					                .collapsible()
 | 
				
			||||||
 | 
					                .filling()
 | 
				
			||||||
                .child(new SidePaneContainer('left')
 | 
					                .child(new SidePaneContainer('left')
 | 
				
			||||||
                    .hideInZenMode()
 | 
					                    .hideInZenMode()
 | 
				
			||||||
                    .child(new GlobalButtonsWidget())
 | 
					                    .child(new GlobalButtonsWidget())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,6 +37,10 @@ function subscribeToMessages(messageHandler) {
 | 
				
			|||||||
// used to serialize sync operations
 | 
					// used to serialize sync operations
 | 
				
			||||||
let consumeQueuePromise = null;
 | 
					let consumeQueuePromise = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// most sync events are sent twice - once immediatelly after finishing the transaction and once during the scheduled ping
 | 
				
			||||||
 | 
					// but we want to process only once
 | 
				
			||||||
 | 
					const receivedSyncIds = new Set();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function handleMessage(event) {
 | 
					async function handleMessage(event) {
 | 
				
			||||||
    const message = JSON.parse(event.data);
 | 
					    const message = JSON.parse(event.data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,14 +56,19 @@ async function handleMessage(event) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (syncRows.length > 0) {
 | 
					        if (syncRows.length > 0) {
 | 
				
			||||||
            const filteredRows = syncRows.filter(row =>
 | 
					            const filteredRows = syncRows.filter(row =>
 | 
				
			||||||
                row.entityName !== 'recent_notes'
 | 
					                !receivedSyncIds.has(row.id)
 | 
				
			||||||
 | 
					                && row.entityName !== 'recent_notes'
 | 
				
			||||||
                && (row.entityName !== 'options' || row.entityId !== 'openTabs'));
 | 
					                && (row.entityName !== 'options' || row.entityId !== 'openTabs'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (filteredRows.length > 0) {
 | 
					            if (filteredRows.length > 0) {
 | 
				
			||||||
                console.debug(utils.now(), "Sync data: ", filteredRows);
 | 
					                console.debug(utils.now(), "Sync data: ", filteredRows);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            syncDataQueue.push(...syncRows);
 | 
					            for (const row of filteredRows) {
 | 
				
			||||||
 | 
					                receivedSyncIds.add(row.id);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            syncDataQueue.push(...filteredRows);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // we set lastAcceptedSyncId even before sync processing and send ping so that backend can start sending more updates
 | 
					            // we set lastAcceptedSyncId even before sync processing and send ping so that backend can start sending more updates
 | 
				
			||||||
            lastAcceptedSyncId = Math.max(lastAcceptedSyncId, syncRows[syncRows.length - 1].id);
 | 
					            lastAcceptedSyncId = Math.max(lastAcceptedSyncId, syncRows[syncRows.length - 1].id);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,6 +30,11 @@ class BasicWidget extends Component {
 | 
				
			|||||||
        return this;
 | 
					        return this;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    filling() {
 | 
				
			||||||
 | 
					        this.css('flex-grow', '1');
 | 
				
			||||||
 | 
					        return this;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hideInZenMode() {
 | 
					    hideInZenMode() {
 | 
				
			||||||
        this.class('hide-in-zen-mode');
 | 
					        this.class('hide-in-zen-mode');
 | 
				
			||||||
        return this;
 | 
					        return this;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -807,7 +807,9 @@ export default class NoteTreeWidget extends TabAwareWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    async entitiesReloadedEvent({loadResults}) {
 | 
					    async entitiesReloadedEvent({loadResults}) {
 | 
				
			||||||
        const activeNode = this.getActiveNode();
 | 
					        const activeNode = this.getActiveNode();
 | 
				
			||||||
 | 
					        const nextNode = activeNode ? (activeNode.getNextSibling() || activeNode.getPrevSibling() || activeNode.getParent()) : null;
 | 
				
			||||||
        const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;
 | 
					        const activeNotePath = activeNode ? treeService.getNotePath(activeNode) : null;
 | 
				
			||||||
 | 
					        const nextNotePath = nextNode ? treeService.getNotePath(nextNode) : null;
 | 
				
			||||||
        const activeNoteId = activeNode ? activeNode.data.noteId : null;
 | 
					        const activeNoteId = activeNode ? activeNode.data.noteId : null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const noteIdsToUpdate = new Set();
 | 
					        const noteIdsToUpdate = new Set();
 | 
				
			||||||
@@ -929,6 +931,17 @@ export default class NoteTreeWidget extends TabAwareWidget {
 | 
				
			|||||||
            if (node) {
 | 
					            if (node) {
 | 
				
			||||||
                node.setActive(true, {noEvents: true});
 | 
					                node.setActive(true, {noEvents: true});
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                // this is used when original note has been deleted and we want to move the focus to the note above/below
 | 
				
			||||||
 | 
					                node = await this.expandToNote(nextNotePath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (node) {
 | 
				
			||||||
 | 
					                    this.tree.setFocus();
 | 
				
			||||||
 | 
					                    node.setFocus(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    await appContext.tabManager.getActiveTabContext().setNote(nextNotePath);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -602,18 +602,23 @@ export default class TabRowWidget extends BasicWidget {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    updateTab($tab, note) {
 | 
					    updateTab($tab, note) {
 | 
				
			||||||
        if (!note || !$tab.length) {
 | 
					        if (!$tab.length) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.updateTitle($tab, note.title);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (const clazz of Array.from($tab[0].classList)) { // create copy to safely iterate over while removing classes
 | 
					        for (const clazz of Array.from($tab[0].classList)) { // create copy to safely iterate over while removing classes
 | 
				
			||||||
            if (clazz !== 'note-tab') {
 | 
					            if (clazz !== 'note-tab') {
 | 
				
			||||||
                $tab.removeClass(clazz);
 | 
					                $tab.removeClass(clazz);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!note) {
 | 
				
			||||||
 | 
					            this.updateTitle($tab, 'New tab');
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.updateTitle($tab, note.title);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $tab.addClass(note.getCssClass());
 | 
					        $tab.addClass(note.getCssClass());
 | 
				
			||||||
        $tab.addClass(utils.getNoteTypeClass(note.type));
 | 
					        $tab.addClass(utils.getNoteTypeClass(note.type));
 | 
				
			||||||
        $tab.addClass(utils.getMimeTypeClass(note.mime));
 | 
					        $tab.addClass(utils.getMimeTypeClass(note.mime));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,10 @@ const TPL = `
 | 
				
			|||||||
    .note-detail-readonly-text p:first-child, .note-detail-text::before {
 | 
					    .note-detail-readonly-text p:first-child, .note-detail-text::before {
 | 
				
			||||||
        margin-top: 0;
 | 
					        margin-top: 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    .note-detail-readonly-text img {
 | 
				
			||||||
 | 
					        max-width: 100%;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    </style>
 | 
					    </style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div class="alert alert-warning no-print">
 | 
					    <div class="alert alert-warning no-print">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -221,6 +221,7 @@ async function transactional(func) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            await commit();
 | 
					            await commit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // note that sync rows sent from this action will be sent again by scheduled periodic ping
 | 
				
			||||||
            require('./ws.js').sendPingToAllClients();
 | 
					            require('./ws.js').sendPingToAllClients();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            transactionActive = false;
 | 
					            transactionActive = false;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user