https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113279

Revision: 113279
Author:   rmoen
Date:     2012-03-07 19:37:17 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
port over annotation methods from ES to CE, remove unused renderDomNode method

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js

Modified: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js        
2012-03-07 19:36:40 UTC (rev 113278)
+++ trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js        
2012-03-07 19:37:17 UTC (rev 113279)
@@ -22,6 +22,7 @@
        this.$ = $container
                .addClass( 'es-surfaceView' )
                .append( this.documentView.$ );
+       this.insertionAnnotations = [];
        this.emitUpdateTimeout = undefined;
        this.clipboard = {};
        this.autoRender = false;
@@ -100,6 +101,7 @@
                this.autoRender = true;
                this.model.transact( tx );
                this.autoRender = false;
+               //TODO: Redraw selection
                                
        } else {
                if ( method === 'set' ) {
@@ -110,10 +112,47 @@
        }
 };
 
-ve.ce.Surface.prototype.renderDomNode = function ( node ) {
-       this.getLeafNode( node ).data( 'view' ).renderContent();
+ve.ce.Surface.prototype.getAnnotations = function() {
+       return this.getSelection().getLength() ?
+               this.model.getDocument().getAnnotationsFromRange( 
this.getSelection() ) :
+               {
+                       'full': this.insertionAnnotations,
+                       'partial': [],
+                       'all': this.insertionAnnotations
+               };
 };
 
+ve.ce.Surface.prototype.getInsertionAnnotations = function() {
+       return this.insertionAnnotations;
+};
+
+ve.ce.Surface.prototype.addInsertionAnnotation = function( annotation ) {
+       this.insertionAnnotations.push( annotation );
+};
+
+ve.ce.Surface.prototype.loadInsertionAnnotations = function( annotation ) {
+       this.insertionAnnotations =
+               this.model.getDocument().getAnnotationsFromOffset( 
this.getSelection().to - 1 );
+       // Filter out annotations that aren't textStyles or links
+       for ( var i = 0; i < this.insertionAnnotations.length; i++ ) {
+               if ( !this.insertionAnnotations[i].type.match( 
/(textStyle\/|link\/)/ ) ) {
+                       this.insertionAnnotations.splice( i, 1 );
+                       i--;
+               }
+       }
+};
+
+ve.ce.Surface.prototype.removeInsertionAnnotation = function( annotation ) {
+       var index = ve.dm.DocumentNode.getIndexOfAnnotation( 
this.insertionAnnotations, annotation );
+       if ( index !== -1 ) {
+               this.insertionAnnotations.splice( index, 1 );
+       }
+};
+
+ve.ce.Surface.prototype.clearInsertionAnnotations = function() {
+       this.insertionAnnotations = [];
+};
+
 ve.ce.Surface.prototype.onCutCopy = function( e ) {
        var _this = this,
                sel = rangy.getSelection(),


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to