diff --git a/manifest.json b/manifest.json index 0aba0bc..b812d83 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "id": "customizable-page-header-buttons", "name": "Customizable Page Header and Title Bar", "version": "4.5.2", - "minAppVersion": "0.15.2", + "minAppVersion": "0.15.4", "description": "This plugin lets you add buttons for executing commands to the page header and on desktop to the title bar.", "author": "kometenstaub", "authorUrl": "https://github.com/kometenstaub", diff --git a/src/main.ts b/src/main.ts index 1ca9bc7..60eea5a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,7 @@ import { Platform, Plugin, + View, Workspace, WorkspaceLeaf, WorkspaceWindow, @@ -72,13 +73,15 @@ export default class TopBarButtonsPlugin extends Plugin { viewActions.prepend(buttonIcon); - this.registerDomEvent(buttonIcon, 'click', () => { + this.registerDomEvent(buttonIcon, 'mousedown', () => { /* this way the pane gets activated from the click otherwise the action would get executed on the former active pane timeout of 1 was enough, but 5 is chosen for slower computers may need to be made its own setting in the future */ - setTimeout(() => this.app.commands.executeCommandById(id), 5); + setTimeout(() => { + this.app.commands.executeCommandById(id); + }, 5); }); } @@ -253,22 +256,12 @@ export default class TopBarButtonsPlugin extends Plugin { }) ); this.registerEvent( - this.app.workspace.on('file-open', () => { - const activeLeaf = app.workspace.getMostRecentLeaf(); - - // if that is used, the buttons don't stay when navigating to a non-markdown pane (excalidraw) - //const view = - // app.workspace.getActiveViewOfType(MarkdownView); + this.app.workspace.on('layout-change', () => { + const activeLeaf = app.workspace.getActiveViewOfType(View); if (!activeLeaf) { return; } - //let activeLeaf = view.containerEl; - /* - const activeLeaf = document.getElementsByClassName( - 'workspace-leaf mod-active' - )[0]; -*/ - this.addButtonsToLeaf(activeLeaf); + this.addButtonsToLeaf(activeLeaf.leaf); }) ); this.registerEvent( diff --git a/versions.json b/versions.json index 43ecf07..5a46e2d 100644 --- a/versions.json +++ b/versions.json @@ -3,5 +3,6 @@ "3.1.2": "0.12.19", "4.0.0": "0.13.31", "4.5.1": "0.14.15", - "4.5.2": "0.15.2" + "4.5.2": "0.15.2", + "4.6.0": "0.15.4" }