0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 23:40:35 -05:00

IE requires handlers on before(cut|paste) events.

This commit is contained in:
Neil Jenkins 2011-11-04 17:53:24 +11:00
parent 3b09cbf703
commit 75109c404e
2 changed files with 9 additions and 4 deletions

File diff suppressed because one or more lines are too long

View file

@ -21,7 +21,8 @@ document.addEventListener( 'DOMContentLoaded', function () {
body = doc.body; body = doc.body;
var isOpera = !!win.opera; var isOpera = !!win.opera;
var useTextFixer = isOpera || !!win.ie; var isIE = !!win.ie;
var useTextFixer = isOpera || isOpera;
// --- DOM Sugar --- // --- DOM Sugar ---
@ -959,14 +960,18 @@ document.addEventListener( 'DOMContentLoaded', function () {
// --- Cut and Paste --- // --- Cut and Paste ---
doc.addEventListener( 'cut', function () { doc.addEventListener( isIE ? 'beforecut' : 'cut', function () {
// Save undo checkpoint
var range = getSelection();
recordUndoState( range );
getRangeAndRemoveBookmark( range );
// If all content removed, ensure div at start of body. // If all content removed, ensure div at start of body.
setTimeout( function () { setTimeout( function () {
body.fixCursor(); body.fixCursor();
}, 0 ); }, 0 );
}); });
doc.addEventListener( 'paste', function () { doc.addEventListener( isIE ? 'beforepaste' : 'paste', function () {
var range = getSelection(), var range = getSelection(),
startContainer = range.startContainer, startContainer = range.startContainer,
startOffset = range.startOffset, startOffset = range.startOffset,