javascript - TinyMCE Replace Parent Node -


i'm developping wordpress plugin adds button tinymce editor. when button clicked desired behaviour should be: 1. if selected text not part of short (or short) shortcode should inserted dom. 2 if not, shortcode should replaced new one.

the first requirement fufilled, second not. when inserted, show in visual editor not saved or displayed when saving or switching text. leads me believe im not directly editting object underneath editor, displayed. correct way go it. please see following function:

...    insertcontent: function(){     var atts  = '';     var node  = tinymce.activeeditor.selection.getnode();     var edit  = $(node).is('div.wp-arv-faq');      jquery('./$p/-sc-input').each(function() {       atts = atts + jquery(this).attr('name') + '=\"' + $(this).val() + "\" ";     });      var caption   = 'f.a.q. ' + $('./$p/-sc-input[name="tax"] option:selected').text();     var style     = $('./$p/-sc-input[name="style"] option:selected').text();     atts += ' caption="' + caption + ' (' + style + ')"';      if (edit){       $(node).empty();        tinymce.activeeditor.selection.setcontent('[arv-faq ' + atts + '][/arv-faq]');               /$p/faqmce.closemodal();   }, ... 

please note, '/$p/' unique build process , should ignored. in advance

from question not clear trying do, guess trying insert html code editor.

be sure have selection set right after calling $(node).empty();

note: tags , attributes need configured allowed tags , attributes using valid_elements , valid_children configuration paramters.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -