remember the new order when icons get dragged around

This commit is contained in:
2026-06-13 00:27:15 +06:00
parent 1c8cfb3004
commit 82b2b701b0
+17
View File
@@ -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;