diff --git a/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx b/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx index 31acd2c..b9fee87 100644 --- a/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx +++ b/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx @@ -32,14 +32,14 @@ function UnknownRoomMentionItem({ const mx = useMatrixClient(); const roomAlias: string = roomAliasFromQueryText(mx, query.text); + const handleSelect = () => handleAutocomplete(roomAlias, roomAlias); + return ( ) => - onTabPress(evt, () => handleAutocomplete(roomAlias, roomAlias)) - } - onClick={() => handleAutocomplete(roomAlias, roomAlias)} + onKeyDown={(evt: ReactKeyboardEvent) => onTabPress(evt, handleSelect)} + onClick={handleSelect} before={ @@ -140,15 +140,17 @@ export function RoomMentionAutocomplete({ const avatarUrl = getRoomAvatarUrl(mx, room); const iconSrc = !dm && joinRuleToIconSrc(Icons, room.getJoinRule(), room.isSpaceRoom()); + const handleSelect = () => handleAutocomplete(room.getCanonicalAlias() ?? rId, room.name); + return ( ) => - onTabPress(evt, () => handleAutocomplete(rId, room.name)) + onTabPress(evt, handleSelect) } - onClick={() => handleAutocomplete(room.getCanonicalAlias() ?? rId, room.name)} + onClick={handleSelect} after={ {room.getCanonicalAlias() ?? ''} diff --git a/src/app/components/editor/input.ts b/src/app/components/editor/input.ts index 37aa724..91386a8 100644 --- a/src/app/components/editor/input.ts +++ b/src/app/components/editor/input.ts @@ -74,7 +74,7 @@ const elementToInlineNode = (node: Element): MentionElement | EmoticonElement | if (typeof href !== 'string') return undefined; const [mxId] = parseMatrixToUrl(href); if (mxId) { - return createMentionElement(mxId, mxId, false); + return createMentionElement(mxId, parseNodeText(node) || mxId, false); } } return undefined; diff --git a/src/app/plugins/react-custom-html-parser.tsx b/src/app/plugins/react-custom-html-parser.tsx index aba5997..09f09d8 100644 --- a/src/app/plugins/react-custom-html-parser.tsx +++ b/src/app/plugins/react-custom-html-parser.tsx @@ -180,10 +180,7 @@ export const getReactCustomHtmlParser = ( mentionPrefix === '#' ? getRoomWithCanonicalAlias(mx, mentionId) : mx.getRoom(mentionId); - const mentionName = mentionRoom?.name; - const mentionDisplayName = - mentionName && (mentionName.startsWith('#') ? mentionName : `#${mentionName}`); return ( - {mentionDisplayName ?? mentionId} + {domToReact(children, opts)} ); }