Skip to content

Commit

Permalink
wip: inform window opener that module content is awaited
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelie-crouillebois authored and dianeCdrPix committed Oct 9, 2024
1 parent 656285b commit 423af73
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mon-pix/app/components/module/preview.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class ModulixPreview extends Component {
"element": {
"id": "3333333a-3333-3bcd-e333-3f3333gh3333",
"type": "text",
"content": "<p>Voici un texte de leçon. Parfois, il y a des émojis pour aider à la lecture&nbsp;<span aria-hidden='true'>📚</span>.<br>Et là, voici une image&#8239;!</p>"
"content": "<p>Voici un texte de leçon. Parfois, il y a des émojis pour aider à la lecture&nbsp;<span aria-hidden="true">📚</span>.<br>Et là, voici une image&#8239;!</p>"
}
},
{
Expand All @@ -78,11 +78,14 @@ export default class ModulixPreview extends Component {

this.modulixPreviewMode.enable();

window.addEventListener('message', () => {
if (event.data?.from === 'modulix-editor') {
this.module = JSON.stringify(event.data.moduleContent, null, 2);
}
});
if (window.opener) {
window.addEventListener('message', (event) => {
if (event.data?.from === 'modulix-editor') {
this.module = JSON.stringify(event.data.moduleContent, null, 2);
}
});
window.opener.postMessage({ from: 'pix-app', message: 'Gimme the content !' }, '*');
}
}

get passage() {
Expand Down

0 comments on commit 423af73

Please sign in to comment.