Fixed paste on IE. Fixes #579
This commit is contained in:
parent
bd062a2103
commit
23b58f9696
@ -292,13 +292,19 @@ define([
|
|||||||
|
|
||||||
var nextTickAdjustScroll = false;
|
var nextTickAdjustScroll = false;
|
||||||
var debouncedSave = utils.debounce(function() {
|
var debouncedSave = utils.debounce(function() {
|
||||||
|
save();
|
||||||
|
self.updateCursorCoordinates(nextTickAdjustScroll);
|
||||||
|
// In some cases we have to wait a little bit more to see the selection change (Cmd+A on Chrome/OSX)
|
||||||
|
longerDebouncedSave();
|
||||||
|
});
|
||||||
|
var longerDebouncedSave = utils.debounce(function() {
|
||||||
save();
|
save();
|
||||||
if(lastSelectionStart === self.selectionStart && lastSelectionEnd === self.selectionEnd) {
|
if(lastSelectionStart === self.selectionStart && lastSelectionEnd === self.selectionEnd) {
|
||||||
nextTickAdjustScroll = false;
|
nextTickAdjustScroll = false;
|
||||||
}
|
}
|
||||||
self.updateCursorCoordinates(nextTickAdjustScroll);
|
self.updateCursorCoordinates(nextTickAdjustScroll);
|
||||||
nextTickAdjustScroll = false;
|
nextTickAdjustScroll = false;
|
||||||
});
|
}, 10);
|
||||||
|
|
||||||
return function(debounced, adjustScroll, forceAdjustScroll) {
|
return function(debounced, adjustScroll, forceAdjustScroll) {
|
||||||
if(forceAdjustScroll) {
|
if(forceAdjustScroll) {
|
||||||
@ -880,10 +886,19 @@ define([
|
|||||||
.on('paste', function(evt) {
|
.on('paste', function(evt) {
|
||||||
undoMgr.currentMode = 'paste';
|
undoMgr.currentMode = 'paste';
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var data = (evt.originalEvent || evt).clipboardData.getData('text/plain') || prompt('Paste something...');
|
var data, clipboardData = (evt.originalEvent || evt).clipboardData;
|
||||||
data = escape(data);
|
if(clipboardData) {
|
||||||
|
data = clipboardData.getData('text/plain');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
clipboardData = window.clipboardData;
|
||||||
|
data = clipboardData && clipboardData.getData('Text');
|
||||||
|
}
|
||||||
|
if(!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
replace(selectionMgr.selectionStart, selectionMgr.selectionEnd, data);
|
||||||
adjustCursorPosition();
|
adjustCursorPosition();
|
||||||
document.execCommand('insertHtml', false, data);
|
|
||||||
})
|
})
|
||||||
.on('cut', function() {
|
.on('cut', function() {
|
||||||
undoMgr.currentMode = 'cut';
|
undoMgr.currentMode = 'cut';
|
||||||
|
Loading…
Reference in New Issue
Block a user