Index: trunk/parsers/wikidom/lib/es/es.Surface.js |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | this.location = null; |
27 | 27 | this.selection = null; |
28 | 28 | this.keydownInterval = null; |
| 29 | + this.initialHorizontalCursorPosition = null; |
29 | 30 | this.render(); |
30 | 31 | |
31 | 32 | this.state = { |
— | — | @@ -71,24 +72,28 @@ |
72 | 73 | |
73 | 74 | switch ( e.keyCode ) { |
74 | 75 | case 37: // Left arrow |
| 76 | + this.initialHorizontalCursorPosition = null; |
75 | 77 | this.moveCursorLeft(); |
76 | 78 | break; |
77 | 79 | case 38: // Up arrow |
78 | 80 | this.moveCursorUp(); |
79 | 81 | break; |
80 | 82 | case 39: // Right arrow |
| 83 | + this.initialHorizontalCursorPosition = null; |
81 | 84 | this.moveCursorRight(); |
82 | 85 | break; |
83 | 86 | case 40: // Down arrow |
84 | 87 | this.moveCursorDown(); |
85 | 88 | break; |
86 | 89 | case 8: // Backspace |
| 90 | + this.initialHorizontalCursorPosition = null; |
87 | 91 | this.handleBackspace(); |
88 | 92 | break; |
89 | 93 | case 46: // Delete |
90 | 94 | this.handleDelete(); |
91 | 95 | break; |
92 | 96 | default: |
| 97 | + this.initialHorizontalCursorPosition = null; |
93 | 98 | this.cursor.hide(); |
94 | 99 | if ( this.keydownInterval ) { |
95 | 100 | clearTimeout( this.keydownInterval ); |
— | — | @@ -131,6 +136,8 @@ |
132 | 137 | } |
133 | 138 | |
134 | 139 | Surface.prototype.onMouseDown = function( e ) { |
| 140 | + this.initialHorizontalCursorPosition = null; |
| 141 | + |
135 | 142 | var $target = $( e.target ); |
136 | 143 | $block = $target.is( '.editSurface-block' ) |
137 | 144 | ? $target : $target.closest( '.editSurface-block' ); |
— | — | @@ -226,6 +233,13 @@ |
227 | 234 | Surface.prototype.moveCursorUp = function() { |
228 | 235 | var location = this.getLocation(), |
229 | 236 | position = location.block.getPosition( location.offset ); |
| 237 | + |
| 238 | + if ( this.initialHorizontalCursorPosition ) { |
| 239 | + position.left = this.initialHorizontalCursorPosition; |
| 240 | + } else { |
| 241 | + this.initialHorizontalCursorPosition = position.left; |
| 242 | + } |
| 243 | + |
230 | 244 | position.top = position.top - 1; |
231 | 245 | if ( position.top < 0 ) { |
232 | 246 | var previousBlock = location.block.previousBlock(); |
— | — | @@ -245,6 +259,13 @@ |
246 | 260 | Surface.prototype.moveCursorDown = function() { |
247 | 261 | var location = this.getLocation() |
248 | 262 | position = location.block.getPosition( location.offset ); |
| 263 | + |
| 264 | + if ( this.initialHorizontalCursorPosition ) { |
| 265 | + position.left = this.initialHorizontalCursorPosition; |
| 266 | + } else { |
| 267 | + this.initialHorizontalCursorPosition = position.left; |
| 268 | + } |
| 269 | + |
249 | 270 | position.top = position.bottom + 1; |
250 | 271 | if ( position.top > location.block.$.height() ) { |
251 | 272 | var nextBlock = location.block.nextBlock(); |