-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add emoji autocompletion (#987) #1961
Conversation
As discussed, I first looked into opportunities to outsource the emoji autocompletion into nextcloud-vue components. But unfortunately that's not really an option - at least I didn't see a good one. The nextcloud-vue implementation would be specific to the RichContenteditable component and our implementation utilizes the TipTap Suggestions extension. I'd be happy to learn about others' ideas on how to merge (parts of) the two approaches though 😊 |
c1fbadb
to
e3004ee
Compare
@nimishavijay and @jancborchardt feel free to drop some early feedback as well 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Wow it is very nice already!
The nextcloud-vue implementation would be specific to the RichContenteditable component and our implementation utilizes the TipTap Suggestions extension.
I guess it would require to implement something generic enough so it could be used in RichContenteditable and as a replacement of your EmojiSuggestions component.
I think it would be nicer to factorize the work on text suggestion.
I'll have a look at our Vue lib soonish.
When there is no suggestion, the TipTap emoji plugin sometimes provides an emojiRect with x==0 and y==0 which causes the suggestion box to jump to the top left corner. I didn't dig too deep but I feel this could be avoided with a few checks.
Looking super nice! Pretty much done looks-wise :D
|
The suggestion dropdown appears right after typing ":". You can then change the highlighted one with the arrows and select one with enter or by clicking it. Pressing the tab has no effect on the dropdown, it changes the focus to other stuff in the page.
Right now it's 5.
Sounds good, yes. |
dc4ea5d
to
b5feddf
Compare
I digged a bit deeper here. The problem is that This works well in my tests, but not sure if it's the smartest solution. Let me know what you think 😬 |
Good point, I'll make it work on
As @eneiluj said, it's limited to five for now (Github also shows five).
Good idea. What would be a good max-width on mobile? |
Seems good and a similar approach is used in https://github.com/ueberdosis/tiptap/blob/v1/examples/Components/Routes/Suggestions/index.vue#L230 |
b736773
to
ecf9739
Compare
I went with Also did some further CSS/positioning improvements, see 95e2583 for details. I updated the screencast above accordingly. |
95e2583
to
f08da45
Compare
So I looked into the problem of marks being applied within emoji search and came up with #1964, which is the proper fix here in my eyes. This also fixes the problem for inserting e.g. URLs with two underscores etc. Therefore I removed the quoted todo as it's out of scope for this PR. |
I did not take a look at the code yet... but i am super excited to see this! Just wanted to share the excitement. And yes... i know there are emoji reactions for this... sometimes they are not enough though ;) |
7e99467
to
2d77a80
Compare
This fix makes sense. It now works very nicely 🚀. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
As far as I've seen, in the suggestion list, when there's no query, only the last used emoji is added in the end. It would be nice to have the 3 last used or the 3 most used. What do you think? Does it make sense? Is it even possible/easy to implement?
|
9630596
to
62ba128
Compare
An alternative would be to always append a space when adding an emoji. That's also, what others do. What do you think about that? |
That's a great idea. Avoids opening the emoji picker when ending a word with a colon like this: |
7ace9f8
to
b05c62b
Compare
I put some more work into the PR and think that it's ready to be merged now. In particular, implementing automatic scrolling when navigating through the suggestion list was tricky and to be honest I'm a bit proud about the result 😊 b05c62b Also, as discussed with @max-nextcloud, every inserted emoji now always gets a whitespace appended, to make it easy to insert several emojis in a row. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks very clean. Will give it a try and then merge.
/compile amend / |
b3fd0b7
to
c9494e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works like a charm and also nice and clean from a code perspective 👍
Trying to fix the jest issue. I ran into something similar before.
Okay... i think i found the underlying problem. There are some imports using src paths in Using a locally linked diff --git a/src/functions/emoji/emoji.js b/src/functions/emoji/emoji.js
index e54e8a28..126d327d 100644
--- a/src/functions/emoji/emoji.js
+++ b/src/functions/emoji/emoji.js
@@ -21,8 +21,7 @@
*/
import data from 'emoji-mart-vue-fast/data/all.json'
-import { EmojiIndex } from 'emoji-mart-vue-fast/src'
-import frequently from 'emoji-mart-vue-fast/src/utils/frequently'
+import { EmojiIndex, frequently } from 'emoji-mart-vue-fast'
// export const allEmojis = index.buildIndex() The |
nextcloud-libraries/nextcloud-vue#2521 has the upstream fix. We'll have to wait for a release of |
Adds emoji autocompletion by typing `:<search_string>`. It utilizes the emoji functions from nextcloud-vue[1] and the TipTap suggestions extension. [1] nextcloud-libraries/nextcloud-vue#1474 Signed-off-by: Jonas <jonas@freesources.org>
Navigating the suggestion list via arrow up/down keys is handled in javascript, so we have to handle the scrolling in javascript too. Only scrolls if the new selected item has not visible before. At ArrowDown, scroll bottom of visible area to lower border of item. At ArrowUp, scroll top of visible area to upper border of item. Signed-off-by: Jonas <jonas@freesources.org>
Signed-off-by: Jonas <jonas@freesources.org> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Importing `core-js/stable` as recommended by https://babeljs.io/docs/en/babel-polyfill It is also not listed in our package.json. So far it was provided as a dependency of `emoji-mart-vue-fast` via `@nextcloud/vue`. Signed-off-by: Max <max@nextcloud.com>
6e8fa6b
to
3f9cc92
Compare
Signed-off-by: Max <max@nextcloud.com>
3f9cc92
to
b1840b0
Compare
Adds emoji autocompletion by typing
:<search string>
.It utilizes the emoji functions from nextcloud-vue[1] and the TipTap
suggestions extension.
[1] nextcloud-libraries/nextcloud-vue#1474
Signed-off-by: Jonas Meurer jonas@freesources.org
Screencasts
Summary