snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
17
packages/gazzodown/src/emoji/BigEmojiBlock.tsx
Normal file
17
packages/gazzodown/src/emoji/BigEmojiBlock.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import type * as MessageParser from '@rocket.chat/message-parser';
|
||||
|
||||
import BigEmojiElement from './BigEmojiElement';
|
||||
|
||||
export type BigEmojiBlockProps = {
|
||||
emoji: MessageParser.Emoji[];
|
||||
};
|
||||
|
||||
const BigEmojiBlock = ({ emoji }: BigEmojiBlockProps) => (
|
||||
<div role='presentation'>
|
||||
{emoji.map((emoji, index) => (
|
||||
<BigEmojiElement key={index} {...emoji} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
export default BigEmojiBlock;
|
||||
9
packages/gazzodown/src/emoji/BigEmojiElement.tsx
Normal file
9
packages/gazzodown/src/emoji/BigEmojiElement.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import type * as MessageParser from '@rocket.chat/message-parser';
|
||||
|
||||
import Emoji from './Emoji';
|
||||
|
||||
export type BigEmojiElementProps = MessageParser.Emoji;
|
||||
|
||||
const BigEmojiElement = (emoji: BigEmojiElementProps) => <Emoji big {...emoji} />;
|
||||
|
||||
export default BigEmojiElement;
|
||||
32
packages/gazzodown/src/emoji/Emoji.tsx
Normal file
32
packages/gazzodown/src/emoji/Emoji.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import type * as MessageParser from '@rocket.chat/message-parser';
|
||||
import { useMemo, useContext, memo } from 'react';
|
||||
|
||||
import { MarkupInteractionContext } from '../MarkupInteractionContext';
|
||||
import EmojiRenderer from './EmojiRenderer';
|
||||
import PlainSpan from '../elements/PlainSpan';
|
||||
|
||||
export type EmojiProps = MessageParser.Emoji & {
|
||||
big?: boolean;
|
||||
preview?: boolean;
|
||||
};
|
||||
|
||||
const Emoji = ({ big = false, preview = false, ...emoji }: EmojiProps) => {
|
||||
const { convertAsciiToEmoji, useEmoji } = useContext(MarkupInteractionContext);
|
||||
|
||||
const asciiEmoji = useMemo(
|
||||
() => ('shortCode' in emoji && emoji.value.value !== emoji.shortCode ? emoji.value.value : undefined),
|
||||
[emoji],
|
||||
);
|
||||
|
||||
if (!useEmoji && 'shortCode' in emoji) {
|
||||
return <PlainSpan text={emoji.shortCode === emoji.value.value ? `:${emoji.shortCode}:` : emoji.value.value} />;
|
||||
}
|
||||
|
||||
if (!convertAsciiToEmoji && asciiEmoji) {
|
||||
return <PlainSpan text={asciiEmoji} />;
|
||||
}
|
||||
|
||||
return <EmojiRenderer big={big} preview={preview} {...emoji} />;
|
||||
};
|
||||
|
||||
export default memo(Emoji);
|
||||
10
packages/gazzodown/src/emoji/EmojiElement.tsx
Normal file
10
packages/gazzodown/src/emoji/EmojiElement.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import type * as MessageParser from '@rocket.chat/message-parser';
|
||||
import { memo } from 'react';
|
||||
|
||||
import Emoji from './Emoji';
|
||||
|
||||
export type EmojiElementProps = MessageParser.Emoji;
|
||||
|
||||
const EmojiElement = (emoji: EmojiElementProps) => <Emoji {...emoji} />;
|
||||
|
||||
export default memo(EmojiElement);
|
||||
47
packages/gazzodown/src/emoji/EmojiRenderer.tsx
Normal file
47
packages/gazzodown/src/emoji/EmojiRenderer.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { MessageEmoji, ThreadMessageEmoji } from '@rocket.chat/fuselage';
|
||||
import type * as MessageParser from '@rocket.chat/message-parser';
|
||||
import { useContext, memo } from 'react';
|
||||
|
||||
import { MarkupInteractionContext } from '../MarkupInteractionContext';
|
||||
import { useEmojiDescriptors } from './useEmojiDescriptors';
|
||||
import PlainSpan from '../elements/PlainSpan';
|
||||
|
||||
type EmojiProps = MessageParser.Emoji & {
|
||||
big?: boolean;
|
||||
preview?: boolean;
|
||||
};
|
||||
|
||||
const EmojiRenderer = ({ big = false, preview = false, ...emoji }: EmojiProps) => {
|
||||
const { useEmoji } = useContext(MarkupInteractionContext);
|
||||
|
||||
const { descriptors, sanitizedFallback } = useEmojiDescriptors(emoji);
|
||||
|
||||
//handles unicode emojis
|
||||
if (!useEmoji) {
|
||||
return <PlainSpan text={descriptors?.map(({ name, content }) => name || content).join('') ?? sanitizedFallback} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{descriptors?.map(({ name, className, image, content }, i) => (
|
||||
<span key={i} title={name}>
|
||||
{preview ? (
|
||||
<ThreadMessageEmoji className={className} name={name} image={image}>
|
||||
{content}
|
||||
</ThreadMessageEmoji>
|
||||
) : (
|
||||
<MessageEmoji big={big} className={className} name={name} image={image}>
|
||||
{content}
|
||||
</MessageEmoji>
|
||||
)}
|
||||
</span>
|
||||
)) ?? (
|
||||
<span title={sanitizedFallback} role='img' aria-label={sanitizedFallback.charAt(0) === ':' ? sanitizedFallback : undefined}>
|
||||
{sanitizedFallback}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(EmojiRenderer);
|
||||
17
packages/gazzodown/src/emoji/PreviewBigEmojiBlock.tsx
Normal file
17
packages/gazzodown/src/emoji/PreviewBigEmojiBlock.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import type * as MessageParser from '@rocket.chat/message-parser';
|
||||
|
||||
import PreviewEmojiElement from './PreviewEmojiElement';
|
||||
|
||||
export type PreviewBigEmojiBlockProps = {
|
||||
emoji: MessageParser.Emoji[];
|
||||
};
|
||||
|
||||
const PreviewBigEmojiBlock = ({ emoji }: PreviewBigEmojiBlockProps) => (
|
||||
<>
|
||||
{emoji.map((emoji, index) => (
|
||||
<PreviewEmojiElement key={index} {...emoji} />
|
||||
))}
|
||||
</>
|
||||
);
|
||||
|
||||
export default PreviewBigEmojiBlock;
|
||||
9
packages/gazzodown/src/emoji/PreviewEmojiElement.tsx
Normal file
9
packages/gazzodown/src/emoji/PreviewEmojiElement.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import type * as MessageParser from '@rocket.chat/message-parser';
|
||||
|
||||
import Emoji from './Emoji';
|
||||
|
||||
export type PreviewEmojiElementProps = MessageParser.Emoji;
|
||||
|
||||
const PreviewEmojiElement = (emoji: PreviewEmojiElementProps) => <Emoji preview {...emoji} />;
|
||||
|
||||
export default PreviewEmojiElement;
|
||||
20
packages/gazzodown/src/emoji/useEmojiDescriptors.ts
Normal file
20
packages/gazzodown/src/emoji/useEmojiDescriptors.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type * as MessageParser from '@rocket.chat/message-parser';
|
||||
import DOMPurify from 'dompurify';
|
||||
import { useContext, useMemo } from 'react';
|
||||
|
||||
import { MarkupInteractionContext } from '../MarkupInteractionContext';
|
||||
|
||||
export const useEmojiDescriptors = (emoji: MessageParser.Emoji) => {
|
||||
const { detectEmoji } = useContext(MarkupInteractionContext);
|
||||
|
||||
const fallback = useMemo(() => ('unicode' in emoji ? emoji.unicode : `:${emoji.shortCode ?? emoji.value.value}:`), [emoji]);
|
||||
|
||||
const sanitizedFallback = useMemo(() => DOMPurify.sanitize(fallback), [fallback]);
|
||||
|
||||
const descriptors = useMemo(() => {
|
||||
const detected = detectEmoji?.(sanitizedFallback);
|
||||
return detected?.length !== 0 ? detected : undefined;
|
||||
}, [detectEmoji, sanitizedFallback]);
|
||||
|
||||
return { descriptors, sanitizedFallback };
|
||||
};
|
||||
Reference in New Issue
Block a user