From b3580de295425a490fa9c7add55ec2de7e40693a Mon Sep 17 00:00:00 2001 From: xLaura3m5 Date: Wed, 13 Mar 2024 19:09:31 +0100 Subject: [PATCH 1/2] TASK: listen to iframe load instead of iframe fires event --- .../react-ui-components/src/Frame/frame.tsx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/react-ui-components/src/Frame/frame.tsx b/packages/react-ui-components/src/Frame/frame.tsx index 57b306abb1..bb91a0f9a4 100644 --- a/packages/react-ui-components/src/Frame/frame.tsx +++ b/packages/react-ui-components/src/Frame/frame.tsx @@ -48,6 +48,19 @@ export default class Frame extends PureComponent { } public componentDidMount(): void { + if (this.ref) { + this.ref.addEventListener('load', () => { + if (this.ref && this.ref.contentDocument && this.ref.contentWindow) { + const doc = this.ref.contentDocument; + const win = this.ref.contentWindow; + const mountTarget = doc.querySelector(this.props.mountTarget); + if (mountTarget) { + this.props.contentDidUpdate(win, doc, mountTarget); + } + } + }); + } + this.updateIframeUrlIfNecessary(); this.addClickListener(); } @@ -106,19 +119,6 @@ export default class Frame extends PureComponent { } } - public UNSAFE_componentWillMount(): void { - document.addEventListener('Neos.Neos.Ui.ContentReady', () => { - if (this.ref && this.ref.contentDocument && this.ref.contentWindow) { - const doc = this.ref.contentDocument; - const win = this.ref.contentWindow; - const mountTarget = doc.querySelector(this.props.mountTarget); - if (mountTarget) { - this.props.contentDidUpdate(win, doc, mountTarget); - } - } - }); - } - private readonly handleUnload = () => { this.setState({ transitioning: true @@ -184,7 +184,7 @@ export default class Frame extends PureComponent { public componentWillUnmount(): void { if (this.ref) { - document.removeEventListener('Neos.Neos.Ui.ContentReady', this.renderFrameContents); + this.ref.removeEventListener('load', this.renderFrameContents); } this.removeClickListener(); } From 35d819fa56da2beec1a6c58750162263eb2208a0 Mon Sep 17 00:00:00 2001 From: xLaura3m5 Date: Thu, 14 Mar 2024 09:36:06 +0100 Subject: [PATCH 2/2] TASK: remove GuestNoficationScript --- Classes/Fusion/ExceptionHandler/PageExceptionHandler.php | 4 ---- Resources/Private/Fusion/Prototypes/Page.fusion | 6 ------ .../Private/Templates/Backend/GuestNotificationScript.html | 6 ------ Resources/Private/Templates/Error/ErrorMessage.html | 3 +-- packages/react-ui-components/src/Frame/frame.tsx | 7 ++----- 5 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 Resources/Private/Templates/Backend/GuestNotificationScript.html diff --git a/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php b/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php index 8fdfb46ed7..a9c26fce3e 100644 --- a/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php +++ b/Classes/Fusion/ExceptionHandler/PageExceptionHandler.php @@ -102,10 +102,6 @@ protected function prepareFluidView(): ViewInterface $fluidView->setFormat('html'); $fluidView->setTemplatePathAndFilename('resource://Neos.Neos.Ui/Private/Templates/Error/ErrorMessage.html'); - $guestNotificationScript = new StandaloneView(); - $guestNotificationScript->setTemplatePathAndFilename('resource://Neos.Neos.Ui/Private/Templates/Backend/GuestNotificationScript.html'); - $fluidView->assign('guestNotificationScript', $guestNotificationScript->render()); - return $fluidView; } } diff --git a/Resources/Private/Fusion/Prototypes/Page.fusion b/Resources/Private/Fusion/Prototypes/Page.fusion index b8ea315e93..56177ada61 100644 --- a/Resources/Private/Fusion/Prototypes/Page.fusion +++ b/Resources/Private/Fusion/Prototypes/Page.fusion @@ -63,12 +63,6 @@ prototype(Neos.Neos:Page) { neosBackendContainer.@position = 'before closingBodyTag' neosBackendContainer.@if.inBackend = ${documentNode.context.inBackend} - neosBackendNotification = Neos.Fusion:Template { - @position = 'before closingBodyTag' - templatePath = 'resource://Neos.Neos.Ui/Private/Templates/Backend/GuestNotificationScript.html' - @if.inBackend = ${documentNode.context.inBackend} - } - @exceptionHandler = 'Neos\\Neos\\Ui\\Fusion\\ExceptionHandler\\PageExceptionHandler' } diff --git a/Resources/Private/Templates/Backend/GuestNotificationScript.html b/Resources/Private/Templates/Backend/GuestNotificationScript.html deleted file mode 100644 index 54229f3e0d..0000000000 --- a/Resources/Private/Templates/Backend/GuestNotificationScript.html +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/Resources/Private/Templates/Error/ErrorMessage.html b/Resources/Private/Templates/Error/ErrorMessage.html index 650759a075..460c653839 100644 --- a/Resources/Private/Templates/Error/ErrorMessage.html +++ b/Resources/Private/Templates/Error/ErrorMessage.html @@ -4,9 +4,8 @@ Neos Error - {guestNotificationScript -> f:format.raw()} -
{message -> f:format.raw()}
+
{message -> f:format.raw()}
diff --git a/packages/react-ui-components/src/Frame/frame.tsx b/packages/react-ui-components/src/Frame/frame.tsx index bb91a0f9a4..f79c98f6af 100644 --- a/packages/react-ui-components/src/Frame/frame.tsx +++ b/packages/react-ui-components/src/Frame/frame.tsx @@ -5,7 +5,7 @@ import ReactDOM from 'react-dom'; export interface FrameProps extends React.IframeHTMLAttributes { readonly src: string; readonly mountTarget: string; - readonly contentDidUpdate: (window: Window, document: Document, mountTarget: Element) => void; + readonly contentDidUpdate: (window: Window, document: Document) => void; readonly onLoad: (event: SyntheticEvent) => void; readonly onUnload: () => void; readonly children: ReactNode; @@ -53,10 +53,7 @@ export default class Frame extends PureComponent { if (this.ref && this.ref.contentDocument && this.ref.contentWindow) { const doc = this.ref.contentDocument; const win = this.ref.contentWindow; - const mountTarget = doc.querySelector(this.props.mountTarget); - if (mountTarget) { - this.props.contentDidUpdate(win, doc, mountTarget); - } + this.props.contentDidUpdate(win, doc); } }); }