In PHP the editor-supplied data is a post variable such as $_POST["html_edit_data_string"] (are the quotes necessary?). That string is stored as an HTML page somewhere, and then that page is loaded by a user/client.
When it is loaded, any php that is in the page gets executed by the server on its way to the browser. To prevent that, the string has to go through regular expression filters to take out malisous code that would execute on the server (PHP has all the system calls (such as "rm" any files created by the Apache user--which your ID when you get executed). Likewise, javascript could be executed by the browser, though I only think it can only set/earse cookies.. but it could be AJAX code that...
This is interesting to me for a whole other reason-this is where the image data (string w/in a string) can be located, altered into a normal image (ie jpg) and stored, and the img reference to it can can be subsituted into the string to string to create a normal web page, rather than one w/ image data in it (there is really no other way).
I wrote my very last paper using the original "composer" that came with ncsa moasic (first graphic browswer), later netscape, etc, to Sea Monkey. I am wondering if that is not the place to develop given all potential the security issues. Sea Monkey composer has problems, but all are with optional features that can be found in the browser itself, such as text searching and spell checking. The major advantage is that I could paste from the clipboard, such as illustrations, or, even more useful, text directly from google books so that I could look at it while I wrote-in the material for the paper(s).
I will continue with the TinyMCE browser until it has a filesystem list for all the files and a search function, then give it a rest. I am beginning to feel that the web-connecting "app" route (such as on Android) makes more sense than the "intelligent" web page that started as CGI and became javascript.