how to override ngx-quill editor link and make it open in the same tab? By default it opens in new tab

时间:2018-08-22 13:50:25

标签: javascript angular npm quill

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 个答案:

答案 0 :(得分:0)

目标属性在link blot中设置。 您可以extend链接印迹来删除此属性:

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'
});
相关问题