1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-11-04 13:31:45 +03:00

API: Re-ordered routes, Improved navigation

Updated route order to follow some kind of logic.
Updated scrolling sidebar to not be so cut-off in various scenarios.
Added new nav helper to quick jump to specific API models.

Closes #5865
This commit is contained in:
Dan Brown
2025-11-02 14:29:00 +00:00
parent 4a57933cd1
commit d40a68b411
5 changed files with 148 additions and 84 deletions

View File

@@ -0,0 +1,32 @@
import {Component} from "./component";
export class ApiNav extends Component {
private select!: HTMLSelectElement;
private sidebar!: HTMLElement;
private body!: HTMLElement;
setup() {
this.select = this.$refs.select as HTMLSelectElement;
this.sidebar = this.$refs.sidebar;
this.body = this.$el.ownerDocument.documentElement;
this.select.addEventListener('change', () => {
const section = this.select.value;
const sidebarTarget = document.getElementById(`sidebar-header-${section}`);
const contentTarget = document.getElementById(`section-${section}`);
if (sidebarTarget && contentTarget) {
const sidebarPos = sidebarTarget.getBoundingClientRect().top - this.sidebar.getBoundingClientRect().top + this.sidebar.scrollTop;
this.sidebar.scrollTo({
top: sidebarPos - 120,
behavior: 'smooth',
});
const bodyPos = contentTarget.getBoundingClientRect().top + this.body.scrollTop;
this.body.scrollTo({
top: bodyPos - 20,
behavior: 'smooth',
});
}
});
}
}