mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-27 10:30:15 -05:00
Port emojimart 2.6.1 changes to glitch flavour
See also the following commits: -0c3ce41031
-268d90e810
This commit is contained in:
parent
4d8d1fa129
commit
fac6e392e9
@ -107,7 +107,7 @@ const mapDispatchToProps = (dispatch, { onPickEmoji }) => ({
|
|||||||
const assetHost = process.env.CDN_HOST || '';
|
const assetHost = process.env.CDN_HOST || '';
|
||||||
let EmojiPicker, Emoji; // load asynchronously
|
let EmojiPicker, Emoji; // load asynchronously
|
||||||
|
|
||||||
const backgroundImageFn = () => `${assetHost}/emoji/sheet.png`;
|
const backgroundImageFn = () => `${assetHost}/emoji/sheet_10.png`;
|
||||||
const listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
|
const listenerOptions = detectPassiveEvents.hasSupport ? { passive: true } : false;
|
||||||
|
|
||||||
const categoriesSort = [
|
const categoriesSort = [
|
||||||
|
@ -9,7 +9,14 @@ const { unicodeToFilename } = require('./unicode_to_filename');
|
|||||||
const { unicodeToUnifiedName } = require('./unicode_to_unified_name');
|
const { unicodeToUnifiedName } = require('./unicode_to_unified_name');
|
||||||
const emojiMap = require('./emoji_map.json');
|
const emojiMap = require('./emoji_map.json');
|
||||||
const { emojiIndex } = require('emoji-mart');
|
const { emojiIndex } = require('emoji-mart');
|
||||||
const { default: emojiMartData } = require('emoji-mart/dist/data');
|
const { uncompress: emojiMartUncompress } = require('emoji-mart/dist/utils/data');
|
||||||
|
let data = require('emoji-mart/data/all.json');
|
||||||
|
|
||||||
|
if(data.compressed) {
|
||||||
|
data = emojiMartUncompress(data);
|
||||||
|
}
|
||||||
|
const emojiMartData = data;
|
||||||
|
|
||||||
|
|
||||||
const excluded = ['®', '©', '™'];
|
const excluded = ['®', '©', '™'];
|
||||||
const skins = ['🏻', '🏼', '🏽', '🏾', '🏿'];
|
const skins = ['🏻', '🏼', '🏽', '🏾', '🏿'];
|
||||||
@ -88,6 +95,6 @@ module.exports = JSON.parse(JSON.stringify([
|
|||||||
shortCodesToEmojiData,
|
shortCodesToEmojiData,
|
||||||
emojiMartData.skins,
|
emojiMartData.skins,
|
||||||
emojiMartData.categories,
|
emojiMartData.categories,
|
||||||
emojiMartData.short_names,
|
emojiMartData.aliases,
|
||||||
emojisWithoutShortCodes,
|
emojisWithoutShortCodes,
|
||||||
]));
|
]));
|
||||||
|
@ -8,6 +8,7 @@ let originalPool = {};
|
|||||||
let index = {};
|
let index = {};
|
||||||
let emojisList = {};
|
let emojisList = {};
|
||||||
let emoticonsList = {};
|
let emoticonsList = {};
|
||||||
|
let customEmojisList = [];
|
||||||
|
|
||||||
for (let emoji in data.emojis) {
|
for (let emoji in data.emojis) {
|
||||||
let emojiData = data.emojis[emoji];
|
let emojiData = data.emojis[emoji];
|
||||||
@ -28,7 +29,18 @@ for (let emoji in data.emojis) {
|
|||||||
originalPool[id] = emojiData;
|
originalPool[id] = emojiData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearCustomEmojis(pool) {
|
||||||
|
customEmojisList.forEach((emoji) => {
|
||||||
|
let emojiId = emoji.id || emoji.short_names[0];
|
||||||
|
|
||||||
|
delete pool[emojiId];
|
||||||
|
delete emojisList[emojiId];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function addCustomToPool(custom, pool) {
|
function addCustomToPool(custom, pool) {
|
||||||
|
if (customEmojisList.length) clearCustomEmojis(pool);
|
||||||
|
|
||||||
custom.forEach((emoji) => {
|
custom.forEach((emoji) => {
|
||||||
let emojiId = emoji.id || emoji.short_names[0];
|
let emojiId = emoji.id || emoji.short_names[0];
|
||||||
|
|
||||||
@ -37,9 +49,13 @@ function addCustomToPool(custom, pool) {
|
|||||||
emojisList[emojiId] = getSanitizedData(emoji);
|
emojisList[emojiId] = getSanitizedData(emoji);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
customEmojisList = custom;
|
||||||
|
index = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
function search(value, { emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}) {
|
function search(value, { emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}) {
|
||||||
|
if (customEmojisList !== custom)
|
||||||
addCustomToPool(custom, originalPool);
|
addCustomToPool(custom, originalPool);
|
||||||
|
|
||||||
maxResults = maxResults || 75;
|
maxResults = maxResults || 75;
|
||||||
@ -143,7 +159,7 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
|
|||||||
|
|
||||||
if (results) {
|
if (results) {
|
||||||
if (emojisToShowFilter) {
|
if (emojisToShowFilter) {
|
||||||
results = results.filter((result) => emojisToShowFilter(data.emojis[result.id].unified));
|
results = results.filter((result) => emojisToShowFilter(data.emojis[result.id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results && results.length > maxResults) {
|
if (results && results.length > maxResults) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Picker from 'emoji-mart/dist-es/components/picker';
|
import Picker from 'emoji-mart/dist-es/components/picker/picker';
|
||||||
import Emoji from 'emoji-mart/dist-es/components/emoji';
|
import Emoji from 'emoji-mart/dist-es/components/emoji/emoji';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Picker,
|
Picker,
|
||||||
|
Loading…
Reference in New Issue
Block a user