Last active
September 18, 2018 13:17
-
-
Save mustmodify/5fc47b4c628a246b708f18b3e2181537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMyString(datum) | |
{ | |
let promise = new Promise(function(resolve, reject) | |
{ | |
// if readonly mode, reject(); | |
// per https://www.w3.org/TR/html51/editing.html#the-datatransferitem-interface | |
if datum.kind !== 'string' | |
reject(); | |
else | |
// We can't seem to test for 'readonly mode' and don't know about other | |
// failures, so we still need a timeout to reject. | |
setTimeout(function(){console.log('timeout reject from getMyString'); reject()}, 1000); | |
datum.getAsString(resolve); | |
}); | |
} | |
} | |
function getImageURL(data) { | |
const urlList = data.find(d => (data.kind == 'string') && (data.type.match('^text/uri-list')) | |
if (urlList) | |
{ | |
return getMyString(urlList); | |
} else { | |
return Promise.resolve(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment