remember the new order when icons get dragged around
This commit is contained in:
@@ -5,10 +5,27 @@ module.exports = class RibbonOrderLock extends Plugin {
|
|||||||
this.settings = Object.assign({ order: [] }, await this.loadData());
|
this.settings = Object.assign({ order: [] }, await this.loadData());
|
||||||
|
|
||||||
this.app.workspace.onLayoutReady(() => {
|
this.app.workspace.onLayoutReady(() => {
|
||||||
|
this.patchRibbon();
|
||||||
this.enforceOrder();
|
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() {
|
enforceOrder() {
|
||||||
const ribbon = this.app.workspace.leftRibbon;
|
const ribbon = this.app.workspace.leftRibbon;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user