Fix merging single message entities

This commit is contained in:
Eduard Kuzmenko 2023-03-08 18:41:57 +04:00
parent 2e2c8218f2
commit 6a424aa385
2 changed files with 3 additions and 2 deletions

View File

@ -4,7 +4,7 @@
* https://github.com/morethanwords/tweb/blob/master/LICENSE * https://github.com/morethanwords/tweb/blob/master/LICENSE
*/ */
import {MARKDOWN_ENTITIES_TYPES, PASS_CONFLICTING_ENTITIES} from '.'; import {PASS_CONFLICTING_ENTITIES, PASS_SINGLE_CONFLICTING_ENTITIES} from '.';
import {MessageEntity} from '../../layer'; import {MessageEntity} from '../../layer';
const SINGLE_ENTITIES: Set<MessageEntity['_']> = new Set(['messageEntityPre', 'messageEntityCode']); const SINGLE_ENTITIES: Set<MessageEntity['_']> = new Set(['messageEntityPre', 'messageEntityCode']);
@ -16,7 +16,7 @@ export default function findConflictingEntity(currentEntities: MessageEntity[],
singleEnd = currentEntity.offset + currentEntity.length; singleEnd = currentEntity.offset + currentEntity.length;
} }
if(newEntity.offset < singleEnd && MARKDOWN_ENTITIES_TYPES.has(newEntity._)) { if(newEntity.offset < singleEnd && !PASS_SINGLE_CONFLICTING_ENTITIES.has(newEntity._)) {
return true; return true;
} }

View File

@ -106,6 +106,7 @@ export const PASS_CONFLICTING_ENTITIES: Set<MessageEntity['_']> = new Set([
'messageEntityLinebreak', 'messageEntityLinebreak',
'messageEntityCaret' 'messageEntityCaret'
]); ]);
export const PASS_SINGLE_CONFLICTING_ENTITIES = new Set(PASS_CONFLICTING_ENTITIES);
for(const i in MARKDOWN_ENTITIES) { for(const i in MARKDOWN_ENTITIES) {
PASS_CONFLICTING_ENTITIES.add(MARKDOWN_ENTITIES[i]); PASS_CONFLICTING_ENTITIES.add(MARKDOWN_ENTITIES[i]);
} }