1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
*
* HtmlArea (tinyMCE 4) wrapper
*
* @author Gabor Berczi <gabor.berczi@devworx.hu>
*
*/
Prado.WebUI.THtmlArea4 = Class.create(Prado.WebUI.Control,
{
initialize: function($super, options)
{
options.ID = options.EditorOptions.elements;
$super(options);
},
onInit : function(options)
{
this.options = options;
tinyMCE.init(this.options.EditorOptions);
},
removePreviousInstance: function()
{
for(var i=0;i<tinyMCE.editors.length;i++)
if (tinyMCE.editors[i].id==this.ID)
{
tinyMCE.editors.splice(i,1); // ugly hack, but works
i--;
}
},
onDone: function()
{
// check for previous tinyMCE registration, and try to remove it gracefully first
var prev = tinyMCE.get(this.ID);
if (prev)
try
{
tinyMCE.execCommand('mceFocus', false, this.ID);
// when removed, tinyMCE restores its content to the textarea. If the textarea content has been
// updated in this same callback, it will be overwritten with the old content. Workaround this.
// var curtext = $(this.ID).html();
tinyMCE.execCommand('mceRemoveControl', false, this.ID);
// $(this.ID).html(curtext);
}
catch (e)
{
// suppress error here in case editor can't be properly removed
// (happens when <textarea> has been removed from DOM tree without deinitialzing the tinyMCE editor first)
}
// doublecheck editor instance here and remove manually from tinyMCE-registry if neccessary
this.removePreviousInstance();
}
});
|