Fix displaying other entities in monospace text
Fix formatting
This commit is contained in:
parent
c7e0cd4759
commit
20b2525d51
@ -4178,13 +4178,14 @@ export default class ChatBubbles {
|
||||
}
|
||||
|
||||
default:
|
||||
attachmentDiv = undefined;
|
||||
bubble.classList.remove('is-message-empty');
|
||||
messageDiv.append(i18n(UNSUPPORTED_LANG_PACK_KEY), timeSpan);
|
||||
this.log.warn('unrecognized media type:', messageMedia._, message);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!processingWebPage) {
|
||||
if(!processingWebPage && attachmentDiv) {
|
||||
bubbleContainer.append(attachmentDiv);
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,22 @@
|
||||
import { PASS_CONFLICTING_ENTITIES } from ".";
|
||||
import { MessageEntity } from "../../layer";
|
||||
|
||||
export default function findConflictingEntity(currentEntities: MessageEntity[], newEntity: MessageEntity) {
|
||||
return currentEntities.find((currentEntity) => {
|
||||
const isConflictingTypes = newEntity._ === currentEntity._ ||
|
||||
(!PASS_CONFLICTING_ENTITIES.has(newEntity._) && !PASS_CONFLICTING_ENTITIES.has(currentEntity._));
|
||||
const SINGLE_ENTITIES: Set<MessageEntity['_']> = new Set(['messageEntityPre', 'messageEntityCode']);
|
||||
|
||||
export default function findConflictingEntity(currentEntities: MessageEntity[], newEntity: MessageEntity) {
|
||||
let singleEnd = -1;
|
||||
return currentEntities.find((currentEntity) => {
|
||||
if(SINGLE_ENTITIES.has(currentEntity._)) {
|
||||
singleEnd = currentEntity.offset + currentEntity.length;
|
||||
}
|
||||
|
||||
if(newEntity.offset < singleEnd && !PASS_CONFLICTING_ENTITIES.has(newEntity._)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const isConflictingTypes = newEntity._ === currentEntity._ ||
|
||||
(!PASS_CONFLICTING_ENTITIES.has(newEntity._) && !PASS_CONFLICTING_ENTITIES.has(currentEntity._));
|
||||
|
||||
if(!isConflictingTypes) {
|
||||
return false;
|
||||
}
|
||||
|
@ -434,7 +434,15 @@ export default function wrapRichText(text: string, options: Partial<{
|
||||
// (lastElement || fragment).append(element ?? partText);
|
||||
// }
|
||||
|
||||
if(entity.length > partText.length && element) {
|
||||
if(nasty.usedLength <= endOffset) {
|
||||
if(nasty.usedLength < endOffset) {
|
||||
(element || fragment).append(nasty.text.slice(nasty.usedLength, endOffset));
|
||||
nasty.usedLength = endOffset;
|
||||
}
|
||||
|
||||
lastElement = fragment;
|
||||
nasty.lastEntity = undefined;
|
||||
} else if(entity.length > partText.length && element) {
|
||||
lastElement = element;
|
||||
} else {
|
||||
lastElement = fragment;
|
||||
@ -455,3 +463,5 @@ export default function wrapRichText(text: string, options: Partial<{
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
(window as any).wrapRichText = wrapRichText;
|
||||
|
Loading…
x
Reference in New Issue
Block a user