* feat: 统一并标准化eslint * lint: napcat.webui * lint: napcat.webui * lint: napcat.core * build: fix * lint: napcat.webui * refactor: 重构eslint * Update README.md
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;
|