parent
d99fa5268d
commit
f538b3fb22
4 changed files with 1729 additions and 15 deletions
7
ui/src/components/comment-form.tsx
vendored
7
ui/src/components/comment-form.tsx
vendored
|
@ -1,7 +1,8 @@
|
|||
import { Component, linkEvent } from 'inferno';
|
||||
import { CommentNode as CommentNodeI, CommentForm as CommentFormI, SearchForm, SearchType, SortType, UserOperation, SearchResponse } from '../interfaces';
|
||||
import { Subscription } from "rxjs";
|
||||
import { capitalizeFirstLetter, mentionDropdownFetchLimit, msgOp, md, emojiMentionList, mdToHtml, randomStr, imageUploadUrl, markdownHelpUrl } from '../utils';
|
||||
import { capitalizeFirstLetter, mentionDropdownFetchLimit, msgOp, mdToHtml, randomStr, imageUploadUrl, markdownHelpUrl } from '../utils';
|
||||
import { twemojis } from '../twemojis';
|
||||
import { WebSocketService, UserService } from '../services';
|
||||
import * as autosize from 'autosize';
|
||||
import { i18n } from '../i18next';
|
||||
|
@ -49,12 +50,12 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
|
|||
trigger: ':',
|
||||
menuItemTemplate: (item: any) => {
|
||||
let emoji = `:${item.original.key}:`;
|
||||
return `${md.renderInline(emoji)} ${emoji}`;
|
||||
return `${item.original.val} ${emoji}`;
|
||||
},
|
||||
selectTemplate: (item: any) => {
|
||||
return `:${item.original.key}:`;
|
||||
},
|
||||
values: emojiMentionList(),
|
||||
values: Object.entries(twemojis).map(e => {return {'key': e[0], 'val': e[1]}}),
|
||||
allowSpaces: false,
|
||||
autocompleteMode: true,
|
||||
menuItemLimit: 10,
|
||||
|
|
1
ui/src/emoji_list.ts
vendored
1
ui/src/emoji_list.ts
vendored
File diff suppressed because one or more lines are too long
1721
ui/src/twemojis.ts
vendored
Normal file
1721
ui/src/twemojis.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
15
ui/src/utils.ts
vendored
15
ui/src/utils.ts
vendored
|
@ -11,8 +11,8 @@ import { UserOperation, Comment, User, SortType, ListingType } from './interface
|
|||
import * as markdown_it from 'markdown-it';
|
||||
declare var markdownitEmoji: any;
|
||||
import * as markdown_it_container from 'markdown-it-container';
|
||||
import { emoji_list } from './emoji_list';
|
||||
import * as twemoji from 'twemoji';
|
||||
import { twemojis } from './twemojis';
|
||||
|
||||
export const repoUrl = 'https://github.com/dessalines/lemmy';
|
||||
export const imageUploadUrl = 'https://postimages.org/';
|
||||
|
@ -49,7 +49,9 @@ export const md = new markdown_it({
|
|||
return '</details>\n';
|
||||
}
|
||||
}
|
||||
}).use(markdownitEmoji);
|
||||
}).use(markdownitEmoji, {
|
||||
defs: twemojis
|
||||
});
|
||||
|
||||
md.renderer.rules.emoji = function(token, idx) {
|
||||
return twemoji.parse(token[idx].content);
|
||||
|
@ -195,15 +197,6 @@ export function getLanguage(): string {
|
|||
return (navigator.language || navigator.userLanguage);
|
||||
}
|
||||
|
||||
export function emojiMentionList(): Array<{}> {
|
||||
let keyedEmojis = [];
|
||||
for (let e of emoji_list) {
|
||||
let obj = {key: e};
|
||||
keyedEmojis.push(obj);
|
||||
}
|
||||
return keyedEmojis;
|
||||
}
|
||||
|
||||
export function getMomentLanguage(): string {
|
||||
let lang = getLanguage();
|
||||
if (lang.startsWith('zh')) {
|
||||
|
|
Loading…
Reference in a new issue