mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import Quill from 'quill'
|
|
|
|
// eslint-disable-next-line
|
|
const Embed = Quill.import('blots/embed') as any
|
|
export interface EmojiValue {
|
|
alt: string
|
|
src: string
|
|
id: string
|
|
}
|
|
class EmojiBlot extends Embed {
|
|
static blotName: string = 'emoji'
|
|
static tagName: string = 'img'
|
|
static classNames: string[] = ['w-6', 'h-6']
|
|
|
|
static create(value: HTMLImageElement) {
|
|
const node = super.create(value)
|
|
node.setAttribute('alt', value.alt)
|
|
node.setAttribute('src', value.src)
|
|
node.setAttribute('data-id', value.id)
|
|
node.classList.add(...EmojiBlot.classNames)
|
|
return node
|
|
}
|
|
|
|
static formats(node: HTMLImageElement): EmojiValue {
|
|
return {
|
|
alt: node.getAttribute('alt') ?? '',
|
|
src: node.getAttribute('src') ?? '',
|
|
id: node.getAttribute('data-id') ?? ''
|
|
}
|
|
}
|
|
|
|
static value(node: HTMLImageElement): EmojiValue {
|
|
return {
|
|
alt: node.getAttribute('alt') ?? '',
|
|
src: node.getAttribute('src') ?? '',
|
|
id: node.getAttribute('data-id') ?? ''
|
|
}
|
|
}
|
|
}
|
|
|
|
export default EmojiBlot
|