Issue #1669💬 AnsweredOpened December 18, 2018by SeongwoonHong0 reactions

Custom link modal doesn't update the current text but add another text with link

Quick answerby SeongwoonHong

I'd like to add one more, inside onclick handler for btnLink, <a class="link" href="${inputEl.value}">${rte.selection()}</a> returns <a class="link" href="..."></a> the inner text is empty.. i have no idea how to approach this

Read full answer below ↓

Question

Hello Artur, I'm trying to have a custom modal when clicked link button in RTE. but it doesn't convert selected text to link but what it does is it adds another text with link. Thank you..

Answers (3)

SeongwoonHongDecember 18, 2018

I'd like to add one more, inside onclick handler for btnLink, <a class="link" href="${inputEl.value}">${rte.selection()}</a> returns <a class="link" href="..."></a> the inner text is empty.. i have no idea how to approach this

artfDecember 20, 2018

Change this: rte.insertHTML('<a class="link" href="${inputEl.value}">${rte.selection()}</a>'); to rte.insertHTML(linkInputEl.value);rte.selection() will be empty because the focus is lost, learn how to store the selection (eg. https://stackoverflow.com/questions/9841082/execcommand-inserthtml-break...

lock[bot]December 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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 →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.