Browse Source

Adding emoji-short-name package.

- Fixes #266
pull/1/head
Dessalines 2 years ago
parent
commit
d8b4398f1c
  1. 1
      package.json
  2. 4
      src/components/comment-form.tsx
  3. 1721
      src/twemojis.ts
  4. 12
      src/utils.ts
  5. 5
      yarn.lock

1
package.json

@ -23,6 +23,7 @@
"autosize": "^4.0.2",
"classcat": "^1.1.3",
"dotenv": "^6.1.0",
"emoji-short-name": "^0.1.0",
"i18next": "^17.0.9",
"inferno": "^7.0.1",
"inferno-i18next": "nimbusec-oss/inferno-i18next",

4
src/components/comment-form.tsx

@ -2,12 +2,12 @@ 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, mdToHtml, randomStr, imageUploadUrl, markdownHelpUrl } from '../utils';
import { twemojis } from '../twemojis';
import { WebSocketService, UserService } from '../services';
import * as autosize from 'autosize';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
import Tribute from 'tributejs/src/Tribute.js';
import * as emojiShortName from 'emoji-short-name';
interface CommentFormProps {
postId?: number;
@ -55,7 +55,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
selectTemplate: (item: any) => {
return `:${item.original.key}:`;
},
values: Object.entries(twemojis).map(e => {return {'key': e[0], 'val': e[1]}}),
values: Object.entries(emojiShortName).map(e => {return {'key': e[1], 'val': e[0]}}),
allowSpaces: false,
autocompleteMode: true,
menuItemLimit: 10,

1721
src/twemojis.ts
File diff suppressed because it is too large
View File

12
src/utils.ts

@ -12,7 +12,7 @@ import * as markdown_it from 'markdown-it';
import * as markdownitEmoji from 'markdown-it-emoji/light';
import * as markdown_it_container from 'markdown-it-container';
import * as twemoji from 'twemoji';
import { twemojis } from './twemojis';
import * as emojiShortName from 'emoji-short-name';
export const repoUrl = 'https://github.com/dessalines/lemmy';
export const imageUploadUrl = 'https://postimages.org/';
@ -50,7 +50,7 @@ export const md = new markdown_it({
}
}
}).use(markdownitEmoji, {
defs: twemojis
defs: objectFlip(emojiShortName)
});
md.renderer.rules.emoji = function(token, idx) {
@ -197,6 +197,14 @@ export function getLanguage(): string {
return (navigator.language || navigator.userLanguage);
}
export function objectFlip(obj: any) {
const ret = {};
Object.keys(obj).forEach((key) => {
ret[obj[key]] = key;
});
return ret;
}
export function getMomentLanguage(): string {
let lang = getLanguage();
if (lang.startsWith('zh')) {

5
yarn.lock

@ -782,6 +782,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
[email protected]^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/emoji-short-name/-/emoji-short-name-0.1.0.tgz#e2f0fd743e3e16384ae32f8a8b0ce6a47216e1d3"
integrity sha512-vpQaGMxBDC4VGHz52CjVKTJsGsgQ0YueEgQFyDkoanPIK3RgGMbHSjnek2viaCwgf8T6TKCR5v03O/SlfD7iFA==
[email protected]~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"

Loading…
Cancel
Save