I am trying to create a custom format for links in react-quill. I will attach the working code at the link.
class LinkBlot extends Inline {
static create(value) {
let node = super.create();
node.setAttribute("href", value);
if (/^(https?:)?\/\//.test(value)) {
node.setAttribute("target", "_blank");
node.setAttribute("rel", "noopener noreferrer");
}
return node;
}
static formats(node) {
return node.getAttribute("href");
}
}
LinkBlot.blotName = "link";
LinkBlot.tagName = "a";
Quill.register("formats/link", LinkBlot);
There is a problem, after adding a link I can't open it for editing, as it happens without custom formatting. How can i fix this problem ?