1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-23 23:11:12 +02:00

use local html file for preview in normal mode

This commit is contained in:
Kushagra Gour
2024-03-27 13:22:43 +05:30
parent 5dfa0c791e
commit 3ebb6b7ab1
2 changed files with 15 additions and 3 deletions

View File

@@ -181,7 +181,7 @@ export default class ContentWrap extends Component {
})
]).then(writeInsideIframe);
// Setting to blank string cause frame to reload
// this.frame.src = '';
this.frame.src = this.frame.src;
}
} else {
// we need to store user script in external JS file to prevent inline-script
@@ -908,11 +908,11 @@ export default class ContentWrap extends Component {
</SplitPane>
<div class="demo-side" id="js-demo-side" style="">
<iframe
src={`${PREVIEW_FRAME_HOST}/preview.html`}
src={`./indexpm.html`}
ref={el => (this.frame = el)}
frameborder="0"
id="demo-frame"
sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation"
sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-scripts allow-top-navigation-by-user-activation"
allow="accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write; web-share"
allowpaymentrequest="true"
allowfullscreen="true"

12
src/indexpm.html Normal file
View File

@@ -0,0 +1,12 @@
<script>
function callback(e) {
console.log('post message recvd', e.data);
window.document.open();
const { contents } = e.data;
window.document.write(e.data.contents);
window.document.close();
window.addEventListener('message', callback);
}
window.addEventListener('message', callback);
</script>