mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-19 13:18:59 +08:00
Bugfix: i've wrecked rendering of inline images
This commit is contained in:
parent
aa3f71d299
commit
385cd9588c
2 changed files with 27 additions and 29 deletions
|
@ -655,37 +655,33 @@ class MessageModel extends AbstractModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
showInternalImages() {
|
showInternalImages() {
|
||||||
if (this.body && !this.body.rlInitInternalImages) {
|
const body = this.body;
|
||||||
this.body.rlInitInternalImages = true;
|
if (body && !body.rlInitInternalImages) {
|
||||||
|
const findAttachmentByCid = cid => this.attachments.findByCid(cid);
|
||||||
|
|
||||||
const body = this.body,
|
body.rlInitInternalImages = true;
|
||||||
findAttachmentByCid = cid => this.attachments.findByCid(cid);
|
|
||||||
|
|
||||||
body.querySelectorAll('[data-x-src-cid]').forEach(node => {
|
body.querySelectorAll('[data-x-src-cid],[data-x-src-location],[data-x-style-cid]').forEach(el => {
|
||||||
const attachment = findAttachmentByCid(node.dataset.xSrcCid);
|
const data = el.dataset;
|
||||||
if (attachment && attachment.download) {
|
if (data.xSrcCid) {
|
||||||
node.src = attachment.linkPreview();
|
const attachment = findAttachmentByCid(data.xSrcCid);
|
||||||
}
|
if (attachment && attachment.download) {
|
||||||
});
|
el.src = attachment.linkPreview();
|
||||||
|
}
|
||||||
body.querySelectorAll('[data-x-src-location]').forEach(node => {
|
} else if (data.xSrcLocation) {
|
||||||
const attachment = this.attachments.find(item => node.dataset.xSrcLocation === item.contentLocation)
|
const attachment = this.attachments.find(item => data.xSrcLocation === item.contentLocation)
|
||||||
|| findAttachmentByCid(node.dataset.xSrcLocation);
|
|| findAttachmentByCid(data.xSrcLocation);
|
||||||
if (attachment && attachment.download) {
|
if (attachment && attachment.download) {
|
||||||
if (node.matches('img')) {
|
el.loading = 'lazy';
|
||||||
node.loading = 'lazy';
|
el.src = attachment.linkPreview();
|
||||||
|
}
|
||||||
|
} else if (data.xStyleCid) {
|
||||||
|
const name = data.xStyleCidName,
|
||||||
|
attachment = findAttachmentByCid(data.xStyleCid);
|
||||||
|
if (attachment && attachment.linkPreview && name) {
|
||||||
|
el.setAttribute('style', name + ": url('" + attachment.linkPreview() + "');"
|
||||||
|
+ (el.getAttribute('style') || ''));
|
||||||
}
|
}
|
||||||
node.src = attachment.linkPreview();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
body.querySelectorAll('[style-cid]').forEach(node => {
|
|
||||||
const name = node.dataset.xStyleCidName,
|
|
||||||
attachment = findAttachmentByCid(node.dataset.xStyleCid);
|
|
||||||
if (attachment && attachment.linkPreview && name) {
|
|
||||||
node.setAttribute('style', ((node.getAttribute('style')||'')
|
|
||||||
+ ';' + name + ": url('" + attachment.linkPreview() + "')")
|
|
||||||
.replace(/^[;\s]+/,''));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,6 +494,7 @@ class MessageUserStore {
|
||||||
iMessageBodyCacheCount += 1;
|
iMessageBodyCacheCount += 1;
|
||||||
textBody.rlCacheCount = iMessageBodyCacheCount;
|
textBody.rlCacheCount = iMessageBodyCacheCount;
|
||||||
message.fetchDataFromDom();
|
message.fetchDataFromDom();
|
||||||
|
message.body = textBody;
|
||||||
} else {
|
} else {
|
||||||
let isHtml = false;
|
let isHtml = false;
|
||||||
if (data.Result.Html) {
|
if (data.Result.Html) {
|
||||||
|
@ -542,6 +543,8 @@ class MessageUserStore {
|
||||||
+ '</div>');
|
+ '</div>');
|
||||||
body.rlCacheCount = iMessageBodyCacheCount;
|
body.rlCacheCount = iMessageBodyCacheCount;
|
||||||
|
|
||||||
|
message.body = body;
|
||||||
|
|
||||||
message.isHtml(!!isHtml);
|
message.isHtml(!!isHtml);
|
||||||
message.hasImages(!!data.Result.HasExternals);
|
message.hasImages(!!data.Result.HasExternals);
|
||||||
|
|
||||||
|
@ -560,7 +563,6 @@ class MessageUserStore {
|
||||||
this.purgeMessageBodyCacheThrottle();
|
this.purgeMessageBodyCacheThrottle();
|
||||||
}
|
}
|
||||||
|
|
||||||
message.body = body || textBody;
|
|
||||||
this.messageActiveDom(message.body);
|
this.messageActiveDom(message.body);
|
||||||
|
|
||||||
this.hideMessageBodies();
|
this.hideMessageBodies();
|
||||||
|
|
Loading…
Reference in a new issue