Unplanned
Last Updated: 05 Jan 2016 15:42 by akom
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>
1 comment
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);