- Enhancement: Delete the imge upon cancel if it is a new image (fixes #177)

master
Brett Zamir 2018-05-28 19:19:00 +08:00
parent beb513ae0e
commit c2e06534ff
1 changed files with 7 additions and 3 deletions

View File

@ -1462,11 +1462,15 @@ editor.init = function () {
svgCanvas.setBackground(color, url); svgCanvas.setBackground(color, url);
} }
function promptImgURL () { function promptImgURL ({cancelDeletes = false} = {}) {
let curhref = svgCanvas.getHref(selectedElement); let curhref = svgCanvas.getHref(selectedElement);
curhref = curhref.startsWith('data:') ? '' : curhref; curhref = curhref.startsWith('data:') ? '' : curhref;
$.prompt(uiStrings.notification.enterNewImgURL, curhref, function (url) { $.prompt(uiStrings.notification.enterNewImgURL, curhref, function (url) {
if (url) { setImageURL(url); } if (url) {
setImageURL(url);
} else if (cancelDeletes) {
svgCanvas.deleteSelectedElements();
}
}); });
} }
@ -1852,7 +1856,7 @@ editor.init = function () {
if (elname === 'image' && svgCanvas.getMode() === 'image') { if (elname === 'image' && svgCanvas.getMode() === 'image') {
// Prompt for URL if not a data URL // Prompt for URL if not a data URL
if (!svgCanvas.getHref(elem).startsWith('data:')) { if (!svgCanvas.getHref(elem).startsWith('data:')) {
promptImgURL(); promptImgURL({cancelDeletes: true});
} }
} }
/* else if (elname == 'text') { /* else if (elname == 'text') {