Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pleroma-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
pleroma-fe
Commits
980241c1
Unverified
Commit
980241c1
authored
2 years ago
by
tusooa
Browse files
Options
Downloads
Patches
Plain Diff
Support filtering by keywords from cldr
parent
a73f9731
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1711
Update stable - 2.5.0 release
,
!1408
Group emojis into packs in emoji picker
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/emoji_picker/emoji_picker.js
+21
-4
21 additions, 4 deletions
src/components/emoji_picker/emoji_picker.js
with
21 additions
and
4 deletions
src/components/emoji_picker/emoji_picker.js
+
21
−
4
View file @
980241c1
...
...
@@ -47,13 +47,30 @@ const UNICODE_EMOJI_GROUP_ICON = {
flags
:
'
flag
'
}
const
filterByKeyword
=
(
list
,
keyword
=
''
)
=>
{
const
maybeLocalizedKeywords
=
(
emoji
,
languages
)
=>
{
const
res
=
[
emoji
.
displayText
]
if
(
emoji
.
annotations
)
{
languages
.
forEach
(
lang
=>
{
const
keywords
=
emoji
.
annotations
[
lang
]?.
keywords
||
[]
const
name
=
emoji
.
annotations
[
lang
]?.
name
res
.
push
(...(
keywords
.
concat
([
name
]).
filter
(
k
=>
k
)))
})
}
return
res
}
const
filterByKeyword
=
(
list
,
keyword
=
''
,
languages
)
=>
{
if
(
keyword
===
''
)
return
list
const
keywordLowercase
=
keyword
.
toLowerCase
()
const
orderedEmojiList
=
[]
for
(
const
emoji
of
list
)
{
const
indexOfKeyword
=
emoji
.
displayText
.
toLowerCase
().
indexOf
(
keywordLowercase
)
const
indices
=
maybeLocalizedKeywords
(
emoji
,
languages
)
.
map
(
k
=>
k
.
toLowerCase
().
indexOf
(
keywordLowercase
))
.
filter
(
k
=>
k
>
-
1
)
const
indexOfKeyword
=
indices
.
length
?
Math
.
min
(...
indices
)
:
-
1
if
(
indexOfKeyword
>
-
1
)
{
if
(
!
Array
.
isArray
(
orderedEmojiList
[
indexOfKeyword
]))
{
orderedEmojiList
[
indexOfKeyword
]
=
[]
...
...
@@ -172,7 +189,7 @@ const EmojiPicker = {
this
.
showingStickers
=
value
},
filterByKeyword
(
list
,
keyword
)
{
return
filterByKeyword
(
list
,
keyword
)
return
filterByKeyword
(
list
,
keyword
,
this
.
languages
)
},
initializeLazyLoad
()
{
this
.
destroyLazyLoad
()
...
...
@@ -221,7 +238,7 @@ const EmojiPicker = {
return
this
.
allEmojiGroups
.
map
(
group
=>
({
...
group
,
emojis
:
filterByKeyword
(
group
.
emojis
,
trim
(
this
.
keyword
))
emojis
:
this
.
filterByKeyword
(
group
.
emojis
,
trim
(
this
.
keyword
))
}))
.
filter
(
group
=>
group
.
emojis
.
length
>
0
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment