Make emoji text matching case-insensitive

See [#5186][5186].

[5186]: https://github.com/signalapp/Signal-Desktop/pull/5186
This commit is contained in:
Quentin Hibon 2021-09-17 11:21:33 -05:00 committed by Evan Hahn
parent 51d85e58eb
commit 756af78d57
2 changed files with 7 additions and 10 deletions

View file

@ -104,7 +104,7 @@ export class EmojiCompletion {
const range = this.quill.getSelection();
const [blot, index] = this.quill.getLeaf(range ? range.index : -1);
return getBlotTextPartitions(blot, index);
return getBlotTextPartitions(blot.text, index);
}
onSelectionChange(): void {

View file

@ -93,17 +93,14 @@ export const getTextAndMentionsFromOps = (
};
export const getBlotTextPartitions = (
blot: LeafBlot,
blotText: string | undefined,
index: number
): [string, string] => {
if (blot !== undefined && blot.text !== undefined) {
const leftLeafText = blot.text.substr(0, index);
const rightLeafText = blot.text.substr(index);
const lowerCaseBlotText = (blotText || '').toLowerCase();
const leftLeafText = lowerCaseBlotText.substr(0, index);
const rightLeafText = lowerCaseBlotText.substr(index);
return [leftLeafText, rightLeafText];
}
return ['', ''];
return [leftLeafText, rightLeafText];
};
export const matchBlotTextPartitions = (
@ -112,7 +109,7 @@ export const matchBlotTextPartitions = (
leftRegExp: RegExp,
rightRegExp?: RegExp
): Array<RegExpMatchArray | null> => {
const [leftText, rightText] = getBlotTextPartitions(blot, index);
const [leftText, rightText] = getBlotTextPartitions(blot.text, index);
const leftMatch = leftRegExp.exec(leftText);
let rightMatch = null;