From 684f858415ba14bc6e53684cabb3451319e6d4aa Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 1 Jul 2014 15:40:21 -0400 Subject: [PATCH] closes #1772 --- public/src/modules/composer/uploads.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/src/modules/composer/uploads.js b/public/src/modules/composer/uploads.js index ac601a25ce..008970a3ca 100644 --- a/public/src/modules/composer/uploads.js +++ b/public/src/modules/composer/uploads.js @@ -200,6 +200,10 @@ define('composer/uploads', ['composer/preview'], function(preview) { return response; } + function insertText(str, index, insert) { + return str.slice(0, index) + insert + str.slice(index); + }; + function uploadContentFiles(params) { var files = params.files, post_uuid = params.post_uuid, @@ -213,7 +217,8 @@ define('composer/uploads', ['composer/preview'], function(preview) { for(var i = 0; i < files.length; ++i) { var isImage = files[i].type.match(/image./); - text += (isImage ? '!' : '') + '[' + files[i].name + '](uploading...) '; + + text = insertText(text, textarea.getCursorPosition(), (isImage ? '!' : '') + '[' + files[i].name + '](uploading...) '); if(files[i].size > parseInt(config.maximumFileSize, 10) * 1024) { uploadForm[0].reset();