mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-24 16:14:01 +08:00
Remove “Click to download” on images, no longer support ”manual” attachment fetch
This commit is contained in:
parent
c9d9e1c5a5
commit
d337d9d407
3 changed files with 0 additions and 59 deletions
|
@ -10,7 +10,6 @@ import {
|
|||
} from 'mailspring-exports';
|
||||
import { autolink } from './autolinker';
|
||||
import { adjustImages } from './adjust-images';
|
||||
import { addInlineImageListeners } from './inline-image-listeners';
|
||||
import EmailFrameStylesStore from './email-frame-styles-store';
|
||||
|
||||
export default class EmailFrame extends React.Component {
|
||||
|
@ -86,7 +85,6 @@ export default class EmailFrame extends React.Component {
|
|||
|
||||
autolink(doc, { async: true });
|
||||
adjustImages(doc);
|
||||
addInlineImageListeners(doc);
|
||||
|
||||
for (const extension of MessageStore.extensions()) {
|
||||
if (!extension.renderedMessageBodyIntoDocument) {
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
import { Actions, Utils } from 'mailspring-exports';
|
||||
|
||||
function safeEncode(str) {
|
||||
return btoa(unescape(encodeURIComponent(str)));
|
||||
}
|
||||
|
||||
function safeDecode(str) {
|
||||
return atob(decodeURIComponent(escape(str)));
|
||||
}
|
||||
|
||||
function _runOnImageNode(node) {
|
||||
if (node.src && node.dataset.nylasFile) {
|
||||
node.addEventListener('error', () => {
|
||||
const file = Utils.convertToModel(JSON.parse(safeDecode(node.dataset.nylasFile)));
|
||||
const initialDisplay = node.style.display;
|
||||
const downloadButton = document.createElement('a');
|
||||
downloadButton.classList.add('inline-download-prompt');
|
||||
downloadButton.textContent = 'Click to download inline image';
|
||||
downloadButton.addEventListener('click', () => {
|
||||
Actions.fetchFile(file);
|
||||
node.parentNode.removeChild(downloadButton);
|
||||
node.addEventListener('load', () => {
|
||||
node.style.display = initialDisplay;
|
||||
});
|
||||
});
|
||||
node.style.display = 'none';
|
||||
node.parentNode.insertBefore(downloadButton, node);
|
||||
});
|
||||
|
||||
node.addEventListener('load', () => {
|
||||
const file = Utils.convertToModel(JSON.parse(safeDecode(node.dataset.nylasFile)));
|
||||
node.addEventListener('dblclick', () => {
|
||||
Actions.fetchAndOpenFile(file);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function encodedAttributeForFile(file) {
|
||||
return safeEncode(JSON.stringify(file));
|
||||
}
|
||||
|
||||
export function addInlineImageListeners(doc) {
|
||||
const imgTagWalker = document.createTreeWalker(doc.body, NodeFilter.SHOW_ELEMENT, {
|
||||
acceptNode: node => {
|
||||
if (node.nodeName === 'IMG') {
|
||||
return NodeFilter.FILTER_ACCEPT;
|
||||
}
|
||||
return NodeFilter.FILTER_SKIP;
|
||||
},
|
||||
});
|
||||
|
||||
while (imgTagWalker.nextNode()) {
|
||||
_runOnImageNode(imgTagWalker.currentNode);
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ import {
|
|||
import { InjectedComponentSet, RetinaImg } from 'mailspring-component-kit';
|
||||
|
||||
import EmailFrame from './email-frame';
|
||||
import { encodedAttributeForFile } from './inline-image-listeners';
|
||||
|
||||
const TransparentPixel =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNikAQAACIAHF/uBd8AAAAASUVORK5CYII=';
|
||||
|
|
Loading…
Reference in a new issue