Hello,
I badly need your help to understand how to create a custom plugin to do the following :
- get some highlighted text
- surround the selection with <a/>
- replace the highlighted text with the new value
I managed to get the first point, but only the text, and I don't understand how to make points 2 and 3. I've searched all cksource site and the web for a solution, I've only found some bribes of code that I can hardly understand, and they don't fit to my purpose.
I know it sounds terribly close to the link button, but I need a custom one.
Please help me to achieve it. I managed to create some functions before, but this one is too hard for me.
Thanks for you help.
Best regards.
I badly need your help to understand how to create a custom plugin to do the following :
- get some highlighted text
- surround the selection with <a/>
- replace the highlighted text with the new value
I managed to get the first point, but only the text, and I don't understand how to make points 2 and 3. I've searched all cksource site and the web for a solution, I've only found some bribes of code that I can hardly understand, and they don't fit to my purpose.
I know it sounds terribly close to the link button, but I need a custom one.
Please help me to achieve it. I managed to create some functions before, but this one is too hard for me.
Thanks for you help.
Best regards.
Re: Custom link plugin
to insert the new link instead of the selected text.
In order for the link to be accepted by CKEditor you have to add a data-cke-saved-href attribute:
Here is an example of the code I use (value being the destination, title being the tooltip and text being the visible text - in your case the selected text):
Re: Custom link plugin
you saved my day. Thank you so much for your quick answer, that is perfect for me ! How can it be so simple ? I never figured it in my vain searchs !
Best regards.