mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-07 05:20:32 +03:00
feat: new option disableSearch
This commit is contained in:
parent
fec4605115
commit
d4ab5adc17
|
@ -220,6 +220,7 @@ You can use all of the following options with standalone version on <redoc> tag
|
||||||
* `hideLoading` - do not show loading animation. Useful for small docs
|
* `hideLoading` - do not show loading animation. Useful for small docs
|
||||||
* `nativeScrollbars` - use native scrollbar for sidemenu instead of perfect-scroll (scrolling performance optimization for big specs)
|
* `nativeScrollbars` - use native scrollbar for sidemenu instead of perfect-scroll (scrolling performance optimization for big specs)
|
||||||
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
||||||
|
* `disableSearch` - disable search indexing and search box
|
||||||
* `theme` - ReDoc theme. Not documented yet. For details check source code: [theme.ts](https://github.com/Rebilly/ReDoc/blob/master/src/theme.ts)
|
* `theme` - ReDoc theme. Not documented yet. For details check source code: [theme.ts](https://github.com/Rebilly/ReDoc/blob/master/src/theme.ts)
|
||||||
|
|
||||||
## Advanced usage of standalone version
|
## Advanced usage of standalone version
|
||||||
|
|
|
@ -42,12 +42,15 @@ export class Redoc extends React.Component<RedocProps> {
|
||||||
<RedocWrap className="redoc-wrap">
|
<RedocWrap className="redoc-wrap">
|
||||||
<StickyResponsiveSidebar menu={menu} className="menu-content">
|
<StickyResponsiveSidebar menu={menu} className="menu-content">
|
||||||
<ApiLogo info={spec.info} />
|
<ApiLogo info={spec.info} />
|
||||||
|
{(!options.disableSearch && (
|
||||||
<SearchBox
|
<SearchBox
|
||||||
search={search}
|
search={search!}
|
||||||
marker={marker}
|
marker={marker}
|
||||||
getItemById={menu.getItemById}
|
getItemById={menu.getItemById}
|
||||||
onActivate={menu.activateAndScroll}
|
onActivate={menu.activateAndScroll}
|
||||||
/>
|
/>
|
||||||
|
)) ||
|
||||||
|
null}
|
||||||
<SideMenu menu={menu} />
|
<SideMenu menu={menu} />
|
||||||
</StickyResponsiveSidebar>
|
</StickyResponsiveSidebar>
|
||||||
<ApiContentWrap className="api-content">
|
<ApiContentWrap className="api-content">
|
||||||
|
|
|
@ -41,7 +41,9 @@ export class AppStore {
|
||||||
const inst = new AppStore(state.spec.data, state.spec.url, state.options, false);
|
const inst = new AppStore(state.spec.data, state.spec.url, state.options, false);
|
||||||
inst.menu.activeItemIdx = state.menu.activeItemIdx || 0;
|
inst.menu.activeItemIdx = state.menu.activeItemIdx || 0;
|
||||||
inst.menu.activate(inst.menu.flatItems[inst.menu.activeItemIdx]);
|
inst.menu.activate(inst.menu.flatItems[inst.menu.activeItemIdx]);
|
||||||
inst.search.load(state.searchIndex);
|
if (!inst.options.disableSearch) {
|
||||||
|
inst.search!.load(state.searchIndex);
|
||||||
|
}
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +51,7 @@ export class AppStore {
|
||||||
spec: SpecStore;
|
spec: SpecStore;
|
||||||
rawOptions: RedocRawOptions;
|
rawOptions: RedocRawOptions;
|
||||||
options: RedocNormalizedOptions;
|
options: RedocNormalizedOptions;
|
||||||
search: SearchStore<string>;
|
search?: SearchStore<string>;
|
||||||
marker = new MarkerService();
|
marker = new MarkerService();
|
||||||
|
|
||||||
private scroll: ScrollService;
|
private scroll: ScrollService;
|
||||||
|
@ -71,6 +73,7 @@ export class AppStore {
|
||||||
this.spec = new SpecStore(spec, specUrl, this.options);
|
this.spec = new SpecStore(spec, specUrl, this.options);
|
||||||
this.menu = new MenuStore(this.spec, this.scroll);
|
this.menu = new MenuStore(this.spec, this.scroll);
|
||||||
|
|
||||||
|
if (!this.options.disableSearch) {
|
||||||
this.search = new SearchStore();
|
this.search = new SearchStore();
|
||||||
if (createSearchIndex) {
|
if (createSearchIndex) {
|
||||||
this.search.indexItems(this.menu.items);
|
this.search.indexItems(this.menu.items);
|
||||||
|
@ -80,6 +83,7 @@ export class AppStore {
|
||||||
this.updateMarkOnMenu(change.newValue as number);
|
this.updateMarkOnMenu(change.newValue as number);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onDidMount() {
|
onDidMount() {
|
||||||
this.menu.updateOnHash();
|
this.menu.updateOnHash();
|
||||||
|
@ -128,7 +132,7 @@ export class AppStore {
|
||||||
url: this.spec.parser.specUrl,
|
url: this.spec.parser.specUrl,
|
||||||
data: this.spec.parser.spec,
|
data: this.spec.parser.spec,
|
||||||
},
|
},
|
||||||
searchIndex: await this.search.toJS(),
|
searchIndex: this.search ? await this.search.toJS() : undefined,
|
||||||
options: this.rawOptions,
|
options: this.rawOptions,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ export interface RedocRawOptions {
|
||||||
untrustedSpec?: boolean | string;
|
untrustedSpec?: boolean | string;
|
||||||
hideLoading?: boolean | string;
|
hideLoading?: boolean | string;
|
||||||
hideDownloadButton?: boolean | string;
|
hideDownloadButton?: boolean | string;
|
||||||
|
disableSearch?: boolean | string;
|
||||||
|
|
||||||
unstable_ignoreMimeParameters?: boolean;
|
unstable_ignoreMimeParameters?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +94,7 @@ export class RedocNormalizedOptions {
|
||||||
pathInMiddlePanel: boolean;
|
pathInMiddlePanel: boolean;
|
||||||
untrustedSpec: boolean;
|
untrustedSpec: boolean;
|
||||||
hideDownloadButton: boolean;
|
hideDownloadButton: boolean;
|
||||||
|
disableSearch: boolean;
|
||||||
|
|
||||||
/* tslint:disable-next-line */
|
/* tslint:disable-next-line */
|
||||||
unstable_ignoreMimeParameters: boolean;
|
unstable_ignoreMimeParameters: boolean;
|
||||||
|
@ -115,6 +117,7 @@ export class RedocNormalizedOptions {
|
||||||
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
||||||
this.untrustedSpec = argValueToBoolean(raw.untrustedSpec);
|
this.untrustedSpec = argValueToBoolean(raw.untrustedSpec);
|
||||||
this.hideDownloadButton = argValueToBoolean(raw.hideDownloadButton);
|
this.hideDownloadButton = argValueToBoolean(raw.hideDownloadButton);
|
||||||
|
this.disableSearch = argValueToBoolean(raw.disableSearch);
|
||||||
|
|
||||||
this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters);
|
this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user