mirror of
https://github.com/fluxerapp/fluxer.git
synced 2026-09-03 05:10:25 +03:00
fix(app): replace the whole +: token when picking a reaction emoji (#1916)
This commit is contained in:
@@ -28,6 +28,10 @@ export function getComposerAutocompleteReplacementStart(
|
||||
if (type === 'commandArg') {
|
||||
return Math.max(0, textUpToCursor.length - (matchedArgument == null ? 0 : matchedArgument.length));
|
||||
}
|
||||
if (type === 'emojiReaction') {
|
||||
const whole = match[0] == null ? '' : match[0];
|
||||
return Math.max(0, (match.index == null ? 0 : match.index) + (whole.length - whole.trimStart().length));
|
||||
}
|
||||
return Math.max(0, (match.index == null ? 0 : match.index) + (matchedPrefix == null ? 0 : matchedPrefix.length));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import {getComposerAutocompleteReplacementStart} from '@app/features/lexical/composer/ComposerAutocompleteInsertion';
|
||||
import {detectAutocompleteTrigger} from '@app/features/messaging/utils/SlashCommandUtils';
|
||||
import type {MenuTextMatch} from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
||||
|
||||
@@ -8,8 +9,7 @@ export function buildComposerMenuMatch(fullText: string, anchorText: string): Me
|
||||
if (trigger == null) {
|
||||
return null;
|
||||
}
|
||||
const matchStart =
|
||||
(trigger.match.index == null ? 0 : trigger.match.index) + (trigger.match[1] == null ? 0 : trigger.match[1].length);
|
||||
const matchStart = getComposerAutocompleteReplacementStart(fullText, trigger.type, trigger.match);
|
||||
const tokenLength = fullText.length - matchStart;
|
||||
const leadOffset = Math.max(0, anchorText.length - tokenLength);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user