🐛 Fix problem with RTL texts

This commit is contained in:
alonso.torres 2022-05-11 15:53:27 +02:00
parent 20211101b7
commit fef69cb707
3 changed files with 15 additions and 16 deletions

View file

@ -21,27 +21,21 @@ goog.scope(function () {
return range.getClientRects();
}
self.parse_text_nodes = function(parent, direction, textNode) {
self.parse_text_nodes = function(parent, textNode) {
const content = textNode.textContent;
const textSize = content.length;
const rtl = direction === "rtl";
let from = 0;
let to = 0;
let current = "";
let result = [];
let prevRect = null;
while (to < textSize) {
const rects = getRangeRects(textNode, from, to + 1);
if (rects.length > 1) {
let position;
if (rtl) {
position = rects[1];
} else {
position = rects[0];
}
const position = prevRect;
result.push({
node: parent,
@ -53,6 +47,7 @@ goog.scope(function () {
current = "";
} else {
prevRect = rects[0];
current += content[to];
to = to + 1;
}