diff --git a/src/components/ContentItems/ContentItems.tsx b/src/components/ContentItems/ContentItems.tsx index f7441990..5d299ff9 100644 --- a/src/components/ContentItems/ContentItems.tsx +++ b/src/components/ContentItems/ContentItems.tsx @@ -9,7 +9,6 @@ import { ContentItemModel } from '../../services/MenuBuilder'; import { GroupModel, OperationModel } from '../../services/models'; import { Operation } from '../Operation/Operation'; import { SecurityDefs } from '../SecuritySchemes/SecuritySchemes'; -import { StoreConsumer } from '../StoreBuilder'; const DEFAULT_ALLOWED_COMPONENTS = { 'security-definitions': { @@ -74,7 +73,7 @@ export class ContentItem extends React.Component { return ( <> -
+
{content}
{item.items && ( @@ -91,7 +90,8 @@ const middlePanelWrap = component => {component}; export class SectionItem extends React.Component { render() { const { name, description, level } = this.props.item as GroupModel; - const components = this.props.allowedMdComponents; + const { allowedMdComponents } = this.props; + const Header = level === 2 ? H2 : H1; return ( <> @@ -103,16 +103,11 @@ export class SectionItem extends React.Component { - - {store => ( - - )} - + ); } diff --git a/src/components/Markdown/AdvancedMarkdown.tsx b/src/components/Markdown/AdvancedMarkdown.tsx index 5b4a1f90..cba6232f 100644 --- a/src/components/Markdown/AdvancedMarkdown.tsx +++ b/src/components/Markdown/AdvancedMarkdown.tsx @@ -4,16 +4,20 @@ import { AppStore, MarkdownRenderer, MDXComponentMeta } from '../../services'; import { BaseMarkdownProps } from './Markdown'; import { SanitizedMarkdownHTML } from './SanitizedMdBlock'; +import { StoreConsumer } from '../StoreBuilder'; + export interface AdvancedMarkdownProps extends BaseMarkdownProps { - store?: AppStore; allowedComponents: Dict; htmlWrap?: (part: JSX.Element) => JSX.Element; } export class AdvancedMarkdown extends React.Component { render() { - const { store, source, allowedComponents, htmlWrap = i => i } = this.props; + return {store => this.renderWithStore(store)}; + } + renderWithStore(store?: AppStore) { + const { allowedComponents, source, htmlWrap = i => i } = this.props; if (!store) { throw new Error('When using componentes in markdown, store prop must be provided'); } diff --git a/src/components/Markdown/SanitizedMdBlock.tsx b/src/components/Markdown/SanitizedMdBlock.tsx index 30903ddf..9f0a8cb4 100644 --- a/src/components/Markdown/SanitizedMdBlock.tsx +++ b/src/components/Markdown/SanitizedMdBlock.tsx @@ -1,7 +1,7 @@ import * as DOMPurify from 'dompurify'; import * as React from 'react'; -import { OptionsContext } from '../OptionsProvider'; +import { OptionsConsumer } from '../OptionsProvider'; import { StylingMarkdownProps } from './Markdown'; import { StyledMarkdownBlock } from './styled.elements'; @@ -15,7 +15,7 @@ export function SanitizedMarkdownHTML( const Wrap = props.inline ? StyledMarkdownSpan : StyledMarkdownBlock; return ( - + {options => ( )} - + ); } diff --git a/src/services/MenuStore.ts b/src/services/MenuStore.ts index bee6c63e..e4fd4d43 100644 --- a/src/services/MenuStore.ts +++ b/src/services/MenuStore.ts @@ -74,7 +74,7 @@ export class MenuStore { * @param scroll scroll service instance used by this menu */ constructor(spec: SpecStore, public scroll: ScrollService) { - this.items = spec.operationGroups; + this.items = spec.contentItems; this.flatItems = flattenByProp(this.items || [], 'items'); this.flatItems.forEach((item, idx) => (item.absoluteIdx = idx)); diff --git a/src/services/SpecStore.ts b/src/services/SpecStore.ts index 2f0ab5e5..dcb39941 100644 --- a/src/services/SpecStore.ts +++ b/src/services/SpecStore.ts @@ -13,7 +13,7 @@ export class SpecStore { info: ApiInfoModel; externalDocs?: OpenAPIExternalDocumentation; - operationGroups: ContentItemModel[]; + contentItems: ContentItemModel[]; securitySchemes: SecuritySchemesModel; constructor( @@ -24,8 +24,7 @@ export class SpecStore { this.parser = new OpenAPIParser(spec, specUrl, options); this.info = new ApiInfoModel(this.parser); this.externalDocs = this.parser.spec.externalDocs; - this.operationGroups = MenuBuilder.buildStructure(this.parser, this.options); - + this.contentItems = MenuBuilder.buildStructure(this.parser, this.options); this.securitySchemes = new SecuritySchemesModel(this.parser); } }