import Quill from "quill";
const Inline = Quill.import('blots/inline');

export default class LinkBlot extends Inline {
  static create(value) {
    let node = super.create()
    let rs = value
    if (rs.indexOf('http://') < 0) {
      rs = 'http://' + rs
    }
    node.setAttribute('href', rs)
    node.setAttribute('target', '_blank')
    return node;
  }

  static formats(node) {
    return node.getAttribute('href');
  }
}
LinkBlot.blotName = 'link'
LinkBlot.tagName = 'a'