How to select text/node inside block programmatically? #13976
Labels
[Feature] Rich Text
Related to the Rich Text component that allows developers to render a contenteditable
[Type] Enhancement
A suggestion for improvement.
I'm looking for any alternative to TinyMCE's editor.selection.select() functionality or any other way to select DOM node or text by it's position in the document.
In my case: I have a plugin, which shows all links from the article's content in the sidebar panel.
When I click on any of those links, I want it to be selected (highlighted) in the editor.
The problem is, I can't find any documentation about selection functionality in Gutenberg, and standart
window.getSelection/addRange isn't working as expected (it works once, but then there is no way to remove selection - .removeRange / .removeAllRanges or addRange(someNewRange) make no effect when another link clicked in the sidebar).
What is the best way to find a piece of text or DOM node (by selector), which could be in any block and then select it (not a whole block, only particular text/node)?
The text was updated successfully, but these errors were encountered: