https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112861

Revision: 112861
Author:   christian
Date:     2012-03-02 00:37:01 +0000 (Fri, 02 Mar 2012)
Log Message:
-----------
adding paste fixes to cut handler

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js

Modified: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js        
2012-03-02 00:34:31 UTC (rev 112860)
+++ trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js        
2012-03-02 00:37:01 UTC (rev 112861)
@@ -87,17 +87,30 @@
 ve.es.Surface.prototype.onCutCopy = function( e ) {
        console.log('cut/copy');
        var _this = this,
-       rangySel = rangy.getSelection(),
-       key = rangySel.getRangeAt(0).toString().replace(/\s/gm,"");
+               rangySel = rangy.getSelection(),
+               key = rangySel.getRangeAt(0).toString().replace(/\s/gm,"");
 
        _this.clipboard[key] = ve.copyArray( _this.documentView.model.getData( 
_this.getSelection() ) );
 
        if ( event.type == 'cut' ) {
                setTimeout( function() {
+                       // we don't like how browsers cut, so let's undo it and 
do it ourselves.
                        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 );
                        _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 );
                }, 1 );
        }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to