Skip to content
This repository was archived by the owner on Mar 8, 2019. It is now read-only.
This repository was archived by the owner on Mar 8, 2019. It is now read-only.

How to prevent the reset of a link's title and target attributes? #349

@mtlehtin

Description

@mtlehtin

I have to add internal and external links to the content. I made a custom dialog where you can choose the type of the link and title.

Internal link generates markup like:
<a href="http://sample.url" title="Custom title">sample</a>

and external:
<a href="http://sample.url" class="external" title="Custom title" target="_blank">sample</a>

The first save is successful, but when I open the editor again and save it second time, editor resets link's attributes with default values:
<a href="http://sample.url" class="external" title="Link: http://sample.url">sample</a>

Same happens when I copy paste HTML with e.g. following markup to the editor:
<a href="http://sample.url" class="external" title="Custom title" target="_blank">sample</a>

Editor will reset the title and the target from the link within the paste.

Could it be achieved with dynamic parser rules like followed? Or can I use directly setAttributes? If so, how would that work?

set_attributes: { "target": <use _blank if external link otherwise empty>, "title": <use current title> }

One option would be to use regexp in editor.getValue() to add attributes before save, but that does not seem very wise thing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions