Browse Source

Fix splitted emoji

master
Eduard Kuzmenko 3 years ago
parent
commit
bd3c5fc372
  1. 1
      src/index.ts
  2. 13
      src/lib/richtextprocessor.ts

1
src/index.ts

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
import App from './config/app';
import blurActiveElement from './helpers/dom/blurActiveElement';
import { cancelEvent } from './helpers/dom/cancelEvent';
import fixSafariStickyInput from './helpers/dom/fixSafariStickyInput';
import { IS_STICKY_INPUT_BUGGED } from './helpers/dom/fixSafariStickyInputFocusing';
import loadFonts from './helpers/dom/loadFonts';
import IS_EMOJI_SUPPORTED from './helpers/emojiSupport';

13
src/lib/richtextprocessor.ts

@ -382,6 +382,19 @@ namespace RichTextProcessor { @@ -382,6 +382,19 @@ namespace RichTextProcessor {
currentEntities.push(...filtered);
currentEntities.sort((a, b) => a.offset - b.offset);
if(!emojiSupported) { // fix splitted emoji. messageEntityTextUrl can split the emoji if starts before its end (e.g. on fe0f)
for(let i = 0; i < currentEntities.length; ++i) {
const entity = currentEntities[i];
if(entity._ === 'messageEntityEmoji') {
const nextEntity = currentEntities[i + 1];
if(nextEntity && nextEntity.offset < (entity.offset + entity.length)) {
entity.length = nextEntity.offset - entity.offset;
}
}
}
}
return currentEntities;
}

Loading…
Cancel
Save