Make emoji text matching case-insensitive
See [#5186][5186]. [5186]: https://github.com/signalapp/Signal-Desktop/pull/5186
This commit is contained in:
parent
51d85e58eb
commit
756af78d57
2 changed files with 7 additions and 10 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue