Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
fix: support 0.15.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kometenstaub committed Jul 5, 2022
1 parent ba6d3c8 commit 1f40baa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 8 additions & 15 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Platform,
Plugin,
View,
Workspace,
WorkspaceLeaf,
WorkspaceWindow,
Expand Down Expand Up @@ -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);
});
}

Expand Down Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 1f40baa

Please sign in to comment.