r113279 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113278‎ | r113279 | r113280 >
Date:19:37, 7 March 2012
Author:rmoen
Status:deferred
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js
@@ -22,6 +22,7 @@
2323 this.$ = $container
2424 .addClass( 'es-surfaceView' )
2525 .append( this.documentView.$ );
 26+ this.insertionAnnotations = [];
2627 this.emitUpdateTimeout = undefined;
2728 this.clipboard = {};
2829 this.autoRender = false;
@@ -100,6 +101,7 @@
101102 this.autoRender = true;
102103 this.model.transact( tx );
103104 this.autoRender = false;
 105+ //TODO: Redraw selection
104106
105107 } else {
106108 if ( method === 'set' ) {
@@ -110,10 +112,47 @@
111113 }
112114 };
113115
114 -ve.ce.Surface.prototype.renderDomNode = function ( node ) {
115 - this.getLeafNode( node ).data( 'view' ).renderContent();
 116+ve.ce.Surface.prototype.getAnnotations = function() {
 117+ return this.getSelection().getLength() ?
 118+ this.model.getDocument().getAnnotationsFromRange( this.getSelection() ) :
 119+ {
 120+ 'full': this.insertionAnnotations,
 121+ 'partial': [],
 122+ 'all': this.insertionAnnotations
 123+ };
116124 };
117125
 126+ve.ce.Surface.prototype.getInsertionAnnotations = function() {
 127+ return this.insertionAnnotations;
 128+};
 129+
 130+ve.ce.Surface.prototype.addInsertionAnnotation = function( annotation ) {
 131+ this.insertionAnnotations.push( annotation );
 132+};
 133+
 134+ve.ce.Surface.prototype.loadInsertionAnnotations = function( annotation ) {
 135+ this.insertionAnnotations =
 136+ this.model.getDocument().getAnnotationsFromOffset( this.getSelection().to - 1 );
 137+ // Filter out annotations that aren't textStyles or links
 138+ for ( var i = 0; i < this.insertionAnnotations.length; i++ ) {
 139+ if ( !this.insertionAnnotations[i].type.match( /(textStyle\/|link\/)/ ) ) {
 140+ this.insertionAnnotations.splice( i, 1 );
 141+ i--;
 142+ }
 143+ }
 144+};
 145+
 146+ve.ce.Surface.prototype.removeInsertionAnnotation = function( annotation ) {
 147+ var index = ve.dm.DocumentNode.getIndexOfAnnotation( this.insertionAnnotations, annotation );
 148+ if ( index !== -1 ) {
 149+ this.insertionAnnotations.splice( index, 1 );
 150+ }
 151+};
 152+
 153+ve.ce.Surface.prototype.clearInsertionAnnotations = function() {
 154+ this.insertionAnnotations = [];
 155+};
 156+
118157 ve.ce.Surface.prototype.onCutCopy = function( e ) {
119158 var _this = this,
120159 sel = rangy.getSelection(),

Status & tagging log