How to use the emoji-mart.emojiIndex.search function in emoji-mart

To help you get started, weโ€™ve selected a few emoji-mart examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / emoji-mart / emoji-mart-tests.tsx View on Github external
if (match && match[2]) {
        // smiley is closed
        let emoji = emojiIndex.emojis[match[1]];
        const isSingleEmoji = (e: EmojiEntry): e is EmojiData => {
            return 'name' in e;
        };
        const isNativeEmoji = (e: EmojiData): e is BaseEmoji => {
            return 'native' in e;
        };
        if (!isSingleEmoji(emoji)) {
            emoji = emoji[1];
        }
        const native = (isNativeEmoji(emoji) && emoji.native) || '';
        setSearch(search.replace(match[0], native));
    } else if (match && match[1].length > 2) {
        suggestions = emojiIndex.search(match[1]) || [];
    }
    return (
        <div>
            {suggestions.map(emoji =&gt; {
                return 'native' in emoji &amp;&amp; <span>{emoji.native}</span>;
            })}
            {match &amp;&amp; <div>{match[0]}</div>}
            <input value="{search}" placeholder="enter a message..." type="text">
        </div>
    );
};
github AugurProject / augur / packages / orbit-web / src / containers / SendMessage.js View on Github external
const handleInputChange = React.useCallback(() => {
    if (!inputRef.current) return
    const inputValue = inputRef.current.value
    const lastWord = inputValue.split(' ').pop()
    const emojiPickerActive = lastWord.startsWith(':') && useEmojis
    const lastEmojiIdx = emojiPickerActive ? inputValue.lastIndexOf(':') : null
    const emojiSearch = emojiPickerActive ? inputValue.slice(lastEmojiIdx) : null
    let emojiResults = emojiSearch ? emojiIndex.search(emojiSearch) : []

    if (emojiResults.length === 0) {
      // Slice the ':' prefix so we search for emojis instead of emoticons so
      // ':smile' => 'smile'
      // This is needed because we can also search for ':)' which requires the
      // ':' prefix
      emojiResults = emojiSearch ? emojiIndex.search(emojiSearch.slice(1)) : []
    }

    setInputValue(inputValue)
    setEmojiResults(emojiResults)
    setEmojiPickerActive(emojiPickerActive)
  }, [useEmojis])
github orbitdb / orbit-web / src / containers / SendMessage.js View on Github external
const handleInputChange = React.useCallback(() => {
    if (!inputRef.current) return
    const inputValue = inputRef.current.value
    const lastWord = inputValue.split(' ').pop()
    const emojiPickerActive = lastWord.startsWith(':') && useEmojis
    const lastEmojiIdx = emojiPickerActive ? inputValue.lastIndexOf(':') : null
    const emojiSearch = emojiPickerActive ? inputValue.slice(lastEmojiIdx) : null
    let emojiResults = emojiSearch ? emojiIndex.search(emojiSearch) : []

    if (emojiResults.length === 0) {
      // Slice the ':' prefix so we search for emojis instead of emoticons so
      // ':smile' => 'smile'
      // This is needed because we can also search for ':)' which requires the
      // ':' prefix
      emojiResults = emojiSearch ? emojiIndex.search(emojiSearch.slice(1)) : []
    }

    setInputValue(inputValue)
    setEmojiResults(emojiResults)
    setEmojiPickerActive(emojiPickerActive)
  }, [useEmojis])
github AugurProject / augur / packages / orbit-web / src / containers / SendMessage.js View on Github external
const handleInputChange = React.useCallback(() => {
    if (!inputRef.current) return
    const inputValue = inputRef.current.value
    const lastWord = inputValue.split(' ').pop()
    const emojiPickerActive = lastWord.startsWith(':') && useEmojis
    const lastEmojiIdx = emojiPickerActive ? inputValue.lastIndexOf(':') : null
    const emojiSearch = emojiPickerActive ? inputValue.slice(lastEmojiIdx) : null
    let emojiResults = emojiSearch ? emojiIndex.search(emojiSearch) : []

    if (emojiResults.length === 0) {
      // Slice the ':' prefix so we search for emojis instead of emoticons so
      // ':smile' => 'smile'
      // This is needed because we can also search for ':)' which requires the
      // ':' prefix
      emojiResults = emojiSearch ? emojiIndex.search(emojiSearch.slice(1)) : []
    }

    setInputValue(inputValue)
    setEmojiResults(emojiResults)
    setEmojiPickerActive(emojiPickerActive)
  }, [useEmojis])
github orbitdb / orbit-web / src / containers / SendMessage.js View on Github external
const handleInputChange = React.useCallback(() => {
    if (!inputRef.current) return
    const inputValue = inputRef.current.value
    const lastWord = inputValue.split(' ').pop()
    const emojiPickerActive = lastWord.startsWith(':') && useEmojis
    const lastEmojiIdx = emojiPickerActive ? inputValue.lastIndexOf(':') : null
    const emojiSearch = emojiPickerActive ? inputValue.slice(lastEmojiIdx) : null
    let emojiResults = emojiSearch ? emojiIndex.search(emojiSearch) : []

    if (emojiResults.length === 0) {
      // Slice the ':' prefix so we search for emojis instead of emoticons so
      // ':smile' => 'smile'
      // This is needed because we can also search for ':)' which requires the
      // ':' prefix
      emojiResults = emojiSearch ? emojiIndex.search(emojiSearch.slice(1)) : []
    }

    setInputValue(inputValue)
    setEmojiResults(emojiResults)
    setEmojiPickerActive(emojiPickerActive)
  }, [useEmojis])
github keybase / client / shared / chat / conversation / input-area / normal / index.tsx View on Github external
const emojiDatasource = (filter: string) => ({
  data: emojiPrepass.test(filter) ? emojiIndex.search(filter) : [],
  useSpaces: false,
})
const emojiRenderer = (item: {colons: string}, selected: boolean) => (
github GetStream / react-activity-feed / src / components / Textarea.js View on Github external
dataProvider: (token) => {
              const emojis = emojiIndex.search(token) || [];
              return emojis.slice(0, 10);
            },
            component: AutocompleteItem,