+
+
{{ emojiInfo.title }}
-
+
+ {{ emojiInfo.keywords.join(', ') }}
-
-
- Unicode: {{ emojiInfo.unicode }}
-
-->
-
-
- {{ emojiInfo.codePoints }}
+
+
+
+
+ {{ completeCodePoints }}
-
+
+
+
{{ emojiInfo.unicode }}
+
+
+
+ ⚠️
+
+
+
diff --git a/src/tools/emoji-picker/emoji-picker.vue b/src/tools/emoji-picker/emoji-picker.vue
index f245635d..ca9571a7 100644
--- a/src/tools/emoji-picker/emoji-picker.vue
+++ b/src/tools/emoji-picker/emoji-picker.vue
@@ -3,12 +3,55 @@ import emojiUnicodeData from 'unicode-emoji-json';
import emojiKeywords from 'emojilib';
import _ from 'lodash';
import type { EmojiInfo } from './emoji.types';
-import { useFuzzySearch } from '@/composable/fuzzySearch';
+import { escapeUnicodeComplete, getAllCodePoints } from './emoji-utils';
import useDebouncedRef from '@/composable/debouncedref';
+import { useFlexSearch } from '@/composable/flexSearch';
-const escapeUnicode = ({ emoji }: { emoji: string }) => emoji.split('').map(unit => `\\u${unit.charCodeAt(0).toString(16).padStart(4, '0')}`).join('');
-const getEmojiCodePoints = ({ emoji }: { emoji: string }) => emoji.codePointAt(0) ? `0x${emoji.codePointAt(0)?.toString(16)}` : undefined;
+// Enhanced emoji processing functions
+const escapeUnicode = ({ emoji }: { emoji: string }) => escapeUnicodeComplete(emoji);
+function getEmojiCodePoints({ emoji }: { emoji: string }) {
+ // Get all code points for complex emojis (like flags)
+ const codePoints: string[] = [];
+ for (const char of emoji) {
+ const codePoint = char.codePointAt(0);
+ if (codePoint) {
+ codePoints.push(`0x${codePoint.toString(16)}`);
+ }
+ }
+ return codePoints.length > 0 ? codePoints.join(' ') : undefined;
+}
+
+// Function to detect if a string contains emojis
+function containsEmoji(text: string): boolean {
+ // Check each character in the text against our emoji data
+ for (const char of text) {
+ if (emojiUnicodeData[char]) {
+ return true;
+ }
+ }
+ return false;
+}
+// Function to convert emojis in text to their unicode representations
+function convertEmojisToUnicode(text: string): string {
+ let result = text;
+
+ // Process each character/emoji in the string
+ for (const char of text) {
+ // Check if this character is an emoji by looking it up in our emoji data
+ if (emojiUnicodeData[char]) {
+ const unicodeString = escapeUnicode({ emoji: char });
+ if (unicodeString) {
+ // Replace the emoji with its unicode representation
+ result = result.replace(char, unicodeString);
+ }
+ }
+ }
+
+ return result;
+}
+
+// Process emojis with enhanced code point handling
const emojis = _.map(emojiUnicodeData, (emojiInfo, emoji) => ({
...emojiInfo,
emoji,
@@ -16,75 +59,167 @@ const emojis = _.map(emojiUnicodeData, (emojiInfo, emoji) => ({
keywords: emojiKeywords[emoji as keyof typeof emojiKeywords],
codePoints: getEmojiCodePoints({ emoji }),
unicode: escapeUnicode({ emoji }),
+ allCodePoints: getAllCodePoints(emoji), // Add complete code point info
}));
-const emojisGroups: { emojiInfos: EmojiInfo[]; group: string }[] = _
- .chain(emojis)
+// Group emojis and sort groups for better organization
+const emojisGroups: { emojiInfos: EmojiInfo[]; group: string }[] = _.chain(emojis)
.groupBy('group')
- .map((emojiInfos, group) => ({ group, emojiInfos }))
+ .map((emojiInfos, group) => ({
+ group: _.startCase(group), // Better group name formatting
+ emojiInfos,
+ }))
.value();
-const limit = ref(100);
-const searchQuery = useDebouncedRef('', 500);
+const limit = ref(150);
+const rawSearchQuery = ref('');
+const searchQuery = useDebouncedRef('', 250);
-const { searchResult } = useFuzzySearch({
+// Add automated lazy loading for emoji groups
+const visibleGroupsCount = ref(1); // Start with 1 group
+let loadingInterval: NodeJS.Timeout | null = null;
+
+// Watch for raw search query changes and process emojis
+watch(rawSearchQuery, (newQuery) => {
+ if (containsEmoji(newQuery)) {
+ // Convert emojis to unicode and update the debounced search query
+ const unicodeQuery = convertEmojisToUnicode(newQuery);
+ searchQuery.value = unicodeQuery;
+ }
+ else {
+ // Regular text search
+ searchQuery.value = newQuery;
+ }
+});
+
+const { searchResult } = useFlexSearch({
search: searchQuery,
data: emojis,
options: {
- keys: ['group', { name: 'name', weight: 3 }, 'keywords', 'unicode', 'codePoints', 'emoji'],
- threshold: 0.3,
- useExtendedSearch: true,
- isCaseSensitive: false,
+ keys: ['group', { name: 'name', weight: 3 }, 'keywords', 'unicode', 'codePoints', 'allCodePoints', 'emoji'],
+ filterEmpty: false,
},
- limit: limit.value,
+ limit,
+});
+
+// Computed property for filtered results
+const displayedSearchResults = computed(() => {
+ return searchResult.value.slice(0, limit.value);
+});
+
+// Computed property for visible emoji groups
+const visibleEmojisGroups = computed(() => {
+ return emojisGroups.slice(0, visibleGroupsCount.value);
+});
+
+// Function to stop automated loading
+function stopAutomatedLoading() {
+ if (loadingInterval) {
+ clearInterval(loadingInterval);
+ loadingInterval = null;
+ }
+}
+
+// Function to start automated loading
+function startAutomatedLoading() {
+ // Clear any existing interval
+ if (loadingInterval) {
+ clearInterval(loadingInterval);
+ }
+
+ // Start loading groups every 150ms
+ loadingInterval = setInterval(() => {
+ if (visibleGroupsCount.value < emojisGroups.length) {
+ visibleGroupsCount.value++;
+ }
+ else {
+ // Stop loading when all groups are visible
+ stopAutomatedLoading();
+ }
+ }, 150);
+}
+
+// Watch for search query changes
+watch(searchQuery, (newQuery, oldQuery) => {
+ if (newQuery.trim()) {
+ // Stop automated loading when searching
+ stopAutomatedLoading();
+ }
+ else if (oldQuery && oldQuery.trim()) {
+ // Reset and start automated loading when switching from search to browse
+ visibleGroupsCount.value = 1;
+ nextTick(() => {
+ startAutomatedLoading();
+ });
+ }
+});
+
+// Start automated loading on component mount (when not searching)
+onMounted(() => {
+ if (!searchQuery.value.trim()) {
+ startAutomatedLoading();
+ }
+});
+
+// Clean up on component unmount
+onUnmounted(() => {
+ stopAutomatedLoading();
});
-
+
-
+
+
-
- No results
+
+
No results found
+
+ Try searching for something else like "smile", "flag", or "😄"
+
-
- Search result
+
+ Search Results
+ ({{ displayedSearchResults.length }} found)
-
+
-
-
- {{ group }}
+
+
+
+
+ {{ group }}
+ ({{ emojiInfos.length }})
+
+
+
-
+
+
+
+ Loading more groups... ({{ visibleGroupsCount }}/{{ emojisGroups.length }})
+
+
diff --git a/src/tools/emoji-picker/emoji-utils.ts b/src/tools/emoji-picker/emoji-utils.ts
new file mode 100644
index 00000000..e52630ee
--- /dev/null
+++ b/src/tools/emoji-picker/emoji-utils.ts
@@ -0,0 +1,48 @@
+export function getAllCodePoints(emoji: string): string {
+ const codePoints: string[] = [];
+ for (const char of emoji) {
+ const codePoint = char.codePointAt(0);
+ if (codePoint) {
+ codePoints.push(`U+${codePoint.toString(16).toUpperCase().padStart(4, '0')}`);
+ }
+ }
+ return codePoints.join(' ');
+}
+
+export function escapeUnicodeComplete(emoji: string): string {
+ return Array.from(emoji)
+ .map((char) => {
+ const codePoint = char.codePointAt(0);
+ return codePoint ? `\\u${codePoint.toString(16).padStart(4, '0')}` : '';
+ })
+ .join('');
+}
+
+export function isEmojiSupported(emoji: string): boolean {
+ if (typeof document === 'undefined') {
+ return true;
+ } // SSR fallback
+
+ const canvas = document.createElement('canvas');
+ const ctx = canvas.getContext('2d');
+ if (!ctx) {
+ return true;
+ }
+
+ canvas.width = 32;
+ canvas.height = 32;
+ ctx.textBaseline = 'top';
+ ctx.font = '24px "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji"';
+
+ const beforeImageData = ctx.getImageData(0, 0, 32, 32).data;
+ ctx.fillText(emoji, 0, 0);
+ const afterImageData = ctx.getImageData(0, 0, 32, 32).data;
+
+ // Check if any pixels changed
+ for (let i = 0; i < beforeImageData.length; i++) {
+ if (beforeImageData[i] !== afterImageData[i]) {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/src/tools/emoji-picker/emoji.types.ts b/src/tools/emoji-picker/emoji.types.ts
index 7b7bf922..d2038eb0 100644
--- a/src/tools/emoji-picker/emoji.types.ts
+++ b/src/tools/emoji-picker/emoji.types.ts
@@ -1,8 +1,10 @@
-import type emojiUnicodeData from 'unicode-emoji-json';
-
-export type EmojiInfo = {
- title: string
+export interface EmojiInfo {
emoji: string
- codePoints: string | undefined
+ name: string
+ title: string
+ group: string
+ keywords?: string[]
+ codePoints?: string
unicode: string
-} & typeof emojiUnicodeData[string];
+ allCodePoints?: string
+}