r112861 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112860‎ | r112861 | r112862 >
Date:00:37, 2 March 2012
Author:christian
Status:deferred
Tags:
Comment:
adding paste fixes to cut handler
Modified paths:
  • /trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
@@ -87,17 +87,30 @@
8888 ve.es.Surface.prototype.onCutCopy = function( e ) {
8989 console.log('cut/copy');
9090 var _this = this,
91 - rangySel = rangy.getSelection(),
92 - key = rangySel.getRangeAt(0).toString().replace(/\s/gm,"");
 91+ rangySel = rangy.getSelection(),
 92+ key = rangySel.getRangeAt(0).toString().replace(/\s/gm,"");
9393
9494 _this.clipboard[key] = ve.copyArray( _this.documentView.model.getData( _this.getSelection() ) );
9595
9696 if ( event.type == 'cut' ) {
9797 setTimeout( function() {
 98+ // we don't like how browsers cut, so let's undo it and do it ourselves.
9899 document.execCommand('undo', false, false);
99 - var selection = _this.getSelection();
 100+
 101+ var selection = _this.getSelection(),
 102+ node = rangy.getSelection().anchorNode;
 103+
 104+ // transact
100105 var tx = _this.model.getDocument().prepareRemoval( selection );
101106 _this.model.transact( tx );
 107+
 108+ // re-render
 109+ _this.getLeafNode( node ).data( 'view' ).renderContent();
 110+
 111+ // clear the prev information from poll object (probably a better way to do this)
 112+ _this.poll.prevText = _this.poll.prevHash = _this.poll.prevOffset = _this.poll.node = null;
 113+
 114+ // place cursor
102115 _this.showCursorAt( selection.start );
103116 }, 1 );
104117 }

Status & tagging log