Merge "Keyboard shortcuts for bold and italic"

This commit is contained in:
Catrope 2012-06-21 02:09:28 +00:00 committed by Gerrit Code Review
commit ac835c2d69
2 changed files with 21 additions and 1 deletions

View file

@ -149,6 +149,26 @@ ve.ce.Surface.prototype.onKeyDown = function( e ) {
this.handleDelete( false );
e.preventDefault();
break;
// B
case 66:
if ( e.metaKey ) {
// Ctrl+B / Cmd+B, annotate with bold
var annotations = this.documentView.model.getAnnotationsFromRange( this.model.getSelection() ),
annotation = {"type":"textStyle/bold"};
this.model.annotate( annotations[ve.getHash(annotation)] ? 'clear' : 'set', annotation );
}
break;
// I
case 73:
if ( e.metaKey ) {
// Ctrl+I / Cmd+I, annotate with italic
var annotations = this.documentView.model.getAnnotationsFromRange( this.model.getSelection() ),
annotation = {"type":"textStyle/italic"};
this.model.annotate( annotations[ve.getHash(annotation)] ? 'clear' : 'set', annotation );
}
break;
default:
if ( this.poll.polling === false ) {
this.poll.polling = true;

View file

@ -101,7 +101,7 @@ ve.dm.Surface.prototype.annotate = function( method, annotation ) {
var tx = ve.dm.Transaction.newFromAnnotation(
this.getDocument(), selection, method, annotation
);
this.change( tx );
this.change( tx, selection );
}
};