mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
✨ Added firing of portal-ready
post message for preview
no refs This adds a way for top level site/admin to detect when Portal is loaded on the site and is ready to render, which allows dynamic UI handling specially in Preview mode in Admin.
This commit is contained in:
parent
8ac6364d3a
commit
347805d4d0
@ -57,6 +57,7 @@ export default class App extends React.Component {
|
|||||||
if (this.state.initStatus === 'success' && prevState.initStatus !== this.state.initStatus) {
|
if (this.state.initStatus === 'success' && prevState.initStatus !== this.state.initStatus) {
|
||||||
const {siteUrl} = this.props;
|
const {siteUrl} = this.props;
|
||||||
const contextState = this.getContextFromState();
|
const contextState = this.getContextFromState();
|
||||||
|
this.sendPortalReadyEvent(siteUrl);
|
||||||
handleDataAttributes({
|
handleDataAttributes({
|
||||||
siteUrl,
|
siteUrl,
|
||||||
site: contextState.site,
|
site: contextState.site,
|
||||||
@ -73,6 +74,14 @@ export default class App extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendPortalReadyEvent(siteUrl) {
|
||||||
|
const siteOrigin = ((new URL(siteUrl)).origin).replace(/\/$/, '');
|
||||||
|
|
||||||
|
if (window.self !== window.parent) {
|
||||||
|
window.parent.postMessage('portal-ready', siteOrigin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Setup custom trigger buttons handling on page */
|
/** Setup custom trigger buttons handling on page */
|
||||||
setupCustomTriggerButton() {
|
setupCustomTriggerButton() {
|
||||||
// Handler for custom buttons
|
// Handler for custom buttons
|
||||||
|
Loading…
Reference in New Issue
Block a user