Files
Tom MoorandClaude Opus 5 4b4c7d3281 chore: React 19 upgrade (#13562)
* React 19 upgrade

Bumps react and react-dom to 19.2.8, with the dependency changes React 19
requires: react-is 19, @types/react 19, @types/react-dom 19,
react-helmet-async 3 and react-avatar-editor 15 (which now ships its own
types). framer-motion moves to 13 — its v6 types reference React.ReactHTML,
removed from @types/react 19.

The type changes fall into a few classes:

- The global JSX namespace is gone, so JSX.Element becomes React.JSX.Element
  and the custom element declarations move into a module augmentation.
- useRef() now requires an initial value.
- A ref created with a null initial value is typed nullable, so consumers
  that accept one are widened to RefObject<T | null>.
- React.ReactChild was removed; tooltips take React.ReactNode.
- Ref callbacks may only return a cleanup function. react-dnd connectors
  return the connected node, so useDragRef and useDropRef wrap useDrag and
  useDrop and hand back a ref callback.

react-i18next stays on v12: i18next 23 drops compatibilityJSON "v3", which
would rewrite all 64 _plural keys across every locale.

outline-icons, oy-vey and react-waypoint have no release that lists React 19
as a peer. All three render correctly under it; the install reports them as
unmet peers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Remove react-helmet and forwardRef

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 22:22:50 -04:00

67 lines
2.0 KiB
TypeScript

import { isUUID } from "validator";
import { getEmojiFromName } from "../editor/lib/emoji";
import { CustomEmoji } from "./CustomEmoji";
type Props = {
/** The text to render, which may contain emoji shortcodes like :smile: or :uuid: */
children: string;
/** Size of rendered custom emojis */
emojiSize?: number | string;
};
// Matches emoji shortcodes like :smile: or :550e8400-e29b-41d4-a716-446655440000:
const emojiShortcodeRegex = /:([a-zA-Z0-9_-]+):/g;
/**
* Renders text with embedded emoji shortcodes. Standard emoji shortcodes like
* :smile: are converted to native emoji characters, while UUID shortcodes are
* rendered as custom emoji images.
*
* @param props.children - the text to render, which may contain emoji shortcodes.
* @param props.emojiSize - size of rendered custom emojis.
* @returns a React element with text and inline emojis.
*/
export function EmojiText({ children, emojiSize = "1em" }: Props) {
const parts: (string | React.JSX.Element)[] = [];
let lastIndex = 0;
let match: RegExpExecArray | null;
let key = 0;
while ((match = emojiShortcodeRegex.exec(children)) !== null) {
// Add text before the match
if (match.index > lastIndex) {
parts.push(children.slice(lastIndex, match.index));
}
const shortcode = match[1];
if (isUUID(shortcode)) {
// Custom emoji - render as image
parts.push(
<CustomEmoji key={key++} value={shortcode} size={emojiSize} />
);
} else {
// Standard emoji - convert to native character
const emoji = getEmojiFromName(shortcode);
if (emoji !== "?") {
parts.push(emoji);
} else {
// Unknown shortcode, keep original text
parts.push(match[0]);
}
}
lastIndex = match.index + match[0].length;
}
// Add remaining text after last match
if (lastIndex < children.length) {
parts.push(children.slice(lastIndex));
}
// Reset regex state for next call
emojiShortcodeRegex.lastIndex = 0;
return <>{parts}</>;
}