Unable to select link component without clicking on canvas in richtexteditor
I found the method which works for me 👍 editor.getSelected().view.syncContent(); Thanks
Read full answer below ↓Question
I have created link toolbar in richtexteditor and want to select link component (dynamically added) in else statement after insertHTML. It is not created as a component until I click on canvas. Is there any method to achieve it?
Here is the following code:
editor.RichTextEditor.add('link', {
icon: '<i class="fa fa-link"/>',
attributes: { title: 'Link' },
result:
function (rte) {
if (isValidAnchor(rte))
rte.exec('unlink');
else {
rte.insertHTML(`<a data-gjs-type="link" class="link" href="">${rte.selection()}</a>`);
}
},
});Answers (1)
I found the method which works for me 👍
editor.getSelected().view.syncContent();
Thanks
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2770
[QUESTION] Set selected element
Hello, is there a way to select an element after added to the body? When i add a link, i want to open the Component Settings immediately. H...
Issue #6685
Custom component styles are not applied after deletion and re-addition
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v143.0.7499.193 Reproducible demo l...
Issue #6152
CSS added via custom code persists after custom code component is removed
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link https://grapesj...
Issue #5905
Unable to open component settings again, after clicking component and then clicking Blocks
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Opera 10.0.5130.23 | Linux Reproducible de...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.