Issue #2551💬 AnsweredOpened February 5, 2020by gagan3480 reactions

Unable to select link component without clicking on canvas in richtexteditor

快速解答by gagan348

I found the method which works for me 👍 editor.getSelected().view.syncContent(); Thanks

Read full answer below ↓

Question

代码片段TEXT
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)

gagan348February 6, 2020

I found the method which works for me 👍

editor.getSelected().view.syncContent();

Thanks

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

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.