From 75b03e5a7dc1ff9a8728ed2341fd9fe970d0615f Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 21 Feb 2021 19:24:54 +0000 Subject: [PATCH] tidy up: remove unused code in caretPosition.js --- src/static/js/caretPosition.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/static/js/caretPosition.js b/src/static/js/caretPosition.js index a217765da..014ea50a8 100644 --- a/src/static/js/caretPosition.js +++ b/src/static/js/caretPosition.js @@ -4,7 +4,7 @@ // This function is useful to get the caret position of the line as // is represented by the browser exports.getPosition = () => { - let rect, line; + let line; const range = getSelectionRange(); const isSelectionInsideTheEditor = range && $(range.endContainer).closest('body')[0].id === 'innerdocbody'; @@ -18,22 +18,6 @@ exports.getPosition = () => { line = getPositionOfElementOrSelection(clonedRange); clonedRange.detach(); } - - // when there's a
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; };