From 9861a4c0d523c26e42825c869ebedc7cfc1f8dfa Mon Sep 17 00:00:00 2001 From: tabaliov Date: Tue, 18 Sep 2018 12:57:52 +0300 Subject: [PATCH] added unlink functionality in RTE --- src/rich_text_editor/model/RichTextEditor.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rich_text_editor/model/RichTextEditor.js b/src/rich_text_editor/model/RichTextEditor.js index c87738f40..d8d1a74da 100644 --- a/src/rich_text_editor/model/RichTextEditor.js +++ b/src/rich_text_editor/model/RichTextEditor.js @@ -37,8 +37,14 @@ const defActions = { style: 'font-size:1.4rem;padding:0 4px 2px;', title: 'Link' }, - result: rte => - rte.insertHTML(`${rte.selection()}`) + result: rte => { + const nextSibling = rte.selection().anchorNode.nextSibling; + if (nextSibling && nextSibling.nodeName == 'A') { + rte.exec('unlink'); + } else { + rte.insertHTML(`${rte.selection()}`); + } + } } };