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

夙愿已清 提交于 2019-12-13 04:15:19

问题


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'
});


来源:https://stackoverflow.com/questions/51968424/how-to-override-ngx-quill-editor-link-and-make-it-open-in-the-same-tab-by-defau

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!