Opened 13 years ago

Closed 13 years ago

#839 closed defect (fixed)

Impossible to remove link from linker plugin when original selection is kept

Reported by: mokhet Owned by: gogo
Priority: normal Milestone:
Component: Plugin_Linker Version:
Severity: major Keywords: remove link
Cc:

Description

The button "remove link" in linker plugin is not removing links if the whole <a> is selected.

step to reproduce :

0) Linker plugin obviously activated
1) write some text : Lorem ipsum dolor si amen
2) double click on a word to select (let's do it on the word "ipsum")
3) the word is selected, now click on the linker button in toolbar
4) click on OK button, no matters to what it is linked
5) the inline linker dialog is closed, the word is now a link.
6) click again on the linker button in toolbar - do not change the active selection -
7) click on "remove link" button
8) the inline linker dialog is closed and the word is still a link

Expected result :

step 8 should remove the previously defined link

Workaround :

before step 6, the selection must be canceled and the link must NOT be selected at all to be removed

With standard link button, when the href attribute is removed from the dialog box, the link is correctly removed even when it was selected.

Change History (6)

comment:1 Changed 13 years ago by mokhet

This patch is doing the work as intended

Index: linker.js
===================================================================
--- linker.js	(revision 554)
+++ linker.js	(working copy)
@@ -232,7 +232,15 @@
     }
     else
     {
-      if(!atr.href) return true;
+      if(!atr.href)
+      {
+        if(confirm(linker._dialog._lc('Are you sure you wish to remove this link?')))
+        {
+          editor._getSelection();
+          editor._doc.execCommand("unlink", false, null);
+          return true;
+        }
+      }
 
       // Insert a link, we let the browser do this, we figure it knows best
       var tmp = HTMLArea.uniq('http://www.example.com/Link');

I think it's ok to commit to trunk, however the linker plugin code is very weird for me and i dunno if it's a good fix or just a lucky one. Can someone confirm it's ok to commit ?

comment:2 Changed 13 years ago by gogo

How do you know at that point that unlink will infact unlink anything, the selection may not include any link to unlink. The user might have highlighted something and just changed thier mind, we shouldn't give them a bogus warning.

comment:3 Changed 13 years ago by mokhet

I dont know gogo, at this point i was excepting it to be called only when the button "ok" or "remove" as been clicked since the function name is "doOK()", but as i said, i dont understand this plugin.
So, this seems to be exactly what i though at first, it is just a lucky "fix" and must not be used :( Any idea to correctly fix the problem ?

However, i'm using this "patch" and i dont see the behavior you point out. When i click on "cancel", the inline-dialog is closed and the confirmation warning is not shown.

comment:4 Changed 13 years ago by gogo

Yes, but if you click on OK without specifying a link href it would present it I think, but not really correct if there was nothing there to unlink in the first place. The proper fix would be to figure out if unlinking would actually unlink anything, and only alert then.

comment:5 Changed 13 years ago by ray

The problem is that in the moment when the link is just created and selection is not changed (updated manually) for some reason the selection is not aware that there is now a link.
Note that the url is still www.example.com, not the actually chosen, new one.
I think that this is a problem, but I've got a feeling that it cannot be resolved

comment:6 Changed 13 years ago by ray

  • Resolution set to fixed
  • Status changed from new to closed

OK, was not so hard. See Changeset [582]

Note: See TracTickets for help on using tickets.