From edb5914282f0547a9b829ca6d29fd79a8447ae4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 5 Apr 2023 20:46:36 +0200 Subject: [PATCH] Lexical: fix EmojiNode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../compose/editor/nodes/emoji-node.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/soapbox/features/compose/editor/nodes/emoji-node.tsx b/app/soapbox/features/compose/editor/nodes/emoji-node.tsx index 74ae000545..bd093306ca 100644 --- a/app/soapbox/features/compose/editor/nodes/emoji-node.tsx +++ b/app/soapbox/features/compose/editor/nodes/emoji-node.tsx @@ -29,16 +29,18 @@ class EmojiNode extends DecoratorNode { } 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 { 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 { } 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 { } 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 { } decorate(): JSX.Element { + console.log('decoratin', this); return ( );