Browse Source

Fix setting target on stickers helper

Remove \uFE0F in emoji helper
Fix emoji helper layout
master
morethanwords 4 years ago
parent
commit
671e7140d5
  1. 8
      src/components/chat/input.ts
  2. 10
      src/components/emoticonsDropdown/tabs/emoji.ts
  3. 1
      src/helpers/dom/attachListNavigation.ts
  4. 17
      src/lib/richtextprocessor.ts
  5. 8
      src/scss/partials/_chatEmojiHelper.scss

8
src/components/chat/input.ts

@ -60,7 +60,6 @@ import { MarkdownType, markdownTags } from '../../helpers/dom/getRichElementValu
import getRichValueWithCaret from '../../helpers/dom/getRichValueWithCaret'; import getRichValueWithCaret from '../../helpers/dom/getRichValueWithCaret';
import EmojiHelper from './emojiHelper'; import EmojiHelper from './emojiHelper';
import setRichFocus from '../../helpers/dom/setRichFocus'; import setRichFocus from '../../helpers/dom/setRichFocus';
import { toCodePoints } from '../../vendor/emoji';
const RECORD_MIN_TIME = 500; const RECORD_MIN_TIME = 500;
const POSTING_MEDIA_NOT_ALLOWED = 'Posting media content isn\'t allowed in this group.'; const POSTING_MEDIA_NOT_ALLOWED = 'Posting media content isn\'t allowed in this group.';
@ -1162,12 +1161,7 @@ export default class ChatInput {
const hadEntities = RichTextProcessor.parseEntities(fullValue); const hadEntities = RichTextProcessor.parseEntities(fullValue);
RichTextProcessor.mergeEntities(entities, hadEntities); RichTextProcessor.mergeEntities(entities, hadEntities);
const emojiEntity: MessageEntity.messageEntityEmoji = { const emojiEntity = RichTextProcessor.getEmojiEntityFromEmoji(emoji);
_: 'messageEntityEmoji',
offset: 0,
length: emoji.length,
unicode: toCodePoints(emoji).join('-')
};
const addEntities: MessageEntity[] = [emojiEntity]; const addEntities: MessageEntity[] = [emojiEntity];
emojiEntity.offset = matchIndex; emojiEntity.offset = matchIndex;
addEntities.push({ addEntities.push({

10
src/components/emoticonsDropdown/tabs/emoji.ts

@ -13,7 +13,6 @@ import Config from "../../../lib/config";
import { i18n, LangPackKey } from "../../../lib/langPack"; import { i18n, LangPackKey } from "../../../lib/langPack";
import { RichTextProcessor } from "../../../lib/richtextprocessor"; import { RichTextProcessor } from "../../../lib/richtextprocessor";
import rootScope from "../../../lib/rootScope"; import rootScope from "../../../lib/rootScope";
import { toCodePoints } from "../../../vendor/emoji";
import { putPreloader } from "../../misc"; import { putPreloader } from "../../misc";
import Scrollable from "../../scrollable"; import Scrollable from "../../scrollable";
import StickyIntersector from "../../stickyIntersector"; import StickyIntersector from "../../stickyIntersector";
@ -29,14 +28,7 @@ export function appendEmoji(emoji: string, container: HTMLElement, prepend = fal
let kek: string; let kek: string;
if(unify) { if(unify) {
kek = RichTextProcessor.wrapRichText(emoji, { kek = RichTextProcessor.wrapSingleEmoji(emoji);
entities: [{
_: 'messageEntityEmoji',
offset: 0,
length: emoji.length,
unicode: toCodePoints(emoji).join('-')
}]
});
} else { } else {
kek = RichTextProcessor.wrapEmojiText(emoji); kek = RichTextProcessor.wrapEmojiText(emoji);
} }

1
src/helpers/dom/attachListNavigation.ts

@ -155,6 +155,7 @@ export default function attachListNavigation({list, type, onSelect, once, waitFo
onKeyDown = _onKeyDown; onKeyDown = _onKeyDown;
document.addEventListener(HANDLE_EVENT, onKeyDown, {capture: true, passive: false}); document.addEventListener(HANDLE_EVENT, onKeyDown, {capture: true, passive: false});
waitForKey = undefined;
resetTarget(); resetTarget();
} }
}; };

17
src/lib/richtextprocessor.ts

@ -12,7 +12,7 @@
import Config from './config'; import Config from './config';
import emojiRegExp from '../vendor/emoji/regex'; import emojiRegExp from '../vendor/emoji/regex';
import { encodeEmoji } from '../vendor/emoji'; import { encodeEmoji, toCodePoints } from '../vendor/emoji';
import { MessageEntity } from '../layer'; import { MessageEntity } from '../layer';
import { encodeEntities } from '../helpers/string'; import { encodeEntities } from '../helpers/string';
import { isSafari } from '../helpers/userAgent'; import { isSafari } from '../helpers/userAgent';
@ -840,6 +840,21 @@ namespace RichTextProcessor {
export function isUsernameValid(username: string) { export function isUsernameValid(username: string) {
return ((username.length >= 5 && username.length <= 32) || !username.length) && /^[a-zA-Z0-9_]*$/.test(username); return ((username.length >= 5 && username.length <= 32) || !username.length) && /^[a-zA-Z0-9_]*$/.test(username);
} }
export function getEmojiEntityFromEmoji(emoji: string): MessageEntity.messageEntityEmoji {
return {
_: 'messageEntityEmoji',
offset: 0,
length: emoji.length,
unicode: toCodePoints(emoji).join('-').replace(/-?fe0f/g, '')
};
}
export function wrapSingleEmoji(emoji: string) {
return wrapRichText(emoji, {
entities: [getEmojiEntityFromEmoji(emoji)]
});
}
} }
MOUNT_CLASS_TO.RichTextProcessor = RichTextProcessor; MOUNT_CLASS_TO.RichTextProcessor = RichTextProcessor;

8
src/scss/partials/_chatEmojiHelper.scss

@ -7,8 +7,14 @@
} }
.super-emojis { .super-emojis {
display: block; display: flex;
white-space: nowrap; white-space: nowrap;
align-items: center;
justify-content: flex-start;
}
.super-emoji {
flex: 0 0 auto;
} }
.super-emoji:not(.active) { .super-emoji:not(.active) {

Loading…
Cancel
Save