Lexical: fix EmojiNode
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
33d8ad1774
commit
edb5914282
1 changed files with 16 additions and 1 deletions
|
@ -29,16 +29,18 @@ class EmojiNode extends DecoratorNode<JSX.Element> {
|
|||
}
|
||||
|
||||
static clone(node: EmojiNode): EmojiNode {
|
||||
return new EmojiNode(node.__name, node.__key);
|
||||
return new EmojiNode(node.__name, node.__src);
|
||||
}
|
||||
|
||||
constructor(name: string, src: string, key?: NodeKey) {
|
||||
console.log(name, src);
|
||||
super(key);
|
||||
this.__name = name;
|
||||
this.__src = src;
|
||||
}
|
||||
|
||||
createDOM(config: EditorConfig): HTMLElement {
|
||||
console.log('creating');
|
||||
const span = document.createElement('span');
|
||||
const theme = config.theme;
|
||||
const className = theme.emoji;
|
||||
|
@ -48,7 +50,12 @@ class EmojiNode extends DecoratorNode<JSX.Element> {
|
|||
return span;
|
||||
}
|
||||
|
||||
updateDOM(): false {
|
||||
return false;
|
||||
}
|
||||
|
||||
exportDOM(): DOMExportOutput {
|
||||
console.log('exporting');
|
||||
const element = document.createElement('img');
|
||||
element.setAttribute('src', this.__src);
|
||||
element.setAttribute('alt', this.__name);
|
||||
|
@ -57,6 +64,7 @@ class EmojiNode extends DecoratorNode<JSX.Element> {
|
|||
}
|
||||
|
||||
static importJSON(serializedNode: SerializedEmojiNode): EmojiNode {
|
||||
console.log('importing json');
|
||||
const { name, src } =
|
||||
serializedNode;
|
||||
const node = $createEmojiNode(name, src);
|
||||
|
@ -64,6 +72,12 @@ class EmojiNode extends DecoratorNode<JSX.Element> {
|
|||
}
|
||||
|
||||
exportJSON(): SerializedEmojiNode {
|
||||
console.log('exporting json', {
|
||||
name: this.__name,
|
||||
src: this.__src,
|
||||
type: 'emoji',
|
||||
version: 1,
|
||||
});
|
||||
return {
|
||||
name: this.__name,
|
||||
src: this.__src,
|
||||
|
@ -81,6 +95,7 @@ class EmojiNode extends DecoratorNode<JSX.Element> {
|
|||
}
|
||||
|
||||
decorate(): JSX.Element {
|
||||
console.log('decoratin', this);
|
||||
return (
|
||||
<Emoji src={this.__src} alt={this.__name} className='emojione h-4 w-4' />
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue