r103414 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103413‎ | r103414 | r103415 >
Date:23:34, 16 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Added support for enter key in elements with attributes - like headings, listitems.
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
@@ -364,9 +364,13 @@
365365
366366 while ( node ) {
367367 nodeType = node.getElementType();
368 - stack.push(nodeType);
 368+ stack.splice(
 369+ stack.length / 2,
 370+ 0,
 371+ { 'type': '/' + nodeType },
 372+ { 'type': nodeType, 'attributes': es.copyObject( node.element.attributes ) }
 373+ );
369374 node = node.getParent();
370 -
371375 if ( es.DocumentView.splitRules[ nodeType ].self === true ) {
372376 nodeType = node.getElementType();
373377 if ( es.DocumentView.splitRules[ nodeType ].children === true) {
@@ -374,16 +378,8 @@
375379 }
376380 }
377381 }
378 -
379 - var temp = [];
380 - for ( var i = 0; i < stack.length; i++ ) {
381 - temp.push( { 'type' : '/' + stack[i] } );
382 - }
383 - for ( var i = stack.length - 1; i >= 0; i-- ) {
384 - temp.push( { 'type' : stack[i] } );
385 - }
386382
387 - var tx = this.documentView.model.prepareInsertion( this.selection.to, temp );
 383+ var tx = this.documentView.model.prepareInsertion( this.selection.to, stack );
388384 this.documentView.model.commit( tx );
389385
390386 this.selection.from = this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.to, 1 );

Status & tagging log