r112858 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112857‎ | r112858 | r112859 >
Date:00:27, 2 March 2012
Author:christian
Status:deferred
Tags:
Comment:
better cut-copy-paste support
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
@@ -88,7 +88,7 @@
8989 console.log('cut/copy');
9090 var _this = this,
9191 rangySel = rangy.getSelection(),
92 - key = rangySel.getRangeAt(0).toString().replace(/( |\r\n|\n|\r|\t)/gm,"");
 92+ key = rangySel.getRangeAt(0).toString().replace(/\s/gm,"");
9393
9494 _this.clipboard[key] = ve.copyArray( _this.documentView.model.getData( _this.getSelection() ) );
9595
@@ -107,22 +107,12 @@
108108 var _this = this,
109109 insertionPoint = _this.getSelection().start,
110110 node = rangy.getSelection().anchorNode;
111 -
112 -_this.stopPolling();
 111+
113112 $('#paste').html('').show().css( 'top', $(window).scrollTop() ).css(' left', $(window).scrollLeft() ).focus();
114113
115 -
116 -
117114 setTimeout( function() {
 115+ var key = $('#paste').hide().text().replace(/\s/gm,"");
118116
119 - console.log('key is: ');
120 - console.log(_this.clipboard);
121 - console.log('paste is: ');
122 - console.log( $('#paste').hide().text().replace(/( |\r\n|\n|\r|\t)/gm,"") );
123 -
124 -
125 - var key = $('#paste').hide().text().replace(/( |\r\n|\n|\r|\t)/gm,"");
126 -
127117 if ( _this.clipboard[key] ) {
128118 // transact
129119 var tx = _this.documentView.model.prepareInsertion( insertionPoint, _this.clipboard[key]);
@@ -130,12 +120,12 @@
131121
132122 // re-render
133123 _this.getLeafNode( node ).data( 'view' ).renderContent();
 124+
 125+ // clear the prev information from poll object (probably a better way to do this)
134126 _this.poll.prevText = _this.poll.prevHash = _this.poll.prevOffset = _this.poll.node = null;
135127
136128 // place cursor
137 - //_this.showCursorAt( insertionPoint + _this.clipboard[key].length );
138 -
139 - //_this.startPolling();
 129+ _this.showCursorAt( insertionPoint + _this.clipboard[key].length );
140130 } else {
141131 alert('i can only handle copy/paste from hybrid surface. sorry. :(');
142132 }

Status & tagging log