get my pointer focused on a specific position on lexical

72 Views Asked by At

I am using a lexical editor and I want a way to make my pointer appear at specific position in text editor

I was trying this but not working

I store the current pointer position and then I try to update it

  const selection:any = $getSelection();
  let keyVal = selection.focus.key;
  let offsetVal = selection.focus.offset;
  const nodeSelection = $createNodeSelection(
     {
     root: document.getElementById('root'),
     selector: `node[key=${keyVal}]`,
     offset: (x: any, y: any) => {
       return {
         x: x + offsetVal,
         y,
       };
     },
   });
  $setSelection(nodeSelection); 
0

There are 0 best solutions below