How do I get values ​​from my TinyMCE plugin?

I make an extra button on the TinyMCE toolbar (this is for Wordpress, but I don't think it matters).

A button is clicked and the form is displayed, I’ll just completely lose it when setting up, so the values ​​entered into the form are actually passed to the rest of the tinyMce plugin.

The only relevant documents I found is this page where they show you how to implement a custom browser. But this is pretty cryptic for the first timer (or at least for me).

Here is what I have:

This is done when the button is clicked:

ed.windowManager.open({ file : url + '/dialog.html', width : 400, height : 120, inline : 1 }, { plugin_url : url, // Plugin absolute URL some_custom_arg : 'custom arg' // Custom argument }); 

This is the contents of the dialog.html file

 <html> <head> <title>Hello world!</title> </head> <body> <form name="Hello world" method="post"> <input size="30" name="textbox1" type="text" id="textbox1" /> <input type="submit" value="" name="submitbutton" /> </form> </body> </html> 

Obviously, this does nothing (it doesn’t even close the dialog), but I don’t know where to start looking for something.

+8
tinymce
source share
2 answers

I answered this on the MoxieCode forums, but added my answer here for others.

The sample plugin that is included in TinyMCE should help and is used in the plugin tutorial.

Looking at the plugin, in the js directory you will find the JavaScript dialog.js library that contains the method that is called when you click on submit in the example dialog box. It essentially just uses mceInsertContent via execCommand to paste this value into the editor.

So, in your example, first of all you will need to change the form in order to call the JavaScript method when submitting. Then you will need to create this method to do what you want to insert into TinyMCE.

+3
source share

Examples tinymce is really the place to look. In addition to the information that Brett has already given, you can also refer to the instance of the caller tinymce and put variables there, or you can call the function of one of your own plugins.

<strong> Examples:

 // insertion of content into the calling editor instance tinyMCEPopup.execCommand('mceInsertContent', false, 'my_content'; // store value in editor variable tinyMCEPopup.editor.new_variable = 'new_special_blah'; // call a function from an own plugin tinyMCEPopup.editor.plugins.my_plugin.my_custom_function(var1, var2); 
+1
source share

All Articles