core/emoji/auto_complete

Emoji auto complete.

Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

(require("core/emoji/auto_complete"))(root, textArea, hasSuggestionCallback, selectCallback)

Source:

Initialise the emoji auto complete.

Parameters:
Name Type Description
root Element

The root container element for the auto complete

textArea Element

The text area element to monitor for auto complete

hasSuggestionCallback function

Callback for when there are auto-complete suggestions

selectCallback function

Callback for when the user selects an emoji

Methods

(inner) addRecentEmoji(unified, shortName)

Source:

Add an emoji data to the set of recent emojis. The new set of recent emojis are saved in local storage.

Parameters:
Name Type Description
unified String

The char chodes for the emoji

shortName String

The emoji short name

(inner) getActiveEmojiSuggestion(root) → {Element|null}

Source:

Get the currently active emoji button element in the list of suggestions.

Parameters:
Name Type Description
root Element

The emoji auto complete container element

Returns:
Type
Element | null

(inner) getEmojiTextFromShortName(shortName) → {String|null}

Source:

Get the actual emoji string from the short name.

Parameters:
Name Type Description
shortName String

Emoji short name

Returns:
Type
String | null

(inner) getRecentEmojis() → {Array}

Source:

Get the list of recent emojis data from local storage.

Returns:
Type
Array

(inner) getShortNameFromText(text) → {String}

Source:

Remove the colon characters from the given text.

Parameters:
Name Type Description
text String

The text to process

Returns:
Type
String

(inner) getWordFromPosition(text, position) → {String}

Source:

Get the current word at the given position (index) within the text.

Parameters:
Name Type Description
text String

The text to process

position Number

The position (index) within the text to match the word

Returns:
Type
String

(inner) isCompleteShortName(text) → {Bool}

Source:

Check if the given text is a full short name, i.e. has leading and trialing colon characters.

Parameters:
Name Type Description
text String

The text to process

Returns:
Type
Bool

(inner) isPartialShortName(text) → {Bool}

Source:

Check if the given text is a partial short name, i.e. has a leading colon but no trailing colon.

Parameters:
Name Type Description
text String

The text to process

Returns:
Type
Bool

(async, inner) render(root, shortNames)

Source:

Render the auto complete list for the given short names.

Parameters:
Name Type Description
root Element

The root container for the emoji auto complete

shortNames Array

The list of short names for emoji suggestions to show

(inner) searchEmojis(searchTerm, limit) → {Array}

Source:

Get the list of emoji short names that include the given search term. If the search term is an empty string then the list of recently used emojis will be returned.

Parameters:
Name Type Description
searchTerm String

Text to match on

limit Number

Maximum number of results to return

Returns:
Type
Array

(inner) selectEmojiElement(element, selectCallback)

Source:

Trigger the select callback for the given emoji button element.

Parameters:
Name Type Description
element Element

The emoji button element

selectCallback function

The callback for when the user selects an emoji

(inner) selectNextEmojiSuggestion(root)

Source:

Make the next sibling to the current active emoji active.

Parameters:
Name Type Description
root Element

The emoji auto complete container element

(inner) selectPreviousEmojiSuggestion(root)

Source:

Make the previous sibling of the current active emoji active.

Parameters:
Name Type Description
root Element

The emoji auto complete container element