r103876 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103875‎ | r103876 | r103877 >
Date:00:26, 22 November 2011
Author:tparscal
Status:ok
Tags:
Comment:
Backing out history integration for now
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
@@ -45,9 +45,6 @@
4646 this.documentView = new es.DocumentView( this.model.getDocument(), this );
4747 this.$.append( this.documentView.$ );
4848
49 - // History
50 - this.history = new es.HistoryModel( this.documentView.getModel() );
51 -
5249 // Interaction state
5350
5451 // There are three different selection modes available for mouse. Selection of:
@@ -351,16 +348,22 @@
352349 this.handleEnter();
353350 e.preventDefault();
354351 break;
355 - case 90: // z (undo)
 352+ case 90: // z (undo/redo)
356353 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+ */
358366 }
359367 break;
360 - case 89: // y (redo)
361 - if ( e.metaKey || e.ctrlKey ) {
362 - this.history.redo();
363 - }
364 - break;
365368 default: // Insert content (maybe)
366369 if ( this.keyboard.keydownTimeout ) {
367370 clearTimeout( this.keyboard.keydownTimeout );
@@ -426,12 +429,12 @@
427430 tx = this.documentView.getModel().prepareRemoval(
428431 new es.Range( targetOffset, sourceOffset )
429432 );
430 - this.history.commit( tx );
 433+ this.documentView.getModel().commit( tx );
431434 } else {
432435 tx = this.documentView.getModel().prepareInsertion(
433436 targetOffset, sourceNode.model.getContent()
434437 );
435 - this.history.commit( tx );
 438+ this.documentView.getModel().commit( tx );
436439
437440 var nodeToDelete = sourceNode;
438441 es.DocumentNode.traverseUpstream( nodeToDelete, function( node ) {
@@ -445,12 +448,12 @@
446449 range.from = this.documentView.getOffsetFromNode( nodeToDelete, false );
447450 range.to = range.from + nodeToDelete.getElementLength();
448451 tx = this.documentView.getModel().prepareRemoval( range );
449 - this.history.commit( tx );
 452+ this.documentView.getModel().commit( tx );
450453 }
451454 } else {
452455 // selection removal
453456 tx = this.documentView.getModel().prepareRemoval( this.selection );
454 - this.history.commit( tx );
 457+ this.documentView.getModel().commit( tx );
455458 this.documentView.clearSelection();
456459 this.selection.from = this.selection.to = this.selection.start;
457460 this.showCursor();
@@ -472,7 +475,7 @@
473476 nodeOffset + node.getElementLength(),
474477 [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ]
475478 );
476 - this.history.commit( tx );
 479+ this.documentView.getModel().commit( tx );
477480 this.selection.from = this.selection.to = nodeOffset + node.getElementLength() + 1;
478481 this.showCursor();
479482 } else {
@@ -499,7 +502,7 @@
500503 splitable = es.DocumentView.splitRules[ elementType ].self;
501504 } );
502505 var tx = this.documentView.model.prepareInsertion( this.selection.to, stack );
503 - this.history.commit( tx );
 506+ this.documentView.getModel().commit( tx );
504507 this.selection.from = this.selection.to =
505508 this.documentView.getModel().getRelativeContentOffset( this.selection.to, 1 );
506509 this.showCursor();
@@ -513,13 +516,13 @@
514517 var tx;
515518 if ( this.selection.from != this.selection.to ) {
516519 tx = this.documentView.getModel().prepareRemoval( this.selection );
517 - this.history.commit( tx );
 520+ this.documentView.getModel().commit( tx );
518521 this.documentView.clearSelection();
519522 this.selection.from = this.selection.to =
520523 Math.min( this.selection.from, this.selection.to );
521524 }
522525 tx = this.documentView.getModel().prepareInsertion( this.selection.from, val.split('') );
523 - this.history.commit( tx );
 526+ this.documentView.getModel().commit( tx );
524527 this.selection.from += val.length;
525528 this.selection.to += val.length;
526529 this.showCursor();

Status & tagging log