Browse Source

Replace spoiler pattern

Do not render emoji as big if it's hidden
Fix displaying start button in regular peers
master
Eduard Kuzmenko 3 years ago
parent
commit
f8b414f03b
  1. 2
      src/components/chat/bubbles.ts
  2. 2
      src/lib/appManagers/appImManager.ts
  3. 16
      src/lib/richtextprocessor.ts

2
src/components/chat/bubbles.ts

@ -2663,7 +2663,7 @@ export default class ChatBubbles { @@ -2663,7 +2663,7 @@ export default class ChatBubbles {
let strLength = messageMessage.length;
let emojiStrLength = emojiEntities.reduce((acc, curr) => acc + curr.length, 0);
if(emojiStrLength === strLength && emojiEntities.length <= 3) {
if(emojiStrLength === strLength && emojiEntities.length <= 3 && totalEntities.length === emojiEntities.length) {
if(rootScope.settings.emoji.big) {
let sticker = this.appStickersManager.getAnimatedEmojiSticker(messageMessage);
if(emojiEntities.length === 1 && !messageMedia && sticker) {

2
src/lib/appManagers/appImManager.ts

@ -413,7 +413,7 @@ export class AppImManager { @@ -413,7 +413,7 @@ export class AppImManager {
domain: pathnameParams[0],
post: pathnameParams[1],
comment: uriParams.comment,
start: 'start' in uriParams && uriParams.start
start: 'start' in uriParams ? uriParams.start : undefined
};
}

16
src/lib/richtextprocessor.ts

@ -774,8 +774,9 @@ namespace RichTextProcessor { @@ -774,8 +774,9 @@ namespace RichTextProcessor {
case 'messageEntitySpoiler': {
if(options.noTextFormat) {
const before = text.slice(0, entity.offset);
const spoilerBefore = text.slice(entity.offset, entity.offset + entity.length);
const after = text.slice(entity.offset + entity.length);
text = before + '▚'.repeat(entity.length) + after;
text = before + spoiler(spoilerBefore)/* '▚'.repeat(entity.length) */ + after;
} else if(options.wrappingDraft) {
insertPart(entity, '<span style="font-family: spoiler;">', '</span>');
} else {
@ -887,6 +888,19 @@ namespace RichTextProcessor { @@ -887,6 +888,19 @@ namespace RichTextProcessor {
}
return url;
}
export function spoiler(text: string): string {
const chars = '⠁⠂⠄⠈⠐⠠⡀⢀⠃⠅⠆⠉⠊⠌⠑⠒⠔⠘⠡⠢⠤⠨⠰⡁⡂⡄⡈⡐⡠⢁⢂⢄⢈⢐⢠⣀⠇⠋⠍⠎⠓⠕⠖⠙⠚⠜⠣⠥⠦⠩⠪⠬⠱⠲⠴⠸⡃⡅⡆⡉⡊⡌⡑⡒⡔⡘⡡⡢⡤⡨⡰⢃⢅⢆⢉⢊⢌⢑⢒⢔⢘⢡⢢⢤⢨⢰⣁⣂⣄⣈⣐⣠⠏⠗⠛⠝⠞⠧⠫⠭⠮⠳⠵⠶⠹⠺⠼⡇⡋⡍⡎⡓⡕⡖⡙⡚⡜⡣⡥⡦⡩⡪⡬⡱⡲⡴⡸⢇⢋⢍⢎⢓⢕⢖⢙⢚⢜⢣⢥⢦⢩⢪⢬⢱⢲⢴⢸⣃⣅⣆⣉⣊⣌⣑⣒⣔⣘⣡⣢⣤⣨⣰⠟⠯⠷⠻⠽⠾⡏⡗⡛⡝⡞⡧⡫⡭⡮⡳⡵⡶⡹⡺⡼⢏⢗⢛⢝⢞⢧⢫⢭⢮⢳⢵⢶⢹⢺⢼⣇⣋⣍⣎⣓⣕⣖⣙⣚⣜⣣⣥⣦⣩⣪⣬⣱⣲⣴⣸⠿⡟⡯⡷⡻⡽⡾⢟⢯⢷⢻⢽⢾⣏⣗⣛⣝⣞⣧⣫⣭⣮⣳⣵⣶⣹⣺⣼⡿⢿⣟⣯⣷⣻⣽⣾⣿';
const charsLength = chars.length;
const out: string[] = [];
for(let i = 0; i < text.length; ++i) {
let char = text.charCodeAt(i);
out.push(chars[char % charsLength]);
}
return out.join('');
}
/* export function replaceUrlEncodings(urlWithEncoded: string) {
return urlWithEncoded.replace(/(%[A-Z\d]{2})+/g, (str) => {

Loading…
Cancel
Save