quill
quill copied to clipboard
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?
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
`