mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 22:23:33 +01:00
caretPosition: Invert condition in getPosition()
for readability
This commit is contained in:
parent
773959ec57
commit
02fd0048bf
1 changed files with 22 additions and 25 deletions
|
@ -4,12 +4,10 @@
|
|||
// This function is useful to get the caret position of the line as
|
||||
// is represented by the browser
|
||||
exports.getPosition = () => {
|
||||
let rect, line;
|
||||
const range = getSelectionRange();
|
||||
const isSelectionInsideTheEditor = range &&
|
||||
$(range.endContainer).closest('body')[0].id === 'innerdocbody';
|
||||
if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null;
|
||||
let rect, line;
|
||||
|
||||
if (isSelectionInsideTheEditor) {
|
||||
// when we have the caret in an empty line, e.g. a line with only a <br>,
|
||||
// getBoundingClientRect() returns all dimensions value as 0
|
||||
const selectionIsInTheBeginningOfLine = range.endOffset > 0;
|
||||
|
@ -34,7 +32,6 @@ exports.getPosition = () => {
|
|||
clonedRange.detach();
|
||||
shadowCaret.remove();
|
||||
}
|
||||
}
|
||||
return line;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue