mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-23 23:11:12 +02:00
get preview running for extension
This commit is contained in:
@@ -181,7 +181,11 @@ export default class ContentWrap extends Component {
|
||||
})
|
||||
]).then(fn);
|
||||
// Setting to blank string cause frame to reload
|
||||
this.frame.src = this.frame.src;
|
||||
if (window.IS_EXTENSION) {
|
||||
this.frame.src = '';
|
||||
} else {
|
||||
this.frame.src = this.frame.src;
|
||||
}
|
||||
};
|
||||
const writeInsideIframe = () => {
|
||||
if (!cachedSandboxAttribute && window.DEBUG) {
|
||||
@@ -191,10 +195,13 @@ export default class ContentWrap extends Component {
|
||||
// this.frame.setAttribute('sandbox', cachedSandboxAttribute);
|
||||
// this.frame.removeAttribute('sweet');
|
||||
// console.log('sending postmessage');
|
||||
this.frame.contentWindow.postMessage({ contents }, '*');
|
||||
// this.frame.contentDocument.open();
|
||||
// this.frame.contentDocument.write(contents);
|
||||
// this.frame.contentDocument.close();
|
||||
if (window.IS_EXTENSION) {
|
||||
this.frame.contentDocument.open();
|
||||
this.frame.contentDocument.write(contents);
|
||||
this.frame.contentDocument.close();
|
||||
} else {
|
||||
this.frame.contentWindow.postMessage({ contents }, '*');
|
||||
}
|
||||
};
|
||||
refreshAndDo(() => {
|
||||
cachedSandboxAttribute = this.frame.getAttribute('sandbox');
|
||||
@@ -561,11 +568,20 @@ export default class ContentWrap extends Component {
|
||||
const iframeHeight = iframeBounds.height;
|
||||
document.body.classList.add('is-detached-mode');
|
||||
|
||||
this.detachedWindow = window.open(
|
||||
`${PREVIEW_FRAME_HOST}/preview.html`,
|
||||
'Web Maker',
|
||||
`width=${iframeWidth},height=${iframeHeight},resizable,scrollbars=yes,status=1`
|
||||
);
|
||||
if (window.IS_EXTENSION) {
|
||||
this.detachedWindow = window.open(
|
||||
'./preview.html',
|
||||
'Web Maker',
|
||||
`width=${iframeWidth},height=${iframeHeight},resizable,scrollbars=yes,status=1`
|
||||
);
|
||||
} else {
|
||||
this.detachedWindow = window.open(
|
||||
`${PREVIEW_FRAME_HOST}/preview.html`,
|
||||
'Web Maker',
|
||||
`width=${iframeWidth},height=${iframeHeight},resizable,scrollbars=yes,status=1`
|
||||
);
|
||||
}
|
||||
|
||||
// Trigger initial render in detached window
|
||||
setTimeout(() => {
|
||||
this.setPreviewContent(true);
|
||||
@@ -929,16 +945,26 @@ export default class ContentWrap extends Component {
|
||||
</div>
|
||||
</SplitPane>
|
||||
<div class="demo-side" id="js-demo-side" style="">
|
||||
<iframe
|
||||
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-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"
|
||||
/>
|
||||
{window.IS_EXTENSION ? (
|
||||
<iframe
|
||||
ref={el => (this.frame = el)}
|
||||
frameborder="0"
|
||||
id="demo-frame"
|
||||
allowpaymentrequest="true"
|
||||
allowfullscreen="true"
|
||||
/>
|
||||
) : (
|
||||
<iframe
|
||||
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-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"
|
||||
/>
|
||||
)}
|
||||
|
||||
<PreviewDimension ref={comp => (this.previewDimension = comp)} />
|
||||
|
||||
|
Reference in New Issue
Block a user