0

Sommeone please tell on how to get get cursor position in lightning input rich text in lightning web component.

I am using the following code but getting undefined:

let element = this.template.querySelector("lightning-input-rich-text");
console.log(element.selectionStart, element.selectionEnd);
  • Please, check the online documentation first: https://developer.salesforce.com/docs/component-library/bundle/lightning-formatted-rich-text/specification a lightning-input-rich-text does not have any of the queried properties. – Xypron Sep 15 '20 at 15:01

1 Answers1

0

I wouldn't call it a complete solution.

Use "window.getSelection()" to get the selection indexes, however you might want to ensure the rich text was in focus when selection occurred.

the specified method will return a Selection object, anchorOffset & extentOffset properties will contain the start and end indexes.