jpuri / draftjs-to-html

Library for converting Draftjs editor content state to HTML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change default target option

Manasa-wal opened this issue · comments

How to change target option of anchor tag from "_self" to "_blank" and how to change css of anchor tag?
Page is not opening in new tab even when the checkbox "open link in a new tab" is checked

I found that, the attribute target is being removed after sanitizing using DOMPurify.
So, to solve the issue..

use this code,

DOMPurify.addHook("afterSanitizeAttributes", function (node) {
    if ("target" in node) {
      node.setAttribute("target", "blank");
      node.setAttribute("rel", "noopener");
    }
  });