diff --git a/modules/ve/ce/ve.ce.js b/modules/ve/ce/ve.ce.js index f3dd582057..ab6644ccce 100644 --- a/modules/ve/ce/ve.ce.js +++ b/modules/ve/ce/ve.ce.js @@ -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 ); +}; \ No newline at end of file