surmon-china / vue-quill-editor

@quilljs editor component for @vuejs(2)
https://github.surmon.me/vue-quill-editor
MIT License
7.38k stars 1.03k forks source link

blot为link时,创建不成功;不清楚是不是quill有问题 #389

Open hwenjie opened 4 years ago

hwenjie commented 4 years ago

BUG REPORT TEMPLATE

image

image

wanWanWei commented 2 years ago

需要创建Link blot , 比如: // 自定义插入a链接 const Link = Quill.import('formats/link') class FileBlot extends Link { // 继承Link Blot static create(value) { let node if (value && !value.href) { // 适应原本的Link Blot node = super.create(value) } else { // 自定义Link Blot node = super.create(value.href) node.href = value.href // 不加会报错 node.download = value.innerText // 左键点击即下载 node.innerText = value.innerText } return node } } FileBlot.blotName = 'link' FileBlot.tagName = 'A' Quill.register(FileBlot)

然后再使用: this.quill.insertEmbed(self.cursorIndex, 'link', { href: self.fileURL, innerText: self.fileName })