Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. (function() {
  2.  
  3. tinymce.create('tinymce.plugins.my_shortcode_plugin', {
  4. init : function(ed, url) {
  5. ed.addCommand('my_shortcode_insert_shortcode', function() {
  6. selected = tinyMCE.activeEditor.selection.getContent();
  7.  
  8. if ( selected ) {
  9. content = '[my_shortcode]'+ selected +'[/my_shortcode]';
  10. } else {
  11. content = '[my_shortcode][/my_shortcode]';
  12. }
  13.  
  14. tinymce.execCommand('mceInsertContent', false, content);
  15. });
  16.  
  17.  
  18. ed.addButton('my_shortcode_button', {title : 'Insert my_shortcode', cmd : 'my_shortcode_insert_shortcode', image: url + '/assets/images/my_shortcode-icon.png', // onclick: function() {add popup window with color picker here?}});
  19. },
  20. });
  21.  
  22. tinymce.PluginManager.add('my_shortcode_button', tinymce.plugins.my_shortcode_plugin);
  23. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement