Wordpress - Paste html / text into the editor

I am creating a Vimeo Upload plugin for Wordpress so that you can upload directly from Wordpress to Vimeo and embed it directly. Anyway, I think I have the hardest part, and that was authentication (bad examples there).

Now I have a different problem. In Wordpress, you can embed images in a text editor by clicking a button in a popup window. ( http://cl.ly/6Xns ) (Dutch Invoegen in bericht button).

Now I want to do the same, paste "some tekst" (enough URL) in the expanded text area when someone clicks on my invoegen button ( http://cl.ly/6Wmn ) how can I achieve this?

I can not find javascript documentation on Wordpress site. Hope someone can help. I thought, let's see how another button does it, but the inspector does not show any "onclicks", etc. On this button. They are connected on the fly, and I don’t know where to look for this in the code.

Hope someone can help me.

Sincerely.

+6
source share
2 answers

Fixed.

function appendText(text) { //Insert content parent.tinyMCE.activeEditor.setContent(parent.tinyMCE.activeEditor.getContent() + text); //Close window parent.jQuery("#TB_closeWindowButton").click(); } 
+6
source

For those of you who want to add text to the current cursor location , you can use the mceInsertContent function (the TinyMCE built-in function).

Quick example:

 function addTextIntoEditor(myText){ tinymce.activeEditor.execCommand('mceInsertContent', false, myText); } 

It is based on the Magus answer located here.

0
source

Source: https://habr.com/ru/post/887414/


All Articles