Compare commits

..

3 Commits

Author SHA1 Message Date
40a292d05e Scrolled to bottom fix. 2025-05-27 12:21:40 +02:00
bf723db2cc Scrolled to bottom fix. 2025-05-27 12:16:47 +02:00
46052172b2 Scrolled to bottom fix. 2025-05-27 12:14:02 +02:00

View File

@ -75,14 +75,19 @@ class ChatInputComponent extends HTMLElement {
authors.forEach(author => {
const lowerAuthor = author.toLowerCase();
let distance = this.levenshteinDistance(lowerMention, lowerAuthor);
if(!this.isSubsequence(lowerMention,lowerAuthor)) {
distance += 1
distance += 10
}
console.warn([ mention, author, distance ]);
if (distance < minDistance) {
minDistance = distance;
closestAuthor = author;
console.info({ mention, closestAuthor, distance });
}
});
return { mention, closestAuthor, distance: minDistance };
@ -124,11 +129,9 @@ levenshteinDistance(a, b) {
const mentions = this.extractMentions(text);
const matches = this.matchMentionsToAuthors(mentions, authors);
console.info(matches)
let updatedText = text;
matches.forEach(({ mention, closestAuthor }) => {
const mentionRegex = new RegExp(`@${mention}`, 'g');
console.info(closestAuthor)
updatedText = updatedText.replace(mentionRegex, `@${closestAuthor}`);
});