Skip to content
Snippets Groups Projects
Commit cb2093fb authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge pull request #8702 from m-a-r-c-o/raw-image-paste-fix

Fix raw image paste from clipboard
parents 704922c8 7b3fd031
No related branches found
No related tags found
Loading
Loading
@@ -42,7 +42,7 @@ v 7.8.0
Loading
@@ -42,7 +42,7 @@ v 7.8.0
- Password reset token validity increased from 2 hours to 2 days since it is also send on account creation. - Password reset token validity increased from 2 hours to 2 days since it is also send on account creation.
- -
- -
- - Enable raw image paste from clipboard, currently Chrome only (Marco Cyriacks)
- -
- -
- Add action property to merge request hook (Julien Bianchi) - Add action property to merge request hook (Julien Bianchi)
Loading
Loading
Loading
@@ -13,6 +13,8 @@ class @DropzoneInput
Loading
@@ -13,6 +13,8 @@ class @DropzoneInput
   
form_textarea = $(form).find("textarea.markdown-area") form_textarea = $(form).find("textarea.markdown-area")
form_textarea.wrap "<div class=\"div-dropzone\"></div>" form_textarea.wrap "<div class=\"div-dropzone\"></div>"
form_textarea.bind 'paste', (event) =>
handlePaste(event)
   
form_dropzone = $(form).find('.div-dropzone') form_dropzone = $(form).find('.div-dropzone')
form_dropzone.parent().addClass "div-dropzone-wrapper" form_dropzone.parent().addClass "div-dropzone-wrapper"
Loading
@@ -133,24 +135,17 @@ class @DropzoneInput
Loading
@@ -133,24 +135,17 @@ class @DropzoneInput
formatLink = (str) -> formatLink = (str) ->
"![" + str.alt + "](" + str.url + ")" "![" + str.alt + "](" + str.url + ")"
   
handlePaste = (e) -> handlePaste = (event) ->
e.preventDefault() pasteEvent = event.originalEvent
my_event = e.originalEvent if pasteEvent.clipboardData and pasteEvent.clipboardData.items
image = isImage(pasteEvent)
if my_event.clipboardData and my_event.clipboardData.items if image
processItem(my_event) event.preventDefault()
processItem = (e) -> filename = getFilename(pasteEvent) or "image.png"
image = isImage(e) text = "{{" + filename + "}}"
if image pasteText(text)
filename = getFilename(e) or "image.png" uploadFile image.getAsFile(), filename
text = "{{" + filename + "}}"
pasteText(text)
uploadFile image.getAsFile(), filename
else
text = e.clipboardData.getData("text/plain")
pasteText(text)
   
isImage = (data) -> isImage = (data) ->
i = 0 i = 0
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment