Opened 16 years ago

Closed 16 years ago

#1845 closed Task (duplicate)

Maintaining Cursor positioning in text area while switching views.

Reported by: Leonardo Owned by:
Priority: Normal Milestone:
Component: UI : Source View Version:
Keywords: Discussion Cc:

Description

I have an implementation that allows for webpage editing using WYSIWYG. When the view is switched to "Source" the cursor is positioned to the beginning of the page forcing the user to manually scroll to the area of interest.

I would like to have the cursor position maintained eliminating the nuance of manually scrolling. For this I need a pointer to the element that holds the editor text.

See the following code to obtain the cursor position on IE:

<HTML>

<HEAD>
<SCRIPT LANGUAGE="JScript">
function saveCaret(elem)
{
  if ( elem.isTextEdit ) 
    elem.caretPos = document.selection.createRange();
}
function getCaretPos(elem)
{
  if ( elem.isTextEdit && elem.caretPos )
  {
    var bookmark = "~";
    var orig = elem.value;
    var caretPos = elem.caretPos;
    caretPos.text = bookmark;
    var i = elem.value.search( bookmark );
    window.status = "Caret is at character " + i;
    elem.value = orig;
  }
}
</SCRIPT>
</HEAD>

<BODY>
<INPUT NAME="txtInput" ONSELECT="saveCaret(this)" 
   ONCLICK="saveCaret(this)" ONKEYUP="saveCaret(this)" VALUE="Where are you?">
<INPUT TYPE="button" VALUE="caret pos" ONCLICK="getCaretPos(txtInput)">

</BODY>
</HTML>

Can anyone tell me how to get a handle of the element that has the text in the Editor?

Change History (2)

comment:1 Changed 16 years ago by Wojciech Olchawa

Keywords: Discussion added

It's a matter I think we need to discuss. I'm opening a discussion for it.

comment:2 Changed 16 years ago by Frederico Caldeira Knabben

Resolution: duplicate
Status: newclosed

DUP of #385

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy