mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Merge "Keyboard shortcuts for bold and italic"
This commit is contained in:
commit
ac835c2d69
|
@ -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;
|
||||
|
|
|
@ -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