Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -45,9 +45,6 @@ |
46 | 46 | this.documentView = new es.DocumentView( this.model.getDocument(), this ); |
47 | 47 | this.$.append( this.documentView.$ ); |
48 | 48 | |
49 | | - // History |
50 | | - this.history = new es.HistoryModel( this.documentView.getModel() ); |
51 | | - |
52 | 49 | // Interaction state |
53 | 50 | |
54 | 51 | // There are three different selection modes available for mouse. Selection of: |
— | — | @@ -351,16 +348,22 @@ |
352 | 349 | this.handleEnter(); |
353 | 350 | e.preventDefault(); |
354 | 351 | break; |
355 | | - case 90: // z (undo) |
| 352 | + case 90: // z (undo/redo) |
356 | 353 | if ( e.metaKey || e.ctrlKey ) { |
357 | | - this.history.undo(); |
| 354 | + /* |
| 355 | + if ( this.keyboard.keys.shift ) { |
| 356 | + this.history.redo(); |
| 357 | + } else { |
| 358 | + this.history.undo(); |
| 359 | + } |
| 360 | + var selection = this.history.getCurrentStateSelection(); |
| 361 | + if ( selection ) { |
| 362 | + this.selection = selection.clone(); |
| 363 | + this.showCursor(); |
| 364 | + } |
| 365 | + */ |
358 | 366 | } |
359 | 367 | break; |
360 | | - case 89: // y (redo) |
361 | | - if ( e.metaKey || e.ctrlKey ) { |
362 | | - this.history.redo(); |
363 | | - } |
364 | | - break; |
365 | 368 | default: // Insert content (maybe) |
366 | 369 | if ( this.keyboard.keydownTimeout ) { |
367 | 370 | clearTimeout( this.keyboard.keydownTimeout ); |
— | — | @@ -426,12 +429,12 @@ |
427 | 430 | tx = this.documentView.getModel().prepareRemoval( |
428 | 431 | new es.Range( targetOffset, sourceOffset ) |
429 | 432 | ); |
430 | | - this.history.commit( tx ); |
| 433 | + this.documentView.getModel().commit( tx ); |
431 | 434 | } else { |
432 | 435 | tx = this.documentView.getModel().prepareInsertion( |
433 | 436 | targetOffset, sourceNode.model.getContent() |
434 | 437 | ); |
435 | | - this.history.commit( tx ); |
| 438 | + this.documentView.getModel().commit( tx ); |
436 | 439 | |
437 | 440 | var nodeToDelete = sourceNode; |
438 | 441 | es.DocumentNode.traverseUpstream( nodeToDelete, function( node ) { |
— | — | @@ -445,12 +448,12 @@ |
446 | 449 | range.from = this.documentView.getOffsetFromNode( nodeToDelete, false ); |
447 | 450 | range.to = range.from + nodeToDelete.getElementLength(); |
448 | 451 | tx = this.documentView.getModel().prepareRemoval( range ); |
449 | | - this.history.commit( tx ); |
| 452 | + this.documentView.getModel().commit( tx ); |
450 | 453 | } |
451 | 454 | } else { |
452 | 455 | // selection removal |
453 | 456 | tx = this.documentView.getModel().prepareRemoval( this.selection ); |
454 | | - this.history.commit( tx ); |
| 457 | + this.documentView.getModel().commit( tx ); |
455 | 458 | this.documentView.clearSelection(); |
456 | 459 | this.selection.from = this.selection.to = this.selection.start; |
457 | 460 | this.showCursor(); |
— | — | @@ -472,7 +475,7 @@ |
473 | 476 | nodeOffset + node.getElementLength(), |
474 | 477 | [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ] |
475 | 478 | ); |
476 | | - this.history.commit( tx ); |
| 479 | + this.documentView.getModel().commit( tx ); |
477 | 480 | this.selection.from = this.selection.to = nodeOffset + node.getElementLength() + 1; |
478 | 481 | this.showCursor(); |
479 | 482 | } else { |
— | — | @@ -499,7 +502,7 @@ |
500 | 503 | splitable = es.DocumentView.splitRules[ elementType ].self; |
501 | 504 | } ); |
502 | 505 | var tx = this.documentView.model.prepareInsertion( this.selection.to, stack ); |
503 | | - this.history.commit( tx ); |
| 506 | + this.documentView.getModel().commit( tx ); |
504 | 507 | this.selection.from = this.selection.to = |
505 | 508 | this.documentView.getModel().getRelativeContentOffset( this.selection.to, 1 ); |
506 | 509 | this.showCursor(); |
— | — | @@ -513,13 +516,13 @@ |
514 | 517 | var tx; |
515 | 518 | if ( this.selection.from != this.selection.to ) { |
516 | 519 | tx = this.documentView.getModel().prepareRemoval( this.selection ); |
517 | | - this.history.commit( tx ); |
| 520 | + this.documentView.getModel().commit( tx ); |
518 | 521 | this.documentView.clearSelection(); |
519 | 522 | this.selection.from = this.selection.to = |
520 | 523 | Math.min( this.selection.from, this.selection.to ); |
521 | 524 | } |
522 | 525 | tx = this.documentView.getModel().prepareInsertion( this.selection.from, val.split('') ); |
523 | | - this.history.commit( tx ); |
| 526 | + this.documentView.getModel().commit( tx ); |
524 | 527 | this.selection.from += val.length; |
525 | 528 | this.selection.to += val.length; |
526 | 529 | this.showCursor(); |