signal-desktop/ts/quill/emoji/blot.tsx
Sidney Keese fbf93374c1 Replace Draft with Quill for composition area
Co-authored-by: Sidney Keese <sidney@carbonfive.com>
2020-11-04 13:00:40 -06:00

36 lines
826 B
TypeScript

import React from 'react';
import Parchment from 'parchment';
import Quill from 'quill';
import { render } from 'react-dom';
import { Emoji } from '../../components/emoji/Emoji';
const Embed: typeof Parchment.Embed = Quill.import('blots/embed');
export class EmojiBlot extends Embed {
static blotName = 'emoji';
static tagName = 'span';
static className = 'emoji-blot';
static create(emoji: string): Node {
const node = super.create(undefined) as HTMLElement;
node.dataset.emoji = emoji;
const emojiSpan = document.createElement('span');
render(
<Emoji emoji={emoji} inline size={20}>
{emoji}
</Emoji>,
emojiSpan
);
node.appendChild(emojiSpan);
return node;
}
static value(node: HTMLElement): string | undefined {
return node.dataset.emoji;
}
}