mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-10-31 15:57:30 +03:00 
			
		
		
		
	feat: make virtualization configurable where the default is not using virtualization
This commit is contained in:
		
							parent
							
								
									2e5c98e9fc
								
							
						
					
					
						commit
						80509a8ceb
					
				|  | @ -166,6 +166,12 @@ _Default: false_ | ||||||
| 
 | 
 | ||||||
| If set to `true`, the API definition is considered untrusted and all HTML/Markdown is sanitized to prevent XSS. | If set to `true`, the API definition is considered untrusted and all HTML/Markdown is sanitized to prevent XSS. | ||||||
| 
 | 
 | ||||||
|  | ### enableVirtualization | ||||||
|  | 
 | ||||||
|  | If set to `true`, the API documentation content will use virtualization. Virtualization only renders the API content when it is currently visible in user's viewport. | ||||||
|  | 
 | ||||||
|  | _Default: false_ | ||||||
|  | 
 | ||||||
| ## Theme settings | ## Theme settings | ||||||
| 
 | 
 | ||||||
| * `spacing` | * `spacing` | ||||||
|  |  | ||||||
|  | @ -14,6 +14,8 @@ import { ApiContentWrap, BackgroundStub, RedocWrap } from './styled.elements'; | ||||||
| import { SearchBox } from '../SearchBox/SearchBox'; | import { SearchBox } from '../SearchBox/SearchBox'; | ||||||
| import { StoreProvider } from '../StoreBuilder'; | import { StoreProvider } from '../StoreBuilder'; | ||||||
| import VirtualizedContent from '../Virtualization/VirtualizedContent'; | import VirtualizedContent from '../Virtualization/VirtualizedContent'; | ||||||
|  | import { ApiInfo } from '../ApiInfo/ApiInfo'; | ||||||
|  | import { ContentItems } from '../ContentItems/ContentItems'; | ||||||
| 
 | 
 | ||||||
| export interface RedocProps { | export interface RedocProps { | ||||||
|   store: AppStore; |   store: AppStore; | ||||||
|  | @ -56,7 +58,14 @@ export class Redoc extends React.Component<RedocProps> { | ||||||
|                 <SideMenu menu={menu} /> |                 <SideMenu menu={menu} /> | ||||||
|               </StickyResponsiveSidebar> |               </StickyResponsiveSidebar> | ||||||
|               <ApiContentWrap className="api-content"> |               <ApiContentWrap className="api-content"> | ||||||
|                 <VirtualizedContent store={store} menu={menu} /> |                 {options.enableVirtualization ? ( | ||||||
|  |                   <VirtualizedContent store={store} menu={menu} /> | ||||||
|  |                 ) : ( | ||||||
|  |                   <> | ||||||
|  |                     <ApiInfo store={store} /> | ||||||
|  |                     <ContentItems items={menu.items as any} /> | ||||||
|  |                   </> | ||||||
|  |                 )} | ||||||
|               </ApiContentWrap> |               </ApiContentWrap> | ||||||
|               <BackgroundStub /> |               <BackgroundStub /> | ||||||
|             </RedocWrap> |             </RedocWrap> | ||||||
|  |  | ||||||
|  | @ -79,6 +79,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|                     "disableSearch": false, |                     "disableSearch": false, | ||||||
|                     "downloadDefinitionUrl": undefined, |                     "downloadDefinitionUrl": undefined, | ||||||
|                     "downloadFileName": undefined, |                     "downloadFileName": undefined, | ||||||
|  |                     "enableVirtualization": false, | ||||||
|                     "enumSkipQuotes": false, |                     "enumSkipQuotes": false, | ||||||
|                     "expandDefaultServerVariables": false, |                     "expandDefaultServerVariables": false, | ||||||
|                     "expandResponses": {}, |                     "expandResponses": {}, | ||||||
|  | @ -351,6 +352,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|                     "disableSearch": false, |                     "disableSearch": false, | ||||||
|                     "downloadDefinitionUrl": undefined, |                     "downloadDefinitionUrl": undefined, | ||||||
|                     "downloadFileName": undefined, |                     "downloadFileName": undefined, | ||||||
|  |                     "enableVirtualization": false, | ||||||
|                     "enumSkipQuotes": false, |                     "enumSkipQuotes": false, | ||||||
|                     "expandDefaultServerVariables": false, |                     "expandDefaultServerVariables": false, | ||||||
|                     "expandResponses": {}, |                     "expandResponses": {}, | ||||||
|  | @ -610,6 +612,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|               "disableSearch": false, |               "disableSearch": false, | ||||||
|               "downloadDefinitionUrl": undefined, |               "downloadDefinitionUrl": undefined, | ||||||
|               "downloadFileName": undefined, |               "downloadFileName": undefined, | ||||||
|  |               "enableVirtualization": false, | ||||||
|               "enumSkipQuotes": false, |               "enumSkipQuotes": false, | ||||||
|               "expandDefaultServerVariables": false, |               "expandDefaultServerVariables": false, | ||||||
|               "expandResponses": {}, |               "expandResponses": {}, | ||||||
|  | @ -931,6 +934,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|                     "disableSearch": false, |                     "disableSearch": false, | ||||||
|                     "downloadDefinitionUrl": undefined, |                     "downloadDefinitionUrl": undefined, | ||||||
|                     "downloadFileName": undefined, |                     "downloadFileName": undefined, | ||||||
|  |                     "enableVirtualization": false, | ||||||
|                     "enumSkipQuotes": false, |                     "enumSkipQuotes": false, | ||||||
|                     "expandDefaultServerVariables": false, |                     "expandDefaultServerVariables": false, | ||||||
|                     "expandResponses": {}, |                     "expandResponses": {}, | ||||||
|  | @ -1215,6 +1219,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|                     "disableSearch": false, |                     "disableSearch": false, | ||||||
|                     "downloadDefinitionUrl": undefined, |                     "downloadDefinitionUrl": undefined, | ||||||
|                     "downloadFileName": undefined, |                     "downloadFileName": undefined, | ||||||
|  |                     "enableVirtualization": false, | ||||||
|                     "enumSkipQuotes": false, |                     "enumSkipQuotes": false, | ||||||
|                     "expandDefaultServerVariables": false, |                     "expandDefaultServerVariables": false, | ||||||
|                     "expandResponses": {}, |                     "expandResponses": {}, | ||||||
|  | @ -1470,6 +1475,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|               "disableSearch": false, |               "disableSearch": false, | ||||||
|               "downloadDefinitionUrl": undefined, |               "downloadDefinitionUrl": undefined, | ||||||
|               "downloadFileName": undefined, |               "downloadFileName": undefined, | ||||||
|  |               "enableVirtualization": false, | ||||||
|               "enumSkipQuotes": false, |               "enumSkipQuotes": false, | ||||||
|               "expandDefaultServerVariables": false, |               "expandDefaultServerVariables": false, | ||||||
|               "expandResponses": {}, |               "expandResponses": {}, | ||||||
|  | @ -1750,6 +1756,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|           "disableSearch": false, |           "disableSearch": false, | ||||||
|           "downloadDefinitionUrl": undefined, |           "downloadDefinitionUrl": undefined, | ||||||
|           "downloadFileName": undefined, |           "downloadFileName": undefined, | ||||||
|  |           "enableVirtualization": false, | ||||||
|           "enumSkipQuotes": false, |           "enumSkipQuotes": false, | ||||||
|           "expandDefaultServerVariables": false, |           "expandDefaultServerVariables": false, | ||||||
|           "expandResponses": {}, |           "expandResponses": {}, | ||||||
|  | @ -2060,6 +2067,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|               "disableSearch": false, |               "disableSearch": false, | ||||||
|               "downloadDefinitionUrl": undefined, |               "downloadDefinitionUrl": undefined, | ||||||
|               "downloadFileName": undefined, |               "downloadFileName": undefined, | ||||||
|  |               "enableVirtualization": false, | ||||||
|               "enumSkipQuotes": false, |               "enumSkipQuotes": false, | ||||||
|               "expandDefaultServerVariables": false, |               "expandDefaultServerVariables": false, | ||||||
|               "expandResponses": {}, |               "expandResponses": {}, | ||||||
|  | @ -2332,6 +2340,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|               "disableSearch": false, |               "disableSearch": false, | ||||||
|               "downloadDefinitionUrl": undefined, |               "downloadDefinitionUrl": undefined, | ||||||
|               "downloadFileName": undefined, |               "downloadFileName": undefined, | ||||||
|  |               "enableVirtualization": false, | ||||||
|               "enumSkipQuotes": false, |               "enumSkipQuotes": false, | ||||||
|               "expandDefaultServerVariables": false, |               "expandDefaultServerVariables": false, | ||||||
|               "expandResponses": {}, |               "expandResponses": {}, | ||||||
|  | @ -2591,6 +2600,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|         "disableSearch": false, |         "disableSearch": false, | ||||||
|         "downloadDefinitionUrl": undefined, |         "downloadDefinitionUrl": undefined, | ||||||
|         "downloadFileName": undefined, |         "downloadFileName": undefined, | ||||||
|  |         "enableVirtualization": false, | ||||||
|         "enumSkipQuotes": false, |         "enumSkipQuotes": false, | ||||||
|         "expandDefaultServerVariables": false, |         "expandDefaultServerVariables": false, | ||||||
|         "expandResponses": {}, |         "expandResponses": {}, | ||||||
|  |  | ||||||
|  | @ -57,6 +57,8 @@ export interface RedocRawOptions { | ||||||
|   hideFab?: boolean; |   hideFab?: boolean; | ||||||
|   minCharacterLengthToInitSearch?: number; |   minCharacterLengthToInitSearch?: number; | ||||||
|   showWebhookVerb?: boolean; |   showWebhookVerb?: boolean; | ||||||
|  | 
 | ||||||
|  |   enableVirtualization?: boolean | string; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean { | export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean { | ||||||
|  | @ -259,6 +261,8 @@ export class RedocNormalizedOptions { | ||||||
|   minCharacterLengthToInitSearch: number; |   minCharacterLengthToInitSearch: number; | ||||||
|   showWebhookVerb: boolean; |   showWebhookVerb: boolean; | ||||||
| 
 | 
 | ||||||
|  |   enableVirtualization: boolean; | ||||||
|  | 
 | ||||||
|   nonce?: string; |   nonce?: string; | ||||||
| 
 | 
 | ||||||
|   constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) { |   constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) { | ||||||
|  | @ -338,5 +342,6 @@ export class RedocNormalizedOptions { | ||||||
|     this.hideFab = argValueToBoolean(raw.hideFab); |     this.hideFab = argValueToBoolean(raw.hideFab); | ||||||
|     this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3; |     this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3; | ||||||
|     this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb); |     this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb); | ||||||
|  |     this.enableVirtualization = argValueToBoolean(raw.enableVirtualization); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user