https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103404
Revision: 103404
Author: inez
Date: 2011-11-16 23:16:02 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
Basic support for enter key in heading and paragraphs
Modified Paths:
--------------
trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
Modified: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
2011-11-16 22:55:48 UTC (rev 103403)
+++ trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
2011-11-16 23:16:02 UTC (rev 103404)
@@ -143,7 +143,7 @@
if ( e.button === 0 ) { // left mouse button
var offset = this.documentView.getOffsetFromEvent( e );
-
+
console.log('onMouseDown; offset: ' + offset);
if ( e.originalEvent.detail === 1 ) { // single click
@@ -356,6 +356,40 @@
}
break;
+ case 13: // Enter
+ if ( this.selection.from === this.selection.to ) {
+ var node =
this.documentView.getNodeFromOffset( this.selection.to, false ).model,
+ nodeType,
+ stack = [];
+
+ while ( node ) {
+ nodeType = node.getElementType();
+ stack.push(nodeType);
+ node = node.getParent();
+
+ if ( es.DocumentView.splitRules[
nodeType ].self === true ) {
+ nodeType =
node.getElementType();
+ if (
es.DocumentView.splitRules[ nodeType ].children === true) {
+ break;
+ }
+ }
+ }
+
+ var temp = [];
+ for ( var i = 0; i < stack.length; i++ ) {
+ temp.push( { 'type' : '/' + stack[i] }
);
+ }
+ for ( var i = stack.length - 1; i >= 0; i-- ) {
+ temp.push( { 'type' : stack[i] } );
+ }
+
+ var tx =
this.documentView.model.prepareInsertion( this.selection.to, temp );
+ this.documentView.model.commit( tx );
+
+ //this.selection.from = this.selection.to =
this.documentView.getModel().getRelativeContentOffset( this.selection.to+1, 1 );
+ //this.showCursor();
+ }
+ break;
default: // Insert content (maybe)
if ( this.keyboard.keydownTimeout ) {
clearTimeout( this.keyboard.keydownTimeout );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs