D
D
Dmitry2014-08-13 14:46:49
JavaScript
Dmitry, 2014-08-13 14:46:49

How to remove wrap tag in tinyMCE editor?

In the tinyMCE editor, the necessary piece of text is wrapped in tags for me.
<div class="gallery">...</div>
How can I make a button that would clear the entire code from such tags, or only the part where the cursor is?
Analogue highlighting in bold, exposing links.
What is:
I created a button in the editor that wraps the selected piece with <div class="gallery">...</div>
button code tags:

var selected = $('#container').tinymce().selection.getContent();
$('#container').tinymce().execCommand('mceReplaceContent', false, '<div class="my_select">'+selected+'</div>');

An example of possible HTML with these tags:
<div class="gallery">
<img src="...">
<p>....</p>
</div

<div class="gallery">
<div class="gallery">...</div>
<img src="...">
<p>....</p>
</div>

I don't want to select all the values, parse them, count the number of divs, look for closing tags, maybe there is an easier way, please tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Novikov, 2014-10-23
@BOOMER_74

I decided to abandon such editors altogether, in favor of CodeMirror, which I advise you to do as well. There are also disadvantages, there is no visual editor, but for me it's even better. If you need a ready-made CodeMirror with connected plugins, please contact me (all contacts can be found in Brainstorage).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question