4 * HtmlArea (tinyMCE 4) wrapper
6 * @author Gabor Berczi <gabor.berczi@devworx.hu>
11 Prado.WebUI.THtmlArea4 = jQuery.klass(Prado.WebUI.Control,
13 initialize: function($super, options)
15 options.ID = options.EditorOptions.elements;
19 onInit : function(options)
21 this.options = options;
22 tinyMCE.init(this.options.EditorOptions);
25 removePreviousInstance: function()
27 for(var i=0;i<tinyMCE.editors.length;i++)
28 if (tinyMCE.editors[i].id==this.ID)
30 tinyMCE.editors.splice(i,1); // ugly hack, but works
37 // check for previous tinyMCE registration, and try to remove it gracefully first
38 var prev = tinyMCE.get(this.ID);
42 tinyMCE.execCommand('mceFocus', false, this.ID);
43 // when removed, tinyMCE restores its content to the textarea. If the textarea content has been
44 // updated in this same callback, it will be overwritten with the old content. Workaround this.
45 // var curtext = jQuery(this.ID).html();
46 tinyMCE.execCommand('mceRemoveControl', false, this.ID);
47 // jQuery(this.ID).html(curtext);
51 // suppress error here in case editor can't be properly removed
52 // (happens when <textarea> has been removed from DOM tree without deinitialzing the tinyMCE editor first)
55 // doublecheck editor instance here and remove manually from tinyMCE-registry if neccessary
56 this.removePreviousInstance();