Browse Source

minor fixes

master
Eduard Kuzmenko 5 years ago
parent
commit
2fa80a1adf
  1. 6
      src/components/emoticonsDropdown.ts
  2. 8
      src/lib/appManagers/appDialogsManager.ts
  3. 66
      src/lib/appManagers/appImManager.ts
  4. 42
      src/lib/appManagers/appMessagesManager.ts
  5. 7
      src/lib/appManagers/appSidebarLeft.ts
  6. 4
      src/lib/appManagers/appStickersManager.ts
  7. 2
      src/lib/appManagers/appWebPagesManager.ts
  8. 4
      src/lib/mtproto/apiManager.ts
  9. 7
      src/lib/richtextprocessor.js
  10. 63
      src/lib/utils.js

6
src/components/emoticonsDropdown.ts

@ -10,6 +10,7 @@ import apiManager from '../lib/mtproto/apiManager';
import CryptoWorker from '../lib/crypto/cryptoworker'; import CryptoWorker from '../lib/crypto/cryptoworker';
import LazyLoadQueue from "./lazyLoadQueue"; import LazyLoadQueue from "./lazyLoadQueue";
import { MTDocument, wrapSticker } from "./wrappers"; import { MTDocument, wrapSticker } from "./wrappers";
import appWebpManager from "../lib/appManagers/appWebpManager";
export const EMOTICONSSTICKERGROUP = 'emoticons-dropdown'; export const EMOTICONSSTICKERGROUP = 'emoticons-dropdown';
@ -310,7 +311,7 @@ const initEmoticonsDropdown = (pageEl: HTMLDivElement,
let thumb = stickerSet.set.thumb; let thumb = stickerSet.set.thumb;
appStickersManager.getStickerSetThumb(stickerSet.set).then(async(blob) => { appStickersManager.getStickerSetThumb(stickerSet.set).then(async(blob) => {
if(thumb.w == 1 && thumb.h == 1) { if(thumb.w == 1 && thumb.h == 1) { // means animated
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('loadend', async(e) => { reader.addEventListener('loadend', async(e) => {
@ -329,7 +330,8 @@ const initEmoticonsDropdown = (pageEl: HTMLDivElement,
reader.readAsArrayBuffer(blob); reader.readAsArrayBuffer(blob);
} else { } else {
let image = new Image(); let image = new Image();
image.src = URL.createObjectURL(blob); //image.src = URL.createObjectURL(blob);
appWebpManager.polyfillImage(image, blob);
li.append(image); li.append(image);
} }

8
src/lib/appManagers/appDialogsManager.ts

@ -215,7 +215,7 @@ export class AppDialogsManager {
if(inUpper.length < hiddenLength) { if(inUpper.length < hiddenLength) {
inUpper.push(dom.listEl); inUpper.push(dom.listEl);
} else if(inViewportIndex <= inViewportLength - 1) { } else if(inViewportIndex <= inViewportLength - 1) {
this.chatList.append(dom.listEl); chatList.append(dom.listEl);
++inViewportIndex; ++inViewportIndex;
//this.chatList.insertBefore(dom.listEl, this.chatList.children[inViewportIndex++]); //this.chatList.insertBefore(dom.listEl, this.chatList.children[inViewportIndex++]);
} else { } else {
@ -368,10 +368,6 @@ export class AppDialogsManager {
public setUnreadMessages(dialog: any) { public setUnreadMessages(dialog: any) {
let dom = this.getDialogDom(dialog.peerID); let dom = this.getDialogDom(dialog.peerID);
if(dialog.peerID == 228260936) {
console.log('dialog setUnreadMessages', dialog);
}
dom.statusSpan.innerHTML = ''; dom.statusSpan.innerHTML = '';
let lastMessage = appMessagesManager.getMessage(dialog.top_message); let lastMessage = appMessagesManager.getMessage(dialog.top_message);
if(lastMessage._ != 'messageEmpty' && if(lastMessage._ != 'messageEmpty' &&
@ -380,7 +376,7 @@ export class AppDialogsManager {
let outgoing = (lastMessage.pFlags && lastMessage.pFlags.unread) let outgoing = (lastMessage.pFlags && lastMessage.pFlags.unread)
/* && dialog.read_outbox_max_id != 0 */; // maybe uncomment, 31.01.2020 /* && dialog.read_outbox_max_id != 0 */; // maybe uncomment, 31.01.2020
console.log('outgoing', outgoing, lastMessage); //console.log('outgoing', outgoing, lastMessage);
if(outgoing) { if(outgoing) {
dom.statusSpan.classList.remove('tgico-checks'); dom.statusSpan.classList.remove('tgico-checks');

66
src/lib/appManagers/appImManager.ts

@ -1,5 +1,5 @@
import apiManager from '../mtproto/apiManager'; import apiManager from '../mtproto/apiManager';
import { $rootScope, isElementInViewport, numberWithCommas, findUpClassName, formatNumber, placeCaretAtEnd, calcImageInBox, findUpTag } from "../utils"; import { $rootScope, isElementInViewport, numberWithCommas, findUpClassName, formatNumber, placeCaretAtEnd, calcImageInBox, findUpTag, getRichValue, getRichValueWithCaret, getSelectedText } from "../utils";
import appUsersManager from "./appUsersManager"; import appUsersManager from "./appUsersManager";
import appMessagesManager from "./appMessagesManager"; import appMessagesManager from "./appMessagesManager";
import appPeersManager from "./appPeersManager"; import appPeersManager from "./appPeersManager";
@ -140,7 +140,7 @@ class ChatInput {
this.messageInput.addEventListener('keydown', (e: KeyboardEvent) => { this.messageInput.addEventListener('keydown', (e: KeyboardEvent) => {
if(e.key == 'Enter') { if(e.key == 'Enter') {
if(e.shiftKey) { if(e.shiftKey || e.ctrlKey) {
return; return;
} }
@ -201,29 +201,36 @@ class ChatInput {
} }
}); });
this.messageInput.addEventListener('copy', (e) => { if(!RichTextProcessor.emojiSupported) {
const selection = document.getSelection(); this.messageInput.addEventListener('copy', (e) => {
const selection = document.getSelection();
let range = selection.getRangeAt(0); let range = selection.getRangeAt(0);
let ancestorContainer = range.commonAncestorContainer; let ancestorContainer = range.commonAncestorContainer;
let str = ''; let str = '';
let selectedNodes = Array.from(ancestorContainer.childNodes).slice(range.startOffset, range.endOffset); let selectedNodes = Array.from(ancestorContainer.childNodes).slice(range.startOffset, range.endOffset);
if(selectedNodes.length) { if(selectedNodes.length) {
str = this.serializeNodes(selectedNodes); str = this.serializeNodes(selectedNodes);
} else { } else {
str = selection.toString(); str = selection.toString();
} }
console.log('messageInput copy', str, ancestorContainer.childNodes, range); //console.log('messageInput copy', str, ancestorContainer.childNodes, range);
// @ts-ignore //let str = getRichValueWithCaret(this.messageInput);
event.clipboardData.setData('text/plain', str); //console.log('messageInput childNode copy:', str);
event.preventDefault();
}); // @ts-ignore
event.clipboardData.setData('text/plain', str);
event.preventDefault();
});
}
this.messageInput.addEventListener('paste', (e) => { this.messageInput.addEventListener('paste', (e) => {
//console.log('messageInput paste');
e.preventDefault(); e.preventDefault();
// @ts-ignore // @ts-ignore
let text = (e.originalEvent || e).clipboardData.getData('text/plain'); let text = (e.originalEvent || e).clipboardData.getData('text/plain');
@ -321,11 +328,14 @@ class ChatInput {
return; return;
} }
//console.log('document paste');
// @ts-ignore // @ts-ignore
var items = (event.clipboardData || event.originalEvent.clipboardData).items; var items = (event.clipboardData || event.originalEvent.clipboardData).items;
//console.log('item', event.clipboardData.getData()); //console.log('item', event.clipboardData.getData());
for(let i = 0; i < items.length; ++i) { for(let i = 0; i < items.length; ++i) {
if(items[i].kind == 'file') { if(items[i].kind == 'file') {
event.preventDefault()
event.cancelBubble = true; event.cancelBubble = true;
event.stopPropagation(); event.stopPropagation();
@ -398,16 +408,19 @@ class ChatInput {
if(typeof(child) === 'object' && child.textContent) return str += child.textContent; if(typeof(child) === 'object' && child.textContent) return str += child.textContent;
if(child.innerText) return str += child.innerText; if(child.innerText) return str += child.innerText;
if(child.tagName == 'IMG' && child.classList && child.classList.contains('emoji')) return str += child.getAttribute('emoji'); if(child.tagName == 'IMG' && child.classList && child.classList.contains('emoji')) return str += child.getAttribute('alt');
return str; return str;
}, ''); }, '');
}; };
public sendMessage() { public sendMessage() {
let str = this.serializeNodes(Array.from(this.messageInput.childNodes)); //let str = this.serializeNodes(Array.from(this.messageInput.childNodes));
let str = getRichValue(this.messageInput);
//console.log('childnode str after:', str/* , getRichValue(this.messageInput) */);
//console.log('childnode str after:', str); //return;
this.lastUrl = ''; this.lastUrl = '';
appMessagesManager.sendText(appImManager.peerID, str, { appMessagesManager.sendText(appImManager.peerID, str, {
replyToMsgID: appImManager.replyToMsgID == 0 ? undefined : appImManager.replyToMsgID, replyToMsgID: appImManager.replyToMsgID == 0 ? undefined : appImManager.replyToMsgID,
@ -770,6 +783,12 @@ export class AppImManager {
return; return;
} }
if(e.key == 'Meta' || e.key == 'Control') {
return;
} else if(e.key == 'c' && (e.ctrlKey || e.metaKey) && target.tagName != 'INPUT') {
return;
}
if(e.target != this.chatInputC.messageInput && target.tagName != 'INPUT') { if(e.target != this.chatInputC.messageInput && target.tagName != 'INPUT') {
this.chatInputC.messageInput.focus(); this.chatInputC.messageInput.focus();
placeCaretAtEnd(this.chatInputC.messageInput); placeCaretAtEnd(this.chatInputC.messageInput);
@ -1465,6 +1484,7 @@ export class AppImManager {
} }
public renderMessage(message: any, reverse = false, multipleRender?: boolean, bubble: HTMLDivElement = null) { public renderMessage(message: any, reverse = false, multipleRender?: boolean, bubble: HTMLDivElement = null) {
this.log('message to render:', message);
if(message.deleted) return; if(message.deleted) return;
let peerID = this.peerID; let peerID = this.peerID;
@ -1473,8 +1493,6 @@ export class AppImManager {
let messageDiv = document.createElement('div'); let messageDiv = document.createElement('div');
messageDiv.classList.add('message'); messageDiv.classList.add('message');
this.log('message to render:', message);
//messageDiv.innerText = message.message; //messageDiv.innerText = message.message;
// bubble // bubble
@ -1824,7 +1842,7 @@ export class AppImManager {
let originalMessage = appMessagesManager.getMessage(message.reply_to_mid); let originalMessage = appMessagesManager.getMessage(message.reply_to_mid);
let originalPeerTitle = appPeersManager.getPeerTitle(originalMessage.fromID) || ''; let originalPeerTitle = appPeersManager.getPeerTitle(originalMessage.fromID) || '';
this.log('message to render reply', originalMessage, originalPeerTitle, bubble); this.log('message to render reply', originalMessage, originalPeerTitle, bubble, message);
let originalText = ''; let originalText = '';
if(originalMessage.message) { if(originalMessage.message) {

42
src/lib/appManagers/appMessagesManager.ts

@ -62,7 +62,7 @@ export class AppMessagesManager {
public maxSeenID = 0; public maxSeenID = 0;
public allDialogsLoaded: {[folder_id: number]: boolean} = {}; public allDialogsLoaded: {[folder_id: number]: boolean} = {};
public dialogsOffsetDate = 0; public dialogsOffsetDate: {[folder_id: number]: number} = {};
public pinnedIndex = 0; public pinnedIndex = 0;
public dialogsNum = 0; public dialogsNum = 0;
@ -73,8 +73,8 @@ export class AppMessagesManager {
public newMessagesToHandle: any = {}; public newMessagesToHandle: any = {};
public newDialogsHandlePromise = 0; public newDialogsHandlePromise = 0;
public newDialogsToHandle: any = {}; public newDialogsToHandle: any = {};
public notificationsHandlePromise = 0; //public notificationsHandlePromise = 0;
public notificationsToHandle: any = {}; //public notificationsToHandle: any = {};
public newUpdatesAfterReloadToHandle: any = {}; public newUpdatesAfterReloadToHandle: any = {};
public fwdMessagesPluralize = _('conversation_forwarded_X_messages'); public fwdMessagesPluralize = _('conversation_forwarded_X_messages');
@ -802,9 +802,9 @@ export class AppMessagesManager {
var offsetIndex = 0; var offsetIndex = 0;
var flags = 0; var flags = 0;
if(this.dialogsOffsetDate) { if(this.dialogsOffsetDate[folderID]) {
offsetDate = this.dialogsOffsetDate + serverTimeManager.serverTimeOffset; offsetDate = this.dialogsOffsetDate[folderID] + serverTimeManager.serverTimeOffset;
offsetIndex = this.dialogsOffsetDate * 0x10000; offsetIndex = this.dialogsOffsetDate[folderID] * 0x10000;
flags |= 1; flags |= 1;
} }
@ -898,7 +898,7 @@ export class AppMessagesManager {
return (date * 0x10000) + ((++this.dialogsNum) & 0xFFFF); return (date * 0x10000) + ((++this.dialogsNum) & 0xFFFF);
} }
public pushDialogToStorage(dialog: any, offsetDate?: any) { public pushDialogToStorage(dialog: any, offsetDate?: number) {
var dialogs = this.dialogsStorage.dialogs; var dialogs = this.dialogsStorage.dialogs;
var pos = this.getDialogByPeerID(dialog.peerID)[1]; var pos = this.getDialogByPeerID(dialog.peerID)[1];
if(pos !== undefined) { if(pos !== undefined) {
@ -907,12 +907,12 @@ export class AppMessagesManager {
if(offsetDate && if(offsetDate &&
!dialog.pFlags.pinned && !dialog.pFlags.pinned &&
(!this.dialogsOffsetDate || offsetDate < this.dialogsOffsetDate)) { (!this.dialogsOffsetDate[dialog.folder_id] || offsetDate < this.dialogsOffsetDate[dialog.folder_id])) {
if(pos !== undefined) { if(pos !== undefined) {
// So the dialog jumped to the last position // So the dialog jumped to the last position
return false; return false;
} }
this.dialogsOffsetDate = offsetDate; this.dialogsOffsetDate[dialog.folder_id] = offsetDate;
} }
var index = dialog.index; var index = dialog.index;
@ -1092,7 +1092,7 @@ export class AppMessagesManager {
if(apiMessage.action) { if(apiMessage.action) {
var migrateFrom; var migrateFrom;
var migrateTo; var migrateTo;
switch (apiMessage.action._) { switch(apiMessage.action._) {
case 'messageActionChatEditPhoto': case 'messageActionChatEditPhoto':
appPhotosManager.savePhoto(apiMessage.action.photo, mediaContext); appPhotosManager.savePhoto(apiMessage.action.photo, mediaContext);
if(isBroadcast) { if(isBroadcast) {
@ -1332,9 +1332,7 @@ export class AppMessagesManager {
dialog.top_message = mid; dialog.top_message = mid;
dialog.read_inbox_max_id = appMessagesIDsManager.getFullMessageID(dialog.read_inbox_max_id, channelID); dialog.read_inbox_max_id = appMessagesIDsManager.getFullMessageID(dialog.read_inbox_max_id, channelID);
//peerID == 228260936 && console.log('we get drunk', dialog, dialog.read_outbox_max_id);
dialog.read_outbox_max_id = appMessagesIDsManager.getFullMessageID(dialog.read_outbox_max_id, channelID); dialog.read_outbox_max_id = appMessagesIDsManager.getFullMessageID(dialog.read_outbox_max_id, channelID);
//peerID == 228260936 && console.log('we get high', dialog, dialog.read_outbox_max_id);
var topDate = message.date; var topDate = message.date;
if(channelID) { if(channelID) {
@ -1398,11 +1396,11 @@ export class AppMessagesManager {
}*/ // WARNING }*/ // WARNING
} }
public handleNotifications() { /*public handleNotifications() {
clearTimeout(this.notificationsHandlePromise); clearTimeout(this.notificationsHandlePromise);
this.notificationsHandlePromise = 0; this.notificationsHandlePromise = 0;
var timeout = $rootScope.idle.isIDLE /* && StatusManager.isOtherDeviceActive() */ ? 30000 : 1000; var timeout = $rootScope.idle.isIDLE /* && StatusManager.isOtherDeviceActive() * ? 30000 : 1000;
Object.keys(this.notificationsToHandle).forEach((key: any) => { Object.keys(this.notificationsToHandle).forEach((key: any) => {
let notifyPeerToHandle = this.notificationsToHandle[key]; let notifyPeerToHandle = this.notificationsToHandle[key];
notifyPeerToHandle.isMutedPromise.then((muted: boolean) => { notifyPeerToHandle.isMutedPromise.then((muted: boolean) => {
@ -1423,9 +1421,9 @@ export class AppMessagesManager {
}); });
this.notificationsToHandle = {}; this.notificationsToHandle = {};
} }*/
public notifyAboutMessage(message: any, options: any = {}) { /*public notifyAboutMessage(message: any, options: any = {}) {
var peerID = this.getMessagePeer(message); var peerID = this.getMessagePeer(message);
var peerString: string; var peerString: string;
var notification: any = {}; var notification: any = {};
@ -1623,7 +1621,7 @@ export class AppMessagesManager {
notification.silent = message.pFlags.silent || false notification.silent = message.pFlags.silent || false
if(notificationPhoto.location && !notificationPhoto.location.empty) { if(notificationPhoto.location && !notificationPhoto.location.empty) {
apiFileManager.downloadSmallFile(notificationPhoto.location/* , notificationPhoto.size */) apiFileManager.downloadSmallFile(notificationPhoto.location/* , notificationPhoto.size *)
.then((blob) => { .then((blob) => {
if(message.pFlags.unread) { if(message.pFlags.unread) {
notification.image = blob notification.image = blob
@ -1633,7 +1631,7 @@ export class AppMessagesManager {
} else { } else {
// NotificationsManager.notify(notification) // warning // NotificationsManager.notify(notification) // warning
} }
} }*/
public mergeReplyKeyboard(historyStorage: any, message: any) { public mergeReplyKeyboard(historyStorage: any, message: any) {
// console.log('merge', message.mid, message.reply_markup, historyStorage.reply_markup) // console.log('merge', message.mid, message.reply_markup, historyStorage.reply_markup)
@ -2249,13 +2247,13 @@ export class AppMessagesManager {
this.newDialogsHandlePromise = window.setTimeout(this.handleNewDialogs.bind(this), 0); this.newDialogsHandlePromise = window.setTimeout(this.handleNewDialogs.bind(this), 0);
} }
if(inboxUnread && /*if(inboxUnread &&
($rootScope.selectedPeerID != peerID || $rootScope.idle.isIDLE)) { ($rootScope.selectedPeerID != peerID || $rootScope.idle.isIDLE)) {
var notifyPeer = message.flags & 16 ? message.from_id : peerID; var notifyPeer = message.flags & 16 ? message.from_id : peerID;
var notifyPeerToHandle = this.notificationsToHandle[notifyPeer]; var notifyPeerToHandle = this.notificationsToHandle[notifyPeer];
if(notifyPeerToHandle === undefined) { if(notifyPeerToHandle === undefined) {
notifyPeerToHandle = this.notificationsToHandle[notifyPeer] = { notifyPeerToHandle = this.notificationsToHandle[notifyPeer] = {
isMutedPromise: Promise.resolve()/* NotificationsManager.getPeerMuted(notifyPeer) */, // WARNING isMutedPromise: Promise.resolve()/* NotificationsManager.getPeerMuted(notifyPeer), // WARNING
fwd_count: 0, fwd_count: 0,
from_id: 0 from_id: 0
}; };
@ -2274,7 +2272,7 @@ export class AppMessagesManager {
if(!this.notificationsHandlePromise) { if(!this.notificationsHandlePromise) {
this.notificationsHandlePromise = window.setTimeout(this.handleNotifications.bind(this), 1000); this.notificationsHandlePromise = window.setTimeout(this.handleNotifications.bind(this), 1000);
} }
} } */
break; break;
} }
@ -3137,6 +3135,8 @@ export class AppMessagesManager {
timeout: 300, timeout: 300,
noErrorBox: true noErrorBox: true
}).then((historyResult: any) => { }).then((historyResult: any) => {
console.log('requestHistory result:', historyResult);
appUsersManager.saveApiUsers(historyResult.users); appUsersManager.saveApiUsers(historyResult.users);
appChatsManager.saveApiChats(historyResult.chats); appChatsManager.saveApiChats(historyResult.chats);
this.saveMessages(historyResult.messages); this.saveMessages(historyResult.messages);

7
src/lib/appManagers/appSidebarLeft.ts

@ -107,7 +107,12 @@ class AppSidebarLeft {
this.savedBtn.addEventListener('click', (e) => { this.savedBtn.addEventListener('click', (e) => {
this.log('savedbtn click'); this.log('savedbtn click');
setTimeout(() => { // menu doesn't close if no timeout (lol) setTimeout(() => { // menu doesn't close if no timeout (lol)
appImManager.setPeer(appImManager.myID); let dom = appDialogsManager.getDialogDom(appImManager.myID);
if(dom) {
dom.listEl.click();
} else {
appImManager.setPeer(appImManager.myID);
}
}, 0); }, 0);
}); });

4
src/lib/appManagers/appStickersManager.ts

@ -146,6 +146,10 @@ class appStickersManager {
return await promise; return await promise;
} }
public async cleanup() { // if logout
await AppStorage.remove('stickerSets');
}
} }
export default new appStickersManager(); export default new appStickersManager();

2
src/lib/appManagers/appWebPagesManager.ts

@ -1,4 +1,4 @@
import { $rootScope, safeReplaceObject, templateUrl, calcImageInBox, encodeEntities, copy } from "../utils"; import { $rootScope, safeReplaceObject, calcImageInBox, encodeEntities, copy } from "../utils";
import appPhotosManager from "./appPhotosManager"; import appPhotosManager from "./appPhotosManager";
import appDocsManager from "./appDocsManager"; import appDocsManager from "./appDocsManager";
import { RichTextProcessor } from "../richtextprocessor"; import { RichTextProcessor } from "../richtextprocessor";

4
src/lib/mtproto/apiManager.ts

@ -75,12 +75,12 @@ export class ApiManager {
} }
return Promise.all(logoutPromises).then(() => { return Promise.all(logoutPromises).then(() => {
AppStorage.remove('dc', 'user_auth'); AppStorage.remove('dc', 'user_auth', 'stickerSets');
this.baseDcID = 0; this.baseDcID = 0;
this.telegramMeNotify(false); this.telegramMeNotify(false);
return this.mtpClearStorage(); return this.mtpClearStorage();
}, (error) => { }, (error) => {
storageKeys.push('dc', 'user_auth'); storageKeys.push('dc', 'user_auth', 'stickerSets');
AppStorage.remove(storageKeys); AppStorage.remove(storageKeys);
this.baseDcID = 0; this.baseDcID = 0;
error.handled = true; error.handled = true;

7
src/lib/richtextprocessor.js

@ -514,9 +514,9 @@ function wrapRichText (text, options = {}) {
*///html.push(`<span class="emoji-outer emoji-sizer" contenteditable="false">${emojiSupported ? encodeEntities(entityText) : inner}\u200B</span>`); *///html.push(`<span class="emoji-outer emoji-sizer" contenteditable="false">${emojiSupported ? encodeEntities(entityText) : inner}\u200B</span>`);
//} //}
inner = `<img src="assets/img/blank.gif" alt="" class="emoji" style="background: url(${emojiData.sheetUrl}${entity.coords.sheetNo}.png); inner = `<img src="assets/img/blank.gif" alt="${encodeEntities(entityText)}" class="emoji" style="background: url(${emojiData.sheetUrl}${entity.coords.sheetNo}.png);
background-position:${entity.coords.column}% ${entity.coords.row}%; background-position:${entity.coords.column}% ${entity.coords.row}%;
background-size:${emojiData.sizeX}% ${emojiData.sizeY}%" emoji="${encodeEntities(entityText)}">`; background-size:${emojiData.sizeX}% ${emojiData.sizeY}%">`;
//html.push(`<span class="emoji-outer emoji-sizer" contenteditable="false">${emojiSupported ? encodeEntities(entityText) : inner}\u200B</span>`); //html.push(`<span class="emoji-outer emoji-sizer" contenteditable="false">${emojiSupported ? encodeEntities(entityText) : inner}\u200B</span>`);
@ -784,7 +784,8 @@ let RichTextProcessor = {
parseMarkdown: parseMarkdown, parseMarkdown: parseMarkdown,
parseEmojis: parseEmojis, parseEmojis: parseEmojis,
mergeEntities: mergeEntities, mergeEntities: mergeEntities,
getEmojiSpritesheetCoords: getEmojiSpritesheetCoords getEmojiSpritesheetCoords: getEmojiSpritesheetCoords,
emojiSupported: emojiSupported
}; };
window.RichTextProcessor = RichTextProcessor; window.RichTextProcessor = RichTextProcessor;

63
src/lib/utils.js

@ -172,12 +172,12 @@ export function getRichValueWithCaret (field) {
var selOffset var selOffset
if (sel && sel.rangeCount) { if (sel && sel.rangeCount) {
var range = sel.getRangeAt(0) var range = sel.getRangeAt(0)
if (range.startContainer && /* if (range.startContainer &&
range.startContainer == range.endContainer && range.startContainer == range.endContainer &&
range.startOffset == range.endOffset) { range.startOffset == range.endOffset) { */
selNode = range.startContainer selNode = range.startContainer
selOffset = range.startOffset selOffset = range.startOffset
} //}
} }
getRichElementValue(field, lines, line, selNode, selOffset) getRichElementValue(field, lines, line, selNode, selOffset)
@ -312,7 +312,35 @@ export const $rootScope = {
} }
}; };
export const _ = (str/* : string */) => str; export const langPack = {
"messageActionChatCreate": "created the group",
"messageActionChatEditTitle": "changed group name",
"messageActionChatEditPhoto": "changed group photo",
"messageActionChatDeletePhoto": "removed group photo",
"messageActionChatReturn": "returned to group",
"messageActionChatJoined": "joined the group",
"messageActionChatAddUser": "invited {user}",
"messageActionChatAddUsers": "invited {} users",
"messageActionChatLeave": "left group",
"messageActionChatDeleteUser": "removed user",
"messageActionChatJoinedByLink": "joined the group",
"messageActionChannelCreate": "Channel created",
"messageActionChannelEditTitle": "Channel renamed",
"messageActionChannelEditPhoto": "Channel photo updated",
"messageActionChannelDeletePhoto": "Channel photo removed",
"messageActionPinMessage": "pinned message",
"messageActionPhoneCall.in_ok": "Incoming Call",
"messageActionPhoneCall.out_ok": "Outgoing Call",
"messageActionPhoneCall.in_missed": "Missed Call",
"messageActionPhoneCall.out_missed": "Cancelled Call",
};
export const _ = (str/* : string */) => {
str = str.replace('_raw', '');
return langPack[str] ? langPack[str] : str;
};
export function isObject(object) { export function isObject(object) {
return typeof(object) === 'object' && object !== null; return typeof(object) === 'object' && object !== null;
@ -540,33 +568,6 @@ export function listUniqSorted (list) {
return resultList return resultList
} }
export function templateUrl (tplName) {
var forceLayout = {
confirm_modal: 'desktop',
error_modal: 'desktop',
media_modal_layout: 'desktop',
slider: 'desktop',
reply_message: 'desktop',
full_round: 'desktop',
message_body: 'desktop',
message_media: 'desktop',
message_attach_game: 'desktop',
forwarded_messages: 'desktop',
chat_invite_link_modal: 'desktop',
reply_markup: 'desktop',
short_message: 'desktop',
pinned_message: 'desktop',
channel_edit_modal: 'desktop',
megagroup_edit_modal: 'desktop',
inline_results: 'desktop',
composer_dropdown: 'desktop',
peer_pinned_message_bar: 'desktop',
report_msgs_modal: 'desktop'
}
var layout = forceLayout[tplName] || (Config.Mobile ? 'mobile' : 'desktop')
return 'partials/' + layout + '/' + tplName + '.html'
}
export function encodeEntities (value) { export function encodeEntities (value) {
return value.replace(/&/g, '&amp;').replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, function (value) { return value.replace(/&/g, '&amp;').replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, function (value) {
var hi = value.charCodeAt(0) var hi = value.charCodeAt(0)

Loading…
Cancel
Save