 
     _cancelUrlPopover : () =>
         pop = @urlPopover
+        pop.style.display = 'none'
         seg.style.removeProperty('background-color') for seg in pop.segments
-        # case of a linkifySelection() called and cancelled => reverse the
-        # modification
-        if pop.calledByLinkifySelection
-            @_restoreSavedLine()
-            pop.style.display = 'none'
+        # case of a link creation called and cancelled : a segment for the link
+        # to creat has already been added in order to show the selection when 
+        # popover is visible. As it is canceled, we undo in order to remove this
+        # link.
+        if pop.isLinkCreation
+            rg = document.createRange()
+            rg.selectNodeContents(seg)
+            @currentSel.sel.setSingleRange rg
+            @unDo()
             @setFocus()
+        else
+            @currentSel.sel.setSingleRange(pop.initialSelRg)
+            @setFocus()
+
+        return true
+
+    _validateUrlPopover : () =>
+        pop = @urlPopover
+        segments = pop.segments
+
+        # in case of a link creation and the user validated an empty url, just
+        # cancel the link creation
+        if pop.urlInput.value == '' && pop.isLinkCreation
+            @_cancelUrlPopover()
             return true
 
-
-        # case of a deletion of the urlInput value, what means 'remove the link'
-        if pop.urlInput.value == '' or pop.urlInput.value == 'http:///'
-            bps = @_applyMetaData(pop.initialSelRg, false, 'A', []) 
-            # 4- Position selection
+        # remove background of selection and hide popover
+        pop.style.display = 'none'
+        seg.style.removeProperty('background-color') for seg in segments
+
+        # in case of a link creation, addhistory has already be done, it must 
+        # then be done if non a link creation.
+        if !pop.isLinkCreation
+            @currentSel.sel.setSingleRange pop.initialSelRg # otherwise addhistory will not work
+            @_addHistory()
+
+        # case of a deletion of the urlInput value => 'remove the link'
+        if pop.urlInput.value == ''
+            # bps = @_applyMetaData(pop.initialSelRg, false, 'A', [])
+            l = segments.length
+            bp1 = 
+                cont : segments[0].firstChild
+                offset : 0
+            bp2 = 
+                cont : segments[l-1].firstChild
+                offset : segments[l-1].firstChild.length
+            bps = [bp1,bp2]
+            @_applyAhrefToSegments(segments[0], segments[l-1], bps, false, 'A', '')
+            # Position selection
             rg = document.createRange()
             bp1 = bps[0]
             bp2 = bps[1]

            segments = @_getLinkSegments()
            # case when the start break point is in a link
            if segments
                @_showUrlPopover(segments,true)
            # case when the start break point is not in a link
            else
                @_saveLine()
                @_applyMetaDataOnSelection('A','http://')
                segments = @_getLinkSegments()
                @_showUrlPopover(segments,true)

            # 2 - restore selection
            savedSel = @_history.historySelect[@_history.index+1]
            savedSel.restored = false
            rangy.deserializeSelection(savedSel, @linesDiv)
            # 3 - restore scrollbar position
            xcoord = @_history.historyScroll[@_history.index+1].xcoord
            ycoord = @_history.historyScroll[@_history.index+1].ycoord
