Added NEXT_PUBLIC_IGNORE_IFRAME_ORIGIN_CONFIG (#1738)

* Added NEXT_PUBLIC_IGNORE_IFRAME_ORIGIN_CONFIG

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-12-31 00:05:02 +01:00 committed by GitHub
parent acd368813d
commit ca49eb957d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 14 deletions

View file

@ -5,10 +5,9 @@
*/
import React, { createContext, useContext, useEffect, useMemo } from 'react'
import { useSelector } from 'react-redux'
import { RendererToEditorCommunicator } from '../../render-page/window-post-message-communicator/renderer-to-editor-communicator'
import { CommunicationMessageType } from '../../render-page/window-post-message-communicator/rendering-message'
import type { ApplicationState } from '../../../redux/application-state'
import { ORIGIN_TYPE, useOriginFromConfig } from './use-origin-from-config'
const RendererToEditorCommunicatorContext = createContext<RendererToEditorCommunicator | undefined>(undefined)
@ -27,7 +26,7 @@ export const useRendererToEditorCommunicator: () => RendererToEditorCommunicator
}
export const RendererToEditorCommunicatorContextProvider: React.FC = ({ children }) => {
const editorOrigin = useSelector((state: ApplicationState) => state.config.iframeCommunication.editorOrigin)
const editorOrigin = useOriginFromConfig(ORIGIN_TYPE.EDITOR)
const communicator = useMemo<RendererToEditorCommunicator>(() => {
const newCommunicator = new RendererToEditorCommunicator()
newCommunicator.setMessageTarget(window.parent, editorOrigin)