Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js |
— | — | @@ -87,17 +87,30 @@ |
88 | 88 | ve.es.Surface.prototype.onCutCopy = function( e ) { |
89 | 89 | console.log('cut/copy'); |
90 | 90 | 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,""); |
93 | 93 | |
94 | 94 | _this.clipboard[key] = ve.copyArray( _this.documentView.model.getData( _this.getSelection() ) ); |
95 | 95 | |
96 | 96 | if ( event.type == 'cut' ) { |
97 | 97 | setTimeout( function() { |
| 98 | + // we don't like how browsers cut, so let's undo it and do it ourselves. |
98 | 99 | document.execCommand('undo', false, false); |
99 | | - var selection = _this.getSelection(); |
| 100 | + |
| 101 | + var selection = _this.getSelection(), |
| 102 | + node = rangy.getSelection().anchorNode; |
| 103 | + |
| 104 | + // transact |
100 | 105 | var tx = _this.model.getDocument().prepareRemoval( selection ); |
101 | 106 | _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 |
102 | 115 | _this.showCursorAt( selection.start ); |
103 | 116 | }, 1 ); |
104 | 117 | } |