Cursor Location Problems

I am trying to understand how selection and cursor position works. My goal is to go to a table cell and append text to the existing content of the cell.

When trying to determine how to position the cursor (set the selection) I have found two different Heirarchical indexes for the cursor position One that looks like: "

"0;18;3;1;1;6" where the numbers refer to sectionId, "blockId", tableRowId; tableColumnId; CellBlockId, offset


but if I get the offset by calling getHeirarchicalIndex or getIndex() I get indexes that look like:

"1;0;7;3;1;1;0;6" where 1;0;7 seems to correspond to 0;18 and 1;0;6 seems to correspond with 1;6
The second index is easier to retrieve from the Widget elements, but this index cannot be used to set the selection.  

Is there some documentation on how to convert the two indexes?

Is there a simple way to get the heirarchical index of the last character in a table cell?

Alternatively is there another way to set the selection?

Also I am unclear on how to get the section Id (ie the zero before 18 in the above indexes)


1 Reply

DS Dhanush Sekar Syncfusion Team January 6, 2025 01:00 PM UTC

Hi Bill,


It is advised not to use the internal APIs of the Document editor. Instead, you may utilize the selection start and end offsets to determine and adjust the cursor position.

Move selection to specific position in React Document editor component | Syncfusion

##Is there some documentation on how to convert the two indexes?

Please refer the below documentation for more information

Move selection to specific position in React Document editor component | Syncfusion

##Is there a simple way to get the heirarchical index of the last character in a table cell?

You can select the table cell using selectCell method and get the selection end offset

Selection API in React DocumentEditor API component - Syncfusion

##Alternatively is there another way to set the selection?

You can use Document editor select API to set the selection

// Selection will occur between provided start and end offset
this.documentEdContainerIns.documentEditor.editor.insertText("Welcome");
// The below code will select the letters “We” from inserted text “Welcome”
this.documentEdContainerIns.documentEditor.selection.select("0;0;0", "0;0;2");


Regards,

Dhanush S


Loader.
Up arrow icon