const id = "image-" + Math.random().toString(16).slice(2);
const loadingImage = window.baseUrl('/loading.gif');
+ const handleUploadError = (error) => {
+ if (error.status === 413) {
+ window.$events.emit('error', wysiwygComponent.serverUploadLimitText);
+ } else {
+ window.$events.emit('error', wysiwygComponent.imageUploadErrorText);
+ }
+ console.log(error);
+ };
+
// Handle updating an existing image
if (currentNode) {
DrawIO.close();
pageEditor.dom.setAttrib(imgElem, 'src', img.url);
pageEditor.dom.setAttrib(currentNode, 'drawio-diagram', img.id);
} catch (err) {
- window.$events.emit('error', wysiwygComponent.imageUploadErrorText);
- console.log(err);
+ handleUploadError(err);
}
return;
}
pageEditor.dom.get(id).parentNode.setAttribute('drawio-diagram', img.id);
} catch (err) {
pageEditor.dom.remove(id);
- window.$events.emit('error', wysiwygComponent.imageUploadErrorText);
- console.log(err);
+ handleUploadError(err);
}
}, 5);
}
this.pageId = this.$opts.pageId;
this.textDirection = this.$opts.textDirection;
this.imageUploadErrorText = this.$opts.imageUploadErrorText;
+ this.serverUploadLimitText = this.$opts.serverUploadLimitText;
this.isDarkMode = document.documentElement.classList.contains('dark-mode');
this.plugins = "image imagetools table textcolor paste link autolink fullscreen code customhr autosave lists codeeditor media";
}
// Replace the actively selected content with the linked image
+ const imageUrl = image.thumbs.display || image.url;
let html = `<a href="${image.url}" target="_blank">`;
- html += `<img src="${image.thumbs.display}" alt="${image.name}">`;
+ html += `<img src="${imageUrl}" alt="${image.name}">`;
html += '</a>';
win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, html);
}, 'gallery');
tooltip: 'Insert an image',
onclick: function () {
window.ImageManager.show(function (image) {
+ const imageUrl = image.thumbs.display || image.url;
let html = `<a href="${image.url}" target="_blank">`;
- html += `<img src="${image.thumbs.display}" alt="${image.name}">`;
+ html += `<img src="${imageUrl}" alt="${image.name}">`;
html += '</a>';
editor.execCommand('mceInsertContent', false, html);
}, 'gallery');