mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 06:34:39 -04:00
Fix smooth scroll and other bugs (#1861)
This PR fixes: - The wrong clean up of window post message communicators - The smooth scroll bug in chrome (Fixes Anchor navigation in render view not working #1770) - Scroll by using touch devices in renderer - Lazy loading of the editor (code mirror doesn't need to be lazy loaded any more)
This commit is contained in:
parent
0f3f7a82b5
commit
8b4e9191e5
15 changed files with 260 additions and 213 deletions
|
@ -27,20 +27,18 @@ export const useRendererToEditorCommunicator: () => RendererToEditorCommunicator
|
|||
|
||||
export const RendererToEditorCommunicatorContextProvider: React.FC = ({ children }) => {
|
||||
const editorOrigin = useOriginFromConfig(ORIGIN_TYPE.EDITOR)
|
||||
const communicator = useMemo<RendererToEditorCommunicator>(() => {
|
||||
const newCommunicator = new RendererToEditorCommunicator()
|
||||
newCommunicator.setMessageTarget(window.parent, editorOrigin)
|
||||
return newCommunicator
|
||||
}, [editorOrigin])
|
||||
const communicator = useMemo<RendererToEditorCommunicator>(() => new RendererToEditorCommunicator(), [])
|
||||
|
||||
useEffect(() => {
|
||||
const currentCommunicator = communicator
|
||||
currentCommunicator.setMessageTarget(window.parent, editorOrigin)
|
||||
currentCommunicator.registerEventListener()
|
||||
currentCommunicator.enableCommunication()
|
||||
currentCommunicator.sendMessageToOtherSide({
|
||||
type: CommunicationMessageType.RENDERER_READY
|
||||
})
|
||||
return () => currentCommunicator?.unregisterEventListener()
|
||||
}, [communicator])
|
||||
}, [communicator, editorOrigin])
|
||||
|
||||
/**
|
||||
* Provides a {@link RendererToEditorCommunicator renderer to editor communicator} for the child components via Context.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue