-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(rich-text-editor): DLT-2116 enable emoji searching by name and keyword #1
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,19 +7,25 @@ import EmojiSuggestion from './EmojiSuggestion.vue'; | |
import tippy from 'tippy.js'; | ||
import hideOnEsc from '../tippy_plugins/hide_on_esc'; | ||
|
||
const suggestionLimit = 20; | ||
|
||
export default { | ||
items: ({ query }) => { | ||
if (query.length < 2) { | ||
return []; | ||
} | ||
const emojiList = Object.values(emojisIndexed); | ||
const filteredEmoji = emojiList.filter(function (item) { | ||
if (item.shortname.substring(1, item.shortname.length - 1).startsWith(query.toLowerCase())) { | ||
return true; | ||
} | ||
return false; | ||
}); | ||
return filteredEmoji.map(item => { return { code: item.shortname }; }); | ||
query = query.toLowerCase(); | ||
|
||
const filteredEmoji = emojiList | ||
.filter( | ||
item => [ | ||
item.name, | ||
item.shortname.replaceAll(':', ''), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: replaceAll might not be supported in all environments. Consider using replace with regex |
||
...item.keywords, | ||
].some(text => text.startsWith(query)), | ||
).splice(0, suggestionLimit); | ||
Comment on lines
+20
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: This filtering could be expensive for large emoji lists. Consider memoization or indexing for better performance |
||
return filteredEmoji.map(item => ({ code: item.shortname })); | ||
}, | ||
|
||
command: ({ editor, range, props }) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,19 +8,25 @@ import EmojiSuggestion from './EmojiSuggestion.vue'; | |
import tippy from 'tippy.js'; | ||
import hideOnEsc from '../tippy_plugins/hide_on_esc'; | ||
|
||
const suggestionLimit = 20; | ||
|
||
export default { | ||
items: ({ query }) => { | ||
if (query.length < 2) { | ||
return []; | ||
} | ||
const emojiList = Object.values(emojisIndexed); | ||
const filteredEmoji = emojiList.filter(function (item) { | ||
if (item.shortname.substring(1, item.shortname.length - 1).startsWith(query.toLowerCase())) { | ||
return true; | ||
} | ||
return false; | ||
}); | ||
return filteredEmoji.map(item => { return { code: item.shortname }; }); | ||
query = query.toLowerCase(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Reassigning function parameter. Consider using a new variable name |
||
|
||
const filteredEmoji = emojiList | ||
.filter( | ||
item => [ | ||
item.name, | ||
item.shortname.replaceAll(':', ''), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: replaceAll may not be supported in all browsers. Consider using replace with a regex for better compatibility |
||
...item.keywords, | ||
].some(text => text.startsWith(query)), | ||
).splice(0, suggestionLimit); | ||
Comment on lines
+21
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: This filtering logic might be computationally expensive for large emoji lists. Consider optimizing if performance issues arise |
||
return filteredEmoji.map(item => ({ code: item.shortname })); | ||
}, | ||
|
||
command: ({ editor, range, props }) => { | ||
|
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.
style: Reassigning function parameter. Consider using a new variable name