21 lines
333 B
TypeScript
Raw Normal View History

/**
* Emoji
*/
2018-06-17 19:55:39 +09:00
export type TextElementEmoji = {
2018-06-18 14:28:43 +09:00
type: 'emoji'
2018-06-17 19:55:39 +09:00
content: string
emoji: string
};
export default function(text: string) {
2018-08-15 20:27:49 +09:00
const match = text.match(/^:([a-zA-Z0-9+-_]+):/);
if (!match) return null;
const emoji = match[0];
return {
type: 'emoji',
content: emoji,
2018-08-15 20:27:49 +09:00
emoji: match[1]
2018-06-17 19:55:39 +09:00
} as TextElementEmoji;
}