I am using quill rich editor with angular 4. Whenever I add a link it gets added with _target = "blank", which makes it open in a new tab. I want to open it in the same tab. Thanks in advance.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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) {
const node = super.create(value);
node.removeAttribute('target');
return node;
}
}
Quill.register(MyLink, true);
var quill = new Quill('#editor-container', {
modules: {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['link']
]
},
placeholder: 'Compose an epic...',
theme: 'snow' // or 'bubble'
});