Refactoring & 設定でTwemojiを使うかどうか切り替えられるように

This commit is contained in:
syuilo
2018-11-05 19:20:35 +09:00
parent 54e9147782
commit 65961bc15b
13 changed files with 95 additions and 58 deletions

View File

@@ -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;
}