mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 09:09:25 +00:00
Merge "Introduce helper functions."
This commit is contained in:
commit
f34407b31a
|
@ -211,7 +211,7 @@ ve.ce.getOffsetFromElementNode = function ( domNode, domOffset, addOuterLength )
|
||||||
if ( addOuterLength === true ) {
|
if ( addOuterLength === true ) {
|
||||||
return nodeModel.getOffset() + nodeModel.getOuterLength();
|
return nodeModel.getOffset() + nodeModel.getOuterLength();
|
||||||
} else {
|
} else {
|
||||||
return nodeModel.getOffset();
|
return nodeModel.getOffset() + (nodeModel.isWrapped() ? 1 : 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
node = $domNode.contents().last()[0];
|
node = $domNode.contents().last()[0];
|
||||||
|
@ -247,3 +247,15 @@ ve.ce.getOffsetOfSlug = function ( $node ) {
|
||||||
throw new Error( 'Incorrect slug location' );
|
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