How to edit target attribute in QuillJs links

The target attribute is set in the link blot. You can extend the link blot to remove this attribute:

var Link = Quill.import('formats/link');

class MyLink extends Link {
    static create(value) {
        let node = super.create(value);
        value = this.sanitize(value);
        node.setAttribute('href', value);
        if (value.includes(thisDomain)) {
            node.removeAttribute('target');
        }
        return node;
    }
}

Quill.register(MyLink);

Additional Resources:

Comments

Leave a Comment

All fields are required. Your email address will not be published.