
inez at svn
Feb 10, 2012, 5:04 PM
Post #1 of 1
(21 views)
Permalink
|
|
SVN: [111222] trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
|
|
https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111222 Revision: 111222 Author: inez Date: 2012-02-11 01:04:14 +0000 (Sat, 11 Feb 2012) Log Message: ----------- Working prototype of insertion of the text with annotations Modified Paths: -------------- trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js Modified: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js =================================================================== --- trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js 2012-02-11 00:41:07 UTC (rev 111221) +++ trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js 2012-02-11 01:04:14 UTC (rev 111222) @@ -42,7 +42,7 @@ _this.onPaste( e ); } ); - this.$.on('mouseup', function( e ) { + this.$.on('m---ouseup', function( e ) { var offset = _this.getSelection().start; var $node = _this.documentView.getNodeFromOffset( offset ).$; @@ -177,6 +177,16 @@ _this.node = rangy.getSelection().anchorNode; var prevText = _this.node.textContent; _this.worker = setInterval( function() { + + if ( ( _this.node.previousSibling !== null && _this.node.previousSibling.nodeType === 3 ) || ( _this.node.nextSibling !== null && _this.node.nextSibling.nodeType === 3 ) ) { + console.log("!"); + var start = _this.getSelection().start; + _this.node.parentNode.normalize(); + _this.showCursorAt( start ); + _this.node = rangy.getSelection().anchorNode; + } + + var text = _this.node.textContent; if ( text === prevText ) { @@ -209,6 +219,8 @@ if ( sameFromLeft + sameFromRight !== text.length ) { // insert var data = text.split('').slice(sameFromLeft, text.length - sameFromRight); + var annotations = _this.model.getDocument().getAnnotationsFromOffset( nodeOffset + sameFromLeft - 1 ); + ve.dm.DocumentNode.addAnnotationsToData( data, annotations ); var tx = _this.documentView.model.prepareInsertion( nodeOffset + sameFromLeft, data); _this.model.transact( tx ); } @@ -216,18 +228,6 @@ prevText = text; }, 50 ); }, 1 ); - - - /* - - var sel = rangy.getSelection(); - - - if ( sel.anchorOffset === sel.focusOffset && sel.anchorNode === sel.focusNode ) { - console.log("123"); - } - - */ }; ve.es.Surface.prototype.attachContextView = function( contextView ) { _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|