-1

In my page have one textarea. The user is able to type a document in that textarea.

I used WYSIWYG text editor to formate the text, so the textarea is changed to an iframe on runtime.

So I cannot the get the value from the iframe, but I need the cursor line number and user high lighted text.

When user highlight the text the image has shown on end of the textarea.

I get it from text area [textarea link] but how can get the same from iframe

Community
  • 1
  • 1
Kartee
  • 11
  • 3

1 Answers1

0

The linum function counts the number of \n in the textarea:

function lineNum() {
    return doc.value.substr(0, doc.selectionStart).split("\n").length;
}

But in the WYSIWYG text editor, there is no new lines. If you switch, you can see all the html code in one line.

There is no simple way to know on which line the cursor is:

  • You can set useLineBreaks option as true, but it changes only the way the editor interprets the Enter key: with <br> or <p>.
  • a line can be truncate in case it is longer than the text area width without any information in the text.

I think you should rethink what you want, however, you can:

Community
  • 1
  • 1
Gaël Barbin
  • 3,769
  • 3
  • 25
  • 52