diff --git a/main.js b/main.js index 8055b9a..c837b76 100644 --- a/main.js +++ b/main.js @@ -7,9 +7,18 @@ module.exports = class RibbonOrderLock extends Plugin { this.app.workspace.onLayoutReady(() => { this.patchRibbon(); this.enforceOrder(); + this.observeRibbon(); }); } + observeRibbon() { + const ribbon = this.app.workspace.leftRibbon; + const containerEl = ribbon.ribbonItemsEl; + + this.observer = new MutationObserver(() => this.enforceOrder()); + this.observer.observe(containerEl, { childList: true }); + } + // hook the ribbon's own onChange so drags and hide/show toggles update // our saved order automatically, same as Obsidian's native reorder does patchRibbon() {