Merge remote-tracking branch 'origin/master' into feat/add-reference-to-api-on-schema

This commit is contained in:
Depickere Sven 2023-04-25 16:07:07 +01:00
commit 77aa71133f
2 changed files with 9 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "redoc", "name": "redoc",
"version": "2.0.0-0.1.1", "version": "2.0.0-0.2.0",
"description": "ReDoc", "description": "ReDoc",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -72,6 +72,9 @@ export class AppStore {
// update position statically based on hash (in case of SSR) // update position statically based on hash (in case of SSR)
MenuStore.updateOnHistory(this.history.currentId, this.scroll); MenuStore.updateOnHistory(this.history.currentId, this.scroll);
// Listen for external event to update
window.addEventListener('redocUpdatePosition', this.updateOnEvent);
// override the openApi standard to version 3.1.0 // override the openApi standard to version 3.1.0
// TODO remove when fully supporting open API 3.1.0 // TODO remove when fully supporting open API 3.1.0
spec.openapi = '3.1.0'; spec.openapi = '3.1.0';
@ -98,6 +101,7 @@ export class AppStore {
dispose() { dispose() {
this.scroll.dispose(); this.scroll.dispose();
this.menu.dispose(); this.menu.dispose();
window.removeEventListener('redocUpdatePosition', this.updateOnEvent);
if (this.search) { if (this.search) {
this.search.dispose(); this.search.dispose();
} }
@ -125,6 +129,10 @@ export class AppStore {
}; };
} }
private updateOnEvent(): void {
MenuStore.updateOnHistory(this.history.currentId, this.scroll);
}
private updateMarkOnMenu(idx: number) { private updateMarkOnMenu(idx: number) {
const start = Math.max(0, idx); const start = Math.max(0, idx);
const end = Math.min(this.menu.flatItems.length, start + 5); const end = Math.min(this.menu.flatItems.length, start + 5);