mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 14:14:56 +03:00
inject options into MenuStore and allow activation of group items if configured
This commit is contained in:
parent
34c152c08a
commit
3d0db68b3b
|
@ -74,7 +74,7 @@ export class AppStore {
|
|||
MenuStore.updateOnHistory(history.currentId, this.scroll);
|
||||
|
||||
this.spec = new SpecStore(spec, specUrl, this.options);
|
||||
this.menu = new MenuStore(this.spec, this.scroll, history);
|
||||
this.menu = new MenuStore(this.spec, this.scroll, history, this.options);
|
||||
|
||||
if (!this.options.disableSearch) {
|
||||
this.search = new SearchStore();
|
||||
|
|
|
@ -7,6 +7,7 @@ import { ScrollService } from './ScrollService';
|
|||
|
||||
import { flattenByProp, SECURITY_SCHEMES_SECTION_PREFIX } from '../utils';
|
||||
import { GROUP_DEPTH } from './MenuBuilder';
|
||||
import { RedocNormalizedOptions } from "./RedocNormalizedOptions";
|
||||
|
||||
export type MenuItemGroupType = 'group' | 'tag' | 'section';
|
||||
export type MenuItemType = MenuItemGroupType | 'operation';
|
||||
|
@ -75,7 +76,12 @@ export class MenuStore {
|
|||
* @param spec [SpecStore](#SpecStore) which contains page content structure
|
||||
* @param scroll scroll service instance used by this menu
|
||||
*/
|
||||
constructor(spec: SpecStore, public scroll: ScrollService, public history: HistoryService) {
|
||||
constructor(
|
||||
spec: SpecStore,
|
||||
public scroll: ScrollService,
|
||||
public history: HistoryService,
|
||||
public options: RedocNormalizedOptions
|
||||
) {
|
||||
this.items = spec.contentItems;
|
||||
|
||||
this.flatItems = flattenByProp(this.items || [], 'items');
|
||||
|
@ -197,7 +203,7 @@ export class MenuStore {
|
|||
|
||||
// do not allow activating group items
|
||||
// TODO: control over options
|
||||
if (item.depth <= GROUP_DEPTH) {
|
||||
if (item.depth <= GROUP_DEPTH && !this.options.collapseTagGroups) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user