mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
re: AnnotationSet, annotationButtonTool properly clears annotation.
Surface model annotate method previously cleared basic tool annotation objects. Now that bold and other annotations have htmlAttributes from parsoid, we must gather annotations by type from selection and iterate through to properly clear. Change-Id: Id53bf5733078524ae5aac376e01b9679eb8c32df
This commit is contained in:
parent
db2c44ef2d
commit
7be9f92de7
|
@ -35,13 +35,30 @@ ve.inheritClass( ve.ui.AnnotationButtonTool, ve.ui.ButtonTool );
|
|||
ve.ui.AnnotationButtonTool.prototype.onClick = function () {
|
||||
var surfaceView = this.toolbar.getSurfaceView(),
|
||||
surfaceModel = surfaceView.model,
|
||||
selection = surfaceModel.getSelection();
|
||||
documentModel = surfaceModel.getDocument(),
|
||||
selection = surfaceModel.getSelection(),
|
||||
annotations,
|
||||
i;
|
||||
|
||||
if ( this.inspector ) {
|
||||
if ( selection && selection.getLength() ) {
|
||||
surfaceView.contextView.openInspector( this.inspector );
|
||||
}
|
||||
} else {
|
||||
surfaceModel.annotate( this.active ? 'clear' : 'set', this.annotation );
|
||||
if ( this.active ) {
|
||||
// Get all annotations by type.
|
||||
annotations = documentModel
|
||||
.getAnnotationsFromRange( surfaceModel.getSelection() )
|
||||
.getAnnotationsOfType( this.annotation.type )
|
||||
.get();
|
||||
// Clear each selected annotation.
|
||||
for( i = 0; i < annotations.length; i++ ) {
|
||||
surfaceModel.annotate( 'clear', annotations[i] );
|
||||
}
|
||||
} else {
|
||||
// Set annotation.
|
||||
surfaceModel.annotate( 'set', this.annotation );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue