mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
fb9f4bb991
* feat: Allow replacing custom emoji image
33 lines
683 B
TypeScript
33 lines
683 B
TypeScript
import useShare from "@shared/hooks/useShare";
|
|
|
|
type Props = React.ImgHTMLAttributes<HTMLImageElement> & {
|
|
value: string;
|
|
size?: number | string;
|
|
/** Optional cache-busting key, e.g. updatedAt timestamp. */
|
|
cacheKey?: string;
|
|
};
|
|
|
|
export const CustomEmoji = ({
|
|
value,
|
|
size = 16,
|
|
cacheKey,
|
|
...props
|
|
}: Props) => {
|
|
const { shareId } = useShare();
|
|
let src = `/api/emojis.redirect?id=${value}`;
|
|
if (shareId) {
|
|
src += `&shareId=${shareId}`;
|
|
}
|
|
if (cacheKey) {
|
|
src += `&v=${encodeURIComponent(cacheKey)}`;
|
|
}
|
|
return (
|
|
<img
|
|
alt=""
|
|
src={src}
|
|
style={{ width: size, height: size, objectFit: "contain" }}
|
|
{...props}
|
|
/>
|
|
);
|
|
};
|