Reputation: 670
I am using https://quilljs.com/ editor it adds the target attribute to all links. I want to remove it all dynamically. I am using it in the SPA so it's not good.
Upvotes: 1
Views: 1120
Reputation: 1872
Duplicate: https://stackoverflow.com/a/52275503/6809056
You can extend the Link format and remove the target attribute. See this example.
var Link = Quill.import('formats/link');
class MyLink extends Link {
static create(value) {
const node = super.create(value);
node.setAttribute('href', this.sanitize(value));
//node.setAttribute('target', '_blank');
node.removeAttribute('target');
return node;
}
}
Quill.register(MyLink);
var quill = new Quill('#editor-container', {
modules: {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['link']
]
},
placeholder: 'Compose an epic...',
theme: 'snow' // or 'bubble'
});
Upvotes: 1
Reputation: 298
This code should do.
const targets = document.querySelectorAll('[target]')
targets.forEach(e => {
e.removeAttribute('target')
})
Upvotes: 1