summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-01-29 10:28:05 +0000
committerPhil Hughes <me@iamphill.com>2016-01-29 10:28:05 +0000
commitfc334e72f40ab5394c70f5cd29829dc3c0b0d485 (patch)
tree9a15f7e1736aacef7781da84e18a2426310bf53d
parentf5860ce6466bf8934bc01254351bffd005dfeafe (diff)
downloadgitlab-ce-fc334e72f40ab5394c70f5cd29829dc3c0b0d485.tar.gz
Adds the markdown link at the cursor poisition
When writing a comment and then dropping an image it will correctly add the image markdown link at the cursor position Fixes #12822
-rw-r--r--app/assets/javascripts/dropzone_input.js.coffee7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/assets/javascripts/dropzone_input.js.coffee b/app/assets/javascripts/dropzone_input.js.coffee
index c714c0fa939..32a5594a5b1 100644
--- a/app/assets/javascripts/dropzone_input.js.coffee
+++ b/app/assets/javascripts/dropzone_input.js.coffee
@@ -65,8 +65,13 @@ class @DropzoneInput
return
success: (header, response) ->
+ link_markdown = response.link.markdown
child = $(dropzone[0]).children("textarea")
- $(child).val $(child).val() + response.link.markdown + "\n"
+ cursor_pos = child.prop "selectionStart"
+ value = $(child).val()
+ new_text = "#{value.substring(0, cursor_pos)}#{link_markdown}#{value.substring(cursor_pos, value.length)}"
+
+ $(child).val new_text + "\n"
return
error: (temp, errorMessage) ->