Skip to content

Commit

Permalink
[FEATURE] Attendre le message "ready" de pix App pour envoyer le cont…
Browse files Browse the repository at this point in the history
…enu d'un module (#6)

* feat(modulix-editor): expect ready message from Pix App before sending module content.

---------

Co-authored-by: Aurelie Crouillebois <aurelie.crouillebois@gmail.com>
  • Loading branch information
dianeCdrPix and aurelie-crouillebois authored Oct 10, 2024
1 parent f6c0f21 commit f5fcc47
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ <h2>JSON à copier/coller</h2>
const moduleContent = editor.getValue();
const windowName = `modulix-preview-${moduleContent.id}`;
previewWindow = window.open('https://app.pix.fr/modules/preview', windowName);
window.setTimeout(() => sendDataForPreview(previewWindow, moduleContent), 1000);
});

window.addEventListener('message', (event) => {

if (event.data?.from === 'pix-app' && event.data?.message === 'Ready to receive content !') {
const moduleContent = editor.getValue();
sendDataForPreview(previewWindow, moduleContent);
}
});

const resetButton = document.querySelector('#reset-button');
Expand Down

0 comments on commit f5fcc47

Please sign in to comment.