From c2e06534ff14e23a3cfe89653a3e34d85d0a43c9 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Mon, 28 May 2018 19:19:00 +0800 Subject: [PATCH] - Enhancement: Delete the imge upon cancel if it is a new image (fixes #177) --- editor/svg-editor.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index fbd4904e..d48f1429 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1462,11 +1462,15 @@ editor.init = function () { svgCanvas.setBackground(color, url); } - function promptImgURL () { + function promptImgURL ({cancelDeletes = false} = {}) { let curhref = svgCanvas.getHref(selectedElement); curhref = curhref.startsWith('data:') ? '' : curhref; $.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') { // Prompt for URL if not a data URL if (!svgCanvas.getHref(elem).startsWith('data:')) { - promptImgURL(); + promptImgURL({cancelDeletes: true}); } } /* else if (elname == 'text') {