feat(theme-mermaid): upgrade Mermaid to v10.4 - handle async rendering (#9305)

This commit is contained in:
Sébastien Lorber 2023-09-14 17:23:07 +02:00 committed by GitHub
parent dc7ae426ac
commit 58be496da2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 327 additions and 86 deletions

View file

@ -107,5 +107,6 @@ export {
export {
ErrorBoundaryTryAgainButton,
ErrorBoundaryError,
ErrorBoundaryErrorMessageFallback,
ErrorCauseBoundary,
} from './utils/errorBoundaryUtils';

View file

@ -9,3 +9,8 @@
white-space: pre-wrap;
color: red;
}
.errorBoundaryFallback {
color: red;
padding: 0.55rem;
}

View file

@ -8,6 +8,7 @@
import React, {type ComponentProps} from 'react';
import Translate from '@docusaurus/Translate';
import {getErrorCausalChain} from '@docusaurus/utils-common';
import type {Props as ErrorProps} from '@theme/Error';
import styles from './errorBoundaryUtils.module.css';
export function ErrorBoundaryTryAgainButton(
@ -23,6 +24,20 @@ export function ErrorBoundaryTryAgainButton(
</button>
);
}
// A very simple reusable ErrorBoundary fallback component
export function ErrorBoundaryErrorMessageFallback({
error,
tryAgain,
}: ErrorProps): JSX.Element {
return (
<div className={styles.errorBoundaryFallback}>
<p>{error.message}</p>
<ErrorBoundaryTryAgainButton onClick={tryAgain} />
</div>
);
}
export function ErrorBoundaryError({error}: {error: Error}): JSX.Element {
const causalChain = getErrorCausalChain(error);
const fullMessage = causalChain.map((e) => e.message).join('\n\nCause:\n');