94 lines
3.0 KiB
JavaScript
94 lines
3.0 KiB
JavaScript
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
if you want to view the source, please visit the github repository of this plugin
|
|
*/
|
|
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// main.ts
|
|
var main_exports = {};
|
|
__export(main_exports, {
|
|
default: () => CycleInSidebarPlugin
|
|
});
|
|
module.exports = __toCommonJS(main_exports);
|
|
var import_obsidian = require("obsidian");
|
|
var CycleInSidebarPlugin = class extends import_obsidian.Plugin {
|
|
getLeavesOfSidebar(split) {
|
|
const oneSideSplitRoot = split.getRoot();
|
|
const leaves = [];
|
|
this.app.workspace.iterateAllLeaves((l) => {
|
|
leaves.push(l);
|
|
});
|
|
return leaves.filter((l) => l.getRoot() === oneSideSplitRoot).filter((l) => l.view.getViewType() !== "empty");
|
|
}
|
|
isSidebarOpen(split) {
|
|
return this.getLeavesOfSidebar(split).some((l) => l.view.containerEl.clientHeight > 0);
|
|
}
|
|
cycleInSideBar(split, offset) {
|
|
const leaves = this.getLeavesOfSidebar(split);
|
|
var currentIndex = 0;
|
|
for (; currentIndex < leaves.length; currentIndex++) {
|
|
if (leaves[currentIndex].view.containerEl.clientHeight > 0)
|
|
break;
|
|
}
|
|
if (currentIndex == leaves.length)
|
|
return;
|
|
const nextIndex = (currentIndex + offset < 0 ? leaves.length - 1 : currentIndex + offset) % leaves.length;
|
|
this.app.workspace.revealLeaf(leaves[nextIndex]);
|
|
}
|
|
async cycleRightSideBar(offset) {
|
|
this.cycleInSideBar(this.app.workspace.rightSplit, offset);
|
|
}
|
|
async cycleLeftSideBar(offset) {
|
|
this.cycleInSideBar(this.app.workspace.leftSplit, offset);
|
|
}
|
|
async onload() {
|
|
this.addCommand({
|
|
id: "cycle-right-sidebar",
|
|
name: "Cycle tabs of right sidebar",
|
|
callback: () => {
|
|
this.cycleRightSideBar(1);
|
|
}
|
|
});
|
|
this.addCommand({
|
|
id: "cycle-right-sidebar-reverse",
|
|
name: "Cycle tabs of right sidebar in reverse",
|
|
callback: () => {
|
|
this.cycleRightSideBar(-1);
|
|
}
|
|
});
|
|
this.addCommand({
|
|
id: "cycle-left-sidebar",
|
|
name: "Cycle tabs of left sidebar",
|
|
callback: () => {
|
|
this.cycleLeftSideBar(1);
|
|
}
|
|
});
|
|
this.addCommand({
|
|
id: "cycle-left-sidebar-reverse",
|
|
name: "Cycle tabs of left sidebar in reverse",
|
|
callback: () => {
|
|
this.cycleLeftSideBar(-1);
|
|
}
|
|
});
|
|
}
|
|
onunload() {
|
|
}
|
|
};
|