Skip to content

Commit

Permalink
try to fix paste when select all
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyfive committed May 9, 2014
1 parent a48f4ce commit 531145a
Show file tree
Hide file tree
Showing 7 changed files with 4,547 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ module.exports = (grunt) ->
}, {
src: 'lib/simditor-all.js',
dest: 'site/assets/scripts/simditor-all.js'
}, {
src: 'lib/simditor-all.js',
dest: 'site/assets/scripts/simditor-all.min.js'
}]
package:
files: [{
Expand Down Expand Up @@ -134,7 +137,7 @@ module.exports = (grunt) ->
tasks: ['sass:simditor', 'copy:styles', 'shell']
scripts:
files: ['src/*.coffee', 'src/buttons/*.coffee']
tasks: ['concat:simditor', 'coffee:simditor', 'concat:all', 'copy:scripts', 'shell']
tasks: ['concat:simditor', 'coffee:simditor', 'concat:all', 'copy:site', 'shell']
siteStyles:
files: ['site/assets/_sass/*.scss']
tasks: ['sass:site', 'shell']
Expand Down
10 changes: 10 additions & 0 deletions lib/simditor-all.js

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

10 changes: 10 additions & 0 deletions lib/simditor.js

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

10 changes: 10 additions & 0 deletions site/assets/scripts/simditor-all.js

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

4,486 changes: 4,483 additions & 3 deletions site/assets/scripts/simditor-all.min.js

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/inputManager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class InputManager extends Plugin
@editor.uploader?.upload(imageFile, uploadOpt)
return false


$blockEl = @editor.util.closestBlockEl()
cleanPaste = $blockEl.is 'pre, table'
@editor.selection.deleteRangeContents()
Expand Down Expand Up @@ -318,6 +317,21 @@ class InputManager extends Plugin
.click()
false

'cmd+65': (e) ->
range = document.createRange()
node = @editor.body[0]
# startNode = @editor.body.children().first()
# endNode = @editor.body.children().last()

range.setStart(node, 0)
range.setEnd(node, @editor.util.getNodeLength(node))

# @editor.selection.setRangeAtStartOf(@editor.body.children().get(0), range)
# @editor.selection.setRangeAtEndOf(@editor.body.children().last()[0], range)
@editor.selection.selectRange(range)
console.log(range)
false

addShortcut: (keys, handler) ->
@_shortcuts[keys] = $.proxy(handler, this)

Expand Down
16 changes: 15 additions & 1 deletion src/simditor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ class InputManager extends Plugin
@editor.uploader?.upload(imageFile, uploadOpt)
return false


$blockEl = @editor.util.closestBlockEl()
cleanPaste = $blockEl.is 'pre, table'
@editor.selection.deleteRangeContents()
Expand Down Expand Up @@ -686,6 +685,21 @@ class InputManager extends Plugin
.click()
false

'cmd+65': (e) ->
range = document.createRange()
node = @editor.body[0]
# startNode = @editor.body.children().first()
# endNode = @editor.body.children().last()

range.setStart(node, 0)
range.setEnd(node, @editor.util.getNodeLength(node))

# @editor.selection.setRangeAtStartOf(@editor.body.children().get(0), range)
# @editor.selection.setRangeAtEndOf(@editor.body.children().last()[0], range)
@editor.selection.selectRange(range)
console.log(range)
false

addShortcut: (keys, handler) ->
@_shortcuts[keys] = $.proxy(handler, this)

Expand Down

0 comments on commit 531145a

Please sign in to comment.