Skip to content
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

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link

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


const filteredEmoji = emojiList
.filter(
item => [
item.name,
item.shortname.replaceAll(':', ''),
Copy link

Choose a reason for hiding this comment

The 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
Copy link

Choose a reason for hiding this comment

The 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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link

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


const filteredEmoji = emojiList
.filter(
item => [
item.name,
item.shortname.replaceAll(':', ''),
Copy link

Choose a reason for hiding this comment

The 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
Copy link

Choose a reason for hiding this comment

The 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 }) => {
Expand Down