
import {Quill} from 'vue-quill-editor'
const BlockEmbed = Quill.import('blots/block/embed')
const inline = Quill.import('blots/inline')
// 添加插入图片
class ImageBlot extends BlockEmbed {
  static create(value) {
    const node = super.create(value)
    console.log(node)
    node.setAttribute('src', value.url)
    // node.setAttribute('title', value.name)
    // node.setAttribute('controls', value.controls)
    // node.setAttribute('controlslist', value.controlslist)
    node.setAttribute('width', value.width)
    node.setAttribute('height', value.height)
    // node.setAttribute('webkit-playsinline', true)
    // node.setAttribute('playsinline', true)
    // node.setAttribute('x5-playsinline', true)
    node.setAttribute('style', value.style)
    // if (value.autoplay) {
    //   node.setAttribute('autoplay', value.autoplay)
    // }
    return node
  }
 
  static value(node) {
    return {
      url: node.getAttribute('src'), // 注意这里和上面的属性和值反过来相对
    //   name: node.getAttribute('title'),
    //   autoplay: node.getAttribute('autoplay'),
    //   controls: node.getAttribute('controls'),
    //   controlslist: node.getAttribute('controlslist'),
      width: node.getAttribute('width'),
      height: node.getAttribute('height'),
      style: node.getAttribute('style')
    }
  }
}
 
ImageBlot.blotName = 'image1' //quill使用时的名称
ImageBlot.tagName = 'img' //定义的html标签名
Quill.register(ImageBlot) // 注册




class WordBox extends inline {
  static create(value) {
    const node = super.create(value);
    //设置需要的样式
    node.setAttribute('style', 'width:80px;height: 80px;border: 1px solid #f9f6f675;vertical-align:middle');
    return node;
  }
}

WordBox.blotName = 'wordBox'; //工具栏中的名字与此名字需保持一致
WordBox.tagName = 'wordBox';  //需要添加的标签名

Quill.register(WordBox);
