Keyboard shortcuts for bold and italic

Change-Id: I12b80134152bbbbd2dfa42b32fec072cde29baa5
This commit is contained in:
Christian Williams 2012-06-20 18:28:00 -07:00 committed by Catrope
parent e4ada5296a
commit 14054becb5
2 changed files with 21 additions and 1 deletions

View file

@ -134,6 +134,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 );
}
};