Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2010-12-22 11:07:02

LeMacabre
New member
Registered: 2010-10-06
Posts: 8

Plugin - How can I replace a Link

Hi
I have a Plugin with which I can insert Tags (Such like ###EMAIL###, ###FIRSTNAME### and so on).
Thre are Tags which can be used for a Link or eMail.

My Idea ist:

If the user selected a word the plugin wraps a linktag arround the selected word.
If the selected word is already a link, the plugin edit the href-attribute.

My problem:
I don't know how to find out if there is  wrapped.

I know how to get the word (editor.getSelection() ) So I can wrap a normal Word.

hope somebody can help me ^^'

Offline

#2 2010-12-22 16:14:43

ejucovy
Xinha Community Member
From: NY
Registered: 2010-11-15
Posts: 35
Website

Re: Plugin - How can I replace a Link

You can look at the CreateLink module to see how to do this:

http://trac.xinha.org/browser/trunk/mod … ds.js#L147

Your plugin should copy that method.  Then you can call it in your plugin -- it will either return the Anchor tag that wraps the current selection, or nothing.

Offline

#3 2010-12-23 04:28:21

LeMacabre
New member
Registered: 2010-10-06
Posts: 8

Re: Plugin - How can I replace a Link

Aaaaaah thx smile
I looked into the CreateLink - Plugin before, but i didn't found the line where 'a' was declared so I was a little bit confused wink
Big thx to you. Now I know how to expand the selection, too (when the user selected only a part of the link).

Offline

#4 2010-12-23 11:21:04

ejucovy
Xinha Community Member
From: NY
Registered: 2010-11-15
Posts: 35
Website

Re: Plugin - How can I replace a Link

Happy to help smile

Offline

Board footer

Powered by FluxBB