Refactoring & 設定でTwemojiを使うかどうか切り替えられるように
This commit is contained in:
@@ -8,27 +8,26 @@ export type TextElementEmoji = {
|
||||
type: 'emoji';
|
||||
content: string;
|
||||
emoji?: string;
|
||||
raw?: string;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
export default function(text: string) {
|
||||
const name = text.match(/^:([a-zA-Z0-9+_-]+):/);
|
||||
if (name) {
|
||||
const [content, emoji] = name;
|
||||
return {
|
||||
type: 'emoji',
|
||||
content: name[0],
|
||||
name: name[1]
|
||||
} as TextElementEmoji;
|
||||
}
|
||||
const unicode = text.match(emojiRegex);
|
||||
if (unicode) {
|
||||
const [content, emoji] = unicode;
|
||||
return {
|
||||
type: 'emoji',
|
||||
content,
|
||||
emoji
|
||||
} as TextElementEmoji;
|
||||
}
|
||||
const unicode = text.match(emojiRegex);
|
||||
if (unicode) {
|
||||
const [content, raw] = unicode;
|
||||
return {
|
||||
type: 'emoji',
|
||||
content,
|
||||
raw
|
||||
} as TextElementEmoji;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user