Skip to content
This repository was archived by the owner on Jun 25, 2026. It is now read-only.

Commit d686847

Browse files
committed
feat(sandbox): add emoji & unicode recipe to sandbox examples
1 parent 56c302e commit d686847

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

sandbox/src/sandbox-recipes.const.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,31 @@ tw.timeline
9595
.wait(200)
9696
.type("Line three", { by: "char", interval: 60 });
9797
98+
await tw.play();`,
99+
},
100+
101+
{
102+
id: "emoji-unicode",
103+
title: "Emoji & Unicode",
104+
description: "Type and delete emoji clusters, flags, ZWJ sequences, and accented text using by: \"grapheme\" for correct user-perceived character handling.",
105+
category: "basics",
106+
code: `const tw = createTypewriter({ renderer });
107+
108+
// Each emoji spans a different number of codepoints but is one user-perceived character.
109+
// 🙂 = 1 codepoint
110+
// 👍🏽 = base + skin-tone modifier (2 codepoints)
111+
// 🇲🇦 = flag via two regional indicators (2 codepoints)
112+
// 👨‍👩‍👧‍👦 = ZWJ family sequence (7 codepoints joined by U+200D)
113+
// by: "grapheme" steps one perceived character at a time regardless of byte length.
114+
tw.timeline
115+
.type("🙂 👍🏽 🇲🇦 👨‍👩‍👧‍👦", { by: "grapheme", interval: 250 })
116+
.wait(600)
117+
.type("\\ncafé naïve façade", { by: "grapheme", interval: 70 })
118+
.wait(500)
119+
.delete(6, { by: "grapheme", interval: 110 })
120+
.type("résumé", { by: "grapheme", interval: 90 })
121+
.wait(800);
122+
98123
await tw.play();`,
99124
},
100125

0 commit comments

Comments
 (0)