mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 20:16:08 +08:00
Update to Twemoji 12 and switch to 'simple-emoji-map' (#20)
This commit is contained in:
parent
7ae9b1263b
commit
5fe1de86dc
1510
extensions/emoji/js/package-lock.json
generated
1510
extensions/emoji/js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -2,18 +2,15 @@
|
|||
"private": true,
|
||||
"name": "@flarum/emoji",
|
||||
"dependencies": {
|
||||
"emojibase-data": "^3.2.0",
|
||||
"flarum-webpack-config": "0.1.0-beta.10",
|
||||
"simple-emoji-map": "^0.3.0",
|
||||
"textarea-caret": "^3.1.0",
|
||||
"twemoji": "^11.2.0",
|
||||
"webpack": "^4.26.0",
|
||||
"webpack-cli": "^3.1.2"
|
||||
"twemoji": "^12.1.2",
|
||||
"webpack": "^4.35.3",
|
||||
"webpack-cli": "^3.3.5"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "webpack --mode development --watch",
|
||||
"build": "webpack --mode production",
|
||||
"predev": "npm run generate-emoji-map",
|
||||
"prebuild": "npm run generate-emoji-map",
|
||||
"generate-emoji-map": "node ./scripts/generate-emoji-map.js"
|
||||
"build": "webpack --mode production"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const twemoji = require('twemoji/2/twemoji.npm');
|
||||
|
||||
const outputPath = './src/forum/generated/emojiMap.json';
|
||||
const data = require('emojibase-data/en/data.json');
|
||||
const twemojiFileNames = fs.readdirSync('./node_modules/twemoji/2/svg')
|
||||
.map(name => path.basename(name, '.svg'));
|
||||
|
||||
const alternative = {
|
||||
"👁️🗨️" : "👁🗨",
|
||||
};
|
||||
|
||||
const emojis = {};
|
||||
|
||||
for (let e of data) {
|
||||
const emoji = alternative[e.emoji] || e.emoji;
|
||||
const emojiCode = getEmojiIconCode(emoji);
|
||||
|
||||
if (!checkExistanceInTwemoji(emojiCode)) {
|
||||
console.error('Can not find', emoji, emojiCode);
|
||||
continue;
|
||||
}
|
||||
|
||||
emojis[emoji] = e.shortcodes;
|
||||
}
|
||||
|
||||
const outputDir = path.dirname(outputPath);
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir);
|
||||
}
|
||||
|
||||
fs.writeFileSync(outputPath, JSON.stringify(emojis));
|
||||
|
||||
function checkExistanceInTwemoji(code) {
|
||||
return twemojiFileNames.indexOf(code) != -1;
|
||||
}
|
||||
|
||||
function getEmojiIconCode(emoji) {
|
||||
const U200D = String.fromCharCode(0x200D);
|
||||
return twemoji.convert.toCodePoint(emoji.indexOf(U200D) < 0 ?
|
||||
emoji.replace(/\uFE0F/g, '') :
|
||||
emoji
|
||||
);
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import getCaretCoordinates from 'textarea-caret';
|
||||
import emojiMap from 'simple-emoji-map';
|
||||
|
||||
import { extend } from 'flarum/extend';
|
||||
import ComposerBody from 'flarum/components/ComposerBody';
|
||||
import TextEditor from 'flarum/components/TextEditor';
|
||||
import TextEditorButton from 'flarum/components/TextEditorButton';
|
||||
import emojiMap from './generated/emojiMap.json';
|
||||
import getEmojiIconCode from './helpers/getEmojiIconCode';
|
||||
import KeyboardNavigatable from 'flarum/utils/KeyboardNavigatable';
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
https://github.com/twitter/twemoji/blob/gh-pages/LICENSE
|
||||
*/
|
||||
|
||||
import twemoji from 'twemoji/2/twemoji.npm';
|
||||
import twemoji from 'twemoji';
|
||||
|
||||
// avoid using a string literal like '\u200D' here because minifiers expand it inline
|
||||
const U200D = String.fromCharCode(0x200D);
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import { override } from 'flarum/extend';
|
||||
import app from 'flarum/app';
|
||||
import Post from 'flarum/models/Post';
|
||||
|
||||
import addComposerAutocomplete from './addComposerAutocomplete';
|
||||
import renderEmoji from './renderEmoji';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*global s9e*/
|
||||
|
||||
import twemoji from 'twemoji/2/twemoji.npm';
|
||||
import twemoji from 'twemoji';
|
||||
|
||||
import { override } from 'flarum/extend';
|
||||
import Post from 'flarum/models/Post';
|
||||
|
|
Loading…
Reference in New Issue
Block a user