Stored Range Selection Offsets Not Updating After Editor Content Changes #6653
Unanswered
manufac-kbhatia
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Lexical Community,
I am developing a custom plugin for my editor, built on top of Lexical, where I need to store the ranges of text selections made in the editor. My goal is to be able to access the
startOffset
andendOffset
of each stored RangeSelections at any given time. However, when changes occur in the editor, and I try to retrieve the updatedstartOffset
andendOffset
for the storedRangeSelections
, these values are not updating as expected.In a typical JavaScript environment (vanilla JS), when I use getSelection to capture selection ranges and store them in an array, these stored ranges act as memory references. As the document content changes, the browser automatically updates these references, allowing me to consistently retrieve the updated
startOffset
andendOffset
for each range.However, when trying to achieve the same behavior with Lexical’s getSelection (rangeSelection), the stored
RangeSelection
doesn’t automatically update when the editor’s content changes. It seems Lexical is not updating the RangeSelection in the same way that the nativegetSelection
in the browser does.Beta Was this translation helpful? Give feedback.
All reactions