Won't Fix
Last Updated: 11 Nov 2024 14:38 by ADMIN
ADMIN
Ianko
Created on: 08 Dec 2015 09:43
Category: Editor
Type: Bug Report
0
Empty anchor element is not cleared when inserting new line and cursor is between link and text
Inserting a new line after a link typically adds a new line and removes the copied link. 

However, this does not work when paragraph is about to be split. 

For the time being you can override the _nodeInsertedHandler method to resolve the bug as in this example:

<telerik:RadEditor runat="server" ID="RadEditor1">
     <Content>
         <p><a href="http://www.telerik.com" >link</a>text</p>
     </Content>
 </telerik:RadEditor>

 <script>
     Telerik.Web.UI.Editor.InsertParagraphCommand.prototype._nodeInsertedHandler = function (args) {
         var command = this,
             cursor = args.get_cursor(),
             container = args.get_container(),
             isEmptyContainer = command._isEmptyContainer(container, cursor),
             $E = Telerik.Web.UI.Editor,
             utils = $E.Utils;

         var parentAnchor = utils.getElementParentByTag(cursor, "A");

         if (command._isEmptyContainer(parentAnchor, cursor))
             command._removeNode(parentAnchor);

         if (isEmptyContainer) {
             if (command.get_editor().get_enableTrackChanges()) {
                 var tcUtils = $E.TrackChangesUtils,
                     parentTrackedInsert = tcUtils.getParentTrackChangesInsertNode(cursor, container),
                     parentTrackedDelete = tcUtils.getParentTrackChangesDeleteNode(cursor, container);
                 command._removeNode(parentTrackedInsert);
                 command._removeNode(parentTrackedDelete);
             }
         }
     };
 </script>
2 comments
ADMIN
Rumen
Posted on: 11 Nov 2024 14:38
The issue where an empty anchor element is not cleared when inserting a new line while the cursor is between a link and text has been reviewed. A workaround is available, and the bug has been marked as Won't Fix due to consistently low interest from the community since it was reported in 2015.
akom
Posted on: 05 Jan 2016 15:42
Please note that this check will fail if parentAnchor is null e.g. new line without link:
if (command._isEmptyContainer(parentAnchor, cursor))
command._removeNode(parentAnchor);

It should be updated to the something like this:
if (parentAnchor && command._isEmptyContainer(parentAnchor, cursor))
command._removeNode(parentAnchor);