diff --git a/frontend/src/components/render-page/render-page-content.tsx b/frontend/src/components/render-page/render-page-content.tsx index 51635f238..b9789840f 100644 --- a/frontend/src/components/render-page/render-page-content.tsx +++ b/frontend/src/components/render-page/render-page-content.tsx @@ -16,13 +16,15 @@ import { CommunicationMessageType, RendererType } from './window-post-message-co import { countWords } from './word-counter' import type { SlideOptions } from '@hedgedoc/commons' import { EventEmitter2 } from 'eventemitter2' -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import React, { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react' /** * Wraps the markdown rendering in an iframe. */ export const RenderPageContent: React.FC = () => { - const [markdownContentLines, setMarkdownContentLines] = useState([]) + const [wantedMarkdownContentLines, setWantedMarkdownContentLines] = useState([]) + const deferredMarkdownContentLines = useDeferredValue(wantedMarkdownContentLines) + const [scrollState, setScrollState] = useState({ firstLineInView: 1, scrolledPercentage: 0 }) const [baseConfiguration, setBaseConfiguration] = useState(undefined) const communicator = useRendererToEditorCommunicator() @@ -49,7 +51,7 @@ export const RenderPageContent: React.FC = () => { useRendererReceiveHandler( CommunicationMessageType.SET_MARKDOWN_CONTENT, - useCallback((values) => setMarkdownContentLines(values.content), []) + useCallback((values) => setWantedMarkdownContentLines(values.content), []) ) useRendererReceiveHandler( @@ -119,7 +121,7 @@ export const RenderPageContent: React.FC = () => { case RendererType.DOCUMENT: return ( { case RendererType.SLIDESHOW: return ( { case RendererType.SIMPLE: return ( { } }, [ baseConfiguration, - markdownContentLines, + deferredMarkdownContentLines, newLinesAreBreaks, onHeightChange, onMakeScrollSource,