mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Keyboard shortcuts for bold and italic
Change-Id: I12b80134152bbbbd2dfa42b32fec072cde29baa5
This commit is contained in:
parent
e4ada5296a
commit
14054becb5
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue