Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/72133
Change subject: Make all annotations additive
......................................................................
Make all annotations additive
Any annotation could have a style attribute which has
a compound effect, and this also prevents roundtrip
errors. Button tool logic prevents any annotation being
applied which shouldn't be.
Bug: 49755
Change-Id: I8502a55cd2b195d28d0e2ecd63f15de670f80d60
---
M modules/ve/dm/annotations/ve.dm.TextStyleAnnotation.js
M modules/ve/dm/ve.dm.Annotation.js
M modules/ve/dm/ve.dm.AnnotationSet.js
M modules/ve/test/dm/ve.dm.example.js
4 files changed, 6 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/33/72133/1
diff --git a/modules/ve/dm/annotations/ve.dm.TextStyleAnnotation.js
b/modules/ve/dm/annotations/ve.dm.TextStyleAnnotation.js
index e94e19a..67d22ba 100644
--- a/modules/ve/dm/annotations/ve.dm.TextStyleAnnotation.js
+++ b/modules/ve/dm/annotations/ve.dm.TextStyleAnnotation.js
@@ -157,7 +157,6 @@
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.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.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.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 );
diff --git a/modules/ve/dm/ve.dm.Annotation.js
b/modules/ve/dm/ve.dm.Annotation.js
index c2d220d..305b3a9 100644
--- a/modules/ve/dm/ve.dm.Annotation.js
+++ b/modules/ve/dm/ve.dm.Annotation.js
@@ -33,15 +33,6 @@
/* 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.
*
* @static
diff --git a/modules/ve/dm/ve.dm.AnnotationSet.js
b/modules/ve/dm/ve.dm.AnnotationSet.js
index 80d2440..0a7eb79 100644
--- a/modules/ve/dm/ve.dm.AnnotationSet.js
+++ b/modules/ve/dm/ve.dm.AnnotationSet.js
@@ -359,16 +359,12 @@
/**
* 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 );
};
/**
diff --git a/modules/ve/test/dm/ve.dm.example.js
b/modules/ve/test/dm/ve.dm.example.js
index a76c441..2d68a12 100644
--- a/modules/ve/test/dm/ve.dm.example.js
+++ b/modules/ve/test/dm/ve.dm.example.js
@@ -868,18 +868,21 @@
]
},
'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' },
--
To view, visit https://gerrit.wikimedia.org/r/72133
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8502a55cd2b195d28d0e2ecd63f15de670f80d60
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits