Handle tg://join as tg://joinchat

Fix editing monospace text in messageEntityPre
This commit is contained in:
Eduard Kuzmenko 2022-01-16 19:48:56 +04:00
parent 5767876abd
commit 9b7b63bcfb
2 changed files with 18 additions and 14 deletions

View File

@ -486,17 +486,19 @@ export class AppImManager {
}
});
this.addAnchorListener<{
uriParams: {
invite: string
}
}>({
name: 'joinchat',
protocol: 'tg',
callback: ({uriParams}) => {
const link = this.makeLink(INTERNAL_LINK_TYPE.JOIN_CHAT, uriParams);
this.processInternalLink(link);
}
['joinchat' as const, 'join' as const].forEach(name => {
this.addAnchorListener<{
uriParams: {
invite: string
}
}>({
name,
protocol: 'tg',
callback: ({uriParams}) => {
const link = this.makeLink(INTERNAL_LINK_TYPE.JOIN_CHAT, uriParams);
this.processInternalLink(link);
}
});
});
this.onHashChange();
@ -688,8 +690,8 @@ export class AppImManager {
}
private addAnchorListener<Params extends {pathnameParams?: any, uriParams?: any}>(options: {
name: 'showMaskedAlert' | 'execBotCommand' | 'searchByHashtag' | 'addstickers' | 'joinchat' | 'im' |
'resolve' | 'privatepost' | 'addstickers' | 'voicechat',
name: 'showMaskedAlert' | 'execBotCommand' | 'searchByHashtag' | 'addstickers' | 'im' |
'resolve' | 'privatepost' | 'addstickers' | 'voicechat' | 'joinchat' | 'join',
protocol?: 'tg',
callback: (params: Params, element?: HTMLAnchorElement) => boolean | any,
noPathnameParams?: boolean,

View File

@ -564,7 +564,9 @@ namespace RichTextProcessor {
}
case 'messageEntityPre': {
if(!options.noTextFormat) {
if(options.wrappingDraft) {
insertPart(entity, '<span style="font-family: monospace;">', '</span>');
} else if(!options.noTextFormat) {
insertPart(entity, `<pre><code${entity.language ? ' class="language-' + encodeEntities(entity.language) + '"' : ''}>`, '</code></pre>');
}