mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04: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
|
// This function is useful to get the caret position of the line as
|
||||||
// is represented by the browser
|
// is represented by the browser
|
||||||
exports.getPosition = () => {
|
exports.getPosition = () => {
|
||||||
let rect, line;
|
|
||||||
const range = getSelectionRange();
|
const range = getSelectionRange();
|
||||||
const isSelectionInsideTheEditor = range &&
|
if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null;
|
||||||
$(range.endContainer).closest('body')[0].id === 'innerdocbody';
|
let rect, line;
|
||||||
|
|
||||||
if (isSelectionInsideTheEditor) {
|
|
||||||
// when we have the caret in an empty line, e.g. a line with only a <br>,
|
// when we have the caret in an empty line, e.g. a line with only a <br>,
|
||||||
// getBoundingClientRect() returns all dimensions value as 0
|
// getBoundingClientRect() returns all dimensions value as 0
|
||||||
const selectionIsInTheBeginningOfLine = range.endOffset > 0;
|
const selectionIsInTheBeginningOfLine = range.endOffset > 0;
|
||||||
|
@ -34,7 +32,6 @@ exports.getPosition = () => {
|
||||||
clonedRange.detach();
|
clonedRange.detach();
|
||||||
shadowCaret.remove();
|
shadowCaret.remove();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue