diff --git a/preview/detached-window.js b/preview/detached-window.js index cd119fa..59354ed 100644 --- a/preview/detached-window.js +++ b/preview/detached-window.js @@ -1,7 +1,17 @@ window.addEventListener('message', e => { // Recieving from app window - if (e.data && e.data.contents && e.data.contents.match(/ { frame.contentDocument.open(); @@ -9,6 +19,7 @@ window.addEventListener('message', e => { frame.contentDocument.close(); }, 10); } + // for files mode if (e.data && e.data.url && e.data.url.match(/index\.html/)) { document.querySelector('iframe').src = e.data.url; } diff --git a/src/components/ContentWrap.jsx b/src/components/ContentWrap.jsx index dd1e88d..92d618d 100644 --- a/src/components/ContentWrap.jsx +++ b/src/components/ContentWrap.jsx @@ -248,11 +248,9 @@ export default class ContentWrap extends Component { // If just CSS was changed (and everything shudn't be empty), // change the styles inside the iframe. if ( - false && !isForced && currentCode.html === this.codeInPreview.html && - currentCode.js === this.codeInPreview.js && - false + currentCode.js === this.codeInPreview.js ) { computeCss( cssMode === CssModes.ACSS ? currentCode.html : currentCode.css, @@ -262,11 +260,11 @@ export default class ContentWrap extends Component { if (cssMode === CssModes.ACSS) { this.cm.css.setValue(result.code || ''); } - if (targetFrame.contentDocument.querySelector('#webmakerstyle')) { - targetFrame.contentDocument.querySelector( - '#webmakerstyle' - ).textContent = result.code || ''; - } + + this.frame.contentWindow.postMessage( + { isCssOnly: true, css: result.code || '' }, + '*' + ); }); } else { var htmlPromise = computeHtml( diff --git a/src/indexpm.html b/src/indexpm.html index 9128559..bfba80e 100644 --- a/src/indexpm.html +++ b/src/indexpm.html @@ -1,11 +1,18 @@