Answer the question
In order to leave comments, you need to log in
How to properly add an HTML tag insert button to the TinyMCE editor?
I add a button, it is displayed. Here is the code
(function() {
tinymce.create('tinymce.plugins.insert_gallery', {
init : function(ed, url) {
ed.addButton('insert_gallery', {
title : 'Вставить слайдер',
image : url + '/img/gallery.png',
onclick : function() {
ed.selection.setContent('<xpageslider>' + ed.selection.getContent() + '</xpageslider>');
}
});
},
createControl : function(n, cm) {
return null;
},
});
tinymce.PluginManager.add('insert_gallery', tinymce.plugins.insert_gallery);
})();
<xpageslider>
. When you add this tag to the editor, it is immediately cut out. In init () I allowed to insert all tags. In other cases, for example, inserting code through the editor's dialog box, it works and all the rules. Answer the question
In order to leave comments, you need to log in
I decided that the tag to be inserted should not be empty
(function() {
tinymce.create('tinymce.plugins.insert_gallery', {
init : function(ed, url) {
ed.addButton('insert_gallery', {
title : 'Вставить слайдер',
image : url + '/img/gallery.png',
onclick : function() {
ed.selection.setContent('<xpageslider> </xpageslider>');
}
});
},
createControl : function(n, cm) {
return null;
},
});
tinymce.PluginManager.add('insert_gallery', tinymce.plugins.insert_gallery);
})();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question