[wp-hackers] Plugin to insert a link, how do I handle the selected text?

Callum Macdonald lists.automattic.com at callum-macdonald.com
Mon Mar 19 21:46:58 GMT 2007


I've looked at that, but it's launched as a javascript prompt, not a new 
HTML window. So it exists with all the variables already set. What I'm 
doing is trying to send a command back to the editor from an external 
window. So I can't figure a way to do it relating to the existing insert 
link functions.

Any ideas?


Callum.

Computer Guru wrote:
> Can't you refer to the original link insertion dialog for TinyMCE?
>
> Computer Guru
> NeoSmart Technologies
> http://neosmart.net/blog/
>
>
>   
>> -----Original Message-----
>> From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-
>> bounces at lists.automattic.com] On Behalf Of Callum Macdonald
>> Sent: Monday, March 19, 2007 9:11 AM
>> To: wp-hackers at lists.automattic.com
>> Subject: [wp-hackers] Plugin to insert a link, how do I handle the
>> selected text?
>>
>> G'day,
>>
>> I'm working on a plugin that adds a couple of buttons to the editors
>> (using Photopress as a base) and then pops up a list of links to insert
>> into the post. However, I can't figure out how to detect if text is
>> currently selected in the editor, and if so, wrap the link around that
>> text. My current code is:
>> function pluginInsertLink(linkcode) {
>> var winder = window.opener ? window.opener : window.dialogArguments;
>>     if ( !winder ) {
>>         winder = top;
>>     }
>>     tinyMCE = winder.tinyMCE;
>>     if ( typeof tinyMCE != "undefined" &&
>> tinyMCE.getInstanceById("content") ) {
>>         tinyMCE.selectedInstance.getWin().focus();
>> alert(focusElm);
>>         tinyMCE.execCommand("mceInsertContent", false, linkcode);
>>     } else {
>>         edCanvas = window.opener.document.post.content;
>>         winder.edInsertContent(edCanvas, linkcode);
>>     }
>> }
>>
>> Does anyone know if the current text is mapped to a javascript
>> variable?
>> Do I need to pass it to the popup when the popup is opened?
>>
>> Or does anyone know of another plugin which does something similar? I'm
>> happy to poke about in that code and figure something out.
>>
>> Cheers,
>>
>>
>> Callum.
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>     
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>   



More information about the wp-hackers mailing list