1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-18 23:07:45 +02:00

Clipper: Support clipping screenshots

This commit is contained in:
Laurent Cozic
2018-05-25 08:51:54 +01:00
parent 4640d6d6e3
commit 264ee4f319
8 changed files with 132 additions and 44 deletions

View File

@ -29,6 +29,17 @@ const mime = {
return null;
},
fromDataUrl(dataUrl) {
// Example: data:image/jpeg;base64,/9j/4AAQSkZJR.....
const defaultMime = 'text/plain';
let p = dataUrl.substr(0, dataUrl.indexOf(',')).split(';');
let s = p[0];
s = s.split(':');
if (s.length <= 1) return defaultMime;
s = s[1];
return s.indexOf('/') >= 0 ? s : defaultMime; // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
},
}
module.exports = { mime };