diff --git a/app/assets/javascripts/discourse/lib/utilities.js b/app/assets/javascripts/discourse/lib/utilities.js index 672c75237..f398e7910 100644 --- a/app/assets/javascripts/discourse/lib/utilities.js +++ b/app/assets/javascripts/discourse/lib/utilities.js @@ -215,8 +215,8 @@ Discourse.Utilities = { } }, - getUploadPlaceholder: function(filename) { - return "[" + I18n.t("uploading_filename", { filename: filename }) + "]() "; + getUploadPlaceholder: function() { + return "[" + I18n.t("uploading") + "]() "; }, isAnImage: function(path) { diff --git a/app/assets/javascripts/discourse/views/composer.js.es6 b/app/assets/javascripts/discourse/views/composer.js.es6 index 71cbe5b32..c44edb492 100644 --- a/app/assets/javascripts/discourse/views/composer.js.es6 +++ b/app/assets/javascripts/discourse/views/composer.js.es6 @@ -342,9 +342,9 @@ const ComposerView = Ember.View.extend(Ember.Evented, { this.messageBus.subscribe("/uploads/composer", upload => { if (!cancelledByTheUser) { if (upload && upload.url) { - const regex = new RegExp(`\\[${I18n.t("uploading")}.+?\\]\\(\\)`), + const old = Discourse.Utilities.getUploadPlaceholder(), markdown = Discourse.Utilities.getUploadMarkdown(upload); - this.replaceMarkdown(regex, markdown); + this.replaceMarkdown(old, markdown); } else { Discourse.Utilities.displayErrorForUpload(upload); } @@ -372,7 +372,7 @@ const ComposerView = Ember.View.extend(Ember.Evented, { // deal with cancellation cancelledByTheUser = false; // add upload placeholder - const markdown = Discourse.Utilities.getUploadPlaceholder(data.files[0].name); + const markdown = Discourse.Utilities.getUploadPlaceholder(); this.addMarkdown(markdown); if (data["xhr"]) { @@ -527,9 +527,9 @@ const ComposerView = Ember.View.extend(Ember.Evented, { }); }, - replaceMarkdown(regex, text) { + replaceMarkdown(old, text) { const reply = this.get("model.reply"); - this.set("model.reply", reply.replace(regex, text)); + this.set("model.reply", reply.replace(old, text)); }, // Uses javascript to get the image sizes from the preview, if present