Seeking an Efficient Way to Find Node Children in Plate.js #3123
-
Hello Plate.js Community, I am working with an editor where multiple sentences are written, and I have a specific requirement related to text formatting and style. When placing the mouse cursor at a certain position within the text, I want to retrieve all the information about the character immediately following the cursor position. This is particularly important for cases where specific styles (such as font size or color) are applied to certain characters, and I need to retrieve this styling information later. For instance, if I place the cursor at the end of a sentence, I would like to obtain details about the first character of the next sentence, especially if I have previously applied specific styling to it. My question revolves around whether using Is there a recommended way to efficiently obtain this information using Plate.js utilities, or should I consider a different approach? Thank you for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Slate provides a number of utilities for working with offsets. For example, |
Beta Was this translation helpful? Give feedback.
Slate provides a number of utilities for working with offsets. For example,
getPointAfter(editor, editor.selection, { unit: 'character', distance: 1 })
returns a Point object (see Slate's docs) corresponding to one character after the end of the selection, orundefined
if no such point exists. You can then pass this point togetNodeLeaf
to get the data for the text node at that point.