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
Merge requests
!1095
WIP: Update master for 2.0.3
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
WIP: Update master for 2.0.3
develop
into
master
Overview
2
Commits
19
Pipelines
3
Changes
15
Closed
Shpuld Shpludson
requested to merge
develop
into
master
4 years ago
Overview
2
Commits
19
Pipelines
3
Changes
15
Expand
0
0
Merge request reports
Compare
master
version 2
c67e9daf
4 years ago
version 1
af3e6974
4 years ago
master (base)
and
latest version
latest version
5f90b6a3
19 commits,
4 years ago
version 2
c67e9daf
15 commits,
4 years ago
version 1
af3e6974
13 commits,
4 years ago
15 files
+
237
−
62
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
15
Search (e.g. *.vue) (Ctrl+P)
src/components/emoji_input/suggestor.js
+
18
−
6
Options
@@ -29,17 +29,29 @@ export default data => input => {
export
const
suggestEmoji
=
emojis
=>
input
=>
{
const
noPrefix
=
input
.
toLowerCase
().
substr
(
1
)
return
emojis
.
filter
(({
displayText
})
=>
displayText
.
toLowerCase
().
startsWit
h
(
noPrefix
))
.
filter
(({
displayText
})
=>
displayText
.
toLowerCase
().
matc
h
(
noPrefix
))
.
sort
((
a
,
b
)
=>
{
let
aScore
=
0
let
bScore
=
0
//
Make custom emojis a priority
aScore
+=
a
.
imageUrl
?
1
0
:
0
bScore
+=
b
.
imageUrl
?
1
0
:
0
//
An exact match always wins
aScore
+=
a
.
displayText
.
toLowerCase
()
===
noPrefix
?
20
0
:
0
bScore
+=
b
.
displayText
.
toLowerCase
()
===
noPrefix
?
20
0
:
0
// Sort alphabetically
const
alphabetically
=
a
.
displayText
>
b
.
displayText
?
1
:
-
1
// Prioritize custom emoji a lot
aScore
+=
a
.
imageUrl
?
100
:
0
bScore
+=
b
.
imageUrl
?
100
:
0
// Prioritize prefix matches somewhat
aScore
+=
a
.
displayText
.
toLowerCase
().
startsWith
(
noPrefix
)
?
10
:
0
bScore
+=
b
.
displayText
.
toLowerCase
().
startsWith
(
noPrefix
)
?
10
:
0
// Sort by length
aScore
-=
a
.
displayText
.
length
bScore
-=
b
.
displayText
.
length
// Break ties alphabetically
const
alphabetically
=
a
.
displayText
>
b
.
displayText
?
0.5
:
-
0.5
return
bScore
-
aScore
+
alphabetically
})
Loading