This commit is contained in:
Henry Jameson 2019-06-18 22:13:03 +03:00
parent 0032802f0a
commit 46e0122067
2 changed files with 11 additions and 13 deletions

View file

@ -6,7 +6,7 @@ import { take } from 'lodash'
* without having to give up the comfort of <input/> and <textarea/> elements
*
* Intended usage is:
* <emoji-input v-model="something">
* <EmojiInput v-model="something">
* <input v-model="something"/>
* </EmojiInput>
*

View file

@ -8,8 +8,7 @@
* Depending on data present one or both (or none) can be present, so if field
* doesn't support user linking you can just provide only emoji.
*/
export default function suggest (data) {
return input => {
export default data => input => {
const firstChar = input[0]
if (firstChar === ':' && data.emoji) {
return suggestEmoji(data.emoji)(input)
@ -18,10 +17,9 @@ export default function suggest (data) {
return suggestUsers(data.users)(input)
}
return []
}
}
export const suggestEmoji = (emojis) => input => {
export const suggestEmoji = emojis => input => {
const noPrefix = input.toLowerCase().substr(1)
return emojis
.filter(({ displayText }) => displayText.toLowerCase().startsWith(noPrefix))
@ -40,7 +38,7 @@ export const suggestEmoji = (emojis) => input => {
})
}
export const suggestUsers = (users) => input => {
export const suggestUsers = users => input => {
const noPrefix = input.toLowerCase().substr(1)
return users.filter(
user =>