QML TextArea/TexteEdit map the index of string from formatted to basic form
-
in QML TextEdit or TextArea, we can format or style a text either HTML or Markdown, the non formatted text can be accesed by TextArea.text but the formatted text can be accessed by getFormattedText().
I want to know how to get which index in the non formatted text is equivalent for the formatted text, this is important when say, If I select a text in the formatted view, i want to change its markdown in the non formatted view. There seems to not have a method for this.
example, in formatted view a string with "1\n2\n3\n4" which means every line there is a text, is equivalent to "1\n\n2\n\n3\n\n" or a bold text like in formatted "text" is equivalent to "text" in non formatted.
So if i have a string "the quick brown fox" where the word "quick" is bold, it is represented in the non formated text (TextArea.text) as "the quick brown fox", now the string index of fox is
index 16 in the formatted text but it is index 20 in the non formatted text.Is there an efficient way to access this?
Any idea or suggestion?