Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -170,10 +170,12 @@ |
171 | 171 | |
172 | 172 | } else if ( e.originalEvent.detail >= 3 ) { // triple click |
173 | 173 | this.mouse.selectingMode = 3; // used in mouseMove handler |
174 | | - |
175 | | - var node = this.documentView.getNodeFromOffset( offset ); |
176 | | - this.selection.from = this.documentView.getOffsetFromNode( node, false ) + 1; |
177 | | - this.selection.to = this.selection.from + node.getElementLength() - 2; |
| 174 | + |
| 175 | + var node = this.documentView.getNodeFromOffset( offset ), |
| 176 | + nodeOffset = this.documentView.getOffsetFromNode( node, false ); |
| 177 | + |
| 178 | + this.selection.from = this.documentView.getModel().getRelativeContentOffset( nodeOffset, 1 ); |
| 179 | + this.selection.to = this.documentView.getModel().getRelativeContentOffset( nodeOffset + node.getElementLength(), -1 ); |
178 | 180 | this.mouse.selectedRange = this.selection.clone(); |
179 | 181 | } |
180 | 182 | |
— | — | @@ -214,14 +216,17 @@ |
215 | 217 | this.selection.to = offset; |
216 | 218 | } |
217 | 219 | } else if ( this.mouse.selectingMode === 3 ) { |
| 220 | + |
| 221 | + this.mouse.selectingMode = 3; // used in mouseMove handler |
| 222 | + |
218 | 223 | var nodeRange = this.documentView.getRangeFromNode( |
219 | 224 | this.documentView.getNodeFromOffset( offset ) |
220 | 225 | ); |
221 | 226 | if ( nodeRange.to <= this.mouse.selectedRange.from ) { |
222 | | - this.selection.to = nodeRange.from; |
| 227 | + this.selection.to = this.documentView.getModel().getRelativeContentOffset( nodeRange.from, 1 ); |
223 | 228 | this.selection.from = this.mouse.selectedRange.to; |
224 | 229 | } else { |
225 | | - this.selection.to = nodeRange.to; |
| 230 | + this.selection.to = this.documentView.getModel().getRelativeContentOffset( nodeRange.to, -1 ); |
226 | 231 | this.selection.from = this.mouse.selectedRange.from; |
227 | 232 | } |
228 | 233 | } |
— | — | @@ -359,7 +364,7 @@ |
360 | 365 | var tx = this.documentView.model.prepareRemoval( this.selection ); |
361 | 366 | this.documentView.model.commit( tx ); |
362 | 367 | this.documentView.clearSelection(); |
363 | | - this.selection.to = this.selection.from; |
| 368 | + this.selection.from = this.selection.to = Math.min( this.selection.from, this.selection.to ); |
364 | 369 | this.showCursor(); |
365 | 370 | } |
366 | 371 | break; |
— | — | @@ -403,7 +408,7 @@ |
404 | 409 | var tx = this.documentView.model.prepareRemoval( this.selection ); |
405 | 410 | this.documentView.model.commit( tx ); |
406 | 411 | this.documentView.clearSelection(); |
407 | | - this.selection.to = this.selection.from; |
| 412 | + this.selection.from = this.selection.to = Math.min( this.selection.from, this.selection.to ); |
408 | 413 | this.showCursor(); |
409 | 414 | } |
410 | 415 | break; |
— | — | @@ -480,11 +485,13 @@ |
481 | 486 | var tx = this.documentView.model.prepareRemoval( this.selection ); |
482 | 487 | this.documentView.model.commit( tx ); |
483 | 488 | this.documentView.clearSelection(); |
| 489 | + this.selection.from = this.selection.to = Math.min( this.selection.from, this.selection.to ); |
484 | 490 | } |
485 | 491 | |
486 | 492 | var tx = this.documentView.model.prepareInsertion( this.selection.from, val.split('') ); |
487 | 493 | this.documentView.model.commit ( tx ); |
488 | | - this.selection.to = this.selection.from += val.length; |
| 494 | + this.selection.from += val.length; |
| 495 | + this.selection.to += val.length; |
489 | 496 | this.showCursor(); |
490 | 497 | } |
491 | 498 | }; |