In my AngularJS project, I am utilizing Froala editor. I want to create a unique functionality where a custom button wraps selected text with <close></close>
tags when activated. Moreover, if the selected text is already wrapped with these tags, clicking the button should remove them.
This feature should operate similarly to underlining or bolding text. For example, you can bold an entire word, but upon selecting 'ol' and clicking bold again, you will get a result like this: bold
I have managed to program a button that adds the tags, but I need assistance with removing them as well:
callback: function () {
var selectedText = this.html.getSelected(),
firstTag = '<close>',
lastTag = '</close>';
// replace selected text with wrapped text
this.html.insert(firstTag + selectedText + lastTag, true)
}