Skip to content

Commit

Permalink
fix jbt#28: allow paste a string directly through API call
Browse files Browse the repository at this point in the history
  • Loading branch information
greenlaw110 committed May 20, 2016
1 parent 4812667 commit 1c781ba
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,15 @@ Editor.prototype.paste = function(evt){
self.selMgr.setRange(start, start);
self.changed();
}

var insert = typeof evt == 'string';

if(insert || evt.clipboardData){
if (!insert) {
evt.preventDefault();
}

if(evt.clipboardData){
evt.preventDefault();

var pasted = evt.clipboardData.getData('text/plain');
var pasted = insert ? evt : evt.clipboardData.getData('text/plain');

this.apply({
add: pasted,
Expand All @@ -310,4 +314,5 @@ Editor.prototype.paste = function(evt){
applyPasted(self.getText().slice(start, newEnd));
}, 0);
}

};

0 comments on commit 1c781ba

Please sign in to comment.