diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index c29253f99..8a177ca3a 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -1457,6 +1457,25 @@ define([ // Add image to the list var mediasSources = getMediasSources(); + + // Check if name already exists + var getUniqueName = function (name, mediasSources) { + var get = function () { + var s = name.split('.'); + if (s.length > 1) { + s[s.length - 2] = s[s.length - 2] + '-' + Util.uid(); + name = s.join('.'); + } else { + name += '-'+ Util.uid(); + } + }; + while (mediasSources[name]) { get(); } + return name; + }; + if (mediasSources[name]) { + name = getUniqueName(name, mediasSources); + data.name = name; + } mediasSources[name] = data; APP.onLocal();