mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 00:55:25 +08:00
FIX: Emoji search/autocomplete should respect selected skin tone (#11917)
This commit makes our emoji autocomplete in the composer respect the skin tone you select in the emoji picker.
This commit is contained in:
parent
dd175537f3
commit
6efdeef461
@ -542,7 +542,10 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = emojiSearch(term, { maxResults: 5 });
|
const options = emojiSearch(term, {
|
||||||
|
maxResults: 5,
|
||||||
|
diversity: this.emojiStore.diversity,
|
||||||
|
});
|
||||||
|
|
||||||
return resolve(options);
|
return resolve(options);
|
||||||
})
|
})
|
||||||
|
@ -224,6 +224,7 @@ export default Component.extend({
|
|||||||
if (event.target.value) {
|
if (event.target.value) {
|
||||||
results.innerHTML = emojiSearch(event.target.value.toLowerCase(), {
|
results.innerHTML = emojiSearch(event.target.value.toLowerCase(), {
|
||||||
maxResults: 10,
|
maxResults: 10,
|
||||||
|
diversity: this.emojiStore.diversity,
|
||||||
})
|
})
|
||||||
.map(this._replaceEmoji)
|
.map(this._replaceEmoji)
|
||||||
.join("");
|
.join("");
|
||||||
|
@ -136,5 +136,18 @@ discourseModule("Unit | Utility | emoji", function () {
|
|||||||
|
|
||||||
// able to find middle of line search
|
// able to find middle of line search
|
||||||
assert.equal(emojiSearch("check", { maxResults: 3 }).length, 3);
|
assert.equal(emojiSearch("check", { maxResults: 3 }).length, 3);
|
||||||
|
|
||||||
|
// appends diversity
|
||||||
|
assert.deepEqual(emojiSearch("woman_artist", { diversity: 5 }), [
|
||||||
|
"woman_artist:t5",
|
||||||
|
]);
|
||||||
|
assert.deepEqual(emojiSearch("woman_artist", { diversity: 2 }), [
|
||||||
|
"woman_artist:t2",
|
||||||
|
]);
|
||||||
|
|
||||||
|
// no diversity appended for emojis that can't be diversified
|
||||||
|
assert.deepEqual(emojiSearch("green_apple", { diversity: 3 }), [
|
||||||
|
"green_apple",
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -210,6 +210,7 @@ export function emojiExists(code) {
|
|||||||
let toSearch;
|
let toSearch;
|
||||||
export function emojiSearch(term, options) {
|
export function emojiSearch(term, options) {
|
||||||
const maxResults = (options && options["maxResults"]) || -1;
|
const maxResults = (options && options["maxResults"]) || -1;
|
||||||
|
const diversity = options && options.diversity;
|
||||||
if (maxResults === 0) {
|
if (maxResults === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@ -227,7 +228,11 @@ export function emojiSearch(term, options) {
|
|||||||
function addResult(t) {
|
function addResult(t) {
|
||||||
const val = aliasHash[t] || t;
|
const val = aliasHash[t] || t;
|
||||||
if (results.indexOf(val) === -1) {
|
if (results.indexOf(val) === -1) {
|
||||||
results.push(val);
|
if (diversity && diversity > 1 && isSkinTonableEmoji(val)) {
|
||||||
|
results.push(`${val}:t${diversity}`);
|
||||||
|
} else {
|
||||||
|
results.push(val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user