0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -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:
Misha Koryak 2015-05-01 14:07:28 -04:00
parent 2452ef9556
commit ed10b03b9f
4 changed files with 29 additions and 20 deletions

View file

@ -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

View file

@ -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();
}

View file

@ -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 ) {