mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
caretPosition: Clarify comment in getPosition()
This commit is contained in:
parent
91955609af
commit
1908bedabe
1 changed files with 3 additions and 7 deletions
|
@ -6,17 +6,13 @@
|
||||||
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;
|
||||||
|
// When there's a <br> or any element that has no height, we can't get the dimension of the
|
||||||
// when there's a <br> or any element that has no height, we can't get
|
// element where the caret is. As we can't get the element height, we create a text node to get
|
||||||
// the dimension of the element where the caret is
|
// the dimensions on the position.
|
||||||
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
|
|
||||||
// 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]);
|
||||||
|
|
||||||
const line = getPositionOfElementOrSelection(clonedRange);
|
const line = getPositionOfElementOrSelection(clonedRange);
|
||||||
shadowCaret.remove();
|
shadowCaret.remove();
|
||||||
return line;
|
return line;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue