From 82b2b701b02c279535be76aac0495e4e12355e2c Mon Sep 17 00:00:00 2001 From: bdeshi Date: Sat, 13 Jun 2026 00:27:15 +0600 Subject: [PATCH] remember the new order when icons get dragged around --- main.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main.js b/main.js index f55fa28..ede39d8 100644 --- a/main.js +++ b/main.js @@ -5,10 +5,27 @@ module.exports = class RibbonOrderLock extends Plugin { this.settings = Object.assign({ order: [] }, await this.loadData()); this.app.workspace.onLayoutReady(() => { + this.patchRibbon(); this.enforceOrder(); }); } + // 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() { + const ribbon = this.app.workspace.leftRibbon; + + const original = ribbon.onChange.bind(ribbon); + this.originalOnChange = original; + + ribbon.onChange = (save) => { + original(save); + if (save) { + this.recordOrder(ribbon); + } + }; + } + enforceOrder() { const ribbon = this.app.workspace.leftRibbon;