Closed (works as designed)
Project:
Wysiwyg
Version:
7.x-2.1
Component:
Plugins
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Mar 2013 at 20:22 UTC
Updated:
7 Mar 2013 at 20:08 UTC
I'm trying to create a plugin to insert a link into to an internal resource into a wysiwyg. And when the cursor is in one of our links and they invoke the plugin, I want to replace the old link entirely. The best I can manager right now is inserting the new link inside the old one, which I don't want.
To illustrate:
<a href="old_url">Te|xt</a> where | is the cursor when the plugin is invoked.
I want it to be this:
<a href="new_url">New Text|</a>
But instead I get:
<a href="old_url">Te<a href="new_url">New Text|</a>xt</a>
Am I missing something that would help me accomplish this?
Comments
Comment #1
twodThe selection abstraction support for cross-editor plugins is currently very limited. You'll have to resort to using the browsers' native selection objects (tricky to get right), or figure out which editor is currently active for the field and use its selection abstraction. CKEditor and TinyMCE and perhaps also YUI have pretty good APIs for that, others are falling behind.
The WYSIWYG image upload module worked around all this to be able to manage its in-WYSIWYG placeholders better. Perhaps you can find help in that code.
Another option would be to create native plugins instead, but that will of course mean one plugin for each editor.
Comment #2
MPetrovic commentedThanks, I ended up using the native selection objects. Not as tricky as you'd think.