fix screenshots
This commit is contained in:
@@ -92,24 +92,27 @@ define(
|
|||||||
},
|
},
|
||||||
saveTemplate: function (response, done) {
|
saveTemplate: function (response, done) {
|
||||||
const iframe = document.createElement('iframe');
|
const iframe = document.createElement('iframe');
|
||||||
|
iframe.width = 660;
|
||||||
iframe.src = response.meta.preview_url;
|
iframe.src = response.meta.preview_url;
|
||||||
iframe.onload = () => {
|
iframe.onload = () => {
|
||||||
html2canvas(iframe.contentDocument.documentElement).then((thumbnail) => {
|
setTimeout(() => {
|
||||||
document.body.removeChild(iframe);
|
html2canvas(iframe.contentDocument.documentElement).then((thumbnail) => {
|
||||||
MailPoet.Ajax.post({
|
document.body.removeChild(iframe);
|
||||||
api_version: window.mailpoet_api_version,
|
MailPoet.Ajax.post({
|
||||||
endpoint: 'newsletterTemplates',
|
api_version: window.mailpoet_api_version,
|
||||||
action: 'save',
|
endpoint: 'newsletterTemplates',
|
||||||
data: {
|
action: 'save',
|
||||||
newsletter_id: response.data.id,
|
data: {
|
||||||
name: response.data.subject,
|
newsletter_id: response.data.id,
|
||||||
description: response.data.preheader,
|
name: response.data.subject,
|
||||||
thumbnail: thumbnail.toDataURL('image/jpeg'),
|
description: response.data.preheader,
|
||||||
body: JSON.stringify(response.data.body),
|
thumbnail: thumbnail.toDataURL('image/jpeg'),
|
||||||
categories: '["recent"]',
|
body: JSON.stringify(response.data.body),
|
||||||
},
|
categories: '["recent"]',
|
||||||
}).then(done).fail(this.showError);
|
},
|
||||||
});
|
}).then(done).fail(this.showError);
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
};
|
};
|
||||||
// just to hide the iframe
|
// just to hide the iframe
|
||||||
iframe.style.cssText ='position: absolute; opacity:0; z-index: -9999';
|
iframe.style.cssText ='position: absolute; opacity:0; z-index: -9999';
|
||||||
|
Reference in New Issue
Block a user