mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-27 04:06:51 +00:00
adding paste fixes to cut handler
This commit is contained in:
parent
b16a1c3899
commit
3a1ee7e5b9
Notes:
christian
2012-03-02 00:37:01 +00:00
|
@ -94,10 +94,23 @@ ve.es.Surface.prototype.onCutCopy = function( e ) {
|
||||||
|
|
||||||
if ( event.type == 'cut' ) {
|
if ( event.type == 'cut' ) {
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
|
// we don't like how browsers cut, so let's undo it and do it ourselves.
|
||||||
document.execCommand('undo', false, false);
|
document.execCommand('undo', false, false);
|
||||||
var selection = _this.getSelection();
|
|
||||||
|
var selection = _this.getSelection(),
|
||||||
|
node = rangy.getSelection().anchorNode;
|
||||||
|
|
||||||
|
// transact
|
||||||
var tx = _this.model.getDocument().prepareRemoval( selection );
|
var tx = _this.model.getDocument().prepareRemoval( selection );
|
||||||
_this.model.transact( tx );
|
_this.model.transact( tx );
|
||||||
|
|
||||||
|
// re-render
|
||||||
|
_this.getLeafNode( node ).data( 'view' ).renderContent();
|
||||||
|
|
||||||
|
// clear the prev information from poll object (probably a better way to do this)
|
||||||
|
_this.poll.prevText = _this.poll.prevHash = _this.poll.prevOffset = _this.poll.node = null;
|
||||||
|
|
||||||
|
// place cursor
|
||||||
_this.showCursorAt( selection.start );
|
_this.showCursorAt( selection.start );
|
||||||
}, 1 );
|
}, 1 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue