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 committed Oct 8, 2024
1 parent 6928a49 commit 7c74f5f
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions mon-pix/app/components/module/preview.gjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link';
import PixTextarea from '@1024pix/pix-ui/components/pix-textarea';
import { on } from '@ember/modifier';
import { action } from '@ember/object';
import { service } from '@ember/service';
import {on} from '@ember/modifier';
import {action} from '@ember/object';
import {service} from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { t } from 'ember-intl';
import { pageTitle } from 'ember-page-title';
import {tracked} from '@glimmer/tracking';
import {t} from 'ember-intl';
import {pageTitle} from 'ember-page-title';
import ModulixGrain from 'mon-pix/components/module/grain';

export default class ModulixPreview extends Component {
Expand Down 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 7c74f5f

Please sign in to comment.