For the sake of this discussion , I’m trying to add the WYSIWYG editor TinyMCE to the WordPress add new comments field. (Actually, I’m hacking P2 but let’s not get distracted.)
I start with a textarea id=”posttext”.
A click triggers adding the editor: tinyMCE.init({mode : “exact”, elements: “posttext”});
The catch is, I also want to use WP Add Media. The Insert into Post works on the textarea. But once I init the editor WP loses track of where to insert. Since Add Media works with the editor on Admin posts I presume it’s possible but there’s something I don’t have just right.
Also, what id= does the Insert into Post look for? So far I’ve figured it can be posttext and content.
Thanks in advance for your help.
p.s. While I have your attention, is there anything special I need to know about submitting a change from the TinyMCE editor via Ajax. P2 has a plain ol’ textarea, what I want is to add WYSIWYG to that. Am I making sense?
For informational sake, TinyMCE uses a Ajax script from /wp-admin/admin-ajax.php to submit an action called send-attachment-to-editor.
This function is inside of /wp-includes/js/media-editor.min.js
Basically once a image item is selected and after hitting the “insert to post” button, it runs the Ajax script and sends the action: send-attachment-to-editor and all the img attachment information including nonce.
Example Ajax Post:
Which then this responds with the img you requested over and puts it inside the editor:
And for your second question I believe by default the content area ID would equal to #page_contents which you could manually add the content yourself through JS/JQuery.
With all this the only concern I have is how are you going to show the contents of add media and the functionality of the upload/img managment. This particular section would need some permissions I believe and would cause it to have control over the pictures that are currently on the site already. I would be interested to see how you would handle the task of displaying this information and practical usage inside the comment section.
I know this plugin is out of date and probably doesn’t even work but it might help you http://wordpress.org/extend/plugins/tinymcecomments/