diff --git a/src/HtmlUtils.tsx b/src/HtmlUtils.tsx index 95558fc9c882..a1e21f763052 100644 --- a/src/HtmlUtils.tsx +++ b/src/HtmlUtils.tsx @@ -617,7 +617,7 @@ export function bodyToHtml(content: IContent, highlights: Optional, op const match = BIGEMOJI_REGEX.exec(contentBodyTrimmed); const matched = match && match[0] && match[0].length === contentBodyTrimmed.length; - emojiBody = (matched || isAllHtmlEmoji); + emojiBody = matched || isAllHtmlEmoji; } const className = classNames({ diff --git a/src/autocomplete/Autocompleter.ts b/src/autocomplete/Autocompleter.ts index d58cc99d40ae..cb14ff4bf3a8 100644 --- a/src/autocomplete/Autocompleter.ts +++ b/src/autocomplete/Autocompleter.ts @@ -27,6 +27,7 @@ import { timeout } from "../utils/promise"; import AutocompleteProvider, { ICommand } from "./AutocompleteProvider"; import SpaceProvider from "./SpaceProvider"; import { TimelineRenderingType } from "../contexts/RoomContext"; +import { ICustomEmoji } from "../emojipicker/customemoji"; export interface ISelectionRange { beginning?: boolean; // whether the selection is in the first block of the editor or not diff --git a/src/components/views/messages/TextualBody.tsx b/src/components/views/messages/TextualBody.tsx index c57ffcd7a21e..b8a3bc4df915 100644 --- a/src/components/views/messages/TextualBody.tsx +++ b/src/components/views/messages/TextualBody.tsx @@ -439,6 +439,13 @@ export default class TextualBody extends React.Component { let target = e.target as HTMLLinkElement; // links processed by linkifyjs have their own handler so don't handle those here if (target.classList.contains(linkifyOpts.className as string)) return; + // handle clicking packs + const packUrl = target.getAttribute("data-mx-pack-url"); + if (packUrl) { + // it could be converted to a localHref -> therefore handle locally + e.preventDefault(); + window.location.hash = tryTransformPermalinkToLocalHref(packUrl); + } if (target.nodeName !== "A") { // Jump to parent as the `` may contain children, e.g. an anchor wrapping an inline code section target = target.closest("a"); diff --git a/src/editor/autocomplete.ts b/src/editor/autocomplete.ts index d5b3871c60c7..90f9f1e360e2 100644 --- a/src/editor/autocomplete.ts +++ b/src/editor/autocomplete.ts @@ -109,7 +109,14 @@ export default class AutocompleteWrapperModel { // command needs special handling for auto complete, but also renders as plain texts return [(this.partCreator as CommandPartCreator).command(text)]; case "customEmoji": - return [this.partCreator.customEmoji(text, completionId, completion.customEmoji?.roomId, completion.customEmoji?.eventId)]; + return [ + this.partCreator.customEmoji( + text, + completionId, + completion.customEmoji?.roomId, + completion.customEmoji?.eventId, + ), + ]; default: // used for emoji and other plain text completion replacement return this.partCreator.plainWithEmoji(text); diff --git a/src/editor/parts.ts b/src/editor/parts.ts index 7c2d8f92eb35..51a03033c962 100644 --- a/src/editor/parts.ts +++ b/src/editor/parts.ts @@ -466,7 +466,7 @@ class CustomEmojiPart extends PillPart implements ICustomEmojiPart { return { ...super.serialize(), roomId: this.roomId, - eventId: this.eventId + eventId: this.eventId, }; } } diff --git a/src/editor/serialize.ts b/src/editor/serialize.ts index 780194216dfa..83e8fa86c100 100644 --- a/src/editor/serialize.ts +++ b/src/editor/serialize.ts @@ -53,9 +53,11 @@ export function mdSerialize(model: EditorModel): string { `[${part.text.replace(/[[\\\]]/g, (c) => "\\" + c)}](${makeGenericPermalink(part.resourceId)})` ); case Type.CustomEmoji: - const customEmojiPart : ICustomEmojiPart = part; - if (customEmojiPart.roomId) { - const permalink = makeRoomPermalink(customEmojiPart.roomId, customEmojiPart.eventId); + if ((part as ICustomEmojiPart).roomId) { + const permalink = makeRoomPermalink( + (part as ICustomEmojiPart).roomId, + (part as ICustomEmojiPart).eventId, + ); return ( html + `