Unable to select link component without clicking on canvas in richtexteditor
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 #6152
BUG: 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
BUG: 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...
Issue #2399
SVG Component Not Draggable
Hi, I am using grapesjs in angular 7.What I want to achieve when ever canvas drop method called I add svg component in canvas.I have add sv...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.