Tiny MCE editor and fill the field

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information:CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Tom, Tech Support
Posts: 3491
Joined: Mon May 31, 2010 4:59 pm

Re: Tiny MCE editor and fill the field

Post by Tom, Tech Support » Mon May 02, 2011 10:01 am

Hello green.pine,

It might have to do with the content in your !EXTRACT variable, for example, does it contain quote characters? This might be confusing the Javascript interpretation.

Can you post an example of your extracted text file?
Regards,

Tom, iMacros Support
wg@gregorigroup.com
Posts: 6
Joined: Mon May 23, 2011 2:15 pm

Re: Tiny MCE editor and fill the field

Post by wg@gregorigroup.com » Mon May 23, 2011 5:16 pm

I'm having the same problem posting to the tiny_mce url.

It works fine for smaller html strings but large ones will not post properly. My guess is that we are over running the URL length. I'd be glad to send you my variable string if you'd like to test.

Thanks
Tom, Tech Support
Posts: 3491
Joined: Mon May 31, 2010 4:59 pm

Re: Tiny MCE editor and fill the field

Post by Tom, Tech Support » Tue May 24, 2011 7:36 pm

wg@gregorigroup.com wrote:I'm having the same problem posting to the tiny_mce url.

It works fine for smaller html strings but large ones will not post properly. My guess is that we are over running the URL length. I'd be glad to send you my variable string if you'd like to test.

Thanks
Please see my post here regarding reading the contents from a file.
Regards,

Tom, iMacros Support
Eagle
Posts: 2
Joined: Tue Feb 01, 2011 9:45 am

Re: Tiny MCE editor and fill the field

Post by Eagle » Fri Jun 03, 2011 12:44 pm

To overcome the limitation of passing the text directly to JavaScript, which requires proper escaping and may be problematic with extracted texts, the following trick can be used:
  1. Create a temporary textarea with unique ID
  2. Let iMacros set the required text to this textarea
  3. Use JavaScript to read its content and send it to TinyMCE
  4. Destroy the temporary textarea
With a little JavaScript magic the necessary code can look something like this:

Code: Select all

URL GOTO=javascript:void(function(){var<SP>ta=document.createElement("textarea");ta.id="imacros2tinymce";document.body.appendChild(ta);}());
TAG POS=1 TYPE=TEXTAREA ATTR=ID:imacros2tinymce CONTENT=EDITOR_CONTENTS
URL GOTO=javascript:void(function(){var<SP>ta=document.getElementById('imacros2tinymce');tinyMCE.editors['EDITOR_NAME'].setContent(ta.value);document.body.removeChild(ta);}());
where EDITOR_NAME is name of the textarea the editor is associated with and EDITOR_CONTENTS is what you want to set the contents to.

The first line creates a temporary textarea with id "imacros2tinymce" and adds it to the page. On the second line iMacros fill this textarea with the required content. The third line takes this content, sends it to TinyMCE and destroys the temporary textarea. It's a pretty hacky solution, but it should do the trick...

Example macro:

Code: Select all

VERSION BUILD=7210419 RECORDER=FX
URL GOTO=http://tinymce.moxiecode.com/tryit/full.php
WAIT SECONDS=5
URL GOTO=javascript:void(function(){var<SP>ta=document.createElement("textarea");ta.id="imacros2tinymce";document.body.appendChild(ta);}());
TAG POS=1 TYPE=TEXTAREA ATTR=ID:imacros2tinymce CONTENT=My<SP>content<SP>filled<SP>by<SP><b>iMacros</b><SP>(now<SP>including<SP>quotes<SP>'<SP>"<SP>!)
URL GOTO=javascript:void(function(){var<SP>ta=document.getElementById('imacros2tinymce');tinyMCE.editors['content'].setContent(ta.value);document.body.removeChild(ta);}());
(should open the TinyMCE example page and after 5 seconds change the editor content to My content filled by iMacros (now including quotes ' " !))

Tested with iMacros for Firefox 7.2.1.0 in FF 3.6.17
Tom, Tech Support
Posts: 3491
Joined: Mon May 31, 2010 4:59 pm

Re: Tiny MCE editor and fill the field

Post by Tom, Tech Support » Sat Jun 04, 2011 8:29 am

Brilliant! Thanks for the tip Eagle!
Regards,

Tom, iMacros Support
vicky
Posts: 23
Joined: Sun Apr 08, 2012 3:17 am
Contact:

Re: Tiny MCE editor and fill the field

Post by vicky » Thu Apr 12, 2012 2:12 am

Can we fill this type of editor using this trick : Let me know if there is any expert, who can help on this type of text editor.

http://www.quikr.com/post-classifieds-ads
http://www.yolist.com/post-free-classified-ads


Thanks
Vicky
Post Reply