mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
Introduce helper functions.
* ve.ce.isLeftOrRightArrowKey * ve.ce.isUpOrDownArrowKey * ve.ce.isArrowKey Change-Id: Id9fd7975e98085d01e545d1d0fc6086a06648031
This commit is contained in:
parent
c8819742eb
commit
5b9964878d
|
@ -211,7 +211,7 @@ ve.ce.getOffsetFromElementNode = function ( domNode, domOffset, addOuterLength )
|
|||
if ( addOuterLength === true ) {
|
||||
return nodeModel.getOffset() + nodeModel.getOuterLength();
|
||||
} else {
|
||||
return nodeModel.getOffset();
|
||||
return nodeModel.getOffset() + (nodeModel.isWrapped() ? 1 : 0);
|
||||
}
|
||||
} else {
|
||||
node = $domNode.contents().last()[0];
|
||||
|
@ -247,3 +247,15 @@ ve.ce.getOffsetOfSlug = function ( $node ) {
|
|||
throw new Error( 'Incorrect slug location' );
|
||||
}
|
||||
};
|
||||
|
||||
ve.ce.isLeftOrRightArrowKey = function ( keyCode ) {
|
||||
return keyCode === ve.Keys.DOM_VK_LEFT || keyCode === ve.Keys.DOM_VK_RIGHT;
|
||||
};
|
||||
|
||||
ve.ce.isUpOrDownArrowKey = function ( keyCode ) {
|
||||
return keyCode === ve.Keys.DOM_VK_UP || keyCode === ve.Keys.DOM_VK_DOWN;
|
||||
};
|
||||
|
||||
ve.ce.isArrowKey = function ( keyCode ) {
|
||||
return ve.ce.isLeftOrRightArrowKey( keyCode ) || ve.ce.isUpOrDownArrowKey( keyCode );
|
||||
};
|
Loading…
Reference in a new issue