Re: Mark,
You did not fully explain what you would do to call TinymceWrapper if I added MODx.loadRTE support.
TinymceWrapper is designed to attempt to keep the TinyMCE inits absolutely independent. I am not sure that this MODx.loadRTE method would not complicate issues, namely by hijacking the
selector part of the init. I want everything to be in the init chunk, bare and visible.
Here are two solutions for you:
1) You will have to do something like what Bruno is doing already for MIGX.
The TinymceWrapper plugin is already activated - TinyMCE will already be loaded.
All you have to do is allow a user to specify what chunkName they want in some setting of your CB extra.
e.g
tinymce.init({
mode: "exact",
elements: "contentblocks-field-[[+cb_id]]_textarea",
// selector: "textarea[id^=contentblocks-field-].cb-richtext",
[[$TinymceWrapperCommonCode]]
plugins:"autoresize,preview,paste,contextmenu,image,wordcount,fullscreen,code,link,charmap,searchreplace,textpattern,emoticons,insertdatetime",
paste_word_valid_elements: "a,div,b,strong,i,em,h1,h2,h3,p,blockquote,ol,ul,pre",
valid_elements: "iframe[*],object[*],audio[*],-span[!title|!class<test test2],a[href|target|class|rel|title|data-ajax|data-iframe],strong,b,-p[class<text-align-left?text-align-center?text-align-right],br,-h1[class|data-ajax|data-iframe],-h2[class|data-ajax|data-iframe],-h3[class|data-ajax|data-iframe],-img[!src|!alt|!class=round_img|data-ajax|data-iframe],em,-blockquote,pre[class],-ol,-ul,-li,-code[class]",
valid_children: "-li[ul],-li[ol],-li[div],-strong[*],-em[*],-h1[*],-h2[*],-h3[*],-a[strong|em|h1|h2|h3|p|div],blockquote[p|ol|ul],pre,div",
resize:true,
autoresize_min_height:100,
autoresize_max_height:400,
toolbar: "newdocument | fullscreen preview | undo redo | blockquote | bold | italic | aligncenter | bullist numlist | link unlink | image | styleselect | charmap emoticons insertdatetime | searchreplace",
contextmenu: "removeformat | link | image | code",
setup: function(editor) {
editor.on('mouseleave', function(evt) {
tinyMCE.activeEditor.save();
//console.log("saved");//debug stuff
});
}
});
Now once a user adds a CB richtext, and a textarea is created on the fly, you would fire that piece of chunk code as well, either each time, or have it in the background listening for new richtext textareas.
2) Simply give each new richtext textarea a common class, something like what MODx does for its richTVs
At this time, as far as I can see in CB, there is no way to tell the difference between a richtext textarea and a plain textarea. Bruno put this demarcation in MIGX recently.
This is good practice for future Extras to integrate with CB.
<textarea id="contentblocks-field-1_textarea" class="cb-richtext"></textarea>
<textarea id="contentblocks-field-2_textarea" class="cb-richtext"></textarea>
<textarea id="contentblocks-field-3_textarea" class="cb-richtext"></textarea>
With this HTML in place, TinymceWrapper or any other Extra/Plugin will be able to target the textareas without any qualm.
Cheers.