mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-25 10:03:45 +03:00
fix: fix major search performance due to wrong marker element
fixes #1109
This commit is contained in:
parent
7608800d0a
commit
8c053cc474
|
@ -100,7 +100,7 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
|
|||
)) ||
|
||||
null}
|
||||
</StyledMarkdownBlock>
|
||||
<Markdown source={store.spec.info.description} />
|
||||
<Markdown source={store.spec.info.description} data-role="redoc-description" />
|
||||
{externalDocs && <ExternalDocumentation externalDocs={externalDocs} />}
|
||||
</MiddlePanel>
|
||||
</Row>
|
||||
|
|
|
@ -17,11 +17,12 @@ export type MarkdownProps = BaseMarkdownProps &
|
|||
StylingMarkdownProps & {
|
||||
source: string;
|
||||
className?: string;
|
||||
'data-role'?: string;
|
||||
};
|
||||
|
||||
export class Markdown extends React.Component<MarkdownProps> {
|
||||
render() {
|
||||
const { source, inline, compact, className } = this.props;
|
||||
const { source, inline, compact, className, 'data-role': dataRole } = this.props;
|
||||
const renderer = new MarkdownRenderer();
|
||||
return (
|
||||
<SanitizedMarkdownHTML
|
||||
|
@ -29,6 +30,7 @@ export class Markdown extends React.Component<MarkdownProps> {
|
|||
inline={inline}
|
||||
compact={compact}
|
||||
className={className}
|
||||
data-role={dataRole}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ const StyledMarkdownSpan = StyledMarkdownBlock.withComponent('span');
|
|||
const sanitize = (untrustedSpec, html) => (untrustedSpec ? DOMPurify.sanitize(html) : html);
|
||||
|
||||
export function SanitizedMarkdownHTML(
|
||||
props: StylingMarkdownProps & { html: string; className?: string },
|
||||
props: StylingMarkdownProps & { html: string; className?: string; 'data-role'?: string },
|
||||
) {
|
||||
const Wrap = props.inline ? StyledMarkdownSpan : StyledMarkdownBlock;
|
||||
|
||||
|
@ -22,6 +22,7 @@ export function SanitizedMarkdownHTML(
|
|||
dangerouslySetInnerHTML={{
|
||||
__html: sanitize(options.untrustedSpec, props.html),
|
||||
}}
|
||||
data-role={props['data-role']}
|
||||
{...props}
|
||||
/>
|
||||
)}
|
||||
|
|
|
@ -18,6 +18,8 @@ import {
|
|||
SECURITY_DEFINITIONS_JSX_NAME,
|
||||
} from '../utils/openapi';
|
||||
|
||||
import { IS_BROWSER } from '../utils';
|
||||
|
||||
export interface StoreState {
|
||||
menu: {
|
||||
activeItemIdx: number;
|
||||
|
@ -134,16 +136,16 @@ export class AppStore {
|
|||
|
||||
const elements: Element[] = [];
|
||||
for (let i = start; i < end; i++) {
|
||||
let elem = this.menu.getElementAt(i);
|
||||
const elem = this.menu.getElementAt(i);
|
||||
if (!elem) {
|
||||
continue;
|
||||
}
|
||||
if (this.menu.flatItems[i].type === 'section') {
|
||||
elem = elem.parentElement!.parentElement;
|
||||
}
|
||||
if (elem) {
|
||||
elements.push(elem);
|
||||
}
|
||||
elements.push(elem);
|
||||
}
|
||||
|
||||
if (idx === -1 && IS_BROWSER) {
|
||||
const $description = document.querySelector('[data-role="redoc-description"]');
|
||||
if ($description) elements.push($description);
|
||||
}
|
||||
|
||||
this.marker.addOnly(elements);
|
||||
|
|
Loading…
Reference in New Issue
Block a user