Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions docs/src/examples/EmojiEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export default function App() {

const suggestions = useMemo(() => {
if (!open) return [];
// A trailing ":" (as in ":smile:") is part of the query - drop it.
const q = query.replace(/:$/, '').toLowerCase();
return EMOJIS.filter(emoji => emoji.shortcode.startsWith(q));
return EMOJIS.filter(emoji =>
emoji.shortcode.startsWith(query.toLowerCase())
Comment thread
hejsztynx marked this conversation as resolved.
);
}, [open, query]);

const openPicker = () => {
Expand All @@ -50,6 +50,16 @@ export default function App() {
const updateQuery = ({ text }: OnChangeMentionEvent) => {
setOpen(true);
setQuery(text);

if (text.endsWith(':')) {
const strippedQuery = text.slice(0, text.length - 1).toLowerCase();
const autoChosenEmoji = EMOJIS.find(
emoji => emoji.shortcode === strippedQuery
);
if (autoChosenEmoji) {
pick(autoChosenEmoji);
}
}
};

const pick = (emoji: Emoji) => {
Expand All @@ -61,7 +71,7 @@ export default function App() {
};

return (
<View style={styles.container}>
<View>
<EnrichedTextInput
ref={ref}
style={styles.input}
Expand Down Expand Up @@ -102,16 +112,20 @@ const htmlStyle: HtmlStyle = {
};

const styles = StyleSheet.create({
container: { gap: 8 },
input: {
fontSize: 18,
color: '#232736',
padding: 12,
marginBottom: 186,
borderRadius: 12,
minHeight: 96,
backgroundColor: '#eef0ff',
},
picker: {
position: 'absolute',
top: '100%',
marginTop: -170,
width: '100%',
borderWidth: 1,
borderColor: '#dfe3f5',
borderRadius: 12,
Expand Down
8 changes: 6 additions & 2 deletions docs/src/examples/MentionOnlyEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function App() {
};

return (
<View style={styles.container}>
<View>
<EnrichedTextInput
ref={ref}
style={styles.input}
Expand Down Expand Up @@ -118,16 +118,20 @@ const htmlStyle: HtmlStyle = {
};

const styles = StyleSheet.create({
container: { gap: 8 },
input: {
fontSize: 18,
color: '#232736',
padding: 12,
marginBottom: 192,
borderRadius: 12,
minHeight: 96,
backgroundColor: '#eef0ff',
},
picker: {
position: 'absolute',
top: '100%',
marginTop: -176,
width: '100%',
borderWidth: 1,
borderColor: '#dfe3f5',
borderRadius: 12,
Expand Down
5 changes: 4 additions & 1 deletion docs/src/examples/TextAlignmentEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export default function App() {
<Pressable
key={alignment}
style={[styles.button, isActive && styles.buttonActive]}
onPress={() => ref.current?.setTextAlignment(alignment)}>
onPress={() => {
const alignmentToSet = isActive ? 'auto' : alignment;
ref.current?.setTextAlignment(alignmentToSet);
}}>
Comment thread
hejsztynx marked this conversation as resolved.
<Text style={[styles.text, isActive && styles.textActive]}>
{alignment}
</Text>
Expand Down
Loading