mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
make it possible to replace the reference to e.fragment
in willPaste
event, also add isDefaultPrevented
method to that event
This commit is contained in:
parent
2452ef9556
commit
ed10b03b9f
4 changed files with 29 additions and 20 deletions
|
@ -1,4 +1,4 @@
|
|||
/* Copyright © 2011-2013 by Neil Jenkins. MIT Licensed. */
|
||||
/* Copyright © 2011-2015 by Neil Jenkins. MIT Licensed. */
|
||||
|
||||
( function ( doc, undefined ) {
|
||||
|
||||
|
@ -3082,21 +3082,25 @@ proto._onPaste = function ( event ) {
|
|||
removeEmptyInlines( frag );
|
||||
|
||||
var node = frag,
|
||||
doPaste = true;
|
||||
doPaste = true,
|
||||
evt = {
|
||||
fragment: frag,
|
||||
preventDefault: function () {
|
||||
doPaste = false;
|
||||
},
|
||||
isDefaultPrevented: function () {
|
||||
return doPaste;
|
||||
}
|
||||
};
|
||||
while ( node = getNextBlock( node ) ) {
|
||||
fixCursor( node );
|
||||
}
|
||||
|
||||
self.fireEvent( 'willPaste', {
|
||||
fragment: frag,
|
||||
preventDefault: function () {
|
||||
doPaste = false;
|
||||
}
|
||||
});
|
||||
self.fireEvent( 'willPaste', evt);
|
||||
|
||||
// Insert pasted data
|
||||
if ( doPaste ) {
|
||||
insertTreeFragmentIntoRange( range, frag );
|
||||
insertTreeFragmentIntoRange( range, evt.fragment );
|
||||
if ( !canObserveMutations ) {
|
||||
self._docWasChanged();
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1658,21 +1658,25 @@ proto._onPaste = function ( event ) {
|
|||
removeEmptyInlines( frag );
|
||||
|
||||
var node = frag,
|
||||
doPaste = true;
|
||||
doPaste = true,
|
||||
evt = {
|
||||
fragment: frag,
|
||||
preventDefault: function () {
|
||||
doPaste = false;
|
||||
},
|
||||
isDefaultPrevented: function () {
|
||||
return doPaste;
|
||||
}
|
||||
};
|
||||
while ( node = getNextBlock( node ) ) {
|
||||
fixCursor( node );
|
||||
}
|
||||
|
||||
self.fireEvent( 'willPaste', {
|
||||
fragment: frag,
|
||||
preventDefault: function () {
|
||||
doPaste = false;
|
||||
}
|
||||
});
|
||||
self.fireEvent( 'willPaste', evt);
|
||||
|
||||
// Insert pasted data
|
||||
if ( doPaste ) {
|
||||
insertTreeFragmentIntoRange( range, frag );
|
||||
insertTreeFragmentIntoRange( range, evt.fragment );
|
||||
if ( !canObserveMutations ) {
|
||||
self._docWasChanged();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright © 2011-2013 by Neil Jenkins. MIT Licensed. */
|
||||
/* Copyright © 2011-2015 by Neil Jenkins. MIT Licensed. */
|
||||
/*jshint ignore:start */
|
||||
|
||||
( function ( doc, undefined ) {
|
||||
|
|
Loading…
Reference in a new issue