In order to complete my WordPress Plugin I want to make tinyMCE to switch between a custom Tag (Some|data|here) and a corresponding Image Display in the WYSIWYG-View.
The event should be triggered on load, safe, autosave, switch view etc. Threre are 4 different events defined, but none of them works as expected.
- onBeforeSetContent
- onGetContent
- onPostProcess
- onLoadContent
.
ed.onPostProcess.add(function(ed, o) {
if (o.set){
o.content = t._htmlToWysiwyg(o.content, url);
}
if (o.get){
o.content = t._wysiwygToHtml(o.content, t);
}
});
Anyon know the right way?
I do not know what you expect the 4 different events will do (?), but i can see some problems in your code.
1. The object
o
does not contain fieldsget
andset
– soo.get
ando.set
will never betrue
! Thus your code will never be called.2. You are using the variable
url
, but this one is not defined here.Working example: You may try to paste a string containing “a” into the editor. Use the following:
You should see that all lower ‘
a
‘s get replaced by ‘A
‘s.