[wp-hackers] Plugin to insert a link,
how do I handle the selected text?
Computer Guru
computerguru at neosmart.net
Mon Mar 19 10:21:57 GMT 2007
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
More information about the wp-hackers
mailing list