mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05: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
1 changed files with 9 additions and 0 deletions
|
@ -57,6 +57,7 @@ export default class App extends React.Component {
|
|||
if (this.state.initStatus === 'success' && prevState.initStatus !== this.state.initStatus) {
|
||||
const {siteUrl} = this.props;
|
||||
const contextState = this.getContextFromState();
|
||||
this.sendPortalReadyEvent(siteUrl);
|
||||
handleDataAttributes({
|
||||
siteUrl,
|
||||
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 */
|
||||
setupCustomTriggerButton() {
|
||||
// Handler for custom buttons
|
||||
|
|
Loading…
Add table
Reference in a new issue