mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 06:34:39 -04:00
Fix reveal (#1563)
Fix race condition in slide show Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
3958ef550d
commit
e84ed1398f
5 changed files with 84 additions and 19 deletions
|
@ -12,7 +12,7 @@ import { useExtractFirstHeadline } from './hooks/use-extract-first-headline'
|
|||
import { TocAst } from 'markdown-it-toc-done-right'
|
||||
import { useOnRefChange } from './hooks/use-on-ref-change'
|
||||
import { useTrimmedContent } from './hooks/use-trimmed-content'
|
||||
import { useReveal } from './hooks/use-reveal'
|
||||
import { REVEAL_STATUS, useReveal } from './hooks/use-reveal'
|
||||
import './slideshow.scss'
|
||||
import { ScrollProps } from '../editor-page/synced-scroll/scroll-props'
|
||||
import { DocumentLengthLimitReachedAlert } from './document-length-limit-reached-alert'
|
||||
|
@ -20,6 +20,7 @@ import { BasicMarkdownItConfigurator } from './markdown-it-configurator/basic-ma
|
|||
import { SlideOptions } from '../common/note-frontmatter/types'
|
||||
import { processRevealCommentNodes } from './process-reveal-comment-nodes'
|
||||
import { CommonMarkdownRendererProps } from './common-markdown-renderer-props'
|
||||
import { LoadingSlide } from './loading-slide'
|
||||
|
||||
export interface SlideshowMarkdownRendererProps extends CommonMarkdownRendererProps {
|
||||
slideOptions: SlideOptions
|
||||
|
@ -59,17 +60,26 @@ export const SlideshowMarkdownRenderer: React.FC<SlideshowMarkdownRendererProps
|
|||
replacers,
|
||||
processRevealCommentNodes
|
||||
)
|
||||
const revealStatus = useReveal(content, slideOptions)
|
||||
|
||||
useExtractFirstHeadline(markdownBodyRef, content, onFirstHeadingChange)
|
||||
useExtractFirstHeadline(
|
||||
markdownBodyRef,
|
||||
revealStatus === REVEAL_STATUS.INITIALISED ? content : undefined,
|
||||
onFirstHeadingChange
|
||||
)
|
||||
useOnRefChange(tocAst, onTocChange)
|
||||
useReveal(content, slideOptions)
|
||||
|
||||
const slideShowDOM = useMemo(
|
||||
() => (revealStatus === REVEAL_STATUS.INITIALISED ? markdownReactDom : <LoadingSlide />),
|
||||
[markdownReactDom, revealStatus]
|
||||
)
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<DocumentLengthLimitReachedAlert show={contentExceedsLimit} />
|
||||
<div className={'reveal'}>
|
||||
<div ref={markdownBodyRef} className={`${className ?? ''} slides`}>
|
||||
{markdownReactDom}
|
||||
{slideShowDOM}
|
||||
</div>
|
||||
</div>
|
||||
</Fragment>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue