#431 Need help about image tags

master
agriyadev5 2021-06-10 14:01:58 +05:30
parent 0583da9af8
commit 096abcb028
3 changed files with 25 additions and 12 deletions

View File

@ -417,10 +417,21 @@ class Editor extends EditorStartup {
$id("change_image_url").style.display = 'block'; $id("change_image_url").style.display = 'block';
} else { } else {
// regular URL // regular URL
this.svgCanvas.embedImage(url, function (dataURI) { const self = this;
// Couldn't embed, so show warning const promised = this.svgCanvas.embedImage(url);
// eslint-disable-next-line promise/catch-or-return
promised
.then( function (dataURI) {
// eslint-disable-next-line promise/always-return
$id('url_notice').style.display = (!dataURI) ? 'block' : 'none'; $id('url_notice').style.display = (!dataURI) ? 'block' : 'none';
this.defaultImageURL = url; // switch into "select" mode if we've clicked on an element
self.svgCanvas.setMode('select');
self.svgCanvas.selectOnly(self.svgCanvas.getSelectedElems(), true);
}, function (error) {
// eslint-disable-next-line no-console
console.log("error =", error);
seAlert(self.i18next.t('tools.no_embed'));
self.svgCanvas.deleteSelectedElements();
}); });
$id("image_url").style.display = 'block'; $id("image_url").style.display = 'block';
$id("change_image_url").style.display = 'none'; $id("change_image_url").style.display = 'none';

View File

@ -292,6 +292,7 @@ class TopPanel {
$id("g_panel").style.display = 'block'; $id("g_panel").style.display = 'block';
} }
// siblings // siblings
if (elem.parentNode) {
const selements = Array.prototype.filter.call(elem.parentNode.children, function(child){ const selements = Array.prototype.filter.call(elem.parentNode.children, function(child){
return child !== elem; return child !== elem;
}); });
@ -299,6 +300,7 @@ class TopPanel {
$id("a_panel").style.display = 'block'; $id("a_panel").style.display = 'block';
linkHref = this.editor.svgCanvas.getHref(elem.parentNode); linkHref = this.editor.svgCanvas.getHref(elem.parentNode);
} }
}
// Hide/show the make_link buttons // Hide/show the make_link buttons
$id('tool_make_link').style.display = (!linkHref) ? 'block' : 'none'; $id('tool_make_link').style.display = (!linkHref) ? 'block' : 'none';

View File

@ -651,7 +651,7 @@ export const embedImage = function (src) {
resolve(svgContext_.getEncodableImages(src)); resolve(svgContext_.getEncodableImages(src));
}); });
imgI.addEventListener("error", (e) => { imgI.addEventListener("error", (e) => {
reject(new Error(`error loading image: ${e.currentTarget.attributes.src.value}`)); reject(`error loading image: ${e.currentTarget.attributes.src.value}`);
}); });
imgI.setAttribute('src', src); imgI.setAttribute('src', src);
}); });