Skip to content

Commit

Permalink
Fix problem with spaces in emoji picker. Fixes adam-p#93.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfx2006 committed Aug 4, 2024
1 parent 9122ee5 commit f63bcbc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Show error message when using GChart Image API for Math Rendering
[#91](https://gitlab.com/jfx2006/markdown-here-revival/-/issues/91)
- Updated translations
- Fixed issue with spaces in emoji picker
[#93](https://gitlab.com/jfx2006/markdown-here-revival/-/issues/93)

## [4.0 beta 19]

Expand Down
2 changes: 2 additions & 0 deletions extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Show error message when using GChart Image API for Math Rendering
[#91](https://gitlab.com/jfx2006/markdown-here-revival/-/issues/91)
- Updated translations
- Fixed issue with spaces in emoji picker
[#93](https://gitlab.com/jfx2006/markdown-here-revival/-/issues/93)

## [4.0 beta 19]

Expand Down
21 changes: 1 addition & 20 deletions extension/auto-emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,6 @@ const loadEmoji = async () => {
return _fuse
}

/*const gatherCandidates = async (term, limit = 10) => {
const kvs = await loadEmoji()
const results = []
// Whether previous key started with the term
let prevMatch = false
for (const [key, url] of kvs) {
if (key.startsWith(term)) {
results.push([key, url])
if (results.length === limit) {
break
}
prevMatch = true
} else if (prevMatch) {
break
}
}
return results
}*/

async function gatherCandidates(term, limit = 10) {
const fuse = await loadEmoji()
const results = fuse.search(term)
Expand All @@ -58,7 +39,7 @@ const EMOJI_STRATEGY = {
search: async (term, callback) => {
callback(await gatherCandidates(term))
},
replace: ([key]) => `:${key}: `,
replace: ([key]) => `:${key.replaceAll(" ", "_")}: `,
template: ([key, emoji_unicode]) => `${emoji_unicode}&nbsp;<small>${key}</small>`,
context: (text) => {
const blockmatch = text.match(CODEBLOCK)
Expand Down

0 comments on commit f63bcbc

Please sign in to comment.