git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
commitf673621d8a7581810a8d8006ad91c0fd92c03c6e authorMark <mark.eibes@gmail.com> dateThu 19 Feb 2026, 18:41 (7 months ago) parente8955a1
2 files changed+11−1
example-macos/src/Demo/Chat.js+6 example-macos/src/Demo/Chat.purs+5−1
example-macos/src/Demo/Chat.js+6
@@ -137,6 +137,12 @@ export const setTimeout_ = (ms, fn) => {
137137export const emojiDir =
138138 "/Users/mark/Developer/purescript-yoga-react-native/example-macos/macos/YogaReactExample-macOS/emoji";
139139
140+// Replace custom emoji shortcodes with a placeholder character for sizing
141+export const stripCustomEmoji_ = (emojiMap) => (str) =>
142+ str.replace(/:([a-zA-Z0-9_]+):/g, (m, name) =>
143+ emojiMap[name] ? "\u2003" : m
144+ );
145+
140146// Returns the custom emoji filename if the message is a single custom emoji, otherwise null
141147export const singleCustomEmoji_ = (emojiMap) => (str) => {
142148 var trimmed = str.trim();
example-macos/src/Demo/Chat.purs+5−1
@@ -67,8 +67,12 @@ foreign import isSingleEmoji :: String -> Boolean
6767foreign import replaceEmoji :: String -> String
6868foreign import setTimeout_ :: EffectFn2 Int (Effect Unit) Unit
6969foreign import emojiDir :: String
70+foreign import stripCustomEmoji_ :: EmojiMap -> String -> String
7071foreign import singleCustomEmoji_ :: EmojiMap -> String -> Nullable String
7172
73+stripCustomEmoji :: String -> String
74+stripCustomEmoji = stripCustomEmoji_ customEmojiMap
75+
7276singleCustomEmoji :: String -> Maybe String
7377singleCustomEmoji = toMaybe <<< singleCustomEmoji_ customEmojiMap
7478
@@ -422,7 +426,7 @@ chatDemo = component "ChatDemo" \dp -> React.do
422426 , opacity: 0.0
423427 }
424428 }
425− msg.body
429+ (stripCustomEmoji msg.body)
426430 , nativeRichTextLabel
427431 { text: msg.body
428432 , emojiMap: customEmojiMap