import Quill from 'quill'; // eslint-disable-next-line const BlockEmbed = Quill.import('blots/block/embed') as any export interface ReplyBlockValue { messageId: string } class ReplyBlock extends BlockEmbed { static blotName = 'reply'; static tagName = 'div'; static classNames = [ 'p-2', 'select-none', 'bg-default-100', 'rounded-md', 'pointer-events-none', ]; static create (value: ReplyBlockValue) { const node = super.create(); node.setAttribute('data-message-id', value.messageId); node.setAttribute('contenteditable', 'false'); node.classList.add(...ReplyBlock.classNames); const innerDom = document.createElement('div'); innerDom.classList.add('text-sm', 'text-default-500', 'relative'); const svgContainer = document.createElement('div'); svgContainer.classList.add('w-3', 'h-3', 'absolute', 'top-0', 'right-0'); const svg = ' '; svgContainer.innerHTML = svg; innerDom.innerHTML = `消息ID:${value.messageId}`; innerDom.appendChild(svgContainer); node.appendChild(innerDom); return node; } static value (node: HTMLElement): ReplyBlockValue { return { messageId: node.getAttribute('data-message-id') || '', }; } } export default ReplyBlock;