mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-21 14:09:17 +02:00
display custom emojis
This commit is contained in:
5
.changeset/happy-cats-arrive.md
Normal file
5
.changeset/happy-cats-arrive.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"nostrudel": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Display custom emojis
|
23
src/components/embed-types/emoji.tsx
Normal file
23
src/components/embed-types/emoji.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Image } from "@chakra-ui/react";
|
||||||
|
import { EmbedableContent, embedJSX } from "../../helpers/embeds";
|
||||||
|
import { DraftNostrEvent, NostrEvent } from "../../types/nostr-event";
|
||||||
|
|
||||||
|
export function embedEmoji(content: EmbedableContent, note: NostrEvent | DraftNostrEvent) {
|
||||||
|
return embedJSX(content, {
|
||||||
|
regexp: /:([a-zA-Z0-9]+):/i,
|
||||||
|
render: (match) => {
|
||||||
|
console.log(match);
|
||||||
|
|
||||||
|
const emojiTag = note.tags.find(
|
||||||
|
(tag) => tag[0] === "emoji" && tag[1].toLowerCase() === match[1].toLowerCase() && tag[2]
|
||||||
|
);
|
||||||
|
if (emojiTag) {
|
||||||
|
return (
|
||||||
|
<Image src={emojiTag[2]} height="1.5em" display="inline-block" verticalAlign="middle" title={match[1]} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
name: "emoji",
|
||||||
|
});
|
||||||
|
}
|
@@ -4,3 +4,4 @@ export * from "./music";
|
|||||||
export * from "./common";
|
export * from "./common";
|
||||||
export * from "./youtube";
|
export * from "./youtube";
|
||||||
export * from "./nostr";
|
export * from "./nostr";
|
||||||
|
export * from "./emoji";
|
||||||
|
@@ -18,6 +18,7 @@ import {
|
|||||||
renderSpotifyUrl,
|
renderSpotifyUrl,
|
||||||
renderTidalUrl,
|
renderTidalUrl,
|
||||||
renderVideoUrl,
|
renderVideoUrl,
|
||||||
|
embedEmoji,
|
||||||
} from "../embed-types";
|
} from "../embed-types";
|
||||||
import { ImageGalleryProvider } from "../image-gallery";
|
import { ImageGalleryProvider } from "../image-gallery";
|
||||||
import { useTrusted } from "./trust";
|
import { useTrusted } from "./trust";
|
||||||
@@ -47,6 +48,7 @@ function buildContents(event: NostrEvent | DraftNostrEvent, trusted = false) {
|
|||||||
content = embedNostrLinks(content);
|
content = embedNostrLinks(content);
|
||||||
content = embedNostrMentions(content, event);
|
content = embedNostrMentions(content, event);
|
||||||
content = embedNostrHashtags(content, event);
|
content = embedNostrHashtags(content, event);
|
||||||
|
content = embedEmoji(content, event);
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user