From a0529cc4bd2e787e248d3ad4863a47df6a258d55 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Fri, 11 Nov 2016 14:21:41 +0330 Subject: [PATCH] fix text selection and cursor position in lines with rtl text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit assume a line contain both english text and persian (rtl) text, like this ``` Sample Text متن نمونه sample text ``` atom always look at first rect size of Text Element and calculate position, this cause cursor to place in wrong position in our example `Range.getClientRects()` return three rects, look at this pen http://codepen.io/farnabaz/pen/rWxrGW --- src/lines-yardstick.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lines-yardstick.coffee b/src/lines-yardstick.coffee index d4979865c..6c42a2f3e 100644 --- a/src/lines-yardstick.coffee +++ b/src/lines-yardstick.coffee @@ -126,4 +126,4 @@ class LinesYardstick clientRectForRange: (textNode, startIndex, endIndex) -> @rangeForMeasurement.setStart(textNode, startIndex) @rangeForMeasurement.setEnd(textNode, endIndex) - @rangeForMeasurement.getClientRects()[0] ? @rangeForMeasurement.getBoundingClientRect() + @rangeForMeasurement.getBoundingClientRect()