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

Element is removed in blockEmbed, please help~! #412

Open phucblog opened 4 years ago

phucblog commented 4 years ago

Hi, i'm newbie to Quill, and bad English i have a problem when i try to create a BlockEmbed i want a tag has an img child and so i cant click on the image and open the link

<a href="https://github.com">
     <img src="">
</a>

it seemed fine when i use insertEmbed() on the first time and save the article. but when i reopen and edit the article, any a tag is removed on first load, to this

<img src="">

this is the block embed i used

class LinkImage extends BlockEmbed {
    static create(value) {
        const node = super.create()
        node.setAttribute('href', value.url)
        node.setAttribute('target', '_blank')

        const child = document.createElement('img')
        child.setAttribute('src', value.src)
                child.setAttribute('alt', value.alt)

        node.appendChild(child)
        return node
    }

    static value(domNode) {
        return domNode.querySelector('src')
    }
}

LinkImage.blotName = 'link-image'
LinkImage.tagName = 'a'
Quill.register(LinkImage)

ps: i use vue.js and vue-quill-editor

Hxmic commented 3 years ago

Have you solved it

Hxmic commented 3 years ago

I need you help