Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After creating a custom blot, when I copy and paste a link, both the href and innerHTML of the link become undefined. How can I resolve this? #4183

Open
arafat813 opened this issue May 7, 2024 · 0 comments

Comments

@arafat813
Copy link

arafat813 commented May 7, 2024

After creating a custom blot, when I copy and paste a link, both the href and innerHTML of the link become undefined. How can I resolve this?

this is my code

const Inline = Quill.import('blots/inline')
        // @ts-ignore
        class Emoji extends Inline {
            static blotName = 'div'; // blot的名称,需要唯一,防止冲突
            static tagName = 'a'; // 渲染的标签名
            static create(value: any) {
                console.log(value)
                const dom = super.create(value)
                dom.setAttribute('href', value.href);
                // dom.setAttribute('id', 'downLoadFile');
                dom.setAttribute('rel', 'noopener noreferrer');
                dom.setAttribute('target', '_blank');
                dom.innerText = value.text
                return dom
            }
        }
        Quill.register({ 'formats/emoji': Emoji }, true)
```typescript



add code
`
 const cursorPosition = quill.current.getSelection()?.index || 0;
                    quill.current.insertEmbed(cursorPosition, 'div', {
                        href: obj.href,
                        text: obj.text
                    });
```typescript

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant