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
41eeaf35
Commit
41eeaf35
authored
5 years ago
by
HJ
Browse files
Options
Downloads
Patches
Plain Diff
self-review
parent
e536a562
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1028
`master` refresh with `develop`
,
!824
EmojiInput refactoring
Pipeline
#13004
passed
5 years ago
Stage: lint
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/emoji-input/emoji-input.js
+54
-20
54 additions, 20 deletions
src/components/emoji-input/emoji-input.js
with
54 additions
and
20 deletions
src/components/emoji-input/emoji-input.js
+
54
−
20
View file @
41eeaf35
import
Completion
from
'
../../services/completion/completion.js
'
import
{
take
}
from
'
lodash
'
/**
* EmojiInput - augmented inputs for emoji and autocomplete support in inputs
* without having to give up the comfort of <input/> and <textarea/> elements
*
* Intended usage is:
* <emoji-input v-model="something">
* <input v-model="something"/>
* </emoji-input>
*
* Works only with <input> and <textarea>. Intended to use with only one nested
* input. It will find first input or textarea and work with that, multiple
* nested children not tested. You HAVE TO duplicate v-model for both
* <emoji-input> and <input>/<textarea> otherwise it will not work.
*
* Be prepared for CSS troubles though because it still wraps component in a div
* while TRYING to make it look like nothing happened, but it could break stuff.
*/
const
EmojiInput
=
{
props
:
[
'
placeholder
'
,
'
suggest
'
,
'
value
'
,
'
type
'
,
'
classname
'
],
props
:
{
suggest
:
{
/**
* suggest: function (input: String) => Suggestion[]
*
* Function that takes input string which takes string (textAtCaret)
* and returns an array of Suggestions
*
* Suggestion is an object containing following properties:
* displayText: string. Main display text, what actual suggestion
* represents (user's screen name/emoji shortcode)
* replacementText: string. Text that should replace the textAtCaret
* detailText: string, optional. Subtitle text, providing additional info
* if present (user's nickname)
* imageUrl: string, optional. Image to display alongside with suggestion,
* currently if no image is provided, replacementText will be used (for
* unicode emojis)
*
* TODO: make it asynchronous when adding proper server-provided user
* suggestions
*
* For commonly used suggestors (emoji, users, both) use suggestor.js
*/
required
:
true
,
type
:
Function
},
value
:
{
/**
* Used for v-model
*/
required
:
true
,
type
:
String
}
},
data
()
{
return
{
input
:
undefined
,
highlighted
:
0
,
caret
:
0
,
focused
:
false
,
popupOptions
:
{
placement
:
'
bottom-start
'
,
trigger
:
'
hover
'
,
// See: https://github.com/RobinCK/vue-popper/issues/63
'
delay-on-mouse-over
'
:
9999999
,
'
delay-on-mouse-out
'
:
9999999
,
modifiers
:
{
arrow
:
{
enabled
:
true
},
offset
:
{
offset
:
'
0, 5px
'
}
}
}
focused
:
false
}
},
computed
:
{
...
...
@@ -172,7 +206,7 @@ const EmojiInput = {
onInput
(
e
)
{
this
.
$emit
(
'
input
'
,
e
.
target
.
value
)
},
setCaret
({
target
:
{
selectionStart
,
value
}
})
{
setCaret
({
target
:
{
selectionStart
}
})
{
this
.
caret
=
selectionStart
},
resize
()
{
...
...
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