Quote: Fix highlight after message editing (#5987)
This commit is contained in:
parent
c226e8fc0b
commit
e1fd770402
@ -74,7 +74,8 @@ function MessageText({
|
|||||||
const entitiesWithFocusedQuote = useMemo(() => {
|
const entitiesWithFocusedQuote = useMemo(() => {
|
||||||
if (!text || !focusedQuote) return entities;
|
if (!text || !focusedQuote) return entities;
|
||||||
|
|
||||||
const index = text.indexOf(focusedQuote, focusedQuoteOffset);
|
const offsetIndex = text.indexOf(focusedQuote, focusedQuoteOffset);
|
||||||
|
const index = offsetIndex >= 0 ? offsetIndex : text.indexOf(focusedQuote); // Fallback to first occurrence
|
||||||
const lendth = focusedQuote.length;
|
const lendth = focusedQuote.length;
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
return insertTextEntity(entities || [], {
|
return insertTextEntity(entities || [], {
|
||||||
|
|||||||
@ -314,7 +314,8 @@ export function insertTextEntity(entities: ApiMessageEntity[], newEntity: ApiMes
|
|||||||
if (existingEntityEnd <= newEntityStart
|
if (existingEntityEnd <= newEntityStart
|
||||||
|| existingEntityStart > newEntityEnd
|
|| existingEntityStart > newEntityEnd
|
||||||
|| (existingEntityStart > newEntityStart
|
|| (existingEntityStart > newEntityStart
|
||||||
&& existingEntityEnd < newEntityEnd)) {
|
&& existingEntityEnd < newEntityEnd)
|
||||||
|
|| (existingEntityStart === newEntityStart && existingEntityEnd === newEntityEnd)) {
|
||||||
resultEntities.push(existingEntity);
|
resultEntities.push(existingEntity);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user