mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Merge "Aggressive keyboard shortcut fix for all browsers and platforms"
This commit is contained in:
commit
f35c8adac8
|
@ -196,9 +196,9 @@ ve.ce.Surface.prototype.onKeyDown = function( e ) {
|
||||||
break;
|
break;
|
||||||
// B
|
// B
|
||||||
case 66:
|
case 66:
|
||||||
if ( e.metaKey ) {
|
if ( ve.ce.Surface.isShortcutKey( e ) ) {
|
||||||
e.preventDefault();
|
|
||||||
// Ctrl+B / Cmd+B, annotate with bold
|
// Ctrl+B / Cmd+B, annotate with bold
|
||||||
|
e.preventDefault();
|
||||||
var annotations = this.documentView.model.getAnnotationsFromRange( this.model.getSelection() ),
|
var annotations = this.documentView.model.getAnnotationsFromRange( this.model.getSelection() ),
|
||||||
annotation = {"type":"textStyle/bold"};
|
annotation = {"type":"textStyle/bold"};
|
||||||
|
|
||||||
|
@ -207,13 +207,13 @@ ve.ce.Surface.prototype.onKeyDown = function( e ) {
|
||||||
break;
|
break;
|
||||||
// I
|
// I
|
||||||
case 73:
|
case 73:
|
||||||
if ( e.metaKey ) {
|
if ( ve.ce.Surface.isShortcutKey( e ) ) {
|
||||||
// Ctrl+I / Cmd+I, annotate with italic
|
// Ctrl+I / Cmd+I, annotate with italic
|
||||||
|
e.preventDefault();
|
||||||
var annotations = this.documentView.model.getAnnotationsFromRange( this.model.getSelection() ),
|
var annotations = this.documentView.model.getAnnotationsFromRange( this.model.getSelection() ),
|
||||||
annotation = {"type":"textStyle/italic"};
|
annotation = {"type":"textStyle/italic"};
|
||||||
|
|
||||||
this.model.annotate( annotations[ve.getHash(annotation)] ? 'clear' : 'set', annotation );
|
this.model.annotate( annotations[ve.getHash(annotation)] ? 'clear' : 'set', annotation );
|
||||||
e.preventDefault();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -312,7 +312,7 @@ ve.ce.Surface.prototype.onPaste = function( e ) {
|
||||||
ve.ce.Surface.prototype.onKeyPress = function( e ) {
|
ve.ce.Surface.prototype.onKeyPress = function( e ) {
|
||||||
ve.log('onKeyPress');
|
ve.log('onKeyPress');
|
||||||
|
|
||||||
if (e.metaKey) {
|
if ( ve.ce.Surface.isShortcutKey( e ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1069,6 +1069,14 @@ ve.ce.Surface.prototype.getSelectionRect = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Tests if the modifier key for keyboard shortcuts is pressed. */
|
||||||
|
ve.ce.Surface.isShortcutKey = function( e ) {
|
||||||
|
if ( e.ctrlKey || e.metaKey ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
ve.ce.Surface.prototype.getModel = function() {
|
ve.ce.Surface.prototype.getModel = function() {
|
||||||
return this.model;
|
return this.model;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue