Merge "Make all annotations additive"

This commit is contained in:
jenkins-bot 2013-07-08 19:51:56 +00:00 committed by Gerrit Code Review
commit c328e3deff
5 changed files with 7 additions and 23 deletions

View file

@ -157,7 +157,6 @@ ve.dm.TextStyleSmallAnnotation = function VeDmTextStyleSmallAnnotation( element
ve.inheritClass( ve.dm.TextStyleSmallAnnotation, ve.dm.TextStyleAnnotation );
ve.dm.TextStyleSmallAnnotation.static.name = 'textStyle/small';
ve.dm.TextStyleSmallAnnotation.static.matchTagNames = ['small'];
ve.dm.TextStyleSmallAnnotation.static.isAdditive = true;
ve.dm.modelRegistry.register( ve.dm.TextStyleSmallAnnotation );
/**
@ -174,7 +173,6 @@ ve.dm.TextStyleBigAnnotation = function VeDmTextStyleBigAnnotation( element ) {
ve.inheritClass( ve.dm.TextStyleBigAnnotation, ve.dm.TextStyleAnnotation );
ve.dm.TextStyleBigAnnotation.static.name = 'textStyle/big';
ve.dm.TextStyleBigAnnotation.static.matchTagNames = ['big'];
ve.dm.TextStyleBigAnnotation.static.isAdditive = true;
ve.dm.modelRegistry.register( ve.dm.TextStyleBigAnnotation );
/**
@ -239,7 +237,6 @@ ve.dm.TextStyleSuperScriptAnnotation = function VeDmTextStyleSuperScriptAnnotati
ve.inheritClass( ve.dm.TextStyleSuperScriptAnnotation, ve.dm.TextStyleAnnotation );
ve.dm.TextStyleSuperScriptAnnotation.static.name = 'textStyle/superScript';
ve.dm.TextStyleSuperScriptAnnotation.static.matchTagNames = ['sup'];
ve.dm.TextStyleSuperScriptAnnotation.static.isAdditive = true;
ve.dm.modelRegistry.register( ve.dm.TextStyleSuperScriptAnnotation );
/**
@ -256,5 +253,4 @@ ve.dm.TextStyleSubScriptAnnotation = function VeDmTextStyleSubScriptAnnotation(
ve.inheritClass( ve.dm.TextStyleSubScriptAnnotation, ve.dm.TextStyleAnnotation );
ve.dm.TextStyleSubScriptAnnotation.static.name = 'textStyle/subScript';
ve.dm.TextStyleSubScriptAnnotation.static.matchTagNames = ['sub'];
ve.dm.TextStyleSubScriptAnnotation.static.isAdditive = true;
ve.dm.modelRegistry.register( ve.dm.TextStyleSubScriptAnnotation );

View file

@ -32,15 +32,6 @@ ve.inheritClass( ve.dm.Annotation, ve.dm.Model );
/* Static properties */
/**
* Allow annotation to be applied additively, e.g. <big><big>Foo</big></big>
*
* @static
* @type {boolean}
* @inheritable
*/
ve.dm.Annotation.static.isAdditive = false;
/**
* About grouping is not supported for annotations; setting this to true has no effect.
*

View file

@ -359,16 +359,12 @@ ve.dm.AnnotationSet.prototype.addSet = function ( set ) {
/**
* Add an annotation at the end of the set.
*
* If the annotation is already present in the set, nothing happens.
*
* @method
* @param {ve.dm.Annotation} annotation Annotation to add
*/
ve.dm.AnnotationSet.prototype.push = function ( annotation ) {
var storeIndex = this.getStore().index( annotation );
if ( annotation.constructor.static.isAdditive || !this.containsIndex( storeIndex ) ) {
this.storeIndexes.push( storeIndex );
}
this.storeIndexes.push( storeIndex );
};
/**

View file

@ -9,7 +9,7 @@ QUnit.module( 've.dm.AnnotationSet' );
/* Tests */
QUnit.test( 'Basic usage', 33, function ( assert ) {
QUnit.test( 'Basic usage', 32, function ( assert ) {
var annotationSet3,
store = new ve.dm.IndexValueStore(),
bold = new ve.dm.TextStyleBoldAnnotation(),
@ -59,8 +59,6 @@ QUnit.test( 'Basic usage', 33, function ( assert ) {
annotationSet2.push( bold );
annotationSet2.push( italic );
assert.deepEqual( annotationSet2.get(), [bold, italic], 'set2 contains bold then italic after two pushes' );
annotationSet2.push( italic );
assert.deepEqual( annotationSet2.getLength(), 2, 'pushing existing annotation doesn\'t change length' );
annotationSet2 = new ve.dm.AnnotationSet( store, store.indexes( [ italic, underline ] ) );
annotationSet2.removeNotInSet( annotationSet );

View file

@ -868,18 +868,21 @@ ve.dm.example.domToDataCases = {
]
},
'additive annotations': {
'html': '<body><p><big>a<big>b</big>c</big></p></body>',
'html': '<body><p><big>a<big>b</big>c</big><b>d<b>e</b>f</b></p></body>',
'data': [
{ 'type': 'paragraph' },
['a', [ ve.dm.example.big ]],
['b', [ ve.dm.example.big, ve.dm.example.big ]],
['c', [ ve.dm.example.big ]],
['d', [ ve.dm.example.bold ]],
['e', [ ve.dm.example.bold, ve.dm.example.bold ]],
['f', [ ve.dm.example.bold ]],
{ 'type': '/paragraph' },
{ 'type': 'internalList' },
{ 'type': '/internalList' }
]
},
'additive annotations overlapping basic annotations': {
'additive annotations overlapping other annotations': {
'html': '<body><p><i><big>a<big><b>b</b></big><b>c</b></big></i></p></body>',
'data': [
{ 'type': 'paragraph' },