use active-leaf-change event instead of click for tracking active editor

This commit is contained in:
dartungar 2023-01-01 12:27:03 +06:00
parent 8b8c17d5b8
commit 88d3376a81
2 changed files with 2 additions and 2 deletions

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) [year] [fullname]
Copyright (c) [2023] [Daniel Nikolaev]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -27,7 +27,7 @@ export default class MermaidPlugin extends Plugin {
// keep track of last active editor
// cannot simply call this.app.workspace.activeEditor ad hoc
// because Editor will be null when using Mermaid toolbar view
this.registerDomEvent(document, 'click', () => {
this.app.workspace.on('active-leaf-change', (leaf) => {
this.activeEditor = this.app.workspace.activeEditor?.editor ?? this.activeEditor;
});