mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
parent
6deae3c188
commit
8b580ed988
4 changed files with 54 additions and 2 deletions
|
@ -2228,6 +2228,31 @@ var onPaste = function ( event ) {
|
||||||
}, 0 );
|
}, 0 );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// On Windows you can drag an drop text. We can't handle this ourselves, because
|
||||||
|
// as far as I can see, there's no way to get the drop insertion point. So just
|
||||||
|
// save an undo state and hope for the best.
|
||||||
|
var onDrop = function ( event ) {
|
||||||
|
var types = event.dataTransfer.types;
|
||||||
|
var l = types.length;
|
||||||
|
var hasPlain = false;
|
||||||
|
var hasHTML = false;
|
||||||
|
while ( l-- ) {
|
||||||
|
switch ( types[l] ) {
|
||||||
|
case 'text/plain':
|
||||||
|
hasPlain = true;
|
||||||
|
break;
|
||||||
|
case 'text/html':
|
||||||
|
hasHTML = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( hasHTML || hasPlain ) {
|
||||||
|
this.saveUndoState();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var instances = [];
|
var instances = [];
|
||||||
|
|
||||||
function getSquireInstance ( doc ) {
|
function getSquireInstance ( doc ) {
|
||||||
|
@ -2328,6 +2353,7 @@ function Squire ( root, config ) {
|
||||||
this.addEventListener( isIElt11 ? 'beforecut' : 'cut', onCut );
|
this.addEventListener( isIElt11 ? 'beforecut' : 'cut', onCut );
|
||||||
this.addEventListener( 'copy', onCopy );
|
this.addEventListener( 'copy', onCopy );
|
||||||
this.addEventListener( isIElt11 ? 'beforepaste' : 'paste', onPaste );
|
this.addEventListener( isIElt11 ? 'beforepaste' : 'paste', onPaste );
|
||||||
|
this.addEventListener( 'drop', onDrop );
|
||||||
|
|
||||||
// Opera does not fire keydown repeatedly.
|
// Opera does not fire keydown repeatedly.
|
||||||
this.addEventListener( isPresto ? 'keypress' : 'keydown', onKey );
|
this.addEventListener( isPresto ? 'keypress' : 'keydown', onKey );
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -206,3 +206,28 @@ var onPaste = function ( event ) {
|
||||||
}
|
}
|
||||||
}, 0 );
|
}, 0 );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// On Windows you can drag an drop text. We can't handle this ourselves, because
|
||||||
|
// as far as I can see, there's no way to get the drop insertion point. So just
|
||||||
|
// save an undo state and hope for the best.
|
||||||
|
var onDrop = function ( event ) {
|
||||||
|
var types = event.dataTransfer.types;
|
||||||
|
var l = types.length;
|
||||||
|
var hasPlain = false;
|
||||||
|
var hasHTML = false;
|
||||||
|
while ( l-- ) {
|
||||||
|
switch ( types[l] ) {
|
||||||
|
case 'text/plain':
|
||||||
|
hasPlain = true;
|
||||||
|
break;
|
||||||
|
case 'text/html':
|
||||||
|
hasHTML = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( hasHTML || hasPlain ) {
|
||||||
|
this.saveUndoState();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -100,6 +100,7 @@ function Squire ( root, config ) {
|
||||||
this.addEventListener( isIElt11 ? 'beforecut' : 'cut', onCut );
|
this.addEventListener( isIElt11 ? 'beforecut' : 'cut', onCut );
|
||||||
this.addEventListener( 'copy', onCopy );
|
this.addEventListener( 'copy', onCopy );
|
||||||
this.addEventListener( isIElt11 ? 'beforepaste' : 'paste', onPaste );
|
this.addEventListener( isIElt11 ? 'beforepaste' : 'paste', onPaste );
|
||||||
|
this.addEventListener( 'drop', onDrop );
|
||||||
|
|
||||||
// Opera does not fire keydown repeatedly.
|
// Opera does not fire keydown repeatedly.
|
||||||
this.addEventListener( isPresto ? 'keypress' : 'keydown', onKey );
|
this.addEventListener( isPresto ? 'keypress' : 'keydown', onKey );
|
||||||
|
|
Loading…
Reference in a new issue