diff --git a/src/features/compose/editor/nodes/mention-node.tsx b/src/features/compose/editor/nodes/mention-node.tsx index 5035e7293..7ea8646ae 100644 --- a/src/features/compose/editor/nodes/mention-node.tsx +++ b/src/features/compose/editor/nodes/mention-node.tsx @@ -16,28 +16,29 @@ import type { SerializedLexicalNode, Spread, } from 'lexical'; +import type { Mention as MentionEntity } from 'soapbox/schemas'; type SerializedMentionNode = Spread<{ - acct: string; + mention: MentionEntity; type: 'mention'; version: 1; }, SerializedLexicalNode>; class MentionNode extends DecoratorNode { - __acct: string; + __mention: MentionEntity; static getType(): string { return 'mention'; } static clone(node: MentionNode): MentionNode { - return new MentionNode(node.__acct, node.__key); + return new MentionNode(node.__mention, node.__key); } - constructor(acct: string, key?: NodeKey) { + constructor(mention: MentionEntity, key?: NodeKey) { super(key); - this.__acct = acct; + this.__mention = mention; } createDOM(config: EditorConfig): HTMLElement { @@ -49,20 +50,20 @@ class MentionNode extends DecoratorNode { } static importJSON(serializedNode: SerializedMentionNode): MentionNode { - const node = $createMentionNode(serializedNode.acct); + const node = $createMentionNode(serializedNode.mention); return node; } exportJSON(): SerializedMentionNode { return { type: 'mention', - acct: this.__acct, + mention: this.__mention, version: 1, }; } getTextContent(): string { - return `@${this.__acct}`; + return `@${this.__mention.acct}`; } canInsertTextBefore(): boolean { @@ -74,18 +75,15 @@ class MentionNode extends DecoratorNode { } decorate(): JSX.Element { - const acct = this.__acct; - const username = acct.split('@')[0]; - return ( - + ); } } -function $createMentionNode(acct: string): MentionNode { - const node = new MentionNode(acct); +function $createMentionNode(mention: MentionEntity): MentionNode { + const node = new MentionNode(mention); return $applyNodeReplacement(node); } diff --git a/src/features/compose/editor/plugins/autosuggest-plugin.tsx b/src/features/compose/editor/plugins/autosuggest-plugin.tsx index 93d032b42..e4fd4a2de 100644 --- a/src/features/compose/editor/plugins/autosuggest-plugin.tsx +++ b/src/features/compose/editor/plugins/autosuggest-plugin.tsx @@ -327,8 +327,8 @@ const AutosuggestPlugin = ({ node.setTextContent(`${suggestion} `); node.select(); } else { - const acct = selectAccount(getState(), suggestion)!.acct; - replaceMatch($createMentionNode(acct)); + const account = selectAccount(getState(), suggestion)!; + replaceMatch($createMentionNode(account)); } dispatch(clearComposeSuggestions(composeId));