mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
caretPosition: Delete unused var in getPosition()
This commit is contained in:
parent
02fd0048bf
commit
5e731dfbfd
1 changed files with 10 additions and 12 deletions
|
@ -6,7 +6,7 @@
|
||||||
exports.getPosition = () => {
|
exports.getPosition = () => {
|
||||||
const range = getSelectionRange();
|
const range = getSelectionRange();
|
||||||
if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null;
|
if (!range || $(range.endContainer).closest('body')[0].id !== 'innerdocbody') return null;
|
||||||
let rect, line;
|
let line;
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -19,19 +19,17 @@ exports.getPosition = () => {
|
||||||
|
|
||||||
// when there's a <br> or any element that has no height, we can't get
|
// when there's a <br> or any element that has no height, we can't get
|
||||||
// the dimension of the element where the caret is
|
// the dimension of the element where the caret is
|
||||||
if (!rect || rect.height === 0) {
|
const clonedRange = createSelectionRange(range);
|
||||||
const clonedRange = createSelectionRange(range);
|
|
||||||
|
|
||||||
// as we can't get the element height, we create a text node to get the dimensions
|
// as we can't get the element height, we create a text node to get the dimensions
|
||||||
// on the position
|
// on the position
|
||||||
const shadowCaret = $(document.createTextNode('|'));
|
const shadowCaret = $(document.createTextNode('|'));
|
||||||
clonedRange.insertNode(shadowCaret[0]);
|
clonedRange.insertNode(shadowCaret[0]);
|
||||||
clonedRange.selectNode(shadowCaret[0]);
|
clonedRange.selectNode(shadowCaret[0]);
|
||||||
|
|
||||||
line = getPositionOfElementOrSelection(clonedRange);
|
line = getPositionOfElementOrSelection(clonedRange);
|
||||||
clonedRange.detach();
|
clonedRange.detach();
|
||||||
shadowCaret.remove();
|
shadowCaret.remove();
|
||||||
}
|
|
||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue