Skip to content

Commit

Permalink
IE 11 support paste upload image
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyfive committed Apr 29, 2014
1 parent c9087c0 commit 340c0bb
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
7 changes: 6 additions & 1 deletion lib/simditor-all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion lib/simditor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion site/assets/scripts/simditor-all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/buttons/image.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ class ImageButton extends Button

createImage: () ->
range = @editor.selection.getRange()

unless range
caret = @editor.inputManager.lastCaretPosition
@editor.undoManager.caretPosition caret
range = @editor.selection.getRange()

startNode = range.startContainer
endNode = range.endContainer
$startBlock = @editor.util.closestBlockEl(startNode)
Expand Down
4 changes: 2 additions & 2 deletions src/inputManager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ class InputManager extends Plugin
children = pasteContent.contents()
@editor.selection.insertNode node, range for node in children

# paste image in firefox
# paste image in firefox and IE 11
else if pasteContent.is('.simditor-image')
$img = pasteContent.find('img')

# firefox
# firefox and IE 11
if dataURLtoBlob && $img.is('img[src^="data:image/png;base64"]')
return unless @opts.pasteImage
blob = dataURLtoBlob $img.attr( "src" )
Expand Down
10 changes: 8 additions & 2 deletions src/simditor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,11 @@ class InputManager extends Plugin
children = pasteContent.contents()
@editor.selection.insertNode node, range for node in children

# paste image in firefox
# paste image in firefox and IE 11
else if pasteContent.is('.simditor-image')
$img = pasteContent.find('img')

# firefox
# firefox and IE 11
if dataURLtoBlob && $img.is('img[src^="data:image/png;base64"]')
return unless @opts.pasteImage
blob = dataURLtoBlob $img.attr( "src" )
Expand Down Expand Up @@ -2738,6 +2738,12 @@ class ImageButton extends Button

createImage: () ->
range = @editor.selection.getRange()

unless range
caret = @editor.inputManager.lastCaretPosition
@editor.undoManager.caretPosition caret
range = @editor.selection.getRange()

startNode = range.startContainer
endNode = range.endContainer
$startBlock = @editor.util.closestBlockEl(startNode)
Expand Down

0 comments on commit 340c0bb

Please sign in to comment.