mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 23:40:35 -05:00
Override page up/down to match expected platform behaviour.
This commit is contained in:
parent
de7d7011a7
commit
4f010a5de0
3 changed files with 38 additions and 10 deletions
|
@ -1142,6 +1142,8 @@ var keys = {
|
||||||
9: 'tab',
|
9: 'tab',
|
||||||
13: 'enter',
|
13: 'enter',
|
||||||
32: 'space',
|
32: 'space',
|
||||||
|
33: 'pageup',
|
||||||
|
34: 'pagedown',
|
||||||
37: 'left',
|
37: 'left',
|
||||||
39: 'right',
|
39: 'right',
|
||||||
46: 'delete',
|
46: 'delete',
|
||||||
|
@ -1565,6 +1567,18 @@ if ( isMac && isGecko && win.getSelection().modify ) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// System standard for page up/down on Mac is to just scroll, not move the
|
||||||
|
// cursor. On Linux/Windows, it should move the cursor, but some browsers don't
|
||||||
|
// implement this natively. Override to support it.
|
||||||
|
if ( !isMac ) {
|
||||||
|
keyHandlers.pageup = function ( self ) {
|
||||||
|
self.moveCursorToStart();
|
||||||
|
};
|
||||||
|
keyHandlers.pagedown = function ( self ) {
|
||||||
|
self.moveCursorToEnd();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
keyHandlers[ ctrlKey + 'b' ] = mapKeyToFormat( 'B' );
|
keyHandlers[ ctrlKey + 'b' ] = mapKeyToFormat( 'B' );
|
||||||
keyHandlers[ ctrlKey + 'i' ] = mapKeyToFormat( 'I' );
|
keyHandlers[ ctrlKey + 'i' ] = mapKeyToFormat( 'I' );
|
||||||
keyHandlers[ ctrlKey + 'u' ] = mapKeyToFormat( 'U' );
|
keyHandlers[ ctrlKey + 'u' ] = mapKeyToFormat( 'U' );
|
||||||
|
@ -3837,15 +3851,15 @@ proto.removeList = command( 'modifyBlocks', removeList );
|
||||||
proto.increaseListLevel = command( 'modifyBlocks', increaseListLevel );
|
proto.increaseListLevel = command( 'modifyBlocks', increaseListLevel );
|
||||||
proto.decreaseListLevel = command( 'modifyBlocks', decreaseListLevel );
|
proto.decreaseListLevel = command( 'modifyBlocks', decreaseListLevel );
|
||||||
|
|
||||||
|
if ( typeof exports === 'object' ) {
|
||||||
|
module.exports = Squire;
|
||||||
|
} else {
|
||||||
if ( top !== win ) {
|
if ( top !== win ) {
|
||||||
win.editor = new Squire( doc );
|
win.editor = new Squire( doc );
|
||||||
if ( win.onEditorLoad ) {
|
if ( win.onEditorLoad ) {
|
||||||
win.onEditorLoad( win.editor );
|
win.onEditorLoad( win.editor );
|
||||||
win.onEditorLoad = null;
|
win.onEditorLoad = null;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if ( typeof exports === 'object' ) {
|
|
||||||
module.exports = Squire;
|
|
||||||
} else {
|
} else {
|
||||||
win.Squire = Squire;
|
win.Squire = Squire;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5,6 +5,8 @@ var keys = {
|
||||||
9: 'tab',
|
9: 'tab',
|
||||||
13: 'enter',
|
13: 'enter',
|
||||||
32: 'space',
|
32: 'space',
|
||||||
|
33: 'pageup',
|
||||||
|
34: 'pagedown',
|
||||||
37: 'left',
|
37: 'left',
|
||||||
39: 'right',
|
39: 'right',
|
||||||
46: 'delete',
|
46: 'delete',
|
||||||
|
@ -428,6 +430,18 @@ if ( isMac && isGecko && win.getSelection().modify ) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// System standard for page up/down on Mac is to just scroll, not move the
|
||||||
|
// cursor. On Linux/Windows, it should move the cursor, but some browsers don't
|
||||||
|
// implement this natively. Override to support it.
|
||||||
|
if ( !isMac ) {
|
||||||
|
keyHandlers.pageup = function ( self ) {
|
||||||
|
self.moveCursorToStart();
|
||||||
|
};
|
||||||
|
keyHandlers.pagedown = function ( self ) {
|
||||||
|
self.moveCursorToEnd();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
keyHandlers[ ctrlKey + 'b' ] = mapKeyToFormat( 'B' );
|
keyHandlers[ ctrlKey + 'b' ] = mapKeyToFormat( 'B' );
|
||||||
keyHandlers[ ctrlKey + 'i' ] = mapKeyToFormat( 'I' );
|
keyHandlers[ ctrlKey + 'i' ] = mapKeyToFormat( 'I' );
|
||||||
keyHandlers[ ctrlKey + 'u' ] = mapKeyToFormat( 'U' );
|
keyHandlers[ ctrlKey + 'u' ] = mapKeyToFormat( 'U' );
|
||||||
|
|
Loading…
Reference in a new issue