mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
tidy up: remove unused code in caretPosition.js
This commit is contained in:
parent
e5d6fed67c
commit
75b03e5a7d
1 changed files with 1 additions and 17 deletions
|
@ -4,7 +4,7 @@
|
||||||
// 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;
|
let line;
|
||||||
const range = getSelectionRange();
|
const range = getSelectionRange();
|
||||||
const isSelectionInsideTheEditor = range &&
|
const isSelectionInsideTheEditor = range &&
|
||||||
$(range.endContainer).closest('body')[0].id === 'innerdocbody';
|
$(range.endContainer).closest('body')[0].id === 'innerdocbody';
|
||||||
|
@ -18,22 +18,6 @@ exports.getPosition = () => {
|
||||||
line = getPositionOfElementOrSelection(clonedRange);
|
line = getPositionOfElementOrSelection(clonedRange);
|
||||||
clonedRange.detach();
|
clonedRange.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
if (rect.height === 0) {
|
|
||||||
const clonedRange = createSelectionRange(range);
|
|
||||||
|
|
||||||
// as we can't get the element height, we create a text node to get the dimensions
|
|
||||||
// on the position
|
|
||||||
const shadowCaret = $(document.createTextNode('|'));
|
|
||||||
clonedRange.insertNode(shadowCaret[0]);
|
|
||||||
clonedRange.selectNode(shadowCaret[0]);
|
|
||||||
|
|
||||||
line = getPositionOfElementOrSelection(clonedRange);
|
|
||||||
clonedRange.detach();
|
|
||||||
shadowCaret.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue