Commit 1731f45e authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'attach-file-cursor-position' into 'master'

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

![drop-image-markdown](/uploads/52f41e38faca48c9ee01a02a75ec71be/drop-image-markdown.gif)

Tested in Chrome & Firefox and both working fine 👍 

Fixes #12822 

cc. @jschatz1 

See merge request !2648
parents 7b8ad807 76534e77
...@@ -65,8 +65,7 @@ class @DropzoneInput ...@@ -65,8 +65,7 @@ class @DropzoneInput
return return
success: (header, response) -> success: (header, response) ->
child = $(dropzone[0]).children("textarea") pasteText response.link.markdown
$(child).val $(child).val() + response.link.markdown + "\n"
return return
error: (temp, errorMessage) -> error: (temp, errorMessage) ->
...@@ -128,6 +127,7 @@ class @DropzoneInput ...@@ -128,6 +127,7 @@ class @DropzoneInput
beforeSelection = $(child).val().substring 0, caretStart beforeSelection = $(child).val().substring 0, caretStart
afterSelection = $(child).val().substring caretEnd, textEnd afterSelection = $(child).val().substring caretEnd, textEnd
$(child).val beforeSelection + text + afterSelection $(child).val beforeSelection + text + afterSelection
child.get(0).setSelectionRange caretStart + text.length, caretEnd + text.length
form_textarea.trigger "input" form_textarea.trigger "input"
getFilename = (e) -> getFilename = (e) ->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment