review
This commit is contained in:
parent
0032802f0a
commit
46e0122067
2 changed files with 11 additions and 13 deletions
|
@ -6,7 +6,7 @@ import { take } from 'lodash'
|
||||||
* without having to give up the comfort of <input/> and <textarea/> elements
|
* without having to give up the comfort of <input/> and <textarea/> elements
|
||||||
*
|
*
|
||||||
* Intended usage is:
|
* Intended usage is:
|
||||||
* <emoji-input v-model="something">
|
* <EmojiInput v-model="something">
|
||||||
* <input v-model="something"/>
|
* <input v-model="something"/>
|
||||||
* </EmojiInput>
|
* </EmojiInput>
|
||||||
*
|
*
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
* Depending on data present one or both (or none) can be present, so if field
|
* 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.
|
* doesn't support user linking you can just provide only emoji.
|
||||||
*/
|
*/
|
||||||
export default function suggest (data) {
|
export default data => input => {
|
||||||
return input => {
|
|
||||||
const firstChar = input[0]
|
const firstChar = input[0]
|
||||||
if (firstChar === ':' && data.emoji) {
|
if (firstChar === ':' && data.emoji) {
|
||||||
return suggestEmoji(data.emoji)(input)
|
return suggestEmoji(data.emoji)(input)
|
||||||
|
@ -19,9 +18,8 @@ export default function suggest (data) {
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export const suggestEmoji = (emojis) => input => {
|
export const suggestEmoji = emojis => input => {
|
||||||
const noPrefix = input.toLowerCase().substr(1)
|
const noPrefix = input.toLowerCase().substr(1)
|
||||||
return emojis
|
return emojis
|
||||||
.filter(({ displayText }) => displayText.toLowerCase().startsWith(noPrefix))
|
.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)
|
const noPrefix = input.toLowerCase().substr(1)
|
||||||
return users.filter(
|
return users.filter(
|
||||||
user =>
|
user =>
|
||||||
|
|
Loading…
Reference in a new issue